From df29260522bb804f0911a6bacaf44ecfba8542fc Mon Sep 17 00:00:00 2001 From: nhauge Date: Wed, 14 Nov 2007 00:00:40 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'v200711140100'. --- assembly/features/org.eclipse.jpt.sdk/.cvsignore | 4 - assembly/features/org.eclipse.jpt.sdk/.project | 17 - .../features/org.eclipse.jpt.sdk/build.properties | 15 - .../org.eclipse.jpt.sdk/eclipse_update_120.jpg | Bin 21695 -> 0 bytes assembly/features/org.eclipse.jpt.sdk/epl-v10.html | 328 --- .../org.eclipse.jpt.sdk/feature.properties | 145 -- assembly/features/org.eclipse.jpt.sdk/feature.xml | 38 - assembly/features/org.eclipse.jpt.sdk/license.html | 98 - assembly/features/org.eclipse.jpt.tests/.cvsignore | 2 - assembly/features/org.eclipse.jpt.tests/.project | 17 - .../.settings/org.eclipse.core.resources.prefs | 3 - .../org.eclipse.jpt.tests/build.properties | 5 - .../org.eclipse.jpt.tests/eclipse_update_120.jpg | Bin 21695 -> 0 bytes .../features/org.eclipse.jpt.tests/epl-v10.html | 328 --- .../org.eclipse.jpt.tests/feature.properties | 145 -- .../features/org.eclipse.jpt.tests/feature.xml | 28 - .../features/org.eclipse.jpt.tests/license.html | 98 - assembly/features/org.eclipse.jpt/.cvsignore | 2 - assembly/features/org.eclipse.jpt/.project | 17 - assembly/features/org.eclipse.jpt/build.properties | 16 - .../org.eclipse.jpt/eclipse_update_120.jpg | Bin 21695 -> 0 bytes assembly/features/org.eclipse.jpt/epl-v10.html | 328 --- .../features/org.eclipse.jpt/feature.properties | 144 -- assembly/features/org.eclipse.jpt/feature.xml | 38 - assembly/features/org.eclipse.jpt/license.html | 93 - assembly/plugins/org.eclipse.jpt/.cvsignore | 3 - assembly/plugins/org.eclipse.jpt/.project | 22 - .../.settings/org.eclipse.core.resources.prefs | 3 - .../plugins/org.eclipse.jpt/META-INF/MANIFEST.MF | 7 - assembly/plugins/org.eclipse.jpt/about.html | 34 - assembly/plugins/org.eclipse.jpt/about.ini | 44 - assembly/plugins/org.eclipse.jpt/about.mappings | 6 - assembly/plugins/org.eclipse.jpt/about.properties | 24 - assembly/plugins/org.eclipse.jpt/build.properties | 19 - assembly/plugins/org.eclipse.jpt/component.xml | 12 - assembly/plugins/org.eclipse.jpt/eclipse32.gif | Bin 1706 -> 0 bytes assembly/plugins/org.eclipse.jpt/eclipse32.png | Bin 4594 -> 0 bytes assembly/plugins/org.eclipse.jpt/plugin.properties | 13 - jpa/features/org.eclipse.jpt.feature/.project | 17 - .../.settings/org.eclipse.core.resources.prefs | 3 - .../org.eclipse.jpt.feature/build.properties | 15 - .../org.eclipse.jpt.feature/eclipse_update_120.jpg | Bin 21695 -> 0 bytes jpa/features/org.eclipse.jpt.feature/epl-v10.html | 328 --- .../org.eclipse.jpt.feature/feature.properties | 140 -- jpa/features/org.eclipse.jpt.feature/feature.xml | 121 - jpa/features/org.eclipse.jpt.feature/license.html | 98 - .../sourceTemplateFeature/build.properties | 16 - .../sourceTemplateFeature/eclipse_update_120.jpg | Bin 21695 -> 0 bytes .../sourceTemplateFeature/epl-v10.html | 328 --- .../sourceTemplateFeature/feature.properties | 145 -- .../sourceTemplateFeature/feature.xml | 26 - .../sourceTemplateFeature/license.html | 82 - .../sourceTemplatePlugin/about.html | 27 - .../sourceTemplatePlugin/about.ini | 31 - .../sourceTemplatePlugin/about.mappings | 6 - .../sourceTemplatePlugin/about.properties | 26 - .../sourceTemplatePlugin/build.properties | 11 - .../sourceTemplatePlugin/eclipse32.gif | Bin 1706 -> 0 bytes .../sourceTemplatePlugin/eclipse32.png | Bin 4634 -> 0 bytes .../sourceTemplatePlugin/eclipse_update_120.jpg | Bin 21695 -> 0 bytes .../sourceTemplatePlugin/epl-v10.html | 328 --- .../sourceTemplatePlugin/license.html | 83 - .../sourceTemplatePlugin/plugin.properties | 13 - .../org.eclipse.jpt.tests.feature/.project | 17 - .../.settings/org.eclipse.core.resources.prefs | 3 - .../org.eclipse.jpt.tests.feature/build.properties | 10 - .../eclipse_update_120.jpg | Bin 21695 -> 0 bytes .../org.eclipse.jpt.tests.feature/epl-v10.html | 328 --- .../feature.properties | 145 -- .../org.eclipse.jpt.tests.feature/feature.xml | 32 - .../org.eclipse.jpt.tests.feature/license.html | 98 - jpa/features/org.eclipse.jpt_sdk.feature/.project | 17 - .../.settings/org.eclipse.core.resources.prefs | 3 - .../org.eclipse.jpt_sdk.feature/build.properties | 9 - .../eclipse_update_120.jpg | Bin 21695 -> 0 bytes .../org.eclipse.jpt_sdk.feature/epl-v10.html | 328 --- .../org.eclipse.jpt_sdk.feature/feature.properties | 140 -- .../org.eclipse.jpt_sdk.feature/feature.xml | 28 - .../org.eclipse.jpt_sdk.feature/license.html | 98 - jpa/plugins/org.eclipse.jpt.db.ui/.classpath | 7 - jpa/plugins/org.eclipse.jpt.db.ui/.cvsignore | 3 - jpa/plugins/org.eclipse.jpt.db.ui/.project | 28 - .../.settings/org.eclipse.core.resources.prefs | 3 - .../.settings/org.eclipse.jdt.core.prefs | 7 - .../org.eclipse.jpt.db.ui/META-INF/MANIFEST.MF | 14 - jpa/plugins/org.eclipse.jpt.db.ui/about.html | 34 - jpa/plugins/org.eclipse.jpt.db.ui/build.properties | 17 - jpa/plugins/org.eclipse.jpt.db.ui/component.xml | 1 - .../org.eclipse.jpt.db.ui/plugin.properties | 25 - .../org/eclipse/jpt/db/ui/internal/DTPUiTools.java | 99 - jpa/plugins/org.eclipse.jpt.db/.classpath | 7 - jpa/plugins/org.eclipse.jpt.db/.cvsignore | 3 - jpa/plugins/org.eclipse.jpt.db/.project | 28 - .../.settings/org.eclipse.core.resources.prefs | 3 - .../.settings/org.eclipse.jdt.core.prefs | 7 - .../org.eclipse.jpt.db/META-INF/MANIFEST.MF | 15 - jpa/plugins/org.eclipse.jpt.db/about.html | 34 - jpa/plugins/org.eclipse.jpt.db/build.properties | 19 - jpa/plugins/org.eclipse.jpt.db/component.xml | 1 - jpa/plugins/org.eclipse.jpt.db/plugin.properties | 25 - .../src/org/eclipse/jpt/db/internal/Catalog.java | 108 - .../src/org/eclipse/jpt/db/internal/Column.java | 162 -- .../org/eclipse/jpt/db/internal/Connection.java | 66 - .../jpt/db/internal/ConnectionListener.java | 31 - .../eclipse/jpt/db/internal/ConnectionProfile.java | 259 --- .../db/internal/ConnectionProfileRepository.java | 253 -- .../db/internal/DTPConnectionProfileWrapper.java | 263 --- .../jpt/db/internal/DTPConnectionWrapper.java | 170 -- .../jpt/db/internal/DTPDatabaseWrapper.java | 229 -- .../src/org/eclipse/jpt/db/internal/DTPTools.java | 212 -- .../org/eclipse/jpt/db/internal/DTPWrapper.java | 52 - .../src/org/eclipse/jpt/db/internal/Database.java | 229 -- .../org/eclipse/jpt/db/internal/ForeignKey.java | 337 --- .../org/eclipse/jpt/db/internal/JptDbPlugin.java | 64 - .../eclipse/jpt/db/internal/NullConnection.java | 81 - .../jpt/db/internal/NullConnectionProfile.java | 192 -- .../org/eclipse/jpt/db/internal/NullDatabase.java | 109 - .../eclipse/jpt/db/internal/ProfileListener.java | 35 - .../src/org/eclipse/jpt/db/internal/Schema.java | 299 --- .../src/org/eclipse/jpt/db/internal/Sequence.java | 74 - .../src/org/eclipse/jpt/db/internal/Table.java | 359 --- jpa/plugins/org.eclipse.jpt.doc.user/.project | 22 - .../org.eclipse.jpt.doc.user/META-INF/MANIFEST.MF | 8 - jpa/plugins/org.eclipse.jpt.doc.user/about.html | 48 - .../org.eclipse.jpt.doc.user/build.properties | 102 - .../cheatsheets/add_persistence.xml | 63 - .../cheatsheets/create_entity.xml | 44 - .../cheatsheets/map_entity.xml | 88 - .../org.eclipse.jpt.doc.user/concept_mapping.htm | 51 - .../concept_persistence.htm | 46 - jpa/plugins/org.eclipse.jpt.doc.user/concepts.htm | 65 - .../org.eclipse.jpt.doc.user/concepts001.htm | 48 - .../org.eclipse.jpt.doc.user/concepts002.htm | 50 - .../org.eclipse.jpt.doc.user/concepts003.htm | 51 - jpa/plugins/org.eclipse.jpt.doc.user/contexts.xml | 422 ---- .../dcommon/css/blafdoc.css | 21 - .../org.eclipse.jpt.doc.user/dcommon/html/cpyr.htm | 12 - .../org.eclipse.jpt.doc.user/getting_started.htm | 54 - .../getting_started001.htm | 65 - .../getting_started002.htm | 59 - .../getting_started003.htm | 90 - .../getting_started004.htm | 111 - .../getting_started005.htm | 140 -- .../getting_started006.htm | 48 - .../getting_started007.htm | 215 -- .../getting_started008.htm | 52 - .../getting_started009.htm | 68 - .../getting_started010.htm | 63 - .../getting_started011.htm | 85 - .../getting_started012.htm | 60 - .../getting_started013.htm | 64 - .../getting_started014.htm | 132 -- .../getting_started015.htm | 133 -- .../getting_started016.htm | 89 - .../getting_started017.htm | 71 - .../getting_started018.htm | 89 - .../getting_started019.htm | 67 - .../img/address_java_open.png | Bin 5702 -> 0 bytes .../img/address_jpa_details.png | Bin 8558 -> 0 bytes .../img/address_jpa_structure.png | Bin 4099 -> 0 bytes .../img/button_jpa_perspective.png | Bin 318 -> 0 bytes .../img/database_explorer.png | Bin 4645 -> 0 bytes .../img/details_entitymappings.png | Bin 5647 -> 0 bytes .../img/edit_join_column_dialog.png | Bin 10049 -> 0 bytes .../org.eclipse.jpt.doc.user/img/error_sample.png | Bin 13762 -> 0 bytes .../img/generate_entities.png | Bin 6223 -> 0 bytes .../img/icon_11mapping.png | Bin 244 -> 0 bytes .../img/icon_1mmapping.png | Bin 303 -> 0 bytes .../img/icon_basicmapping.png | Bin 476 -> 0 bytes .../img/icon_embeddable.png | Bin 354 -> 0 bytes .../img/icon_embeddedidmapping.png | Bin 213 -> 0 bytes .../img/icon_embeddedmapping.png | Bin 400 -> 0 bytes .../img/icon_idmapping.png | Bin 521 -> 0 bytes .../img/icon_m1mapping.png | Bin 301 -> 0 bytes .../img/icon_mmmapping.png | Bin 255 -> 0 bytes .../img/icon_nonpersistent.png | Bin 210 -> 0 bytes .../img/icon_persistent.png | Bin 649 -> 0 bytes .../img/icon_superclass.png | Bin 632 -> 0 bytes .../img/icon_transientmapping.png | Bin 224 -> 0 bytes .../img/icon_versionmapping.png | Bin 443 -> 0 bytes .../img/inheritance_join.png | Bin 11615 -> 0 bytes .../img/inheritance_single.png | Bin 3359 -> 0 bytes .../img/inheritance_tab.png | Bin 4236 -> 0 bytes .../img/java_editor_address.png | Bin 7823 -> 0 bytes .../img/jpa_details_employee.png | Bin 8587 -> 0 bytes .../img/jpa_facet_dialog.png | Bin 14095 -> 0 bytes .../img/new_jpa_project_dialog.png | Bin 23157 -> 0 bytes .../org.eclipse.jpt.doc.user/img/new_project_2.png | Bin 7208 -> 0 bytes .../org.eclipse.jpt.doc.user/img/ngrelc.png | Bin 667 -> 0 bytes .../org.eclipse.jpt.doc.user/img/ngrelr.png | Bin 615 -> 0 bytes .../org.eclipse.jpt.doc.user/img/ngrelt.png | Bin 568 -> 0 bytes .../img/open_persistence_editor.png | Bin 12520 -> 0 bytes .../img/persistence_outline_address.png | Bin 7215 -> 0 bytes .../img/persistence_outline_empid.png | Bin 6734 -> 0 bytes .../img/persistence_outline_entity.png | Bin 2090 -> 0 bytes .../img/persistence_outline_fields.png | Bin 4307 -> 0 bytes .../img/persistence_outline_fname.png | Bin 6658 -> 0 bytes .../img/persistence_outline_owner.png | Bin 6409 -> 0 bytes .../img/persistence_outline_phone.png | Bin 7292 -> 0 bytes .../img/persistence_outline_version.png | Bin 6923 -> 0 bytes .../img/persistence_outline_view.png | Bin 8746 -> 0 bytes .../img/persistence_perspective.png | Bin 43141 -> 0 bytes .../img/persistence_view_address.png | Bin 8600 -> 0 bytes .../img/persistence_view_addressid.png | Bin 9705 -> 0 bytes .../img/persistence_view_embedded.png | Bin 8080 -> 0 bytes .../img/persistence_view_empid.png | Bin 6545 -> 0 bytes .../img/persistence_view_empid_pk.png | Bin 12188 -> 0 bytes .../img/persistence_view_employee.png | Bin 8850 -> 0 bytes .../img/persistence_view_entity.png | Bin 8013 -> 0 bytes .../img/persistence_view_firstname.png | Bin 8892 -> 0 bytes .../img/persistence_view_manytoone.png | Bin 11009 -> 0 bytes .../img/persistence_view_mappedsprc.png | Bin 8293 -> 0 bytes .../img/persistence_view_onetomany.png | Bin 17395 -> 0 bytes .../img/persistence_view_onetoone.png | Bin 9280 -> 0 bytes .../img/persistence_view_version.png | Bin 7852 -> 0 bytes .../img/persistence_xml_editor.png | Bin 2899 -> 0 bytes .../img/properties_persistence.png | Bin 19758 -> 0 bytes .../img/quickstart_project.png | Bin 9094 -> 0 bytes .../img/secondary_tables.png | Bin 1750 -> 0 bytes .../img/synchornize_classes.png | Bin 16378 -> 0 bytes .../org.eclipse.jpt.doc.user/img/table_entity.png | Bin 9169 -> 0 bytes .../img/tutorial_object_model.png | Bin 7632 -> 0 bytes jpa/plugins/org.eclipse.jpt.doc.user/index.xml | 546 ----- jpa/plugins/org.eclipse.jpt.doc.user/legal.htm | 45 - .../org.eclipse.jpt.doc.user/plugin.properties | 24 - jpa/plugins/org.eclipse.jpt.doc.user/plugin.xml | 37 - .../org.eclipse.jpt.doc.user/ref_details_orm.htm | 52 - .../org.eclipse.jpt.doc.user/ref_jpa_facet.htm | 91 - .../ref_mapping_general.htm | 213 -- .../ref_new_jpa_project.htm | 91 - .../ref_new_jpa_project_wizard.htm | 54 - .../ref_persistence_map_view.htm | 57 - .../ref_persistence_outline.htm | 55 - .../ref_persistence_perspective.htm | 65 - .../ref_persistence_prop_view.htm | 54 - .../org.eclipse.jpt.doc.user/ref_primary_key.htm | 144 -- .../ref_project_properties.htm | 80 - jpa/plugins/org.eclipse.jpt.doc.user/reference.htm | 65 - .../org.eclipse.jpt.doc.user/reference001.htm | 48 - .../org.eclipse.jpt.doc.user/reference002.htm | 57 - .../org.eclipse.jpt.doc.user/reference003.htm | 115 - .../org.eclipse.jpt.doc.user/reference004.htm | 53 - .../org.eclipse.jpt.doc.user/reference005.htm | 108 - .../org.eclipse.jpt.doc.user/reference006.htm | 84 - .../org.eclipse.jpt.doc.user/reference007.htm | 73 - .../org.eclipse.jpt.doc.user/reference008.htm | 100 - .../org.eclipse.jpt.doc.user/reference009.htm | 102 - .../org.eclipse.jpt.doc.user/reference010.htm | 48 - .../org.eclipse.jpt.doc.user/reference011.htm | 51 - .../org.eclipse.jpt.doc.user/reference012.htm | 71 - .../org.eclipse.jpt.doc.user/reference013.htm | 51 - .../org.eclipse.jpt.doc.user/reference014.htm | 116 - .../org.eclipse.jpt.doc.user/reference015.htm | 65 - .../org.eclipse.jpt.doc.user/reference016.htm | 44 - .../org.eclipse.jpt.doc.user/reference017.htm | 58 - .../task_add_persistence.htm | 65 - .../task_additonal_tables.htm | 79 - .../task_create_new_project.htm | 103 - .../task_generate_entities.htm | 74 - .../org.eclipse.jpt.doc.user/task_inheritance.htm | 143 -- .../org.eclipse.jpt.doc.user/task_manage_orm.htm | 69 - .../task_manage_persistence.htm | 69 - .../org.eclipse.jpt.doc.user/task_mapping.htm | 78 - jpa/plugins/org.eclipse.jpt.doc.user/tasks.htm | 74 - jpa/plugins/org.eclipse.jpt.doc.user/tasks001.htm | 67 - jpa/plugins/org.eclipse.jpt.doc.user/tasks002.htm | 67 - jpa/plugins/org.eclipse.jpt.doc.user/tasks003.htm | 68 - jpa/plugins/org.eclipse.jpt.doc.user/tasks004.htm | 81 - jpa/plugins/org.eclipse.jpt.doc.user/tasks005.htm | 72 - jpa/plugins/org.eclipse.jpt.doc.user/tasks006.htm | 86 - jpa/plugins/org.eclipse.jpt.doc.user/tasks007.htm | 206 -- jpa/plugins/org.eclipse.jpt.doc.user/tasks008.htm | 120 - jpa/plugins/org.eclipse.jpt.doc.user/tasks009.htm | 94 - jpa/plugins/org.eclipse.jpt.doc.user/tasks010.htm | 176 -- jpa/plugins/org.eclipse.jpt.doc.user/tasks011.htm | 179 -- jpa/plugins/org.eclipse.jpt.doc.user/tasks012.htm | 134 -- jpa/plugins/org.eclipse.jpt.doc.user/tasks013.htm | 169 -- jpa/plugins/org.eclipse.jpt.doc.user/tasks014.htm | 141 -- jpa/plugins/org.eclipse.jpt.doc.user/tasks015.htm | 72 - jpa/plugins/org.eclipse.jpt.doc.user/tasks016.htm | 135 -- jpa/plugins/org.eclipse.jpt.doc.user/tasks017.htm | 74 - jpa/plugins/org.eclipse.jpt.doc.user/tasks018.htm | 59 - jpa/plugins/org.eclipse.jpt.doc.user/tasks019.htm | 98 - jpa/plugins/org.eclipse.jpt.doc.user/tasks020.htm | 55 - jpa/plugins/org.eclipse.jpt.doc.user/tasks021.htm | 89 - .../org.eclipse.jpt.doc.user/tips_and_tricks.htm | 71 - jpa/plugins/org.eclipse.jpt.doc.user/toc.xml | 116 - jpa/plugins/org.eclipse.jpt.doc.user/whats_new.htm | 53 - .../org.eclipse.jpt.doc.user/whats_new001.htm | 54 - .../org.eclipse.jpt.doc.user/whats_new002.htm | 57 - .../org.eclipse.jpt.doc.user/whats_new003.htm | 56 - jpa/plugins/org.eclipse.jpt.gen/.classpath | 7 - jpa/plugins/org.eclipse.jpt.gen/.cvsignore | 3 - jpa/plugins/org.eclipse.jpt.gen/.project | 28 - .../.settings/org.eclipse.core.resources.prefs | 3 - .../.settings/org.eclipse.jdt.core.prefs | 7 - .../org.eclipse.jpt.gen/META-INF/MANIFEST.MF | 15 - jpa/plugins/org.eclipse.jpt.gen/about.html | 34 - jpa/plugins/org.eclipse.jpt.gen/build.properties | 16 - jpa/plugins/org.eclipse.jpt.gen/component.xml | 1 - jpa/plugins/org.eclipse.jpt.gen/plugin.properties | 24 - .../eclipse/jpt/gen/internal/EntityGenerator.java | 1459 ------------ .../src/org/eclipse/jpt/gen/internal/GenScope.java | 181 -- .../src/org/eclipse/jpt/gen/internal/GenTable.java | 342 --- .../jpt/gen/internal/ManyToManyRelation.java | 104 - .../jpt/gen/internal/ManyToOneRelation.java | 61 - .../jpt/gen/internal/OneToManyRelation.java | 37 - .../eclipse/jpt/gen/internal/PackageGenerator.java | 97 - jpa/plugins/org.eclipse.jpt.utility/.classpath | 12 - jpa/plugins/org.eclipse.jpt.utility/.cvsignore | 3 - jpa/plugins/org.eclipse.jpt.utility/.project | 28 - .../.settings/org.eclipse.core.resources.prefs | 3 - .../.settings/org.eclipse.jdt.core.prefs | 7 - .../org.eclipse.jpt.utility/META-INF/MANIFEST.MF | 10 - jpa/plugins/org.eclipse.jpt.utility/about.html | 34 - .../org.eclipse.jpt.utility/build.properties | 17 - jpa/plugins/org.eclipse.jpt.utility/component.xml | 1 - .../org.eclipse.jpt.utility/plugin.properties | 24 - .../src/org/eclipse/jpt/utility/internal/Bag.java | 49 - .../org/eclipse/jpt/utility/internal/BitTools.java | 70 - .../eclipse/jpt/utility/internal/ClassTools.java | 1505 ------------ .../eclipse/jpt/utility/internal/Classpath.java | 910 -------- .../jpt/utility/internal/CollectionTools.java | 2437 -------------------- .../eclipse/jpt/utility/internal/FileTools.java | 1006 -------- .../org/eclipse/jpt/utility/internal/Filter.java | 46 - .../org/eclipse/jpt/utility/internal/HashBag.java | 733 ------ .../jpt/utility/internal/IndentingPrintWriter.java | 148 -- .../eclipse/jpt/utility/internal/JDBCTools.java | 348 --- .../org/eclipse/jpt/utility/internal/JDBCType.java | 167 -- .../org/eclipse/jpt/utility/internal/JavaType.java | 232 -- .../eclipse/jpt/utility/internal/NameTools.java | 305 --- .../org/eclipse/jpt/utility/internal/Range.java | 87 - .../jpt/utility/internal/ReverseComparator.java | 41 - .../eclipse/jpt/utility/internal/SimpleFilter.java | 106 - .../eclipse/jpt/utility/internal/StringTools.java | 2101 ----------------- .../eclipse/jpt/utility/internal/Transformer.java | 48 - .../jpt/utility/internal/XMLStringEncoder.java | 182 -- .../utility/internal/iterators/ArrayIterator.java | 72 - .../internal/iterators/ArrayListIterator.java | 78 - .../utility/internal/iterators/ChainIterator.java | 124 - .../utility/internal/iterators/CloneIterator.java | 144 -- .../internal/iterators/CloneListIterator.java | 229 -- .../internal/iterators/CompositeIterator.java | 118 - .../internal/iterators/CompositeListIterator.java | 194 -- .../internal/iterators/EmptyEnumeration.java | 55 - .../utility/internal/iterators/EmptyIterator.java | 59 - .../internal/iterators/EmptyListIterator.java | 83 - .../internal/iterators/EnumerationIterator.java | 50 - .../internal/iterators/FilteringIterator.java | 130 -- .../utility/internal/iterators/GraphIterator.java | 223 -- .../internal/iterators/IteratorEnumeration.java | 47 - .../internal/iterators/PeekableIterator.java | 100 - .../internal/iterators/ReadOnlyIterator.java | 61 - .../internal/iterators/ReadOnlyListIterator.java | 93 - .../internal/iterators/ResultSetIterator.java | 154 -- .../internal/iterators/SingleElementIterator.java | 63 - .../iterators/SingleElementListIterator.java | 94 - .../internal/iterators/TransformationIterator.java | 80 - .../iterators/TransformationListIterator.java | 108 - .../utility/internal/iterators/TreeIterator.java | 175 -- jpa/tests/org.eclipse.jpt.core.tests/.classpath | 13 - jpa/tests/org.eclipse.jpt.core.tests/.cvsignore | 1 - jpa/tests/org.eclipse.jpt.core.tests/.project | 28 - .../.settings/org.eclipse.core.resources.prefs | 3 - .../.settings/org.eclipse.jdt.core.prefs | 7 - .../META-INF/MANIFEST.MF | 25 - jpa/tests/org.eclipse.jpt.core.tests/about.html | 34 - .../org.eclipse.jpt.core.tests/build.properties | 19 - .../org.eclipse.jpt.core.tests/plugin.properties | 22 - .../jpt/core/tests/internal/JptCoreTests.java | 38 - .../jpt/core/tests/internal/ProjectUtility.java | 91 - .../content/java/mappings/JavaEntityTests.java | 52 - .../content/java/mappings/JpaJavaTestCase.java | 62 - .../mappings/JptCoreContentJavaMappingsTests.java | 28 - .../internal/jdtutility/AnnotationTestCase.java | 429 ---- ...onIndexedDeclarationAnnotationAdapterTests.java | 728 ------ .../tests/internal/jdtutility/JDTToolsTests.java | 86 - .../jdtutility/JptCoreJdtUtilityTests.java | 34 - .../MemberAnnotationElementAdapterTests.java | 948 -------- .../NestedDeclarationAnnotationAdapterTests.java | 763 ------ ...edIndexedDeclarationAnnotationAdapterTests.java | 2209 ------------------ .../SimpleDeclarationAnnotationAdapterTests.java | 204 -- .../core/tests/internal/jdtutility/TypeTests.java | 67 - .../tests/internal/model/JptCoreModelTests.java | 27 - .../internal/model/ModelInitializationTests.java | 90 - .../internal/platform/BaseJpaPlatformTests.java | 81 - .../internal/platform/JptCorePlatformTests.java | 28 - .../internal/projects/TestFacetedProject.java | 48 - .../tests/internal/projects/TestJavaProject.java | 148 -- .../tests/internal/projects/TestJpaProject.java | 60 - .../internal/projects/TestPlatformProject.java | 195 -- jpa/tests/org.eclipse.jpt.core.tests/test.xml | 44 - jpa/tests/org.eclipse.jpt.db.tests/.classpath | 7 - jpa/tests/org.eclipse.jpt.db.tests/.cvsignore | 1 - jpa/tests/org.eclipse.jpt.db.tests/.project | 28 - .../org.eclipse.jpt.db.tests/META-INF/MANIFEST.MF | 16 - .../org.eclipse.jpt.db.tests/build.properties | 15 - .../config/derby101.properties | 30 - .../config/oracle10g.properties | 29 - .../config/oracle9i.properties | 29 - .../config/sqlserver2005.properties | 30 - .../org.eclipse.jpt.db.tests/plugin.properties | 25 - .../eclipse/jpt/db/tests/internal/JptDbTests.java | 39 - .../jpt/db/tests/internal/JptDbTestsPlugin.java | 54 - .../tests/internal/platforms/AllPlatformTests.java | 42 - .../tests/internal/platforms/DTPPlatformTests.java | 385 ---- .../db/tests/internal/platforms/Derby101Tests.java | 64 - .../tests/internal/platforms/Oracle10gTests.java | 60 - .../db/tests/internal/platforms/Oracle9iTests.java | 60 - .../internal/platforms/SQLServer2005Tests.java | 64 - jpa/tests/org.eclipse.jpt.utility.tests/.classpath | 7 - jpa/tests/org.eclipse.jpt.utility.tests/.cvsignore | 1 - jpa/tests/org.eclipse.jpt.utility.tests/.project | 28 - .../.settings/org.eclipse.core.resources.prefs | 3 - .../.settings/org.eclipse.jdt.core.prefs | 7 - .../META-INF/MANIFEST.MF | 12 - jpa/tests/org.eclipse.jpt.utility.tests/about.html | 34 - .../org.eclipse.jpt.utility.tests/build.properties | 16 - .../plugin.properties | 24 - .../jpt/utility/tests/internal/BitToolsTests.java | 59 - .../utility/tests/internal/ClassToolsTests.java | 548 ----- .../jpt/utility/tests/internal/ClasspathTests.java | 289 --- .../tests/internal/CollectionToolsTests.java | 1990 ---------------- .../jpt/utility/tests/internal/FileToolsTests.java | 594 ----- .../jpt/utility/tests/internal/HashBagTests.java | 448 ---- .../tests/internal/IndentingPrintWriterTests.java | 107 - .../jpt/utility/tests/internal/JDBCTypeTests.java | 66 - .../jpt/utility/tests/internal/JavaTypeTests.java | 250 -- .../utility/tests/internal/JptUtilityTests.java | 49 - .../jpt/utility/tests/internal/NameToolsTests.java | 214 -- .../jpt/utility/tests/internal/RangeTests.java | 74 - .../tests/internal/ReverseComparatorTests.java | 101 - .../utility/tests/internal/StringToolsTests.java | 833 ------- .../jpt/utility/tests/internal/TestTools.java | 161 -- .../tests/internal/XMLStringEncoderTests.java | 135 -- .../internal/iterators/ArrayIteratorTests.java | 126 - .../internal/iterators/ArrayListIteratorTests.java | 150 -- .../internal/iterators/ChainIteratorTests.java | 119 - .../internal/iterators/CloneIteratorTests.java | 252 -- .../internal/iterators/CloneListIteratorTests.java | 408 ---- .../internal/iterators/CompositeIteratorTests.java | 334 --- .../iterators/CompositeListIteratorTests.java | 404 ---- .../internal/iterators/EmptyEnumerationTests.java | 53 - .../internal/iterators/EmptyIteratorTests.java | 63 - .../internal/iterators/EmptyListIteratorTests.java | 127 - .../iterators/EnumerationIteratorTests.java | 119 - .../internal/iterators/FilteringIteratorTests.java | 285 --- .../internal/iterators/GraphIteratorTests.java | 183 -- .../iterators/IteratorEnumerationTests.java | 98 - .../iterators/JptUtilityIteratorsTests.java | 53 - .../internal/iterators/PeekableIteratorTests.java | 140 -- .../internal/iterators/ReadOnlyIteratorTests.java | 118 - .../iterators/ReadOnlyListIteratorTests.java | 203 -- .../iterators/SingleElementIteratorTests.java | 71 - .../iterators/SingleElementListIteratorTests.java | 111 - .../iterators/TransformationIteratorTests.java | 216 -- .../iterators/TransformationListIteratorTests.java | 306 --- .../internal/iterators/TreeIteratorTests.java | 197 -- jpa/tests/org.eclipse.jpt.utility.tests/test.xml | 44 - 459 files changed, 51809 deletions(-) delete mode 100644 assembly/features/org.eclipse.jpt.sdk/.cvsignore delete mode 100644 assembly/features/org.eclipse.jpt.sdk/.project delete mode 100644 assembly/features/org.eclipse.jpt.sdk/build.properties delete mode 100644 assembly/features/org.eclipse.jpt.sdk/eclipse_update_120.jpg delete mode 100644 assembly/features/org.eclipse.jpt.sdk/epl-v10.html delete mode 100644 assembly/features/org.eclipse.jpt.sdk/feature.properties delete mode 100644 assembly/features/org.eclipse.jpt.sdk/feature.xml delete mode 100644 assembly/features/org.eclipse.jpt.sdk/license.html delete mode 100644 assembly/features/org.eclipse.jpt.tests/.cvsignore delete mode 100644 assembly/features/org.eclipse.jpt.tests/.project delete mode 100644 assembly/features/org.eclipse.jpt.tests/.settings/org.eclipse.core.resources.prefs delete mode 100644 assembly/features/org.eclipse.jpt.tests/build.properties delete mode 100644 assembly/features/org.eclipse.jpt.tests/eclipse_update_120.jpg delete mode 100644 assembly/features/org.eclipse.jpt.tests/epl-v10.html delete mode 100644 assembly/features/org.eclipse.jpt.tests/feature.properties delete mode 100644 assembly/features/org.eclipse.jpt.tests/feature.xml delete mode 100644 assembly/features/org.eclipse.jpt.tests/license.html delete mode 100644 assembly/features/org.eclipse.jpt/.cvsignore delete mode 100644 assembly/features/org.eclipse.jpt/.project delete mode 100644 assembly/features/org.eclipse.jpt/build.properties delete mode 100644 assembly/features/org.eclipse.jpt/eclipse_update_120.jpg delete mode 100644 assembly/features/org.eclipse.jpt/epl-v10.html delete mode 100644 assembly/features/org.eclipse.jpt/feature.properties delete mode 100644 assembly/features/org.eclipse.jpt/feature.xml delete mode 100644 assembly/features/org.eclipse.jpt/license.html delete mode 100644 assembly/plugins/org.eclipse.jpt/.cvsignore delete mode 100644 assembly/plugins/org.eclipse.jpt/.project delete mode 100644 assembly/plugins/org.eclipse.jpt/.settings/org.eclipse.core.resources.prefs delete mode 100644 assembly/plugins/org.eclipse.jpt/META-INF/MANIFEST.MF delete mode 100644 assembly/plugins/org.eclipse.jpt/about.html delete mode 100644 assembly/plugins/org.eclipse.jpt/about.ini delete mode 100644 assembly/plugins/org.eclipse.jpt/about.mappings delete mode 100644 assembly/plugins/org.eclipse.jpt/about.properties delete mode 100644 assembly/plugins/org.eclipse.jpt/build.properties delete mode 100644 assembly/plugins/org.eclipse.jpt/component.xml delete mode 100644 assembly/plugins/org.eclipse.jpt/eclipse32.gif delete mode 100644 assembly/plugins/org.eclipse.jpt/eclipse32.png delete mode 100644 assembly/plugins/org.eclipse.jpt/plugin.properties delete mode 100644 jpa/features/org.eclipse.jpt.feature/.project delete mode 100644 jpa/features/org.eclipse.jpt.feature/.settings/org.eclipse.core.resources.prefs delete mode 100644 jpa/features/org.eclipse.jpt.feature/build.properties delete mode 100644 jpa/features/org.eclipse.jpt.feature/eclipse_update_120.jpg delete mode 100644 jpa/features/org.eclipse.jpt.feature/epl-v10.html delete mode 100644 jpa/features/org.eclipse.jpt.feature/feature.properties delete mode 100644 jpa/features/org.eclipse.jpt.feature/feature.xml delete mode 100644 jpa/features/org.eclipse.jpt.feature/license.html delete mode 100644 jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/build.properties delete mode 100644 jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/eclipse_update_120.jpg delete mode 100644 jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/epl-v10.html delete mode 100644 jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/feature.properties delete mode 100644 jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/feature.xml delete mode 100644 jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/license.html delete mode 100644 jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.html delete mode 100644 jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.ini delete mode 100644 jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.mappings delete mode 100644 jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.properties delete mode 100644 jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/build.properties delete mode 100644 jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse32.gif delete mode 100644 jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse32.png delete mode 100644 jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse_update_120.jpg delete mode 100644 jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/epl-v10.html delete mode 100644 jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/license.html delete mode 100644 jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/plugin.properties delete mode 100644 jpa/features/org.eclipse.jpt.tests.feature/.project delete mode 100644 jpa/features/org.eclipse.jpt.tests.feature/.settings/org.eclipse.core.resources.prefs delete mode 100644 jpa/features/org.eclipse.jpt.tests.feature/build.properties delete mode 100644 jpa/features/org.eclipse.jpt.tests.feature/eclipse_update_120.jpg delete mode 100644 jpa/features/org.eclipse.jpt.tests.feature/epl-v10.html delete mode 100644 jpa/features/org.eclipse.jpt.tests.feature/feature.properties delete mode 100644 jpa/features/org.eclipse.jpt.tests.feature/feature.xml delete mode 100644 jpa/features/org.eclipse.jpt.tests.feature/license.html delete mode 100644 jpa/features/org.eclipse.jpt_sdk.feature/.project delete mode 100644 jpa/features/org.eclipse.jpt_sdk.feature/.settings/org.eclipse.core.resources.prefs delete mode 100644 jpa/features/org.eclipse.jpt_sdk.feature/build.properties delete mode 100644 jpa/features/org.eclipse.jpt_sdk.feature/eclipse_update_120.jpg delete mode 100644 jpa/features/org.eclipse.jpt_sdk.feature/epl-v10.html delete mode 100644 jpa/features/org.eclipse.jpt_sdk.feature/feature.properties delete mode 100644 jpa/features/org.eclipse.jpt_sdk.feature/feature.xml delete mode 100644 jpa/features/org.eclipse.jpt_sdk.feature/license.html delete mode 100644 jpa/plugins/org.eclipse.jpt.db.ui/.classpath delete mode 100644 jpa/plugins/org.eclipse.jpt.db.ui/.cvsignore delete mode 100644 jpa/plugins/org.eclipse.jpt.db.ui/.project delete mode 100644 jpa/plugins/org.eclipse.jpt.db.ui/.settings/org.eclipse.core.resources.prefs delete mode 100644 jpa/plugins/org.eclipse.jpt.db.ui/.settings/org.eclipse.jdt.core.prefs delete mode 100644 jpa/plugins/org.eclipse.jpt.db.ui/META-INF/MANIFEST.MF delete mode 100644 jpa/plugins/org.eclipse.jpt.db.ui/about.html delete mode 100644 jpa/plugins/org.eclipse.jpt.db.ui/build.properties delete mode 100644 jpa/plugins/org.eclipse.jpt.db.ui/component.xml delete mode 100644 jpa/plugins/org.eclipse.jpt.db.ui/plugin.properties delete mode 100644 jpa/plugins/org.eclipse.jpt.db.ui/src/org/eclipse/jpt/db/ui/internal/DTPUiTools.java delete mode 100644 jpa/plugins/org.eclipse.jpt.db/.classpath delete mode 100644 jpa/plugins/org.eclipse.jpt.db/.cvsignore delete mode 100644 jpa/plugins/org.eclipse.jpt.db/.project delete mode 100644 jpa/plugins/org.eclipse.jpt.db/.settings/org.eclipse.core.resources.prefs delete mode 100644 jpa/plugins/org.eclipse.jpt.db/.settings/org.eclipse.jdt.core.prefs delete mode 100644 jpa/plugins/org.eclipse.jpt.db/META-INF/MANIFEST.MF delete mode 100644 jpa/plugins/org.eclipse.jpt.db/about.html delete mode 100644 jpa/plugins/org.eclipse.jpt.db/build.properties delete mode 100644 jpa/plugins/org.eclipse.jpt.db/component.xml delete mode 100644 jpa/plugins/org.eclipse.jpt.db/plugin.properties delete mode 100644 jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Catalog.java delete mode 100644 jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Column.java delete mode 100644 jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Connection.java delete mode 100644 jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionListener.java delete mode 100644 jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionProfile.java delete mode 100644 jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionProfileRepository.java delete mode 100644 jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionProfileWrapper.java delete mode 100644 jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionWrapper.java delete mode 100644 jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPDatabaseWrapper.java delete mode 100644 jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPTools.java delete mode 100644 jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPWrapper.java delete mode 100644 jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Database.java delete mode 100644 jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ForeignKey.java delete mode 100644 jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/JptDbPlugin.java delete mode 100644 jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullConnection.java delete mode 100644 jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullConnectionProfile.java delete mode 100644 jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullDatabase.java delete mode 100644 jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ProfileListener.java delete mode 100644 jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Schema.java delete mode 100644 jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Sequence.java delete mode 100644 jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Table.java delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/.project delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/META-INF/MANIFEST.MF delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/about.html delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/build.properties delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/add_persistence.xml delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/create_entity.xml delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/map_entity.xml delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/concept_mapping.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/concept_persistence.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/concepts.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/concepts001.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/concepts002.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/concepts003.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/contexts.xml delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/dcommon/css/blafdoc.css delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/dcommon/html/cpyr.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/getting_started.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/getting_started001.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/getting_started002.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/getting_started003.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/getting_started004.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/getting_started005.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/getting_started006.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/getting_started007.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/getting_started008.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/getting_started009.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/getting_started010.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/getting_started011.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/getting_started012.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/getting_started013.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/getting_started014.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/getting_started015.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/getting_started016.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/getting_started017.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/getting_started018.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/getting_started019.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/address_java_open.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/address_jpa_details.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/address_jpa_structure.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/button_jpa_perspective.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/database_explorer.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/details_entitymappings.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/edit_join_column_dialog.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/error_sample.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/generate_entities.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/icon_11mapping.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/icon_1mmapping.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/icon_basicmapping.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddable.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddedidmapping.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddedmapping.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/icon_idmapping.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/icon_m1mapping.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/icon_mmmapping.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/icon_nonpersistent.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/icon_persistent.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/icon_superclass.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/icon_transientmapping.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/icon_versionmapping.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_join.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_single.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_tab.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/java_editor_address.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/jpa_details_employee.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/jpa_facet_dialog.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/new_jpa_project_dialog.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/new_project_2.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelc.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelr.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelt.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/open_persistence_editor.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_address.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_empid.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_entity.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_fields.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_fname.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_owner.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_phone.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_version.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_view.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_perspective.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_address.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_addressid.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_embedded.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_empid.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_empid_pk.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_employee.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_entity.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_firstname.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_manytoone.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_mappedsprc.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_onetomany.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_onetoone.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_version.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_xml_editor.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/properties_persistence.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/quickstart_project.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/secondary_tables.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/synchornize_classes.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/table_entity.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/img/tutorial_object_model.png delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/index.xml delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/legal.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/plugin.properties delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/plugin.xml delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/ref_details_orm.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/ref_jpa_facet.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/ref_mapping_general.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/ref_new_jpa_project.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/ref_new_jpa_project_wizard.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_map_view.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_outline.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_perspective.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_prop_view.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/ref_primary_key.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/ref_project_properties.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/reference.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/reference001.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/reference002.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/reference003.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/reference004.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/reference005.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/reference006.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/reference007.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/reference008.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/reference009.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/reference010.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/reference011.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/reference012.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/reference013.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/reference014.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/reference015.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/reference016.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/reference017.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/task_add_persistence.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/task_additonal_tables.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/task_create_new_project.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/task_generate_entities.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/task_inheritance.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/task_manage_orm.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/task_manage_persistence.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/task_mapping.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tasks.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tasks001.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tasks002.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tasks003.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tasks004.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tasks005.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tasks006.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tasks007.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tasks008.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tasks009.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tasks010.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tasks011.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tasks012.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tasks013.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tasks014.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tasks015.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tasks016.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tasks017.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tasks018.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tasks019.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tasks020.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tasks021.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/tips_and_tricks.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/toc.xml delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/whats_new.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/whats_new001.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/whats_new002.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.doc.user/whats_new003.htm delete mode 100644 jpa/plugins/org.eclipse.jpt.gen/.classpath delete mode 100644 jpa/plugins/org.eclipse.jpt.gen/.cvsignore delete mode 100644 jpa/plugins/org.eclipse.jpt.gen/.project delete mode 100644 jpa/plugins/org.eclipse.jpt.gen/.settings/org.eclipse.core.resources.prefs delete mode 100644 jpa/plugins/org.eclipse.jpt.gen/.settings/org.eclipse.jdt.core.prefs delete mode 100644 jpa/plugins/org.eclipse.jpt.gen/META-INF/MANIFEST.MF delete mode 100644 jpa/plugins/org.eclipse.jpt.gen/about.html delete mode 100644 jpa/plugins/org.eclipse.jpt.gen/build.properties delete mode 100644 jpa/plugins/org.eclipse.jpt.gen/component.xml delete mode 100644 jpa/plugins/org.eclipse.jpt.gen/plugin.properties delete mode 100644 jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/EntityGenerator.java delete mode 100644 jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/GenScope.java delete mode 100644 jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/GenTable.java delete mode 100644 jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ManyToManyRelation.java delete mode 100644 jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ManyToOneRelation.java delete mode 100644 jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/OneToManyRelation.java delete mode 100644 jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/PackageGenerator.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/.classpath delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/.cvsignore delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/.project delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/.settings/org.eclipse.core.resources.prefs delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/.settings/org.eclipse.jdt.core.prefs delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/META-INF/MANIFEST.MF delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/about.html delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/build.properties delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/component.xml delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/plugin.properties delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Bag.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/BitTools.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ClassTools.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Classpath.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/CollectionTools.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/FileTools.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Filter.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/HashBag.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/IndentingPrintWriter.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/JDBCTools.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/JDBCType.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/JavaType.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/NameTools.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Range.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ReverseComparator.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleFilter.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/StringTools.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Transformer.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/XMLStringEncoder.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ArrayIterator.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ArrayListIterator.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ChainIterator.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CloneIterator.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CloneListIterator.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CompositeIterator.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CompositeListIterator.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyEnumeration.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyIterator.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyListIterator.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EnumerationIterator.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/FilteringIterator.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/GraphIterator.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/IteratorEnumeration.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/PeekableIterator.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ReadOnlyIterator.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ReadOnlyListIterator.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ResultSetIterator.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/SingleElementIterator.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/SingleElementListIterator.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TransformationIterator.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TransformationListIterator.java delete mode 100644 jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TreeIterator.java delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/.classpath delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/.cvsignore delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/.project delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/.settings/org.eclipse.core.resources.prefs delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/.settings/org.eclipse.jdt.core.prefs delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/META-INF/MANIFEST.MF delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/about.html delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/build.properties delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/plugin.properties delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/JptCoreTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/ProjectUtility.java delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/content/java/mappings/JavaEntityTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/content/java/mappings/JpaJavaTestCase.java delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/content/java/mappings/JptCoreContentJavaMappingsTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/AnnotationTestCase.java delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/CombinationIndexedDeclarationAnnotationAdapterTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/JDTToolsTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/JptCoreJdtUtilityTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/MemberAnnotationElementAdapterTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/NestedDeclarationAnnotationAdapterTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/NestedIndexedDeclarationAnnotationAdapterTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/SimpleDeclarationAnnotationAdapterTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/TypeTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JptCoreModelTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/ModelInitializationTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/BaseJpaPlatformTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/JptCorePlatformTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestFacetedProject.java delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestJavaProject.java delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestJpaProject.java delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestPlatformProject.java delete mode 100644 jpa/tests/org.eclipse.jpt.core.tests/test.xml delete mode 100644 jpa/tests/org.eclipse.jpt.db.tests/.classpath delete mode 100644 jpa/tests/org.eclipse.jpt.db.tests/.cvsignore delete mode 100644 jpa/tests/org.eclipse.jpt.db.tests/.project delete mode 100644 jpa/tests/org.eclipse.jpt.db.tests/META-INF/MANIFEST.MF delete mode 100644 jpa/tests/org.eclipse.jpt.db.tests/build.properties delete mode 100644 jpa/tests/org.eclipse.jpt.db.tests/config/derby101.properties delete mode 100644 jpa/tests/org.eclipse.jpt.db.tests/config/oracle10g.properties delete mode 100644 jpa/tests/org.eclipse.jpt.db.tests/config/oracle9i.properties delete mode 100644 jpa/tests/org.eclipse.jpt.db.tests/config/sqlserver2005.properties delete mode 100644 jpa/tests/org.eclipse.jpt.db.tests/plugin.properties delete mode 100644 jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/JptDbTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/JptDbTestsPlugin.java delete mode 100644 jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/AllPlatformTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/DTPPlatformTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Derby101Tests.java delete mode 100644 jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle10gTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle9iTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/SQLServer2005Tests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/.classpath delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/.cvsignore delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/.project delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/.settings/org.eclipse.core.resources.prefs delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/.settings/org.eclipse.jdt.core.prefs delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/META-INF/MANIFEST.MF delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/about.html delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/build.properties delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/plugin.properties delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BitToolsTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClassToolsTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClasspathTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CollectionToolsTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/FileToolsTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/HashBagTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/IndentingPrintWriterTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JDBCTypeTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JavaTypeTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JptUtilityTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/NameToolsTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/RangeTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ReverseComparatorTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/StringToolsTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/TestTools.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/XMLStringEncoderTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ArrayIteratorTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ArrayListIteratorTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ChainIteratorTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CloneIteratorTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CloneListIteratorTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CompositeIteratorTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CompositeListIteratorTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyEnumerationTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyIteratorTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyListIteratorTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EnumerationIteratorTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/FilteringIteratorTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/GraphIteratorTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/IteratorEnumerationTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/JptUtilityIteratorsTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/PeekableIteratorTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ReadOnlyIteratorTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ReadOnlyListIteratorTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/SingleElementIteratorTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/SingleElementListIteratorTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TransformationIteratorTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TransformationListIteratorTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TreeIteratorTests.java delete mode 100644 jpa/tests/org.eclipse.jpt.utility.tests/test.xml diff --git a/assembly/features/org.eclipse.jpt.sdk/.cvsignore b/assembly/features/org.eclipse.jpt.sdk/.cvsignore deleted file mode 100644 index bc2abf75c1..0000000000 --- a/assembly/features/org.eclipse.jpt.sdk/.cvsignore +++ /dev/null @@ -1,4 +0,0 @@ -*.bin.dist.zip -build.xml -features -plugins diff --git a/assembly/features/org.eclipse.jpt.sdk/.project b/assembly/features/org.eclipse.jpt.sdk/.project deleted file mode 100644 index 821d453136..0000000000 --- a/assembly/features/org.eclipse.jpt.sdk/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - org.eclipse.jpt.sdk - - - - - - org.eclipse.pde.FeatureBuilder - - - - - - org.eclipse.pde.FeatureNature - - diff --git a/assembly/features/org.eclipse.jpt.sdk/build.properties b/assembly/features/org.eclipse.jpt.sdk/build.properties deleted file mode 100644 index 7200939aca..0000000000 --- a/assembly/features/org.eclipse.jpt.sdk/build.properties +++ /dev/null @@ -1,15 +0,0 @@ -############################################################################### -# Copyright (c) 2006 Oracle. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License 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,\ - epl-v10.html,\ - license.html,\ - feature.properties diff --git a/assembly/features/org.eclipse.jpt.sdk/eclipse_update_120.jpg b/assembly/features/org.eclipse.jpt.sdk/eclipse_update_120.jpg deleted file mode 100644 index bfdf708ad6..0000000000 Binary files a/assembly/features/org.eclipse.jpt.sdk/eclipse_update_120.jpg and /dev/null differ diff --git a/assembly/features/org.eclipse.jpt.sdk/epl-v10.html b/assembly/features/org.eclipse.jpt.sdk/epl-v10.html deleted file mode 100644 index ed4b196655..0000000000 --- a/assembly/features/org.eclipse.jpt.sdk/epl-v10.html +++ /dev/null @@ -1,328 +0,0 @@ - - - - - - - - -Eclipse Public License - Version 1.0 - - - - - - -
- -

Eclipse Public License - v 1.0 -

- -

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER -THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, -REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE -OF THIS AGREEMENT.

- -

1. DEFINITIONS

- -

"Contribution" means:

- -

a) -in the case of the initial Contributor, the initial code and documentation -distributed under this Agreement, and
-b) in the case of each subsequent Contributor:

- -

i) -changes to the Program, and

- -

ii) -additions to the Program;

- -

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.

- -

"Contributor" means any person or -entity that distributes the Program.

- -

"Licensed Patents " 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.

- -

"Program" means the Contributions -distributed in accordance with this Agreement.

- -

"Recipient" means anyone who -receives the Program under this Agreement, including all Contributors.

- -

2. GRANT OF RIGHTS

- -

a) -Subject to the terms of this Agreement, each Contributor hereby grants Recipient -a non-exclusive, worldwide, royalty-free copyright license to 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.

- -

b) -Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, 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.

- -

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.

- -

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.

- -

3. REQUIREMENTS

- -

A Contributor may choose to distribute the -Program in object code form under its own license agreement, provided that: -

- -

a) -it complies with the terms and conditions of this Agreement; and

- -

b) -its license agreement:

- -

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;

- -

ii) -effectively excludes on behalf of all Contributors all liability for damages, -including direct, indirect, special, incidental and consequential damages, such -as lost profits;

- -

iii) -states that any provisions which differ from this Agreement are offered by that -Contributor alone and not by any other party; and

- -

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.

- -

When the Program is made available in source -code form:

- -

a) -it must be made available under this Agreement; and

- -

b) a -copy of this Agreement must be included with each copy of the Program.

- -

Contributors may not remove or alter any -copyright notices contained within the Program.

- -

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.

- -

4. COMMERCIAL DISTRIBUTION

- -

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 ("Commercial -Contributor") hereby agrees to defend and indemnify every other -Contributor ("Indemnified Contributor") against any losses, damages and -costs (collectively "Losses") 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.

- -

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.

- -

5. NO WARRANTY

- -

EXCEPT AS EXPRESSLY SET FORTH IN THIS -AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" 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.

- -

6. DISCLAIMER OF LIABILITY

- -

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.

- -

7. GENERAL

- -

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.

- -

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.

- -

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.

- -

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.

- -

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.

- -

 

- -
- - - - \ No newline at end of file diff --git a/assembly/features/org.eclipse.jpt.sdk/feature.properties b/assembly/features/org.eclipse.jpt.sdk/feature.properties deleted file mode 100644 index abb0c88d62..0000000000 --- a/assembly/features/org.eclipse.jpt.sdk/feature.properties +++ /dev/null @@ -1,145 +0,0 @@ -############################################################################### -# Copyright (c) 2006 Oracle. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License 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 API (JPA) project SDK - -# "providerName" property - name of the company that provides the feature -providerName=Eclipse.org - -# "updateSiteName" property - label for the update site -updateSiteName=The Eclipse Web Tools Platform (WTP) Project update site - -# "description" property - description of the feature -description=Dali Java Persistence API (JPA) project SDK - -# "copyright" property - text of the "Feature Update Copyright" -copyright=\ -Copyright (c) 2006 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 -licenseURL=license.html - -# "license" property - text of the "Feature Update License" -# should be plain text version of license agreement pointed to be "licenseURL" -license=\ -ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\ -June 06, 2007\n\ -\n\ -Usage Of Content\n\ -\n\ -THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\ -OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\ -USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\ -AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\ -NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\ -AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\ -AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\ -OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\ -TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\ -OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\ -BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\ -\n\ -Applicable Licenses\n\ -\n\ -Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\ -is provided to you under the terms and conditions of the Eclipse Public\n\ -License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\ -Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\ -For purposes of the EPL, "Program" will mean the Content.\n\ -\n\ -Content includes, but is not limited to, source code, object code,\n\ -documentation and other files maintained in the Eclipse.org CVS\n\ -repository ("Repository") in CVS modules ("Modules") and made available\n\ -as downloadable archives ("Downloads").\n\ -\n\ - - Content may be structured and packaged into modules to facilitate delivering,\n\ - extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\ - plug-in fragments ("Fragments"), and features ("Features").\n\ - - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java? ARchive)\n\ - in a directory named "plugins".\n\ - - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\ - Each Feature may be packaged as a sub-directory in a directory named "features".\n\ - Within a Feature, files named "feature.xml" may contain a list of the names and version\n\ - numbers of the Plug-ins and/or Fragments associated with that Feature.\n\ - - Features may also include other Features ("Included Features"). Within a Feature, files\n\ - named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\ -\n\ -Features may also include other Features ("Included Features"). Files named\n\ -"feature.xml" may contain a list of the names and version numbers of\n\ -Included Features.\n\ -\n\ -The terms and conditions governing Plug-ins and Fragments should be\n\ -contained in files named "about.html" ("Abouts"). The terms and\n\ -conditions governing Features and Included Features should be contained\n\ -in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\ -Licenses may be located in any directory of a Download or Module\n\ -including, but not limited to the following locations:\n\ -\n\ - - The top-level (root) directory\n\ - - Plug-in and Fragment directories\n\ - - Inside Plug-ins and Fragments packaged as JARs\n\ - - Sub-directories of the directory named "src" of certain Plug-ins\n\ - - Feature directories\n\ -\n\ -Note: if a Feature made available by the Eclipse Foundation is installed using the\n\ -Eclipse Update Manager, you must agree to a license ("Feature Update\n\ -License") during the installation process. If the Feature contains\n\ -Included Features, the Feature Update License should either provide you\n\ -with the terms and conditions governing the Included Features or inform\n\ -you where you can locate them. Feature Update Licenses may be found in\n\ -the "license" property of files named "feature.properties". Such Abouts,\n\ -Feature Licenses and Feature Update Licenses contain the terms and\n\ -conditions (or references to such terms and conditions) that govern your\n\ -use of the associated Content in that directory.\n\ -\n\ -THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\ -TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\ -SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\ -\n\ - - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\ - - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\ - - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\ - - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\ - - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\ - - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\ - - Common Development and Distribution License (CDDL) Version 1.0 (available at http://www.sun.com/cddl/cddl.html)\n\ -\n\ -IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\ -TO USE OF THE CONTENT. If no About, Feature License or Feature Update License\n\ -is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\ -govern that particular Content.\n\ -\n\ -Cryptography\n\ -\n\ -Content may contain encryption software. The country in which you are\n\ -currently may have restrictions on the import, possession, and use,\n\ -and/or re-export to another country, of encryption software. BEFORE\n\ -using any encryption software, please check the country's laws,\n\ -regulations and policies concerning the import, possession, or use,\n\ -and re-export of encryption software, to see if this is permitted.\n\ -\n\ -Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.\n -########### end of license property ########################################## diff --git a/assembly/features/org.eclipse.jpt.sdk/feature.xml b/assembly/features/org.eclipse.jpt.sdk/feature.xml deleted file mode 100644 index a08b2792c0..0000000000 --- a/assembly/features/org.eclipse.jpt.sdk/feature.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - %description - - - - %copyright - - - - %license - - - - - - - - - - - - diff --git a/assembly/features/org.eclipse.jpt.sdk/license.html b/assembly/features/org.eclipse.jpt.sdk/license.html deleted file mode 100644 index 76abfb4621..0000000000 --- a/assembly/features/org.eclipse.jpt.sdk/license.html +++ /dev/null @@ -1,98 +0,0 @@ - - -Eclipse.org Software User Agreement - - - -

Eclipse Foundation Software User Agreement

-

June 06, 2007

-

Usage Of Content

-

THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION -AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). 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.

-

Applicable Licenses

-

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 ("EPL"). A copy of the EPL is provided with this -Content and is also available at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

-

Content includes, but is not limited to, source code, object code, -documentation and other files maintained in the Eclipse.org CVS repository -("Repository") in CVS modules ("Modules") and made available as downloadable -archives ("Downloads").

-

Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments -("Fragments"), and features ("Features"). A Feature is a bundle of one or more -Plug-ins and/or Fragments and associated material. Files named "feature.xml" may -contain a list of the names and version numbers of the Plug-ins and/or Fragments -associated with a Feature. Plug-ins and Fragments are located in directories -named "plugins" and Features are located in directories named "features".

-

Features may also include other Features ("Included Features"). Files named -"feature.xml" may contain a list of the names and version numbers of Included -Features.

-

The terms and conditions governing Plug-ins and Fragments should be contained -in files named "about.html" ("Abouts"). The terms and conditions governing -Features and Included Features should be contained in files named "license.html" -("Feature Licenses"). Abouts and Feature Licenses may be located in any -directory of a Download or Module including, but not limited to the following -locations:

- -

Note: if a Feature made available by the Eclipse Foundation is installed -using the Eclipse Update Manager, you must agree to a license ("Feature Update -License") 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 "license" property of -files named "feature.properties". 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.

-

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):

- -

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.

-

Cryptography

-

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.

diff --git a/assembly/features/org.eclipse.jpt.tests/.cvsignore b/assembly/features/org.eclipse.jpt.tests/.cvsignore deleted file mode 100644 index d9e4340782..0000000000 --- a/assembly/features/org.eclipse.jpt.tests/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -*.bin.dist.zip -build.xml diff --git a/assembly/features/org.eclipse.jpt.tests/.project b/assembly/features/org.eclipse.jpt.tests/.project deleted file mode 100644 index 3d1dde631a..0000000000 --- a/assembly/features/org.eclipse.jpt.tests/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - org.eclipse.jpt.tests - - - - - - org.eclipse.pde.FeatureBuilder - - - - - - org.eclipse.pde.FeatureNature - - diff --git a/assembly/features/org.eclipse.jpt.tests/.settings/org.eclipse.core.resources.prefs b/assembly/features/org.eclipse.jpt.tests/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 17acb651a8..0000000000 --- a/assembly/features/org.eclipse.jpt.tests/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Sun May 27 15:11:05 EDT 2007 -eclipse.preferences.version=1 -encoding/=ISO-8859-1 diff --git a/assembly/features/org.eclipse.jpt.tests/build.properties b/assembly/features/org.eclipse.jpt.tests/build.properties deleted file mode 100644 index 7f47694aab..0000000000 --- a/assembly/features/org.eclipse.jpt.tests/build.properties +++ /dev/null @@ -1,5 +0,0 @@ -bin.includes = feature.xml,\ - eclipse_update_120.jpg,\ - epl-v10.html,\ - license.html,\ - feature.properties diff --git a/assembly/features/org.eclipse.jpt.tests/eclipse_update_120.jpg b/assembly/features/org.eclipse.jpt.tests/eclipse_update_120.jpg deleted file mode 100644 index bfdf708ad6..0000000000 Binary files a/assembly/features/org.eclipse.jpt.tests/eclipse_update_120.jpg and /dev/null differ diff --git a/assembly/features/org.eclipse.jpt.tests/epl-v10.html b/assembly/features/org.eclipse.jpt.tests/epl-v10.html deleted file mode 100644 index ed4b196655..0000000000 --- a/assembly/features/org.eclipse.jpt.tests/epl-v10.html +++ /dev/null @@ -1,328 +0,0 @@ - - - - - - - - -Eclipse Public License - Version 1.0 - - - - - - -
- -

Eclipse Public License - v 1.0 -

- -

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER -THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, -REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE -OF THIS AGREEMENT.

- -

1. DEFINITIONS

- -

"Contribution" means:

- -

a) -in the case of the initial Contributor, the initial code and documentation -distributed under this Agreement, and
-b) in the case of each subsequent Contributor:

- -

i) -changes to the Program, and

- -

ii) -additions to the Program;

- -

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.

- -

"Contributor" means any person or -entity that distributes the Program.

- -

"Licensed Patents " 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.

- -

"Program" means the Contributions -distributed in accordance with this Agreement.

- -

"Recipient" means anyone who -receives the Program under this Agreement, including all Contributors.

- -

2. GRANT OF RIGHTS

- -

a) -Subject to the terms of this Agreement, each Contributor hereby grants Recipient -a non-exclusive, worldwide, royalty-free copyright license to 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.

- -

b) -Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, 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.

- -

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.

- -

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.

- -

3. REQUIREMENTS

- -

A Contributor may choose to distribute the -Program in object code form under its own license agreement, provided that: -

- -

a) -it complies with the terms and conditions of this Agreement; and

- -

b) -its license agreement:

- -

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;

- -

ii) -effectively excludes on behalf of all Contributors all liability for damages, -including direct, indirect, special, incidental and consequential damages, such -as lost profits;

- -

iii) -states that any provisions which differ from this Agreement are offered by that -Contributor alone and not by any other party; and

- -

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.

- -

When the Program is made available in source -code form:

- -

a) -it must be made available under this Agreement; and

- -

b) a -copy of this Agreement must be included with each copy of the Program.

- -

Contributors may not remove or alter any -copyright notices contained within the Program.

- -

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.

- -

4. COMMERCIAL DISTRIBUTION

- -

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 ("Commercial -Contributor") hereby agrees to defend and indemnify every other -Contributor ("Indemnified Contributor") against any losses, damages and -costs (collectively "Losses") 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.

- -

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.

- -

5. NO WARRANTY

- -

EXCEPT AS EXPRESSLY SET FORTH IN THIS -AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" 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.

- -

6. DISCLAIMER OF LIABILITY

- -

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.

- -

7. GENERAL

- -

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.

- -

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.

- -

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.

- -

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.

- -

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.

- -

 

- -
- - - - \ No newline at end of file diff --git a/assembly/features/org.eclipse.jpt.tests/feature.properties b/assembly/features/org.eclipse.jpt.tests/feature.properties deleted file mode 100644 index 6b58fe6a33..0000000000 --- a/assembly/features/org.eclipse.jpt.tests/feature.properties +++ /dev/null @@ -1,145 +0,0 @@ -############################################################################### -# Copyright (c) 2006 Oracle. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License 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 API (JPA) project Tests - -# "providerName" property - name of the company that provides the feature -providerName=Eclipse.org - -# "updateSiteName" property - label for the update site -updateSiteName=The Eclipse Web Tools Platform (WTP) Project update site - -# "description" property - description of the feature -description=Dali Java Persistence API (JPA) project Tests - -# "copyright" property - text of the "Feature Update Copyright" -copyright=\ -Copyright (c) 2006 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 -licenseURL=license.html - -# "license" property - text of the "Feature Update License" -# should be plain text version of license agreement pointed to be "licenseURL" -license=\ -ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\ -June 06, 2007\n\ -\n\ -Usage Of Content\n\ -\n\ -THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\ -OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\ -USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\ -AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\ -NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\ -AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\ -AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\ -OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\ -TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\ -OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\ -BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\ -\n\ -Applicable Licenses\n\ -\n\ -Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\ -is provided to you under the terms and conditions of the Eclipse Public\n\ -License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\ -Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\ -For purposes of the EPL, "Program" will mean the Content.\n\ -\n\ -Content includes, but is not limited to, source code, object code,\n\ -documentation and other files maintained in the Eclipse.org CVS\n\ -repository ("Repository") in CVS modules ("Modules") and made available\n\ -as downloadable archives ("Downloads").\n\ -\n\ - - Content may be structured and packaged into modules to facilitate delivering,\n\ - extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\ - plug-in fragments ("Fragments"), and features ("Features").\n\ - - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java? ARchive)\n\ - in a directory named "plugins".\n\ - - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\ - Each Feature may be packaged as a sub-directory in a directory named "features".\n\ - Within a Feature, files named "feature.xml" may contain a list of the names and version\n\ - numbers of the Plug-ins and/or Fragments associated with that Feature.\n\ - - Features may also include other Features ("Included Features"). Within a Feature, files\n\ - named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\ -\n\ -Features may also include other Features ("Included Features"). Files named\n\ -"feature.xml" may contain a list of the names and version numbers of\n\ -Included Features.\n\ -\n\ -The terms and conditions governing Plug-ins and Fragments should be\n\ -contained in files named "about.html" ("Abouts"). The terms and\n\ -conditions governing Features and Included Features should be contained\n\ -in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\ -Licenses may be located in any directory of a Download or Module\n\ -including, but not limited to the following locations:\n\ -\n\ - - The top-level (root) directory\n\ - - Plug-in and Fragment directories\n\ - - Inside Plug-ins and Fragments packaged as JARs\n\ - - Sub-directories of the directory named "src" of certain Plug-ins\n\ - - Feature directories\n\ -\n\ -Note: if a Feature made available by the Eclipse Foundation is installed using the\n\ -Eclipse Update Manager, you must agree to a license ("Feature Update\n\ -License") during the installation process. If the Feature contains\n\ -Included Features, the Feature Update License should either provide you\n\ -with the terms and conditions governing the Included Features or inform\n\ -you where you can locate them. Feature Update Licenses may be found in\n\ -the "license" property of files named "feature.properties". Such Abouts,\n\ -Feature Licenses and Feature Update Licenses contain the terms and\n\ -conditions (or references to such terms and conditions) that govern your\n\ -use of the associated Content in that directory.\n\ -\n\ -THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\ -TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\ -SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\ -\n\ - - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\ - - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\ - - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\ - - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\ - - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\ - - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\ - - Common Development and Distribution License (CDDL) Version 1.0 (available at http://www.sun.com/cddl/cddl.html)\n\ -\n\ -IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\ -TO USE OF THE CONTENT. If no About, Feature License or Feature Update License\n\ -is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\ -govern that particular Content.\n\ -\n\ -Cryptography\n\ -\n\ -Content may contain encryption software. The country in which you are\n\ -currently may have restrictions on the import, possession, and use,\n\ -and/or re-export to another country, of encryption software. BEFORE\n\ -using any encryption software, please check the country's laws,\n\ -regulations and policies concerning the import, possession, or use,\n\ -and re-export of encryption software, to see if this is permitted.\n\ -\n\ -Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.\n -########### end of license property ########################################## diff --git a/assembly/features/org.eclipse.jpt.tests/feature.xml b/assembly/features/org.eclipse.jpt.tests/feature.xml deleted file mode 100644 index 771d849f42..0000000000 --- a/assembly/features/org.eclipse.jpt.tests/feature.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - %description - - - - %copyright - - - - %license - - - - - - - - - diff --git a/assembly/features/org.eclipse.jpt.tests/license.html b/assembly/features/org.eclipse.jpt.tests/license.html deleted file mode 100644 index 56445985d9..0000000000 --- a/assembly/features/org.eclipse.jpt.tests/license.html +++ /dev/null @@ -1,98 +0,0 @@ - - -Eclipse.org Software User Agreement - - - -

Eclipse Foundation Software User Agreement

-

June 06, 2007

-

Usage Of Content

-

THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION -AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). 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.

-

Applicable Licenses

-

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 ("EPL"). A copy of the EPL is provided with this -Content and is also available at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

-

Content includes, but is not limited to, source code, object code, -documentation and other files maintained in the Eclipse.org CVS repository -("Repository") in CVS modules ("Modules") and made available as downloadable -archives ("Downloads").

-

Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments -("Fragments"), and features ("Features"). A Feature is a bundle of one or more -Plug-ins and/or Fragments and associated material. Files named "feature.xml" may -contain a list of the names and version numbers of the Plug-ins and/or Fragments -associated with a Feature. Plug-ins and Fragments are located in directories -named "plugins" and Features are located in directories named "features".

-

Features may also include other Features ("Included Features"). Files named -"feature.xml" may contain a list of the names and version numbers of Included -Features.

-

The terms and conditions governing Plug-ins and Fragments should be contained -in files named "about.html" ("Abouts"). The terms and conditions governing -Features and Included Features should be contained in files named "license.html" -("Feature Licenses"). Abouts and Feature Licenses may be located in any -directory of a Download or Module including, but not limited to the following -locations:

- -

Note: if a Feature made available by the Eclipse Foundation is installed -using the Eclipse Update Manager, you must agree to a license ("Feature Update -License") 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 "license" property of -files named "feature.properties". 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.

-

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):

- -

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.

-

Cryptography

-

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.

diff --git a/assembly/features/org.eclipse.jpt/.cvsignore b/assembly/features/org.eclipse.jpt/.cvsignore deleted file mode 100644 index d9e4340782..0000000000 --- a/assembly/features/org.eclipse.jpt/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -*.bin.dist.zip -build.xml diff --git a/assembly/features/org.eclipse.jpt/.project b/assembly/features/org.eclipse.jpt/.project deleted file mode 100644 index b7aaec2f54..0000000000 --- a/assembly/features/org.eclipse.jpt/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - org.eclipse.jpt - - - - - - org.eclipse.pde.FeatureBuilder - - - - - - org.eclipse.pde.FeatureNature - - diff --git a/assembly/features/org.eclipse.jpt/build.properties b/assembly/features/org.eclipse.jpt/build.properties deleted file mode 100644 index 470b4bcb63..0000000000 --- a/assembly/features/org.eclipse.jpt/build.properties +++ /dev/null @@ -1,16 +0,0 @@ -############################################################################### -# Copyright (c) 2006 Oracle. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License 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,\ - epl-v10.html,\ - license.html,\ - feature.properties - \ No newline at end of file diff --git a/assembly/features/org.eclipse.jpt/eclipse_update_120.jpg b/assembly/features/org.eclipse.jpt/eclipse_update_120.jpg deleted file mode 100644 index bfdf708ad6..0000000000 Binary files a/assembly/features/org.eclipse.jpt/eclipse_update_120.jpg and /dev/null differ diff --git a/assembly/features/org.eclipse.jpt/epl-v10.html b/assembly/features/org.eclipse.jpt/epl-v10.html deleted file mode 100644 index ed4b196655..0000000000 --- a/assembly/features/org.eclipse.jpt/epl-v10.html +++ /dev/null @@ -1,328 +0,0 @@ - - - - - - - - -Eclipse Public License - Version 1.0 - - - - - - -
- -

Eclipse Public License - v 1.0 -

- -

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER -THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, -REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE -OF THIS AGREEMENT.

- -

1. DEFINITIONS

- -

"Contribution" means:

- -

a) -in the case of the initial Contributor, the initial code and documentation -distributed under this Agreement, and
-b) in the case of each subsequent Contributor:

- -

i) -changes to the Program, and

- -

ii) -additions to the Program;

- -

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.

- -

"Contributor" means any person or -entity that distributes the Program.

- -

"Licensed Patents " 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.

- -

"Program" means the Contributions -distributed in accordance with this Agreement.

- -

"Recipient" means anyone who -receives the Program under this Agreement, including all Contributors.

- -

2. GRANT OF RIGHTS

- -

a) -Subject to the terms of this Agreement, each Contributor hereby grants Recipient -a non-exclusive, worldwide, royalty-free copyright license to 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.

- -

b) -Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, 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.

- -

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.

- -

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.

- -

3. REQUIREMENTS

- -

A Contributor may choose to distribute the -Program in object code form under its own license agreement, provided that: -

- -

a) -it complies with the terms and conditions of this Agreement; and

- -

b) -its license agreement:

- -

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;

- -

ii) -effectively excludes on behalf of all Contributors all liability for damages, -including direct, indirect, special, incidental and consequential damages, such -as lost profits;

- -

iii) -states that any provisions which differ from this Agreement are offered by that -Contributor alone and not by any other party; and

- -

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.

- -

When the Program is made available in source -code form:

- -

a) -it must be made available under this Agreement; and

- -

b) a -copy of this Agreement must be included with each copy of the Program.

- -

Contributors may not remove or alter any -copyright notices contained within the Program.

- -

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.

- -

4. COMMERCIAL DISTRIBUTION

- -

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 ("Commercial -Contributor") hereby agrees to defend and indemnify every other -Contributor ("Indemnified Contributor") against any losses, damages and -costs (collectively "Losses") 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.

- -

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.

- -

5. NO WARRANTY

- -

EXCEPT AS EXPRESSLY SET FORTH IN THIS -AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" 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.

- -

6. DISCLAIMER OF LIABILITY

- -

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.

- -

7. GENERAL

- -

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.

- -

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.

- -

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.

- -

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.

- -

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.

- -

 

- -
- - - - \ No newline at end of file diff --git a/assembly/features/org.eclipse.jpt/feature.properties b/assembly/features/org.eclipse.jpt/feature.properties deleted file mode 100644 index 0ae42bbb56..0000000000 --- a/assembly/features/org.eclipse.jpt/feature.properties +++ /dev/null @@ -1,144 +0,0 @@ -############################################################################### -# Copyright (c) 2006 Oracle. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License 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=Java Persistence API Tools - -# "providerName" property - name of the company that provides the feature -providerName=Eclipse.org - -# "updateSiteName" property - label for the update site -updateSiteName=The Eclipse Web Tools Platform (WTP) Project update site - -# "description" property - description of the feature -description=Java Persistence API Tools - Runtime - -# "copyright" property - text of the "Feature Update Copyright" -copyright=\ -Copyright (c) 2006 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 -licenseURL=license.html - -# "license" property - text of the "Feature Update License" -# should be plain text version of license agreement pointed to be "licenseURL" -license=\ -ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\ -March 17, 2005\n\ -\n\ -Usage Of Content\n\ -\n\ -THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\ -OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\ -USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\ -AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\ -NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\ -AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\ -AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\ -OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\ -TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\ -OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\ -BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\ -\n\ -Applicable Licenses\n\ -\n\ -Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\ -is provided to you under the terms and conditions of the Eclipse Public\n\ -License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\ -Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\ -For purposes of the EPL, "Program" will mean the Content.\n\ -\n\ -Content includes, but is not limited to, source code, object code,\n\ -documentation and other files maintained in the Eclipse.org CVS\n\ -repository ("Repository") in CVS modules ("Modules") and made available\n\ -as downloadable archives ("Downloads").\n\ -\n\ - - Content may be structured and packaged into modules to facilitate delivering,\n\ - extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\ - plug-in fragments ("Fragments"), and features ("Features").\n\ - - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java? ARchive)\n\ - in a directory named "plugins".\n\ - - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\ - Each Feature may be packaged as a sub-directory in a directory named "features".\n\ - Within a Feature, files named "feature.xml" may contain a list of the names and version\n\ - numbers of the Plug-ins and/or Fragments associated with that Feature.\n\ - - Features may also include other Features ("Included Features"). Within a Feature, files\n\ - named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\ -\n\ -Features may also include other Features ("Included Features"). Files named\n\ -"feature.xml" may contain a list of the names and version numbers of\n\ -Included Features.\n\ -\n\ -The terms and conditions governing Plug-ins and Fragments should be\n\ -contained in files named "about.html" ("Abouts"). The terms and\n\ -conditions governing Features and Included Features should be contained\n\ -in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\ -Licenses may be located in any directory of a Download or Module\n\ -including, but not limited to the following locations:\n\ -\n\ - - The top-level (root) directory\n\ - - Plug-in and Fragment directories\n\ - - Inside Plug-ins and Fragments packaged as JARs\n\ - - Sub-directories of the directory named "src" of certain Plug-ins\n\ - - Feature directories\n\ -\n\ -Note: if a Feature made available by the Eclipse Foundation is installed using the\n\ -Eclipse Update Manager, you must agree to a license ("Feature Update\n\ -License") during the installation process. If the Feature contains\n\ -Included Features, the Feature Update License should either provide you\n\ -with the terms and conditions governing the Included Features or inform\n\ -you where you can locate them. Feature Update Licenses may be found in\n\ -the "license" property of files named "feature.properties". Such Abouts,\n\ -Feature Licenses and Feature Update Licenses contain the terms and\n\ -conditions (or references to such terms and conditions) that govern your\n\ -use of the associated Content in that directory.\n\ -\n\ -THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\ -TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\ -SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\ -\n\ - - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\ - - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\ - - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\ - - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\ - - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\ - - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\ -\n\ -IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\ -TO USE OF THE CONTENT. If no About, Feature License or Feature Update License\n\ -is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\ -govern that particular Content.\n\ -\n\ -Cryptography\n\ -\n\ -Content may contain encryption software. The country in which you are\n\ -currently may have restrictions on the import, possession, and use,\n\ -and/or re-export to another country, of encryption software. BEFORE\n\ -using any encryption software, please check the country's laws,\n\ -regulations and policies concerning the import, possession, or use,\n\ -and re-export of encryption software, to see if this is permitted.\n\ -\n\ -Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.\n -########### end of license property ########################################## diff --git a/assembly/features/org.eclipse.jpt/feature.xml b/assembly/features/org.eclipse.jpt/feature.xml deleted file mode 100644 index a0f4c82d65..0000000000 --- a/assembly/features/org.eclipse.jpt/feature.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - %description - - - - %copyright - - - - %license - - - - - - - - - - - - diff --git a/assembly/features/org.eclipse.jpt/license.html b/assembly/features/org.eclipse.jpt/license.html deleted file mode 100644 index 2347060ef3..0000000000 --- a/assembly/features/org.eclipse.jpt/license.html +++ /dev/null @@ -1,93 +0,0 @@ - - -Eclipse.org Software User Agreement - - - -

Eclipse Foundation Software User Agreement

-

January 28, 2005

-

Usage Of Content

-

THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION -AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). 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.

-

Applicable Licenses

-

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 ("EPL"). A copy of the EPL is provided with this -Content and is also available at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

-

Content includes, but is not limited to, source code, object code, -documentation and other files maintained in the Eclipse.org CVS repository -("Repository") in CVS modules ("Modules") and made available as downloadable -archives ("Downloads").

-

Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments -("Fragments"), and features ("Features"). A Feature is a bundle of one or more -Plug-ins and/or Fragments and associated material. Files named "feature.xml" may -contain a list of the names and version numbers of the Plug-ins and/or Fragments -associated with a Feature. Plug-ins and Fragments are located in directories -named "plugins" and Features are located in directories named "features".

-

Features may also include other Features ("Included Features"). Files named -"feature.xml" may contain a list of the names and version numbers of Included -Features.

-

The terms and conditions governing Plug-ins and Fragments should be contained -in files named "about.html" ("Abouts"). The terms and conditions governing -Features and Included Features should be contained in files named "license.html" -("Feature Licenses"). Abouts and Feature Licenses may be located in any -directory of a Download or Module including, but not limited to the following -locations:

- -

Note: if a Feature made available by the Eclipse Foundation is installed -using the Eclipse Update Manager, you must agree to a license ("Feature Update -License") 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 "license" property of -files named "feature.properties". 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.

-

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):

- -

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.

-

Cryptography

-

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.

diff --git a/assembly/plugins/org.eclipse.jpt/.cvsignore b/assembly/plugins/org.eclipse.jpt/.cvsignore deleted file mode 100644 index e4254b18e0..0000000000 --- a/assembly/plugins/org.eclipse.jpt/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -bin -temp.folder -build.xml diff --git a/assembly/plugins/org.eclipse.jpt/.project b/assembly/plugins/org.eclipse.jpt/.project deleted file mode 100644 index f51b04cc90..0000000000 --- a/assembly/plugins/org.eclipse.jpt/.project +++ /dev/null @@ -1,22 +0,0 @@ - - - org.eclipse.jpt - - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - - diff --git a/assembly/plugins/org.eclipse.jpt/.settings/org.eclipse.core.resources.prefs b/assembly/plugins/org.eclipse.jpt/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 4aec29d1cd..0000000000 --- a/assembly/plugins/org.eclipse.jpt/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Sun May 27 15:10:09 EDT 2007 -eclipse.preferences.version=1 -encoding/=ISO-8859-1 diff --git a/assembly/plugins/org.eclipse.jpt/META-INF/MANIFEST.MF b/assembly/plugins/org.eclipse.jpt/META-INF/MANIFEST.MF deleted file mode 100644 index f51d1a45fa..0000000000 --- a/assembly/plugins/org.eclipse.jpt/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; singleton:=true -Bundle-Version: 1.0.1.qualifier -Bundle-Localization: plugin -Bundle-Vendor: %providerName diff --git a/assembly/plugins/org.eclipse.jpt/about.html b/assembly/plugins/org.eclipse.jpt/about.html deleted file mode 100644 index ca606b1bb5..0000000000 --- a/assembly/plugins/org.eclipse.jpt/about.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - -About - - - - - -

About This Content

- -

June 06, 2007

- -

License

- -

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 -http://www.eclipse.org/org/documents/epl-v10.php. -For purposes of the EPL, "Program" will mean the Content.

- -

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 -http://www.eclipse.org/.

- - - \ No newline at end of file diff --git a/assembly/plugins/org.eclipse.jpt/about.ini b/assembly/plugins/org.eclipse.jpt/about.ini deleted file mode 100644 index 588a325a8f..0000000000 --- a/assembly/plugins/org.eclipse.jpt/about.ini +++ /dev/null @@ -1,44 +0,0 @@ -############################################################################### -# Copyright (c) 2006 Oracle. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License 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=eclipse32.gif - -# 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/assembly/plugins/org.eclipse.jpt/about.mappings b/assembly/plugins/org.eclipse.jpt/about.mappings deleted file mode 100644 index bddaab4310..0000000000 --- a/assembly/plugins/org.eclipse.jpt/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/assembly/plugins/org.eclipse.jpt/about.properties b/assembly/plugins/org.eclipse.jpt/about.properties deleted file mode 100644 index 159bfceeba..0000000000 --- a/assembly/plugins/org.eclipse.jpt/about.properties +++ /dev/null @@ -1,24 +0,0 @@ -############################################################################### -# Copyright (c) 2006 Oracle. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License 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=Java Persistence API Tools\n\ -\n\ -Version: {featureVersion}\n\ -Build id: {0}\n\ -\n\ -(c) Copyright Eclipse contributors and others 2006. All rights reserved.\n\ -Visit http://www.eclipse.org/webtools diff --git a/assembly/plugins/org.eclipse.jpt/build.properties b/assembly/plugins/org.eclipse.jpt/build.properties deleted file mode 100644 index 0ccfb0ebb8..0000000000 --- a/assembly/plugins/org.eclipse.jpt/build.properties +++ /dev/null @@ -1,19 +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 -############################################################################### -bin.includes = META-INF/,\ - about.ini,\ - about.html,\ - about.mappings,\ - about.properties,\ - eclipse32.gif,\ - eclipse32.png,\ - plugin.properties,\ - component.xml diff --git a/assembly/plugins/org.eclipse.jpt/component.xml b/assembly/plugins/org.eclipse.jpt/component.xml deleted file mode 100644 index 11f133f65a..0000000000 --- a/assembly/plugins/org.eclipse.jpt/component.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/assembly/plugins/org.eclipse.jpt/eclipse32.gif b/assembly/plugins/org.eclipse.jpt/eclipse32.gif deleted file mode 100644 index e6ad7ccd75..0000000000 Binary files a/assembly/plugins/org.eclipse.jpt/eclipse32.gif and /dev/null differ diff --git a/assembly/plugins/org.eclipse.jpt/eclipse32.png b/assembly/plugins/org.eclipse.jpt/eclipse32.png deleted file mode 100644 index 568fac1d05..0000000000 Binary files a/assembly/plugins/org.eclipse.jpt/eclipse32.png and /dev/null differ diff --git a/assembly/plugins/org.eclipse.jpt/plugin.properties b/assembly/plugins/org.eclipse.jpt/plugin.properties deleted file mode 100644 index f45a08d54e..0000000000 --- a/assembly/plugins/org.eclipse.jpt/plugin.properties +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# Copyright (c) 2006 Oracle. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License 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 = Java Persistence API Tools -providerName = Eclipse.org diff --git a/jpa/features/org.eclipse.jpt.feature/.project b/jpa/features/org.eclipse.jpt.feature/.project deleted file mode 100644 index c8eb2f0481..0000000000 --- a/jpa/features/org.eclipse.jpt.feature/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - org.eclipse.jpt.feature - - - - - - org.eclipse.pde.FeatureBuilder - - - - - - org.eclipse.pde.FeatureNature - - diff --git a/jpa/features/org.eclipse.jpt.feature/.settings/org.eclipse.core.resources.prefs b/jpa/features/org.eclipse.jpt.feature/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index dab5837cb6..0000000000 --- a/jpa/features/org.eclipse.jpt.feature/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Sun May 27 15:10:47 EDT 2007 -eclipse.preferences.version=1 -encoding/=ISO-8859-1 diff --git a/jpa/features/org.eclipse.jpt.feature/build.properties b/jpa/features/org.eclipse.jpt.feature/build.properties deleted file mode 100644 index 7200939aca..0000000000 --- a/jpa/features/org.eclipse.jpt.feature/build.properties +++ /dev/null @@ -1,15 +0,0 @@ -############################################################################### -# Copyright (c) 2006 Oracle. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License 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,\ - epl-v10.html,\ - license.html,\ - feature.properties diff --git a/jpa/features/org.eclipse.jpt.feature/eclipse_update_120.jpg b/jpa/features/org.eclipse.jpt.feature/eclipse_update_120.jpg deleted file mode 100644 index bfdf708ad6..0000000000 Binary files a/jpa/features/org.eclipse.jpt.feature/eclipse_update_120.jpg and /dev/null differ diff --git a/jpa/features/org.eclipse.jpt.feature/epl-v10.html b/jpa/features/org.eclipse.jpt.feature/epl-v10.html deleted file mode 100644 index ed4b196655..0000000000 --- a/jpa/features/org.eclipse.jpt.feature/epl-v10.html +++ /dev/null @@ -1,328 +0,0 @@ - - - - - - - - -Eclipse Public License - Version 1.0 - - - - - - -
- -

Eclipse Public License - v 1.0 -

- -

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER -THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, -REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE -OF THIS AGREEMENT.

- -

1. DEFINITIONS

- -

"Contribution" means:

- -

a) -in the case of the initial Contributor, the initial code and documentation -distributed under this Agreement, and
-b) in the case of each subsequent Contributor:

- -

i) -changes to the Program, and

- -

ii) -additions to the Program;

- -

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.

- -

"Contributor" means any person or -entity that distributes the Program.

- -

"Licensed Patents " 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.

- -

"Program" means the Contributions -distributed in accordance with this Agreement.

- -

"Recipient" means anyone who -receives the Program under this Agreement, including all Contributors.

- -

2. GRANT OF RIGHTS

- -

a) -Subject to the terms of this Agreement, each Contributor hereby grants Recipient -a non-exclusive, worldwide, royalty-free copyright license to 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.

- -

b) -Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, 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.

- -

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.

- -

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.

- -

3. REQUIREMENTS

- -

A Contributor may choose to distribute the -Program in object code form under its own license agreement, provided that: -

- -

a) -it complies with the terms and conditions of this Agreement; and

- -

b) -its license agreement:

- -

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;

- -

ii) -effectively excludes on behalf of all Contributors all liability for damages, -including direct, indirect, special, incidental and consequential damages, such -as lost profits;

- -

iii) -states that any provisions which differ from this Agreement are offered by that -Contributor alone and not by any other party; and

- -

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.

- -

When the Program is made available in source -code form:

- -

a) -it must be made available under this Agreement; and

- -

b) a -copy of this Agreement must be included with each copy of the Program.

- -

Contributors may not remove or alter any -copyright notices contained within the Program.

- -

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.

- -

4. COMMERCIAL DISTRIBUTION

- -

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 ("Commercial -Contributor") hereby agrees to defend and indemnify every other -Contributor ("Indemnified Contributor") against any losses, damages and -costs (collectively "Losses") 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.

- -

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.

- -

5. NO WARRANTY

- -

EXCEPT AS EXPRESSLY SET FORTH IN THIS -AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" 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.

- -

6. DISCLAIMER OF LIABILITY

- -

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.

- -

7. GENERAL

- -

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.

- -

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.

- -

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.

- -

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.

- -

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.

- -

 

- -
- - - - \ No newline at end of file diff --git a/jpa/features/org.eclipse.jpt.feature/feature.properties b/jpa/features/org.eclipse.jpt.feature/feature.properties deleted file mode 100644 index a2b39f3024..0000000000 --- a/jpa/features/org.eclipse.jpt.feature/feature.properties +++ /dev/null @@ -1,140 +0,0 @@ -############################################################################### -# Copyright (c) 2006 Oracle. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License 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=Java Persistence API Tools - -# "providerName" property - name of the company that provides the feature -providerName=Eclipse.org - -# "updateSiteName" property - label for the update site -updateSiteName=The Eclipse Web Tools Platform (WTP) Project update site - -# "description" property - description of the feature -description=Java Persistence API (JPA) Tools - -# "copyright" property - text of the "Feature Update Copyright" -copyright=\ -Copyright (c) 2006-07 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 -licenseURL=license.html - -# "license" property - text of the "Feature Update License" -# should be plain text version of license agreement pointed to be "licenseURL" -license=\ -ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\ -June 06, 2007\n\ -\n\ -Usage Of Content\n\ -\n\ -THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\ -OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\ -USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\ -AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\ -NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\ -AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\ -AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\ -OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\ -TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\ -OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\ -BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\ -\n\ -Applicable Licenses\n\ -\n\ -Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\ -is provided to you under the terms and conditions of the Eclipse Public\n\ -License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\ -Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\ -For purposes of the EPL, "Program" will mean the Content.\n\ -\n\ -Content includes, but is not limited to, source code, object code,\n\ -documentation and other files maintained in the Eclipse.org CVS\n\ -repository ("Repository") in CVS modules ("Modules") and made available\n\ -as downloadable archives ("Downloads").\n\ -\n\ - - Content may be structured and packaged into modules to facilitate delivering,\n\ - extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\ - plug-in fragments ("Fragments"), and features ("Features").\n\ - - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java? ARchive)\n\ - in a directory named "plugins".\n\ - - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\ - Each Feature may be packaged as a sub-directory in a directory named "features".\n\ - Within a Feature, files named "feature.xml" may contain a list of the names and version\n\ - numbers of the Plug-ins and/or Fragments associated with that Feature.\n\ - - Features may also include other Features ("Included Features"). Within a Feature, files\n\ - named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\ -\n\ -Features may also include other Features ("Included Features"). Files named\n\ -"feature.xml" may contain a list of the names and version numbers of\n\ -Included Features.\n\ -\n\ -The terms and conditions governing Plug-ins and Fragments should be\n\ -contained in files named "about.html" ("Abouts"). The terms and\n\ -conditions governing Features and Included Features should be contained\n\ -in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\ -Licenses may be located in any directory of a Download or Module\n\ -including, but not limited to the following locations:\n\ -\n\ - - The top-level (root) directory\n\ - - Plug-in and Fragment directories\n\ - - Inside Plug-ins and Fragments packaged as JARs\n\ - - Sub-directories of the directory named "src" of certain Plug-ins\n\ - - Feature directories\n\ -\n\ -Note: if a Feature made available by the Eclipse Foundation is installed using the\n\ -Eclipse Update Manager, you must agree to a license ("Feature Update\n\ -License") during the installation process. If the Feature contains\n\ -Included Features, the Feature Update License should either provide you\n\ -with the terms and conditions governing the Included Features or inform\n\ -you where you can locate them. Feature Update Licenses may be found in\n\ -the "license" property of files named "feature.properties". Such Abouts,\n\ -Feature Licenses and Feature Update Licenses contain the terms and\n\ -conditions (or references to such terms and conditions) that govern your\n\ -use of the associated Content in that directory.\n\ -\n\ -THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\ -TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\ -SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\ -\n\ - - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\ - - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\ - - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\ - - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\ - - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\ - - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\ - - Common Development and Distribution License (CDDL) Version 1.0 (available at http://www.sun.com/cddl/cddl.html)\n\ -\n\ -IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\ -TO USE OF THE CONTENT. If no About, Feature License or Feature Update License\n\ -is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\ -govern that particular Content.\n\ -\n\ -Cryptography\n\ -\n\ -Content may contain encryption software. The country in which you are\n\ -currently may have restrictions on the import, possession, and use,\n\ -and/or re-export to another country, of encryption software. BEFORE\n\ -using any encryption software, please check the country's laws,\n\ -regulations and policies concerning the import, possession, or use,\n\ -and re-export of encryption software, to see if this is permitted.\n\ -\n\ -Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.\n -########### end of license property ########################################## diff --git a/jpa/features/org.eclipse.jpt.feature/feature.xml b/jpa/features/org.eclipse.jpt.feature/feature.xml deleted file mode 100644 index ed0f42dbd1..0000000000 --- a/jpa/features/org.eclipse.jpt.feature/feature.xml +++ /dev/null @@ -1,121 +0,0 @@ - - - - - %description - - - - %copyright - - - - %license - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jpa/features/org.eclipse.jpt.feature/license.html b/jpa/features/org.eclipse.jpt.feature/license.html deleted file mode 100644 index fc77372d46..0000000000 --- a/jpa/features/org.eclipse.jpt.feature/license.html +++ /dev/null @@ -1,98 +0,0 @@ - - -Eclipse.org Software User Agreement - - - -

Eclipse Foundation Software User Agreement

-

June 06, 2007

-

Usage Of Content

-

THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION -AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). 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.

-

Applicable Licenses

-

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 ("EPL"). A copy of the EPL is provided with this -Content and is also available at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

-

Content includes, but is not limited to, source code, object code, -documentation and other files maintained in the Eclipse.org CVS repository -("Repository") in CVS modules ("Modules") and made available as downloadable -archives ("Downloads").

-

Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments -("Fragments"), and features ("Features"). A Feature is a bundle of one or more -Plug-ins and/or Fragments and associated material. Files named "feature.xml" may -contain a list of the names and version numbers of the Plug-ins and/or Fragments -associated with a Feature. Plug-ins and Fragments are located in directories -named "plugins" and Features are located in directories named "features".

-

Features may also include other Features ("Included Features"). Files named -"feature.xml" may contain a list of the names and version numbers of Included -Features.

-

The terms and conditions governing Plug-ins and Fragments should be contained -in files named "about.html" ("Abouts"). The terms and conditions governing -Features and Included Features should be contained in files named "license.html" -("Feature Licenses"). Abouts and Feature Licenses may be located in any -directory of a Download or Module including, but not limited to the following -locations:

-
    -
  • The top-level (root) directory -
  • Plug-in and Fragment directories -
  • Subdirectories of the directory named "src" of certain Plug-ins -
  • Feature directories
-

Note: if a Feature made available by the Eclipse Foundation is installed -using the Eclipse Update Manager, you must agree to a license ("Feature Update -License") 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 "license" property of -files named "feature.properties". 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.

-

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):

- -

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.

-

Cryptography

-

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.

diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/build.properties b/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/build.properties deleted file mode 100644 index 997dd3f0c7..0000000000 --- a/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/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 -############################################################################### -bin.includes =\ -epl-v10.html,\ -eclipse_update_120.jpg,\ -feature.xml,\ -feature.properties,\ -license.html diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/eclipse_update_120.jpg b/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/eclipse_update_120.jpg deleted file mode 100644 index bfdf708ad6..0000000000 Binary files a/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/eclipse_update_120.jpg and /dev/null differ diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/epl-v10.html b/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/epl-v10.html deleted file mode 100644 index 022ad2955b..0000000000 --- a/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/epl-v10.html +++ /dev/null @@ -1,328 +0,0 @@ - - - - - - - - -Eclipse Public License - Version 1.0 - - - - - - -
- -

Eclipse Public License - v 1.0 -

- -

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER -THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, -REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE -OF THIS AGREEMENT.

- -

1. DEFINITIONS

- -

"Contribution" means:

- -

a) -in the case of the initial Contributor, the initial code and documentation -distributed under this Agreement, and
-b) in the case of each subsequent Contributor:

- -

i) -changes to the Program, and

- -

ii) -additions to the Program;

- -

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.

- -

"Contributor" means any person or -entity that distributes the Program.

- -

"Licensed Patents " 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.

- -

"Program" means the Contributions -distributed in accordance with this Agreement.

- -

"Recipient" means anyone who -receives the Program under this Agreement, including all Contributors.

- -

2. GRANT OF RIGHTS

- -

a) -Subject to the terms of this Agreement, each Contributor hereby grants Recipient -a non-exclusive, worldwide, royalty-free copyright license to 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.

- -

b) -Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, 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.

- -

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.

- -

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.

- -

3. REQUIREMENTS

- -

A Contributor may choose to distribute the -Program in object code form under its own license agreement, provided that: -

- -

a) -it complies with the terms and conditions of this Agreement; and

- -

b) -its license agreement:

- -

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;

- -

ii) -effectively excludes on behalf of all Contributors all liability for damages, -including direct, indirect, special, incidental and consequential damages, such -as lost profits;

- -

iii) -states that any provisions which differ from this Agreement are offered by that -Contributor alone and not by any other party; and

- -

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.

- -

When the Program is made available in source -code form:

- -

a) -it must be made available under this Agreement; and

- -

b) a -copy of this Agreement must be included with each copy of the Program.

- -

Contributors may not remove or alter any -copyright notices contained within the Program.

- -

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.

- -

4. COMMERCIAL DISTRIBUTION

- -

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 ("Commercial -Contributor") hereby agrees to defend and indemnify every other -Contributor ("Indemnified Contributor") against any losses, damages and -costs (collectively "Losses") 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.

- -

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.

- -

5. NO WARRANTY

- -

EXCEPT AS EXPRESSLY SET FORTH IN THIS -AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" 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.

- -

6. DISCLAIMER OF LIABILITY

- -

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.

- -

7. GENERAL

- -

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.

- -

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.

- -

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.

- -

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.

- -

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.

- -

 

- -
- - - - diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/feature.properties b/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/feature.properties deleted file mode 100644 index 0c1da15ce6..0000000000 --- a/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/feature.properties +++ /dev/null @@ -1,145 +0,0 @@ -############################################################################### -# Copyright (c) 2006 Oracle. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License 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 API (JPA) Tools - -# "providerName" property - name of the company that provides the feature -providerName=Eclipse.org - -# "updateSiteName" property - label for the update site -updateSiteName=The Eclipse Web Tools Platform (WTP) Project update site - -# "description" property - description of the feature -description=Dali Java Persistence API (JPA) Tools - -# "copyright" property - text of the "Feature Update Copyright" -copyright=\ -Copyright (c) 2006 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 -licenseURL=license.html - -# "license" property - text of the "Feature Update License" -# should be plain text version of license agreement pointed to be "licenseURL" -license=\ -ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\ -June 06, 2007\n\ -\n\ -Usage Of Content\n\ -\n\ -THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\ -OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\ -USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\ -AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\ -NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\ -AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\ -AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\ -OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\ -TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\ -OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\ -BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\ -\n\ -Applicable Licenses\n\ -\n\ -Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\ -is provided to you under the terms and conditions of the Eclipse Public\n\ -License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\ -Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\ -For purposes of the EPL, "Program" will mean the Content.\n\ -\n\ -Content includes, but is not limited to, source code, object code,\n\ -documentation and other files maintained in the Eclipse.org CVS\n\ -repository ("Repository") in CVS modules ("Modules") and made available\n\ -as downloadable archives ("Downloads").\n\ -\n\ - - Content may be structured and packaged into modules to facilitate delivering,\n\ - extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\ - plug-in fragments ("Fragments"), and features ("Features").\n\ - - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java? ARchive)\n\ - in a directory named "plugins".\n\ - - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\ - Each Feature may be packaged as a sub-directory in a directory named "features".\n\ - Within a Feature, files named "feature.xml" may contain a list of the names and version\n\ - numbers of the Plug-ins and/or Fragments associated with that Feature.\n\ - - Features may also include other Features ("Included Features"). Within a Feature, files\n\ - named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\ -\n\ -Features may also include other Features ("Included Features"). Files named\n\ -"feature.xml" may contain a list of the names and version numbers of\n\ -Included Features.\n\ -\n\ -The terms and conditions governing Plug-ins and Fragments should be\n\ -contained in files named "about.html" ("Abouts"). The terms and\n\ -conditions governing Features and Included Features should be contained\n\ -in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\ -Licenses may be located in any directory of a Download or Module\n\ -including, but not limited to the following locations:\n\ -\n\ - - The top-level (root) directory\n\ - - Plug-in and Fragment directories\n\ - - Inside Plug-ins and Fragments packaged as JARs\n\ - - Sub-directories of the directory named "src" of certain Plug-ins\n\ - - Feature directories\n\ -\n\ -Note: if a Feature made available by the Eclipse Foundation is installed using the\n\ -Eclipse Update Manager, you must agree to a license ("Feature Update\n\ -License") during the installation process. If the Feature contains\n\ -Included Features, the Feature Update License should either provide you\n\ -with the terms and conditions governing the Included Features or inform\n\ -you where you can locate them. Feature Update Licenses may be found in\n\ -the "license" property of files named "feature.properties". Such Abouts,\n\ -Feature Licenses and Feature Update Licenses contain the terms and\n\ -conditions (or references to such terms and conditions) that govern your\n\ -use of the associated Content in that directory.\n\ -\n\ -THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\ -TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\ -SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\ -\n\ - - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\ - - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\ - - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\ - - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\ - - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\ - - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\ - - Common Development and Distribution License (CDDL) Version 1.0 (available at http://www.sun.com/cddl/cddl.html)\n\ -\n\ -IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\ -TO USE OF THE CONTENT. If no About, Feature License or Feature Update License\n\ -is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\ -govern that particular Content.\n\ -\n\ -Cryptography\n\ -\n\ -Content may contain encryption software. The country in which you are\n\ -currently may have restrictions on the import, possession, and use,\n\ -and/or re-export to another country, of encryption software. BEFORE\n\ -using any encryption software, please check the country's laws,\n\ -regulations and policies concerning the import, possession, or use,\n\ -and re-export of encryption software, to see if this is permitted.\n\ -\n\ -Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.\n -########### end of license property ########################################## diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/feature.xml b/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/feature.xml deleted file mode 100644 index 12e267e1de..0000000000 --- a/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/feature.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - %description - - - - %copyright - - - - %license - - - - - diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/license.html b/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/license.html deleted file mode 100644 index fec4a489ad..0000000000 --- a/jpa/features/org.eclipse.jpt.feature/sourceTemplateFeature/license.html +++ /dev/null @@ -1,82 +0,0 @@ - - - - -Eclipse.org Software User Agreement - - - -

Eclipse Foundation Software User Agreement

-

June 06, 2007

- -

Usage Of Content

- -

THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS - (COLLECTIVELY "CONTENT"). 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.

- -

Applicable Licenses

- -

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 - ("EPL"). A copy of the EPL is provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html. - For purposes of the EPL, "Program" will mean the Content.

- -

Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse.org CVS repository ("Repository") in CVS - modules ("Modules") and made available as downloadable archives ("Downloads").

- -
    -
  • Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features").
  • -
  • Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java™ ARchive) in a directory named "plugins".
  • -
  • 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 "features". Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins - and/or Fragments associated with that Feature.
  • -
  • Features may also include other Features ("Included Features"). Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of Included Features.
  • -
- -

The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and -Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module -including, but not limited to the following locations:

- -
    -
  • The top-level (root) directory
  • -
  • Plug-in and Fragment directories
  • -
  • Inside Plug-ins and Fragments packaged as JARs
  • -
  • Sub-directories of the directory named "src" of certain Plug-ins
  • -
  • Feature directories
  • -
- -

Note: if a Feature made available by the Eclipse Foundation is installed using the Eclipse Update Manager, you must agree to a license ("Feature Update License") 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 "license" property of files named "feature.properties" 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.

- -

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):

- - - -

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.

- -

Cryptography

- -

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.

- -Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both. - - diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.html b/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.html deleted file mode 100644 index d4916df475..0000000000 --- a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.html +++ /dev/null @@ -1,27 +0,0 @@ - - - -About - - - -

About This Content

- -

June 06, 2007

-

License

- -

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 http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

- -

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.

- -

Source Code

-

This plug-in contains source code zip files ("Source Zips") 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 "about.html" files ("Abouts") 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.

- - - diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.ini b/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.ini deleted file mode 100644 index 2dee36a2e2..0000000000 --- a/jpa/features/org.eclipse.jpt.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/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.mappings b/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.mappings deleted file mode 100644 index a28390a75e..0000000000 --- a/jpa/features/org.eclipse.jpt.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/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.properties b/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.properties deleted file mode 100644 index 5e52cb277e..0000000000 --- a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/about.properties +++ /dev/null @@ -1,26 +0,0 @@ -############################################################################### -# Copyright (c) 2000, 2005 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -############################################################################### -# 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=JavaServer Faces Tooling Source\n\ -\n\ -Version: {featureVersion}\n\ -Build id: {0}\n\ -\n\ -(c) Copyright Eclipse contributors and others 2005. All rights reserved.\n\ -Visit http://www.eclipse.org/webtools - diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/build.properties b/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/build.properties deleted file mode 100644 index e3098b39b2..0000000000 --- a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/build.properties +++ /dev/null @@ -1,11 +0,0 @@ -bin.includes =\ - about.html,\ - about.ini,\ - about.mappings,\ - about.properties,\ - eclipse32.gif,\ - plugin.properties,\ - plugin.xml,\ - src/**,\ - META-INF/ -sourcePlugin = true diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse32.gif b/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse32.gif deleted file mode 100644 index e6ad7ccd75..0000000000 Binary files a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse32.gif and /dev/null differ diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse32.png b/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse32.png deleted file mode 100644 index 50ae49de24..0000000000 Binary files a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse32.png and /dev/null differ diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse_update_120.jpg b/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse_update_120.jpg deleted file mode 100644 index bfdf708ad6..0000000000 Binary files a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/eclipse_update_120.jpg and /dev/null differ diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/epl-v10.html b/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/epl-v10.html deleted file mode 100644 index 022ad2955b..0000000000 --- a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/epl-v10.html +++ /dev/null @@ -1,328 +0,0 @@ - - - - - - - - -Eclipse Public License - Version 1.0 - - - - - - -
- -

Eclipse Public License - v 1.0 -

- -

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER -THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, -REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE -OF THIS AGREEMENT.

- -

1. DEFINITIONS

- -

"Contribution" means:

- -

a) -in the case of the initial Contributor, the initial code and documentation -distributed under this Agreement, and
-b) in the case of each subsequent Contributor:

- -

i) -changes to the Program, and

- -

ii) -additions to the Program;

- -

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.

- -

"Contributor" means any person or -entity that distributes the Program.

- -

"Licensed Patents " 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.

- -

"Program" means the Contributions -distributed in accordance with this Agreement.

- -

"Recipient" means anyone who -receives the Program under this Agreement, including all Contributors.

- -

2. GRANT OF RIGHTS

- -

a) -Subject to the terms of this Agreement, each Contributor hereby grants Recipient -a non-exclusive, worldwide, royalty-free copyright license to 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.

- -

b) -Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, 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.

- -

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.

- -

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.

- -

3. REQUIREMENTS

- -

A Contributor may choose to distribute the -Program in object code form under its own license agreement, provided that: -

- -

a) -it complies with the terms and conditions of this Agreement; and

- -

b) -its license agreement:

- -

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;

- -

ii) -effectively excludes on behalf of all Contributors all liability for damages, -including direct, indirect, special, incidental and consequential damages, such -as lost profits;

- -

iii) -states that any provisions which differ from this Agreement are offered by that -Contributor alone and not by any other party; and

- -

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.

- -

When the Program is made available in source -code form:

- -

a) -it must be made available under this Agreement; and

- -

b) a -copy of this Agreement must be included with each copy of the Program.

- -

Contributors may not remove or alter any -copyright notices contained within the Program.

- -

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.

- -

4. COMMERCIAL DISTRIBUTION

- -

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 ("Commercial -Contributor") hereby agrees to defend and indemnify every other -Contributor ("Indemnified Contributor") against any losses, damages and -costs (collectively "Losses") 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.

- -

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.

- -

5. NO WARRANTY

- -

EXCEPT AS EXPRESSLY SET FORTH IN THIS -AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" 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.

- -

6. DISCLAIMER OF LIABILITY

- -

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.

- -

7. GENERAL

- -

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.

- -

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.

- -

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.

- -

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.

- -

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.

- -

 

- -
- - - - diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/license.html b/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/license.html deleted file mode 100644 index 14b1d50265..0000000000 --- a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/license.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - -Eclipse.org Software User Agreement - - - -

Eclipse Foundation Software User Agreement

-

June 06, 2007

- -

Usage Of Content

- -

THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS - (COLLECTIVELY "CONTENT"). 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.

- -

Applicable Licenses

- -

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 - ("EPL"). A copy of the EPL is provided with this Content and is also available at http://www.eclipse.org/legal/epl-v10.html. - For purposes of the EPL, "Program" will mean the Content.

- -

Content includes, but is not limited to, source code, object code, documentation and other files maintained in the Eclipse.org CVS repository ("Repository") in CVS - modules ("Modules") and made available as downloadable archives ("Downloads").

- -
    -
  • Content may be structured and packaged into modules to facilitate delivering, extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"), plug-in fragments ("Fragments"), and features ("Features").
  • -
  • Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java™ ARchive) in a directory named "plugins".
  • -
  • 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 "features". Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of the Plug-ins - and/or Fragments associated with that Feature.
  • -
  • Features may also include other Features ("Included Features"). Within a Feature, files named "feature.xml" may contain a list of the names and version numbers of Included Features.
  • -
- -

The terms and conditions governing Plug-ins and Fragments should be contained in files named "about.html" ("Abouts"). The terms and conditions governing Features and -Included Features should be contained in files named "license.html" ("Feature Licenses"). Abouts and Feature Licenses may be located in any directory of a Download or Module -including, but not limited to the following locations:

- -
    -
  • The top-level (root) directory
  • -
  • Plug-in and Fragment directories
  • -
  • Inside Plug-ins and Fragments packaged as JARs
  • -
  • Sub-directories of the directory named "src" of certain Plug-ins
  • -
  • Feature directories
  • -
- -

Note: if a Feature made available by the Eclipse Foundation is installed using the Eclipse Update Manager, you must agree to a license ("Feature Update License") 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 "license" property of files named "feature.properties" 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.

- -

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):

- - - -

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.

- -

Cryptography

- -

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.

- -Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both. - - diff --git a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/plugin.properties b/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/plugin.properties deleted file mode 100644 index 088161f801..0000000000 --- a/jpa/features/org.eclipse.jpt.feature/sourceTemplatePlugin/plugin.properties +++ /dev/null @@ -1,13 +0,0 @@ -############################################################################### -# Copyright (c) 2006 Oracle. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License 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 API (JPA) Tools -providerName = Eclipse.org diff --git a/jpa/features/org.eclipse.jpt.tests.feature/.project b/jpa/features/org.eclipse.jpt.tests.feature/.project deleted file mode 100644 index 91760f21b4..0000000000 --- a/jpa/features/org.eclipse.jpt.tests.feature/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - org.eclipse.jpt.tests.feature - - - - - - org.eclipse.pde.FeatureBuilder - - - - - - org.eclipse.pde.FeatureNature - - diff --git a/jpa/features/org.eclipse.jpt.tests.feature/.settings/org.eclipse.core.resources.prefs b/jpa/features/org.eclipse.jpt.tests.feature/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 235b84ae83..0000000000 --- a/jpa/features/org.eclipse.jpt.tests.feature/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Sun May 27 15:11:17 EDT 2007 -eclipse.preferences.version=1 -encoding/=ISO-8859-1 diff --git a/jpa/features/org.eclipse.jpt.tests.feature/build.properties b/jpa/features/org.eclipse.jpt.tests.feature/build.properties deleted file mode 100644 index d6a4dce096..0000000000 --- a/jpa/features/org.eclipse.jpt.tests.feature/build.properties +++ /dev/null @@ -1,10 +0,0 @@ -bin.includes = feature.xml,\ - eclipse_update_120.jpg,\ - epl-v10.html,\ - license.html,\ - feature.properties -src.includes = license.html,\ - feature.xml,\ - epl-v10.html,\ - eclipse_update_120.jpg,\ - build.properties diff --git a/jpa/features/org.eclipse.jpt.tests.feature/eclipse_update_120.jpg b/jpa/features/org.eclipse.jpt.tests.feature/eclipse_update_120.jpg deleted file mode 100644 index bfdf708ad6..0000000000 Binary files a/jpa/features/org.eclipse.jpt.tests.feature/eclipse_update_120.jpg and /dev/null differ diff --git a/jpa/features/org.eclipse.jpt.tests.feature/epl-v10.html b/jpa/features/org.eclipse.jpt.tests.feature/epl-v10.html deleted file mode 100644 index ed4b196655..0000000000 --- a/jpa/features/org.eclipse.jpt.tests.feature/epl-v10.html +++ /dev/null @@ -1,328 +0,0 @@ - - - - - - - - -Eclipse Public License - Version 1.0 - - - - - - -
- -

Eclipse Public License - v 1.0 -

- -

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER -THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, -REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE -OF THIS AGREEMENT.

- -

1. DEFINITIONS

- -

"Contribution" means:

- -

a) -in the case of the initial Contributor, the initial code and documentation -distributed under this Agreement, and
-b) in the case of each subsequent Contributor:

- -

i) -changes to the Program, and

- -

ii) -additions to the Program;

- -

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.

- -

"Contributor" means any person or -entity that distributes the Program.

- -

"Licensed Patents " 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.

- -

"Program" means the Contributions -distributed in accordance with this Agreement.

- -

"Recipient" means anyone who -receives the Program under this Agreement, including all Contributors.

- -

2. GRANT OF RIGHTS

- -

a) -Subject to the terms of this Agreement, each Contributor hereby grants Recipient -a non-exclusive, worldwide, royalty-free copyright license to 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.

- -

b) -Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, 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.

- -

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.

- -

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.

- -

3. REQUIREMENTS

- -

A Contributor may choose to distribute the -Program in object code form under its own license agreement, provided that: -

- -

a) -it complies with the terms and conditions of this Agreement; and

- -

b) -its license agreement:

- -

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;

- -

ii) -effectively excludes on behalf of all Contributors all liability for damages, -including direct, indirect, special, incidental and consequential damages, such -as lost profits;

- -

iii) -states that any provisions which differ from this Agreement are offered by that -Contributor alone and not by any other party; and

- -

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.

- -

When the Program is made available in source -code form:

- -

a) -it must be made available under this Agreement; and

- -

b) a -copy of this Agreement must be included with each copy of the Program.

- -

Contributors may not remove or alter any -copyright notices contained within the Program.

- -

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.

- -

4. COMMERCIAL DISTRIBUTION

- -

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 ("Commercial -Contributor") hereby agrees to defend and indemnify every other -Contributor ("Indemnified Contributor") against any losses, damages and -costs (collectively "Losses") 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.

- -

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.

- -

5. NO WARRANTY

- -

EXCEPT AS EXPRESSLY SET FORTH IN THIS -AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" 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.

- -

6. DISCLAIMER OF LIABILITY

- -

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.

- -

7. GENERAL

- -

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.

- -

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.

- -

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.

- -

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.

- -

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.

- -

 

- -
- - - - \ No newline at end of file diff --git a/jpa/features/org.eclipse.jpt.tests.feature/feature.properties b/jpa/features/org.eclipse.jpt.tests.feature/feature.properties deleted file mode 100644 index 33ec536d55..0000000000 --- a/jpa/features/org.eclipse.jpt.tests.feature/feature.properties +++ /dev/null @@ -1,145 +0,0 @@ -############################################################################### -# Copyright (c) 2006 Oracle. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License 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 - -# "providerName" property - name of the company that provides the feature -providerName=Eclipse.org - -# "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 API (JPA) Tools - -# "copyright" property - text of the "Feature Update Copyright" -copyright=\ -Copyright (c) 2006 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 -licenseURL=license.html - -# "license" property - text of the "Feature Update License" -# should be plain text version of license agreement pointed to be "licenseURL" -license=\ -ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\ -June 06, 2007\n\ -\n\ -Usage Of Content\n\ -\n\ -THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\ -OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\ -USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\ -AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\ -NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\ -AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\ -AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\ -OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\ -TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\ -OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\ -BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\ -\n\ -Applicable Licenses\n\ -\n\ -Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\ -is provided to you under the terms and conditions of the Eclipse Public\n\ -License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\ -Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\ -For purposes of the EPL, "Program" will mean the Content.\n\ -\n\ -Content includes, but is not limited to, source code, object code,\n\ -documentation and other files maintained in the Eclipse.org CVS\n\ -repository ("Repository") in CVS modules ("Modules") and made available\n\ -as downloadable archives ("Downloads").\n\ -\n\ - - Content may be structured and packaged into modules to facilitate delivering,\n\ - extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\ - plug-in fragments ("Fragments"), and features ("Features").\n\ - - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java? ARchive)\n\ - in a directory named "plugins".\n\ - - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\ - Each Feature may be packaged as a sub-directory in a directory named "features".\n\ - Within a Feature, files named "feature.xml" may contain a list of the names and version\n\ - numbers of the Plug-ins and/or Fragments associated with that Feature.\n\ - - Features may also include other Features ("Included Features"). Within a Feature, files\n\ - named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\ -\n\ -Features may also include other Features ("Included Features"). Files named\n\ -"feature.xml" may contain a list of the names and version numbers of\n\ -Included Features.\n\ -\n\ -The terms and conditions governing Plug-ins and Fragments should be\n\ -contained in files named "about.html" ("Abouts"). The terms and\n\ -conditions governing Features and Included Features should be contained\n\ -in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\ -Licenses may be located in any directory of a Download or Module\n\ -including, but not limited to the following locations:\n\ -\n\ - - The top-level (root) directory\n\ - - Plug-in and Fragment directories\n\ - - Inside Plug-ins and Fragments packaged as JARs\n\ - - Sub-directories of the directory named "src" of certain Plug-ins\n\ - - Feature directories\n\ -\n\ -Note: if a Feature made available by the Eclipse Foundation is installed using the\n\ -Eclipse Update Manager, you must agree to a license ("Feature Update\n\ -License") during the installation process. If the Feature contains\n\ -Included Features, the Feature Update License should either provide you\n\ -with the terms and conditions governing the Included Features or inform\n\ -you where you can locate them. Feature Update Licenses may be found in\n\ -the "license" property of files named "feature.properties". Such Abouts,\n\ -Feature Licenses and Feature Update Licenses contain the terms and\n\ -conditions (or references to such terms and conditions) that govern your\n\ -use of the associated Content in that directory.\n\ -\n\ -THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\ -TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\ -SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\ -\n\ - - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\ - - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\ - - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\ - - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\ - - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\ - - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\ - - Common Development and Distribution License (CDDL) Version 1.0 (available at http://www.sun.com/cddl/cddl.html)\n\ -\n\ -IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\ -TO USE OF THE CONTENT. If no About, Feature License or Feature Update License\n\ -is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\ -govern that particular Content.\n\ -\n\ -Cryptography\n\ -\n\ -Content may contain encryption software. The country in which you are\n\ -currently may have restrictions on the import, possession, and use,\n\ -and/or re-export to another country, of encryption software. BEFORE\n\ -using any encryption software, please check the country's laws,\n\ -regulations and policies concerning the import, possession, or use,\n\ -and re-export of encryption software, to see if this is permitted.\n\ -\n\ -Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.\n -########### end of license property ########################################## diff --git a/jpa/features/org.eclipse.jpt.tests.feature/feature.xml b/jpa/features/org.eclipse.jpt.tests.feature/feature.xml deleted file mode 100644 index 98135a0a21..0000000000 --- a/jpa/features/org.eclipse.jpt.tests.feature/feature.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - %description - - - - %copyright - - - - %license - - - - - - - diff --git a/jpa/features/org.eclipse.jpt.tests.feature/license.html b/jpa/features/org.eclipse.jpt.tests.feature/license.html deleted file mode 100644 index 56445985d9..0000000000 --- a/jpa/features/org.eclipse.jpt.tests.feature/license.html +++ /dev/null @@ -1,98 +0,0 @@ - - -Eclipse.org Software User Agreement - - - -

Eclipse Foundation Software User Agreement

-

June 06, 2007

-

Usage Of Content

-

THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION -AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). 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.

-

Applicable Licenses

-

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 ("EPL"). A copy of the EPL is provided with this -Content and is also available at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

-

Content includes, but is not limited to, source code, object code, -documentation and other files maintained in the Eclipse.org CVS repository -("Repository") in CVS modules ("Modules") and made available as downloadable -archives ("Downloads").

-

Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments -("Fragments"), and features ("Features"). A Feature is a bundle of one or more -Plug-ins and/or Fragments and associated material. Files named "feature.xml" may -contain a list of the names and version numbers of the Plug-ins and/or Fragments -associated with a Feature. Plug-ins and Fragments are located in directories -named "plugins" and Features are located in directories named "features".

-

Features may also include other Features ("Included Features"). Files named -"feature.xml" may contain a list of the names and version numbers of Included -Features.

-

The terms and conditions governing Plug-ins and Fragments should be contained -in files named "about.html" ("Abouts"). The terms and conditions governing -Features and Included Features should be contained in files named "license.html" -("Feature Licenses"). Abouts and Feature Licenses may be located in any -directory of a Download or Module including, but not limited to the following -locations:

-
    -
  • The top-level (root) directory -
  • Plug-in and Fragment directories -
  • Subdirectories of the directory named "src" of certain Plug-ins -
  • Feature directories
-

Note: if a Feature made available by the Eclipse Foundation is installed -using the Eclipse Update Manager, you must agree to a license ("Feature Update -License") 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 "license" property of -files named "feature.properties". 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.

-

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):

- -

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.

-

Cryptography

-

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.

diff --git a/jpa/features/org.eclipse.jpt_sdk.feature/.project b/jpa/features/org.eclipse.jpt_sdk.feature/.project deleted file mode 100644 index 33da750336..0000000000 --- a/jpa/features/org.eclipse.jpt_sdk.feature/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - org.eclipse.jpt_sdk.feature - - - - - - org.eclipse.pde.FeatureBuilder - - - - - - org.eclipse.pde.FeatureNature - - diff --git a/jpa/features/org.eclipse.jpt_sdk.feature/.settings/org.eclipse.core.resources.prefs b/jpa/features/org.eclipse.jpt_sdk.feature/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 6cc7d4b4cd..0000000000 --- a/jpa/features/org.eclipse.jpt_sdk.feature/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Sun May 27 15:09:59 EDT 2007 -eclipse.preferences.version=1 -encoding/=ISO-8859-1 diff --git a/jpa/features/org.eclipse.jpt_sdk.feature/build.properties b/jpa/features/org.eclipse.jpt_sdk.feature/build.properties deleted file mode 100644 index 28724c6843..0000000000 --- a/jpa/features/org.eclipse.jpt_sdk.feature/build.properties +++ /dev/null @@ -1,9 +0,0 @@ -bin.includes = feature.xml,\ - license.html,\ - feature.properties,\ - epl-v10.html,\ - eclipse_update_120.jpg - -src.includes = build.properties - -generate.feature@org.eclipse.jpt.feature.source=org.eclipse.jpt.feature diff --git a/jpa/features/org.eclipse.jpt_sdk.feature/eclipse_update_120.jpg b/jpa/features/org.eclipse.jpt_sdk.feature/eclipse_update_120.jpg deleted file mode 100644 index bfdf708ad6..0000000000 Binary files a/jpa/features/org.eclipse.jpt_sdk.feature/eclipse_update_120.jpg and /dev/null differ diff --git a/jpa/features/org.eclipse.jpt_sdk.feature/epl-v10.html b/jpa/features/org.eclipse.jpt_sdk.feature/epl-v10.html deleted file mode 100644 index ed4b196655..0000000000 --- a/jpa/features/org.eclipse.jpt_sdk.feature/epl-v10.html +++ /dev/null @@ -1,328 +0,0 @@ - - - - - - - - -Eclipse Public License - Version 1.0 - - - - - - -
- -

Eclipse Public License - v 1.0 -

- -

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER -THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, -REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE -OF THIS AGREEMENT.

- -

1. DEFINITIONS

- -

"Contribution" means:

- -

a) -in the case of the initial Contributor, the initial code and documentation -distributed under this Agreement, and
-b) in the case of each subsequent Contributor:

- -

i) -changes to the Program, and

- -

ii) -additions to the Program;

- -

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.

- -

"Contributor" means any person or -entity that distributes the Program.

- -

"Licensed Patents " 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.

- -

"Program" means the Contributions -distributed in accordance with this Agreement.

- -

"Recipient" means anyone who -receives the Program under this Agreement, including all Contributors.

- -

2. GRANT OF RIGHTS

- -

a) -Subject to the terms of this Agreement, each Contributor hereby grants Recipient -a non-exclusive, worldwide, royalty-free copyright license to 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.

- -

b) -Subject to the terms of this Agreement, each Contributor hereby grants -Recipient a non-exclusive, worldwide, 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.

- -

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.

- -

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.

- -

3. REQUIREMENTS

- -

A Contributor may choose to distribute the -Program in object code form under its own license agreement, provided that: -

- -

a) -it complies with the terms and conditions of this Agreement; and

- -

b) -its license agreement:

- -

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;

- -

ii) -effectively excludes on behalf of all Contributors all liability for damages, -including direct, indirect, special, incidental and consequential damages, such -as lost profits;

- -

iii) -states that any provisions which differ from this Agreement are offered by that -Contributor alone and not by any other party; and

- -

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.

- -

When the Program is made available in source -code form:

- -

a) -it must be made available under this Agreement; and

- -

b) a -copy of this Agreement must be included with each copy of the Program.

- -

Contributors may not remove or alter any -copyright notices contained within the Program.

- -

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.

- -

4. COMMERCIAL DISTRIBUTION

- -

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 ("Commercial -Contributor") hereby agrees to defend and indemnify every other -Contributor ("Indemnified Contributor") against any losses, damages and -costs (collectively "Losses") 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.

- -

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.

- -

5. NO WARRANTY

- -

EXCEPT AS EXPRESSLY SET FORTH IN THIS -AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" 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.

- -

6. DISCLAIMER OF LIABILITY

- -

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.

- -

7. GENERAL

- -

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.

- -

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.

- -

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.

- -

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.

- -

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.

- -

 

- -
- - - - \ No newline at end of file diff --git a/jpa/features/org.eclipse.jpt_sdk.feature/feature.properties b/jpa/features/org.eclipse.jpt_sdk.feature/feature.properties deleted file mode 100644 index a14204ac5e..0000000000 --- a/jpa/features/org.eclipse.jpt_sdk.feature/feature.properties +++ /dev/null @@ -1,140 +0,0 @@ -############################################################################### -# Copyright (c) 2006 Oracle. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License 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=Java Persistence API Tools Plug-in SDK - -# "providerName" property - name of the company that provides the feature -providerName=Eclipse.org - -# "updateSiteName" property - label for the update site -updateSiteName=The Eclipse Web Tools Platform (WTP) Project update site - -# "description" property - description of the feature -description=Source code zips for JPA Tools - -# "copyright" property - text of the "Feature Update Copyright" -copyright=\ -Copyright (c) 2006-07 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 -licenseURL=license.html - -# "license" property - text of the "Feature Update License" -# should be plain text version of license agreement pointed to be "licenseURL" -license=\ -ECLIPSE FOUNDATION SOFTWARE USER AGREEMENT\n\ -June 06, 2007\n\ -\n\ -Usage Of Content\n\ -\n\ -THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION AND/OR\n\ -OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT").\n\ -USE OF THE CONTENT IS GOVERNED BY THE TERMS AND CONDITIONS OF THIS\n\ -AGREEMENT AND/OR THE TERMS AND CONDITIONS OF LICENSE AGREEMENTS OR\n\ -NOTICES INDICATED OR REFERENCED BELOW. BY USING THE CONTENT, YOU\n\ -AGREE THAT YOUR USE OF THE CONTENT IS GOVERNED BY THIS AGREEMENT\n\ -AND/OR THE TERMS AND CONDITIONS OF ANY APPLICABLE LICENSE AGREEMENTS\n\ -OR NOTICES INDICATED OR REFERENCED BELOW. IF YOU DO NOT AGREE TO THE\n\ -TERMS AND CONDITIONS OF THIS AGREEMENT AND THE TERMS AND CONDITIONS\n\ -OF ANY APPLICABLE LICENSE AGREEMENTS OR NOTICES INDICATED OR REFERENCED\n\ -BELOW, THEN YOU MAY NOT USE THE CONTENT.\n\ -\n\ -Applicable Licenses\n\ -\n\ -Unless otherwise indicated, all Content made available by the Eclipse Foundation\n\ -is provided to you under the terms and conditions of the Eclipse Public\n\ -License Version 1.0 ("EPL"). A copy of the EPL is provided with this\n\ -Content and is also available at http://www.eclipse.org/legal/epl-v10.html.\n\ -For purposes of the EPL, "Program" will mean the Content.\n\ -\n\ -Content includes, but is not limited to, source code, object code,\n\ -documentation and other files maintained in the Eclipse.org CVS\n\ -repository ("Repository") in CVS modules ("Modules") and made available\n\ -as downloadable archives ("Downloads").\n\ -\n\ - - Content may be structured and packaged into modules to facilitate delivering,\n\ - extending, and upgrading the Content. Typical modules may include plug-ins ("Plug-ins"),\n\ - plug-in fragments ("Fragments"), and features ("Features").\n\ - - Each Plug-in or Fragment may be packaged as a sub-directory or JAR (Java? ARchive)\n\ - in a directory named "plugins".\n\ - - A Feature is a bundle of one or more Plug-ins and/or Fragments and associated material.\n\ - Each Feature may be packaged as a sub-directory in a directory named "features".\n\ - Within a Feature, files named "feature.xml" may contain a list of the names and version\n\ - numbers of the Plug-ins and/or Fragments associated with that Feature.\n\ - - Features may also include other Features ("Included Features"). Within a Feature, files\n\ - named "feature.xml" may contain a list of the names and version numbers of Included Features.\n\ -\n\ -Features may also include other Features ("Included Features"). Files named\n\ -"feature.xml" may contain a list of the names and version numbers of\n\ -Included Features.\n\ -\n\ -The terms and conditions governing Plug-ins and Fragments should be\n\ -contained in files named "about.html" ("Abouts"). The terms and\n\ -conditions governing Features and Included Features should be contained\n\ -in files named "license.html" ("Feature Licenses"). Abouts and Feature\n\ -Licenses may be located in any directory of a Download or Module\n\ -including, but not limited to the following locations:\n\ -\n\ - - The top-level (root) directory\n\ - - Plug-in and Fragment directories\n\ - - Inside Plug-ins and Fragments packaged as JARs\n\ - - Sub-directories of the directory named "src" of certain Plug-ins\n\ - - Feature directories\n\ -\n\ -Note: if a Feature made available by the Eclipse Foundation is installed using the\n\ -Eclipse Update Manager, you must agree to a license ("Feature Update\n\ -License") during the installation process. If the Feature contains\n\ -Included Features, the Feature Update License should either provide you\n\ -with the terms and conditions governing the Included Features or inform\n\ -you where you can locate them. Feature Update Licenses may be found in\n\ -the "license" property of files named "feature.properties". Such Abouts,\n\ -Feature Licenses and Feature Update Licenses contain the terms and\n\ -conditions (or references to such terms and conditions) that govern your\n\ -use of the associated Content in that directory.\n\ -\n\ -THE ABOUTS, FEATURE LICENSES AND FEATURE UPDATE LICENSES MAY REFER\n\ -TO THE EPL OR OTHER LICENSE AGREEMENTS, NOTICES OR TERMS AND CONDITIONS.\n\ -SOME OF THESE OTHER LICENSE AGREEMENTS MAY INCLUDE (BUT ARE NOT LIMITED TO):\n\ -\n\ - - Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html)\n\ - - Apache Software License 1.1 (available at http://www.apache.org/licenses/LICENSE)\n\ - - Apache Software License 2.0 (available at http://www.apache.org/licenses/LICENSE-2.0)\n\ - - IBM Public License 1.0 (available at http://oss.software.ibm.com/developerworks/opensource/license10.html)\n\ - - Metro Link Public License 1.00 (available at http://www.opengroup.org/openmotif/supporters/metrolink/license.html)\n\ - - Mozilla Public License Version 1.1 (available at http://www.mozilla.org/MPL/MPL-1.1.html)\n\ - - Common Development and Distribution License (CDDL) Version 1.0 (available at http://www.sun.com/cddl/cddl.html)\n\ -\n\ -IT IS YOUR OBLIGATION TO READ AND ACCEPT ALL SUCH TERMS AND CONDITIONS PRIOR\n\ -TO USE OF THE CONTENT. If no About, Feature License or Feature Update License\n\ -is provided, please contact the Eclipse Foundation to determine what terms and conditions\n\ -govern that particular Content.\n\ -\n\ -Cryptography\n\ -\n\ -Content may contain encryption software. The country in which you are\n\ -currently may have restrictions on the import, possession, and use,\n\ -and/or re-export to another country, of encryption software. BEFORE\n\ -using any encryption software, please check the country's laws,\n\ -regulations and policies concerning the import, possession, or use,\n\ -and re-export of encryption software, to see if this is permitted.\n\ -\n\ -Java and all Java-based trademarks are trademarks of Sun Microsystems, Inc. in the United States, other countries, or both.\n -########### end of license property ########################################## diff --git a/jpa/features/org.eclipse.jpt_sdk.feature/feature.xml b/jpa/features/org.eclipse.jpt_sdk.feature/feature.xml deleted file mode 100644 index aeea462eba..0000000000 --- a/jpa/features/org.eclipse.jpt_sdk.feature/feature.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - %description - - - - %copyright - - - - %license - - - - - - - diff --git a/jpa/features/org.eclipse.jpt_sdk.feature/license.html b/jpa/features/org.eclipse.jpt_sdk.feature/license.html deleted file mode 100644 index fc77372d46..0000000000 --- a/jpa/features/org.eclipse.jpt_sdk.feature/license.html +++ /dev/null @@ -1,98 +0,0 @@ - - -Eclipse.org Software User Agreement - - - -

Eclipse Foundation Software User Agreement

-

June 06, 2007

-

Usage Of Content

-

THE ECLIPSE FOUNDATION MAKES AVAILABLE SOFTWARE, DOCUMENTATION, INFORMATION -AND/OR OTHER MATERIALS FOR OPEN SOURCE PROJECTS (COLLECTIVELY "CONTENT"). 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.

-

Applicable Licenses

-

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 ("EPL"). A copy of the EPL is provided with this -Content and is also available at http://www.eclipse.org/legal/epl-v10.html. -For purposes of the EPL, "Program" will mean the Content.

-

Content includes, but is not limited to, source code, object code, -documentation and other files maintained in the Eclipse.org CVS repository -("Repository") in CVS modules ("Modules") and made available as downloadable -archives ("Downloads").

-

Content may be apportioned into plug-ins ("Plug-ins"), plug-in fragments -("Fragments"), and features ("Features"). A Feature is a bundle of one or more -Plug-ins and/or Fragments and associated material. Files named "feature.xml" may -contain a list of the names and version numbers of the Plug-ins and/or Fragments -associated with a Feature. Plug-ins and Fragments are located in directories -named "plugins" and Features are located in directories named "features".

-

Features may also include other Features ("Included Features"). Files named -"feature.xml" may contain a list of the names and version numbers of Included -Features.

-

The terms and conditions governing Plug-ins and Fragments should be contained -in files named "about.html" ("Abouts"). The terms and conditions governing -Features and Included Features should be contained in files named "license.html" -("Feature Licenses"). Abouts and Feature Licenses may be located in any -directory of a Download or Module including, but not limited to the following -locations:

-
    -
  • The top-level (root) directory -
  • Plug-in and Fragment directories -
  • Subdirectories of the directory named "src" of certain Plug-ins -
  • Feature directories
-

Note: if a Feature made available by the Eclipse Foundation is installed -using the Eclipse Update Manager, you must agree to a license ("Feature Update -License") 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 "license" property of -files named "feature.properties". 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.

-

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):

- -

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.

-

Cryptography

-

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.

diff --git a/jpa/plugins/org.eclipse.jpt.db.ui/.classpath b/jpa/plugins/org.eclipse.jpt.db.ui/.classpath deleted file mode 100644 index 304e86186a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db.ui/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.db.ui/.cvsignore b/jpa/plugins/org.eclipse.jpt.db.ui/.cvsignore deleted file mode 100644 index 814c6a80a6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db.ui/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -bin -build.xml -javaCompiler...args \ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.db.ui/.project b/jpa/plugins/org.eclipse.jpt.db.ui/.project deleted file mode 100644 index 88ea5da610..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db.ui/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.eclipse.jpt.db.ui - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/jpa/plugins/org.eclipse.jpt.db.ui/.settings/org.eclipse.core.resources.prefs b/jpa/plugins/org.eclipse.jpt.db.ui/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index ee4b8c1b90..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db.ui/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Sun May 27 15:10:38 EDT 2007 -eclipse.preferences.version=1 -encoding/=ISO-8859-1 diff --git a/jpa/plugins/org.eclipse.jpt.db.ui/.settings/org.eclipse.jdt.core.prefs b/jpa/plugins/org.eclipse.jpt.db.ui/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 842c286bb1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db.ui/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -#Sun May 27 14:59:42 EDT 2007 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -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/jpa/plugins/org.eclipse.jpt.db.ui/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.db.ui/META-INF/MANIFEST.MF deleted file mode 100644 index 38a4d91ae9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db.ui/META-INF/MANIFEST.MF +++ /dev/null @@ -1,14 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: %pluginName -Bundle-Vendor: %providerName -Bundle-SymbolicName: org.eclipse.jpt.db.ui -Bundle-Version: 1.0.0.qualifier -Bundle-ClassPath: . -Bundle-Localization: plugin -Export-Package: org.eclipse.jpt.db.ui.internal; x-friends:="org.eclipse.jpt.ui" -Require-Bundle: org.eclipse.ui, - org.eclipse.jpt.db, - org.eclipse.datatools.connectivity.ui, - org.eclipse.datatools.sqltools.editor.core -Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/jpa/plugins/org.eclipse.jpt.db.ui/about.html b/jpa/plugins/org.eclipse.jpt.db.ui/about.html deleted file mode 100644 index 9e73bdabb6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db.ui/about.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - -About - - - - - -

About This Content

- -

June 06, 2007

- -

License

- -

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 -http://www.eclipse.org/org/documents/epl-v10.php. -For purposes of the EPL, "Program" will mean the Content.

- -

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 -http://www.eclipse.org/.

- - - diff --git a/jpa/plugins/org.eclipse.jpt.db.ui/build.properties b/jpa/plugins/org.eclipse.jpt.db.ui/build.properties deleted file mode 100644 index 0d56981f21..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db.ui/build.properties +++ /dev/null @@ -1,17 +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,\ - plugin.properties -jars.compile.order = . diff --git a/jpa/plugins/org.eclipse.jpt.db.ui/component.xml b/jpa/plugins/org.eclipse.jpt.db.ui/component.xml deleted file mode 100644 index bf648aaa4f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db.ui/component.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.db.ui/plugin.properties b/jpa/plugins/org.eclipse.jpt.db.ui/plugin.properties deleted file mode 100644 index 2b0e5835b1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db.ui/plugin.properties +++ /dev/null @@ -1,25 +0,0 @@ -############################################################################### -# Copyright (c) 2006 Oracle. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License 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 = Java Persistence API Tools - DB UI -providerName = Eclipse.org - diff --git a/jpa/plugins/org.eclipse.jpt.db.ui/src/org/eclipse/jpt/db/ui/internal/DTPUiTools.java b/jpa/plugins/org.eclipse.jpt.db.ui/src/org/eclipse/jpt/db/ui/internal/DTPUiTools.java deleted file mode 100644 index 632fe81411..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db.ui/src/org/eclipse/jpt/db/ui/internal/DTPUiTools.java +++ /dev/null @@ -1,99 +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.db.ui.internal; - -import org.eclipse.datatools.connectivity.ICategory; -import org.eclipse.datatools.connectivity.IConnectionProfile; -import org.eclipse.datatools.connectivity.IProfileListener; -import org.eclipse.datatools.connectivity.ProfileManager; -import org.eclipse.datatools.connectivity.internal.ConnectionProfileManager; -import org.eclipse.datatools.connectivity.internal.ui.wizards.CPWizardNode; -import org.eclipse.datatools.connectivity.internal.ui.wizards.NewCPWizard; -import org.eclipse.datatools.connectivity.internal.ui.wizards.ProfileWizardProvider; -import org.eclipse.datatools.connectivity.ui.wizards.IWizardCategoryProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.jpt.db.internal.ConnectionProfileRepository; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; - -/** - * ConnectionProfileUiTools - */ -public class DTPUiTools { - - /** - * Launch the DTP New Connection Profile wizard to create a new database connection profile. - * - * Returns the name of the added profile, or null if the wizard is cancelled. ConnectionProfileRepository - * can be used to retrieve the added connection profile. - */ - public static String createNewProfile() { - NewCPWizard wizard; - WizardDialog wizardDialog; - - // Filter datasource category - ViewerFilter viewerFilter = new ViewerFilter() { - - public boolean select( Viewer viewer, Object parentElement, Object element) { - - CPWizardNode wizardNode = ( CPWizardNode) element; - if( !( wizardNode.getProvider() instanceof IWizardCategoryProvider)) { - ICategory cat = ConnectionProfileManager.getInstance().getProvider( - (( ProfileWizardProvider) wizardNode.getProvider()).getProfile()).getCategory(); - - // Only display wizards belong to database category - while( cat != null) { - if( cat.getId().equals( ConnectionProfileRepository.DATABASE_CATEGORY_ID)) - return true; - else - cat = cat.getParent(); - } - } - return false; - } - }; - wizard = new NewCPWizard( viewerFilter, null); - Shell currentShell = Display.getCurrent().getActiveShell(); - wizardDialog = new WizardDialog( currentShell, wizard); - wizardDialog.setBlockOnOpen( true); - - LocalProfileListener listener = new LocalProfileListener(); - ProfileManager.getInstance().addProfileListener( listener); - - if( wizardDialog.open() == Window.CANCEL) { - ProfileManager.getInstance().removeProfileListener( listener); - return null; - } - IConnectionProfile addedProfile = listener.addedProfile; - ProfileManager.getInstance().removeProfileListener( listener); - - return addedProfile.getName(); - } - - private static class LocalProfileListener implements IProfileListener { - IConnectionProfile addedProfile; - - public void profileAdded( IConnectionProfile profile) { - addedProfile = profile; - } - - public void profileChanged( IConnectionProfile profile) { - // do nothing - } - - public void profileDeleted( IConnectionProfile profile) { - // do nothing - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/.classpath b/jpa/plugins/org.eclipse.jpt.db/.classpath deleted file mode 100644 index 304e86186a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.db/.cvsignore b/jpa/plugins/org.eclipse.jpt.db/.cvsignore deleted file mode 100644 index e043cc4e2c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -bin -build.xml -javaCompiler...args diff --git a/jpa/plugins/org.eclipse.jpt.db/.project b/jpa/plugins/org.eclipse.jpt.db/.project deleted file mode 100644 index 5675a48e3a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.eclipse.jpt.db - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/jpa/plugins/org.eclipse.jpt.db/.settings/org.eclipse.core.resources.prefs b/jpa/plugins/org.eclipse.jpt.db/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 797ea025b1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Sun May 27 15:10:29 EDT 2007 -eclipse.preferences.version=1 -encoding/=ISO-8859-1 diff --git a/jpa/plugins/org.eclipse.jpt.db/.settings/org.eclipse.jdt.core.prefs b/jpa/plugins/org.eclipse.jpt.db/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 929d54536d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -#Sun May 27 14:59:18 EDT 2007 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -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/jpa/plugins/org.eclipse.jpt.db/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.db/META-INF/MANIFEST.MF deleted file mode 100644 index e1926db75e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/META-INF/MANIFEST.MF +++ /dev/null @@ -1,15 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: %pluginName -Bundle-Vendor: %providerName -Bundle-SymbolicName: org.eclipse.jpt.db -Bundle-Version: 1.0.1.qualifier -Bundle-Activator: org.eclipse.jpt.db.internal.JptDbPlugin -Bundle-ClassPath: . -Bundle-Localization: plugin -Eclipse-LazyStart: true -Export-Package: org.eclipse.jpt.db.internal -Require-Bundle: org.eclipse.core.runtime, - org.eclipse.datatools.sqltools.editor.core, - org.eclipse.jpt.utility -Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/jpa/plugins/org.eclipse.jpt.db/about.html b/jpa/plugins/org.eclipse.jpt.db/about.html deleted file mode 100644 index 9e73bdabb6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/about.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - -About - - - - - -

About This Content

- -

June 06, 2007

- -

License

- -

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 -http://www.eclipse.org/org/documents/epl-v10.php. -For purposes of the EPL, "Program" will mean the Content.

- -

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 -http://www.eclipse.org/.

- - - diff --git a/jpa/plugins/org.eclipse.jpt.db/build.properties b/jpa/plugins/org.eclipse.jpt.db/build.properties deleted file mode 100644 index 974eadac6b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/build.properties +++ /dev/null @@ -1,19 +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 -############################################################################### -javacSource=1.5 -javacTarget=1.5 -source.. = src/ -output.. = bin/ -bin.includes = .,\ - META-INF/,\ - about.html,\ - plugin.properties -jars.compile.order = . diff --git a/jpa/plugins/org.eclipse.jpt.db/component.xml b/jpa/plugins/org.eclipse.jpt.db/component.xml deleted file mode 100644 index 644c396149..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/component.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.db/plugin.properties b/jpa/plugins/org.eclipse.jpt.db/plugin.properties deleted file mode 100644 index e87a2d3972..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/plugin.properties +++ /dev/null @@ -1,25 +0,0 @@ -############################################################################### -# Copyright (c) 2006 Oracle. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License 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 = Java Persistence API Tools - DB -providerName = Eclipse.org - diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Catalog.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Catalog.java deleted file mode 100644 index 0c4238e616..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Catalog.java +++ /dev/null @@ -1,108 +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.db.internal; - -import java.text.Collator; -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObject; -import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObjectListener; -import org.eclipse.emf.common.util.EList; - -/** - * Wrap a DTP Catalogs - */ -final class Catalog extends DTPWrapper implements Comparable { - private final Database database; - final org.eclipse.datatools.modelbase.sql.schema.Catalog dtpCatalog; - @SuppressWarnings("unused") - private ICatalogObjectListener catalogListener; //TODO listen for change - - // ********** constructors ********** - - Catalog( Database database, org.eclipse.datatools.modelbase.sql.schema.Catalog dtpCatalog) { - super(); - this.database = database; - this.dtpCatalog = dtpCatalog; - } - - // ********** behavior ********** - - @Override - protected boolean connectionIsOnline() { - return this.database.connectionIsOnline(); - } - - @SuppressWarnings("unused") - private ICatalogObjectListener buildCatalogListener() { - return new ICatalogObjectListener() { - public void notifyChanged( final ICatalogObject catalog, final int eventType) { - if( catalog == Catalog.this.dtpCatalog) { -// Catalog.this.refresh(); -// Catalog.this.database.catalogChanged( Catalog.this, eventType); - } - } - }; - } - - @Override - protected void dispose() { -// this.removeCatalogObjectListener(( ICatalogObject) this.dtpCatalog, this.catalogListener); - } - - boolean wraps( org.eclipse.datatools.modelbase.sql.schema.Catalog catalog) { - return this.dtpCatalog == catalog; - } - - // ********** queries ********** - - @Override - public String getName() { - return this.dtpCatalog.getName(); - } - - boolean isCaseSensitive() { - return this.database.isCaseSensitive(); - } - - Column column( org.eclipse.datatools.modelbase.sql.tables.Column dtpColumn) { - return this.database.column(dtpColumn); - } - - // ***** schemata - - synchronized Set buildSchemata() { - EList dtpSchemata = this.dtpSchemata(); - - Set result = new HashSet( dtpSchemata.size()); - for (org.eclipse.datatools.modelbase.sql.schema.Schema dtpSchema : dtpSchemata) { - result.add( this.wrap(dtpSchema)); - } - return result; - } - - @SuppressWarnings("unchecked") - private EList dtpSchemata() { - return this.dtpCatalog.getSchemas(); - } - - private Schema wrap( org.eclipse.datatools.modelbase.sql.schema.Schema schema) { - - return new Schema( this.database, schema); - } - - // ********** Comparable implementation ********** - - public int compareTo( Catalog catalog) { - return Collator.getInstance().compare( this.getName(), catalog.getName()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Column.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Column.java deleted file mode 100644 index 547ba01aad..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Column.java +++ /dev/null @@ -1,162 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.internal; - -import java.text.Collator; - -import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObject; -import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObjectListener; -import org.eclipse.datatools.modelbase.sql.datatypes.DataType; -import org.eclipse.datatools.modelbase.sql.datatypes.PredefinedDataType; -import org.eclipse.jpt.utility.internal.JavaType; -import org.eclipse.jpt.utility.internal.NameTools; - -/** - * Wrap a DTP Column - */ -public final class Column extends DTPWrapper implements Comparable { - private final Table table; - private final org.eclipse.datatools.modelbase.sql.tables.Column dtpColumn; - private ICatalogObjectListener columnListener; - - // TODO Object is the default? - private static final JavaType DEFAULT_JAVA_TYPE = new JavaType(java.lang.Object.class); - - private static final JavaType BLOB_JAVA_TYPE = new JavaType(java.sql.Blob.class); - private static final JavaType BYTE_ARRAY_JAVA_TYPE = new JavaType(byte[].class); - - private static final JavaType CLOB_JAVA_TYPE = new JavaType(java.sql.Clob.class); - private static final JavaType STRING_JAVA_TYPE = new JavaType(java.lang.String.class); - - - // ********** constructors ********** - - Column( Table table, org.eclipse.datatools.modelbase.sql.tables.Column dtpColumn) { - super(); - this.table = table; - this.dtpColumn = dtpColumn; - this.initialize(); - } - - // ********** behavior ********** - - private void initialize() { - if( this.connectionIsOnline()) { - this.columnListener = this.buildColumnListener(); - this.addCatalogObjectListener(( ICatalogObject) this.dtpColumn, this.columnListener); - } - } - - @Override - protected boolean connectionIsOnline() { - return this.table.connectionIsOnline(); - } - - private ICatalogObjectListener buildColumnListener() { - return new ICatalogObjectListener() { - public void notifyChanged( final ICatalogObject column, final int eventType) { -// TODO -// if( column == Column.this.dtpColumn) { -// Column.this.table.columnChanged( Column.this, eventType); -// } - } - }; - } - - @Override - protected void dispose() { - - this.removeCatalogObjectListener(( ICatalogObject) this.dtpColumn, this.columnListener); - } - - // ********** queries ********** - - @Override - public String getName() { - return this.dtpColumn.getName(); - } - - boolean isCaseSensitive() { - return this.table.isCaseSensitive(); - } - - public String dataTypeName() { - DataType dataType = this.dtpColumn.getDataType(); - return (dataType == null) ? null : dataType.getName(); - } - - public String javaFieldName() { - String jName = this.getName(); - if ( ! this.isCaseSensitive()) { - jName = jName.toLowerCase(); - } - return NameTools.convertToJavaIdentifier(jName); - } - - public boolean matchesJavaFieldName(String javaFieldName) { - return this.isCaseSensitive() ? - this.getName().equals(javaFieldName) - : - this.getName().equalsIgnoreCase(javaFieldName); - } - - /** - * Return a Java type declaration that is reasonably - * similar to the column's data type. - */ - public String javaTypeDeclaration() { - return this.javaType().declaration(); - } - - /** - * Return a Java type that is reasonably - * similar to the column's data type. - */ - public JavaType javaType() { - DataType dataType = this.dtpColumn.getDataType(); - return (dataType instanceof PredefinedDataType) ? - this.jpaSpecCompliantJavaType(DTPTools.javaTypeFor(((PredefinedDataType) dataType).getPrimitiveType())) - : - DEFAULT_JAVA_TYPE; - } - - /** - * The JDBC spec says JDBC drivers should be able to map BLOBs and CLOBs - * directly, but the JPA spec does not allow them. - */ - private JavaType jpaSpecCompliantJavaType(JavaType javaType) { - if (javaType.equals(BLOB_JAVA_TYPE)) { - return BYTE_ARRAY_JAVA_TYPE; - } - if (javaType.equals(CLOB_JAVA_TYPE)) { - return STRING_JAVA_TYPE; - } - return javaType; - } - - public boolean isLob() { - DataType dataType = this.dtpColumn.getDataType(); - return (dataType instanceof PredefinedDataType) ? - DTPTools.dataTypeIsLob(((PredefinedDataType) dataType).getPrimitiveType()) - : - false; - } - - boolean wraps( org.eclipse.datatools.modelbase.sql.tables.Column column) { - return this.dtpColumn == column; - } - - // ********** Comparable implementation ********** - - public int compareTo( Column column) { - return Collator.getInstance().compare( this.getName(), column.getName()); - } -} - diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Connection.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Connection.java deleted file mode 100644 index 3e1e7365db..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Connection.java +++ /dev/null @@ -1,66 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.internal; - -import java.text.Collator; - - -/** - * Connection wrapper base class. - */ -public abstract class Connection extends DTPWrapper implements Comparable { - - // ********** constructors ********** - - /** - * Create a wrapper for the given IManagedConnection. - */ - static Connection createConnection( org.eclipse.datatools.connectivity.IManagedConnection dtpConnection) { - return ( dtpConnection == null) ? NullConnection.instance() : new DTPConnectionWrapper( dtpConnection); - } - - Connection() { - super(); - } - - // ********** listeners ********** - - public abstract void addConnectionListener( ConnectionListener listener); - - public abstract void removeConnectionListener( ConnectionListener listener); - - - // ********** behavior ********** - - abstract void databaseChanged( Database database, int eventType); - - abstract void schemaChanged( Schema schema, Database database, int eventType); - - abstract void tableChanged( Table table, Schema schema, Database database, int eventType); - - - // ********** queries ********** - - public abstract boolean isConnected(); - - public abstract String getFactoryId(); - - @Override - protected boolean connectionIsOnline() { - return this.isConnected(); - } - - // ********** Comparable implementation ********** - - public int compareTo(Connection connection) { - return Collator.getInstance().compare( this.getName(), connection.getName()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionListener.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionListener.java deleted file mode 100644 index d778cbb1e4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionListener.java +++ /dev/null @@ -1,31 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.internal; - - -/** - * ConnectionListener integrate th DTP IManagedConnectionListener listener. - * This class purpose is to decouple from the DTP listeners by accepting wrappers as parameter. - * - * @see org.eclipse.datatools.connectivity.IManagedConnectionListener - */ -public interface ConnectionListener { - - public void opened( Connection connection); - public void modified( Connection connection); - public boolean okToClose( Connection connection); - public void aboutToClose( Connection connection); - public void closed( Connection connection); - - public void databaseChanged( Connection connection, Database database); - public void schemaChanged( Connection connection, Schema schema); - public void tableChanged( Connection connection, Table table); - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionProfile.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionProfile.java deleted file mode 100644 index a793bb4e83..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionProfile.java +++ /dev/null @@ -1,259 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.internal; - -import java.text.Collator; -import java.util.NoSuchElementException; - -import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObjectListener; - -/** - * ConnectionProfile wrapper base class. - */ -public abstract class ConnectionProfile extends DTPWrapper implements Comparable { - - private Connection connection; // Lazy initialized - private Database database; // Lazy initialized - private String catalogName; // Catalog used for this profile - - private ConnectionListener connectionListener; - - private ConnectionProfileRepository profileRepository; - - // ********** constructors ********** - - static ConnectionProfile createProfile( ConnectionProfileRepository profileRepository, org.eclipse.datatools.connectivity.IConnectionProfile dtpProfile) { - return ( dtpProfile == null) ? NullConnectionProfile.instance() : new DTPConnectionProfileWrapper( profileRepository, dtpProfile); - } - - ConnectionProfile( ConnectionProfileRepository profileRepository) { - super(); - this.profileRepository = profileRepository; - this.connectionListener = buildConnectionListener(); - this.catalogName = ""; - } - - // ********** behavior ********** - - public abstract void connect(); - - public abstract void disconnect(); - - protected abstract Connection buildConnection(); - - protected abstract Database buildDatabase(); - - abstract void databaseChanged( Database db, int eventType); - - abstract void catalogChanged( Catalog catalog, Database db, int eventType); - - abstract void schemaChanged( Schema schema, Database db, int eventType); - - abstract void tableChanged( Table table, Schema schema, Database db, int eventType); - - protected void refreshDatabase() { - this.disposeDatabase(); - this.database = null; - } - - @Override - protected void dispose() { - this.disengageConnectionListener(); - - this.disposeConnection(); - this.disposeDatabase(); - } - - private void disposeConnection() { - if( this.connection != null) { - this.getConnection().dispose(); - } - } - - private void disposeDatabase() { - if( this.database != null) { - this.getDatabase().dispose(); - } - } - - // ********** queries ********** - - public Connection getConnection() { - - if( this.connection == null) { - this.connection = this.buildConnection(); - this.engageConnectionListener(); - - } - return this.connection; - } - - public Database getDatabase() { - - if( this.database == null) { - this.database = this.buildDatabase(); - this.setDefaultCatalogName(); - } - return this.database; - } - - public abstract String getDatabaseName(); - - public abstract String getDatabaseProduct(); - - public abstract String getDatabaseVendor(); - - public abstract String getDatabaseVersion(); - - public abstract String getDriverClass(); - - public abstract String getUrl(); - - public abstract String getUserName(); - - public abstract String getUserPassword(); - - public abstract String getDefaultSchema(); - - public abstract String getInstanceId(); - - public abstract String getProviderId(); - - public abstract String getDriverDefinitionId(); - - public abstract String getDriverJarList(); - - public abstract boolean isConnected(); - - @Override - protected boolean connectionIsOnline() { - return this.isConnected(); - } - - abstract boolean wraps( org.eclipse.datatools.connectivity.IConnectionProfile dtpProfile); - - public boolean isNull() { - return true; - } - - ConnectionProfileRepository getProfileRepository() { - return this.profileRepository; - } - - public String getCatalogName() { - return this.catalogName; - } - - /** - * Set the default catalog name for this profile. - */ - public void setDefaultCatalogName() { - this.setCatalogName( this.database.getDefaultCatalogName()); - } - - /** - * Can only set the catalog to use for this profile, when the database supports catalogs. - */ - public void setCatalogName( String catalogName) { - if( this.catalogName == catalogName) { - return; - } - if( this.database.supportsCatalogs()) { - String name = ( catalogName != null) ? catalogName : this.database.getDefaultCatalogName(); - - Catalog catalog = this.database.catalogNamed( name); - if( catalog == null) { - throw new NoSuchElementException(); - } - this.catalogName = name; - this.database.refresh(); - this.catalogChanged( catalog, this.database, ICatalogObjectListener.EventTypeEnumeration.ELEMENT_REFRESH); - } - else { - this.catalogName = ""; - this.database.refresh(); - } - } - - // ********** listeners ********** - - abstract public void addProfileListener( ProfileListener listener); - - abstract public void removeProfileListener( ProfileListener listener); - - abstract public void addConnectionListener( ConnectionListener listener); - - abstract public void removeConnectionListener( ConnectionListener listener); - - private ConnectionListener buildConnectionListener() { - return new ConnectionListener() { - - public void aboutToClose(Connection c) { - // not interested to this event. - } - - public void closed(Connection c) { - ConnectionProfile.this.refreshDatabase(); - } - - public void modified(Connection c) { - // not interested to this event. - return; - } - - public boolean okToClose(Connection c) { - // not interested to this event. - return true; - } - - public void opened(Connection c) { - ConnectionProfile.this.refreshDatabase(); - } - - public void databaseChanged(Connection c, final Database db) { - // not interested to this event. - return; - } - - public void schemaChanged(Connection c, final Schema schema) { - // not interested to this event. - return; - } - - public void tableChanged(Connection c, final Table table) { - // not interested to this event. - return; - } - }; - } - - protected void disengageConnectionListener() { - this.removeConnectionListener(); - } - - protected void engageConnectionListener() { - this.addConnectionListener(); - } - - private void addConnectionListener() { - this.addConnectionListener( this.connectionListener); - } - - private void removeConnectionListener() { - this.removeConnectionListener( this.connectionListener); - } - - // ********** Comparable implementation ********** - - public int compareTo( ConnectionProfile connectionProfile) { - return Collator.getInstance().compare( this.getName(), connectionProfile.getName()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionProfileRepository.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionProfileRepository.java deleted file mode 100644 index 25e7ea7acd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ConnectionProfileRepository.java +++ /dev/null @@ -1,253 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.internal; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; -import org.eclipse.datatools.connectivity.IConnectionProfile; -import org.eclipse.datatools.connectivity.IProfileListener; -import org.eclipse.datatools.connectivity.ProfileManager; -import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; - -/** - * ConnectionProfileRepository is a mediator to the DTP ProfileManager. - */ -public class ConnectionProfileRepository { - private ProfileManager dtpProfileManager; - - private LocalRepositoryListener repositoryListener; - private LocalProfileListener profileListener; - private Set profiles; - - private static ConnectionProfileRepository INSTANCE; - - public static final String DATABASE_CATEGORY_ID = "org.eclipse.datatools.connectivity.db.category"; //$NON-NLS-1$ - - /** - * singleton support - */ - public static ConnectionProfileRepository instance() { - if (INSTANCE == null) { - INSTANCE = new ConnectionProfileRepository(); - } - return INSTANCE; - } - - // ********** constructors ********** - - private ConnectionProfileRepository() { - super(); - this.dtpProfileManager = ProfileManager.getInstance(); - } - - // ********** behavior ********** - - public void initializeListeners() { - - if( this.repositoryListener == null) { - this.repositoryListener = new LocalRepositoryListener(); - this.dtpProfileManager.addProfileListener( this.repositoryListener); - } - if( this.profileListener == null) { - this.profileListener = new LocalProfileListener(); - this.dtpProfileManager.addProfileListener( this.profileListener); - } - } - - public void disposeListeners() { - for( Iterator stream = this.profiles(); stream.hasNext(); ) { - stream.next().dispose(); - } - if( this.repositoryListener != null) { - this.dtpProfileManager.removeProfileListener( this.repositoryListener); - this.repositoryListener = null; - } - if( this.profileListener != null) { - this.dtpProfileManager.removeProfileListener( this.profileListener); - this.profileListener = null; - } - } - - public Connection getConnectionWithProfileNamed( String name) { - return this.profileNamed( name).getConnection(); - } - - - @Override - public String toString() { - return this.profiles.toString(); - } - - // ********** profiles - - public Iterator profiles() { - return this.getProfiles().iterator(); - } - - public Iterator profileNames() { - return new TransformationIterator( this.profiles()) { - @Override - protected String transform( ConnectionProfile profile) { - return profile.getName(); - } - }; - } - - public ConnectionProfile profileNamed( String name) { - for( Iterator stream = this.profiles(); stream.hasNext(); ) { - ConnectionProfile profile = stream.next(); - if( profile.getName().equals( name)) { - return profile; - } - } - return NullConnectionProfile.instance(); - } - - private Set getProfiles() { - - if( this.profiles == null) { - this.profiles = this.buildProfiles(); - } - return this.profiles; - } - - private Set buildProfiles() { - IConnectionProfile[] dtpProfiles = this.dtpProfileManager.getProfiles(); - Set result = new HashSet( dtpProfiles.length); - for (IConnectionProfile dtpProfile : dtpProfiles) { - result.add( ConnectionProfile.createProfile( this, dtpProfile)); - } - return result; - } - - void addProfile( IConnectionProfile dtpProfile) { - - if( !this.profileExists( dtpProfile)) { - ConnectionProfile newProfile = ConnectionProfile.createProfile( ConnectionProfileRepository.this, dtpProfile); - this.profiles.add( newProfile); - } - } - - void removeProfile( IConnectionProfile dtpProfile) { - - this.profiles.remove( this.getProfile( dtpProfile)); - } - - private boolean profileExists( IConnectionProfile dtpProfile) { - - return ( this.getProfile( dtpProfile) == null) ? false : true; - } - - ConnectionProfile getProfile( IConnectionProfile dtpProfile) { - - for( Iterator stream = this.profiles(); stream.hasNext(); ) { - ConnectionProfile profile = stream.next(); - if( profile.wraps( dtpProfile)) { - return profile; - } - } - return null; - } - - // ********** listeners ********** - - public void addProfileListener( ProfileListener listener) { - - this.profileListener.addProfileListener( listener); - } - - public void removeProfileListener( ProfileListener listener) { - - this.profileListener.removeProfileListener( listener); - } - - @SuppressWarnings("unused") - private void addInternalProfileListener( IProfileListener listener) { - - this.dtpProfileManager.addProfileListener( listener); - } - - @SuppressWarnings("unused") - private void removeInternalProfileListener( IProfileListener listener) { - - this.dtpProfileManager.removeProfileListener( listener); - } - - // ********** member class ********** - /** - * Listens to ProfileManager events and updates the repository. - */ - private class LocalRepositoryListener implements IProfileListener { - - LocalRepositoryListener() { - super(); - } - - public void profileAdded( IConnectionProfile connectionProfile) { - ConnectionProfileRepository.this.addProfile( connectionProfile); - } - - public void profileChanged( IConnectionProfile connectionProfile) { - // do nothing - } - - public void profileDeleted( IConnectionProfile connectionProfile) { - ConnectionProfileRepository.this.removeProfile( connectionProfile); - } - } - - - /** - * This listener translates and forwards IProfileListener events to ProfileListener. - */ - private class LocalProfileListener implements IProfileListener { - private Collection listeners = new ArrayList(); - - LocalProfileListener() { - super(); - } - - void addProfileListener( ProfileListener listener) { - this.listeners.add( listener); - } - - void removeProfileListener( ProfileListener listener) { - this.listeners.remove( listener); - } - - // ********** behavior ********** - - public void profileAdded( IConnectionProfile dtpProfile) { - ConnectionProfile profile = getProfile( dtpProfile); - for (ProfileListener listener : this.listeners) { - listener.profileAdded( profile); - } - } - - public void profileChanged( IConnectionProfile dtpProfile) { - ConnectionProfile profile = getProfile( dtpProfile); - for (ProfileListener listener : this.listeners) { - listener.profileChanged( profile); - } - } - - public void profileDeleted( IConnectionProfile dtpProfile) { - String profileName = dtpProfile.getName(); - for (ProfileListener listener : this.listeners) { - listener.profileDeleted( profileName); - } - } - } -} - - diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionProfileWrapper.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionProfileWrapper.java deleted file mode 100644 index f7e08028d4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionProfileWrapper.java +++ /dev/null @@ -1,263 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.internal; - -import java.util.Properties; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.datatools.connectivity.IManagedConnection; -import org.eclipse.datatools.connectivity.db.generic.IDBDriverDefinitionConstants; -import org.eclipse.datatools.connectivity.drivers.DriverManager; -import org.eclipse.datatools.sqltools.core.DatabaseIdentifier; -import org.eclipse.datatools.sqltools.core.profile.ProfileUtil; - -/** - * Wrap a DTP ConnectionProfile - */ -public final class DTPConnectionProfileWrapper extends ConnectionProfile { - - final private org.eclipse.datatools.connectivity.IConnectionProfile dtpConnectionProfile; - - public static final String CONNECTION_TYPE = "java.sql.Connection"; //$NON-NLS-1$ - public static final String CONNECTION_PROFILE_TYPE = "org.eclipse.datatools.connectivity.db.generic.connectionProfile"; //$NON-NLS-1$ - public static final String DATABASE_PRODUCT_PROPERTY = "org.eclipse.datatools.connectivity.server.version"; //$NON-NLS-1$ - /** - * This property is used in ConnectionProfile creation. - */ - public static final String DATABASE_SAVE_PWD_PROP_ID = IDBDriverDefinitionConstants.PROP_PREFIX + "savePWD"; //$NON-NLS-1$ - /** - * This property is used in ConnectionProfile creation. - */ - public static final String DRIVER_DEFINITION_PROP_ID = "org.eclipse.datatools.connectivity.driverDefinitionID"; //$NON-NLS-1$ - /** - * This property is used in DriverDefinition creation. - */ - public static final String DRIVER_DEFINITION_TYPE_PROP_ID = "org.eclipse.datatools.connectivity.drivers.defnType"; //$NON-NLS-1$ - /** - * This property is used in DriverDefinition creation. - */ - public static final String DRIVER_JAR_LIST_PROP_ID = "jarList"; //$NON-NLS-1$ - - public static final String POSTGRESQL_VENDOR = "postgres"; //$NON-NLS-1$ - - public static final String PUBLIC_SCHEMA = "public"; //$NON-NLS-1$ - - // ********** constructors ********** - - DTPConnectionProfileWrapper( ConnectionProfileRepository profileRepository, org.eclipse.datatools.connectivity.IConnectionProfile dtpConnectionProfile) { - super( profileRepository); - this.dtpConnectionProfile = dtpConnectionProfile; - } - - // ********** listeners ********** - - @Override - public void addProfileListener( ProfileListener listener) { - - this.getProfileRepository().addProfileListener( listener); - } - - @Override - public void removeProfileListener( ProfileListener listener) { - - this.getProfileRepository().removeProfileListener( listener); - } - - @Override - public void addConnectionListener( ConnectionListener listener) { - - this.getConnection().addConnectionListener( listener); - } - - @Override - public void removeConnectionListener( ConnectionListener listener) { - - this.getConnection().removeConnectionListener( listener); - } - - // ********** behavior ********** - - private IManagedConnection buildDtpManagedConnection( org.eclipse.datatools.connectivity.IConnectionProfile dtpProfile) { - return dtpProfile.getManagedConnection( CONNECTION_TYPE); - } - /** - * Connect using this profile. - */ - @Override - public void connect() { - if( !this.dtpConnectionProfile.isConnected()) { - - IStatus status = this.dtpConnectionProfile.connect(); - if( !status.isOK()) { - if( status.isMultiStatus()) { - IStatus[] statusChildren = status.getChildren(); - throw new RuntimeException( statusChildren[ 0].getMessage(), statusChildren[ 0].getException()); - } - throw new RuntimeException( status.getMessage(), status.getException()); - } - } - } - - @Override - public void disconnect() { - - IStatus status = this.dtpConnectionProfile.disconnect(); - if( !status.isOK()) { - if( status.isMultiStatus()) { - IStatus[] statusChildren = status.getChildren(); - throw new RuntimeException( statusChildren[ 0].getMessage(), statusChildren[ 0].getException()); - } - throw new RuntimeException( status.getMessage(), status.getException()); - } - } - - @Override - void databaseChanged( Database database, int eventType) { - this.getConnection().databaseChanged( database, eventType); - return; - } - - @Override - void catalogChanged( Catalog catalog, Database database, int eventType) { - //TODO -// this.getConnection().catalogChanged( catalog, eventType); - return; - } - - @Override - void schemaChanged( Schema schema, Database database, int eventType) { - this.getConnection().schemaChanged( schema, database, eventType); - } - - @Override - void tableChanged( Table table, Schema schema, Database database, int eventType) { - this.getConnection().tableChanged( table, schema, database, eventType); - } - - // ********** queries ********** - - @Override - public boolean isConnected() { - - return this.getConnection().isConnected(); - } - - @Override - public boolean isNull() { - return false; - } - - @Override - public String getName() { - - return this.dtpConnectionProfile.getName(); - } - - @Override - public String getDatabaseName() { - return this.getProperties().getProperty( IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID); - } - - @Override - public String getDatabaseProduct() { - return this.getProperties().getProperty( DATABASE_PRODUCT_PROPERTY); - } - - @Override - public String getDatabaseVendor() { - return this.getProperties().getProperty( IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID); - } - - @Override - public String getDatabaseVersion() { - return this.getProperties().getProperty( IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID); - } - - @Override - public String getUserName() { - return this.getProperties().getProperty( IDBDriverDefinitionConstants.USERNAME_PROP_ID); - } - - @Override - public String getUserPassword() { - return this.getProperties().getProperty( IDBDriverDefinitionConstants.PASSWORD_PROP_ID); - } - - @Override - public String getDefaultSchema() { - if( this.getDatabase().getVendor().equalsIgnoreCase( POSTGRESQL_VENDOR)) { - return PUBLIC_SCHEMA; - } - return this.getUserName(); - } - - @Override - public String getDriverClass() { - return this.getProperties().getProperty( IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID); - } - - @Override - public String getUrl() { - return this.getProperties().getProperty( IDBDriverDefinitionConstants.URL_PROP_ID); - } - - @Override - public String getInstanceId() { - return this.dtpConnectionProfile.getInstanceID(); - } - - @Override - public String getProviderId() { - return this.dtpConnectionProfile.getProviderId(); - } - - @Override - public String getDriverDefinitionId() { - return this.getProperties().getProperty( DTPConnectionProfileWrapper.DRIVER_DEFINITION_PROP_ID); - } - - @Override - public String getDriverJarList() { - return DriverManager.getInstance().getDriverInstanceByID( this.getDriverDefinitionId()).getJarList(); - } - - private Properties getProperties() { - return this.dtpConnectionProfile.getBaseProperties(); - } - - @Override - protected Connection buildConnection() { - - Connection connection = Connection.createConnection( this.buildDtpManagedConnection( this.dtpConnectionProfile)); //$NON-NLS-1$ - return connection; - } - - @Override - protected Database buildDatabase() { - - org.eclipse.datatools.modelbase.sql.schema.Database dtpDatabase; - if( this.isConnected()) { - //TODO see DTP bug 202306 - //pass connect=true in to ProfileUtil.getDatabase() - //there is a bug mentioned in a comment: - // "during the profile connected event notification, - // IManagedConnection is connected while IConnectionProfile is not" - //so some hackery here for their hackery - dtpDatabase = ProfileUtil.getDatabase( new DatabaseIdentifier( this.getName(), this.getDatabaseName()), true); - return Database.createDatabase( this, dtpDatabase); - } - return NullDatabase.instance(); - } - - @Override - boolean wraps( org.eclipse.datatools.connectivity.IConnectionProfile dtpProfile) { - return this.dtpConnectionProfile == dtpProfile; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionWrapper.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionWrapper.java deleted file mode 100644 index 5440b35e3f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPConnectionWrapper.java +++ /dev/null @@ -1,170 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.internal; - -import java.util.ArrayList; -import java.util.Collection; - -import org.eclipse.datatools.connectivity.ConnectEvent; -import org.eclipse.datatools.connectivity.IManagedConnectionListener; - -/** - * Wrap a DTP Connection - */ -public final class DTPConnectionWrapper extends Connection { - - final private org.eclipse.datatools.connectivity.IManagedConnection dtpConnection; - private LocalConnectionListener connectionListener; - - // ********** constructors ********** - - DTPConnectionWrapper( org.eclipse.datatools.connectivity.IManagedConnection dtpConnection) { - super(); - this.dtpConnection = dtpConnection; - this.initialize(); - } - - // ********** behavior ********** - - protected void initialize() { - this.connectionListener = new LocalConnectionListener(); - this.dtpConnection.addConnectionListener( this.connectionListener); - } - - @Override - protected void dispose() { - this.dtpConnection.removeConnectionListener( this.connectionListener); - } - - @Override - public String getName() { - - return this.dtpConnection.getConnection().getConnectionProfile().getName(); - } - - @Override - public boolean isConnected() { - - return this.dtpConnection.isConnected(); - } - - @Override - public String getFactoryId() { - - return this.dtpConnection.getFactoryID(); - } - - @Override - void databaseChanged( Database database, int eventType) { - - this.connectionListener.databaseChanged( database, eventType); - } - - @Override - void schemaChanged( Schema schema, Database database, int eventType) { - - this.connectionListener.schemaChanged( schema, database, eventType); - } - - @Override - void tableChanged( Table table, Schema schema, Database database, int eventType) { - - this.connectionListener.tableChanged( table, schema, database, eventType); - } - - // ********** listeners ********** - - @Override - public void addConnectionListener( ConnectionListener listener) { - // hook up the specified listener to our intermediate listeners - this.connectionListener.addConnectionListener( listener); - } - - @Override - public void removeConnectionListener( ConnectionListener listener) { - - this.connectionListener.removeConnectionListener( listener); - } - - // ********** member classes ********** - - /** - * This listener translates and forwards IManagedConnectionListener events to ConnectionListeners. - */ - private class LocalConnectionListener implements IManagedConnectionListener { - private Collection listeners = new ArrayList(); - - LocalConnectionListener() { - super(); - } - - void addConnectionListener( ConnectionListener listener) { - this.listeners.add( listener); - } - - void removeConnectionListener( ConnectionListener listener) { - this.listeners.remove( listener); - } - - // ********** behavior ********** - - public void aboutToClose( ConnectEvent event) { - for (ConnectionListener listener : this.listeners) { - listener.aboutToClose( DTPConnectionWrapper.this); - } - } - - public void closed( ConnectEvent event) { - for (ConnectionListener listener : this.listeners) { - listener.closed( DTPConnectionWrapper.this); - } - } - - public void modified( ConnectEvent event) { - for (ConnectionListener listener : this.listeners) { - listener.modified( DTPConnectionWrapper.this); - } - } - - public boolean okToClose( ConnectEvent event) { - for (ConnectionListener listener : this.listeners) { - if( !listener.okToClose( DTPConnectionWrapper.this)) { - return false; - } - } - return true; - } - - public void opened( ConnectEvent event) { - for (ConnectionListener listener : this.listeners) { - listener.opened( DTPConnectionWrapper.this); - } - } - - void databaseChanged( Database database, int eventType) { - for (ConnectionListener listener : this.listeners) { - listener.databaseChanged( DTPConnectionWrapper.this, database); - } - } - - void schemaChanged( Schema schema, Database database, int eventType) { - for (ConnectionListener listener : this.listeners) { - listener.schemaChanged( DTPConnectionWrapper.this, schema); - } - } - - void tableChanged( Table table, Schema schema, Database database, int eventType) { - for (ConnectionListener listener : this.listeners) { - listener.tableChanged( DTPConnectionWrapper.this, table); - } - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPDatabaseWrapper.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPDatabaseWrapper.java deleted file mode 100644 index d8b1dadb9e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPDatabaseWrapper.java +++ /dev/null @@ -1,229 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.internal; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.NoSuchElementException; -import java.util.Set; - -import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObject; -import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObjectListener; -import org.eclipse.emf.common.util.EList; - -/** - * Wrap a DTP Database - */ -public final class DTPDatabaseWrapper extends Database { - - final ConnectionProfile profile; - final org.eclipse.datatools.modelbase.sql.schema.Database dtpDatabase; - private ICatalogObjectListener databaseListener; - - private Set catalogs; // lazy-initialized - private Set schemata; // lazy-initialized - - DTPDatabaseWrapper( ConnectionProfile profile, org.eclipse.datatools.modelbase.sql.schema.Database dtpDatabase) { - super(); - this.dtpDatabase = dtpDatabase; - this.profile = profile; - this.initialize(); - } - - // ********** behavior ********** - - private void initialize() { - - if( this.connectionIsOnline()) { - this.databaseListener = this.buildDatabaseListener(); - this.addCatalogObjectListener(( ICatalogObject) this.dtpDatabase, this.databaseListener); - } - } - - @Override - protected boolean connectionIsOnline() { - return this.profile.isConnected(); - } - - private ICatalogObjectListener buildDatabaseListener() { - return new ICatalogObjectListener() { - public void notifyChanged( final ICatalogObject database, final int eventType) { - if( database == DTPDatabaseWrapper.this.dtpDatabase) { - DTPDatabaseWrapper.this.refresh(); - DTPDatabaseWrapper.this.profile.databaseChanged( DTPDatabaseWrapper.this, eventType); - } - } - }; - } - - @Override - void refresh() { - this.disposeSchemata(); - this.disposeCatalogs(); - - this.schemata = null; - this.catalogs = null; - } - - @Override - void catalogChanged( Catalog catalog, int eventType) { - this.profile.catalogChanged( catalog, this, eventType); - return; - } - - @Override - void schemaChanged( Schema schema, int eventType) { - this.profile.schemaChanged( schema, this, eventType); - return; - } - - @Override - void tableChanged( Table table, Schema schema, int eventType) { - this.profile.tableChanged( table, schema, this, eventType); - return; - } - - @Override - protected void dispose() { - this.removeCatalogObjectListener(( ICatalogObject) this.dtpDatabase, this.databaseListener); - - this.disposeSchemata(); - this.disposeCatalogs(); - } - - private void disposeSchemata() { - if( this.schemata != null) { - for( Iterator stream = this.schemata(); stream.hasNext(); ) { - stream.next().dispose(); - } - } - } - - private void disposeCatalogs() { - if( this.catalogs != null) { - for( Iterator stream = this.catalogs(); stream.hasNext(); ) { - stream.next().dispose(); - } - } - } - - // ********** queries ********** - - @Override - public String getName() { - - return this.dtpDatabase.getName(); - } - - @Override - public String getVendor() { - - return this.dtpDatabase.getVendor(); - } - - @Override - public String getVersion() { - - return this.dtpDatabase.getVersion(); - } - - - // ***** schemata - - @Override - synchronized Set getSchemata() { - if( this.schemata == null) { - this.schemata = this.buildSchemata(); - } - return this.schemata; - } - - @SuppressWarnings("unchecked") - private EList dtpSchemata() { - return this.dtpDatabase.getSchemas(); - } - - private Set buildSchemata() { - Set result; - if( this.supportsCatalogs()) { - result = this.getSchemataForCatalogNamed( this.profile.getCatalogName()); - } - else { - EList dtpSchemata = this.dtpSchemata(); - result = new HashSet( dtpSchemata.size()); - for (org.eclipse.datatools.modelbase.sql.schema.Schema dtpSchema : dtpSchemata) { - result.add( this.wrap(dtpSchema)); - } - } - return result; - } - - // ***** catalogs - - @Override - public boolean supportsCatalogs() { - EList dtpSchemata = this.dtpSchemata(); - return ( dtpSchemata == null || dtpSchemata.size() == 0); - } - - @SuppressWarnings("unchecked") - private EList dtpCatalogs() { - return this.dtpDatabase.getCatalogs(); - } - - @Override - public String getDefaultCatalogName() { - - if( !this.supportsCatalogs()) { // this database doesn't support catalogs - return ""; - } - String userName = this.profile.getUserName(); - for (org.eclipse.datatools.modelbase.sql.schema.Catalog dtpCatalog : this.dtpCatalogs()) { - if( dtpCatalog.getName().length() == 0) { // special catalog that contains all schemata - return ""; - } - else if( dtpCatalog.getName().equals( userName)) { - return userName; // returns user name as default catalog - } - else if( dtpCatalog.getName().equals( this.getName())) { - return this.getName(); // special catalog with same name as DB (PostgreSQL) - } - } - throw new NoSuchElementException(); - } - - @Override - synchronized Set getCatalogs() { - if( this.catalogs == null) { - this.catalogs = this.buildCatalogs(); - } - return this.catalogs; - } - - private Set buildCatalogs() { - - EList dtpCatalogs = this.dtpCatalogs(); - if( dtpCatalogs == null) { - return Collections.emptySet(); - } - Set result = new HashSet( dtpCatalogs.size()); - for (org.eclipse.datatools.modelbase.sql.schema.Catalog dtpCatalog : dtpCatalogs) { - result.add( this.wrap(dtpCatalog)); - } - return result; - } - - private Set getSchemataForCatalogNamed( String catalogName) { - - Catalog catalog = this.catalogNamed( catalogName); - return ( catalog != null) ? catalog.buildSchemata() : Collections.emptySet(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPTools.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPTools.java deleted file mode 100644 index 1c46efdfd5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPTools.java +++ /dev/null @@ -1,212 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.internal; - -import java.sql.Types; -import java.util.HashMap; -import org.eclipse.datatools.modelbase.sql.datatypes.PrimitiveType; -import org.eclipse.jpt.utility.internal.JDBCTools; -import org.eclipse.jpt.utility.internal.JDBCType; -import org.eclipse.jpt.utility.internal.JavaType; - -/** - * Helper methods for dealing with Eclipse DTP. - */ -public final class DTPTools { - - /** - * Return the JDBC type corresponding to the specified Primitive type. - */ - public static JDBCType jdbcTypeForPrimitiveTypeNamed(String primitiveTypeName) { - PrimitiveToJDBCTypeMapping mapping = primitiveToJDBCTypeMapping(primitiveTypeName); - return (mapping == null) ? DEFAULT_JDBC_TYPE : mapping.getJDBCType(); - } - - /** - * Return the JDBC type corresponding to the specified Primitive type. - */ - public static JDBCType jdbcTypeFor(PrimitiveType primitiveType) { - return jdbcTypeForPrimitiveTypeNamed(primitiveType.getName()); - } - - /** - * Return the JDBC type corresponding to the specified Primitive type. - */ - public static JDBCType jdbcTypeForPrimitiveTypeCode(int primitiveTypeCode) { - return jdbcTypeFor(PrimitiveType.get(primitiveTypeCode)); - } - - /** - * Return the Java type corresponding to the specified Primitive type. - */ - public static JavaType javaTypeForPrimitiveTypeNamed(String primitiveTypeName) { - return JDBCTools.javaTypeFor(jdbcTypeForPrimitiveTypeNamed(primitiveTypeName)); - } - - /** - * Return the Java type corresponding to the specified Primitive type. - */ - public static JavaType javaTypeFor(PrimitiveType primitiveType) { - return JDBCTools.javaTypeFor(jdbcTypeFor(primitiveType)); - } - - /** - * Return the Java type corresponding to the specified Primitive type. - */ - public static JavaType javaTypeForPrimitiveTypeCode(int primitiveTypeCode) { - return JDBCTools.javaTypeFor(jdbcTypeForPrimitiveTypeCode(primitiveTypeCode)); - } - - /** - * Return whether the specified Primitive type is a LOB - * (i.e. a BLOB, CLOB, or NCLOB). - */ - public static boolean dataTypeIsLob(PrimitiveType primitiveType) { - return (primitiveType == PrimitiveType.BINARY_LARGE_OBJECT_LITERAL) - || (primitiveType == PrimitiveType.CHARACTER_LARGE_OBJECT_LITERAL) - || (primitiveType == PrimitiveType.NATIONAL_CHARACTER_LARGE_OBJECT_LITERAL); - } - - - // ********** internal stuff ********** - - - // ********** DTP Primitive => JDBC ********** - - /** - * Primitive => JDBC type mappings, keyed by Primitive type name (e.g. "CHARACTER_VARYING") - */ - private static HashMap PRIMITIVE_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 PrimitiveToJDBCTypeMapping primitiveToJDBCTypeMapping(String primitiveTypeName) { - return primitiveToJDBCTypeMappings().get(primitiveTypeName); - } - - private static synchronized HashMap primitiveToJDBCTypeMappings() { - if (PRIMITIVE_TO_JDBC_TYPE_MAPPINGS == null) { - PRIMITIVE_TO_JDBC_TYPE_MAPPINGS = buildPrimitiveToJDBCTypeMappings(); - } - return PRIMITIVE_TO_JDBC_TYPE_MAPPINGS; - } - - private static HashMap buildPrimitiveToJDBCTypeMappings() { - HashMap mappings = new HashMap(); - addPrimitiveToJDBCTypeMappingsTo(mappings); - return mappings; - } - - /** - * hard code the default mappings from the DTP primitive types to the - * appropriate JDBC types; - * pretty much a straight one-to-one mapping based on similar names; - * TODO some JDBC types are missing: INTERVAL, XML_TYPE - */ - private static void addPrimitiveToJDBCTypeMappingsTo(HashMap mappings) { - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.BIGINT_LITERAL, Types.BIGINT, mappings); - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.BINARY_LARGE_OBJECT_LITERAL, Types.BLOB, mappings); - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.BINARY_LITERAL, Types.BINARY, mappings); - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.BINARY_VARYING_LITERAL, Types.VARBINARY, mappings); - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.BOOLEAN_LITERAL, Types.BOOLEAN, mappings); - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.CHARACTER_LARGE_OBJECT_LITERAL, Types.CLOB, mappings); - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.CHARACTER_LITERAL, Types.CHAR, mappings); - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.CHARACTER_VARYING_LITERAL, Types.VARCHAR, mappings); - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.DATALINK_LITERAL, Types.DATALINK, mappings); - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.DATE_LITERAL, Types.DATE, mappings); - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.DECIMAL_LITERAL, Types.DECIMAL, mappings); - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.DOUBLE_PRECISION_LITERAL, Types.DOUBLE, mappings); - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.FLOAT_LITERAL, Types.FLOAT, mappings); - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.INTEGER_LITERAL, Types.INTEGER, mappings); - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.INTERVAL_LITERAL, Types.OTHER, mappings); // ??? - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.NATIONAL_CHARACTER_LARGE_OBJECT_LITERAL, Types.CLOB, mappings); - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.NATIONAL_CHARACTER_LITERAL, Types.CHAR, mappings); - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.NATIONAL_CHARACTER_VARYING_LITERAL, Types.VARCHAR, mappings); - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.NUMERIC_LITERAL, Types.NUMERIC, mappings); - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.REAL_LITERAL, Types.REAL, mappings); - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.SMALLINT_LITERAL, Types.SMALLINT, mappings); - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.TIME_LITERAL, Types.TIME, mappings); - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.TIMESTAMP_LITERAL, Types.TIMESTAMP, mappings); - addPrimitiveToJDBCTypeMappingTo(PrimitiveType.XML_TYPE_LITERAL, Types.OTHER, mappings); // ??? - } - - private static void addPrimitiveToJDBCTypeMappingTo(PrimitiveType primitiveType, int jdbcTypeCode, HashMap mappings) { - // check for duplicates - Object prev = mappings.put(primitiveType.getName(), buildPrimitiveToJDBCTypeMapping(primitiveType, jdbcTypeCode)); - if (prev != null) { - throw new IllegalArgumentException("duplicate Java class: " + ((PrimitiveToJDBCTypeMapping) prev).getPrimitiveType().getName()); - } - } - - private static PrimitiveToJDBCTypeMapping buildPrimitiveToJDBCTypeMapping(PrimitiveType primitiveType, int jdbcTypeCode) { - return new PrimitiveToJDBCTypeMapping(primitiveType, JDBCType.type(jdbcTypeCode)); - } - - - // ********** constructor ********** - - /** - * Suppress default constructor, ensuring non-instantiability. - */ - private DTPTools() { - super(); - throw new UnsupportedOperationException(); - } - - - // ********** member classes ********** - - /** - * Primitive => JDBC - */ - private static class PrimitiveToJDBCTypeMapping { - private final PrimitiveType primitiveType; - private final JDBCType jdbcType; - - PrimitiveToJDBCTypeMapping(PrimitiveType primitiveType, JDBCType jdbcType) { - super(); - this.primitiveType = primitiveType; - this.jdbcType = jdbcType; - } - - public PrimitiveType getPrimitiveType() { - return this.primitiveType; - } - - public JDBCType getJDBCType() { - return this.jdbcType; - } - - public boolean maps(PrimitiveType pt) { - return this.primitiveType.equals(pt); - } - - public boolean maps(String primitiveTypeName) { - return this.primitiveType.getName().equals(primitiveTypeName); - } - - public boolean maps(int primitiveTypeCode) { - return this.primitiveType.getValue() == primitiveTypeCode; - } - - @Override - public String toString() { - StringBuffer sb = new StringBuffer(); - this.appendTo(sb); - return sb.toString(); - } - - public void appendTo(StringBuffer sb) { - sb.append(this.primitiveType.getName()); - sb.append(" => "); - this.jdbcType.appendTo(sb); - } - } -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPWrapper.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPWrapper.java deleted file mode 100644 index 11e9808ec6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/DTPWrapper.java +++ /dev/null @@ -1,52 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.internal; - -import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObject; -import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObjectListener; -import org.eclipse.datatools.connectivity.sqm.core.rte.RefreshManager; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * DataTools Wrapper base class. - */ -public abstract class DTPWrapper { - - DTPWrapper() { - super(); - } - - // ********** behavior ********** - - protected abstract void dispose(); - - protected abstract boolean connectionIsOnline(); - - protected void addCatalogObjectListener( ICatalogObject catalogObject, ICatalogObjectListener catalogObjectListener) { - if( this.connectionIsOnline()) { - RefreshManager.getInstance().AddListener( catalogObject, catalogObjectListener); - } - } - - protected void removeCatalogObjectListener( ICatalogObject catalogObject, ICatalogObjectListener catalogObjectListener) { - if( this.connectionIsOnline()) { - RefreshManager.getInstance().removeListener( catalogObject, catalogObjectListener); - } - } - - // ********** queries ********** - - public abstract String getName(); - - @Override - public String toString() { - return StringTools.buildToStringFor( this, this.getName()); - } -} \ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Database.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Database.java deleted file mode 100644 index ab7f5656e9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Database.java +++ /dev/null @@ -1,229 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.internal; - -import java.text.Collator; -import java.util.Iterator; -import java.util.Set; - -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; - -/** - * Database wrapper base class. - */ -public abstract class Database extends DTPWrapper implements Comparable { - - private boolean caseSensitive = false; // TODO allow user to configure - - // ********** constructors ********** - - static Database createDatabase( ConnectionProfile profile, org.eclipse.datatools.modelbase.sql.schema.Database dtpDatabase) { - return ( dtpDatabase == null) ? NullDatabase.instance() : new DTPDatabaseWrapper( profile, dtpDatabase); - } - - Database() { - super(); - } - - // ********** behavior ********** - - abstract void catalogChanged( Catalog catalog, int eventType); - - abstract void schemaChanged( Schema schema, int eventType); - - abstract void tableChanged( Table table, Schema schema, int eventType); - - abstract void refresh(); - - protected Schema wrap( org.eclipse.datatools.modelbase.sql.schema.Schema schema) { - return new Schema( this, schema); - } - - protected Catalog wrap( org.eclipse.datatools.modelbase.sql.schema.Catalog catalog) { - return new Catalog( this, catalog); - } - - // ********** queries ********** - - public abstract String getVendor(); - - public abstract String getVersion(); - - /** - * return the column for the specified dtp column - */ - Column column( org.eclipse.datatools.modelbase.sql.tables.Column dtpColumn) { - return this.table( dtpColumn.getTable()).column( dtpColumn); - } - - /** - * return the table for the specified dtp table - */ - Table table( org.eclipse.datatools.modelbase.sql.tables.Table dtpTable) { - return this.schema( dtpTable.getSchema()).table( dtpTable); - } - - // ********** Comparable implementation ********** - - public int compareTo( Database database) { - return Collator.getInstance().compare( this.getName(), database.getName()); - } - - // ***** caseSensitive - - public boolean isCaseSensitive() { - return this.caseSensitive; - } - - public void setCaseSensitive( boolean caseSensitive) { - this.caseSensitive = caseSensitive; - } - - // ***** catalogs - - abstract Set getCatalogs(); - - /** - * Returns true if this database accepts catalogs. - */ - public abstract boolean supportsCatalogs(); - - /** - * Returns the catalog to use by default. - */ - public abstract String getDefaultCatalogName(); - - public Iterator catalogs() { - return this.getCatalogs().iterator(); - } - - public int catalogSize() { - return this.getCatalogs().size(); - } - - public Iterator catalogNames() { - return new TransformationIterator( this.catalogs()) { - @Override - protected String transform( Catalog catalog) { - return catalog.getName(); - } - }; - } - - public boolean containsCatalogNamed( String name) { - return this.catalogNamed( name) != null; - } - - public Catalog catalogNamed( String name) { - return this.isCaseSensitive() ? this.catalogNamedInternal( name) : this.catalogNamedIgnoreCase( name); - } - - private Catalog catalogNamedInternal( String name) { - for ( Iterator stream = this.catalogs(); stream.hasNext(); ) { - Catalog catalog = stream.next(); - if ( catalog.getName().equals( name)) { - return catalog; - } - } - return null; - } - - private Catalog catalogNamedIgnoreCase( String name) { - for ( Iterator stream = this.catalogs(); stream.hasNext(); ) { - Catalog catalog = stream.next(); - if ( StringTools.stringsAreEqualIgnoreCase( catalog.getName(), name)) { - return catalog; - } - } - return null; - } - - /** - * return the catalog for the specified dtp catalog - */ - Catalog catalog( org.eclipse.datatools.modelbase.sql.schema.Catalog dtpCatalog) { - for ( Iterator stream = this.catalogs(); stream.hasNext(); ) { - Catalog catalog = stream.next(); - if (catalog.wraps( dtpCatalog)) { - return catalog; - } - } - throw new IllegalArgumentException( "invalid dtp catalog: " + dtpCatalog); - } - - - // ***** schemata - - abstract Set getSchemata(); - - public Iterator schemata() { - return this.getSchemata().iterator(); - } - - public int schemataSize() { - return this.getSchemata().size(); - } - - public boolean schemataContains( Column column) { - return this.getSchemata().contains( column); - } - - public Iterator schemaNames() { - return new TransformationIterator( this.schemata()) { - @Override - protected String transform( Schema schema) { - return schema.getName(); - } - }; - } - - public boolean containsSchemaNamed( String name) { - return this.schemaNamed( name) != null; - } - - public Schema schemaNamed( String name) { - return this.isCaseSensitive() ? this.schemaNamedInternal( name) : this.schemaNamedIgnoreCase( name); - } - - private Schema schemaNamedInternal( String name) { - for ( Iterator stream = this.schemata(); stream.hasNext(); ) { - Schema schema = stream.next(); - if ( schema.getName().equals( name)) { - return schema; - } - } - return null; - } - - private Schema schemaNamedIgnoreCase( String name) { - for ( Iterator stream = this.schemata(); stream.hasNext(); ) { - Schema schema = stream.next(); - if ( StringTools.stringsAreEqualIgnoreCase( schema.getName(), name)) { - return schema; - } - } - return null; - } - - /** - * return the schema for the specified dtp schema - */ - Schema schema( org.eclipse.datatools.modelbase.sql.schema.Schema dtpSchema) { - for ( Iterator stream = this.schemata(); stream.hasNext(); ) { - Schema schema = stream.next(); - if ( schema.wraps( dtpSchema)) { - return schema; - } - } - throw new IllegalArgumentException( "invalid dtp schema: " + dtpSchema); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ForeignKey.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ForeignKey.java deleted file mode 100644 index 6fc0501d6a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ForeignKey.java +++ /dev/null @@ -1,337 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.internal; - -import java.text.Collator; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; - -import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObject; -import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObjectListener; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; -import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; - -/** - * Wrap a DTP ForeignKey - */ -public final class ForeignKey extends DTPWrapper implements Comparable { - private final Table baseTable; - private final org.eclipse.datatools.modelbase.sql.constraints.ForeignKey dtpForeignKey; - private ICatalogObjectListener foreignKeyListener; - - private Table referencedTable; // lazy-initialized - private Set columnPairs; // lazy-initialized - private String defaultEntityFieldName; // lazy-initialized - private boolean defaultEntityFieldNameCalculated = false; - - - // ********** constructors ********** - - ForeignKey(Table baseTable, org.eclipse.datatools.modelbase.sql.constraints.ForeignKey dtpForeignKey) { - super(); - this.baseTable = baseTable; - this.dtpForeignKey = dtpForeignKey; - this.initialize(); - } - - // ********** behavior ********** - - private void initialize() { - if( this.connectionIsOnline()) { - this.foreignKeyListener = this.buildForeignKeyListener(); - this.addCatalogObjectListener(( ICatalogObject) this.dtpForeignKey, this.foreignKeyListener); - } - } - - @Override - protected boolean connectionIsOnline() { - return this.baseTable.connectionIsOnline(); - } - - private ICatalogObjectListener buildForeignKeyListener() { - return new ICatalogObjectListener() { - public void notifyChanged( final ICatalogObject foreignKey, final int eventType) { -// TODO -// if( foreignKey == ForeignKey.this.dtpForeignKey) { -// ForeignKey.this.baseTable.foreignKeyChanged( ForeignKey.this, eventType); -// } - } - }; - } - - @Override - protected void dispose() { - - this.removeCatalogObjectListener(( ICatalogObject) this.dtpForeignKey, this.foreignKeyListener); - } - - // ********** queries ********** - - public Table getBaseTable() { - return this.baseTable; - } - - @Override - public String getName() { - return this.dtpForeignKey.getName(); - } - - boolean isCaseSensitive() { - return this.baseTable.isCaseSensitive(); - } - - boolean wraps(org.eclipse.datatools.modelbase.sql.constraints.ForeignKey foreignKey) { - return this.dtpForeignKey == foreignKey; - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this, this.getName() + ": " + this.getColumnPairs()); - } - - public Table getReferencedTable() { - if (this.referencedTable == null) { - this.referencedTable = this.baseTable.table(this.dtpForeignKey.getUniqueConstraint().getBaseTable()); - } - return this.referencedTable; - } - - /** - * return the foreign key's "base" columns - */ - public Iterator baseColumns() { - return new TransformationIterator(this.columnPairs()) { - @Override - protected Column transform(ColumnPair pair) { - return pair.getBaseColumn(); - } - }; - } - - /** - * return the foreign key's "base" columns that are not part of - * the base table's primary key - */ - public Iterator nonPrimaryKeyBaseColumns() { - return new FilteringIterator(this.baseColumns()) { - @Override - protected boolean accept(Object o) { - return ! ForeignKey.this.getBaseTable().primaryKeyColumnsContains((Column) o); - } - }; - } - - /** - * return the foreign key's "referenced" columns - */ - public Iterator referencedColumns() { - return new TransformationIterator(this.columnPairs()) { - @Override - protected Column transform(ColumnPair columnPair) { - return columnPair.getReferencedColumn(); - } - }; - } - - public String javaFieldName() { - String fieldName = this.getDefaultEntityFieldName(); - return (fieldName == null) ? - this.nonDefaultEntityFieldName() - : - fieldName; - } - - public boolean matchesJavaFieldName(String javaFieldName) { - return this.isCaseSensitive() ? - javaFieldName.equals(this.getDefaultEntityFieldName()) - : - javaFieldName.equalsIgnoreCase(this.getDefaultEntityFieldName()); - } - - public boolean isDefaultFor(String javaFieldName) { - if (this.columnPairsSize() != 1) { - return false; - } - - if (this.getReferencedTable().primaryKeyColumnsSize() != 1) { - return false; - } - - ColumnPair columnPair = this.columnPairs().next(); - Column pkColumn = this.getReferencedTable().primaryKeyColumns().next(); - if (columnPair.getReferencedColumn() != pkColumn) { - return false; - } - - return columnPair.getBaseColumn().matchesJavaFieldName(javaFieldName + "_" + pkColumn.getName()); - } - - - // ***** column pairs - - private synchronized Set getColumnPairs() { - if (this.columnPairs == null) { - this.columnPairs = this.buildColumnPairs(); - } - return this.columnPairs; - } - - @SuppressWarnings("unchecked") - private List dtpBaseColumns() { - return this.dtpForeignKey.getMembers(); - } - - @SuppressWarnings("unchecked") - private List dtpRefColumns() { - return this.dtpForeignKey.getUniqueConstraint().getMembers(); - } - - private Set buildColumnPairs() { - List baseColumns = this.dtpBaseColumns(); - int size = baseColumns.size(); - List refColumns = this.dtpRefColumns(); - if (refColumns.size() != size) { - throw new IllegalStateException("mismatched sizes: " + size + " vs. " + refColumns.size()); - } - Set result = new HashSet(baseColumns.size()); - for (int i = baseColumns.size(); i-- > 0; ) { - Column baseColumn = this.baseTable.column(baseColumns.get(i)); - Column refColumn = this.baseTable.column(refColumns.get(i)); - result.add(new ColumnPair(baseColumn, refColumn)); - } - return result; - } - - public Iterator columnPairs() { - return this.getColumnPairs().iterator(); - } - - public int columnPairsSize() { - return this.getColumnPairs().size(); - } - - - // ***** default entity field name - - /** - * If the name of the "base" column adheres to the EJB standard for a - * default mapping (i.e. it ends with an underscore followed by the name - * of the "referenced" column, and the "referenced" column is the single - * primary key column of the "referenced" table), return the corresponding - * default entity field name: - * ForeignKey(EMP.CUBICLE_ID => CUBICLE.ID) => "CUBICLE" - * Return a null if it does not adhere to the EJB standard: - * ForeignKey(EMP.CUBICLE_ID => CUBICLE.CUBICLE_ID) => null - */ - private String getDefaultEntityFieldName() { - if ( ! this.defaultEntityFieldNameCalculated) { - this.defaultEntityFieldNameCalculated = true; - this.defaultEntityFieldName = this.buildDefaultEntityFieldName(); - } - return this.defaultEntityFieldName; - } - - /** - * @see #getDefaultEntityFieldName() - */ - private String buildDefaultEntityFieldName() { - if ( ! this.referencesSingleColumnPrimaryKey()) { - return null; - } - ColumnPair columnPair = this.columnPairs().next(); - String baseColName = columnPair.getBaseColumn().getName(); - String refColName = columnPair.getReferencedColumn().getName(); - if (baseColName.length() <= (refColName.length() + 1)) { - return null; - } - if ( ! baseColName.endsWith(refColName)) { - return null; - } - int _index = baseColName.length() - refColName.length() - 1; - if (baseColName.charAt(_index) != '_') { - return null; - } - String name = baseColName.substring(0, _index); - return this.isCaseSensitive() ? name : name.toLowerCase(); - } - - /** - * Return whether the foreign key references the primary key of the - * "referenced" table and that primary key has only a single column. - */ - public boolean referencesSingleColumnPrimaryKey() { - if (this.columnPairsSize() != 1) { - return false; - } - if (this.getReferencedTable().primaryKeyColumnsSize() != 1) { - return false; - } - - ColumnPair columnPair = this.columnPairs().next(); - return columnPair.getReferencedColumn() == this.getReferencedTable().primaryKeyColumns().next(); - } - - /** - * If this is a simple (single-column) foreign key, return the java field - * name of the single base column. If this is a compound foreign key, - * return the java field name of the referenced table. - */ - // TODO if there is only one FK to a given table, use the table's name instead of the column's name? - // TODO if the FK column name ends with the PK column name, strip the PK column name? - private String nonDefaultEntityFieldName() { - return (this.columnPairsSize() == 1) ? - this.columnPairs().next().getBaseColumn().javaFieldName() - : - this.getReferencedTable().javaFieldName(); - } - - - // ********** Comparable implementation ********** - - public int compareTo(ForeignKey foreignKey) { - return Collator.getInstance().compare(this.getName(), foreignKey.getName()); - } - - - // ********** member class ********** - - public static class ColumnPair implements Comparable { - private final Column baseColumn; - private final Column referencedColumn; - - ColumnPair(Column baseColumn, Column referencedColumn) { - super(); - this.baseColumn = baseColumn; - this.referencedColumn = referencedColumn; - } - - public Column getBaseColumn() { - return this.baseColumn; - } - - public Column getReferencedColumn() { - return this.referencedColumn; - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this, baseColumn.getName() + "=>" + this.referencedColumn.getName()); - } - - public int compareTo(ColumnPair cp) { - return Collator.getInstance().compare(this.getBaseColumn().getName(), cp.getBaseColumn().getName()); - } - - } - -} \ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/JptDbPlugin.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/JptDbPlugin.java deleted file mode 100644 index 0d9f21777f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/JptDbPlugin.java +++ /dev/null @@ -1,64 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.internal; - -import org.eclipse.core.runtime.Plugin; -import org.osgi.framework.BundleContext; - -/** - * The main plugin class to be used in the desktop. - */ -public class JptDbPlugin extends Plugin { - private ConnectionProfileRepository connectionProfileRepository; - - // The shared instance - private static JptDbPlugin plugin; - - /** - * Returns the shared instance - */ - public static JptDbPlugin getDefault() { - return plugin; - } - - /** - * The constructor - */ - public JptDbPlugin() { - super(); - plugin = this; - } - - /** - * This method is called upon plug-in activation - */ - @Override - public void start(BundleContext context) throws Exception { - super.start(context); - this.connectionProfileRepository = ConnectionProfileRepository.instance(); - this.connectionProfileRepository.initializeListeners(); - } - - /** - * This method is called when the plug-in is stopped - */ - @Override - public void stop(BundleContext context) throws Exception { - this.connectionProfileRepository.disposeListeners(); - this.connectionProfileRepository = null; - plugin = null; - super.stop(context); - } - - - public ConnectionProfileRepository getConnectionProfileRepository() { - return this.connectionProfileRepository; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullConnection.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullConnection.java deleted file mode 100644 index f09563360a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullConnection.java +++ /dev/null @@ -1,81 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.internal; - -import org.eclipse.jpt.utility.internal.ClassTools; - -/** - * NullConnection - */ -public final class NullConnection extends Connection { - - private static NullConnection INSTANCE; - - /** - * singleton support - */ - static synchronized Connection instance() { - if( INSTANCE == null) { - INSTANCE = new NullConnection(); - } - return INSTANCE; - } - - private NullConnection() { - super(); - } - - // ********** behavior ********** - - @Override - protected void dispose() { - // do nothing - } - - @Override - public String getName() { - return ClassTools.shortClassNameForObject( this); - } - - @Override - void databaseChanged( Database database, int eventType) { - // do nothing - } - - @Override - void schemaChanged( Schema schema, Database database, int eventType) { - // do nothing - } - - @Override - void tableChanged( Table table, Schema schema, Database database, int eventType) { - // do nothing - } - - @Override - public boolean isConnected() { - return false; - } - - @Override - public String getFactoryId() { - return ""; - } - - @Override - public void addConnectionListener( ConnectionListener listener) { - // do nothing - } - - @Override - public void removeConnectionListener( ConnectionListener listener) { - // do nothing - } -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullConnectionProfile.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullConnectionProfile.java deleted file mode 100644 index 67a2e59f4d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullConnectionProfile.java +++ /dev/null @@ -1,192 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.internal; - -import org.eclipse.datatools.connectivity.drivers.DriverManager; -import org.eclipse.jpt.utility.internal.ClassTools; - -/** - * NullConnectionProfile - */ -public final class NullConnectionProfile extends ConnectionProfile { - - private static NullConnectionProfile INSTANCE; - - /** - * singleton support - */ - static synchronized ConnectionProfile instance() { - if( INSTANCE == null) { - INSTANCE = new NullConnectionProfile(); - } - return INSTANCE; - } - - private NullConnectionProfile() { - super( null); - } - - // ********** behavior ********** - - @Override - protected Connection buildConnection() { - return NullConnection.instance(); - } - - @Override - protected Database buildDatabase() { - return NullDatabase.instance(); - } - - @Override - public void connect() { - // do nothing - } - - @Override - public void disconnect() { - // do nothing - } - - @Override - void databaseChanged( Database database, int eventType) { - // do nothing - } - - @Override - void catalogChanged( Catalog catalog, Database database, int eventType) { - // do nothing - } - - @Override - void schemaChanged( Schema schema, Database database, int eventType) { - // do nothing - } - - @Override - void tableChanged( Table table, Schema schema, Database database, int eventType) { - // do nothing - } - - // ********** queries ********** - - @Override - public Connection getConnection() { - return NullConnection.instance(); - } - - @Override - public Database getDatabase() { - return NullDatabase.instance(); - } - - @Override - public String getName() { - return ClassTools.shortClassNameForObject( this); - } - - @Override - public String getDatabaseName() { - return ""; - } - - @Override - public String getDatabaseProduct() { - return ""; - } - - @Override - public String getDatabaseVendor() { - return ""; - } - - @Override - public String getDatabaseVersion() { - return ""; - } - - @Override - public String getUserName() { - return ""; - } - - @Override - public String getUserPassword() { - return ""; - } - - @Override - public String getDefaultSchema() { - return ""; - } - - @Override - public String getDriverClass() { - return ""; - } - - @Override - public String getUrl() { - return ""; - } - - @Override - public String getInstanceId() { - return ""; - } - - @Override - public String getProviderId() { - return ""; - } - - @Override - public String getDriverDefinitionId() { - return ""; - } - - @Override - public String getDriverJarList() { - return ""; - } - - @Override - public boolean isConnected() { - return false; - } - - @Override - boolean wraps( org.eclipse.datatools.connectivity.IConnectionProfile dtpProfile) { - return false; - } - - // ********** listeners ********** - - @Override - public void addProfileListener( ProfileListener listener) { - // do nothing - } - - @Override - public void removeProfileListener( ProfileListener listener) { - // do nothing - } - - @Override - public void addConnectionListener( ConnectionListener listener) { - // do nothing - } - - @Override - public void removeConnectionListener( ConnectionListener listener) { - // do nothing - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullDatabase.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullDatabase.java deleted file mode 100644 index fa316b82ef..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/NullDatabase.java +++ /dev/null @@ -1,109 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.internal; - -import java.util.Collections; -import java.util.Set; -import org.eclipse.jpt.utility.internal.ClassTools; - -/** - * NullDatabase - */ -public final class NullDatabase extends Database { - - private static NullDatabase INSTANCE; - - /** - * singleton support - */ - static synchronized Database instance() { - if( INSTANCE == null) { - INSTANCE = new NullDatabase(); - } - return INSTANCE; - } - - private NullDatabase() { - super(); - } - - // ********** behavior ********** - - @Override - void catalogChanged( Catalog catalog, int eventType) { - // do nothing - } - - @Override - void schemaChanged( Schema schema, int eventType) { - // do nothing - } - - @Override - void tableChanged( Table table, Schema schema,int eventType) { - // do nothing - } - - @Override - void refresh() { - // do nothing - } - - @Override - protected void dispose() { - // do nothing - } - - @Override - protected boolean connectionIsOnline() { - return false; - } - - // ********** queries ********** - - @Override - public String getName() { - return ClassTools.shortClassNameForObject( this); - } - - @Override - public String getVendor() { - return this.getName(); - } - - @Override - public String getVersion() { - return ""; - } - - // ***** catalogs - - @Override - public boolean supportsCatalogs() { - return false; - } - - @Override - public String getDefaultCatalogName() { - return ""; - } - - @Override - Set getCatalogs() { - return Collections.emptySet(); - } - - // ***** schemata - - @Override - Set getSchemata() { - return Collections.emptySet(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ProfileListener.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ProfileListener.java deleted file mode 100644 index 677b38c031..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/ProfileListener.java +++ /dev/null @@ -1,35 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.internal; - -/** - * ProfileListener integrate th DTP IProfileListener listener. - * This class purpose is to decouple from the DTP listeners by accepting wrappers as parameter. - * - * @see org.eclipse.datatools.connectivity.IProfileListener - */ -public interface ProfileListener { - /** - * The specified profile has been added. - */ - public void profileAdded( ConnectionProfile profile); - - /** - * The specified profile has been deleted. - */ - public void profileDeleted( String profileName); - - /** - * The specified profile has been modified. Modification includes - * changes to any properties, the name, auto-connect flag, etc. - */ - public void profileChanged( ConnectionProfile profile); - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Schema.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Schema.java deleted file mode 100644 index 9ef2c7fb04..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Schema.java +++ /dev/null @@ -1,299 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.internal; - -import java.text.Collator; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObject; -import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObjectListener; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; - -/** - * Wrap a DTP Schema - */ -public final class Schema extends DTPWrapper implements Comparable { - final Database database; - final org.eclipse.datatools.modelbase.sql.schema.Schema dtpSchema; - private ICatalogObjectListener schemaListener; - - private Set tables; // lazy-initialized - private Set sequences; // lazy-initialized - - - // ********** constructors ********** - - Schema( Database database, org.eclipse.datatools.modelbase.sql.schema.Schema dtpSchema) { - super(); - this.database = database; - this.dtpSchema = dtpSchema; - this.initialize(); - } - - // ********** behavior ********** - - private void initialize() { - if( this.connectionIsOnline()) { - this.schemaListener = this.buildSchemaListener(); - this.addCatalogObjectListener(( ICatalogObject) this.dtpSchema, this.schemaListener); - } - } - - @Override - protected boolean connectionIsOnline() { - return this.database.connectionIsOnline(); - } - - private ICatalogObjectListener buildSchemaListener() { - return new ICatalogObjectListener() { - public void notifyChanged( final ICatalogObject schema, final int eventType) { - if( schema == Schema.this.dtpSchema) { - Schema.this.refresh(); - Schema.this.database.schemaChanged( Schema.this, eventType); - } - } - }; - } - - void refresh() { - this.disposeTables(); - this.disposeSequences(); - - this.tables = null; - this.sequences = null; - } - - void tableChanged( Table table, int eventType) { - this.database.tableChanged( table, this, eventType); - } - - protected Table wrap( org.eclipse.datatools.modelbase.sql.tables.Table table) { - return new Table( this, table); - } - - protected Sequence wrap( org.eclipse.datatools.modelbase.sql.schema.Sequence sequence) { - return new Sequence( this, sequence); - } - - @Override - protected void dispose() { - this.removeCatalogObjectListener(( ICatalogObject) this.dtpSchema, this.schemaListener); - - this.disposeTables(); - this.disposeSequences(); - } - - private void disposeTables() { - if( this.tables != null) { - for( Iterator
stream = this.tables(); stream.hasNext(); ) { - stream.next().dispose(); - } - } - } - - private void disposeSequences() { - if( this.sequences != null) { - for( Iterator stream = this.sequences(); stream.hasNext(); ) { - stream.next().dispose(); - } - } - } - - // ********** queries ********** - - @Override - public String getName() { - return this.dtpSchema.getName(); - } - - boolean isCaseSensitive() { - return this.database.isCaseSensitive(); - } - - Column column( org.eclipse.datatools.modelbase.sql.tables.Column dtpColumn) { - return this.database.column(dtpColumn); - } - - - // ********** tables ********** - - private synchronized Collection
getTables() { - if( this.tables == null) { - this.tables = this.buildTables(); - } - return this.tables; - } - - @SuppressWarnings("unchecked") - private Collection dtpTables() { - return this.dtpSchema.getTables(); - } - - private Set
buildTables() { - Collection dtpTables = this.dtpTables(); - Set
result = new HashSet
( dtpTables.size()); - for (org.eclipse.datatools.modelbase.sql.tables.Table dtpTable : dtpTables) { - result.add( this.wrap(dtpTable)); - } - return result; - } - - public Iterator
tables() { - return this.getTables().iterator(); - } - - public int tablesSize() { - return this.getTables().size(); - } - - public boolean tablesContains( Column column) { - return this.getTables().contains( column); - } - - public Iterator tableNames() { - return new TransformationIterator( this.tables()) { - @Override - protected String transform( Table table) { - return table.getName(); - } - }; - } - - public boolean containsTableNamed( String name) { - return this.tableNamed( name) != null; - } - - public Table tableNamed( String name) { - return this.isCaseSensitive() ? this.tableNamedInternal( name) : this.tableNamedIgnoreCase( name); - } - - private Table tableNamedInternal( String name) { - for( Iterator
stream = this.tables(); stream.hasNext(); ) { - Table table = stream.next(); - if( table.getName().equals( name)) { - return table; - } - } - return null; - } - - private Table tableNamedIgnoreCase( String name) { - for( Iterator
stream = this.tables(); stream.hasNext(); ) { - Table table = stream.next(); - if( StringTools.stringsAreEqualIgnoreCase( table.getName(), name)) { - return table; - } - } - return null; - } - - /** - * return the table for the specified dtp table - */ - Table table( org.eclipse.datatools.modelbase.sql.tables.Table dtpTable) { - if( dtpTable.getSchema() != this.dtpSchema) { - return this.database.table( dtpTable); - } - for( Iterator
stream = this.tables(); stream.hasNext(); ) { - Table table = stream.next(); - if( table.wraps( dtpTable)) { - return table; - } - } - throw new IllegalArgumentException( "invalid DTP table: " + dtpTable); - } - - // ***** sequences - - private synchronized Collection getSequences() { - if( this.sequences == null) { - this.sequences = this.buildSequences(); - } - return this.sequences; - } - - @SuppressWarnings("unchecked") - private Collection dtpSequences() { - return this.dtpSchema.getSequences(); - } - - private Set buildSequences() { - Collection dtpSequences = this.dtpSequences(); - Set result = new HashSet( dtpSequences.size()); - for (org.eclipse.datatools.modelbase.sql.schema.Sequence dtpSequence : dtpSequences) { - result.add( this.wrap(dtpSequence)); - } - return result; - } - - public Iterator sequences() { - return this.getSequences().iterator(); - } - - public int sequencesSize() { - return this.getSequences().size(); - } - - public boolean sequencesContains( Column column) { - return this.getSequences().contains( column); - } - - public Iterator sequenceNames() { - return new TransformationIterator(this.sequences()) { - @Override - protected String transform( Sequence sequence) { - return sequence.getName(); - } - }; - } - - public boolean containsSequenceNamed( String name) { - return this.sequenceNamed( name) != null; - } - - public Sequence sequenceNamed( String name) { - return this.isCaseSensitive() ? this.sequenceNamedInternal( name) : this.sequenceNamedIgnoreCase( name); - } - - private Sequence sequenceNamedInternal( String name) { - for( Iterator stream = this.sequences(); stream.hasNext(); ) { - Sequence sequence = stream.next(); - if( sequence.getName().equals( name)) { - return sequence; - } - } - return null; - } - - private Sequence sequenceNamedIgnoreCase( String name) { - for( Iterator stream = this.sequences(); stream.hasNext(); ) { - Sequence sequence = stream.next(); - if( sequence.getName().equalsIgnoreCase( name)) { - return sequence; - } - } - return null; - } - - boolean wraps( org.eclipse.datatools.modelbase.sql.schema.Schema schema) { - return this.dtpSchema == schema; - } - - // ********** Comparable implementation ********** - - public int compareTo( Schema schema) { - return Collator.getInstance().compare( this.getName(), schema.getName()); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Sequence.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Sequence.java deleted file mode 100644 index 7cb68a47e5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Sequence.java +++ /dev/null @@ -1,74 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.internal; - -import java.text.Collator; - -import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObject; -import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObjectListener; - -/** - * Wrap a DTP Sequence - */ -public final class Sequence extends DTPWrapper implements Comparable { - private final Schema schema; - private final org.eclipse.datatools.modelbase.sql.schema.Sequence dtpSequence; - private ICatalogObjectListener sequenceListener; - - Sequence( Schema schema, org.eclipse.datatools.modelbase.sql.schema.Sequence dtpSequence) { - super(); - this.schema = schema; - this.dtpSequence = dtpSequence; - this.initialize(); - } - - // ********** behavior ********** - - private void initialize() { - if( this.connectionIsOnline()) { - this.sequenceListener = this.buildSequenceListener(); - this.addCatalogObjectListener(( ICatalogObject) this.dtpSequence, this.sequenceListener); - } - } - - @Override - protected boolean connectionIsOnline() { - return this.schema.connectionIsOnline(); - } - - private ICatalogObjectListener buildSequenceListener() { - return new ICatalogObjectListener() { - public void notifyChanged( final ICatalogObject sequence, final int eventType) { -// TODO -// if( sequence == Sequence.this.dtpSequence) { -// Sequence.this.schema.sequenceChanged( Sequence.this, eventType); -// } - } - }; - } - - - // ********** queries ********** - - @Override - protected void dispose() { - - this.removeCatalogObjectListener(( ICatalogObject) this.dtpSequence, this.sequenceListener); - } - - @Override - public String getName() { - return this.dtpSequence.getName(); - } - - public int compareTo( Sequence sequence) { - return Collator.getInstance().compare( this.getName(), sequence.getName()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Table.java b/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Table.java deleted file mode 100644 index 7b49b72f8c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.db/src/org/eclipse/jpt/db/internal/Table.java +++ /dev/null @@ -1,359 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.internal; - -import java.text.Collator; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObject; -import org.eclipse.datatools.connectivity.sqm.core.rte.ICatalogObjectListener; -import org.eclipse.datatools.modelbase.sql.constraints.PrimaryKey; -import org.eclipse.datatools.modelbase.sql.tables.BaseTable; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.NameTools; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; - -/** - * Wrap a DTP Table - */ -public final class Table extends DTPWrapper implements Comparable
{ - final Schema schema; - final org.eclipse.datatools.modelbase.sql.tables.Table dtpTable; - private ICatalogObjectListener tableListener; - - private Set columns; // lazy-initialized - private Set primaryKeyColumns; // lazy-initialized - private Set foreignKeys; // lazy-initialized - private Set foreignKeyColumns; // lazy-initialized - - // ********** constructors ********** - - Table(Schema schema, org.eclipse.datatools.modelbase.sql.tables.Table dtpTable) { - super(); - this.schema = schema; - this.dtpTable = dtpTable; - this.initialize(); - } - - - // ********** behavior ********** - - private void initialize() { - if( this.connectionIsOnline()) { - this.tableListener = this.buildTableListener(); - this.addCatalogObjectListener(( ICatalogObject) this.dtpTable, this.tableListener); - } - } - - @Override - protected boolean connectionIsOnline() { - return this.schema.connectionIsOnline(); - } - - private ICatalogObjectListener buildTableListener() { - return new ICatalogObjectListener() { - public void notifyChanged( final ICatalogObject table, final int eventType) { - if( table == Table.this.dtpTable) { - Table.this.refresh(); - Table.this.schema.tableChanged( Table.this, eventType); - } - } - }; - } - - void refresh() { - this.disposeColumns(); - - this.columns = null; - this.primaryKeyColumns = null; - this.foreignKeys = null; - this.foreignKeyColumns = null; - } - - @Override - protected void dispose() { - this.removeCatalogObjectListener(( ICatalogObject) this.dtpTable, this.tableListener); - - this.disposeColumns(); - this.disposeForeignKey(); - } - - private void disposeColumns() { - if( this.columns != null) { - for( Iterator stream = this.columns(); stream.hasNext(); ) { - stream.next().dispose(); - } - } - } - - private void disposeForeignKey() { - if( this.foreignKeys != null) { - for( Iterator stream = this.foreignKeys(); stream.hasNext(); ) { - stream.next().dispose(); - } - } - } - - // ********** queries ********** - - @Override - public String getName() { - return this.dtpTable.getName(); - } - - boolean isCaseSensitive() { - return this.schema.isCaseSensitive(); - } - - public String shortJavaClassName() { - String jName = this.getName(); - if ( ! this.isCaseSensitive()) { - jName = StringTools.capitalize(jName.toLowerCase()); - } - return NameTools.convertToJavaIdentifier(jName); - } - - public boolean matchesShortJavaClassName(String shortJavaClassName) { - return this.isCaseSensitive() ? - this.getName().equals(shortJavaClassName) - : - this.getName().equalsIgnoreCase(shortJavaClassName); - } - - public String javaFieldName() { - String jName = this.getName(); - if ( ! this.isCaseSensitive()) { - jName = jName.toLowerCase(); - } - return NameTools.convertToJavaIdentifier(jName); - } - - boolean wraps(org.eclipse.datatools.modelbase.sql.tables.Table table) { - return this.dtpTable == table; - } - - /** - * return the table for the specified DTP table - */ - Table table(org.eclipse.datatools.modelbase.sql.tables.Table table) { - return this.schema.table(table); - } - - // ***** columns - - private synchronized Set getColumns() { - if (this.columns == null) { - this.columns = this.buildColumns(); - } - return this.columns; - } - - @SuppressWarnings("unchecked") - private Collection dtpColumns() { - return this.dtpTable.getColumns(); - } - - private Set buildColumns() { - Collection dtpColumns = this.dtpColumns(); - Set result = new HashSet(dtpColumns.size()); - for (org.eclipse.datatools.modelbase.sql.tables.Column c : dtpColumns) { - result.add(new Column(this, c)); - } - return result; - } - - public Iterator columns() { - return this.getColumns().iterator(); - } - - public int columnsSize() { - return this.getColumns().size(); - } - - public boolean columnsContains(Column column) { - return this.getColumns().contains(column); - } - - public Iterator columnNames() { - return new TransformationIterator(this.columns()) { - @Override - protected String transform(Column next) { - return next.getName(); - } - }; - } - - public boolean containsColumnNamed(String name) { - return this.columnNamed(name) != null; - } - - public Column columnNamed(String name) { - return this.isCaseSensitive() ? this.columnNamedInternal(name) : this.columnNamedIgnoreCase(name); - } - - private Column columnNamedInternal(String name) { - for (Iterator stream = this.columns(); stream.hasNext(); ) { - Column column = stream.next(); - if (column.getName().equals(name)) { - return column; - } - } - return null; - } - - private Column columnNamedIgnoreCase(String name) { - for (Iterator stream = this.columns(); stream.hasNext(); ) { - Column column = stream.next(); - if (StringTools.stringsAreEqualIgnoreCase(column.getName(), name)) { - return column; - } - } - return null; - } - - /** - * return the column for the specified dtp column - */ - Column column(org.eclipse.datatools.modelbase.sql.tables.Column dtpColumn) { - if (dtpColumn.getTable() != this.dtpTable) { - return this.schema.column(dtpColumn); - } - for (Iterator stream = this.columns(); stream.hasNext(); ) { - Column column = stream.next(); - if (column.wraps(dtpColumn)) { - return column; - } - } - throw new IllegalArgumentException("invalid dtp column: " + dtpColumn); - } - - - // ***** primaryKeyColumns - - private synchronized Set getPrimaryKeyColumns() { - if (this.primaryKeyColumns == null) { - this.primaryKeyColumns = this.buildPrimaryKeyColumns(); - } - return this.primaryKeyColumns; - } - - @SuppressWarnings("unchecked") - private Collection columns(PrimaryKey pk) { - return pk.getMembers(); - } - - private Set buildPrimaryKeyColumns() { - if ( ! (this.dtpTable instanceof BaseTable)) { - return Collections.emptySet(); - } - PrimaryKey pk = ((BaseTable) this.dtpTable).getPrimaryKey(); - if (pk == null) { - // no PK was defined - return Collections.emptySet(); - } - Collection pkColumns = this.columns(pk); - Set result = new HashSet(pkColumns.size()); - for (org.eclipse.datatools.modelbase.sql.tables.Column pkColumn : pkColumns) { - result.add(this.column(pkColumn)); - } - return result; - } - - public Iterator primaryKeyColumns() { - return this.getPrimaryKeyColumns().iterator(); - } - - public int primaryKeyColumnsSize() { - return this.getPrimaryKeyColumns().size(); - } - - public boolean primaryKeyColumnsContains(Column column) { - return this.getPrimaryKeyColumns().contains(column); - } - - - // ***** foreignKeys - - private synchronized Set getForeignKeys() { - if (this.foreignKeys == null) { - this.foreignKeys = this.buildForeignKeys(); - } - return this.foreignKeys; - } - - @SuppressWarnings("unchecked") - private Collection dtpForeignKeys() { - return ((BaseTable) this.dtpTable).getForeignKeys(); - } - - private Set buildForeignKeys() { - if ( ! (this.dtpTable instanceof BaseTable)) { - return Collections.emptySet(); - } - Collection dtpForeignKeys = this.dtpForeignKeys(); - Set result = new HashSet(dtpForeignKeys.size()); - for (org.eclipse.datatools.modelbase.sql.constraints.ForeignKey dtpForeignKey : dtpForeignKeys) { - result.add(new ForeignKey(this, dtpForeignKey)); - } - return result; - } - - public Iterator foreignKeys() { - return this.getForeignKeys().iterator(); - } - - public int foreignKeysSize() { - return this.getForeignKeys().size(); - } - - - // ***** foreignKeyColumns - - private synchronized Set getForeignKeyColumns() { - if (this.foreignKeyColumns == null) { - this.foreignKeyColumns = this.buildForeignKeyColumns(); - } - return this.foreignKeyColumns; - } - - private Set buildForeignKeyColumns() { - if ( ! (this.dtpTable instanceof BaseTable)) { - return Collections.emptySet(); - } - Set result = new HashSet(this.columnsSize()); - for (Iterator stream = this.foreignKeys(); stream.hasNext(); ) { - CollectionTools.addAll(result, stream.next().baseColumns()); - } - return result; - } - - public Iterator foreignKeyColumns() { - return this.getForeignKeyColumns().iterator(); - } - - public int foreignKeyColumnsSize() { - return this.getForeignKeyColumns().size(); - } - - public boolean foreignKeyColumnsContains(Column column) { - return this.getForeignKeyColumns().contains(column); - } - - // ********** Comparable implementation ********** - - public int compareTo( Table table) { - return Collator.getInstance().compare( this.getName(), table.getName()); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/.project b/jpa/plugins/org.eclipse.jpt.doc.user/.project deleted file mode 100644 index 61670ff4fc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/.project +++ /dev/null @@ -1,22 +0,0 @@ - - - org.eclipse.jpt.doc.user - - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.doc.user/META-INF/MANIFEST.MF deleted file mode 100644 index 85ae0c4f47..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/META-INF/MANIFEST.MF +++ /dev/null @@ -1,8 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: %pluginName -Bundle-Vendor: %providerName -Bundle-SymbolicName: org.eclipse.jpt.doc.user;singleton:=true -Bundle-Version: 1.0.1.qualifier -Bundle-Localization: plugin -Eclipse-LazyStart: true diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/about.html b/jpa/plugins/org.eclipse.jpt.doc.user/about.html deleted file mode 100644 index 8f21cb851d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/about.html +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - -About this content - - - - - - - - - - - - - - -
-
- - - -
-

About this content

-
-

June 06, 2007

- -

License

-

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 http://www.eclipse.org/legal/epl-v10.html. For purposes of the EPL, "Program" will mean the Content.

-

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 http://www.eclipse.org.

- - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/build.properties b/jpa/plugins/org.eclipse.jpt.doc.user/build.properties deleted file mode 100644 index ade565e3e9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/build.properties +++ /dev/null @@ -1,102 +0,0 @@ -bin.includes = cheatsheets/,\ - dcommon/,\ - img/,\ - META-INF/,\ - about.html,\ - build.properties,\ - concept_mapping.htm,\ - concept_persistence.htm,\ - concepts.htm,\ - concepts001.htm,\ - concepts002.htm,\ - concepts003.htm,\ - contexts.xml,\ - getting_started.htm,\ - getting_started001.htm,\ - getting_started002.htm,\ - getting_started003.htm,\ - getting_started004.htm,\ - getting_started005.htm,\ - getting_started006.htm,\ - getting_started007.htm,\ - getting_started008.htm,\ - getting_started009.htm,\ - getting_started010.htm,\ - getting_started011.htm,\ - getting_started012.htm,\ - getting_started013.htm,\ - getting_started014.htm,\ - getting_started015.htm,\ - getting_started016.htm,\ - getting_started017.htm,\ - getting_started018.htm,\ - getting_started019.htm,\ - index.xml,\ - legal.htm,\ - plugin.properties,\ - plugin.xml,\ - ref_details_orm.htm,\ - ref_jpa_facet.htm,\ - ref_mapping_general.htm,\ - ref_new_jpa_project.htm,\ - ref_new_jpa_project_wizard.htm,\ - ref_persistence_map_view.htm,\ - ref_persistence_outline.htm,\ - ref_persistence_perspective.htm,\ - ref_persistence_prop_view.htm,\ - ref_primary_key.htm,\ - ref_project_properties.htm,\ - reference.htm,\ - reference001.htm,\ - reference002.htm,\ - reference003.htm,\ - reference004.htm,\ - reference005.htm,\ - reference006.htm,\ - reference007.htm,\ - reference008.htm,\ - reference009.htm,\ - reference010.htm,\ - reference011.htm,\ - reference012.htm,\ - reference013.htm,\ - reference014.htm,\ - reference015.htm,\ - reference016.htm,\ - reference017.htm,\ - task_add_persistence.htm,\ - task_additonal_tables.htm,\ - task_create_new_project.htm,\ - task_generate_entities.htm,\ - task_inheritance.htm,\ - task_manage_orm.htm,\ - task_manage_persistence.htm,\ - task_mapping.htm,\ - tasks.htm,\ - tasks001.htm,\ - tasks002.htm,\ - tasks003.htm,\ - tasks004.htm,\ - tasks005.htm,\ - tasks006.htm,\ - tasks007.htm,\ - tasks008.htm,\ - tasks009.htm,\ - tasks010.htm,\ - tasks011.htm,\ - tasks012.htm,\ - tasks013.htm,\ - tasks014.htm,\ - tasks015.htm,\ - tasks016.htm,\ - tasks017.htm,\ - tasks018.htm,\ - tasks019.htm,\ - tasks020.htm,\ - tasks021.htm,\ - tips_and_tricks.htm,\ - toc.xml,\ - whats_new.htm,\ - whats_new001.htm,\ - whats_new002.htm,\ - whats_new003.htm diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/add_persistence.xml b/jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/add_persistence.xml deleted file mode 100644 index 6dbeedbeca..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/add_persistence.xml +++ /dev/null @@ -1,63 +0,0 @@ - - - - - This cheat sheet will automatically launch wizards, perform actions, and guide you through the steps to create a JPA project. - -To learn more about using cheat sheets, or to see a list of available cheat sheets, click Help (?). -To start work working on this cheat sheet click the "Click to Begin" button below. - -Let's get started! - - - - - Your environment must be set up before you can perform the steps in this cheat sheet. - -Create a database profile and connect to the database. - -The Database Connection dialog automatically appears when you click the "Click to Perform" button. - - - - - - - Use the New Project Wizard to create a JPA project. -Select File->New->Project... and choose JPA->JPA Project in the list. - -On the first page of the wizard, enter a project name and location, select your target runtime, and select a predefined project configuration. - -Click Next to display the next page of the wizard. - -The "New JPA Project" wizard is automatically displayed when you click the "Click to Perform" button. - - - - - - - Use the Project Facet page to select a predefined project configuration or specific specific facets to include in the project. - -Click "Next" to display the next page of the wizard. - - - - - Use the JPA Facet page to specify the the vendor-specific JPA platform, the database connection to use, and the specific JPA implementation library. - -You can also specify if Dali should create an orm.xml file. - -If you do not have an active database connection, click Add Connections to create one. - -If you do not have a defined JPA implementation library, click Configure default JPA implementation library or Configure user libraries to define one. - -Click Finish to complete the wizard and open the open the project. - - - - - Congratulations! You have successfully created a JPA project. Complete the additional cheat sheets to add Java persistent entities and map those entities to database tables. - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/create_entity.xml b/jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/create_entity.xml deleted file mode 100644 index b64e8afdee..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/create_entity.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - -This cheat sheet will automatically launch wizards, perform actions, and guide you through the steps to add a Java persistent entity to your Java project. -To learn more about using cheat sheets or to see a list of available cheat sheets, click Help (?). -To start work working on this cheat sheet, click the Click to Begin button below. -Let's get started! - - - - -To create a Persistent entity, you must create a JPA project. If you already have a JPA project, you may skip this step by clicking the "Click to Skip" button. -If not, select File->New->Project... and choose JPA->JPA Project in the list. Complete each page of the Create JPA Project wizard to create a new JPA project. - - - - - -When working with JPA persistence, you should use the Persistence perspective. If you already have the Persistence perspective active, you may skip this step by clicking the "Click to Skip" button. -If not, select Window->Open Perspective->Other in the menubar at the top of the workbench. In the Select Perspectives dialog, select JPA Development and click OK. This step changes the perspective to set up the Eclipse workbench for JPA development. -You can click the "Click to Perform" button to have the "Persistence" perspective opened automatically. - - - - -The next step is to create a new Java class. In the main toolbar again, click on New Java Class button (or the link below). -The Java editor will automatically open showing your new class. - - - - -Finally we will make the Java class a persistent entity. -In the JPA Structure view select the Java class. -In the JPA Details view, use the "Map As" field to select Entity. Dali automatically adds the @Entity annotation to the class in the Java editor. -Use the Table, Catalog, and Schema fields to associate the entity with a specific table in the database. - - - - -Congratulations! You have successfully added a JPA entity to your JPA project. Complete the additional cheat sheets to map the entity's fields to database tables. - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/map_entity.xml b/jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/map_entity.xml deleted file mode 100644 index 63307f226e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/cheatsheets/map_entity.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - This cheat sheet will automatically launch wizards, perform actions, and guide you through the steps to map the fields of a JPA entity entity to your database. - -To learn more about using cheat sheets or to see a list of available cheat sheets, click Help (?). -To start work working on this cheat sheet, click the "Click to Begin" button below. - -Let's get started! - - - - - Your environment must be set up before you can perform the steps in this cheat sheet. - -Create a database profile and connect to the database. - -If you already have (and are connected to) a database connection, you may skip this step by clicking the "Click to Skip" button. - -The Database Connection dialog automatically appears when you click the "Click to Perform" button. - - - - - - - Use the New Project Wizard to create a JPA project. -Select File->New->Project... and choose JPA->JPA Project in the list. - -Complete each page of the wizard to create a new JPA project. - -The "New JPA Project" wizard is automatically displayed when you click the "Click to Perform" button. - -If you already have a JPA project, you may skip this step by clicking the "Click to Skip" button. - - - - - - - When working with JPA persistence, you should use the Persistence perspective. If you already have the Persistence perspective active, you may skip this step by clicking the "Click to Skip" button. -If not, select Window->Open Perspective->Other in the menubar at the top of the workbench. In the Select Perspectives dialog, select JPA Development and click OK. This step changes the perspective to set up the Eclipse workbench for JPA development. -You can click the "Click to Perform" button to have the "Persistence" perspective opened automatically. - - - - - - - The next step is to create a new Java class. In the main toolbar again, click on New Java Class button (or the link below). -The Java editor will automatically open showing your new class. - - - - - Finally we will make the Java class a persistent entity. -In the JPA Structure view select the Java class. -In the JPA Details view, use the "Map As" field to select Entity. Dali automatically adds the @Entity annotation to the class in the Java editor. -Use the Table, Catalog, and Schema fields to associate the entity with a specific table in the database. - - - - - Now you will add some fields to the entity to map to rows in the database table. - -If your persistent entity already has fields to map, you may skip this step by clicking the "Click to Skip" button. If not, use the Java editor to add fields to the entity. - - - - - - - Now you are ready to map the entity fields to columns in the database table. In the Package Explorer, select the Java class. - -In the JPA Structure view, expand the persistent entity to display the fields. Select a field. - -The JPA Details view displays the information for the field. Use the Map As field to select the Basic mapping. Use the Column field to select a column from the database table. - - - - - - - Congratulations! You have successfully mapped the fields from a Java persistent entity to a column in a database table. - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/concept_mapping.htm b/jpa/plugins/org.eclipse.jpt.doc.user/concept_mapping.htm deleted file mode 100644 index 1b826a5bd0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/concept_mapping.htm +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - -Understanding OR mappings - - - - - - - - - - - - - - -

-
- - - - -
-

Understanding OR mappings

-
-

The Dali OR (object-relational) Mapping Tool allows you to describe how your entity objects map to the data source (or other objects). This approach isolates persistence information from the object model. Developers are free to design their ideal object model, and DBAs are free to design their ideal schema.

-

These mappings transform an object data member type to a corresponding relational database data source representation. These OR mappings can also transform object data members that reference other domain objects stored in other tables in the database and are related through foreign keys.

-

You can use these mappings to map simple data types including primitives (such as int), JDK classes (such as String), and large object (LOB) values. You can also use them to transform object data members that reference other domain objects by way of association where data source representations require object identity maintenance (such as sequencing and back references) and possess various types of multiplicity and navigability. The appropriate mapping class is chosen primarily by the cardinality of the relationship.

-Related task
-
-Mapping an entity -

 

-
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/concept_persistence.htm b/jpa/plugins/org.eclipse.jpt.doc.user/concept_persistence.htm deleted file mode 100644 index 8f339e52ab..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/concept_persistence.htm +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - -Understanding Java persistence - - - - - - - - - - - - - - -

-
- - - - -
-

Understanding Java persistence

-
-

Persistence refers to the ability to store objects in a database and use those objects with transactional integrity. In a J2EE application, data is typically stored and persisted in the data tier, in a relational database.

-

Entity beans are enterprise beans that contain persistent data and that can be saved in various persistent data stores. The entity beans represent data from a database; each entity bean carries its own identity. Entity beans can be deployed using application-managed persistence or container-managed persistence.

-
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/concepts.htm b/jpa/plugins/org.eclipse.jpt.doc.user/concepts.htm deleted file mode 100644 index 38f63d8dd5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/concepts.htm +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - -Concepts - - - - - - - - - - - - - - -

- - - - -
-

Concepts

-
-

This section contains an overview of concepts you should be familiar with when using Dali to create mappings for Java persistent entities.

- -

In addition to these sections, you should review the following resources for additional information:

- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/concepts001.htm b/jpa/plugins/org.eclipse.jpt.doc.user/concepts001.htm deleted file mode 100644 index 9ad5cc172d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/concepts001.htm +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - -Understanding EJB 3.0 Java Persistence API - - - - - - - - - - - - - - -

-
- - - - -
-

Understanding EJB 3.0 Java Persistence API

-
-

The Java 2 Enterprise Edition(J2EE) Enterprise JavaBeans (EJB) are a component architecture that you use to develop and deploy object-oriented, distributed, enterprise-scale applications. An application written according to the Enterprise JavaBeans architecture is scalable, transactional, and secure.

-

The EJB 3.0 Java Persistence API (JPA) improves the EJB architecture by reducing its complexity through the use of metadata (annotations) and specifying programmatic defaults of that metadata.

-Related task
-
-Mapping an entity -

 

- - -
- - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/concepts002.htm b/jpa/plugins/org.eclipse.jpt.doc.user/concepts002.htm deleted file mode 100644 index 40716b5963..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/concepts002.htm +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - -The persistence.xml file - - - - - - - - - - - - - - -

-
- - - - -
-

The persistence.xml file

-
-

The JPA specification requires the use of a persistence.xml file for deployment. This file defines the database and entity manager options, and may contain more than one persistence unit. Dali can use the Eclipse XML Editor to create and maintain this information. See "Managing the persistence.xml file" for more information.

-Related task
-
-Managing the persistence.xml file
-Creating a new JPA project -

 

-
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/concepts003.htm b/jpa/plugins/org.eclipse.jpt.doc.user/concepts003.htm deleted file mode 100644 index 80395b0896..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/concepts003.htm +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - -The orm.xml file - - - - - - - - - - - - - - -

-
- - - - -
-

The orm.xml file

-
-

Although the JPA specification emphasizes the use of annotations to specify persistence, you can also the orm.xml file to store this metadata. Dali can use the Eclipse XML Editor to create and maintain this information. The metadata must match the XSD specification of your selected JPA implementation. See "Managing the orm.xml file" for more information.

-Related task
-
-Managing the orm.xml file
-Creating a new JPA project -

 

-
- - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/contexts.xml b/jpa/plugins/org.eclipse.jpt.doc.user/contexts.xml deleted file mode 100644 index 34de0ef6d1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/contexts.xml +++ /dev/null @@ -1,422 +0,0 @@ - - - - - Specify how the variable is accessed: Property (default) or Field. - - - - - - The name of this entity. By default, the class name is used as the entity name. - - - - - - The database table assigned to this entity. By default, the class name is used as the database table name. - - - - - - - Specify a property or field to be overridden (from the default mappings). - - - - - - Name of the database column. - - - - - - The database column that overrides a property or field. - - - - - - Specifies if the column is always included in SQL INSERT statements. - - - - - - Specifies if the column is always included in SQL UPDATE statements. - - - - - - Specify how this attribute maps to the database. - - - - - - The database column that contains the value for the attribute. - - - - - - Name of the database table that contains the selected column. - - - - - - Specifies if the column is always included in SQL INSERT statements. - - - - - - Specifies if the column is always included in SQL UPDATE statements. - - - - - - Defines how data is loaded from the database: Eager (default) or Lazy - - - - - - Specifies if this field is can be null. - - - - - - Determines how the primary key is generated: Auto (default), Sequence, Identity, or Table. - - - - - - Unique name of the generator. - - - - - - The entity to which this attribute is mapped. - - - - - - Specify which operations are propagated throughout the entity: All, Persist, Merge, or Move. - - - - - - The field in the database table that owns the relationship. - - - - - - The name of the database column that contains the foreign key reference for the entity association. - - - - - - Name of the join table that contains the foreign key column. - - - - - - Specify to override the default mapping of an entity’s attribute. - - - - - - The database column that is being mapped to the entity’s attribute. - - - - - - Specify the type of persistent domain object for the Java class: Persistent, Embedded, or Mapped Superclass. - - - - - - Specify how an entity may inherit properties from other entities: Single table, One table per class, or Joined tables. - - - - - Use to specify the name of the discriminator column when using a Single or Joined inheritance strategy. - - - - - Use this field to set the discriminator type to CHAR or INTEGER (instead of its default: String). The discriminator value must conform to this type. - - - - - Specify the discriminator value used to differentiate an entity in this inheritance hierarchy. The value must conform to the specified discriminator type. - - - - - Specify the default order for objects returned from a query. - - - - - Specify the name of the database table that defines the foreign key for a many-to-many or a unidirectional one-to-many association. You can configure the join table with a specific catalog or schema, configure one or more join table columns with a unique constraint, and use multiple join columns per entity. - - - - - Specify two or more join columns (that is, a composite primary key). - - - - - Specify the join column on the owned (or inverse side) of the association: the owned entity's primary key column. - - - - - Use the Java Persistence options on the Properties page to select the database connection to use with the project. - - - - - - The database connection used to map the persistent entities. - - - - - The database schema used to map the persistent entities. - - - - - Use the Add Persistence dialog to define the database connection use to store the persistence entities. - - - - - The JPA Structure view displays an outline of the structure (its attributes and mappings) of the entity that is currently selected or opened in the editor. - - - - - Use the Generate Entities dialog to create Java persistent entities based on your database tables. - - - - - The project folder name in which to generate the Java persistent entities. Click Browse to select an existing folder. - - - - The package in which to generate the Java persistent entities, or click Browse to select an existing package. - - - - Select the tables from which to create Java persistent entities. - - - - - Use this dialog to define the database connection used to store the persistence entities and to create the persistence.xml file. - - - - - - Use this dialog to define the new JPA project name, its location, target runtime, and other configuration settings. - - - - - - - Use these fields to define the database connection used to store the persistent entities. - - - - - Use this option to add libraries or JARs that contain the Java Persistence API (JPA) and entities to the project’s Java Build Path. - - - - - Use these fields to create the persistence.xml file. Select the persistence version, the name of the JPA provider, and a unique name to identify the persistence unit. - - - - - Use this page to select which script options will be included in the generated script. - - - - - Use this page to select which elements will be included in the generated script. - - - - - Use this page to select the filename and location of the generated script. You can also preview the script and specify to run or continue editing the script after generation. - - - - - This page shows the settings that you selected for the generated DDL. To change any option click "Back" or click "Finish" to continue. - - - - The name of the table sequence generator. This name is global to to the persistence unit (across all generator types). - - - - - The database table that stores the generated ID values. - - - - - The database column of the generator table that stores the generated ID values. - - - - - The name for the column that stores the generated ID values. - - - - - The database column of the generator table that defines the primary key value. - - - - - Use to connect (log in) to a database connection to use with your Java persistent entities. - You must have a defined database connection (and be connected) to add persistence. - - - - Specify if the mapped field contains a Date (java.sql.Date), Time (java.sql.Time), or Timestamp (java.sql.Timestamp) value. - - - - - Define how the primary key is generated - - - - - - Specify to use a specific database table for generating the primary key. - - - - - - Specify to use a specific sequence for generating the primary key. - - - - - - Name of the sequence. - - - - - - - - - - - - Specify if the field is mapped to java.sql.Clob or java.sql.Blob. - - - - - - Specify how to persist enumerated constraints if the String value suits your application requirements or to match an existing database schema. - - - - - - . - - - - The database catalog that contains the Table. This field overrides the defaults in the orm.xml file. - - - - - - The database schema that contains the Table. This field overrides the defaults in the orm.xml file. - - - - - - The Java package that contains the persistent entities to which the orm.xml file applies. - - - - - The database schema to use as the default for all entities managed by this persistence unit. - - - - - The database catalog to use as the default for all entities managed by this persistence unit. - - - - - The default access method for variables in this project: Property or Field. - - - - - Adds cascade-persist to the set of cascade options in entity relationships of the persistence unit. - - - - - Specifies that the Java classes in this persistence unit are fully specified by their metadata. Any annotations will be ignored. - - - - - Specify the vendor-specific JPA implementation.Default is Generic.. - - - - Create an initial orm.xml file. Use this file to specify project and persistence unit defaults. - - - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/dcommon/css/blafdoc.css b/jpa/plugins/org.eclipse.jpt.doc.user/dcommon/css/blafdoc.css deleted file mode 100644 index 4fa017b8b0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/dcommon/css/blafdoc.css +++ /dev/null @@ -1,21 +0,0 @@ -@import "../../../PRODUCT_PLUGIN/book.css"; - -span.control, span.gui-object-action, p.subhead2, span.bold, p.notep1 { - font-weight: bold; -} - -span.name, p.titleinfigure, span.italic { - font-style: italic; -} - -p.titleinfigure, p.subhead2 { - padding-top: 10px; -} - -span.code { - font-family: monospace; -} - -span.copyrightlogo {font-size: 75%} - -.footer {padding-top: 2em;} \ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/dcommon/html/cpyr.htm b/jpa/plugins/org.eclipse.jpt.doc.user/dcommon/html/cpyr.htm deleted file mode 100644 index fe52e9587f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/dcommon/html/cpyr.htm +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - -

License Information

- - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started.htm deleted file mode 100644 index 658022b0e9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started.htm +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - -Getting started - - - - - - - - - - - - - - -

- - - - -
-

Getting started

-
-

This section provides information on getting started with the Java Persistence Tools.

- -

For additional information, please visit the Dali home page at: http://www.eclipse.org/webtools/dali/main.php/.

- - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started001.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started001.htm deleted file mode 100644 index e17ea9100a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started001.htm +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - -Requirements and installation - - - - - - - - - - - - - - -

-
- - - - -
-

Requirements and installation

-
-

Before installing Dali, ensure that your environment meets the following minimum requirements:

- -
-https://glassfish.dev.java.net/downloads/persistence/JavaPersistence.html
-
-
-

Refer to http://www.eclipse.org/webtools/dali/gettingstarted_main.html for additional installation information.

-

Review the Dali quick start and Dali basic tutorial to build your first Dali project.

-
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started002.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started002.htm deleted file mode 100644 index 52f4e25f3d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started002.htm +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - -Dali quick start - - - - - - - - - - - - - - -

-
- - - - -
-

Dali quick start

-
-

This section includes information to help you quickly start using Dali to create relational mappings between Java persistent entities and database tables.

- -

The Dali basic tutorial contains detailed procedures for building you first Dali project.

-Related reference
-
-Dali basic tutorial
-Tips and tricks
-What's new - -
- - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started003.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started003.htm deleted file mode 100644 index dc0cbed0fc..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started003.htm +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - -Creating a new project - - - - - - - - - - - - - - -

-
- - - - -
-

Creating a new project

-
-

This quick start shows how to create a new JPA project.

-
    -
  1. -

    Select File > New > Project. The New Project dialog appears.

    -
  2. -
  3. -

    On the New Project dialog, select JPA > JPA Project and click Next. The Create a Java Project dialog appears.

    -
    -

    New JPA Project

    -New JPA Project dialog.
    -
  4. -
  5. -

    On the Create a JPA Project dialog, enter a Project name (such as QuickStart).

    -
  6. -
  7. -

    Select your Target Runtime (such as Apache Tomcat) and click Next. The Project Facets dialog appears.

    -
  8. -
  9. -

    Verify that the Java Persistence 1.0 facet is selected and click Next. The JPA Facet dialog appears.

    -
    -

    - - - - - - -
    -

    Note:

    -You must configure your project to use Java version 5.0 (or higher). See "Requirements and installation" for more information.
    -
    -
    -
  10. -
  11. -

    On the JPA Facet dialog, select your vendor-specific JPA platform, database connection (or create a new connection), JPA implementation library (such as TopLink Essentials), define how Dali should manage persistent classes, and click Finish.

    -
    -

    JPA Facet Dialog

    -JPA Facet dialog.
    -
  12. -
-

Eclipse adds the project to the workbench and opens the JPA perspective.

-
-

Project in Package Explorer

-Package Explorer showing the JPA project.
- -

Now that you have created a project with persistence, you can continue with Creating a Java persistent entity.

-
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started004.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started004.htm deleted file mode 100644 index 8bc6b26b3e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started004.htm +++ /dev/null @@ -1,111 +0,0 @@ - - - - - - -Creating a Java persistent entity - - - - - - - - - - - - - - -

-
- - - - -
-

Creating a Java persistent entity

-
-

This quick start shows how to create a new persistent Java entity. We will create an entity to associate with a database table. You will also need to add the ADDRESS table to your database.

-
    -
  1. -

    Right-click the project in the Package Explorer and select New > Class. The New Java Class page appears.

    -
  2. -
  3. -

    On the Java Class page, enter a package name (such as quickstart.demo.model), class name (such as Address), and click Finish.

    -
  4. -
  5. -

    Right-click the Address.java file in the Package Explorer and select Open.

    -
    -

    Open Address.java

    -Opening a Java class.
    -
  6. -
  7. -

    Select the Address entity in the JPA Structure view.

    -
    -

    Address Class in JPA Structure View

    -Address class in JPA Structure view.
    -
  8. -
  9. -

    In the JPA Details view, in the Map As field, select Entity. In the Table field, select the ADDRESS database table.

    -
    -

    Address Entity in JPA Details View

    -JPA Details view.
    -
  10. -
-

Eclipse creates the persistent entity and adds the @Entity annotation to the class.

-
-

Address Entity

-Java editor with the Address entity.
- -

Eclipse also displays the Address entity in the JPA Structure view:

-
-

Address Entity

-Address entity in the JPA Structure view.
- -

After creating the entity, you must associate it with a database table.

-
    -
  1. -

    Select the Address class in the Explorer view.

    -
  2. -
  3. -

    In the Persistence Properties view, notice that Dali has automatically associated the ADDRESS database table with the entity because they are named identically.

    -
    -

    - - - - - - -
    -

    Note:

    -Depending on your database connection type, you may need to specify the Schema.
    -
    -
    -
    -

    JPA Details View for Address Entity

    -Address entity in the JPA Details view.
    -
  4. -
-

After associating the entity with the database table, you must update the persistence.xml file to include this JPA entity.

-

Right-click the persistence.xml file in the Package Explorer and select JPA Tools > Synchronize Classes. Dali adds the following to the persistence.xml file:

-

<class>quickstart.demo.model.Address</class>

-

 

-

Now that you have created a persistent entity, you can continue with Mapping an entity to map the entity's fields to columns on the database table.

-
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started005.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started005.htm deleted file mode 100644 index 53017e7f28..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started005.htm +++ /dev/null @@ -1,140 +0,0 @@ - - - - - - -Mapping an entity - - - - - - - - - - - - - - -

-
- - - - -
-

Mapping an entity

-
-

This quick start shows how to map fields in a Java persistent entity. Before beginning, add the following fields to the Address class:

-
-private Long id;
-private String city;
-private String country;
-private String stateOrProvince;
-private String postalCode;
-private String street;
-
-
-

Eclipse updates the Address entity in the JPA Structure view to show its fields:

-
-

Address Entity and Fields

-Address entity and its fields in the JPA Structure view.
- -

You will also need to add the following columns to the ADDRESS database table:

-
-NUMBER(10,0) ADDRESS_ID (primary key)
-VARCHAR2(80) PROVINCE
-VARCHAR2(80) COUNTRY
-VARCHAR2(20) P_CODE
-VARCHAR2(80) STREET
-VARCHAR2(80) CITY
-
-
-
-

Now we are ready to map each fields in the Address class to a column in the database table.

-
    -
  1. -

    Select the id field in the JPA Details view.

    -
  2. -
  3. -

    In the JPA Details view:

    -
      -
    • -

      For the Map As field, select Id

      -
    • -
    • -

      For the Column field, select ADDRESS_ID.

      -
    • -
    -
    -

    JPA Details View for addressId Field

    -JPA Details view for the id field.
    - -

    Eclipse adds the following annotations to the Address entity:

    -
    -@Id
    -@Column(name="ADDRESS_ID")
    -
    -
  4. -
  5. -

    Map each of the following fields (as Basic mappings) to the appropriate database column:

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    FieldMap AsDatabase Column
    cityBasicCITY
    countryBasicCOUNTRY
    postalCodeBasicP_CODE
    provinceOrStateBasicPROVINCE
    streetBasicSTREET
    -
    -
  6. -
-

Notice that Dali will automatically map some fields to the correct database column (such as the city field to the CITY column) if the names are identical.

-

Refer to the Dali basic tutorial to map a complete object model using basic and relational mappings.

-
- - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started006.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started006.htm deleted file mode 100644 index 2dde4a28a3..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started006.htm +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - -Dali basic tutorial - - - - - - - - - - - - - - -

-
- - - - -
-

Dali basic tutorial

-
-

In this tutorial, you will use Dali to map the object model of a company's HR application to track its employees. Figure: Tutorial Object Model illustrates the object model for the tutorial.

-
-

Tutorial Object Model

-This figure shows the object model for the tutorial.
- -

Next, you will Generate the tutorial database schema.

- - -
- - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started007.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started007.htm deleted file mode 100644 index 654b0c9b83..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started007.htm +++ /dev/null @@ -1,215 +0,0 @@ - - - - - - -Generate the tutorial database schema - - - - - - - - - - - - - - -

-
- - - - -
-

Generate the tutorial database schema

-
-

The tutorial application uses three database tables to store each employee's information: EMPLOYEE, ADDRESS and PHONE. Table: Tutorial Database Schema describes the columns for each table.

-

You can download SQL scripts to build and populate the database tables with sample data from http://www.eclipse.org/webtools/dali/docs/dbscripts.zip.

-
-

Tutorial Database Schema

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TableColumnTypeDetails
-

EMPLOYEE

-
-

EMP_ID

-
-

NUMBER(15)

-
-

Primary Key

-
-

F_NAME

-
-

VARCHAR(40)

-

-

L_NAME

-
-

VARCHAR(40)

-

-

ADDR_ID

-
-

NUMBER(15)

-
-

Foreign Key, references ADDRESS.ADDRES_ID

-
-

VERSION

-
-

NUMBER(15)

-

-

ADDRESS

-
-

ADDRESS_ID

-
-

NUMBER(15)

-
-

Primary Key

-
-

PROVINCE

-
-

VARCHAR(80)

-

-

COUNTRY

-
-

VARCHAR(80)

-

-

STREET

-
-

VARCHAR(80)

-

-

P_CODE

-
-

VARCHAR(20)

-

-

CITY

-
-

VARCHAR(80)

-

-

PHONE

-
-

EMP_ID

-
-

NUMBER(15)

-
-

Foreign Key, reference to EMPLOYEE.EMP_ID

-
-

AREA_CODE

-
-

VARCHAR(3)

-

-

P_NUMBER

-
-

VARCHAR(7)

-
-

Primary key

-
-

TYPE

-
-

VARCHAR(15)

-

-
- -

Next, you will Create a database connection.

- - -
- - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started008.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started008.htm deleted file mode 100644 index e277fed35d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started008.htm +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - -Create a database connection - - - - - - - - - - - - - - -

-
- - - - -
-

Create a database connection

-
-

After creating the database you will need to create a database connection to use with the tutorial application. An active database connection is required to complete tutorial application.

-

Use the New Connection wizard to create a database connection.

-
-

Database Explorer

-This figure shows the Database Explorer.
- -

Now you're ready to Create a JPA project.

-
- - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started009.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started009.htm deleted file mode 100644 index fed0cfa4cf..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started009.htm +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - -Create a JPA project - - - - - - - - - - - - - - -

-
- - - - -
-

Create a JPA project

-
-

In order to begin, you must create a new Java project.

-
    -
  1. -

    Select File > New > Project. The New Project dialog appears.

    -
  2. -
  3. -

    On the New Project dialog, select JPA > JPA Project and click OK. The New JPA Project dialog appears.

    -
  4. -
  5. -

    On the New JPA Project dialog, enter Employee as the Project name and click Next. The Project Facets page appears.

    -
  6. -
  7. -

    Verify that you have selected a Java 5.0 (or higher) and JPA 1.0 facet, and click Next. The JPA Facet page appears.

    -
  8. -
  9. -

    Select your vender-specific platform, database connection, and JPA implementation library, and click Finish.

    -
  10. -
-

Eclipse adds the project to the workbench and opens the Java perspective.

-
-

Persistence Perspective

-This figure shows the main parts of the JPA Development Perspective: The JPA Structure and JPA Details views.
- -

The next step is to Create persistent Java entities.

-
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started010.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started010.htm deleted file mode 100644 index 69ec202bed..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started010.htm +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - -Create persistent Java entities - - - - - - - - - - - - - - -

-
- - - - -
-

Create persistent Java entities

-
-

The Tutorial Object Model contains three entities: Employee, Address, and PhoneNumber. Use this procedure to add the entities to the project.

-
    -
  1. -

    Right-click the Employee project in the Package Explorer and select New > Class. The New Java Class dialog appears.

    -
  2. -
  3. -

    On the Java Class dialog, enter a package name (such as dali.tutorial.model), class name (such as Employee), and click Finish. Eclipse adds the Employee entity to the Package Explorer.

    -
  4. -
  5. -

    Select the Employee entity in the JPA Structure view.

    -
  6. -
  7. -

    In the JPA Details view, in the Map As field, select Entity. In the Table field, select the EMPLOYEE database table.

    -
    -

    Employee Entity in JPA Details View

    -Employee entity in JPA Details view.
    -
  8. -
-

Eclipse adds the @Entity annotation to the class. Repeat this procedure to add the PhoneNumber and Address entities.

-

Notice that the Problems view reports several errors for each entity. We'll address these shortly.

-

Next, you will Add fields to the entities.

- - -
- - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started011.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started011.htm deleted file mode 100644 index 0cd45a966f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started011.htm +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - -Add fields to the entities - - - - - - - - - - - - - - -

-
- - - - -
-

Add fields to the entities

-
-

Before mapping the entities to the database, you must add the necessary fields to each entity.

-
    -
  1. -

    Add the following fields to the Employee entity:

    -
    -private Long id;
    -private String firstNname;
    -private String lastName;
    -private String address;
    -private List<PhoneNumber> phoneNumbers;
    -private Long version;
    -
    -
  2. -
  3. -

    Import java.util.List.

    -
  4. -
  5. -

    Generate Getters and Setters for each field.

    -
  6. -
  7. -

    Add the following fields to the Address entity:

    -
    -private Long id;
    -private String street;
    -private String city;
    -private String stateOrProvince;
    -private String country;
    -private String postalCode;
    -
    -
  8. -
  9. -

    Add the following fields to the PhoneNumber entity:

    -
    -private String type;
    -private String areaCode;
    -private String number;
    -private Employee owner;
    -
    -
  10. -
-

Next, you will Associate the entity with a database table.

-
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started012.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started012.htm deleted file mode 100644 index 5f6950e564..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started012.htm +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - -Associate the entity with a database table - - - - - - - - - - - - - - -

-
- - - - -
-

Associate the entity with a database table

-
-

Now you must associate each entity with its primary database table.

-
    -
  1. -

    Select the Employee class in the Explorer view.

    -
  2. -
  3. -

    In the JPA Details view, notice that Dali has automatically selected the EMPLOYEE table as the table name.

    -
    -

    JPA Details View for the Employee Entity

    -JPA Details view for the Employee entity.
    -
  4. -
-

By default, Dali attempts to associate each entity with a similarly named database table. Notice that although you have not explicitly associated the Address entity yet, there is no error in the Problems view because the entity name, Address, is identical to the table name (ADDRESS).

-

For the PhoneNumber entity, however, there is an error. This is because the entity name (PhoneNumber) is different than the database table (PHONE). You must explicitly associate the entity with the PHONE table. Dali adds the @Table(name="PHONE") annotation to the entity.

-

Now you are ready to Create OR mappings.

-
- - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started013.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started013.htm deleted file mode 100644 index d1928e6894..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started013.htm +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - -Create OR mappings - - - - - - - - - - - - - - -

-
- - - - -
-

Create OR mappings

-
-

Now you're ready to map the attributes of each persistent entity to columns in the appropriate database table. For the tutorial application, you will use the following mapping types:

-
    -
  • -

    ID mappings

    -
  • -
  • -

    Basic mappings

    -
  • -
  • -

    One-to-one mappings

    -
  • -
  • -

    Many-to-one mappings

    -
  • -
  • -

    One-to-many mappings

    -
  • -
  • -

    Version mappings

    -
  • -
-

Next, you will Create ID mappings.

- - -
- - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started014.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started014.htm deleted file mode 100644 index a4cda760ef..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started014.htm +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - -Create ID mappings - - - - - - - - - - - - - - -

-
- - - - -
-

Create ID mappings

-
-

Use an ID Mapping to specify the primary key of an entity. Each persistent entity must have an ID. Notice that the Problems view reports that each entity is missing an ID.

-
    -
  1. -

    Select the Employee entity in the Package Explorer view.

    -
  2. -
  3. -

    Expand the Employee entity in the JPA Structure view and select the id field. The JPA Details view (for attributes) displays the properties for the field.

    -
  4. -
  5. -

    In the Map As field, select ID.

    -
    -

    ID Mapping for emp_id Field

    -JPA Details view for the emp_id field.
    -
  6. -
  7. -

    Use this table to complete the remaining fields in the JPA Details view.

    -
    - - - - - - - - - - - - - - - - - -
    PropertyDescription
    Map AsDefines this mapping as an ID Mapping. Dali adds the @Id annotation to the entity.
    ColumnThe database column for the primary key of the table associated with the entity. Select EMP_ID. -

    Because the database column (EMP_ID) is named differently than the entity field (id), Dali adds the @Column(name="EMP_ID") annotation.

    -
    -
    -
  8. -
  9. -

    Leave all other fields on the tab as their defaults. Expand the Primary Key Generation area.

    -
    -

    Primary Key Generation for emp_id Field

    -JPA Details view (with Primary Key options) for the emp_id field.
    -
  10. -
  11. -

    Use this table to complete the Primary Key Generation fields in the JPA Details view.

    -
    - - - - - - - - - - - - - - - - - - - - - -
    PropertyDescription
    Generated ValueThese fields define how the primary key is generated.
      StrategyFor the tutorial project, use the Auto option.
      Generator NameLeave this field blank.
    -
    -
  12. -
-

In the JPA Structure view, the id field is identified as the primary key by the following icon:

-
-

JPA Structure for Employee Entity

-emp_id attribute of the Employee entity in the JPA Structure view.
- -

Repeat this procedure to map the following primary keys (as shown in Table: Tutorial Database Schema):

-
    -
  • -

    The id field of the Address entity to the ADDRESS_ID column of the ADDRESS table.

    -
  • -
  • -

    The number field of the PhoneNumber entity to the P_NUMBER column of the PHONE table.

    -
  • -
-

Next, you will Create basic mappings.

-
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started015.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started015.htm deleted file mode 100644 index 3d5ff04ea4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started015.htm +++ /dev/null @@ -1,133 +0,0 @@ - - - - - - -Create basic mappings - - - - - - - - - - - - - - -

-
- - - - -
-

Create basic mappings

-
-

Use a Basic Mapping to map an attribute directly to a database column. In the Tutorial Object Model, the firstName field of the Employee class maps directly to the F_NAME column of the EMPLOYEE database table.

-
    -
  1. -

    Select the Employee entity in the Package Explorer view.

    -
  2. -
  3. -

    In the JPA Structure view, select the firstName field of the Employee entity. The JPA Details view (for attributes) displays the properties for the field.

    -
  4. -
  5. -

    In the Map As field, select Basic. In the Column field, select F_NAME.

    -
    -

    Basic Mapping for firstName

    -JPA Details view for the firstName field.
    -
  6. -
-

Dali adds the @Column(name="F_NAME") annotation to the entity. In the JPA Structure, the firstName field is identified as a basic mapping as shown in the following figure:

-
-

JPA Structure for Employee Entity

-The firstName attribute of the Employee entity in the JPA Structure view.
- -

Repeat this procedure to map each of the following fields as Basic mappings:

-
    -
  • -

    Employee entity

    -
      -
    • -

      lastName field to L_NAME column

      -
    • -
    -
  • -
  • -

    Address Entity

    -
      -
    • -

      city field to CITY column

      -
    • -
    • -

      country field to COUNTRY column

      -
    • -
    • -

      postalCode field to P_CODE column

      -
    • -
    • -

      stateOrProvice field to PROVINCE column

      -
    • -
    • -

      street field to STREET column

      -
    • -
    -
    -

    - - - - - - -
    -

    Note:

    -Because the city, country, and street fields are named identically to their database columns, Dali automatically maps the fields; no annotations are required.
    -
    -
    -
  • -
  • -

    Phone Entity

    -
      -
    • -

      areaCode field to AREA_CODE column

      -
    • -
    • -

      type field to TYPE column

      -
    • -
    -
    -

    - - - - - - -
    -

    Note:

    -Because the type field is named identically to its database column, Dali automatically maps the field. No annotation is required.
    -
    -
    -
  • -
-

Next, you will Create one-to-one mappings.

-
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started016.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started016.htm deleted file mode 100644 index e57c4f5a0e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started016.htm +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - -Create one-to-one mappings - - - - - - - - - - - - - - -

-
- - - - -
-

Create one-to-one mappings

-
-

Use a One-to-One Mapping to define a relationship from an attribute to another class, with one-to-one multiplicity to a database column. In the Tutorial Object Model, the address field of the Employee class has a one-to-one relationship to the Address class; each employee may have a single address.

-
    -
  1. -

    Select the Employee entity in the Package Explorer view.

    -
  2. -
  3. -

    In the JPA Structure view, select the address field of the Employee entity. The JPA Details view (for attributes) displays the properties for the field.

    -
  4. -
  5. -

    In the Map As field, select One-to-One.

    -
    -

    One-to-one Mapping for address

    -JPA Details view for the address field.
    -
  6. -
  7. -

    For the Target Entity, click Browse and select the Address persistent entity. Dali adds the @OneToOne(targetEntity=dali.tutorial.model.Address.class) entity to the class.

    -

    Leave the other fields with their default values.

    -
  8. -
  9. -

    Select the Override Default option to specify the relationship between the Employee and Address entities. Because you had to explicitly define the ID field for the Address entity in its ID mapping, you will need to edit the default join relationship.

    -
  10. -
  11. -

    Select the address_ADDRESS_ID -> ADDRESS_ID relationship in the Join Columns area and click Edit.

    -
  12. -
  13. -

    In the Edit Join Column dialog, select the following options and click OK.

    -
      -
    • -

      Name: ADDR_ID (from the EMPLOYEE table)

      -
    • -
    • -

      Referenced Column Name: ADDRESS_ID (from the ADDRESS table)

      -
    • -
    -
    -

    Editing Join Column for Address Mapping

    -Edit Join Column dialog for the address 1:1 mapping.
    -
  14. -
-

In the JPA Structure, the address field is identified as a one-to-one mapping, as shown in the following figure:

-
-

JPA Structure for Employee Entity

-The address attribute of the Employee entity in the JPA Structure view.
- -

Next, you will Create one-to-many mappings.

-
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started017.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started017.htm deleted file mode 100644 index 3b69b34c4f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started017.htm +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - -Create one-to-many mappings - - - - - - - - - - - - - - -

-
- - - - -
-

Create one-to-many mappings

-
-

Use a One-to-Many Mapping to define a relationship from an attribute to another class, with one-to-many multiplicity to a database column. In the Tutorial Object Model, the phoneNumbers field of the Employee class has a one-to-many relationship to the Phone class; each employee may have many phone numbers.

-
    -
  1. -

    Select the Employee entity in the Package Explorer view.

    -
  2. -
  3. -

    In the JPA Structure view, select the phoneNumber field of the Employee entity. The JPA Details view (for attributes) displays the properties for the field.

    -
  4. -
  5. -

    In the Map As field, select One-to-Many.

    -
    -

    One-to-many Mapping for phoneNumbers

    -JPA Details view for the phoneNumbers field.
    -
  6. -
  7. -

    Select PhoneNumber as the Target Entity. Leave the other fields with their default values.

    -
  8. -
  9. -

    In the Join Table area, notice that Dali has selected the correct joins, based on the foreign key associations in the database tables.

    -
  10. -
-

In the JPA Structure, the phoneNumbers field is identified as a one-to-many mapping as shown in the following figure:

-
-

JPA Structure for Employee Entity

-The phoneNumbers attribute of the Employee entity in the JPA Structure view.
- -

Next, you will Create many-to-one mappings.

-
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started018.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started018.htm deleted file mode 100644 index 2798be877b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started018.htm +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - -Create many-to-one mappings - - - - - - - - - - - - - - -

-
- - - - -
-

Create many-to-one mappings

-
-

Use a May-to-One Mapping to define a relationship from an attribute to another class, with many-to-one multiplicity to a database column. In the Tutorial Object Model, the owner field of the PhoneNumber class has a one-to-many relationship to the Employee class; there are many phone numbers that each employee may have.

-

This is the "back mapping" of the one-to-many mapping you previously defined.

-
    -
  1. -

    Select the PhoneNumber entity in the Package Explorer view.

    -
  2. -
  3. -

    In the JPA Structure view, select the owner field of the PhoneNumber entity. The JPA Details view (for attributes) displays the properties for the field.

    -
  4. -
  5. -

    In the Map As field, select Many to One.

    -
    -

    Many to One Mapping for owner

    -The JPA Details view for the owner field.
    -
  6. -
  7. -

    Leave the other fields with their default values. Dali correctly completes the information based on the database structure and previously defined mappings.

    -
  8. -
  9. -

    Use the Join Columns area to specify the relationship between the PhoneNumber and Employee entities. Because you had to explicitly define the ID field for the Employee entity in its ID mapping, you will need to edit the default join relationship.

    -
  10. -
  11. -

    Select the Override Default option.

    -
  12. -
  13. -

    Select the owner_EMP_ID -> EMP_ID relationship in the Join Columns area and click Edit.

    -
  14. -
  15. -

    In the Edit Join Column dialog, select the following options and click OK.

    -
      -
    • -

      Name: EMP_ID (from the PHONE table)

      -
    • -
    • -

      Referenced Column Name: EMP_ID (from the EMPLOYEE table)

      -
    • -
    -
  16. -
-

In the JPA Structure, the owner field is identified as a many-to-one mapping as shown in the following figure:

-
-

JPA Structure for PhoneNumber Entity

-The owner attribute of the PhoneNumber entity in the JPA Structure view.
- -

Next, you will Create version mappings

-
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started019.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started019.htm deleted file mode 100644 index 3b8c883853..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started019.htm +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - -Create version mappings - - - - - - - - - - - - - - -

-
- - - - -
-

Create version mappings

-
-

Use a Version Mapping to specify the database field used by a persistent entity for optimistic locking.

-
    -
  1. -

    Select the Employee entity in the Package Explorer view.

    -
  2. -
  3. -

    In the JPA Structure view, select the version field of the Employee entity. The JPA Details view (for attributes) displays the properties for the field.

    -
  4. -
  5. -

    In the Map As field, select Version.

    -
    -

    Version Mapping for version

    -JPA Details view for the version field.
    -
  6. -
-

Dali automatically selects the Version column in the EMPLOYEE database table. In the JPA Structure, the Version field is identified as a version mapping, as shown in the following figure:

-
-

JPA Structure for Employee Entity

-The version attribute of the Employee entity in the JPA Structure view.
- -

Congratulations! All of the entities have been successfully mapped.

-
- - - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/address_java_open.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/address_java_open.png deleted file mode 100644 index 7da0417133..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/address_java_open.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/address_jpa_details.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/address_jpa_details.png deleted file mode 100644 index f96cc3f8b8..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/address_jpa_details.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/address_jpa_structure.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/address_jpa_structure.png deleted file mode 100644 index a18a65652c..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/address_jpa_structure.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/button_jpa_perspective.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/button_jpa_perspective.png deleted file mode 100644 index e0a957185e..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/button_jpa_perspective.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/database_explorer.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/database_explorer.png deleted file mode 100644 index 435be3dcc1..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/database_explorer.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/details_entitymappings.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/details_entitymappings.png deleted file mode 100644 index 5bd48850fd..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/details_entitymappings.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/edit_join_column_dialog.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/edit_join_column_dialog.png deleted file mode 100644 index 9cc32cf47c..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/edit_join_column_dialog.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/error_sample.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/error_sample.png deleted file mode 100644 index 3a4964632c..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/error_sample.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/generate_entities.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/generate_entities.png deleted file mode 100644 index e3cb22b69a..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/generate_entities.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_11mapping.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_11mapping.png deleted file mode 100644 index 6944826370..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_11mapping.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_1mmapping.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_1mmapping.png deleted file mode 100644 index 69d3193a5e..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_1mmapping.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_basicmapping.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_basicmapping.png deleted file mode 100644 index b193753e98..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_basicmapping.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddable.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddable.png deleted file mode 100644 index 645922c306..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddable.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddedidmapping.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddedidmapping.png deleted file mode 100644 index 0587544e2d..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddedidmapping.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddedmapping.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddedmapping.png deleted file mode 100644 index 4bef3567ed..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_embeddedmapping.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_idmapping.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_idmapping.png deleted file mode 100644 index 2b2a94becd..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_idmapping.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_m1mapping.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_m1mapping.png deleted file mode 100644 index a77a01ba6d..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_m1mapping.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_mmmapping.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_mmmapping.png deleted file mode 100644 index 5d5fd1c145..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_mmmapping.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_nonpersistent.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_nonpersistent.png deleted file mode 100644 index 001ef86ee2..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_nonpersistent.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_persistent.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_persistent.png deleted file mode 100644 index 7ea0b1d53e..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_persistent.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_superclass.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_superclass.png deleted file mode 100644 index 952f11d131..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_superclass.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_transientmapping.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_transientmapping.png deleted file mode 100644 index 1a70dd9e68..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_transientmapping.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_versionmapping.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_versionmapping.png deleted file mode 100644 index aa7e0a6f15..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/icon_versionmapping.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_join.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_join.png deleted file mode 100644 index 22b6875f4d..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_join.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_single.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_single.png deleted file mode 100644 index 3146482609..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_single.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_tab.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_tab.png deleted file mode 100644 index a9d721fcc4..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/inheritance_tab.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/java_editor_address.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/java_editor_address.png deleted file mode 100644 index ff7eaa63b0..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/java_editor_address.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/jpa_details_employee.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/jpa_details_employee.png deleted file mode 100644 index d2c21ce726..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/jpa_details_employee.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/jpa_facet_dialog.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/jpa_facet_dialog.png deleted file mode 100644 index 18c294c06b..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/jpa_facet_dialog.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/new_jpa_project_dialog.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/new_jpa_project_dialog.png deleted file mode 100644 index 0fb14b17e1..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/new_jpa_project_dialog.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/new_project_2.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/new_project_2.png deleted file mode 100644 index ad3ab04aa9..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/new_project_2.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelc.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelc.png deleted file mode 100644 index 88381a5a80..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelc.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelr.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelr.png deleted file mode 100644 index 4bbc744806..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelr.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelt.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelt.png deleted file mode 100644 index 60af21f5ea..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/ngrelt.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/open_persistence_editor.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/open_persistence_editor.png deleted file mode 100644 index 56911fe5a5..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/open_persistence_editor.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_address.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_address.png deleted file mode 100644 index bd9351ce90..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_address.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_empid.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_empid.png deleted file mode 100644 index 90d889fb4f..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_empid.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_entity.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_entity.png deleted file mode 100644 index bbcbb52d28..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_entity.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_fields.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_fields.png deleted file mode 100644 index 5a41682f77..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_fields.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_fname.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_fname.png deleted file mode 100644 index 3b8b032dc2..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_fname.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_owner.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_owner.png deleted file mode 100644 index f24fe486b9..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_owner.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_phone.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_phone.png deleted file mode 100644 index 25aca17350..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_phone.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_version.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_version.png deleted file mode 100644 index 4ba483ed2a..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_version.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_view.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_view.png deleted file mode 100644 index 769aa825e5..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_outline_view.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_perspective.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_perspective.png deleted file mode 100644 index f92ea6422b..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_perspective.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_address.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_address.png deleted file mode 100644 index c186d3fef6..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_address.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_addressid.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_addressid.png deleted file mode 100644 index a7e71ad7ca..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_addressid.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_embedded.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_embedded.png deleted file mode 100644 index 91affa5e47..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_embedded.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_empid.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_empid.png deleted file mode 100644 index 9c2811abd5..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_empid.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_empid_pk.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_empid_pk.png deleted file mode 100644 index 46fcc69d4f..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_empid_pk.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_employee.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_employee.png deleted file mode 100644 index 01337ffab0..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_employee.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_entity.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_entity.png deleted file mode 100644 index 0a7685ae3f..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_entity.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_firstname.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_firstname.png deleted file mode 100644 index 67670ff6f0..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_firstname.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_manytoone.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_manytoone.png deleted file mode 100644 index c9f02200b9..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_manytoone.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_mappedsprc.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_mappedsprc.png deleted file mode 100644 index ceb79d9623..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_mappedsprc.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_onetomany.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_onetomany.png deleted file mode 100644 index 148c735293..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_onetomany.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_onetoone.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_onetoone.png deleted file mode 100644 index 3e2b739dcd..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_onetoone.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_version.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_version.png deleted file mode 100644 index fea937d9b6..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_view_version.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_xml_editor.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_xml_editor.png deleted file mode 100644 index b14dc15936..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/persistence_xml_editor.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/properties_persistence.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/properties_persistence.png deleted file mode 100644 index fcc9886484..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/properties_persistence.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/quickstart_project.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/quickstart_project.png deleted file mode 100644 index c7c066427e..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/quickstart_project.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/secondary_tables.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/secondary_tables.png deleted file mode 100644 index e6a9159fd8..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/secondary_tables.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/synchornize_classes.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/synchornize_classes.png deleted file mode 100644 index bede63b968..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/synchornize_classes.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/table_entity.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/table_entity.png deleted file mode 100644 index 1aa1dbe059..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/table_entity.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/img/tutorial_object_model.png b/jpa/plugins/org.eclipse.jpt.doc.user/img/tutorial_object_model.png deleted file mode 100644 index eb25d7d6fb..0000000000 Binary files a/jpa/plugins/org.eclipse.jpt.doc.user/img/tutorial_object_model.png and /dev/null differ diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/index.xml b/jpa/plugins/org.eclipse.jpt.doc.user/index.xml deleted file mode 100644 index 60f79a5d52..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/index.xml +++ /dev/null @@ -1,546 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/legal.htm b/jpa/plugins/org.eclipse.jpt.doc.user/legal.htm deleted file mode 100644 index 12d8b69f02..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/legal.htm +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - -Legal - - - - - - - - - - - - - - -

- - - - -
-

Legal

-
-

-

Notices

-

The material in this guide is copyright © 2006, 2007 by Oracle.

-

Terms and conditions regarding the use of this guide.

- - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/plugin.properties b/jpa/plugins/org.eclipse.jpt.doc.user/plugin.properties deleted file mode 100644 index 85654952f5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/plugin.properties +++ /dev/null @@ -1,24 +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 -############################################################################### -# ==================================================================== -# 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 = Java Persistence Documentation - Doc -providerName = Eclipse.org diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/plugin.xml b/jpa/plugins/org.eclipse.jpt.doc.user/plugin.xml deleted file mode 100644 index a267bbc742..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/plugin.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - This cheat sheet helps you create a JPA project. - - - This cheat sheet helps you create a Java persistent entity. - - - This cheat sheet helps you map the a Java persistent entity to a database table. - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/ref_details_orm.htm b/jpa/plugins/org.eclipse.jpt.doc.user/ref_details_orm.htm deleted file mode 100644 index 32768d4e3d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_details_orm.htm +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - -JPA Details view (for orm.xml) - - - - - - - - - - - - - - -

-
- - - - -
-

JPA Details view (for orm.xml)

-
-

The JPA Details view displays the default mapping and persistence information for the project and contains the following areas:

- -

These defaults can be overridden by the settings on a specific entity or mapping.

- - -
- - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/ref_jpa_facet.htm b/jpa/plugins/org.eclipse.jpt.doc.user/ref_jpa_facet.htm deleted file mode 100644 index bdfd5fd4c8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_jpa_facet.htm +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - -JPA Facet page - - - - - - - - - - - - - - -

-
- - - - -
-

JPA Facet page

-
-

This table lists the properties available on the JPA Facet page of the Create New JPA Project wizard.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyDescriptionDefault
PlatformVendor-specific JPA implementation.Generic
ConnectionSelect the database connection to use with the project. Dali requires an active database connection to use and validate the persistent entities and mappings. -

Click Add connection to create a new database connection.

-

JPA ImplementationSelect to use the JPA implementation provided by the server at runtime, or select a specific implementation library that contain the Java Persistence API (JPA) and entities to be added to the project's Java Build Path. -

Click Configure default JPA implementation library to create a default library for the project or click Configure user libraries to define additional libraries.

-
Determined by server.
Persistent class managementSpecify if Dali will discover annotated classes automatically, or if the annotated classes must be listed in the persistence.xml file. -

Note: To insure application portability, you should explicitly list the managed persistence classes that are included in the persistence unit.

-
Determined by server.
Create orm.xmlSpecify if Dali should create a default orm.xml file for your entity mappings and persistence unit defaults.Selected
-
-
- - - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/ref_mapping_general.htm b/jpa/plugins/org.eclipse.jpt.doc.user/ref_mapping_general.htm deleted file mode 100644 index 60bd0b3a2a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_mapping_general.htm +++ /dev/null @@ -1,213 +0,0 @@ - - - - - - -General information - - - - - - - - - - - - - - -

-
- - - - -
-

General information

-
-

This table lists the General properties available in the Java Details view for each mapping type.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyDescriptionDefaultAvailable for Mapping Type
Map AsDefine the mapping type for the attributeBasicAll mapping types
ColumnThe database column that contains the value for the attribute. This field corresponds to the @Column annotation.By default, the Column is assumed to be named identically to the attribute.Basic mapping, Embedded mapping, ID mapping, Version mapping
  NameName of the database column. -

This field corresponds to the @Column annotation.

-

Basic mapping, Embedded mapping, ID mapping
  TableName of the database table that contains the selected column.
Basic mapping, Embedded mapping, ID mapping
Fetch TypeDefines how data is loaded from the database: -
    -
  • -

    Eager - Data is loaded in before it is actually needed.

    -
  • -
  • -

    Lazy - Data is loaded only when required by the transaction.

    -
  • -
-
EagerBasic mapping, One-to-one mapping
OptionalSpecifies if this field is can be null.YesBasic mapping, One-to-one mapping
LobSpecify if the field is mapped to java.sql.Clob or java.sql.Blob. -

This field corresponds to the @Lob annotation.

-

Basic mapping
TemporalSpecifies if this field is one of the following: -
    -
  • -

    Date - java.sql.Date

    -
  • -
  • -

    Time - java.sql.Time

    -
  • -
  • -

    Timestamp - java.sql.Timestamp

    -
  • -
-

This field corresponds to the @Temporal annotation.

-

Basic mapping, ID mapping
EnumeratedSpecify how to persist enumerated constraints if the String value suits your application requirements or to match an existing database schema. -
    -
  • -

    ordinal

    -
  • -
  • -

    String

    -
  • -
-

This field corresponds to the @Enumerated annotation.

-
Ordinal
Target EntityThe persistent entity to which the attribute is mapped.
One-to-one mapping,, One-to-many mapping Many-to-many mapping, Many-to-one mapping
Cascade TypeSpecify which operations are propagated throughout the entity. -
    -
  • -

    All - All operations

    -
  • -
  • -

    Persist

    -
  • -
  • -

    Merge

    -
  • -
  • -

    Move

    -
  • -
-

One-to-one mapping
Mapped ByThe field in the database table that "owns" the relationship. This field is required only on the non-owning side of the relationship.
One-to-one mapping, One-to-many mapping
Order BySpecify the default order for objects returned from a query: -
    -
  • -

    No ordering

    -
  • -
  • -

    Primary key

    -
  • -
  • -

    Custom ordering

    -
  • -
-

This field corresponds to the @OrderBy annotation.

-
Primary keyOne-to-many mapping. Many-to-many mapping, Many-to-one mapping
Attribute OverridesOverrides Basic mappings of a mapped superclass. (For example, if the inherited column name is incompatible with a pre-existing data model, or invalid as a column name in your database).
Embedded mapping -

Embedded mapping

-
-
- -

 

-Related task
-
-Mapping an entity
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/ref_new_jpa_project.htm b/jpa/plugins/org.eclipse.jpt.doc.user/ref_new_jpa_project.htm deleted file mode 100644 index be37cfa4ff..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_new_jpa_project.htm +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - -New JPA Project page - - - - - - - - - - - - - - -

-
- - - - -
-

New JPA Project page

-
-

This table lists the properties available on the New JPA Project page of the Create New JPA Project wizard.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyDescriptionDefault
Project nameName of the Eclipse JPA project.
Project contentsLocation of the workspace in which to save the project. -

Unselect The Use Default option and click Browse to select a new location.

-
Current workspace
Target runtimeSelect a pre-defined target for the project. -

Click New to create a new environment with the New Server Runtime wizard.

-

ConfigurationsSelect a project configuration with pre-defined facets. -

Select <custom> to manually select the facets for this project.

-
Utility JPA project with Java 5.0
EAR membershipSpecify if this project should be included in an EAR file for deployment. -

Select the EAR Project Name, or click New to create a new EAR project.

-

-
-
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/ref_new_jpa_project_wizard.htm b/jpa/plugins/org.eclipse.jpt.doc.user/ref_new_jpa_project_wizard.htm deleted file mode 100644 index 4fcec9cde4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_new_jpa_project_wizard.htm +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - -Create New JPA Project wizard - - - - - - - - - - - - - - -

-
- - - - -
-

Create New JPA Project wizard

-
-

The Create New JPA Project wizard allows you to create a new Java project using JPA. The wizard consists of the following pages:

- - - -
- - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_map_view.htm b/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_map_view.htm deleted file mode 100644 index b93ae33148..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_map_view.htm +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - -JPA Details view (for attributes) - - - - - - - - - - - - - - -

-
- - - - -
-

JPA Details view (for attributes)

-
-

The JPA Details view displays the persistence information for the currently selected mapped attribute and contains the following areas:

- - - -
- - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_outline.htm b/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_outline.htm deleted file mode 100644 index 92cc34df6a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_outline.htm +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - -JPA Structure view - - - - - - - - - - - - - - -

-
- - - - -
-

JPA Structure view

-
-

The JPA Structure view displays an outline of the structure (its attributes and mappings) of the entity that is currently selected or opened in the editor. The structural elements shown in the outline are the entity and its fields.

-
-

Sample JPA Structure View

-Sample JPA Structure view for an entity.
- -

 

-Related reference
-
-JPA Development perspective -

 

-
- - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_perspective.htm b/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_perspective.htm deleted file mode 100644 index 1dbc7925ff..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_perspective.htm +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - -JPA Development perspective - - - - - - - - - - - - - - -

-
- - - - -
-

JPA Development perspective

-
-

The JPA Development perspective defines the initial set and layout of views in the Workbench window when using Dali. By default, the JPA Development perspective includes the following vies:

- -
-

Sample JPA Development Perspective

-JPA Development perspective with the JPA Structure and JPA Details views.
- -Related concept
-

Perspectives

-
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_prop_view.htm b/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_prop_view.htm deleted file mode 100644 index a6ea107ed4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_prop_view.htm +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - -JPA Details view (for entities) - - - - - - - - - - - - - - -

-
- - - - -
-

JPA Details view (for entities)

-
-

The JPA Details view displays the persistence information for the currently selected entity and contains the following tabs:

- - - -
- - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/ref_primary_key.htm b/jpa/plugins/org.eclipse.jpt.doc.user/ref_primary_key.htm deleted file mode 100644 index d5084e785e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_primary_key.htm +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - -Primary Key Generation information - - - - - - - - - - - - - - -

-
- - - - -
-

Primary Key Generation information

-
-

This table lists the fields available in the Primary Key Generation area in JPA Details view for ID mapping types.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyDescriptionDefault
Primary Key GenerationThese fields define how the primary key is generated. These fields correspond to the @GeneratedValue annotation.Generated Value
   Strategy -
    -
  • Auto
  • -
  • -

    Identity - Values are assigned by the database's Identity column.

    -
  • -
  • -

    Sequence - Values are assigned by a sequence table (see Sequence Generator).

    -
  • -
  • -

    Table - Values are assigned by a database table (see Table Generator).

    -
  • -
-
Auto
  Generator NameUnique name of the generated value.
Table GeneratorThese fields define the database table used for generating the primary key and correspond to the @TableGenerator annotation. -

These fields apply only when Strategy = Table.

-

  NameUnique name of the generator.
  TableDatabase table that stores the generated ID values.
  Primary Key ColumnThe column in the table generator's Table that contains the primary key.
  Value ColumnThe column that stores the generated ID values.
  Primary Key Column ValueThe value for the Primary Key Column in the generator table.
Sequence GeneratorThese fields define the specific sequence used for generating the primary key and correspond to the @SequenceGenerator annotation. -

These fields apply only when Strategy = Sequence.

-

  NameName of the sequence table to use for defining primary key values.
  SequenceUnique name of the sequence.
-
- -

 

-Related task
-
-ID mapping -

 

-Related task
-
-JPA Details view (for attributes)
- - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/ref_project_properties.htm b/jpa/plugins/org.eclipse.jpt.doc.user/ref_project_properties.htm deleted file mode 100644 index 9fc5005afd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_project_properties.htm +++ /dev/null @@ -1,80 +0,0 @@ - - - - - - -Project Properties page - JPA Options - - - - - - - - - - - - - - -

-
- - - - -
-

Project Properties page - JPA Options

-
-

Use the JPA options on the Properties page to select the database connection to use with the project.

-

This table lists the properties available in the Persistence Properties page.

-
- - - - - - - - - - - - - - - - - -
PropertyDescription
PlatformSelect the vendor-specific platform.
ConnectionThe database connection used to map the persistent entities. -
    -
  • -

    To create a new connection, click Add Connections.

    -
  • -
  • -

    To reconnect to an existing connection, click Reconnect.

    -
  • -
-
-
- -

 

-Related task
-
-Modifying persistent project properties
- - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference.htm deleted file mode 100644 index 5dc89a2b7c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference.htm +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - -Reference - - - - - - - - - - - - - - -

- - - - -
-

Reference

-
-

This section includes detailed help information for each of the following elements in the Dali OR Mapping Tool:

- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference001.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference001.htm deleted file mode 100644 index d0a856b8a8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference001.htm +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - -Wizards - - - - - - - - - - - - - - -

-
- - - - -
-

Wizards

-
-

This section includes information on the following wizards:

- - - -
- - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference002.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference002.htm deleted file mode 100644 index b5a99a9a91..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference002.htm +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - -Property pages - - - - - - - - - - - - - - -

-
- - - - -
-

Property pages

-
-

This section includes information on the following property pages:

- - - -
- - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference003.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference003.htm deleted file mode 100644 index 58601b1aa8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference003.htm +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - -General information - - - - - - - - - - - - - - -

-
- - - - -
-

General information

-
-

This table lists the General information fields available in the JPA Details view for each entity type.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyDescriptionDefaultAvailable for Entity Type
Map AsSpecify the type of entity: Entity, Mapped Superclass, Embeddable.EntityEntity, Embeddable, and Mapped superclass
NameThe name of this entity. By default, the class name is used as the entity name.
Entity
TableThe primary database table associated with the entity.
Entity
CatalogThe database catalog that contains the Table.As defined in orm.xml.Entity
SchemaThe database schema that contains the Table.As defined in orm.xml.Entity
Attribute OverridesSpecify a property or field to be overridden (from the default mappings). Select Override Default.
Entity
  ColumnThe database column (from the Table Name) mapped to the entity.
Entity
  TableName of the database table that contains the selected column.
Entity
-
- -

 

-Related task
-
-Adding persistence to a class -

 

-Related reference
-
-JPA Details view (for entities)
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference004.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference004.htm deleted file mode 100644 index 74775a8a8f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference004.htm +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - -Secondary table information - - - - - - - - - - - - - - -

-
- - - - -
-

Secondary table information

-
-

Use the Secondary Tables area in the Java Details view to associate additional tables with an entity. Use this area if the data associated with an entity is spread across multiple tables.

-

 

-Related task
-
-Specifying additional tables
-Adding persistence to a class -

 

-Related reference
-
-JPA Details view (for entities)
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference005.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference005.htm deleted file mode 100644 index c905aae94d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference005.htm +++ /dev/null @@ -1,108 +0,0 @@ - - - - - - -Inheritance information - - - - - - - - - - - - - - -

-
- - - - -
-

Inheritance information

-
-

This table lists the fields available on the Inheritance area in the Java Details view for each entity type.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyDescriptionDefault
StrategySpecify the strategy to use when mapping a class or class hierarchy: -
    -
  • -

    Single table - All classes in the hierarchy are mapped to a single table.

    -
  • -
  • -

    Joined - The root of the hierarchy is mapped to a single table; each child maps to its own table.

    -
  • -
  • -

    Table per class - Each class is mapped to a separate table.

    -
  • -
-
Single table
Discriminator ColumnUse to specify the name of the discriminator column when using a Single or Joined inheritance strategy.
Discriminator TypeSet this field to set the discriminator type to Char or Integer (instead of its default: String). The Discriminator Value must conform to this type.String
Discriminator ValueSpecify the discriminator value used to differentiate an entity in this inheritance hierarchy. The value must conform to the specified Discriminator Type.
Primary Key Join Columns -

Select Override Default.

-

This field corresponds with @PrimaryKeyJoinColumn annotation.

-

-
- -

 

-Related task
-
-Specifying entity inheritance
-Adding persistence to a class -

 

-Related reference
-
-JPA Details view (for entities)
- - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference006.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference006.htm deleted file mode 100644 index 45b9c12628..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference006.htm +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - -Join Table Information - - - - - - - - - - - - - - -

-
- - - - -
-

Join Table Information

-
-

Use area to specify a mapped column for joining an entity association. By default, the mapping is assumed to have a single join.

-

This table lists the fields available on the Join Table area in the JPA Details view for One-to-many mapping and Many-to-many mapping mapping types.

-
- - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyDescriptionDefault
NameName of the join table that contains the foreign key column.By default, the name is assumed to be the primary tables associated with the entities concatenated with an underscore.
Join ColumnsSpecify a mapped column for joining an entity association. This field corresponds to the @JoinColum attribute. -

Select Override Default, then Add, Edit, or Remove the join columns.

-
By default, the mapping is assumed to have a single join.
Inverse Join ColumnsSelect Override Default, then Add, Edit, or Remove the join columns.
-
- -

 

-Related task
-
-Mapping an entity -

 

-Related task
-
-Edit Join Columns Dialog
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference007.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference007.htm deleted file mode 100644 index fb51f2e3ca..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference007.htm +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - -Join Columns Information - - - - - - - - - - - - - - -

-
- - - - -
-

Join Columns Information

-
-

This table lists the fields available in the Join Table area in JPA Details view for Many-to-one mapping and One-to-one mapping mapping types.

-
- - - - - - - - - - - - - - - -
PropertyDescriptionDefault
Join ColumnSpecify a mapped column for joining an entity association. This field corresponds to the @JoinColum attribute. -

Select Override Default, then Add, Edit, or Remove the join columns.

-
By default, the mapping is assumed to have a single join.
-
- -

 

-Related task
-
-Mapping an entity -

 

-Related task
-
-Edit Join Columns Dialog
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference008.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference008.htm deleted file mode 100644 index 8e8197130d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference008.htm +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - -General information - - - - - - - - - - - - - - -

-
- - - - -
-

General information

-
-

This table lists the General information fields available in the JPA Details view for each entity type.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyDescriptionDefault
PackageThe Java package that contains the persistent entities. Click Browse and select the package
SchemaThe database schema that contains the Table. -

This field corresponds to the <schema> element in the orm.xml file.

-

CatalogThe database catalog that contains the Table. -

This field corresponds to the <catalog> element in the orm.xml file.

-

AccessSpecify the default access method for the variables in the project: -
    -
  • -

    Property

    -
  • -
  • -

    Field

    -
  • -
-

This field corresponds to the <access> element in the orm.xml file.

-

-
- -

 

-Related task
-
-Adding persistence to a class -

 

-Related reference
-
-JPA Details view (for entities)
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference009.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference009.htm deleted file mode 100644 index 5a84da5463..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference009.htm +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - -Persistence Unit information - - - - - - - - - - - - - - -

-
- - - - -
-

Persistence Unit information

-
-

This table lists the Persistence Unit information fields available in the JPA Details view for each entity type. These fields are contained in the <persistence-unit-metadata> element in the orm.xml file.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyDescriptionDefault
XML Mapping Data CompleteSpecifies that the Java classes in this persistence unit are fully specified by their metadata. Any annotations will be ignored. -

This field corresponds to the <xml-mapping-metadata-complete> element in the orm.xml file.

-

PackageThe Java package that contains the persistent entities for this persistence unit. -

Click Browse and select the package

-

SchemaThe database schema that contains the Table. -

This field corresponds to the <schema> element in the orm.xml file.

-

CatalogThe database catalog that contains the Table. -

This field corresponds to the <catalog> element in the orm.xml file.

-

Cascade PersistAdds cascade-persist to the set of cascade options in entity relationships of the persistence unit. -

This field corresponds to the <cascade-persist> element in the orm.xml file.

-

-
- -

 

-Related task
-
-Adding persistence to a class -

 

-Related reference
-
-JPA Details view (for entities)
- - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference010.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference010.htm deleted file mode 100644 index 87bfc6bafa..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference010.htm +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - -Preferences - - - - - - - - - - - - - - -

-
- - - - -
-

Preferences

-
-

This section includes information on the following preference pages:

- - - -
- - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference011.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference011.htm deleted file mode 100644 index 942eaf52af..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference011.htm +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - -Dialogs - - - - - - - - - - - - - - -

-
- - - - -
-

Dialogs

-
-

This section includes information on the following preference pages:

- - - -
- - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference012.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference012.htm deleted file mode 100644 index 510ecb3bd8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference012.htm +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - -Edit Join Columns Dialog - - - - - - - - - - - - - - -

-
- - - - -
-

Edit Join Columns Dialog

-
-

Use the Join Columns dialog to create or modify the join tables and columns in relationship mappings.

-

This table lists the properties available in the Join Columns dialog.

-
- - - - - - - - - - - - - - - - - -
PropertyDescription
NameName of the joint table column that contains the foreign key column.
Referenced Column NameName of the database column that contains the foreign key reference for the entity relationship.
-
- -Related reference
-
-Join Table Information
-Join Columns Information
- - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference013.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference013.htm deleted file mode 100644 index 08937e2298..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference013.htm +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - -Icons and buttons - - - - - - - - - - - - - - -

-
- - - - -
-

Icons and buttons

-
-

This section includes information on each of the icons and buttons used in the Dali OR Mapping Tool.

- - - -
- - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference014.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference014.htm deleted file mode 100644 index 043d0a0b88..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference014.htm +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - -Icons - - - - - - - - - - - - - - -

-
- - - - -
-

Icons

-
-

The following icons are used throughout the Dali OR Mapping Tool.

-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IconDescription
Nonpersistent class icon
Nonpersistent class
Persistent entity icon
Entity
Embeddable entity icon
Embeddable entity
Mapped superclass icon
Mapped superclass
Basic mapping icon
Basic mapping
Embedded mapping icon
Embedded mapping
Embedded ID mapping icon
Embedded ID mapping
ID mapping icon
ID mapping
Many-to-many mapping icon
Many-to-many mapping
Many-to-one mapping icon
Many-to-one mapping
One-to-many mapping icon
One-to-many mapping
One-to-one mapping icon
One-to-one mapping
Transient mapping icon
Transient mapping
Version mapping icon
Version mapping
-
- -Related concept
-

Icons and buttons

-
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference015.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference015.htm deleted file mode 100644 index 37531beb60..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference015.htm +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - -Buttons - - - - - - - - - - - - - - -

-
- - - - -
-

Buttons

-
-

The following buttons are used throughout the Dali OR Mapping Tool.

-
- - - - - - - - - - - - - -
IconDescription
Persistence Perspective button
JPA Development perspective
-
- -Related concept
-

Icons and buttons

-
- - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference016.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference016.htm deleted file mode 100644 index 701274392a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference016.htm +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - -Javadoc - - - - - - - - - - - - - - -
- - - - -
-

Javadoc

-
-

There is no public API for Release 1.0.0. Please refer to the Dali Developer Documentation for additional information.

-
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference017.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference017.htm deleted file mode 100644 index 080d092f48..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference017.htm +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - -Dali Developer Documentation - - - - - - - - - - - - - - -

-
- - - - -
-

Dali Developer Documentation

-
-

Additional Dali documentation is available online at:

-

http://wiki.eclipse.org/index.php/Dali_Developer_Documentation

-

This developer documentation includes information about:

-
    -
  • -

    Dali architecture

    -
  • -
  • -

    Plugins that comprise the Dali JPA Eclipse feature

    -
  • -
  • -

    Extension points

    -
  • -
-
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/task_add_persistence.htm b/jpa/plugins/org.eclipse.jpt.doc.user/task_add_persistence.htm deleted file mode 100644 index fbb1ed01e7..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/task_add_persistence.htm +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - -Adding persistence to a class - - - - - - - - - - - - - - -

-
- - - - -
-

Adding persistence to a class

-
-

You can make a Java class into one of the following persistent types:

- -

 

-Related tasks
-
-Specifying additional tables
-Specifying entity inheritance
-Mapping an entity -

 

-Related concept
-
-Understanding Java persistence
-The orm.xml file
-The persistence.xml file - -
- - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/task_additonal_tables.htm b/jpa/plugins/org.eclipse.jpt.doc.user/task_additonal_tables.htm deleted file mode 100644 index 141620504f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/task_additonal_tables.htm +++ /dev/null @@ -1,79 +0,0 @@ - - - - - - -Specifying additional tables - - - - - - - - - - - - - - -

-
- - - - -
-

Specifying additional tables

-
-

An entity may inherit properties from other entities. You can specify a specific strategy to use for inheritance.

-

Use this procedure to specify inheritance (@Inheritance) for an existing entity (@Entity):

-
    -
  1. -

    Select the entity in the Package Explorer.

    -
  2. -
  3. -

    In the JPA Details view, select the Secondary Tables information.

    -
    -

    Specifying Secondary Tables

    -Secondary Tables area on the JPA Details view.
    -
  4. -
  5. -

    Click Add to associate an additional table with the entity. The Edit Secondary Table dialog appears

    -
  6. -
  7. -

    Select the Name, Catalog, and Schema of the additional table to associate with the entity.

    -
  8. -
-

Eclipse adds the following annotations the entity:

-
-@SecondaryTable(name="NAME", catalog = "CATALOG", schema = "SCHEMA"
-
-
-
-

 

-Related reference
-
-

 

-Related task
-
-Adding persistence to a class -

 

-Related concept
-
-Understanding Java persistence
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/task_create_new_project.htm b/jpa/plugins/org.eclipse.jpt.doc.user/task_create_new_project.htm deleted file mode 100644 index b6d33fa961..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/task_create_new_project.htm +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - -Creating a new JPA project - - - - - - - - - - - - - - -

-
- - - - -
-

Creating a new JPA project

-
-

Use this procedure to create a new JPA project.

-
    -
  1. -

    Select File > New > Other. The New Project dialog appears.

    -
  2. -
  3. -

    On the New Project dialog, select JPA > JPA Project and click Next. The New JPA Project wizard appears.

    -
    -

    New JPA Project

    -The New JPA Project dialog.
    -
  4. -
  5. -

    Complete the fields on the New JPA Project page to specify the project name and location, target runtime, and pre-defined configuration.

    -
  6. -
  7. -

    Click Next. The Project Facets page appears.

    -
  8. -
  9. -

    Select the project facets to use to create the project and click Next. The JPA Facet page appears.

    -
    -

    New JPA Project

    -The JPA Facet dialog
    -
  10. -
  11. -

    Complete the fields on the JPA Facet page to specify your vender-specific platform, database connection, and JPA implementation library.

    -
    -

    - - - - - - -
    -

    Note:

    -If the server runtime does not provide a JPA implementation, you must explicitly select a JPA implementation library. -

    To insure the portability of your application, you must explicitly list the managed persistence classes that are included in the persistence unit. If the server supports EJB 3.0, the persistent classes will be discovered automatically.

    -
    -
    -
    -
  12. -
  13. -

    Click Finish. You should now open the JPA Development perspective.

    -
  14. -
-

 

-Related reference
-
-Create New JPA Project wizard
-JPA Development perspective -

 

-Related tasks
-
-Managing the persistence.xml file
-Adding persistence to a class -

 

-Related concept
-
-Understanding Java persistence
-The persistence.xml file
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/task_generate_entities.htm b/jpa/plugins/org.eclipse.jpt.doc.user/task_generate_entities.htm deleted file mode 100644 index 743ece14af..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/task_generate_entities.htm +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - -Generate Entities from Tables dialog - - - - - - - - - - - - - - -

-
- - - - -
-

Generate Entities from Tables dialog

-
-

Use the Generate Entities dialog to create Java persistent entities from your database tables and columns.

-

This table lists the properties available in the Generate Entities dialog.

-
- - - - - - - - - - - - - - - - - - - - - -
PropertyDescription
Source FolderEnter a project folder name in which to generate the Java persistent entities, or click Browse to select an existing folder.
PackageEnter a package name in which to generate the Java persistent entities, or click Browse to select an existing package.
TablesSelect the tables from which to create Java persistent entities. The tables shown are determined by the database connection that you defined in the Project Properties page - JPA Options.
-
- -Related task
-

Generating entities from tables

-

 

-
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/task_inheritance.htm b/jpa/plugins/org.eclipse.jpt.doc.user/task_inheritance.htm deleted file mode 100644 index 42015c065f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/task_inheritance.htm +++ /dev/null @@ -1,143 +0,0 @@ - - - - - - -Specifying entity inheritance - - - - - - - - - - - - - - -

-
- - - - -
-

Specifying entity inheritance

-
-

An entity may inherit properties from other entities. You can specify a specific strategy to use for inheritance.

-

Use this procedure to specify inheritance (@Inheritance) for an existing entity (@Entity):

-
    -
  1. -

    Select the entity in the Package Explorer.

    -
  2. -
  3. -

    In the JPA Details view, select the Inheritance information.

    -
    -

    Specifying Inheritance

    -Selecting the Inheritance area on the JPA Details view.
    -
  4. -
  5. -

    In the Strategy list, select one of the following the inheritance strategies:

    -
      -
    • -

      A single table (default)

      -
    • -
    • -

      Joined table

      -
    • -
    • -

      One table per class

      -
    • -
    -
  6. -
  7. -

    Use the following table to complete the remaining fields on the tab. See "Inheritance information" for additional details.

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    PropertyDescriptionDefault
    Discriminator ColumnName of the discriminator column when using a Single or Joined inheritance strategy. -

    This field corresponds to the @DiscriminatorColumn annotation.

    -

    Discriminator TypeSet the discriminator type to Char or Integer (instead of its default: String). The Discriminator Value must conform to this type.String
    Discriminator ValueSpecify the discriminator value used to differentiate an entity in this inheritance hierarchy. The value must conform to the specified Discriminator Type. -

    This field corresponds to the @DiscriminatorValue annotation.

    -

    Override DefaultUse this field to specify custom primary key join columns. -

    This field corresponds to the @PrimaryKeyJoinClumn annotation.

    -

    -
    -
  8. -
-

Eclipse adds the following annotations the entity field:

-
-@Inheritance(strategy=InheritanceType.<INHERITANCE_STRATEGY>)
-@DiscriminatorColumn(name="<DISCRIMINATOR_COLUMN>",
-    discriminatorType=<DISCRIMINATOR_TYPE>)
-@DiscriminatorValue(value-"<DISCRIMINATOR_VALUE>")
-@PrimaryKeyJoinColumn(name="<JOIN_COLUMN_NAME>", 
-    referencedColumnName = "<REFERENCED_COLUMN_NAME>")
-
-
-
-

The following figures illustrates the different inheritance strategies.

-
-

Single Table Inheritance

-This figure illustrates entity inheritance in a single table.
- -
-

Joined Table Inheritance

-This figure shows a sample joined inheritance table strategy.
- -

 

-Related reference
-
-

 

-Related task
-
-Adding persistence to a class -

 

-Related concept
-
-Understanding Java persistence
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/task_manage_orm.htm b/jpa/plugins/org.eclipse.jpt.doc.user/task_manage_orm.htm deleted file mode 100644 index c749d97a64..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/task_manage_orm.htm +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - -Managing the orm.xml file - - - - - - - - - - - - - - -

-
- - - - -
-

Managing the orm.xml file

-
-

When creating a JPA project, (see "Creating a new JPA project") you can also create the orm.xml file that defines the mapping metadata and defaults.

-

Eclipse creates the META-INF\orm.xml file in your project's directory:

-
-<?xml version="1.0" encoding="UTF-8"?>
-<persistence version="<PERSISTENCE_VERSION>"
-      xmlns="http://java.sun.com/xml/ns/persistence"
-      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
-      http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
-  <persistence-unit name="<PERSISTENCE_UNIT_NAME>">
-    <provider="<PERSISTENCE_PROVIDER>" />
-  </persistence-unit>
-</persistence>
-
-
-

 

-Related reference
-
-Create New JPA Project wizard -

 

-Related task
-
-Working with orm.xml file
-

 

-Related concept
-
-The orm.xml file
- - -
- - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/task_manage_persistence.htm b/jpa/plugins/org.eclipse.jpt.doc.user/task_manage_persistence.htm deleted file mode 100644 index 18bd864c0d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/task_manage_persistence.htm +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - -Managing the persistence.xml file - - - - - - - - - - - - - - -

-
- - - - -
-

Managing the persistence.xml file

-
-

When creating a JPA project, (see "Creating a new JPA project") you can also create the persistence.xml file.

-

Eclipse creates the META-INF\persistence.xml file in your project's directory:

-
-<?xml version="1.0" encoding="UTF-8"?>
-<persistence version="<PERSISTENCE_VERSION>"
-      xmlns="http://java.sun.com/xml/ns/persistence"
-      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-      xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
-      http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
-  <persistence-unit name="<PERSISTENCE_UNIT_NAME>">
-    <provider="<PERSISTENCE_PROVIDER>" />
-  </persistence-unit>
-</persistence>
-
-
-

 

-Related reference
-
-Create New JPA Project wizard -

 

-Related task
-
-Working with persistence.xml file
-

 

-Related concept
-
-The persistence.xml file
- - -
- - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/task_mapping.htm b/jpa/plugins/org.eclipse.jpt.doc.user/task_mapping.htm deleted file mode 100644 index 8c1d6df3f1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/task_mapping.htm +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - -Mapping an entity - - - - - - - - - - - - - - -

-
- - - - -
-

Mapping an entity

-
-

Dali supports the following mapping types for Java persistent entities:

- -

 

-Related concept
-
-Understanding OR mappings - -
- - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks.htm deleted file mode 100644 index 720983393b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks.htm +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - -Tasks - - - - - - - - - - - - - - -

- - - - -
-

Tasks

-
-

This section includes detailed step-by-step procedures for accessing the Dali OR mapping tool functionality.

- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks001.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks001.htm deleted file mode 100644 index 24ff2e2ecf..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks001.htm +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - -Working with persistence.xml file - - - - - - - - - - - - - - -

-
- - - - -
-

Working with persistence.xml file

-
-

You can work with the persistence.xml by using the XML Editor.

-

Use this procedure to work with the persistence.xml file:

-
    -
  1. -

    Right-click the persistence.xml file in the Package Explorer and select Open With > XML Editor.

    -
    -

    Opening the XML Editor

    -This figure shows the Open > XML Editor option for the persistence.xml file.
    -
  2. -
  3. -

    Use the XML Editor to edit the persistence.xml file.

    -
    -

    XML Editor

    -This figure shows the XML Editor.
    -
  4. -
-Related task
-
-Working with persistence.xml file
-Working with XML Files -

 

-Related concept
-
-The persistence.xml file
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks002.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks002.htm deleted file mode 100644 index 2f1129c4da..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks002.htm +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - -Synchronizing classes - - - - - - - - - - - - - - -

-
- - - - -
-

Synchronizing classes

-
-

As you work with the classes in your Java project, you will need to update the persistence.xml file to reflect the changes.

-

Use this procedure to synchronize the persistence.xml file:

-
    -
  1. -

    Right-click the persistence.xml file in the Package Explorer and select JPA Tools > Synchronize Classes.

    -
    -

    Synchronizing the persistence.xml File

    -This figure shows the JPA Tools > Synchronize Classes option.
    - -

    Dali adds the necessary <class> elements to the persistence.xml file.

    -
  2. -
  3. -

    Use the Persistence XML Editor to continue editing the persistence.xml file.

    -
  4. -
-Related task
-
-Working with persistence.xml file -

 

-Related concept
-
-The persistence.xml file
-
- - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks003.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks003.htm deleted file mode 100644 index c652365a23..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks003.htm +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - -Working with orm.xml file - - - - - - - - - - - - - - -

-
- - - - -
-

Working with orm.xml file

-
-

You can work with the orm.xml by using the JPA Details view.

-

Use this procedure to work with the orm.xml file:

-
    -
  1. -

    Right-click the orm.xml file in the Package Explorer and select Open.

    -
  2. -
  3. -

    In the JPA Structure view, select EntityMappings.

    -
  4. -
  5. -

    Use the JPA Details view to configure the entity mapping and persistence unit defaults.

    -
    -

    JPA Details view for EntityMappings (orm.xml)

    -JPA Details view for orm.xml file.
    -
  6. -
-Related task
-
-Working with orm.xml file
-Working with XML Files
-

 

-Related concept
-
-The orm.xml file
- - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks004.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks004.htm deleted file mode 100644 index 1330b04c6b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks004.htm +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - -Entity - - - - - - - - - - - - - - -

-
- - - - -
-

Entity

-
-

An Entity is a persistent domain object.

-

An entity can be:

-
    -
  • -

    Abstract or concrete classes. Entities may also extend non-entity classes as well as entity classes, and non-entity classes may extend entity classes.

    -
  • -
-

An entity must have:

-
    -
  • -

    A no-arg constructor (public or protected); the entity class may have other constructors as well.

    -
  • -
-

Each persistent entity must be mapped to a database table and contain a primary key. Persistent entities are identified by the @Entity annotation.

-

Use this procedure to add persistence to an existing entity:

-
    -
  1. -

    Open the Java class in the Package Explorer.

    -
  2. -
  3. -

    Select the class in the JPA Structure view.

    -
  4. -
  5. -

    In the JPA Details view, use the Map As field to select Entity.

    -
    -

    Selecting Entity Persistence

    -Selecting entity persistence on the JPA Details view.
    -
  6. -
  7. -

    Complete the remaining JPA Details view (for entities).

    -
  8. -
-

 

-Related tasks
-
-Adding persistence to a class
-Specifying additional tables
-Specifying entity inheritance
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks005.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks005.htm deleted file mode 100644 index 4fea3e075d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks005.htm +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - -Embeddable - - - - - - - - - - - - - - -

-
- - - - -
-

Embeddable

-
-

An Embedded class is a class whose instances are stored as part of an owning entity; it shares the identity of the owning entity. Each field of the embedded class is mapped to the database table associated with the owning entity.

-

To override the mapping information for a specific subclass, use the @AttributeOverride annotation for that specific class.

-

An embeddable entity is identified by the @Embeddable annotation.

-

Use this procedure to add embeddable persistence to an existing entity:

-
    -
  1. -

    Open the Java class in the Package Explorer.

    -
  2. -
  3. -

    Select the class in the JPA Structure view.

    -
  4. -
  5. -

    In the JPA Details view, use the Map As drop-list to select Embeddable.

    -
    -

    Selecting Embeddable Persistence

    -Selecting embedded persistence on the JPA Details view.
    -
  6. -
  7. -

    Complete the remaining JPA Details view (for entities).

    -
  8. -
-

 

-Related tasks
-
-
Adding persistence to a class
-
Specifying additional tables
-
Specifying entity inheritance
-
-
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks006.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks006.htm deleted file mode 100644 index 0012aa273b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks006.htm +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - -Mapped superclass - - - - - - - - - - - - - - -

-
- - - - -
-

Mapped superclass

-
-

An entities that extend a Mapped Superclass class inherit the persistent state and mapping information from a superclass. You should use a mapped superclass to define mapping information that is common to multiple entity classes.

-

A mapped superclass can be:

-
    -
  • -

    Abstract or concrete classes

    -
  • -
-

A mapped superclass cannot be:

-
    -
  • -

    Be queried or passed as an argument to Entity-Manager or Query operations

    -
  • -
  • -

    Be the target of a persistent relationship

    -
  • -
-

A mapped superclass does not have a defined database table. Instead, its mapping information is derived from its superclass. To override the mapping information for a specific subclass, use the @AttributeOverride annotation for that specific class.

-

A mapped superclass is identified by the @MappedSuperclass annotation.

-

Use this procedure to add Mapped Superclass persistence to an existing entity:

-
    -
  1. -

    Open the Java class in the Package Explorer.

    -
  2. -
  3. -

    Select the class in the JPA Structure view.

    -
  4. -
  5. -

    In the JPA Details view, use the Map As drop-list to select Mapped Superclass.

    -
    -

    Selecting Mapped Superclass Persistence

    -Selecting embedded persistence on the JPA Details view.
    -
  6. -
  7. -

    Complete the remaining JPA Details view (for entities).

    -
  8. -
-

 

-Related tasks
-
-Adding persistence to a class
-Specifying additional tables
-Specifying entity inheritance
- - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks007.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks007.htm deleted file mode 100644 index 4ad3ef63d4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks007.htm +++ /dev/null @@ -1,206 +0,0 @@ - - - - - - -Basic mapping - - - - - - - - - - - - - - -

-
- - - - -
-

Basic mapping

-
-

Use a Basic Mapping to map an attribute directly to a database column. Basic mappings may be used only with the following attribute types:

-
    -
  • -

    Java primitive types and wrappers of the primitive types

    -
  • -
  • -

    java.lang.String, java.math.BigInteger

    -
  • -
  • -

    java.math.BigDecimal

    -
  • -
  • -

    java.util.Date

    -
  • -
  • -

    java.util.Calendar, java.sql.Date

    -
  • -
  • -

    java.sql.Time

    -
  • -
  • -

    java.sql.Timestamp

    -
  • -
  • -

    byte[]

    -
  • -
  • -

    Byte[]

    -
  • -
  • -

    char[]

    -
  • -
  • -

    Character[]

    -
  • -
  • -

    enums

    -
  • -
  • -

    any other type that implements Serializable

    -
  • -
-

To create a basic mapping:

-
    -
  1. -

    In the JPA Structure view, select the field to map. The JPA Details view (for attributes) displays the properties for the selected field.

    -
  2. -
  3. -

    In the Map As field, select Basic.

    -
  4. -
  5. -

    Use this table to complete the remaining fields on the JPA Details view.

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    PropertyDescriptionDefault
    Map AsDefines this mapping as a Basic Mapping. -

    This field corresponds to the @Basic annotation.

    -
    Basic
    ColumnThe database column mapped to the entity attribute. See "Column" for details. -
      -
    • -

      Name - Name of the database column.

      -
    • -
    • -

      Table - Name of the database table.

      -
    • -
    • -

      Insertable - Specify if the column is always included in SQL INSERT statements.

      -
    • -
    • -

      Updatable - Specify if the column is always included in SQL UPDATE statements.

      -
    • -
    -
    By default, the Column is assumed to be named identically to the attribute and always included in the INSERT and UPDATE statements.
    TableName of the database table.
    FetchDefines how data is loaded from the database. See "Fetch Type" for details. -
      -
    • -

      Eager

      -
    • -
    • -

      Lazy

      -
    • -
    -
    Eager
    OptionalSpecifies if this field is can be null.Yes
    LobSpecifies if this is a large objects (BLOB or CLOB). See "Lob" for details.
    TemporalSpecifies the type of data. See "Temporal" for details. -
      -
    • -

      Date

      -
    • -
    • -

      Time

      -
    • -
    • -

      Timestamp

      -
    • -
    -

    -
    -
  6. -
-

Eclipse adds the following annotations to the field:

-
-@Column(name="<COLUMN_NAME>", table="<COLUMN_TABLE>", 
-    insertable=<INSERTABLE>, updatable=<UPDATABLE>)
-@Basic(fetch=FetchType.<FETCH_TYPE>, optional = <OPTIONAL>)
-@Temporal(TemporalType.<TEMPORAL>)
-
-
-
-

 

-Related task
-
-Mapping an entity -

 

-Related reference
-
-JPA Structure view
-JPA Details view (for attributes) -

 

-Related concept
-
-Understanding OR mappings
-Understanding EJB 3.0 Java Persistence API
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks008.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks008.htm deleted file mode 100644 index bdbba7168e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks008.htm +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - -Embedded mapping - - - - - - - - - - - - - - -

-
- - - - -
-

Embedded mapping

-
-

Use an Embedded Mapping to specify a persistent field or property of an entity whose value is an instance of an embeddable class.

-
    -
  1. -

    In the JPA Structure view, select the field to map. The JPA Details view (for attributes) displays the properties for the selected field.

    -
  2. -
  3. -

    In the Map As field, select Embedded.

    -
  4. -
  5. -

    Use this table to complete the remaining fields on the JPA Details view.

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    PropertyDescriptionDefault
    Map AsDefines this mapping as a Embedded. -

    This field corresponds to the @Embedded annotation.

    -
    Embedded
    Attribute OverridesSpecify to override the default mapping of an entity's attribute. Select Override Default.
    ColumnsThe database column (and its table) mapped to the entity attribute. See "Column" for details. -
      -
    • -

      Name - Name of the database column.

      -
    • -
    • -

      Table - Name of the database table.

      -
    • -
    • -

      Insertable - Specify if the column is always included in SQL INSERT statements.

      -
    • -
    • -

      Updatable - Specify if the column is always included in SQL UPDATE statements.

      -
    • -
    -

    -
    -
  6. -
-

Eclipse adds the following annotations to the field:

-
-@Embedded
-@AttributeOverride(column=@Column(table="<COLUMN_TABLE>", name = "<COLUMN_NAME>"))
-
-
-

 

-Related task
-
-Mapping an entity -

 

-Related reference
-
-JPA Structure view
-JPA Details view (for attributes) -

 

-Related concept
-
-Understanding OR mappings
-Understanding EJB 3.0 Java Persistence API
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks009.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks009.htm deleted file mode 100644 index 6999dd180c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks009.htm +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - -Embedded ID mapping - - - - - - - - - - - - - - -

-
- - - - -
-

Embedded ID mapping

-
-

Use an Embedded ID Mapping to specify the primary key of an embedded ID. These mappings may be used with a Embeddable entities.

-
    -
  1. -

    In the JPA Structure view, select the field to map. The JPA Details view (for attributes) displays the properties for the selected field.

    -
  2. -
  3. -

    In the Map As field, select Embedded Id.

    -
  4. -
  5. -

    Use this table to complete the remaining fields on the JPA Details view.

    -
    - - - - - - - - - - - - - - - -
    PropertyDescriptionDefault
    Map AsDefines this mapping as a Embedded Id. -

    This field corresponds to the @EmbeddedId annotation.

    -
    Embedded Id
    -
    -
  6. -
-

Eclipse adds the following annotations to the field:

-
-@EmbeddedId
-
-
-

 

-Related task
-
-Mapping an entity -

 

-Related reference
-
-JPA Structure view
-JPA Details view (for attributes) -

 

-Related concept
-
-Understanding OR mappings
-Understanding EJB 3.0 Java Persistence API
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks010.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks010.htm deleted file mode 100644 index 5472078fe4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks010.htm +++ /dev/null @@ -1,176 +0,0 @@ - - - - - - -ID mapping - - - - - - - - - - - - - - -

-
- - - - -
-

ID mapping

-
-

Use an ID Mapping to specify the primary key of an entity. ID mappings may be used with a Entity or Mapped superclass. Each Entity must have an ID mapping.

-
    -
  1. -

    In the JPA Structure view, select the field to map. The JPA Details view (for attributes) displays the properties for the selected.

    -
  2. -
  3. -

    In the Map As field, select ID.

    -
  4. -
  5. -

    Use this table to complete the General information fields in the JPA Details view.

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    PropertyDescriptionDefault
    Map AsDefines this mapping as an ID Mapping. -

    This field corresponds to the @Id annotation.

    -
    ID
    ColumnThe database column mapped to the entity attribute. See "Column" for details.By default, the Column is assumed to be named identically to the attribute.
    TableThe database table mapped to the entity attribute.By default, the Table is assumed to be identical to the table associated with the entity.
    TemporalSpecifies the type of data. See "Temporal" for details. -
      -
    • -

      Date

      -
    • -
    • -

      Time

      -
    • -
    • -

      Timestamp

      -
    • -
    -

    -
    -
  6. -
  7. -

    Use this table to complete the fields in Primary Key Generation information area in the JPA Details view.

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    PropertyDescriptionDefault
    Primary Key GenerationThese fields define how the primary key is generated.
      StrategySee "Primary Key Generation" for details. -
      -
    • -

      Auto

      -
    • -
    • -

      Sequence

      -
    • -
    • -

      Identity

      -
    • -
    • -

      Table

      -
    • -
    -
    Auto
      Generator NameName of the primary key generator specified in the Strategy
    -
    -
  8. -
-

Additional fields will appear in the Primary Key Generation information area, depending on the selected Strategy. See "JPA Details view (for attributes)" for additional information.

-

Eclipse adds the following annotations to the field:

-
-@Id
-@Column(name="<COLUMN_NAME>", table="<TABLE_NAME>", insertable=<INSERTABLE>,
-    updatable=<UPDATABLE>)
-@Temporal(<TEMPORAL>)
-@GeneratedValue(strategy=GeneratorType.<STRATEGY>, generator="<GENERATOR_NAME>")@TableGenerator(name="<TABLE_GENERATOR_NAME>", table = "<TABLE_GENERATOR_TABLE>", 
-    pkColumnName = "<TABLE_GENERATOR_PK>", 
-    valueColumnName = "<TABLE_GENERATOR_VALUE_COLUMN>", 
-    pkColumnValue = "<TABLE_GENERATOR_PK_COLUMN_VALUE>")@SequenceGenerator(name="<SEQUENCE_GENERATOR_NAME>", 
-    sequenceName="<SEQUENCE_GENERATOR_SEQUENCE>")
-
-
-

 

-Related task
-
-Mapping an entity -

 

-Related reference
-
-JPA Structure view
-JPA Details view (for attributes) -

 

-Related concept
-
-Understanding OR mappings
-Understanding EJB 3.0 Java Persistence API
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks011.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks011.htm deleted file mode 100644 index ae12cc0852..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks011.htm +++ /dev/null @@ -1,179 +0,0 @@ - - - - - - -Many-to-many mapping - - - - - - - - - - - - - - -

-
- - - - -
-

Many-to-many mapping

-
-

Use a Many-to-Many Mapping to define a many-valued association with many-to-many multiplicity. A many-to-many mapping has two sides: the owning side and non-owning side. You must specify the join table on the owning side. For bidirectional mappings, either side may be the owning side.

-
    -
  1. -

    In the JPA Structure view, select the field to map. The JPA Details view (for attributes) displays the properties for the selected.

    -
  2. -
  3. -

    In the Map As field, select Many-to-Many.

    -
  4. -
  5. -

    Use this table to complete the General information fields of the JPA Details view.

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    PropertyDescriptionDefault
    Map AsDefines this mapping as a Many to Many Mapping. -

    This field corresponds to the @ManyToMany annotation.

    -
    Many to Many
    Target EntityThe entity to which this attribute is mapped.null -

    You do not need to explicitly specify the target entity, since it can be inferred from the type of object being referenced.

    -
    FetchDefines how data is loaded from the database. See "Fetch Type" for details. -
      -
    • -

      Eager

      -
    • -
    • -

      Lazy

      -
    • -
    -
    Lazy
    Mapped ByThe database field that owns the relationship.
    Order BySpecify the default order for objects returned from a query. See "Order By" for details. -
      -
    • -

      No ordering

      -
    • -
    • -

      Primary key

      -
    • -
    • -

      Custom

      -
    • -
    -
    No ordering
    -
    -
  6. -
  7. -

    Use this table to complete the fields in the Join Table Information area in the JPA Details view.

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    PropertyDescriptionDefault
    NameName of the join table that contains the foreign key column.You must specify the join table on the owning side. -

    By default, the name is assumed to be the primary tables associated with the entities concatenated with an underscore.

    -
    Join ColumnsSelect Override Default, then Add, Edit, or Remove the join columns.By default, the name is assumed to be the primary tables associated with the entities concatenated with an underscore.
    Inverse Join ColumnsSelect Override Default, then Add, Edit, or Remove the join columns.By default, the mapping is assumed to have a single join.
    -
    -
  8. -
  9. -

    To add a new Join or Inverse Join Column, click Add.

    -

    To edit an existing Join or Inverse Join Column, select the field to and click Edit.

    -
  10. -
-

Eclipse adds the following annotations to the field:

-
-@JoinTable(joinColumns=@JoinColumn(name="<JOIN_COLUMN>"), 
-    name = "<JOIN_TABLE_NAME>")
-@ManyToMany(cascade=CascadeType.<CASCADE_TYPE>, fetch=FetchType.<FETCH_TYPE>,
-    targetEntity=<TARGET_ENTITY>, mappedBy = "<MAPPED_BY>")
-@OrderBy("<ORDER_BY>")
-
-
-
-

 

-Related task
-
-Mapping an entity -

 

-Related reference
-
-JPA Structure view
-JPA Details view (for attributes) -

 

-Related concept
-
-Understanding OR mappings
-Understanding EJB 3.0 Java Persistence API
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks012.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks012.htm deleted file mode 100644 index 82abc53480..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks012.htm +++ /dev/null @@ -1,134 +0,0 @@ - - - - - - -Many-to-one mapping - - - - - - - - - - - - - - -

-
- - - - -
-

Many-to-one mapping

-
-

Use a Many-to-One mapping to defines a single-valued association to another entity class that has many-to-one multiplicity.

-
    -
  1. -

    In the JPA Structure view, select the field to map. The JPA Details view (for attributes) displays the properties for the selected.

    -
  2. -
  3. -

    In the Map As field, select Many-to-One.

    -
  4. -
  5. -

    Use this table to complete the General information fields JPA Details view.

    -
    - - - - - - - - - - - - - - - - - - - - -
    PropertyDescriptionDefault
    Target EntityThe entity to which this attribute is mapped.null -

    You do not need to explicitly specify the target entity, since it can be inferred from the type of object being referenced.

    -
    Fetch TypeDefines how data is loaded from the database. See "Fetch Type" for details. -
      -
    • -

      Eager

      -
    • -
    • -

      Lazy

      -
    • -
    -
    Eager
    -
    -
  6. -
  7. -

    Use this table to complete the fields on the Join Columns Information tab in the JPA Details view.

    -
    - - - - - - - - - - - - - - - -
    PropertyDescriptionDefault
    Join ColumnSpecify a mapped column for joining an entity association. This field corresponds to the @JoinColum attribute. -

    Select Override Default, then Add, Edit, or Remove the join columns.

    -
    By default, the mapping is assumed to have a single join.
    -
    -
  8. -
-

Eclipse adds the following annotations to the field:

-
-@JoinTable(joinColumns=@JoinColumn(name="<JOIN_COLUMN>"), 
-    name = "<JOIN_TABLE_NAME>")
-@ManyToOne(targetEntity=<TARGET_ENTITY>, fetch=<FETCH_TYPE>, 
-    cascade=<CASCADE_TYPE>)
-
-
-

 

-Related task
-
-Mapping an entity -

 

-Related reference
-
-JPA Structure view
-JPA Details view (for attributes) -

 

-Related concept
-
-Understanding OR mappings
-Understanding EJB 3.0 Java Persistence API
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks013.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks013.htm deleted file mode 100644 index 5c5ac094b2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks013.htm +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - -One-to-many mapping - - - - - - - - - - - - - - -

-
- - - - -
-

One-to-many mapping

-
-

Use a One-to-Many Mapping to define a relationship with one-to-many multiplicity.

-
    -
  1. -

    In the JPA Structure view, select the field to map. The JPA Details view (for attributes) displays the properties for the selected.

    -
  2. -
  3. -

    In the Map As field, select One-to-many.

    -
  4. -
  5. -

    Use this table to complete the General information fields JPA Details view.

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    PropertyDescriptionDefault
    Target EntityThe entity to which this attribute is mapped.
    Fetch TypeDefines how data is loaded from the database. See "Fetch Type" for details. -
      -
    • -

      Eager

      -
    • -
    • -

      Lazy

      -
    • -
    -
    Eager
    Mapped ByThe database field that owns the relationship.
    Order BySpecify the default order for objects returned from a query. See "Order By" for details. -
      -
    • -

      No ordering

      -
    • -
    • -

      Primary key

      -
    • -
    • -

      Custom

      -
    • -
    -
    No ordering
    -
    -
  6. -
  7. -

    Use this table to complete the Join Table Information fields in the JPA Details view.

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    PropertyDescriptionDefault
    NameName of the join tableBy default, the name is assumed to be the primary tables associated with the entities concatenated with an underscore.
    Join ColumnsSpecify two or more join columns (that is, a primary key).
    Inverse Join ColumnsThe join column on the owned (or inverse) side of the association: the owned entity's primary key column.
    -
    -
  8. -
-

Eclipse adds the following annotations to the field:

-
-@OneToMany(targetEntity=<TARGET_ENTITY>)
-@Column(name="<COLUMN>")
-
-
-@OneToMany(targetEntity=<TARGET_ENTITY>.class, cascade=CascadeType.<CASCADE_TYPE>, 
-    fetch = FetchType.<FETCH_TYPE>, mappedBy = "<MAPPED_BY>")@OrderBy("<ORDER_BY>")
-@JoinTable(name="<JOIN_TABLE_NAME>", joinColumns=@JoinColumn(name=
-    "<JOIN_COLUMN_NAME>", referencedColumnName="<JOIN_COLUMN_REFERENCED_COLUMN>"), 
-    inverseJoinColumns=@JoinColumn(name="<INVERSE_JOIN_COLUMN_NAME>", 
-    referencedColumnName="<INVERSE_JOIN_COLUMN_REFERENCED_COLUMN>"))
-
-
-
-

 

-Related task
-
-Mapping an entity -

 

-Related reference
-
-JPA Structure view
-JPA Details view (for attributes) -

 

-Related concept
-
-Understanding OR mappings
-Understanding EJB 3.0 Java Persistence API
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks014.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks014.htm deleted file mode 100644 index c67cbd61d0..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks014.htm +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - -One-to-one mapping - - - - - - - - - - - - - - -

-
- - - - -
-

One-to-one mapping

-
-

Use a One-to-One Mapping to define a relationship with one-to-many multiplicity.

-
    -
  1. -

    In the JPA Structure view, select the field to map. The JPA Details view (for attributes) displays the properties for the selected.

    -
  2. -
  3. -

    In the Map As field, select One-to-one.

    -
  4. -
  5. -

    Use this table to complete the General information fields in the JPA Details view.

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    PropertyDescriptionDefault
    Target EntityThe entity to which this attribute is mapped.null -

    You do not need to explicitly specify the target entity, since it can be inferred from the type of object being referenced.

    -
    Fetch TypeDefines how data is loaded from the database. See "Fetch Type" for details. -
      -
    • -

      Eager

      -
    • -
    • -

      Lazy

      -
    • -
    -
    Eager
    Mapped ByThe database field that owns the relationship.
    -
    -
  6. -
  7. -

    Use this table to complete the Join Columns Information fields in the JPA Details view.

    -
    - - - - - - - - - - - - - - - -
    PropertyDescriptionDefault
    Join ColumnSpecify a mapped column for joining an entity association. This field corresponds to the @JoinColum attribute. -

    Select Override Default, then Add, Edit, or Remove the join columns.

    -
    By default, the mapping is assumed to have a single join.
    -
    -
  8. -
-

Eclipse adds the following annotations to the field:

-
-@OneToOne(targetEntity=<TARGET_ENTITY>, cascade=CascadeType.<CASCADE_TYPE>, 
-    fetch = FetchType.<FETCH_TYPE>, mappedBy = "<MAPPED_BY>")
-@JoinColumn(name="<JOIN_COLUMN_NAME>", referencedColumnName=
-    "<JOIN_COLUMN_REFERENCED_COLUMN>", insertable = <INSERTABLE>, 
-    updatable = <UPDATABLE>)
-
-
-
-

 

-Related task
-
-Mapping an entity -

 

-Related reference
-
-JPA Structure view
-JPA Details view (for attributes) -

 

-Related concept
-
-Understanding OR mappings
-Understanding EJB 3.0 Java Persistence API
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks015.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks015.htm deleted file mode 100644 index 0521e116cd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks015.htm +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - -Transient mapping - - - - - - - - - - - - - - -

-
- - - - -
-

Transient mapping

-
-

Use the Transient Mapping to specify a property or field of the entity class that is not persistent.

-

To create a version mapping:

-
    -
  1. -

    In the JPA Structure view, select the field to map. The JPA Details view (for attributes) displays the properties for the selected.

    -
  2. -
  3. -

    In the Map As field, select Transient.

    -
  4. -
-

Eclipse adds the following annotation to the field:

-
-@Transient
-
-
-

 

-Related task
-
-Mapping an entity -

 

-Related reference
-
-JPA Structure view
-JPA Details view (for attributes) -

 

-Related concept
-
-Understanding OR mappings
-Understanding EJB 3.0 Java Persistence API
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks016.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks016.htm deleted file mode 100644 index c1b4291a6c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks016.htm +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - -Version mapping - - - - - - - - - - - - - - -

-
- - - - -
-

Version mapping

-
-

Use a Version Mapping to specify the field used for optimistic locking. If the entity is associated with multiple tables, you should use a version mapping only with the primary table. You should have only a single version mapping per persistent entity. Version mappings may be used only with the following attribute types:

-
    -
  • -

    int

    -
  • -
  • -

    Integer

    -
  • -
  • -

    short, Short

    -
  • -
  • -

    long, Long

    -
  • -
  • -

    Timestamp

    -
  • -
-

To create a version mapping:

-
    -
  1. -

    In the JPA Structure view, select the field to map. The JPA Details view (for attributes) displays the properties for the selected.

    -
  2. -
  3. -

    In the Map As field, select Version.

    -
  4. -
  5. -

    Use this table to complete the remaining fields in the JPA Details view.

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    PropertyDescriptionDefault
    ColumnThe database column mapped to the entity attribute. See "Column" for details.By default, the Column is assumed to be named identically to the attribute and always included in the INSERT and UPDATE statements.
    TableName of the database table. This must be the primary table associated with the attribute's entity.
    TemporalSpecifies the type of data. See "Temporal" for details. -
      -
    • -

      Date

      -
    • -
    • -

      Time

      -
    • -
    • -

      Timestamp

      -
    • -
    -

    -
    -
  6. -
-

Eclipse adds the following annotations to the field:

-
-@Version
-@Column(table="<COLUMN_TABLE>", name="<COLUMN_NAME>")
-
-
-
-

 

-Related task
-
-Mapping an entity -

 

-Related reference
-
-JPA Structure view
-JPA Details view (for attributes) -

 

-Related concept
-
-Understanding OR mappings
-Understanding EJB 3.0 Java Persistence API
- - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks017.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks017.htm deleted file mode 100644 index dc62498aee..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks017.htm +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - -Generating entities from tables - - - - - - - - - - - - - - -

-
- - - - -
-

Generating entities from tables

-
-

Use this procedure to generate Java persistent entities from database tables. You must create a JPA project and establish a database connection before generating persistent entities. See "Creating a new JPA project" for more information.

-
    -
  1. -

    Right-click the JPA project in the Package Explorer and select JPA Tools > Generate Entities.

    -
    -

    Generating Entities

    -Using the JPA Tools > Generate Entities menu option.
    -
  2. -
  3. -

    If you are not currently connected to the database, the Database Connection page appears. Select your database connection and schema, and click Reconnect.

    -

    To create a new database connection, click Add connection.

    -

    After connecting to the database, click Next.

    -
  4. -
  5. -

    On the Generate Entities from Tables dialog dialog, select the tables from which to generate Java persistent entities and click Finish.

    -
  6. -
-

Eclipse creates a Java persistent entity for each database table. Each entity contains fields based on the table's columns. Eclipse will also generate entity relationships (such as one-to-one) based on the table constraints. Figure: Generating Entities from Tables illustrates how Eclipse generates entities from tables.

-
-

Generating Entities from Tables

-This figure shows the EMPLOYEE and ADDRESS entities generated from database tables.
- -

 

-Related task
-
-

 

-Related reference
-
-

 

-Related concept
-
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks018.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks018.htm deleted file mode 100644 index 986b4faf38..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks018.htm +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - -Validating mappings and reporting problems - - - - - - - - - - - - - - -

-
- - - - -
-

Validating mappings and reporting problems

-
-

Errors and warnings on persistent entities and mappings are indicated with a red error or yellow warning next to the resource with the error, as well as the parent containers up to the project.

-
-

Sample Errors and Warnings

-This figure shows sample error and warning icons in the Explorer view.
- -

This section contains information on the following:

- -

 

-Related concept
-

Problems view

- - -
- - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks019.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks019.htm deleted file mode 100644 index 1ea8850003..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks019.htm +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - -Error messages - - - - - - - - - - - - - - -

-
- - - - -
-

Error messages

-
-

This section contains information on error messages (including how to resolve the issue) you may encounter while working with Dali.

- -

Attribute "<ATTRIBUTE__NAME>" has invalid mapping type in this context

-

The mapped attribute is invalid. Either change the mapping type or change the entity type.

-

See "Mapping an entity" for more information.

- -

Attribute "<ATTRIBUTE_NAME>" cannot be resolved.

-

Dali cannot map the attribute to a database table and column. Verify that you database connection information is correct.

-

See "Creating a new JPA project" for more information.

- -

Class "<CLASS_NAME>" is not annotated as a persistent class.

-

The class has not been identified as a persistent class. Configure the class as an Entity, Mapped Superclass, or Embeddable persistent entity.

-

See "Adding persistence to a class".

- -

Column "<COLUMN_NAME>" cannot be resolved.

-

You mapped an entity's field to an incorrect or invalid column in the database table. By default, Dali will attempt to map each field in the entity with an identically named row in the database table. If the field's name differs from the row's name, you must explicitly create the mapping.

-

Map the field to a valid row in the database table as shown in "Mapping an entity".

- -

Duplicate class "<CLASS_NAME>".

-

You created to persistence classes with the same name. Each Java class must have a unique name. See "Adding persistence to a class" for more information.

- -

Entity does not have an Id or Embedded Id.

-

You created a persistent entity without identifying its primary key. A persistent entity must have a primary key field designated with an @Id or @EmbeddedId annotation.

-

Add an ID mapping to the entity as shown in "ID mapping" or "Embedded ID mapping".

- -

Multiple persistence.xml files in project.

-

You created a JPA project with more than one persistence.xml file. Each JPA project must contain a single persistence.xml file.

-

See "Managing the persistence.xml file" for more information.

- -

No generator named "<GENERATOR_NAME>" is defined in persistence unit.

-

You created a persistence entity that uses sequencing, but did not define include the sequence generator in the psersistence.xml file. Synchronize the persistence.xml file with your current project.

-

See "Synchronizing classes" for more information.

- -

No persistence unit defined.

-

There is no <persistence-unit-metadata> information in the orm.xml file. Add the default persistence unit information.

-

See "Managing the orm.xml file" for more information.

- -

No persistence.xml file in project.

-

You created a JPA project without a persistence.xml file. Each JPA project must contain a single persistence.xml file.

-

See "Managing the persistence.xml file" for more information.

- -

Referenced column "<COLUMN_NAME>" in join column "<COLUMN_NAME>" cannot be resolved.

-

The column that you selected to join a relationship mapping does not exist on the database table. Either select a different column on the Join Table Information or create the necessary column on the database table.

-

See "JPA Details view (for attributes)" for more information.

- -

Schema "<SCHEMA_NAME>" cannot be resolved for table/join table "<TABLE_NAME>".

-

Define the default database schema information in the persistence unit.

-

See "Managing the orm.xml file" for more information.

- -

Table "<TABLE_NAME>" cannot be resolved.

-

You associated a persistent entity to an incorrect or invalid database table. By default, Dali will attempt to associate each persistent entity with an identically named database table. If the entity's name differs from the table's name, you must explicitly create the association.

-

Associate the entity with a valid database table as shown in "Adding persistence to a class".

-Related concept
-

Problems view

-
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks020.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks020.htm deleted file mode 100644 index 01861dfe39..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks020.htm +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - -Warning messages - - - - - - - - - - - - - - -

-
- - - - -
-

Warning messages

-
-

This section contains information on warning messages (including how to resolve the issue) you may encounter while working with Dali.

- -

Connection "<CONNECTION_NAME>" is not active. No validation will be done against the data source.

-

The database connection you specified to use with the JPA project is not active. The JPA project requires an active connection.

- -

No connection specified for the project. No data-specific validation will be performed.

-

You created a JPA project without specifying a database connection. The JPA project requires an active connection.

-

See "Creating a new JPA project" or "Modifying persistent project properties" for information on specifying a database connection.

-Related concept
-

Problems view

-
- - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks021.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks021.htm deleted file mode 100644 index f0956b7831..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks021.htm +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - -Modifying persistent project properties - - - - - - - - - - - - - - -

-
- - - - -
-

Modifying persistent project properties

-
-

Each persistent project must be associated with a database connection. To create a new database connection, click Database Connection use the New Connection wizard.

-

Use this procedure to modify the vender-specific platform and database connection associated with your JPA project.

-
    -
  1. -

    Right-click the project in the Explorer view and select Properties. The Properties page appears.

    -
    -

    Properties - Persistence Page

    -This figure shows the JPA options on the Properties dialog.
    -
  2. -
  3. -

    Use this table to complete the remaining fields on the Properties - JPA page and click OK.

    -
    - - - - - - - - - - - - - - - - - -
    PropertyDescription
    PlatformSelect the vendor-specific platform for the JPA implementation.
    Database ConnectionDatabase connection to use to store the persistent entities. To create a new connection, click Add Connection.
    -
    -
  4. -
-

To create a new connection, click Add connections.

-

 

-Related task
-
-Creating a new JPA project -

 

-Related reference
-
-Project Properties page - JPA Options -

 

-Related concept
-
-Understanding Java persistence
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tips_and_tricks.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tips_and_tricks.htm deleted file mode 100644 index 739ecbb1cf..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tips_and_tricks.htm +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - -Tips and tricks - - - - - - - - - - - - - - -

- - - - -
-

Tips and tricks

-
-

The following tips and tricks give some helpful ideas for increasing your productivity.

- -
- - - - - - - - - - - - - - - - - -
TipDescription
Database ConnectionsWhen starting a new workbench session, be sure to reconnect to your database (if you are working online). This allows Dali to provide database-related mapping assistance and validation.
Schema-based persistence.xmlIf you are behind a firewall, you may need to configure your Eclipse workspace proxy in the Preferences dialog (Preferences > Internet > Proxy Settings) to properly validate a schema-based persistence.xml file.
-
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/toc.xml b/jpa/plugins/org.eclipse.jpt.doc.user/toc.xml deleted file mode 100644 index 55323219b9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/toc.xml +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new.htm b/jpa/plugins/org.eclipse.jpt.doc.user/whats_new.htm deleted file mode 100644 index 8c777d1ff9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new.htm +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - -What's new - - - - - - - - - - - - - - -

- - - - -
-

What's new

-
-

This section contains descriptions of the following new feature and significant changes made to the Dali OR Mapping Tool for Release 1.0.0:

- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new001.htm b/jpa/plugins/org.eclipse.jpt.doc.user/whats_new001.htm deleted file mode 100644 index 26654ca1e6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new001.htm +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - -Generate Persistent Entities from Tables wizard - - - - - - - - - - - - - - -

-
- - - - -
-

Generate Persistent Entities from Tables wizard

-
-

Use the Generate Entities from Tables wizard to quickly create JPA entities from your database tables.

-
-

Generating Entities

-Selecting the JPA Tools > Generate Entities option.
- -

Dali automatically creates the necessary OR mappings, based on your database table constraints.

-Related concept
-
-What's new Related task
-
-Generating entities from tables
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new002.htm b/jpa/plugins/org.eclipse.jpt.doc.user/whats_new002.htm deleted file mode 100644 index 455826bdea..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new002.htm +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - -Create and Manage the persistence.xml file - - - - - - - - - - - - - - -

-
- - - - -
-

Create and Manage the persistence.xml file

-
-

When creating a JPA project, Dali automatically creates the perssistence.xml file.

-
-

JPA Project with persistence.xml File

-JPA project with persistence.xml file.
- -

Use the XML editor to edit the persistence.xml file.

-

After adding your JPA entities, use the Java Persistence > Synchronize Classes option to add the classes to the persistence.xml file.

-
-

Synchronizing the persistence.xml File.

-The JPA Tools > Synchronize Classes option.
- -Related concept
-
-What's new
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new003.htm b/jpa/plugins/org.eclipse.jpt.doc.user/whats_new003.htm deleted file mode 100644 index b75c0a95fb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new003.htm +++ /dev/null @@ -1,56 +0,0 @@ - - - - - - -Create and Manage the orm.xml file - - - - - - - - - - - - - - -

-
- - - - -
-

Create and Manage the orm.xml file

-
-

When creating a JPA project, you can also create the orm.xml file. Select the Create orm.xml option on the JPA Facet page page of the Create New JPA Project wizard.

-
-

JPA Facet Dialog

-JPA Facet dialog.
- -

Use the orm.xml file to define the project and persistence unit defaults.

-
-

JPA Details view for orm.xml file.

-JPA Details view for orm.xml file.
- -Related concept
-
-What's new
- - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.gen/.classpath b/jpa/plugins/org.eclipse.jpt.gen/.classpath deleted file mode 100644 index 304e86186a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.gen/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.gen/.cvsignore b/jpa/plugins/org.eclipse.jpt.gen/.cvsignore deleted file mode 100644 index 2d14989f69..0000000000 --- a/jpa/plugins/org.eclipse.jpt.gen/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -bin -@dot -build.xml diff --git a/jpa/plugins/org.eclipse.jpt.gen/.project b/jpa/plugins/org.eclipse.jpt.gen/.project deleted file mode 100644 index ef2d5088ee..0000000000 --- a/jpa/plugins/org.eclipse.jpt.gen/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.eclipse.jpt.gen - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/jpa/plugins/org.eclipse.jpt.gen/.settings/org.eclipse.core.resources.prefs b/jpa/plugins/org.eclipse.jpt.gen/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 7e690b4d88..0000000000 --- a/jpa/plugins/org.eclipse.jpt.gen/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Sun May 27 15:10:55 EDT 2007 -eclipse.preferences.version=1 -encoding/=ISO-8859-1 diff --git a/jpa/plugins/org.eclipse.jpt.gen/.settings/org.eclipse.jdt.core.prefs b/jpa/plugins/org.eclipse.jpt.gen/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 3e1d50ad46..0000000000 --- a/jpa/plugins/org.eclipse.jpt.gen/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -#Sun May 27 14:28:54 EDT 2007 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -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/jpa/plugins/org.eclipse.jpt.gen/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.gen/META-INF/MANIFEST.MF deleted file mode 100644 index 2394380c08..0000000000 --- a/jpa/plugins/org.eclipse.jpt.gen/META-INF/MANIFEST.MF +++ /dev/null @@ -1,15 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: %pluginName -Bundle-Vendor: %providerName -Bundle-SymbolicName: org.eclipse.jpt.gen -Bundle-Version: 1.0.1.qualifier -Bundle-ClassPath: . -Bundle-Localization: plugin -Export-Package: org.eclipse.jpt.gen.internal; x-friends:="org.eclipse.jpt.ui" -Require-Bundle: org.eclipse.core.runtime, - org.eclipse.jdt.core, - org.eclipse.jpt.core, - org.eclipse.jpt.db, - org.eclipse.jpt.utility -Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/jpa/plugins/org.eclipse.jpt.gen/about.html b/jpa/plugins/org.eclipse.jpt.gen/about.html deleted file mode 100644 index 9e73bdabb6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.gen/about.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - -About - - - - - -

About This Content

- -

June 06, 2007

- -

License

- -

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 -http://www.eclipse.org/org/documents/epl-v10.php. -For purposes of the EPL, "Program" will mean the Content.

- -

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 -http://www.eclipse.org/.

- - - diff --git a/jpa/plugins/org.eclipse.jpt.gen/build.properties b/jpa/plugins/org.eclipse.jpt.gen/build.properties deleted file mode 100644 index 41837ebdd1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.gen/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,\ - plugin.properties -jars.compile.order = . diff --git a/jpa/plugins/org.eclipse.jpt.gen/component.xml b/jpa/plugins/org.eclipse.jpt.gen/component.xml deleted file mode 100644 index 7a4e04e21f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.gen/component.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.gen/plugin.properties b/jpa/plugins/org.eclipse.jpt.gen/plugin.properties deleted file mode 100644 index 4875a8b174..0000000000 --- a/jpa/plugins/org.eclipse.jpt.gen/plugin.properties +++ /dev/null @@ -1,24 +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 -############################################################################### -# ==================================================================== -# 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 = Java Persistence API Tools - Entity Gen -providerName = Eclipse.org diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/EntityGenerator.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/EntityGenerator.java deleted file mode 100644 index f1e6b92298..0000000000 --- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/EntityGenerator.java +++ /dev/null @@ -1,1459 +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 - ******************************************************************************/ -package org.eclipse.jpt.gen.internal; - -import java.io.PrintWriter; -import java.io.Serializable; -import java.io.StringWriter; -import java.lang.reflect.Modifier; -import java.text.Collator; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jdt.core.IJavaModelStatusConstants; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jpt.core.internal.content.java.mappings.JPA; -import org.eclipse.jpt.db.internal.Column; -import org.eclipse.jpt.db.internal.ForeignKey; -import org.eclipse.jpt.db.internal.Table; -import org.eclipse.jpt.utility.internal.IndentingPrintWriter; -import org.eclipse.jpt.utility.internal.JavaType; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; - -// TODO handle table names that are illegal class names -// TODO handle table names that are illegal file names -// TODO handle column names that are illegal field/method names -// TODO format code per preferences -// TODO organize imports per preferences -// TODO prompt user to overwrite existing classes -/** - * This generator will generate an entity for a table. - */ -public class EntityGenerator { - final Config config; - private final IPackageFragment packageFragment; - private final GenTable genTable; - private final String entityClassName; - private final OverwriteConfirmer overwriteConfirmer; - private final IProgressMonitor monitor; - private final String pkClassName; - - - // ********** public API ********** - - public static void generateEntity(Config config, IPackageFragment packageFragment, GenTable genTable, OverwriteConfirmer overwriteConfirmer, IProgressMonitor monitor) { - if ((config == null) || (packageFragment == null) || (genTable == null)) { - throw new NullPointerException(); - } - new EntityGenerator(config, packageFragment, genTable, overwriteConfirmer, monitor).generateEntity(); - } - - - // ********** constructor/initialization ********** - - private EntityGenerator(Config config, IPackageFragment packageFragment, GenTable genTable, OverwriteConfirmer overwriteConfirmer, IProgressMonitor monitor) { - super(); - this.config = config; - this.packageFragment = packageFragment; - this.genTable = genTable; - this.entityClassName = this.fullyQualify(this.entityName()); - this.overwriteConfirmer = overwriteConfirmer; - this.monitor = monitor; - this.pkClassName = this.entityClassName + "PK"; // hack - } - - - // ********** code gen ********** - - private void generateEntity() { - int totalWork = pkClassIsGenerated() ? 40 : 20; - try { - this.monitor.beginTask("", totalWork); - this.generateEntity_(); - } catch (JavaModelException ex) { - throw new RuntimeException(ex); - } - finally { - this.monitor.done(); - } - } - - private void generateEntity_() throws JavaModelException { - // build the body source first so we can gather up the import statements - this.generateSourceFile(this.entityClassName, this.entityName() + ".java", this.buildSource(this.buildBodySource())); - if (this.pkClassIsGenerated()) { - this.generateSourceFile(this.pkClassName, this.pkName() + ".java", this.buildSource(this.buildPKBodySource())); - } - - } - - private void generateSourceFile(String className, String fileName, String source) throws JavaModelException { - try { - this.packageFragment.createCompilationUnit(fileName, source, false, new SubProgressMonitor(this.monitor, 10)); - } catch (JavaModelException ex) { - if (ex.getJavaModelStatus().getCode() == IJavaModelStatusConstants.NAME_COLLISION) { - if (this.overwriteConfirmer.overwrite(className)) { - this.packageFragment.createCompilationUnit(fileName, source, true, new SubProgressMonitor(this.monitor, 0)); - } - } else { - throw ex; - } - } - } - - /** - * build the "body" source first; then build the "package" and "imports" source - * and concatenate the "body" source to it - */ - private String buildSource(BodySource bodySource) { - StringWriter sw = new StringWriter(bodySource.length() + 1000); - PrintWriter pw = new PrintWriter(sw); - this.printPackageAndImportsOn(pw, bodySource); - pw.print(bodySource.source()); - this.monitor.worked(10); - return sw.toString(); - } - - private BodySource buildBodySource() { - EntitySourceWriter pw = new EntitySourceWriter(this.packageName(), this.entityClassName); - this.printBodySourceOn(pw); - return pw; - } - - private BodySource buildPKBodySource() { - EntitySourceWriter pw = new EntitySourceWriter(this.packageName(), this.pkClassName); - this.printPrimaryKeyClassOn(pw); - return pw; - } - - private void printBodySourceOn(EntitySourceWriter pw) { - this.printClassDeclarationOn(pw); - - pw.indent(); - this.printEntityPrimaryKeyFieldsOn(pw); - this.printEntityNonPrimaryKeyBasicFieldsOn(pw); - this.printEntityManyToOneFieldsOn(pw); - this.printEntityOneToManyFieldsOn(pw); - this.printEntityOwnedManyToManyFieldsOn(pw); - this.printEntityNonOwnedManyToManyFieldsOn(pw); - this.printSerialVersionUID(pw); - pw.println(); - - this.printZeroArgumentConstructorOn(this.entityName(), this.config.methodVisibility(), pw); - if (this.config.propertyAccessType() || this.config.generateGettersAndSetters()) { - this.printEntityPrimaryKeyGettersAndSettersOn(pw); - this.printEntityNonPrimaryKeyBasicGettersAndSettersOn(pw); - this.printEntityManyToOneGettersAndSettersOn(pw); - this.printEntityOneToManyGettersAndSettersOn(pw); - this.printEntityOwnedManyToManyGettersAndSettersOn(pw); - this.printEntityNonOwnedManyToManyGettersAndSettersOn(pw); - } - pw.undent(); - - pw.print('}'); - pw.println(); - } - - private void printClassDeclarationOn(EntitySourceWriter pw) { - this.printEntityAnnotationOn(pw); - this.printTableAnnotationOn(pw); - this.printIdClassAnnotationOn(pw); - - pw.print("public class "); - pw.printTypeDeclaration(this.entityClassName); - if (config.serializable()) { - pw.print(" implements "); - pw.printTypeDeclaration(Serializable.class.getName()); - } - pw.print(" {"); - pw.println(); - } - - private void printEntityAnnotationOn(EntitySourceWriter pw) { - pw.printAnnotation(JPA.ENTITY); - pw.println(); - } - - private void printTableAnnotationOn(EntitySourceWriter pw) { - if ( ! this.table().matchesShortJavaClassName(this.entityName())) { - pw.printAnnotation(JPA.TABLE); - pw.print("(name=\""); - pw.print(this.table().getName()); - pw.print("\")"); - pw.println(); - } - } - - private void printIdClassAnnotationOn(EntitySourceWriter pw) { - if (this.pkClassIsGenerated() && this.config.generateIdClassForCompoundPK()) { - pw.printAnnotation(JPA.ID_CLASS); - pw.print('('); - pw.printTypeDeclaration(pkClassName); - pw.print(".class)"); - pw.println(); - } - } - - private void printEntityPrimaryKeyFieldsOn(EntitySourceWriter pw) { - if (this.pkClassIsGenerated() && this.config.generateEmbeddedIdForCompoundPK()) { - this.printEntityEmbeddedIdPrimaryKeyFieldOn(pw); - } else { - this.printEntityReadOnlyPrimaryKeyFieldsOn(pw); - this.printEntityWritablePrimaryKeyFieldsOn(pw); - } - } - - private void printEntityEmbeddedIdPrimaryKeyFieldOn(EntitySourceWriter pw) { - if (this.config.fieldAccessType()) { - pw.printAnnotation(JPA.EMBEDDED_ID); - pw.println(); - } - pw.printVisibility(this.config.fieldVisibility()); - pw.printTypeDeclaration(this.pkClassName); - pw.print(' '); - pw.print(this.genTable.fieldNameForEmbeddedId()); - pw.print(';'); - pw.println(); - pw.println(); - } - - private void printEntityReadOnlyPrimaryKeyFieldsOn(EntitySourceWriter pw) { - for (Iterator stream = this.genTable.readOnlyPrimaryKeyColumns(); stream.hasNext(); ) { - this.printEntityReadOnlyPrimaryKeyFieldOn(stream.next(), pw); - } - } - - private void printEntityReadOnlyPrimaryKeyFieldOn(Column column, EntitySourceWriter pw) { - String fieldName = this.genTable.fieldNameFor(column); - if (this.config.fieldAccessType()) { - pw.printAnnotation(JPA.ID); - pw.println(); - if (column.matchesJavaFieldName(fieldName)) { - this.printReadOnlyColumnAnnotationOn(pw); // no Column name needed - } else { - this.printReadOnlyColumnAnnotationOn(column.getName(), pw); - } - } - pw.printVisibility(this.config.fieldVisibility()); - pw.printTypeDeclaration(column.javaTypeDeclaration()); - pw.print(' '); - pw.print(fieldName); - pw.print(';'); - pw.println(); - pw.println(); - } - - private void printReadOnlyColumnAnnotationOn(String columnName, EntitySourceWriter pw) { - pw.printAnnotation(JPA.COLUMN); - pw.print("(name=\""); - pw.print(columnName); - pw.print("\", insertable=false, updatable=false)"); - pw.println(); - } - - private void printReadOnlyColumnAnnotationOn(EntitySourceWriter pw) { - pw.printAnnotation(JPA.COLUMN); - pw.print("(insertable=false, updatable=false)"); - pw.println(); - } - - private void printEntityWritablePrimaryKeyFieldsOn(EntitySourceWriter pw) { - for (Iterator stream = this.genTable.writablePrimaryKeyColumns(); stream.hasNext(); ) { - this.printEntityWritablePrimaryKeyFieldOn(stream.next(), pw); - } - } - - private void printEntityWritablePrimaryKeyFieldOn(Column column, EntitySourceWriter pw) { - String fieldName = this.genTable.fieldNameFor(column); - if (this.config.fieldAccessType()) { - pw.printAnnotation(JPA.ID); - pw.println(); - if ( ! column.matchesJavaFieldName(fieldName)) { - this.printColumnAnnotationOn(column.getName(), pw); - } - } - pw.printVisibility(this.config.fieldVisibility()); - pw.printTypeDeclaration(column.javaTypeDeclaration()); - pw.print(' '); - pw.print(fieldName); - pw.print(';'); - pw.println(); - pw.println(); - } - - private void printEntityNonPrimaryKeyBasicFieldsOn(EntitySourceWriter pw) { - for (Iterator stream = this.genTable.nonPrimaryKeyBasicColumns(); stream.hasNext(); ) { - this.printEntityNonPrimaryKeyBasicFieldOn(stream.next(), pw); - } - } - - private void printEntityNonPrimaryKeyBasicFieldOn(Column column, EntitySourceWriter pw) { - String fieldName = this.genTable.fieldNameFor(column); - if (this.config.fieldAccessType()) { - if ( ! column.matchesJavaFieldName(fieldName)) { - this.printColumnAnnotationOn(column.getName(), pw); - } - } - if (column.isLob()) { - pw.printAnnotation(JPA.LOB); - pw.println(); - } - pw.printVisibility(this.config.fieldVisibility()); - pw.printTypeDeclaration(column.javaTypeDeclaration()); - pw.print(' '); - pw.print(fieldName); - pw.print(';'); - pw.println(); - pw.println(); - } - - private void printColumnAnnotationOn(String columnName, EntitySourceWriter pw) { - pw.printAnnotation(JPA.COLUMN); - pw.print("(name=\""); - pw.print(columnName); - pw.print("\")"); - pw.println(); - } - - private void printEntityManyToOneFieldsOn(EntitySourceWriter pw) { - for (Iterator stream = this.genTable.manyToOneRelations(); stream.hasNext(); ) { - this.printEntityManyToOneFieldOn(stream.next(), pw); - } - } - - private void printEntityManyToOneFieldOn(ManyToOneRelation relation, EntitySourceWriter pw) { - String fieldName = this.genTable.fieldNameFor(relation); - if (this.config.fieldAccessType()) { - this.printManyToOneAnnotationOn(fieldName, relation, pw); - } - pw.printVisibility(this.config.fieldVisibility()); - pw.printTypeDeclaration(this.fullyQualify(relation.referencedEntityName())); - pw.print(' '); - pw.print(fieldName); - pw.print(';'); - pw.println(); - pw.println(); - } - - private void printManyToOneAnnotationOn(String fieldName, ManyToOneRelation relation, EntitySourceWriter pw) { - pw.printAnnotation(JPA.MANY_TO_ONE); - pw.println(); - ForeignKey fk = relation.getForeignKey(); - if (fk.matchesJavaFieldName(fieldName)) { - return; // no JoinColumn annotation needed - } - if (fk.referencesSingleColumnPrimaryKey()) { - pw.printAnnotation(JPA.JOIN_COLUMN); - pw.print("(name=\""); - pw.print(fk.columnPairs().next().getBaseColumn().getName()); - pw.print("\")"); - } else { - if (fk.columnPairsSize() > 1) { - pw.printAnnotation(JPA.JOIN_COLUMNS); - pw.print("({"); - pw.println(); - pw.indent(); - } - this.printJoinColumnAnnotationsOn(fk, pw); - if (fk.columnPairsSize() > 1) { - pw.undent(); - pw.println(); - pw.print("})"); - } - } - pw.println(); - } - - private void printJoinColumnAnnotationsOn(ForeignKey foreignKey, EntitySourceWriter pw) { - for (Iterator stream = foreignKey.columnPairs(); stream.hasNext(); ) { - this.printJoinColumnAnnotationOn(stream.next(), pw); - if (stream.hasNext()) { - pw.println(','); - } - } - } - - private void printJoinColumnAnnotationOn(ForeignKey.ColumnPair columnPair, EntitySourceWriter pw) { - this.printJoinColumnAnnotationOn(columnPair.getBaseColumn().getName(), columnPair.getReferencedColumn().getName(), pw); - } - - /** - * assume that at least one of the two names is not null - */ - private void printJoinColumnAnnotationOn(String baseColumnName, String referencedColumnName, EntitySourceWriter pw) { - pw.printAnnotation(JPA.JOIN_COLUMN); - pw.print('('); - if (baseColumnName != null) { - pw.print("name=\""); - pw.print(baseColumnName); - } - if (referencedColumnName != null) { - if (baseColumnName != null) { - pw.print("\", "); - } - pw.print("referencedColumnName=\""); - pw.print(referencedColumnName); - } - pw.print("\")"); - } - - private void printEntityOneToManyFieldsOn(EntitySourceWriter pw) { - for (Iterator stream = this.genTable.oneToManyRelations(); stream.hasNext(); ) { - this.printEntityOneToManyFieldOn(stream.next(), pw); - } - } - - private void printEntityOneToManyFieldOn(OneToManyRelation relation, EntitySourceWriter pw) { - String fieldName = this.genTable.fieldNameFor(relation); - if (this.config.fieldAccessType()) { - this.printOneToManyAnnotationOn(fieldName, relation, pw); - } - pw.printVisibility(this.config.fieldVisibility()); - pw.printTypeDeclaration(this.config.getCollectionTypeName()); - pw.print('<'); - pw.printTypeDeclaration(this.fullyQualify(relation.referencedEntityName())); - pw.print('>'); - pw.print(' '); - pw.print(fieldName); - pw.print(';'); - pw.println(); - pw.println(); - } - - private void printOneToManyAnnotationOn(String fieldName, OneToManyRelation relation, EntitySourceWriter pw) { - pw.printAnnotation(JPA.ONE_TO_MANY); - pw.print("(mappedBy=\""); - pw.print(relation.mappedBy()); - pw.print("\")"); - pw.println(); - } - - private void printEntityOwnedManyToManyFieldsOn(EntitySourceWriter pw) { - for (Iterator stream = this.genTable.ownedManyToManyRelations(); stream.hasNext(); ) { - this.printEntityOwnedManyToManyFieldOn(stream.next(), pw); - } - } - - private void printEntityOwnedManyToManyFieldOn(ManyToManyRelation relation, EntitySourceWriter pw) { - String fieldName = this.genTable.fieldNameFor(relation); - if (this.config.fieldAccessType()) { - this.printOwnedManyToManyAnnotationOn(fieldName, relation, pw); - } - pw.printVisibility(this.config.fieldVisibility()); - pw.printTypeDeclaration(this.config.getCollectionTypeName()); - pw.print('<'); - pw.printTypeDeclaration(this.fullyQualify(relation.nonOwningEntityName())); - pw.print('>'); - pw.print(' '); - pw.print(fieldName); - pw.print(';'); - pw.println(); - pw.println(); - } - - /** - * I guess you could build a state machine for all this crap, - * but that seems like overkill... - */ - private void printOwnedManyToManyAnnotationOn(String fieldName, ManyToManyRelation relation, EntitySourceWriter pw) { - pw.printAnnotation(JPA.MANY_TO_MANY); - pw.println(); - boolean first = true; - boolean comma = false; - if ( ! relation.joinTableNameIsDefault()) { - if (first) { - first = false; - pw.printAnnotation(JPA.JOIN_TABLE); - pw.print('('); - } - pw.print("name=\""); - pw.print(relation.getJoinTable().name()); - pw.print('\"'); - comma = true; - } - if ( ! relation.joinColumnsIsDefaultFor(fieldName)) { - if (first) { - first = false; - pw.printAnnotation(JPA.JOIN_TABLE); - pw.print('('); - } else if (comma) { - pw.print(','); - } - pw.println(); - pw.indent(); - this.printJoinTableJoinColumnsOn("joinColumns", fieldName, relation.getOwningForeignKey(), pw); - pw.undent(); - comma = true; - } - String inverseFieldName = relation.getNonOwningTable().fieldNameFor(relation); - if ( ! relation.inverseJoinColumnsIsDefaultFor(inverseFieldName)) { - if (first) { - first = false; - pw.printAnnotation(JPA.JOIN_TABLE); - pw.print('('); - } else if (comma) { - pw.print(','); - } - pw.println(); - pw.indent(); - this.printJoinTableJoinColumnsOn("inverseJoinColumns", inverseFieldName, relation.getNonOwningForeignKey(), pw); - pw.undent(); - comma = true; - } - if ( ! first) { - pw.print(')'); - } - pw.println(); - } - - private void printJoinTableJoinColumnsOn(String elementName, String fieldName, ForeignKey foreignKey, EntitySourceWriter pw) { - if (foreignKey.columnPairsSize() != 1) { - this.printJoinTableJoinColumnsOn(elementName, foreignKey, pw); - } else if (foreignKey.getReferencedTable().primaryKeyColumnsSize() != 1) { - // if the referenced table has a composite primary key, neither of the columns can be a default - // since both of the defaults require a single-column primary key - this.printJoinTableJoinColumnsOn(elementName, foreignKey, pw); - } else { - ForeignKey.ColumnPair columnPair = foreignKey.columnPairs().next(); - Column pkColumn = foreignKey.getReferencedTable().primaryKeyColumns().next(); - if (columnPair.getBaseColumn().matchesJavaFieldName(fieldName + "_" + pkColumn.getName())) { - if (columnPair.getReferencedColumn() == pkColumn) { - // we shouldn't get here... - } else { - pw.print(elementName); - pw.print('='); - this.printJoinColumnAnnotationOn(null, columnPair.getReferencedColumn().getName(), pw); - } - } else { - if (columnPair.getReferencedColumn() == pkColumn) { - pw.print(elementName); - pw.print('='); - this.printJoinColumnAnnotationOn(columnPair.getBaseColumn().getName(), null, pw); - } else { - this.printJoinTableJoinColumnsOn(elementName, foreignKey, pw); - } - } - } - } - - private void printJoinTableJoinColumnsOn(String elementName, ForeignKey foreignKey, EntitySourceWriter pw) { - pw.print(elementName); - pw.print('='); - if (foreignKey.columnPairsSize() > 1) { - pw.print('{'); - pw.println(); - pw.indent(); - } - this.printJoinColumnAnnotationsOn(foreignKey, pw); - if (foreignKey.columnPairsSize() > 1) { - pw.undent(); - pw.println(); - pw.print('}'); - pw.println(); - } - } - - private void printEntityNonOwnedManyToManyFieldsOn(EntitySourceWriter pw) { - for (Iterator stream = this.genTable.nonOwnedManyToManyRelations(); stream.hasNext(); ) { - this.printEntityNonOwnedManyToManyFieldOn(stream.next(), pw); - } - } - - private void printEntityNonOwnedManyToManyFieldOn(ManyToManyRelation relation, EntitySourceWriter pw) { - String fieldName = this.genTable.fieldNameFor(relation); - if (this.config.fieldAccessType()) { - this.printNonOwnedManyToManyAnnotationOn(fieldName, relation, pw); - } - pw.printVisibility(this.config.fieldVisibility()); - pw.printTypeDeclaration(this.config.getCollectionTypeName()); - pw.print('<'); - pw.printTypeDeclaration(this.fullyQualify(relation.owningEntityName())); - pw.print('>'); - pw.print(' '); - pw.print(fieldName); - pw.print(';'); - pw.println(); - pw.println(); - } - - private void printNonOwnedManyToManyAnnotationOn(String fieldName, ManyToManyRelation relation, EntitySourceWriter pw) { - pw.printAnnotation(JPA.MANY_TO_MANY); - pw.print("(mappedBy=\""); - pw.print(relation.getMappedBy()); - pw.print("\")"); - pw.println(); - } - - private String fullyQualify(String shortClassName) { - String pkg = this.packageName(); - return (pkg.length() == 0) ? shortClassName : pkg + '.' + shortClassName; - } - - private void printSerialVersionUID(EntitySourceWriter pw) { - if (this.config.generateSerialVersionUID()) { - pw.print("private static final long serialVersionUID = 1L;"); - pw.println(); - } - } - - private void printZeroArgumentConstructorOn(String ctorName, String visibility, EntitySourceWriter pw) { - if (this.config.generateDefaultConstructor()) { - pw.printVisibility(visibility); - pw.print(ctorName); - pw.print("() {"); - pw.println(); - pw.indent(); - pw.println("super();"); - pw.undent(); - pw.print('}'); - pw.println(); - pw.println(); - } - } - - private void printEntityPrimaryKeyGettersAndSettersOn(EntitySourceWriter pw) { - if (this.pkClassIsGenerated() && this.config.generateEmbeddedIdForCompoundPK()) { - this.printEntityEmbeddedIdPrimaryKeyGetterAndSetterOn(pw); - } else { - this.printEntityReadOnlyPrimaryKeyGettersAndSettersOn(pw); - this.printEntityWritablePrimaryKeyGettersAndSettersOn(pw); - } - } - - private void printEntityEmbeddedIdPrimaryKeyGetterAndSetterOn(EntitySourceWriter pw) { - if (this.config.propertyAccessType()) { - pw.printAnnotation(JPA.EMBEDDED_ID); - pw.println(); - } - pw.printGetterAndSetter(this.genTable.fieldNameForEmbeddedId(), this.pkClassName, this.config.methodVisibility()); - } - - private void printEntityReadOnlyPrimaryKeyGettersAndSettersOn(EntitySourceWriter pw) { - for (Iterator stream = this.genTable.readOnlyPrimaryKeyColumns(); stream.hasNext(); ) { - this.printEntityReadOnlyPrimaryKeyGetterAndSetterOn(stream.next(), pw); - } - } - - private void printEntityReadOnlyPrimaryKeyGetterAndSetterOn(Column column, EntitySourceWriter pw) { - String propertyName = this.genTable.fieldNameFor(column); - if (this.config.propertyAccessType()) { - pw.printAnnotation(JPA.ID); - pw.println(); - if (column.matchesJavaFieldName(propertyName)) { - this.printReadOnlyColumnAnnotationOn(pw); // no Column name needed - } else { - this.printReadOnlyColumnAnnotationOn(column.getName(), pw); - } - } - - pw.printGetterAndSetter(propertyName, column.javaTypeDeclaration(), this.config.methodVisibility()); - } - - private void printEntityWritablePrimaryKeyGettersAndSettersOn(EntitySourceWriter pw) { - for (Iterator stream = this.genTable.writablePrimaryKeyColumns(); stream.hasNext(); ) { - this.printEntityWritablePrimaryKeyGetterAndSetterOn(stream.next(), pw); - } - } - - private void printEntityWritablePrimaryKeyGetterAndSetterOn(Column column, EntitySourceWriter pw) { - String propertyName = this.genTable.fieldNameFor(column); - if (this.config.propertyAccessType()) { - pw.printAnnotation(JPA.ID); - pw.println(); - if ( ! column.matchesJavaFieldName(propertyName)) { - this.printColumnAnnotationOn(column.getName(), pw); - } - } - - pw.printGetterAndSetter(propertyName, column.javaTypeDeclaration(), this.config.methodVisibility()); - } - - private void printEntityNonPrimaryKeyBasicGettersAndSettersOn(EntitySourceWriter pw) { - for (Iterator stream = this.genTable.nonPrimaryKeyBasicColumns(); stream.hasNext(); ) { - this.printEntityNonPrimaryKeyBasicGetterAndSetterOn(stream.next(), pw); - } - } - - private void printEntityNonPrimaryKeyBasicGetterAndSetterOn(Column column, EntitySourceWriter pw) { - String propertyName = this.genTable.fieldNameFor(column); - if (this.config.propertyAccessType()) { - if ( ! column.matchesJavaFieldName(propertyName)) { - this.printColumnAnnotationOn(column.getName(), pw); - } - } - - pw.printGetterAndSetter(propertyName, column.javaTypeDeclaration(), this.config.methodVisibility()); - } - - private void printEntityManyToOneGettersAndSettersOn(EntitySourceWriter pw) { - for (Iterator stream = this.genTable.manyToOneRelations(); stream.hasNext(); ) { - this.printEntityManyToOneGetterAndSetterOn(stream.next(), pw); - } - } - - private void printEntityManyToOneGetterAndSetterOn(ManyToOneRelation relation, EntitySourceWriter pw) { - String propertyName = this.genTable.fieldNameFor(relation); - if (this.config.propertyAccessType()) { - this.printManyToOneAnnotationOn(propertyName, relation, pw); - } - - String typeDeclaration = this.fullyQualify(relation.referencedEntityName()); - pw.printGetterAndSetter(propertyName, typeDeclaration, this.config.methodVisibility()); - } - - private void printEntityOneToManyGettersAndSettersOn(EntitySourceWriter pw) { - for (Iterator stream = this.genTable.oneToManyRelations(); stream.hasNext(); ) { - this.printEntityOneToManyGetterAndSetterOn(stream.next(), pw); - } - } - - private void printEntityOneToManyGetterAndSetterOn(OneToManyRelation relation, EntitySourceWriter pw) { - String propertyName = this.genTable.fieldNameFor(relation); - if (this.config.propertyAccessType()) { - this.printOneToManyAnnotationOn(propertyName, relation, pw); - } - - String elementTypeDeclaration = this.fullyQualify(relation.referencedEntityName()); - pw.printCollectionGetterAndSetter(propertyName, this.config.getCollectionTypeName(), elementTypeDeclaration, this.config.methodVisibility()); - } - - private void printEntityOwnedManyToManyGettersAndSettersOn(EntitySourceWriter pw) { - for (Iterator stream = this.genTable.ownedManyToManyRelations(); stream.hasNext(); ) { - this.printEntityOwnedManyToManyGetterAndSetterOn(stream.next(), pw); - } - } - - private void printEntityOwnedManyToManyGetterAndSetterOn(ManyToManyRelation relation, EntitySourceWriter pw) { - String propertyName = this.genTable.fieldNameFor(relation); - if (this.config.propertyAccessType()) { - this.printOwnedManyToManyAnnotationOn(propertyName, relation, pw); - } - - String elementTypeDeclaration = this.fullyQualify(relation.nonOwningEntityName()); - pw.printCollectionGetterAndSetter(propertyName, this.config.getCollectionTypeName(), elementTypeDeclaration, this.config.methodVisibility()); - } - - private void printEntityNonOwnedManyToManyGettersAndSettersOn(EntitySourceWriter pw) { - for (Iterator stream = this.genTable.nonOwnedManyToManyRelations(); stream.hasNext(); ) { - this.printEntityNonOwnedManyToManyGetterAndSetterOn(stream.next(), pw); - } - } - - private void printEntityNonOwnedManyToManyGetterAndSetterOn(ManyToManyRelation relation, EntitySourceWriter pw) { - String propertyName = this.genTable.fieldNameFor(relation); - if (this.config.propertyAccessType()) { - this.printNonOwnedManyToManyAnnotationOn(propertyName, relation, pw); - } - - String elementTypeDeclaration = this.fullyQualify(relation.owningEntityName()); - pw.printCollectionGetterAndSetter(propertyName, this.config.getCollectionTypeName(), elementTypeDeclaration, this.config.methodVisibility()); - } - - private void printPrimaryKeyClassOn(EntitySourceWriter pw) { - if (this.config.generateEmbeddedIdForCompoundPK()) { - pw.printAnnotation(JPA.EMBEDDABLE); - pw.println(); - } - pw.print("public class "); - pw.printTypeDeclaration(this.pkClassName); - pw.print(" implements "); - pw.printTypeDeclaration(Serializable.class.getName()); - pw.print(" {"); - pw.println(); - - pw.indent(); - this.printIdFieldsOn(pw); - this.printSerialVersionUID(pw); - pw.println(); - this.printZeroArgumentConstructorOn(this.pkName(), "public", pw); - - if (this.config.propertyAccessType() || this.config.generateGettersAndSetters()) { - this.printIdGettersAndSettersOn(pw); - } - - this.printEqualsMethodOn(this.pkName(), this.table().primaryKeyColumns(), pw); - this.printHashCodeMethodOn(this.table().primaryKeyColumns(), pw); - pw.undent(); - - pw.print('}'); - pw.println(); - } - - private void printIdFieldsOn(EntitySourceWriter pw) { - for (Iterator stream = this.table().primaryKeyColumns(); stream.hasNext(); ) { - this.printIdFieldOn(stream.next(), pw); - } - } - - private void printIdFieldOn(Column column, EntitySourceWriter pw) { - String fieldName = this.genTable.fieldNameFor(column); - pw.printVisibility(this.config.fieldVisibility()); - pw.printTypeDeclaration(column.javaTypeDeclaration()); - pw.print(' '); - pw.print(fieldName); - pw.print(';'); - pw.println(); - } - - private void printIdGettersAndSettersOn(EntitySourceWriter pw) { - for (Iterator stream = this.table().primaryKeyColumns(); stream.hasNext(); ) { - this.printIdGetterAndSetterOn(stream.next(), pw); - } - } - - private void printIdGetterAndSetterOn(Column column, EntitySourceWriter pw) { - String propertyName = this.genTable.fieldNameFor(column); - pw.printGetterAndSetter(propertyName, column.javaTypeDeclaration(), this.config.methodVisibility()); - } - - private void printEqualsMethodOn(String className, Iterator columns, EntitySourceWriter pw) { - pw.printAnnotation("java.lang.Override"); - pw.println(); - - pw.println("public boolean equals(Object o) {"); - pw.indent(); - pw.println("if (o == this) {"); - pw.indent(); - pw.println("return true;"); - pw.undent(); - pw.print('}'); - pw.println(); - - pw.print("if ( ! (o instanceof "); - pw.print(className); - pw.print(")) {"); - pw.println(); - pw.indent(); - pw.println("return false;"); - pw.undent(); - pw.print('}'); - pw.println(); - - pw.print(className); - pw.print(" other = ("); - pw.print(className); - pw.print(") o;"); - pw.println(); - - pw.print("return "); - pw.indent(); - while (columns.hasNext()) { - this.printEqualsClauseOn(columns.next(), pw); - if (columns.hasNext()) { - pw.println(); - pw.print("&& "); - } - } - pw.print(';'); - pw.println(); - pw.undent(); - pw.undent(); - pw.print('}'); - pw.println(); - pw.println(); - } - - private void printEqualsClauseOn(Column column, EntitySourceWriter pw) { - String fieldName = this.genTable.fieldNameFor(column); - JavaType javaType = column.javaType(); - if (javaType.isPrimitive()) { - this.printPrimitiveEqualsClauseOn(fieldName, pw); - } else { - this.printReferenceEqualsClauseOn(fieldName, pw); - } - } - - private void printPrimitiveEqualsClauseOn(String fieldName, EntitySourceWriter pw) { - pw.print("(this."); - pw.print(fieldName); - pw.print(" == other."); - pw.print(fieldName); - pw.print(')'); - } - - private void printReferenceEqualsClauseOn(String fieldName, EntitySourceWriter pw) { - pw.print("this."); - pw.print(fieldName); - pw.print(".equals(other."); - pw.print(fieldName); - pw.print(')'); - } - - private void printHashCodeMethodOn(Iterator columns, EntitySourceWriter pw) { - pw.printAnnotation("java.lang.Override"); - pw.println(); - - pw.println("public int hashCode() {"); - pw.indent(); - pw.print("return "); - pw.indent(); - while (columns.hasNext()) { - this.printHashCodeClauseOn(columns.next(), pw); - if (columns.hasNext()) { - pw.println(); - pw.print("^ "); - } - } - pw.print(';'); - pw.println(); - pw.undent(); - pw.undent(); - pw.print('}'); - pw.println(); - pw.println(); - } - - private void printHashCodeClauseOn(Column column, EntitySourceWriter pw) { - String fieldName = this.genTable.fieldNameFor(column); - JavaType javaType = column.javaType(); - if (javaType.isPrimitive()) { - this.printPrimitiveHashCodeClauseOn(javaType.getElementTypeName(), fieldName, pw); - } else { - this.printReferenceHashCodeClauseOn(fieldName, pw); - } - } - - private void printPrimitiveHashCodeClauseOn(String primitiveName, String fieldName, EntitySourceWriter pw) { - if (primitiveName.equals("int") || primitiveName.equals("short") || primitiveName.equals("byte") || primitiveName.equals("char")) { - pw.print("this."); - pw.print(fieldName); - } else if (primitiveName.equals("long")) { // cribbed from Long#hashCode() - // ((int) (this.value ^ (this.value >>> 32))) - pw.print("((int) (this."); - pw.print(fieldName); - pw.print(" ^ (this."); - pw.print(fieldName); - pw.print(" >>> 32)))"); - } else if (primitiveName.equals("double")) { // cribbed from Double#hashCode() - // ((int) (java.lang.Double.doubleToLongBits(this.value) ^ (java.lang.Double.doubleToLongBits(this.value) >>> 32))) - pw.print("((int) ("); - pw.printTypeDeclaration("java.lang.Double"); - pw.print(".doubleToLongBits(this."); - pw.print(fieldName); - pw.print(") ^ ("); - pw.printTypeDeclaration("java.lang.Double"); - pw.print(".doubleToLongBits(this."); - pw.print(fieldName); - pw.print(") >>> 32)))"); - } else if (primitiveName.equals("float")) { // cribbed from Float#hashCode() - // java.lang.Float.floatToIntBits(this.value) - pw.printTypeDeclaration("java.lang.Float"); - pw.print(".floatToIntBits(this."); - pw.print(fieldName); - pw.print(')'); - } else if (primitiveName.equals("boolean")) { // cribbed from Boolean#hashCode() - // (this.value ? 1231 : 1237) - pw.print("(this."); - pw.print(fieldName); - pw.print(" ? 1231 : 1237)"); - } else { - throw new IllegalArgumentException(primitiveName); - } - } - - private void printReferenceHashCodeClauseOn(String fieldName, EntitySourceWriter pw) { - pw.print("this."); - pw.print(fieldName); - pw.print(".hashCode()"); - } - - private void printPackageAndImportsOn(PrintWriter pw, BodySource bodySource) { - if (this.packageName().length() != 0) { - pw.print("package "); - pw.print(this.packageName()); - pw.print(';'); - pw.println(); - pw.println(); - } - - for (Iterator> stream = bodySource.importEntries(); stream.hasNext(); ) { - Map.Entry entry = stream.next(); - pw.print("import "); - pw.print(entry.getValue()); // package - pw.print('.'); - pw.print(entry.getKey()); // short class name - pw.print(';'); - pw.println(); - } - pw.println(); - } - - - // ********** convenience methods ********** - - private String packageName() { - return this.packageFragment.getElementName(); - } - - private Table table() { - return this.genTable.getTable(); - } - - private String entityName() { - return this.genTable.getEntityName(); - } - - private String pkName() { - return this.entityName() + "PK"; // hack - } - - private boolean pkClassIsGenerated() { - return this.table().primaryKeyColumnsSize() > 1; - } - - - // ********** writer ********** - - private interface BodySource { - - /** - * return a sorted set of map entries; the key is the short class name, - * the value is the package name - */ - Iterator> importEntries(); - - /** - * return the body source code - */ - String source(); - - /** - * return the length of the body source code - */ - int length(); - - } - - /** - * Extend IndentingPrintWriter with some methods that facilitate building - * class source code. - */ - private static class EntitySourceWriter extends IndentingPrintWriter implements BodySource { - final String packageName; - final String className; - // key = short class name; value = package name - private final Map imports = new HashMap(); - - EntitySourceWriter(String packageName, String className) { - super(new StringWriter(20000)); - this.packageName = packageName; - this.className = className; - } - - void printVisibility(String visibilityModifier) { - if (visibilityModifier.length() != 0) { - this.print(visibilityModifier); - this.print(' '); - } - } - - void printAnnotation(String annotationName) { - this.print('@'); - this.printTypeDeclaration(annotationName); - } - - void printTypeDeclaration(String typeDeclaration) { - this.print(this.importedTypeDeclaration(typeDeclaration)); - } - - /** - * 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;") - */ - private String importedTypeDeclaration(String typeDeclaration) { - if (this.typeDeclarationIsMemberClass(typeDeclaration)) { - // no need for an import, just return the partially-qualified name - return this.memberClassTypeDeclaration(typeDeclaration); - } - int last = typeDeclaration.lastIndexOf('.'); - String pkg = (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); - } - String prev = this.imports.get(shortElementTypeName); - if (prev == null) { - // this is the first class with this short element type name - this.imports.put(shortElementTypeName, pkg); - return shortTypeDeclaration; - } - if (prev.equals(pkg)) { - // this element type has already been imported - return shortTypeDeclaration; - } - // 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 - */ - private 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") - */ - private String memberClassTypeDeclaration(String typeDeclaration) { - int index = this.packageName.length(); - if (index != 0) { - index++; // bump past the '.' - } - return typeDeclaration.substring(index); - } - - public Iterator> importEntries() { - return new FilteringIterator>(this.sortedImportEntries()) { - @Override - protected boolean accept(Object next) { - @SuppressWarnings("unchecked") - String pkg = ((Map.Entry) next).getValue(); - if (pkg.equals("") - || pkg.equals("java.lang") - || pkg.equals(EntitySourceWriter.this.packageName)) { - return false; - } - return true; - } - }; - } - - private Iterator> sortedImportEntries() { - TreeSet> sortedImports = new TreeSet>(this.buildImportEntriesComparator()); - sortedImports.addAll(this.imports.entrySet()); - return sortedImports.iterator(); - } - - private Comparator> buildImportEntriesComparator() { - return new Comparator>() { - public int compare(Map.Entry e1, Map.Entry e2) { - Collator collator = Collator.getInstance(); - int pkg = collator.compare(e1.getValue(), e2.getValue()); - return (pkg == 0) ? collator.compare(e1.getKey(), e2.getKey()) : pkg; - } - }; - } - - void printGetterAndSetter(String propertyName, String typeDeclaration, String visibility) { - this.printGetter(propertyName, typeDeclaration, visibility); - this.println(); - this.println(); - - this.printSetter(propertyName, typeDeclaration, visibility); - this.println(); - this.println(); - } - - private void printGetter(String propertyName, String typeDeclaration, String visibility) { - this.printVisibility(visibility); - this.printTypeDeclaration(typeDeclaration); - this.print(' '); - this.print(typeDeclaration.equals("boolean") ? "is" : "get"); - this.print(StringTools.capitalize(propertyName)); - this.print("() {"); - this.println(); - - this.indent(); - this.print("return this."); - this.print(propertyName); - this.print(';'); - this.println(); - this.undent(); - - this.print('}'); - } - - private void printSetter(String propertyName, String typeDeclaration, String visibility) { - this.printVisibility(visibility); - this.print("void set"); - this.print(StringTools.capitalize(propertyName)); - this.print('('); - this.printTypeDeclaration(typeDeclaration); - this.print(' '); - this.print(propertyName); - this.print(") {"); - this.println(); - - this.indent(); - this.print("this."); - this.print(propertyName); - this.print(" = "); - this.print(propertyName); - this.print(';'); - this.println(); - this.undent(); - - this.print('}'); - } - - void printCollectionGetterAndSetter(String propertyName, String collectionTypeDeclaration, String elementTypeDeclaration, String visibility) { - this.printCollectionGetter(propertyName, collectionTypeDeclaration, elementTypeDeclaration, visibility); - this.println(); - this.println(); - - this.printCollectionSetter(propertyName, collectionTypeDeclaration, elementTypeDeclaration, visibility); - this.println(); - this.println(); - } - - private void printCollectionGetter(String propertyName, String collectionTypeDeclaration, String elementTypeDeclaration, String visibility) { - this.printVisibility(visibility); - this.printTypeDeclaration(collectionTypeDeclaration); - this.print('<'); - this.printTypeDeclaration(elementTypeDeclaration); - this.print("> get"); - this.print(StringTools.capitalize(propertyName)); - this.print("() {"); - this.println(); - - this.indent(); - this.print("return this."); - this.print(propertyName); - this.print(';'); - this.println(); - this.undent(); - - this.print('}'); - } - - private void printCollectionSetter(String propertyName, String collectionTypeDeclaration, String elementTypeDeclaration, String visibility) { - this.printVisibility(visibility); - this.print("void set"); - this.print(StringTools.capitalize(propertyName)); - this.print('('); - this.printTypeDeclaration(collectionTypeDeclaration); - this.print('<'); - this.printTypeDeclaration(elementTypeDeclaration); - this.print('>'); - this.print(' '); - this.print(propertyName); - this.print(") {"); - this.println(); - - this.indent(); - this.print("this."); - this.print(propertyName); - this.print(" = "); - this.print(propertyName); - this.print(';'); - this.println(); - this.undent(); - - this.print('}'); - } - - public String source() { - return this.out.toString(); - } - - public int length() { - return ((StringWriter) this.out).getBuffer().length(); - } - - } - - - // ********** config ********** - - public static class Config { - private boolean convertToCamelCase = true; - private boolean propertyAccessType = false; // as opposed to "field" - private String collectionTypeName = Set.class.getName(); - private int fieldVisibility = Modifier.PRIVATE; - private int methodVisibility = Modifier.PUBLIC; - private boolean generateGettersAndSetters = true; - private boolean generateDefaultConstructor = true; - private boolean serializable = true; - private boolean generateSerialVersionUID = true; - private boolean generateEmbeddedIdForCompoundPK = true; // as opposed to IdClass - private Map overrideEntityNames = new HashMap(); - - public static final int PRIVATE = 0; - public static final int PACKAGE = 1; - public static final int PROTECTED = 2; - public static final int PUBLIC = 3; - - - public boolean convertToCamelCase() { - return this.convertToCamelCase; - } - public void setConvertToCamelCase(boolean convertToCamelCase) { - this.convertToCamelCase = convertToCamelCase; - } - - public boolean propertyAccessType() { - return this.propertyAccessType; - } - public void setPropertyAccessType(boolean propertyAccessType) { - this.propertyAccessType = propertyAccessType; - } - - public boolean fieldAccessType() { - return ! this.propertyAccessType; - } - public void setFieldAccessType(boolean fieldAccessType) { - this.propertyAccessType = ! fieldAccessType; - } - - public String getCollectionTypeName() { - return this.collectionTypeName; - } - public void setCollectionTypeName(String collectionTypeName) { - this.collectionTypeName = collectionTypeName; - } - - public int getFieldVisibility() { - return this.fieldVisibility; - } - /** entity fields cannot be 'public' */ - public void setFieldVisibility(int fieldVisibility) { - switch (fieldVisibility) { - case PRIVATE: - case PACKAGE: - case PROTECTED: - this.fieldVisibility = fieldVisibility; - break; - default: - throw new IllegalArgumentException("invalid field visibility: " + fieldVisibility); - } - } - String fieldVisibility() { - switch (this.fieldVisibility) { - case PRIVATE: - return "private"; - case PACKAGE: - return ""; - case PROTECTED: - return "protected"; - default: - throw new IllegalStateException("invalid field visibility: " + this.fieldVisibility); - } - } - - public int getMethodVisibility() { - return this.methodVisibility; - } - /** entity properties must be 'public' or 'protected' */ - public void setMethodVisibility(int methodVisibility) { - switch (methodVisibility) { - case PROTECTED: - case PUBLIC: - this.methodVisibility = methodVisibility; - break; - default: - throw new IllegalArgumentException("invalid method visibility: " + methodVisibility); - } - } - String methodVisibility() { - switch (this.methodVisibility) { - case PROTECTED: - return "protected"; - case PUBLIC: - return "public"; - default: - throw new IllegalStateException("invalid method visibility: " + this.methodVisibility); - } - } - - public boolean generateGettersAndSetters() { - return this.generateGettersAndSetters; - } - public void setGenerateGettersAndSetters(boolean generateGettersAndSetters) { - this.generateGettersAndSetters = generateGettersAndSetters; - } - - public boolean generateDefaultConstructor() { - return this.generateDefaultConstructor; - } - public void setGenerateDefaultConstructor(boolean generateDefaultConstructor) { - this.generateDefaultConstructor = generateDefaultConstructor; - } - - public boolean serializable() { - return this.serializable; - } - public void setSerializable(boolean serializable) { - this.serializable = serializable; - } - - public boolean generateSerialVersionUID() { - return this.generateSerialVersionUID; - } - public void setGenerateSerialVersionUID(boolean generateSerialVersionUID) { - this.generateSerialVersionUID = generateSerialVersionUID; - } - - public boolean generateEmbeddedIdForCompoundPK() { - return this.generateEmbeddedIdForCompoundPK; - } - public void setGenerateEmbeddedIdForCompoundPK(boolean generateEmbeddedIdForCompoundPK) { - this.generateEmbeddedIdForCompoundPK = generateEmbeddedIdForCompoundPK; - } - - public boolean generateIdClassForCompoundPK() { - return ! this.generateEmbeddedIdForCompoundPK; - } - public void setGenerateIdClassForCompoundPK(boolean generateIdClassForCompoundPK) { - this.generateEmbeddedIdForCompoundPK = ! generateIdClassForCompoundPK; - } - - /** - * key = table - * value = user-supplied override entity name - */ - public String getOverrideEntityName(Table table) { - return this.overrideEntityNames.get(table); - } - public void setOverrideEntityName(Table table, String overrideEntityName) { - this.overrideEntityNames.put(table, overrideEntityName); - } - public void clearOverrideEntityNames() { - this.overrideEntityNames.clear(); - } - public void setOverrideEntityNames(Map overrideEntityNames) { - this.clearOverrideEntityNames(); - for (Map.Entry entry : overrideEntityNames.entrySet()) { - this.setOverrideEntityName(entry.getKey(), entry.getValue()); - } - } - - } - - - // ********** config ********** - - public static interface OverwriteConfirmer { - /** - * Return whether the entity generator should overwrite the specified - * file. - */ - boolean overwrite(String className); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/GenScope.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/GenScope.java deleted file mode 100644 index f5b07dcf64..0000000000 --- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/GenScope.java +++ /dev/null @@ -1,181 +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 - ******************************************************************************/ -package org.eclipse.jpt.gen.internal; - -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.jpt.db.internal.Table; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; - -class GenScope { - private final Map genTables = new HashMap(); - - private IProgressMonitor progressMonitor; - - // ********** construction/initialization ********** - - GenScope(Collection tables, EntityGenerator.Config entityConfig, IProgressMonitor progressMonitor) { - super(); - this.initialize(tables, entityConfig, progressMonitor); - } - - private void checkCanceled() { - if (this.progressMonitor.isCanceled()) { - throw new OperationCanceledException(); - } - } - - private void initialize(Collection
tables, EntityGenerator.Config entityConfig, IProgressMonitor monitor) { - this.progressMonitor = monitor; - try { - this.progressMonitor.beginTask("", 1000); - this.buildGenTables(tables, entityConfig); - checkCanceled(); - this.configureManyToManyRelations(); - checkCanceled(); - this.configureManyToOneRelations(); - checkCanceled(); - this.configureFieldNames(); - checkCanceled(); - } - finally { - this.progressMonitor.done(); - } - } - - private void buildGenTables(Collection
tables, EntityGenerator.Config entityConfig) { - int size = tables.size(); - // pass around a growing list of the entity names so we can avoid duplicates - Set entityNames = new HashSet(size); - for (Table table : tables) { - this.buildGenTable(table, entityConfig, entityNames); - this.progressMonitor.worked(50/size); - } - } - - private void buildGenTable(Table table, EntityGenerator.Config entityConfig, Collection entityNames) { - this.genTables.put(table, new GenTable(this, table, entityConfig, entityNames)); - } - - /** - * find all the "join" tables - */ - private void configureManyToManyRelations() { - int tablesSize = CollectionTools.size(this.tables()); - - //first time takes the longest, should we take that into account? - for (Iterator stream = this.tables(); stream.hasNext(); ) { - checkCanceled(); - stream.next().configureManyToManyRelations(); - this.progressMonitor.worked(750/tablesSize); - } - // revert any "join" table that is referenced by another table back to an "entity" table - Set referencedTables = this.buildReferencedTables(); - tablesSize = CollectionTools.size(this.joinTables()); - for (Iterator stream = this.joinTables(); stream.hasNext(); ) { - GenTable joinGenTable = stream.next(); - if (referencedTables.contains(joinGenTable)) { - joinGenTable.clearJoinTableRelation(); - } - this.progressMonitor.worked(50/tablesSize); - } - } - - /** - * find all the many-to-one and one-to-many relations - */ - private void configureManyToOneRelations() { - int tablesSize = CollectionTools.size(this.entityTables()); - for (Iterator stream = this.entityTables(); stream.hasNext(); ) { - stream.next().configureManyToOneRelations(); - this.progressMonitor.worked(50/tablesSize); - } - } - - /** - * determine all the Java field names up-front because we will - * need them for things like 'mappedBy' annotation elements - */ - private void configureFieldNames() { - int tablesSize = CollectionTools.size(this.entityTables()); - for (Iterator stream = this.entityTables(); stream.hasNext(); ) { - stream.next().configureFieldNames(); - this.progressMonitor.worked(50/tablesSize); - } - } - - - // ********** package API ********** - - /** - * return only the gen tables that are suitable for generating - * entities (i.e. exclude the "join" tables) - */ - Iterator entityTables() { - return new FilteringIterator(this.tables()) { - @Override - protected boolean accept(Object next) { - return ! ((GenTable) next).isJoinTable(); - } - }; - } - - int numEntityTables() { - return CollectionTools.size(entityTables()); - } - - /** - * return the gen table corresponding to the specified table - */ - GenTable genTable(Table table) { - return this.genTables.get(table); - } - - - // ********** internal API ********** - - private Iterator tables() { - return this.genTables.values().iterator(); - } - - /** - * return only the "join" gen tables - */ - private Iterator joinTables() { - return new FilteringIterator(this.tables()) { - @Override - protected boolean accept(Object next) { - return ((GenTable) next).isJoinTable(); - } - }; - } - - /** - * build a set of the tables that are referenced by other tables - * in the scope - */ - private Set buildReferencedTables() { - int size = CollectionTools.size(this.tables()); - Set referencedTables = new HashSet(this.genTables.size()); - for (Iterator stream = this.tables(); stream.hasNext(); ) { - stream.next().addReferencedTablesTo(referencedTables); - this.progressMonitor.worked(50/size); - } - return referencedTables; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/GenTable.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/GenTable.java deleted file mode 100644 index ea7fd3d3c9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/GenTable.java +++ /dev/null @@ -1,342 +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 - ******************************************************************************/ -package org.eclipse.jpt.gen.internal; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import org.eclipse.jpt.db.internal.Column; -import org.eclipse.jpt.db.internal.ForeignKey; -import org.eclipse.jpt.db.internal.Table; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.NameTools; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; - -/** - * associate a table with the various relations that will be used when - * generating the entity - */ -class GenTable { - private final GenScope scope; - private final Table table; - private final EntityGenerator.Config entityConfig; - private final String entityName; - private ManyToManyRelation joinTableRelation; - private Collection ownedManyToManyRelations = new ArrayList(); - private Collection nonOwnedManyToManyRelations = new ArrayList(); - private Collection manyToOneRelations = new ArrayList(); - private Collection oneToManyRelations = new ArrayList(); - private Set foreignKeyColumns = new HashSet(); - - // key=column/relation; value=name - private final Map fieldNames = new HashMap(); - - private static final Object EMBEDDED_ID_VIRTUAL_COLUMN = new Object(); - - - // ********** construction/initialization ********** - - GenTable(GenScope scope, Table table, EntityGenerator.Config entityConfig, Collection entityNames) { - super(); - this.scope = scope; - this.table = table; - this.entityConfig = entityConfig; - this.entityName = this.buildEntityName(entityNames); - } - - private String buildEntityName(Collection entityNames) { - String name = this.table.shortJavaClassName(); - String overrideEntityName = this.entityConfig.getOverrideEntityName(this.table); - if (overrideEntityName == null) { - if (this.entityConfig.convertToCamelCase()) { - name = StringTools.convertUnderscoresToCamelCase(name); - } - } else { - name = overrideEntityName; - } - name = NameTools.uniqueNameForIgnoreCase(name, entityNames); - entityNames.add(name); - return name; - } - - - // ********** package API ********** - - /** - * determine whether the table is a "join" table within the table's scope - */ - void configureManyToManyRelations() { - if (this.table.foreignKeysSize() != 2) { - // the table must have exactly 2 foreign keys - return; - } - for (Iterator stream = this.table.columns(); stream.hasNext(); ) { - if ( ! this.table.foreignKeyColumnsContains(stream.next())) { - // all the table's columns must belong to one (or both) of the 2 foreign keys - return; - } - } - Iterator fKeys = this.table.foreignKeys(); - ForeignKey owningFK = fKeys.next(); - ForeignKey nonOwningFK = fKeys.next(); - GenTable owningTable = this.scope.genTable(owningFK.getReferencedTable()); - GenTable nonOwningTable = this.scope.genTable(nonOwningFK.getReferencedTable()); - if ((owningTable == null) || (nonOwningTable == null)) { - // both tables must be in the scope - return; - } - this.joinTableRelation = new ManyToManyRelation(this, owningFK, owningTable, nonOwningFK, nonOwningTable); - } - - void addReferencedTablesTo(Set referencedTables) { - for (Iterator stream = this.table.foreignKeys(); stream.hasNext(); ) { - ForeignKey fk = stream.next(); - GenTable genTable = this.scope.genTable(fk.getReferencedTable()); - if (genTable != null) { - referencedTables.add(genTable); - } - } - } - - void clearJoinTableRelation() { - this.joinTableRelation.clear(); - this.joinTableRelation = null; - } - - /** - * find "in-scope" foreign keys - */ - void configureManyToOneRelations() { - for (Iterator stream = this.table.foreignKeys(); stream.hasNext(); ) { - ForeignKey fk = stream.next(); - GenTable referencedtable = this.scope.genTable(fk.getReferencedTable()); - if (referencedtable == null) { - continue; // skip to next FK - } - this.manyToOneRelations.add(new ManyToOneRelation(this, fk, referencedtable)); - } - } - - /** - * now that all the relations are in place, we can configure the Java - * field names - */ - void configureFieldNames() { - Set columns = CollectionTools.set(this.table.columns()); - if ((this.table.primaryKeyColumnsSize() > 1) && this.entityConfig.generateEmbeddedIdForCompoundPK()) { - // if we are going to generate an EmbeddedId field, add it to - // 'fieldNames' so we don't collide with it later, when generating - // field names for the columns etc. - this.configureFieldName(EMBEDDED_ID_VIRTUAL_COLUMN, "pk"); - } - this.configureManyToOneFieldNames(columns); - this.configureBasicFieldNames(columns); - this.configureOneToManyFieldNames(); - this.configureOwnedManyToManyFieldNames(); - this.configureNonOwnedManyToManyFieldNames(); - } - - /** - * return the columns that are part of the table's primary key - * but are also part of an "in-scope" foreign key - */ - public Iterator readOnlyPrimaryKeyColumns() { - return new FilteringIterator(this.table.primaryKeyColumns()) { - @Override - protected boolean accept(Object column) { - return GenTable.this.foreignKeyColumnsContains((Column) column); - } - }; - } - - /** - * return the columns that are part of the table's primary key - * but are NOT part of any "in-scope" foreign key - */ - Iterator writablePrimaryKeyColumns() { - return new FilteringIterator(this.table.primaryKeyColumns()) { - @Override - protected boolean accept(Object column) { - return ! GenTable.this.foreignKeyColumnsContains((Column) column); - } - }; - } - - /** - * return the columns that NEITHER part of the table's primary key - * NOR part of any foreign key - */ - public Iterator nonPrimaryKeyBasicColumns() { - return new FilteringIterator(this.table.columns()) { - @Override - protected boolean accept(Object column) { - return ! (GenTable.this.primaryKeyColumnsContains((Column) column) - || GenTable.this.foreignKeyColumnsContains((Column) column)); - } - }; - } - - Table getTable() { - return this.table; - } - - String getEntityName() { - return this.entityName; - } - - boolean isJoinTable() { - return this.joinTableRelation != null; - } - - void addOwnedManyToManyRelation(ManyToManyRelation relation) { - this.ownedManyToManyRelations.add(relation); - } - - void removeOwnedManyToManyRelation(ManyToManyRelation relation) { - this.ownedManyToManyRelations.remove(relation); - } - - void addNonOwnedManyToManyRelation(ManyToManyRelation relation) { - this.nonOwnedManyToManyRelations.add(relation); - } - - void removeNonOwnedManyToManyRelation(ManyToManyRelation relation) { - this.nonOwnedManyToManyRelations.remove(relation); - } - - void addOneToManyRelation(OneToManyRelation relation) { - this.oneToManyRelations.add(relation); - } - - String javaFieldName() { - return this.table.javaFieldName(); - } - - Iterator manyToOneRelations() { - return this.manyToOneRelations.iterator(); - } - - Iterator oneToManyRelations() { - return this.oneToManyRelations.iterator(); - } - - Iterator ownedManyToManyRelations() { - return this.ownedManyToManyRelations.iterator(); - } - - Iterator nonOwnedManyToManyRelations() { - return this.nonOwnedManyToManyRelations.iterator(); - } - - /** - * the key can be a column or relation - */ - private String fieldNameForInternal(Object o) { - return this.fieldNames.get(o); - } - - /** - * this will return null if we don't want an embedded id field - */ - String fieldNameForEmbeddedId() { - return this.fieldNameForInternal(EMBEDDED_ID_VIRTUAL_COLUMN); - } - - String fieldNameFor(Column column) { - return this.fieldNameForInternal(column); - } - - String fieldNameFor(ManyToOneRelation relation) { - return this.fieldNameForInternal(relation); - } - - String fieldNameFor(OneToManyRelation relation) { - return this.fieldNameForInternal(relation); - } - - String fieldNameFor(ManyToManyRelation relation) { - return this.fieldNameForInternal(relation); - } - - String name() { - return this.table.getName(); - } - - - // ********** internal API ********** - - /** - * while we are figuring out the names for the m:1 fields, remove from the - * specified set of columns the columns that are only part of the foreign keys - */ - private void configureManyToOneFieldNames(Set columns) { - for (ManyToOneRelation relation : this.manyToOneRelations) { - CollectionTools.removeAll(columns, relation.getForeignKey().nonPrimaryKeyBaseColumns()); - CollectionTools.addAll(this.foreignKeyColumns, relation.getForeignKey().baseColumns()); - relation.setMappedBy(this.configureFieldName(relation, relation.javaFieldName())); - } - } - - private String configureFieldName(Object o, String fieldName) { - fieldName = this.camelCase(fieldName); - fieldName = NameTools.uniqueNameFor(fieldName, this.fieldNames.values()); - this.fieldNames.put(o, fieldName); - return fieldName; - } - - private String camelCase(String name) { - return this.entityConfig.convertToCamelCase() ? - StringTools.convertUnderscoresToCamelCase(name, false) // false = don't capitalize first letter - : - name; - } - - /** - * build a unique field name for the specified "basic" columns, - * checking for name collisions - */ - private void configureBasicFieldNames(Set columns) { - for (Column column : columns) { - this.configureFieldName(column, column.javaFieldName()); - } - } - - private void configureOneToManyFieldNames() { - for (OneToManyRelation relation : this.oneToManyRelations) { - this.configureFieldName(relation, relation.javaFieldName()); - } - } - - private void configureOwnedManyToManyFieldNames() { - for (ManyToManyRelation relation : this.ownedManyToManyRelations) { - relation.setMappedBy(this.configureFieldName(relation, relation.javaFieldNameFor(this))); - } - } - - private void configureNonOwnedManyToManyFieldNames() { - for (ManyToManyRelation relation : this.nonOwnedManyToManyRelations) { - this.configureFieldName(relation, relation.javaFieldNameFor(this)); - } - } - - boolean foreignKeyColumnsContains(Column column) { - return this.foreignKeyColumns.contains(column); - } - - boolean primaryKeyColumnsContains(Column column) { - return this.table.primaryKeyColumnsContains(column); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ManyToManyRelation.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ManyToManyRelation.java deleted file mode 100644 index d87608715a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ManyToManyRelation.java +++ /dev/null @@ -1,104 +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 - ******************************************************************************/ -package org.eclipse.jpt.gen.internal; - -import org.eclipse.jpt.db.internal.ForeignKey; - -/** - * This object is shared by the two gen tables that make up the relation. - * Upon construction, 'mappedBy' will be 'null'. The first gen table to be - * used to generate an entity will fill in 'mappedBy' with the appropriate - * field/property name. - */ -class ManyToManyRelation { - private final GenTable joinTable; - private final ForeignKey owningForeignKey; - private final GenTable owningTable; - private final ForeignKey nonOwningForeignKey; - private final GenTable nonOwningTable; - private String mappedBy; - - - ManyToManyRelation(GenTable joinTable, ForeignKey owningForeignKey, GenTable owningTable, ForeignKey nonOwningForeignKey, GenTable nonOwningTable) { - super(); - this.joinTable = joinTable; - - this.owningForeignKey = owningForeignKey; - this.owningTable = owningTable; - owningTable.addOwnedManyToManyRelation(this); - - this.nonOwningForeignKey = nonOwningForeignKey; - this.nonOwningTable = nonOwningTable; - nonOwningTable.addNonOwnedManyToManyRelation(this); - } - - GenTable getJoinTable() { - return this.joinTable; - } - - ForeignKey getOwningForeignKey() { - return this.owningForeignKey; - } - - GenTable getOwningTable() { - return this.owningTable; - } - - ForeignKey getNonOwningForeignKey() { - return this.nonOwningForeignKey; - } - - GenTable getNonOwningTable() { - return this.nonOwningTable; - } - - private GenTable otherTable(GenTable table) { - return (table == this.owningTable) ? this.nonOwningTable : this.owningTable; - } - - String javaFieldNameFor(GenTable table) { - // TODO i18n? - return this.otherTable(table).javaFieldName() + "_collection"; - } - - void clear() { - this.owningTable.removeOwnedManyToManyRelation(this); - this.nonOwningTable.removeNonOwnedManyToManyRelation(this); - } - - String getMappedBy() { - return this.mappedBy; - } - - void setMappedBy(String mappedBy) { - this.mappedBy = mappedBy; - } - - String owningEntityName() { - return this.owningTable.getEntityName(); - } - - String nonOwningEntityName() { - return this.nonOwningTable.getEntityName(); - } - - boolean joinTableNameIsDefault() { - return this.joinTable.name().equals(this.getOwningTable().name() + "_" + this.getNonOwningTable().name()); - } - - boolean joinColumnsIsDefaultFor(String javaFieldName) { - return this.owningForeignKey.isDefaultFor(javaFieldName); - } - - boolean inverseJoinColumnsIsDefaultFor(String javaFieldName) { - return this.nonOwningForeignKey.isDefaultFor(javaFieldName); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ManyToOneRelation.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ManyToOneRelation.java deleted file mode 100644 index 333018d3e6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/ManyToOneRelation.java +++ /dev/null @@ -1,61 +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 - ******************************************************************************/ -package org.eclipse.jpt.gen.internal; - -import org.eclipse.jpt.db.internal.ForeignKey; - -class ManyToOneRelation { - private final GenTable baseTable; // the "many" side - private final ForeignKey foreignKey; - private final GenTable referencedTable; // the "one" side - private String mappedBy; - - - ManyToOneRelation(GenTable baseTable, ForeignKey foreignKey, GenTable referencedTable) { - super(); - this.baseTable = baseTable; - this.foreignKey = foreignKey; - this.referencedTable = referencedTable; - referencedTable.addOneToManyRelation(new OneToManyRelation(this)); - } - - GenTable getBaseTable() { - return this.baseTable; - } - - ForeignKey getForeignKey() { - return this.foreignKey; - } - - GenTable getReferencedTable() { - return this.referencedTable; - } - - String javaFieldName() { - return this.foreignKey.javaFieldName(); - } - - String getMappedBy() { - return this.mappedBy; - } - - void setMappedBy(String mappedBy) { - this.mappedBy = mappedBy; - } - - String baseEntityName() { - return this.baseTable.getEntityName(); - } - - String referencedEntityName() { - return this.referencedTable.getEntityName(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/OneToManyRelation.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/OneToManyRelation.java deleted file mode 100644 index 4656d00c12..0000000000 --- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/OneToManyRelation.java +++ /dev/null @@ -1,37 +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 - ******************************************************************************/ -package org.eclipse.jpt.gen.internal; - -class OneToManyRelation { - private final ManyToOneRelation manyToOneRelation; - - OneToManyRelation(ManyToOneRelation manyToOneRelation) { - super(); - this.manyToOneRelation = manyToOneRelation; - } - - ManyToOneRelation getManyToOneRelation() { - return this.manyToOneRelation; - } - - String javaFieldName() { - // TODO i18n? - return this.manyToOneRelation.getBaseTable().javaFieldName() + "_collection"; - } - - String mappedBy() { - return this.manyToOneRelation.getMappedBy(); - } - - String referencedEntityName() { - return this.manyToOneRelation.baseEntityName(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/PackageGenerator.java b/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/PackageGenerator.java deleted file mode 100644 index eb74550ca4..0000000000 --- a/jpa/plugins/org.eclipse.jpt.gen/src/org/eclipse/jpt/gen/internal/PackageGenerator.java +++ /dev/null @@ -1,97 +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 - ******************************************************************************/ -package org.eclipse.jpt.gen.internal; - -import java.util.Collection; -import java.util.Iterator; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.OperationCanceledException; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jpt.db.internal.Table; -import org.eclipse.jpt.gen.internal.EntityGenerator.OverwriteConfirmer; -import org.eclipse.jpt.utility.internal.CollectionTools; - -/** - * This generator will generate a package of entities for a set of tables. - */ -public class PackageGenerator { - private final Config config; - private final EntityGenerator.Config entityConfig; - private final GenScope scope; - private final OverwriteConfirmer overwriteConfirmer; - private final IProgressMonitor monitor; - - // ********** public API ********** - - public static void generateEntities(Config config, EntityGenerator.Config entityConfig, Collection
tables, OverwriteConfirmer overwriteConfirmer, IProgressMonitor monitor) { - if ((config == null) || (entityConfig == null) || (tables == null)) { - throw new NullPointerException(); - } - try { - monitor.beginTask("", 1000); - new PackageGenerator(config, entityConfig, tables, overwriteConfirmer, monitor).generateEntities(); - } - finally { - monitor.done(); - } - } - - - // ********** construction/initialization ********** - - private PackageGenerator(Config config, EntityGenerator.Config entityConfig, Collection
tables, OverwriteConfirmer overwriteConfirmer, IProgressMonitor monitor) { - super(); - this.config = config; - this.entityConfig = entityConfig; - this.scope = new GenScope(tables, entityConfig, new SubProgressMonitor(monitor, 800)); - this.overwriteConfirmer = overwriteConfirmer; - this.monitor = monitor; - } - - - // ********** generation ********** - - private void generateEntities() { - int size = this.scope.numEntityTables(); - int ticks = 200/size; - for (Iterator stream = this.scope.entityTables(); stream.hasNext(); ) { - checkCanceled(); - this.buildEntity(stream.next(), new SubProgressMonitor(this.monitor, ticks)); - } - } - - private void checkCanceled() { - if (this.monitor.isCanceled()) { - throw new OperationCanceledException(); - } - } - - - private void buildEntity(GenTable genTable, IProgressMonitor monitor) { - EntityGenerator.generateEntity(this.entityConfig, this.config.getPackageFragment(), genTable, overwriteConfirmer, monitor); - } - - - // ********** config ********** - - public static class Config { - private IPackageFragment packageFragment; - - public IPackageFragment getPackageFragment() { - return this.packageFragment; - } - public void setPackageFragment(IPackageFragment packageFragment) { - this.packageFragment = packageFragment; - } - - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/.classpath b/jpa/plugins/org.eclipse.jpt.utility/.classpath deleted file mode 100644 index 1d0cf0db7b..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/.classpath +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/jpa/plugins/org.eclipse.jpt.utility/.cvsignore b/jpa/plugins/org.eclipse.jpt.utility/.cvsignore deleted file mode 100644 index 42191b4579..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -bin -@dot -build.xml \ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.utility/.project b/jpa/plugins/org.eclipse.jpt.utility/.project deleted file mode 100644 index 99b389b9c5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.eclipse.jpt.utility - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/jpa/plugins/org.eclipse.jpt.utility/.settings/org.eclipse.core.resources.prefs b/jpa/plugins/org.eclipse.jpt.utility/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 8b1918da29..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Sun May 27 15:11:35 EDT 2007 -eclipse.preferences.version=1 -encoding/=ISO-8859-1 diff --git a/jpa/plugins/org.eclipse.jpt.utility/.settings/org.eclipse.jdt.core.prefs b/jpa/plugins/org.eclipse.jpt.utility/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 443826069d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -#Sun May 27 14:55:37 EDT 2007 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -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/jpa/plugins/org.eclipse.jpt.utility/META-INF/MANIFEST.MF b/jpa/plugins/org.eclipse.jpt.utility/META-INF/MANIFEST.MF deleted file mode 100644 index ae0ffae31a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/META-INF/MANIFEST.MF +++ /dev/null @@ -1,10 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: %pluginName -Bundle-Vendor: %providerName -Bundle-SymbolicName: org.eclipse.jpt.utility -Bundle-Version: 1.0.1.qualifier -Bundle-Localization: plugin -Export-Package: org.eclipse.jpt.utility.internal, - org.eclipse.jpt.utility.internal.iterators -Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/jpa/plugins/org.eclipse.jpt.utility/about.html b/jpa/plugins/org.eclipse.jpt.utility/about.html deleted file mode 100644 index 9e73bdabb6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/about.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - -About - - - - - -

About This Content

- -

June 06, 2007

- -

License

- -

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 -http://www.eclipse.org/org/documents/epl-v10.php. -For purposes of the EPL, "Program" will mean the Content.

- -

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 -http://www.eclipse.org/.

- - - diff --git a/jpa/plugins/org.eclipse.jpt.utility/build.properties b/jpa/plugins/org.eclipse.jpt.utility/build.properties deleted file mode 100644 index 11ab8d42f6..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/build.properties +++ /dev/null @@ -1,17 +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 -################################################################################ -javacSource=1.5 -javacTarget=1.5 -source.. = src/ -output.. = bin/ -bin.includes = .,\ - META-INF/,\ - about.html,\ - plugin.properties diff --git a/jpa/plugins/org.eclipse.jpt.utility/component.xml b/jpa/plugins/org.eclipse.jpt.utility/component.xml deleted file mode 100644 index b210b281dd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/component.xml +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/jpa/plugins/org.eclipse.jpt.utility/plugin.properties b/jpa/plugins/org.eclipse.jpt.utility/plugin.properties deleted file mode 100644 index 95c029d5d8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/plugin.properties +++ /dev/null @@ -1,24 +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 -################################################################################ -# ==================================================================== -# 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 = Java Persistence API Tools - Utility -providerName = Eclipse.org - diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Bag.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Bag.java deleted file mode 100644 index 2c68536c51..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Bag.java +++ /dev/null @@ -1,49 +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.utility.internal; - -/** - * A collection that allows duplicate elements. - *

- * The Bag interface places additional stipulations, - * beyond those inherited from the java.util.Collection interface, - * on the contracts of the equals and hashCode methods. - * - * @version 1.00 Jan-2002 - * @see java.util.Collection - * @see HashBag - */ - -public interface Bag extends java.util.Collection { - - /** - * Compares the specified object with this bag for equality. Returns - * true 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 null element is defined to be zero. - * This ensures that b1.equals(b2) implies that - * b1.hashCode() == b2.hashCode() for any two bags - * b1 and b2, as required by the general - * contract of the Object.hashCode method. - */ - int hashCode(); - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/BitTools.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/BitTools.java deleted file mode 100644 index cc1221a473..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/BitTools.java +++ /dev/null @@ -1,70 +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 - ******************************************************************************/ -package org.eclipse.jpt.utility.internal; - -/** - * Assorted bit tools - */ -public class BitTools { - - /** - * 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 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 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 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; - } - - - // ********** constructor ********** - - /** - * Suppress default constructor, ensuring non-instantiability. - */ - private BitTools() { - super(); - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ClassTools.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ClassTools.java deleted file mode 100644 index 9f8e2021e8..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ClassTools.java +++ /dev/null @@ -1,1505 +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.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.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 REFERENCE_CLASS_CODE = 'L'; - public static final char REFERENCE_CLASS_NAME_DELIMITER = ';'; - - private static PrimitiveClassCode[] PRIMITIVE_CLASS_CODES; // 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 - - - /** - * Return all the fields for the - * specified class, including inherited fields. - * Class#allFields() - */ - public static Field[] allFields(Class javaClass) { - Stack stack = new Stack(); - 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 stack = new Stack(); - 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 - */ - public static T attemptNewInstance(Class 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 attemptNewInstance(Class 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 attemptNewInstance(Class 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 Constructor constructor(Class 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 Constructor constructor(Class javaClass, Class[] parameterTypes) throws NoSuchMethodException { - Constructor 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 Constructor constructor(Class 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 Constructor defaultConstructor(Class 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) { - StringBuffer sb = new StringBuffer(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) { - StringBuffer sb = new StringBuffer(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 getFieldValue(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 getStaticFieldValue(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,. - */ - public static Class classForName(String javaClassName) { - try { - return Class.forName(javaClassName); - } catch (ClassNotFoundException ex) { - throw new RuntimeException(javaClassName, ex); - } - } - - /** - * Convenience method. - * Return a new instance of the specified class, - * using the class's default (zero-argument) constructor. - * Class#newInstance() - */ - public static T newInstance(Class 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 javaClassName) throws ClassNotFoundException { - return newInstance(javaClassName, ClassTools.class.getClassLoader()); - } - - /** - * 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 javaClassName, ClassLoader classLoader) throws ClassNotFoundException { - return newInstance(classLoader.loadClass(javaClassName)); - } - - /** - * Return a new instance of the specified class, - * given the constructor parameter types and parameters. - * Class#newInstance(Class[] parameterTypes, Object[] parameters) - */ - public static T newInstance(Class 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 javaClassName, Class[] parameterTypes, Object[] parameters) throws ClassNotFoundException { - return newInstance(javaClassName, parameterTypes, parameters, ClassTools.class.getClassLoader()); - } - - /** - * 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 javaClassName, Class[] parameterTypes, Object[] parameters, ClassLoader classLoader) throws ClassNotFoundException { - return newInstance(classLoader.loadClass(javaClassName), 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 newInstance(Class 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 javaClassName, Class parameterType, Object parameter) throws ClassNotFoundException { - return newInstance(javaClassName, parameterType, parameter, ClassTools.class.getClassLoader()); - } - - /** - * 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 javaClassName, Class parameterType, Object parameter, ClassLoader classLoader) throws ClassNotFoundException { - return newInstance(classLoader.loadClass(javaClassName), parameterType, parameter); - } - - /** - * Push the declared fields for the specified class - * onto the top of the stack. - */ - private static void pushDeclaredFields(Class javaClass, Stack 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 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) { - StringBuffer sb = new StringBuffer(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. not void or one of the primitives). - */ - public static boolean classNamedIsReference(String className) { - return ! classNamedIsNonReference(className); - } - - /** - * Return whether the specified class is a "non-reference" - * class (i.e. void or one of the primitives). - */ - public static boolean classNamedIsNonReference(String className) { - if (classNamedIsArray(className) || (className.length() > maxPrimitiveClassNameLength())) { - return false; // performance tweak - } - PrimitiveClassCode[] codes = primitiveClassCodes(); - for (int i = codes.length; i-- > 0; ) { - if (codes[i].javaClass.getName().equals(className)) { - return true; - } - } - return false; - } - - /** - * 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) { - PrimitiveClassCode[] codes = primitiveClassCodes(); - 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())) { - PrimitiveClassCode[] codes = primitiveClassCodes(); - 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())) { - PrimitiveClassCode[] codes = primitiveClassCodes(); - 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 specified "type declaration". - */ - public static Class classForTypeDeclaration(String elementTypeName, int arrayDepth) throws ClassNotFoundException { - return classForTypeDeclaration(elementTypeName, arrayDepth, ClassTools.class.getClassLoader()); - } - - /** - * Return the class for specified "type declaration", - * using the specified class loader. - */ - 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 - PrimitiveClassCode pcc = null; - if (elementTypeName.length() <= maxPrimitiveClassNameLength()) { // performance tweak - PrimitiveClassCode[] codes = primitiveClassCodes(); - 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) ? classLoader.loadClass(elementTypeName) : pcc.javaClass; - } - - // array - StringBuffer sb = new StringBuffer(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 classLoader.loadClass(sb.toString()); - } - - /** - * Return the class name for specified "type declaration". - */ - public static String classNameForTypeDeclaration(String elementTypeName, int arrayDepth) { - // non-array - if (arrayDepth == 0) { - return elementTypeName; - } - - if (elementTypeName.equals(void.class.getName())) { - throw new IllegalArgumentException("'void' must have an array depth of zero: " + arrayDepth + '.'); - } - // array - StringBuffer sb = new StringBuffer(100); - for (int i = arrayDepth; i-- > 0; ) { - sb.append(ARRAY_INDICATOR); - } - - // look for a primitive first - PrimitiveClassCode pcc = null; - if (elementTypeName.length() <= maxPrimitiveClassNameLength()) { // performance tweak - PrimitiveClassCode[] codes = primitiveClassCodes(); - 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; - PrimitiveClassCode[] codes = primitiveClassCodes(); - for (int i = codes.length; i-- > 0; ) { - int len = codes[i].javaClass.getName().length(); - if (len > max) { - max = len; - } - } - return max; - } - - private static PrimitiveClassCode[] primitiveClassCodes() { - if (PRIMITIVE_CLASS_CODES == null) { - PRIMITIVE_CLASS_CODES = buildPrimitiveClassCodes(); - } - return PRIMITIVE_CLASS_CODES; - } - - private static PrimitiveClassCode[] buildPrimitiveClassCodes() { - PrimitiveClassCode[] result = new PrimitiveClassCode[9]; - result[0] = new PrimitiveClassCode(BYTE_CODE, byte.class); - result[1] = new PrimitiveClassCode(CHAR_CODE, char.class); - result[2] = new PrimitiveClassCode(DOUBLE_CODE, double.class); - result[3] = new PrimitiveClassCode(FLOAT_CODE, float.class); - result[4] = new PrimitiveClassCode(INT_CODE, int.class); - result[5] = new PrimitiveClassCode(LONG_CODE, long.class); - result[6] = new PrimitiveClassCode(SHORT_CODE, short.class); - result[7] = new PrimitiveClassCode(BOOLEAN_CODE, boolean.class); - result[8] = new PrimitiveClassCode(VOID_CODE, void.class); - return result; - } - - /** - * Suppress default constructor, ensuring non-instantiability. - */ - private ClassTools() { - super(); - throw new UnsupportedOperationException(); - } - - - // ********** member class ********** - - private static class PrimitiveClassCode { - char code; - Class javaClass; - PrimitiveClassCode(char code, Class javaClass) { - this.code = code; - this.javaClass = javaClass; - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Classpath.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Classpath.java deleted file mode 100644 index 0eac533075..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Classpath.java +++ /dev/null @@ -1,910 +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.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.utility.internal.iterators.ArrayIterator; -import org.eclipse.jpt.utility.internal.iterators.CompositeIterator; -import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; -import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; -import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; - -/** - * TODO - */ -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 rt.jar. - */ - public static Classpath bootClasspath() { - return new Classpath(System.getProperty("sun.boot.class.path")); - } - - /** - * 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 jarFileNames = new ArrayList(); - 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")); - } - - /** - * 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. - * e.g. "java/lang/String.class" is converted to "java.lang.String" - * e.g. "java/lang/String.java" is converted to "java.lang.String" - */ - 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. File(java/lang/String.class) is converted to "java.lang.String" - */ - public static String convertToClassName(File classFile) { - return convertToClassName(classFile.getPath()); - } - - /** - * Convert a relative file name to a class; - * e.g. "java/lang/String.class" is converted to java.lang.String.class - */ - public static Class convertToClass(String classFileName) throws ClassNotFoundException { - return Class.forName(convertToClassName(classFileName)); - } - - /** - * Convert a relative file to a class; - * e.g. File(java/lang/String.class) is converted to java.lang.String.class - */ - 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. "java.lang.String" is converted to "java/lang/String" - */ - public static String convertToArchiveEntryNameBase(String className) { - return className.replace('.', '/'); - } - - /** - * Convert a class to an archive entry name base; - * e.g. java.lang.String.class is converted to "java/lang/String" - */ - public static String convertToArchiveEntryNameBase(Class javaClass) { - return convertToArchiveEntryNameBase(javaClass.getName()); - } - - /** - * Convert a class name to an archive class file entry name; - * e.g. "java.lang.String" is converted to "java/lang/String.class" - */ - public static String convertToArchiveClassFileEntryName(String className) { - return convertToArchiveEntryNameBase(className) + ".class"; - } - - /** - * Convert a class to an archive class file entry name; - * e.g. java.lang.String.class is converted to "java/lang/String.class" - */ - 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. "java.lang.String" is converted to "java/lang/String" on Unix - * and "java\\lang\\String" 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. java.lang.String.class is converted to "java/lang/String" on Unix - * and "java\\lang\\String" 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. "java.lang.String" is converted to "java/lang/String.class" on Unix - * and "java\\lang\\String.class" on Windows - */ - public static String convertToClassFileName(String className) { - return convertToFileNameBase(className) + ".class"; - } - - /** - * Convert a class to a class file name for the current O/S; - * e.g. java.lang.String.class is converted to "java/lang/String.class" on Unix - * and "java\\lang\\String.class" 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. "java.lang.String" is converted to File(java/lang/String.class) - */ - 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. java.lang.String.class is converted to File(java/lang/String.class) - */ - 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. "java.lang.String" is converted to "java/lang/String.java" on Unix - * and "java\\lang\\String.java" on Windows - */ - public static String convertToJavaFileName(String className) { - return convertToFileNameBase(className) + ".java"; - } - - /** - * Convert a class to a java file name for the current O/S; - * e.g. java.lang.String.class is converted to "java/lang/String.java" on Unix - * and "java\\lang\\String.java" 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. "java.lang.String" is converted to File(java/lang/String.java) - */ - 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. java.lang.String.class is converted to File(java/lang/String.java) - */ - public static File convertToJavaFile(Class javaClass) { - return convertToJavaFile(javaClass.getName()); - } - - - // ***** class => resource ***** - - /** - * Convert a class to a resource name; - * e.g. java.lang.String.class is converted to "/java/lang/String.class". - */ - public static String convertToResourceName(Class javaClass) { - return '/' + convertToArchiveClassFileEntryName(javaClass); - } - - /** - * Convert a class to a resource; - * e.g. java.lang.String.class is converted to - * URL(jar:file:/C:/jdk/1.4.2_04/jre/lib/rt.jar!/java/lang/String.class). - */ - 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 ".zip" or ".jar" - */ - public static boolean fileNameIsArchive(String fileName) { - String ext = FileTools.extension(fileName).toLowerCase(); - return ext.equals(".jar") || ext.equals(".zip"); - } - - /** - * Return whether the specified file is an archive file; - * i.e. its name ends with ".zip" or ".jar" - */ - 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. "C:\jdk1.4.2_04\jre\lib\rt.jar". - */ - 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")) { - // 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")) { - // 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")) { - // 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); - } - - - // ***** 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 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"); - } - }; - } - - - // ********** 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: - * "C:\dev\foo.jar;;C:\dev\bar.jar" - * will be parsed into three file names: - * { "C:\dev\foo.jar", "", "C:\dev\bar.jar" } - */ - private static Entry[] buildEntries(String[] fileNames) { - List entries = new ArrayList(); - 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(List fileNames) { - this(fileNames.toArray(new String[fileNames.size()])); - } - - /** - * Consolidate the specified classpaths into a single classpath. - */ - public Classpath(Classpath[] classpaths) { - this(consolidateEntries(classpaths)); - } - - private static Entry[] consolidateEntries(Classpath[] classpaths) { - List entries = new ArrayList(); - for (Classpath classpath : classpaths) { - CollectionTools.addAll(entries, classpath.getEntries()); - } - return entries.toArray(new Entry[entries.size()]); - } - - - // ********** public API ********** - - /** - * Return the classpath's entries. - */ - public Entry[] getEntries() { - return this.entries; - } - - /** - * Return the classpath's path. - */ - public String path() { - Entry[] localEntries = this.entries; - int max = localEntries.length - 1; - if (max == -1) { - return ""; - } - StringBuffer sb = new StringBuffer(2000); - // stop one short of the end of the array - for (int i = 0; i < max; i++) { - sb.append(localEntries[i].fileName()); - sb.append(File.pathSeparatorChar); - } - sb.append(localEntries[max].fileName()); - 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 "rt.jar" or "toplink.jar". - */ - public Entry entryForFileNamed(String shortFileName) { - Entry[] localEntries = this.entries; - for (Entry entry : localEntries) { - if (entry.file().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 entryForClassNamed(String className) { - String relativeClassFileName = convertToClassFileName(className); - String archiveEntryName = convertToArchiveClassFileEntryName(className); - Entry[] localEntries = this.entries; - for (Entry entry : localEntries) { - if (entry.contains(relativeClassFileName, archiveEntryName)) { - return entry; - } - } - return null; - } - - /** - * Return the names of all the classes discovered on the classpath, - * with duplicates removed. - */ - public String[] classNames() { - return this.classNames(Filter.Null.instance()); - } - - /** - * Return the names of all the classes discovered on the classpath - * and accepted by the specified filter, with duplicates removed. - */ - public String[] classNames(Filter filter) { - Collection classNames = new HashSet(10000); - this.addClassNamesTo(classNames, filter); - return classNames.toArray(new String[classNames.size()]); - } - - /** - * Add the names of all the classes discovered on the classpath - * to the specified collection. - */ - public void addClassNamesTo(Collection classNames) { - this.addClassNamesTo(classNames, Filter.Null.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 classNames, Filter filter) { - Entry[] localEntries = this.entries; - for (Entry entry : localEntries) { - entry.addClassNamesTo(classNames, filter); - } - } - - /** - * Return the names of all the classes discovered on the classpath. - * Just a bit more performant than #classNames(). - */ - public Iterator classNamesStream() { - return this.classNamesStream(Filter.Null.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 #classNames(Filter). - */ - public Iterator classNamesStream(Filter filter) { - return new CompositeIterator(this.entryClassNamesStreams(filter)); - } - - private Iterator> entryClassNamesStreams(final Filter filter) { - return new TransformationIterator>(new ArrayIterator(this.entries)) { - @Override - protected Iterator transform(Entry entry) { - return entry.classNamesStream(filter); - } - }; - } - - /** - * Return a "compressed" version of the classpath with its - * duplicate entries eliminated. - */ - public Classpath compressed() { - return new Classpath((Entry[]) CollectionTools.removeDuplicateElements(this.entries)); - } - - /** - * Convert the classpath to an array of URLs - * (that can be used to instantiate a URLClassLoader). - */ - public URL[] urls() { - Entry[] localEntries = this.entries; - int len = localEntries.length; - URL[] urls = new URL[len]; - for (int i = 0; i < len; i++) { - urls[i] = localEntries[i].url(); - } - return urls; - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this, this.path()); - } - - - // ********** inner class ********** - - /** - * TODO - */ - 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"); - } - this.fileName = fileName; - this.file = new File(fileName); - this.canonicalFile = FileTools.canonicalFile(this.file); - } - - public String fileName() { - return this.fileName; - } - - public File file() { - return this.file; - } - - public File canonicalFile() { - return this.canonicalFile; - } - - public String canonicalFileName() { - 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 url() { - try { - return this.canonicalFile.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) { - zipEntry = null; // something is wrong, clear out the entry - } 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. - */ - public String[] classNames() { - return this.classNames(Filter.Null.instance()); - } - - /** - * Return the names of all the classes discovered in the entry - * and accepted by the specified filter. - */ - public String[] classNames(Filter filter) { - Collection classNames = new ArrayList(2000); - this.addClassNamesTo(classNames, filter); - return classNames.toArray(new String[classNames.size()]); - } - - /** - * Add the names of all the classes discovered in the entry - * to the specified collection. - */ - public void addClassNamesTo(Collection classNames) { - this.addClassNamesTo(classNames, Filter.Null.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 classNames, Filter 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 classNames, Filter filter) { - int start = this.canonicalFile.getAbsolutePath().length() + 1; - for (Iterator 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 classFilesForDirectory() { - return new FilteringIterator(FileTools.filesInTree(this.canonicalFile)) { - @Override - protected boolean accept(Object next) { - return Entry.this.fileNameMightBeForClassFile(((File) 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 classNames, Filter filter) { - ZipFile zipFile = null; - try { - zipFile = new ZipFile(this.canonicalFile); - } catch (IOException ex) { - return; - } - for (Enumeration 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 ".class" 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") - && (name.indexOf(' ') == -1); - } - - /** - * Return the names of all the classes discovered on the classpath. - * Just a bit more performant than #classNames(). - */ - public Iterator classNamesStream() { - return this.classNamesStream(Filter.Null.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 #classNames(Filter). - */ - public Iterator classNamesStream(Filter 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 classNamesForDirectory(Filter filter) { - return new FilteringIterator(this.classNamesForDirectory(), filter); - } - - /** - * Transform the class files to class names. - */ - private Iterator classNamesForDirectory() { - final int start = this.canonicalFile.getAbsolutePath().length() + 1; - return new TransformationIterator(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 classNamesForArchive(Filter 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 classNames = new HashSet(zipFile.size()); - for (Enumeration 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/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/CollectionTools.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/CollectionTools.java deleted file mode 100644 index 2c62718ade..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/CollectionTools.java +++ /dev/null @@ -1,2437 +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.utility.internal; - -import java.lang.reflect.Array; -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.List; -import java.util.ListIterator; -import java.util.Random; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; -import java.util.Vector; -import org.eclipse.jpt.utility.internal.iterators.ArrayIterator; -import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator; - -public final class CollectionTools { - - /** - * Return a new array that contains the elements in the - * specified array followed by the specified object to be added. - * java.util.Arrays#add(Object[] array, Object o) - */ - @SuppressWarnings("unchecked") - public static E[] add(E[] array, E value) { - int len = array.length; - E[] result = (E[]) Array.newInstance(array.getClass().getComponentType(), len + 1); - System.arraycopy(array, 0, result, 0, len); - result[len] = value; - return result; - } - - /** - * Return a new array that contains the elements in the - * specified array with the specified object added at the specified index. - * java.util.Arrays#add(Object[] array, int index, Object o) - */ - @SuppressWarnings("unchecked") - public static E[] add(E[] array, int index, E value) { - int len = array.length; - E[] result = (E[]) Array.newInstance(array.getClass().getComponentType(), len + 1); - if (index > 0) { - System.arraycopy(array, 0, result, 0, index); - } - result[index] = value; - if (len > index) { - System.arraycopy(array, index, result, index + 1, len - index); - } - return result; - } - - /** - * Return a new array that contains the elements in the - * specified array followed by the specified value to be added. - * java.util.Arrays#add(char[] array, char value) - */ - public static char[] add(char[] array, char value) { - int len = array.length; - char[] result = new char[len + 1]; - System.arraycopy(array, 0, result, 0, len); - result[len] = value; - return result; - } - - /** - * Return a new array that contains the elements in the - * specified array with the specified value added at the specified index. - * java.util.Arrays#add(char[] array, int index, char value) - */ - public static char[] add(char[] array, int index, char value) { - int len = array.length; - char[] result = new char[len + 1]; - System.arraycopy(array, 0, result, 0, index); - result[index] = value; - System.arraycopy(array, index, result, index + 1, len - index); - return result; - } - - /** - * Return a new array that contains the elements in the - * specified array followed by the specified value to be added. - * java.util.Arrays#add(int[] array, int value) - */ - public static int[] add(int[] array, int value) { - int len = array.length; - int[] result = new int[len + 1]; - System.arraycopy(array, 0, result, 0, len); - result[len] = value; - return result; - } - - /** - * Return a new array that contains the elements in the - * specified array with the specified value added at the specified index. - * java.util.Arrays#add(int[] array, int index, int value) - */ - public static int[] add(int[] array, int index, int value) { - int len = array.length; - int[] result = new int[len + 1]; - System.arraycopy(array, 0, result, 0, index); - result[index] = value; - System.arraycopy(array, index, result, index + 1, len - index); - return result; - } - - /** - * Add all the elements returned by the specified iterator - * to the specified collection. - * Return whether the collection changed as a result. - * java.util.Collection#addAll(java.util.Iterator iterator) - */ - public static boolean addAll(Collection collection, Iterator iterator) { - boolean modified = false; - while (iterator.hasNext()) { - modified |= collection.add(iterator.next()); - } - return modified; - } - - /** - * Add all the elements in the specified array - * to the specified collection. - * Return whether the collection changed as a result. - * java.util.Collection#addAll(Object[] array) - */ - public static boolean addAll(Collection collection, E[] array) { - boolean modified = false; - for (E item : array) { - modified |= collection.add(item); - } - return modified; - } - - /** - * Return a new array that contains the elements in the - * specified array followed by the elements - * in the specified collection. - * java.util.Arrays#addAll(Object[] array, java.util.Collection c) - */ - @SuppressWarnings("unchecked") - public static E[] addAll(E[] array, Collection collection) { - int len = array.length; - E[] result = (E[]) Array.newInstance(array.getClass().getComponentType(), array.length + collection.size()); - System.arraycopy(array, 0, result, 0, len); - int i = len; - for (E item : collection) { - result[i++] = item; - } - return result; - } - - /** - * Return a new array that contains the elements in the - * specified array followed by the elements - * in the specified iterator. - * java.util.Arrays#addAll(Object[] array, java.util.Iterator iterator) - */ - public static E[] addAll(E[] array, Iterator iterator) { - return addAll(array, list(iterator)); - } - - /** - * Return a new array that contains the elements in the - * specified array 1 followed by the elements - * in the specified array 2. - * java.util.Arrays#addAll(Object[] array1, Object[] array2) - */ - @SuppressWarnings("unchecked") - public static E[] addAll(E[] array1, E[] array2) { - int len1 = array1.length; - int len2 = array2.length; - E[] result = (E[]) Array.newInstance(array1.getClass().getComponentType(), len1 + len2); - System.arraycopy(array1, 0, result, 0, len1); - System.arraycopy(array2, 0, result, len1, len2); - return result; - } - - /** - * Return a new array that contains the elements in the - * first specified array with the objects in the second - * specified array added at the specified index. - * java.util.Arrays#add(Object[] array1, int index, Object[] array2) - */ - @SuppressWarnings("unchecked") - public static E[] addAll(E[] array1, int index, E[] array2) { - int len1 = array1.length; - int len2 = array2.length; - E[] result = (E[]) Array.newInstance(array1.getClass().getComponentType(), len1 + len2); - System.arraycopy(array1, 0, result, 0, index); - System.arraycopy(array2, 0, result, index, len2); - System.arraycopy(array1, index, result, index + len2, len1 - index); - return result; - } - - /** - * Return a new array that contains the elements in the - * specified array 1 followed by the elements - * in the specified array 2. - * java.util.Arrays#addAll(char[] array1, char[] array2) - */ - public static char[] addAll(char[] array1, char[] array2) { - int len1 = array1.length; - int len2 = array2.length; - char[] result = new char[len1 + len2]; - System.arraycopy(array1, 0, result, 0, len1); - System.arraycopy(array2, 0, result, len1, len2); - return result; - } - - /** - * Return a new array that contains the elements in the - * first specified array with the objects in the second - * specified array added at the specified index. - * java.util.Arrays#add(char[] array1, int index, char[] array2) - */ - public static char[] addAll(char[] array1, int index, char[] array2) { - int len1 = array1.length; - int len2 = array2.length; - char[] result = new char[len1 + len2]; - System.arraycopy(array1, 0, result, 0, index); - System.arraycopy(array2, 0, result, index, len2); - System.arraycopy(array1, index, result, index + len2, len1 - index); - return result; - } - - /** - * Return a new array that contains the elements in the - * specified array 1 followed by the elements - * in the specified array 2. - * java.util.Arrays#addAll(int[] array1, int[] array2) - */ - public static int[] addAll(int[] array1, int[] array2) { - int len1 = array1.length; - int len2 = array2.length; - int[] result = new int[len1 + len2]; - System.arraycopy(array1, 0, result, 0, len1); - System.arraycopy(array2, 0, result, len1, len2); - return result; - } - - /** - * Return a new array that contains the elements in the - * first specified array with the objects in the second - * specified array added at the specified index. - * java.util.Arrays#add(int[] array1, int index, int[] array2) - */ - public static int[] addAll(int[] array1, int index, int[] array2) { - int len1 = array1.length; - int len2 = array2.length; - int[] result = new int[len1 + len2]; - System.arraycopy(array1, 0, result, 0, index); - System.arraycopy(array2, 0, result, index, len2); - System.arraycopy(array1, index, result, index + len2, len1 - index); - return result; - } - - /** - * Return an array corresponding to the specified iterator. - * @see java.util.Collection#toArray() - * java.util.Iterator#toArray() - */ - public static Object[] array(Iterator iterator) { - return list(iterator).toArray(); - } - - /** - * Return an array corresponding to the specified iterator; - * the runtime type of the returned array is that of the specified array. - * If the collection 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 this collection. - * @see java.util.Collection#toArray(java.lang.Object[]) - * java.util.Iterator#toArray(Object[]) - */ - public static E[] array(Iterator iterator, E[] array) { - return list(iterator).toArray(array); - } - - /** - * Return a bag corresponding to the specified enumeration. - * HashBag(java.util.Enumeration enumeration) - */ - public static Bag bag(Enumeration enumeration) { - Bag bag = new HashBag(); - while (enumeration.hasMoreElements()) { - bag.add(enumeration.nextElement()); - } - return bag; - } - - /** - * Return a bag corresponding to the specified iterator. - * HashBag(java.util.Iterator iterator) - */ - public static Bag bag(Iterator iterator) { - Bag bag = new HashBag(); - while (iterator.hasNext()) { - bag.add(iterator.next()); - } - return bag; - } - - /** - * Return a bag corresponding to the specified array. - * HashBag(Object[] array) - */ - public static Bag bag(E... array) { - Bag bag = new HashBag(array.length); - for (E item : array) { - bag.add(item); - } - return bag; - } - - /** - * Return a collection corresponding to the specified enumeration. - */ - public static Collection collection(Enumeration enumeration) { - return bag(enumeration); - } - - /** - * Return a collection corresponding to the specified iterator. - */ - public static Collection collection(Iterator iterator) { - return bag(iterator); - } - - /** - * Return a collection corresponding to the specified array. - */ - public static Collection collection(E... array) { - return bag(array); - } - - /** - * Return whether the specified enumeration contains the - * specified element. - * java.util.Enumeration#contains(Object o) - */ - 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 iterator contains the - * specified element. - * java.util.Iterator#contains(Object o) - */ - 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; - } - - /** - * Return whether the specified array contains the - * specified element. - * java.util.Arrays#contains(Object[] array, Object o) - */ - public static boolean contains(Object[] array, Object value) { - if (value == null) { - for (int i = array.length; i-- > 0; ) { - if (array[i] == null) { - return true; - } - } - } else { - for (int i = array.length; i-- > 0; ) { - if (value.equals(array[i])) { - return true; - } - } - } - return false; - } - - /** - * Return whether the specified array contains the - * specified element. - * java.util.Arrays#contains(char[] array, char value) - */ - public static boolean contains(char[] array, char value) { - for (int i = array.length; i-- > 0; ) { - if (array[i] == value) { - return true; - } - } - return false; - } - - /** - * Return whether the specified array contains the - * specified element. - * java.util.Arrays#contains(int[] array, int value) - */ - public static boolean contains(int[] array, int value) { - for (int i = array.length; i-- > 0; ) { - if (array[i] == value) { - return true; - } - } - return false; - } - - /** - * Return whether the specified collection contains all of the - * elements in the specified iterator. - * java.util.Collection#containsAll(java.util.Iterator iterator) - */ - 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. - * java.util.Collection#containsAll(Object[] array) - */ - 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 iterator contains all of the - * elements in the specified collection. - * java.util.Iterator#containsAll(java.util.Collection collection) - */ - public static boolean containsAll(Iterator iterator, Collection collection) { - return collection(iterator).containsAll(collection); - } - - /** - * Return whether the specified iterator 1 contains all of the - * elements in the specified iterator 2. - * java.util.Iterator#containsAll(java.util.Iterator iterator) - */ - public static boolean containsAll(Iterator iterator1, Iterator iterator2) { - return containsAll(collection(iterator1), iterator2); - } - - /** - * Return whether the specified iterator contains all of the - * elements in the specified array. - * java.util.Iterator#containsAll(Object[] array) - */ - public static boolean containsAll(Iterator iterator, Object[] array) { - return containsAll(collection(iterator), array); - } - - /** - * Return whether the specified array contains all of the - * elements in the specified collection. - * java.util.Arrays#containsAll(Object[] array, java.util.Collection collection) - */ - 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 iterator. - * java.util.Arrays#containsAll(Object[] array, java.util.Iterator iterator) - */ - public static boolean containsAll(Object[] array, Iterator iterator) { - while (iterator.hasNext()) { - if ( ! contains(array, iterator.next())) { - return false; - } - } - return true; - } - - /** - * Return whether the specified array 1 contains all of the - * elements in the specified array 2. - * java.util.Arrays#containsAll(Object[] array1, Object[] array2) - */ - public static boolean containsAll(Object[] array1, Object[] 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. - * java.util.Arrays#containsAll(char[] array1, char[] array2) - */ - 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. - * java.util.Arrays#containsAll(int[] array1, int[] array2) - */ - public static boolean containsAll(int[] array1, int[] array2) { - for (int i = array2.length; i-- > 0; ) { - if ( ! contains(array1, array2[i])) { - return false; - } - } - return true; - } - - /** - * 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' #equals() method to compare the - * elements. - */ - public static int diffEnd(Object[] array1, Object[] array2) { - return diffEnd(Arrays.asList(array1), Arrays.asList(array2)); - } - - /** - * 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' #equals() method to compare the - * elements. - */ - public static int diffEnd(List list1, List list2) { - int size1 = list1.size(); - int size2 = list2.size(); - if (size1 != size2) { - return Math.max(size1, size2) - 1; - } - int end = size1 - 1; - while (end > -1) { - Object o = list1.get(end); - if (o == null) { - if (list2.get(end) == null) { - end--; - } else { - return end; - } - } else { - if (o.equals(list2.get(end))) { - end--; - } else { - return end; - } - } - } - return end; - } - - /** - * Return the range of elements in the specified - * arrays that are different. - * If the arrays are identical, return [size, -1]. - * Use the elements' #equals() method to compare the - * elements. - * @see #diffStart(Object[], Object[]) - * @see #diffEnd(Object[], Object[]) - */ - public static Range diffRange(Object[] array1, Object[] array2) { - return diffRange(Arrays.asList(array1), Arrays.asList(array2)); - } - - /** - * Return the range of elements in the specified - * arrays that are different. - * If the arrays are identical, return [size, -1]. - * Use the elements' #equals() method to compare the - * elements. - * @see #diffStart(java.util.List, java.util.List) - * @see #diffEnd(java.util.List, java.util.List) - */ - public static Range diffRange(List list1, List list2) { - int end = diffEnd(list1, list2); - if (end == -1) { - // the lists are identical, the start is the size of the two lists - return new Range(list1.size(), end); - } - // the lists are different, calculate the start of the range - return new Range(diffStart(list1, list2), 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' #equals() method to compare the - * elements. - */ - public static int diffStart(Object[] array1, Object[] array2) { - return diffStart(Arrays.asList(array1), Arrays.asList(array2)); - } - - /** - * 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' #equals() method to compare the - * elements. - */ - public static int diffStart(List list1, List list2) { - int end = Math.min(list1.size(), list2.size()); - int start = 0; - while (start < end) { - Object o = list1.get(start); - if (o == null) { - if (list2.get(start) == null) { - start++; - } else { - return start; - } - } else { - if (o.equals(list2.get(start))) { - start++; - } else { - return start; - } - } - } - return start; - } - - /** - * Return whether the specified iterators return equal elements. - * java.util.ListIterator#equals(java.util.ListIterator iterator) - */ - public static boolean equals(ListIterator iterator1, ListIterator iterator2) { - while (iterator1.hasNext() && iterator2.hasNext()) { - Object o1 = iterator1.next(); - Object o2 = iterator2.next(); - if ( ! (o1 == null ? o2 == null : o1.equals(o2))) { - return false; - } - } - return ! (iterator1.hasNext() || iterator2.hasNext()); - } - - /** - * Return the element corresponding to the specified index - * in the specified iterator. - * java.util.ListIterator#get(int index) - */ - public static E get(ListIterator iterator, int index) { - while (iterator.hasNext()) { - E next = iterator.next(); - if (iterator.previousIndex() == index) { - return next; - } - } - throw new IndexOutOfBoundsException(String.valueOf(index) + ':' + String.valueOf(iterator.previousIndex())); - } - - /** - * Return whether the specified arrays contain the same elements. - * java.util.Arrays#identical(Object[] array1, Object[] array2) - */ - public static boolean identical(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; - } - - /** - * Return whether the specified iterators return the same elements. - * java.util.ListIterator#identical(java.util.ListIterator iterator) - */ - public static boolean identical(ListIterator iterator1, ListIterator iterator2) { - while (iterator1.hasNext() && iterator2.hasNext()) { - if (iterator1.next() != iterator2.next()) { - return false; - } - } - return ! (iterator1.hasNext() || iterator2.hasNext()); - } - - /** - * 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) { - return identityDiffEnd(Arrays.asList(array1), Arrays.asList(array2)); - } - - /** - * 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. - */ - public static int identityDiffEnd(List list1, List list2) { - int size1 = list1.size(); - int size2 = list2.size(); - if (size1 != size2) { - return Math.max(size1, size2) - 1; - } - int end = size1 - 1; - while (end > -1) { - if (list1.get(end) == list2.get(end)) { - end--; - } else { - return end; - } - } - return end; - } - - /** - * 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) { - return identityDiffRange(Arrays.asList(array1), Arrays.asList(array2)); - } - - /** - * 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(java.util.List, java.util.List) - * @see #identityDiffEnd(java.util.List, java.util.List) - */ - public static Range identityDiffRange(List list1, List list2) { - int end = identityDiffEnd(list1, list2); - if (end == -1) { - // the lists are identical, the start is the size of the two lists - return new Range(list1.size(), end); - } - // the lists are different, calculate the start of the range - return new Range(identityDiffStart(list1, list2), 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) { - return identityDiffStart(Arrays.asList(array1), Arrays.asList(array2)); - } - - /** - * 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. - */ - public static int identityDiffStart(List list1, List list2) { - int end = Math.min(list1.size(), list2.size()); - int start = 0; - while (start < end) { - if (list1.get(start) == list2.get(start)) { - start++; - } else { - return start; - } - } - return start; - } - - /** - * Return the index of the first occurrence of the - * specified element in the specified iterator, - * or return -1 if there is no such index. - * java.util.ListIterator#indexOf(Object o) - */ - public static int indexOf(ListIterator 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; - } - - /** - * Return the index of the first occurrence of the - * specified element in the specified array, - * or return -1 if there is no such index. - * java.util.Arrays#indexOf(Object[] array, Object o) - */ - 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. - * java.util.Arrays#indexOf(char[] array, char value) - */ - 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. - * java.util.Arrays#indexOf(int[] array, int value) - */ - 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; - } - - /** - * Return the maximum index of where the specified comparable object - * should be inserted into the specified sorted list and still keep - * the list sorted. - */ - public static > int insertionIndexOf(List sortedList, Comparable value) { - int len = sortedList.size(); - for (int i = 0; i < len; i++) { - if (value.compareTo(sortedList.get(i)) < 0) { - return i; - } - } - return len; - } - - /** - * Return the maximum index of where the specified object - * should be inserted into the specified sorted list and still keep - * the list sorted. - */ - public static int insertionIndexOf(List sortedList, E value, Comparator comparator) { - int len = sortedList.size(); - for (int i = 0; i < len; i++) { - if (comparator.compare(value, sortedList.get(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 > int insertionIndexOf(E[] sortedArray, Comparable 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 int insertionIndexOf(E[] sortedArray, E value, Comparator comparator) { - int len = sortedArray.length; - for (int i = 0; i < len; i++) { - if (comparator.compare(value, sortedArray[i]) < 0) { - return i; - } - } - return len; - } - - /** - * Return a one-use Iterable for the Iterator given. - * Throws an IllegalStateException if iterable() is called more than once. - * As such, this utility should only be used in one-use situations, such as - * a "for" loop. - */ - public static Iterable iterable(final Iterator iterator) { - return new Iterable() { - private boolean used = false; - - public Iterator iterator() { - if (used) { - throw new IllegalStateException("This method has already been called"); - } - used = true; - return iterator; - } - }; - } - - /** - * Return an iterator on the elements in the specified array. - * java.util.Arrays#iterator(Object[] array) - */ - public static Iterator iterator(E... array) { - return new ArrayIterator(array); - } - - /** - * Return the index of the last occurrence of the - * specified element in the specified iterator, - * or return -1 if there is no such index. - * java.util.ListIterator#lastIndexOf(Object o) - */ - public static int lastIndexOf(ListIterator iterator, Object value) { - return list(iterator).lastIndexOf(value); - } - - /** - * Return the index of the last occurrence of the - * specified element in the specified array, - * or return -1 if there is no such index. - * java.util.Arrays#lastIndexOf(Object[] array, Object o) - */ - 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. - * java.util.Arrays#lastIndexOf(char[] array, char value) - */ - 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. - * java.util.Arrays#lastIndexOf(int[] array, int value) - */ - public static int lastIndexOf(int[] array, int value) { - for (int i = array.length; i-- > 0; ) { - if (array[i] == value) { - return i; - } - } - return -1; - } - - /** - * Return a list corresponding to the specified iterator. - * java.util.Iterator#toList() - */ - public static List list(Iterator iterator) { - List list = new ArrayList(); - while (iterator.hasNext()) { - list.add(iterator.next()); - } - return list; - } - - /** - * Return a list corresponding to the specified array. - * Unlike java.util.Arrays.asList(Object[]), the list - * is modifiable and is not backed by the array. - */ - public static List list(E... array) { - List list = new ArrayList(array.length); - for (E item : array) { - list.add(item); - } - return list; - } - - /** - * Return a list iterator for the specified array. - * java.util.Arrays#listIterator(Object[] array) - */ - public static ListIterator listIterator(E... array) { - return listIterator(array, 0); - } - - /** - * Return a list iterator for the specified array - * starting at the specified position in the array. - * java.util.Arrays#listIterator(Object[] array, int index) - */ - public static ListIterator listIterator(E[] array, int index) { - return Arrays.asList(array).listIterator(index); - } - - /** - * Return the character from the specified array with the maximum value. - * java.util.Arrays#max(char[] array) - */ - public static char max(char... array) { - int len = array.length; - if (len == 0) { - throw new IndexOutOfBoundsException(); - } - char max = array[0]; - // start at 1 - for (int i = 1; i < len; i++) { - char next = array[i]; - if (next > max) { - max = next; - } - } - return max; - } - - /** - * Return the integer from the specified array with the maximum value. - * java.util.Arrays#max(int[] array) - */ - public static int max(int... array) { - int len = array.length; - if (len == 0) { - throw new IndexOutOfBoundsException(); - } - int max = array[0]; - // start at 1 - for (int i = 1; i < len; i++) { - int next = array[i]; - if (next > max) { - max = next; - } - } - return max; - } - - /** - * Return the character from the specified array with the minimum value. - * java.util.Arrays#min(char[] array) - */ - public static char min(char... array) { - int len = array.length; - if (len == 0) { - throw new IndexOutOfBoundsException(); - } - char min = array[0]; - // start at 1 - for (int i = 1; i < len; i++) { - char next = array[i]; - if (next < min) { - min = next; - } - } - return min; - } - - /** - * Return the integer from the specified array with the minimum value. - * java.util.Arrays#min(int[] array) - */ - public static int min(int... array) { - int len = array.length; - if (len == 0) { - throw new IndexOutOfBoundsException(); - } - int min = array[0]; - // start at 1 - for (int i = 1; i < len; i++) { - int next = array[i]; - if (next < min) { - min = next; - } - } - return min; - } - - /** - * Replace all occurrences of the specified old value with - * the specified new value. - * java.util.Arrays#replaceAll(Object[] array, Object oldValue, Object newValue) - */ - public static 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. - * java.util.Arrays#replaceAll(int[] array, int oldValue, int newValue) - */ - 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. - * java.util.Arrays#replaceAll(char[] array, char oldValue, char newValue) - */ - 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; - } - - /** - * Return a new array that contains the elements in the - * specified array with the specified element removed. - * java.util.Arrays#remove(Object[] array, Object value) - */ - public static 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. - * java.util.Arrays#remove(char[] array, char value) - */ - 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. - * java.util.Arrays#remove(int[] array, int value) - */ - public static int[] remove(int[] array, int value) { - return removeElementAtIndex(array, indexOf(array, value)); - } - - /** - * Remove all the elements returned by the specified iterator - * from the specified collection. - * Return whether the collection changed as a result. - * java.util.Collection#removeAll(java.util.Iterator iterator) - */ - public static boolean removeAll(Collection collection, Iterator iterator) { - boolean modified = false; - while (iterator.hasNext()) { - modified |= removeAllOccurrences(collection, iterator.next()); - } - return modified; - } - - /** - * Remove all the elements in the specified array - * from the specified collection. - * Return whether the collection changed as a result. - * java.util.Collection#removeAll(Object[] array) - */ - public static boolean removeAll(Collection collection, Object[] array) { - boolean modified = false; - for (int i = array.length; i-- > 0; ) { - modified |= removeAllOccurrences(collection, array[i]); - } - return modified; - } - - /** - * Remove from the specified array all the elements in - * the specified collection and return the result. - * java.util.Arrays#removeAll(Object[] array, Collection collection) - */ - public static E[] removeAll(E[] array, Collection collection) { - E[] result = array; - // go backwards since we will be pulling elements - // out of 'result' and it will get shorter as we go - for (int i = array.length; i-- > 0; ) { - E item = array[i]; - if (collection.contains(item)) { - result = removeElementAtIndex(result, i); - } - } - return result; - } - - /** - * Remove from the first specified array all the elements in - * the second specified array and return the result. - * java.util.Arrays#removeAll(Object[] array1, Object[] array2) - */ - public static E[] removeAll(E[] array1, Object[] array2) { - // convert to a bag to take advantage of hashed look-up - return removeAll(array1, bag(array2)); - } - - /** - * Remove from the first specified array all the elements in - * the second specified array and return the result. - * java.util.Arrays#removeAll(char[] array1, char[] array2) - */ - public static char[] removeAll(char[] array1, char[] array2) { - char[] result1 = array1; - // go backwards since we will be pulling elements - // out of 'result1' and it will get shorter as we go - for (int i = array1.length; i-- > 0; ) { - char item = array1[i]; - if (contains(array2, item)) { - result1 = removeElementAtIndex(result1, i); - } - } - return result1; - } - - /** - * Remove from the first specified array all the elements in - * the second specified array and return the result. - * java.util.Arrays#removeAll(int[] array1, int[] array2) - */ - public static int[] removeAll(int[] array1, int[] array2) { - int[] result1 = array1; - // go backwards since we will be pulling elements - // out of 'result1' and it will get shorter as we go - for (int i = array1.length; i-- > 0; ) { - int item = array1[i]; - if (contains(array2, item)) { - result1 = removeElementAtIndex(result1, i); - } - } - return result1; - } - - /** - * Remove all occurrences of the specified element - * from the specified collection. - * Return whether the collection changed as a result. - * java.util.Collection#removeAllOccurrences(Object value) - */ - 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 from the specified array all occurrences of - * the specified element and return the result. - * java.util.Arrays#removeAllOccurrences(Object[] array, Object value) - */ - public static E[] removeAllOccurrences(E[] array, Object value) { - E[] result = array; - if (value == null) { - // go backwards since we will be pulling elements - // out of 'result' and it will get shorter as we go - for (int i = array.length; i-- > 0; ) { - if (array[i] == null) { - result = removeElementAtIndex(result, i); - } - } - } else { - // go backwards since we will be pulling elements - // out of 'result' and it will get shorter as we go - for (int i = array.length; i-- > 0; ) { - if (value.equals(array[i])) { - result = removeElementAtIndex(result, i); - } - } - } - return result; - } - - /** - * Remove from the specified array all occurrences of - * the specified element and return the result. - * java.util.Arrays#removeAllOccurrences(char[] array, char value) - */ - public static char[] removeAllOccurrences(char[] array, char value) { - char[] result = array; - // go backwards since we will be pulling elements - // out of 'result' and it will get shorter as we go - for (int i = array.length; i-- > 0; ) { - if (array[i] == value) { - result = removeElementAtIndex(result, i); - } - } - return result; - } - - /** - * Remove from the specified array all occurrences of - * the specified element and return the result. - * java.util.Arrays#removeAllOccurrences(int[] array, int value) - */ - public static int[] removeAllOccurrences(int[] array, int value) { - int[] result = array; - // go backwards since we will be pulling elements - // out of 'result' and it will get shorter as we go - for (int i = array.length; i-- > 0; ) { - if (array[i] == value) { - result = removeElementAtIndex(result, i); - } - } - return result; - } - - /** - * Return a new array that contains the elements in the - * specified array with the specified element removed. - * java.util.Arrays#removeElementAtIndex(Object[] array, int index) - */ - @SuppressWarnings("unchecked") - public static E[] removeElementAtIndex(E[] array, int index) { - int len = array.length; - E[] result = (E[]) Array.newInstance(array.getClass().getComponentType(), len - 1); - System.arraycopy(array, 0, result, 0, index); - System.arraycopy(array, index + 1, result, index, len - index - 1); - return result; - } - - /** - * Return a new array that contains the elements in the - * specified array with the specified element removed. - * java.util.Arrays#removeElementAtIndex(char[] array, int index) - */ - public static char[] removeElementAtIndex(char[] array, int index) { - int len = array.length; - char[] result = new char[len - 1]; - System.arraycopy(array, 0, result, 0, index); - System.arraycopy(array, index + 1, result, index, len - index - 1); - return result; - } - - /** - * Return a new array that contains the elements in the - * specified array with the specified element removed. - * java.util.Arrays#removeElementAtIndex(int[] array, int index) - */ - public static int[] removeElementAtIndex(int[] array, int index) { - int len = array.length; - int[] result = new int[len - 1]; - System.arraycopy(array, 0, result, 0, index); - System.arraycopy(array, index + 1, result, index, len - index - 1); - return result; - } - - /** - * Remove any duplicate elements from the specified array, - * while maintaining the order. - */ - @SuppressWarnings("unchecked") - public static E[] removeDuplicateElements(E... array) { - List list = removeDuplicateElements(Arrays.asList(array)); - return list.toArray((E[]) Array.newInstance(array.getClass().getComponentType(), list.size())); - } - - /** - * Remove any duplicate elements from the specified list, - * while maintaining the order. - */ - public static List removeDuplicateElements(List list) { - List result = new ArrayList(list.size()); - Set set = new HashSet(list.size()); // take advantage of hashed look-up - for (E item : list) { - if (set.add(item)) { - result.add(item); - } - } - return result; - } - - /** - * Retain only the elements in the specified iterator - * in the specified collection. - * Return whether the collection changed as a result. - * java.util.Collection#retainAll(java.util.Iterator iterator) - */ - public static boolean retainAll(Collection collection, Iterator iterator) { - return collection.retainAll(collection(iterator)); - } - - /** - * Retain only the elements in the specified array - * in the specified collection. - * Return whether the collection changed as a result. - * java.util.Collection#retainAll(Object[] array) - */ - public static boolean retainAll(Collection collection, Object[] array) { - return collection.retainAll(set(array)); - } - - /** - * Retain in the specified array all the elements in - * the specified collection and return the result. - * java.util.Arrays#retainAll(Object[] array, Collection collection) - */ - public static E[] retainAll(E[] array, Collection collection) { - E[] result = array; - // go backwards since we will be pulling elements - // out of 'result' and it will get shorter as we go - for (int i = array.length; i-- > 0; ) { - if ( ! collection.contains(array[i])) { - result = removeElementAtIndex(result, i); - } - } - return result; - } - - /** - * Remove from the first specified array all the elements in - * the second specified array and return the result. - * java.util.Arrays#retainAll(Object[] array1, Object[] array2) - */ - public static E[] retainAll(E[] array1, Object[] array2) { - // convert to a bag to take advantage of hashed look-up - return retainAll(array1, bag(array2)); - } - - /** - * Remove from the first specified array all the elements in - * the second specified array and return the result. - * java.util.Arrays#retainAll(char[] array1, char[] array2) - */ - public static char[] retainAll(char[] array1, char[] array2) { - char[] result1 = array1; - // go backwards since we will be pulling elements - // out of 'result1' and it will get shorter as we go - for (int i = array1.length; i-- > 0; ) { - char item = array1[i]; - if ( ! contains(array2, item)) { - result1 = removeElementAtIndex(result1, i); - } - } - return result1; - } - - /** - * Remove from the first specified array all the elements in - * the second specified array and return the result. - * java.util.Arrays#removeAll(int[] array1, int[] array2) - */ - public static int[] retainAll(int[] array1, int[] array2) { - int[] result1 = array1; - // go backwards since we will be pulling elements - // out of 'result1' and it will get shorter as we go - for (int i = array1.length; i-- > 0; ) { - int item = array1[i]; - if ( ! contains(array2, item)) { - result1 = removeElementAtIndex(result1, i); - } - } - return result1; - } - - /** - * Return the array reversed. - * java.util.Arrays.reverse(Object[] array) - */ - public static E[] reverse(E... array) { - int len = array.length; - for (int i = 0, mid = len >> 1, j = len - 1; i < mid; i++, j--) { - swap(array, i, j); - } - return array; - } - - /** - * Return the array reversed. - * java.util.Arrays.reverse(char[] array) - */ - public static char[] reverse(char... array) { - int len = array.length; - for (int i = 0, mid = len >> 1, j = len - 1; i < mid; i++, j--) { - swap(array, i, j); - } - return array; - } - - /** - * Return the array reversed. - * java.util.Arrays.reverse(int[] array) - */ - public static int[] reverse(int... array) { - int len = array.length; - for (int i = 0, mid = len >> 1, j = len - 1; i < mid; i++, j--) { - swap(array, i, j); - } - return array; - } - - /** - * Return a list with entries in reverse order from those - * returned by the specified iterator. - */ - public static List reverseList(Iterator iterator) { - return reverse(list(iterator)); - } - - /** - * Return the rotated array after rotating it one position. - * java.util.Arrays.rotate(Object[] array) - */ - public static E[] rotate(E... array) { - return rotate(array, 1); - } - - /** - * Return the rotated array after rotating it the specified distance. - * java.util.Arrays.rotate(Object[] array, int distance) - */ - public static E[] rotate(E[] array, int distance) { - int len = array.length; - if (len == 0) { - 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. - * java.util.Arrays.rotate(char[] array) - */ - public static char[] rotate(char... array) { - return rotate(array, 1); - } - - /** - * Return the rotated array after rotating it the specified distance. - * java.util.Arrays.rotate(char[] array, int distance) - */ - public static char[] rotate(char[] array, int distance) { - int len = array.length; - if (len == 0) { - 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. - * java.util.Arrays.rotate(int[] array) - */ - public static int[] rotate(int... array) { - return rotate(array, 1); - } - - /** - * Return the rotated array after rotating it the specified distance. - * java.util.Arrays.rotate(int[] array, int distance) - */ - public static int[] rotate(int[] array, int distance) { - int len = array.length; - if (len == 0) { - 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; - } - - /** - * Return a set corresponding to the specified iterator. - * java.util.HashSet(java.util.Iterator iterator) - */ - public static Set set(Iterator iterator) { - Set set = new HashSet(); - while (iterator.hasNext()) { - set.add(iterator.next()); - } - return set; - } - - /** - * Return a set corresponding to the specified array. - * java.util.HashSet(Object[] array) - */ - public static Set set(E... array) { - Set set = new HashSet(2 * array.length); - for (E item : array) { - set.add(item); - } - return set; - } - - private static final Random RANDOM = new Random(); - - /** - * Return the array after "shuffling" it. - * java.util.Arrays#shuffle(Object[] array) - */ - public static E[] shuffle(E... array) { - return shuffle(array, RANDOM); - } - - /** - * Return the array after "shuffling" it. - * java.util.Arrays#shuffle(Object[] array, Random r) - */ - public static E[] shuffle(E[] array, Random random) { - int len = array.length; - for (int i = len; i-- > 0; ) { - swap(array, i, random.nextInt(len)); - } - return array; - } - - /** - * Return the array after "shuffling" it. - * java.util.Arrays#shuffle(char[] array) - */ - public static char[] shuffle(char... array) { - return shuffle(array, RANDOM); - } - - /** - * Return the array after "shuffling" it. - * java.util.Arrays#shuffle(char[] array, Random r) - */ - public static char[] shuffle(char[] array, Random random) { - int len = array.length; - for (int i = len; i-- > 0; ) { - swap(array, i, random.nextInt(len)); - } - return array; - } - - /** - * Return the array after "shuffling" it. - * java.util.Arrays#shuffle(int[] array) - */ - public static int[] shuffle(int... array) { - return shuffle(array, RANDOM); - } - - /** - * Return the array after "shuffling" it. - * java.util.Arrays#shuffle(int[] array, Random r) - */ - public static int[] shuffle(int[] array, Random random) { - int len = array.length; - for (int i = len; i-- > 0; ) { - swap(array, i, random.nextInt(len)); - } - return array; - } - - /** - * Return an iterator that returns only the single, - * specified object. - * Object#toIterator() ?! - */ - public static Iterator singletonIterator(E value) { - return new SingleElementIterator(value); - } - - /** - * Return the number of elements returned by the specified iterator. - * java.util.Iterator#size() - */ - public static int size(Iterator iterator) { - int size = 0; - while (iterator.hasNext()) { - iterator.next(); - size++; - } - return size; - } - - /** - * Return a sorted set corresponding to the specified iterator. - * java.util.TreeSet(java.util.Iterator iterator) - */ - public static > SortedSet sortedSet(Iterator iterator) { - return sortedSet(iterator, null); - } - - /** - * Return a sorted set corresponding to the specified iterator - * and comparator. - * java.util.TreeSet(java.util.Iterator iterator, java.util.Comparator c) - */ - public static SortedSet sortedSet(Iterator iterator, Comparator comparator) { - SortedSet sortedSet = new TreeSet(comparator); - sortedSet.addAll(list(iterator)); - return sortedSet; - } - - /** - * Return a sorted set corresponding to the specified array. - * java.util.TreeSet(Object[] array) - */ - public static > SortedSet sortedSet(E... array) { - return sortedSet(array, null); - } - - /** - * Return a sorted set corresponding to the specified array - * and comparator. - * java.util.TreeSet(Object[] array, java.util.Comparator c) - */ - public static SortedSet sortedSet(E[] array, Comparator comparator) { - SortedSet sortedSet = new TreeSet(comparator); - sortedSet.addAll(Arrays.asList(array)); - return sortedSet; - } - - /** - * Return the array after the specified elements have been "swapped". - * java.util.Arrays#swap(Object[] array, int i, int j) - */ - public static 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". - * java.util.Arrays#swap(char[] array, int i, int j) - */ - public 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". - * java.util.Arrays#swap(int[] array, int i, int j) - */ - public static int[] swap(int[] array, int i, int j) { - int temp = array[i]; - array[i] = array[j]; - array[j] = temp; - return array; - } - - /** - * Return a vector corresponding to the specified iterator. - * This is useful for legacy code that requires a java.util.Vector. - * java.util.Vector(java.util.Iterator iterator) - */ - public static Vector vector(Iterator iterator) { - Vector v = new Vector(); - 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 java.util.Vector. - * java.util.Vector(Object[] array) - */ - public static Vector vector(E... array) { - int len = array.length; - Vector v = new Vector(len); - for (E item : array) { - v.addElement(item); - } - return v; - } - - - //********** java.util.Collections enhancements ********** - - /** - * Return the destination list after the source list has been copied into it. - * @see java.util.Collections#copy(java.util.List, java.util.List) - */ - public static List copy(List dest, List src) { - Collections.copy(dest, src); - return dest; - } - - /** - * Return the list after it has been "filled". - * @see java.util.Collections#fill(java.util.List, java.lang.Object) - */ - public static List fill(List list, E value) { - Collections.fill(list, value); - return list; - } - - /** - * Return the list after it has been "reversed". - * @see java.util.Collections#reverse(java.util.List) - */ - public static List reverse(List list) { - Collections.reverse(list); - return list; - } - - /** - * Return the list after it has been "rotated" by one position. - * @see java.util.Collections#rotate(java.util.List, int) - */ - public static List rotate(List list) { - return rotate(list, 1); - } - - /** - * Return the list after it has been "rotated". - * @see java.util.Collections#rotate(java.util.List, int) - */ - public static List rotate(List list, int distance) { - Collections.rotate(list, distance); - return list; - } - - /** - * Return the list after it has been "shuffled". - * @see java.util.Collections#shuffle(java.util.List) - */ - public static List shuffle(List list) { - Collections.shuffle(list); - return list; - } - - /** - * Return the list after it has been "shuffled". - * @see java.util.Collections#shuffle(java.util.List, java.util.Random) - */ - public static List shuffle(List list, Random random) { - Collections.shuffle(list, random); - return list; - } - - /** - * Return the list after it has been "sorted". - * @see java.util.Collections#sort(java.util.List) - */ - public static > List sort(List list) { - Collections.sort(list); - return list; - } - - /** - * Return the list after it has been "sorted". - * @see java.util.Collections#sort(java.util.List, java.util.Comparator) - */ - public static List sort(List list, Comparator comparator) { - Collections.sort(list, comparator); - return list; - } - - /** - * Return the iterator after it has been "sorted". - */ - public static > Iterator sort(Iterator iterator) { - return sort(iterator, null); - } - - /** - * Return the list after it has been "sorted". - */ - public static Iterator sort(Iterator iterator, Comparator comparator) { - return sort(list(iterator), comparator).iterator(); - } - - /** - * Return the list after the specified elements have been "swapped". - * @see java.util.Collections#swap(java.util.List, int, int) - */ - public static List swap(List list, int i, int j) { - Collections.swap(list, i, j); - return list; - } - - - //********** java.util.Arrays enhancements ********** - - /** - * Return the array after it has been "filled". - * @see java.util.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 java.util.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 java.util.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 java.util.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 java.util.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 java.util.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 java.util.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 java.util.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 java.util.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 java.util.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 java.util.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 java.util.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 java.util.Arrays#fill(Object[], Object) - */ - public static E[] fill(E[] array, E value) { - Arrays.fill(array, value); - return array; - } - - /** - * Return the array after it has been "filled". - * @see java.util.Arrays#fill(Object[], int, int, Object) - */ - public static 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 java.util.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 java.util.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 java.util.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 java.util.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 java.util.Arrays#sort(byte[]) - */ - public static byte[] sort(byte... array) { - Arrays.sort(array); - return array; - } - - /** - * Return the array after it has been "sorted". - * @see java.util.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 java.util.Arrays#sort(char[]) - */ - public static char[] sort(char... array) { - Arrays.sort(array); - return array; - } - - /** - * Return the array after it has been "sorted". - * @see java.util.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 java.util.Arrays#sort(double[]) - */ - public static double[] sort(double... array) { - Arrays.sort(array); - return array; - } - - /** - * Return the array after it has been "sorted". - * @see java.util.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 java.util.Arrays#sort(float[]) - */ - public static float[] sort(float... array) { - Arrays.sort(array); - return array; - } - - /** - * Return the array after it has been "sorted". - * @see java.util.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 java.util.Arrays#sort(int[]) - */ - public static int[] sort(int... array) { - Arrays.sort(array); - return array; - } - - /** - * Return the array after it has been "sorted". - * @see java.util.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 java.util.Arrays#sort(Object[]) - */ - public static E[] sort(E... array) { - Arrays.sort(array); - return array; - } - - /** - * Return the array after it has been "sorted". - * @see java.util.Arrays#sort(Object[], java.util.Comparator) - */ - public static E[] sort(E[] array, Comparator comparator) { - Arrays.sort(array, comparator); - return array; - } - - /** - * Return the array after it has been "sorted". - * @see java.util.Arrays#sort(Object[], int, int) - */ - public static E[] sort(E[] array, int fromIndex, int toIndex) { - Arrays.sort(array, fromIndex, toIndex); - return array; - } - - /** - * Return the array after it has been "sorted". - * @see java.util.Arrays#sort(Object[], int, int, java.util.Comparator) - */ - public static E[] sort(E[] array, int fromIndex, int toIndex, Comparator comparator) { - Arrays.sort(array, fromIndex, toIndex, comparator); - return array; - } - - /** - * Return the array after it has been "sorted". - * @see java.util.Arrays#sort(long[]) - */ - public static long[] sort(long... array) { - Arrays.sort(array); - return array; - } - - /** - * Return the array after it has been "sorted". - * @see java.util.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 java.util.Arrays#sort(short[]) - */ - public static short[] sort(short... array) { - Arrays.sort(array); - return array; - } - - /** - * Return the array after it has been "sorted". - * @see java.util.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 CollectionTools() { - super(); - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/FileTools.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/FileTools.java deleted file mode 100644 index 39c3efed1c..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/FileTools.java +++ /dev/null @@ -1,1006 +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.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.utility.internal.iterators.ArrayIterator; -import org.eclipse.jpt.utility.internal.iterators.CompositeIterator; -import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; -import org.eclipse.jpt.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"); - public static final String USER_TEMPORARY_DIRECTORY_NAME = System.getProperty("java.io.tmpdir"); - public static String DEFAULT_TEMPORARY_DIRECTORY_NAME = "tmpdir"; - public static final String CURRENT_WORKING_DIRECTORY_NAME = System.getProperty("user.dir"); - - /** 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. */ - 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. - * USE WITH CARE. - * File#deleteAll()? - */ - public static void deleteDirectory(String directoryName) { - deleteDirectory(new File(directoryName)); - } - - /** - * Delete the specified directory and all of its contents. - * USE WITH CARE. - * File#deleteAll()? - */ - public static void deleteDirectory(File directory) { - deleteDirectoryContents(directory); - if ( ! directory.delete()) { - throw new RuntimeException("unable to delete directory: " + directory.getAbsolutePath()); - } - } - - /** - * Delete the contents of the specified directory - * (but not the directory itself). - * USE WITH CARE. - * File#deleteFiles() - */ - public static void deleteDirectoryContents(String directoryName) { - deleteDirectoryContents(new File(directoryName)); - } - - /** - * Delete the contents of the specified directory - * (but not the directory itself). - * USE WITH CARE. - * 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()); - } - } - } - } - - - // ********** 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()); - destinationFile.createNewFile(); - 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 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 filesIn(File directory) { - return filesIn(directory.listFiles()); - } - - private static Iterator filesIn(File[] files) { - return new FilteringIterator(new ArrayIterator(files)) { - @Override - protected boolean accept(Object next) { - return ((File) next).isFile(); - } - }; - } - - /** - * Return an iterator on all the subdirectories - * in the specified directory. - * File#subDirectories() - */ - public static Iterator directoriesIn(String directoryName) { - return directoriesIn(new File(directoryName)); - } - - /** - * Return an iterator on all the subdirectories - * in the specified directory. - * File#subDirectories() - */ - public static Iterator directoriesIn(File directory) { - return directoriesIn(directory.listFiles()); - } - - private static Iterator directoriesIn(File[] files) { - return new FilteringIterator(new ArrayIterator(files)) { - @Override - protected boolean accept(Object next) { - return ((File) 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 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 filesInTree(File directory) { - return filesInTreeAsSet(directory).iterator(); - } - - private static Set filesInTreeAsSet(File directory) { - Set files = new HashSet(10000); - addFilesInTreeTo(directory, files); - return files; - } - - private static void addFilesInTreeTo(File directory, Collection 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 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 directoriesInTree(File directory) { - File[] files = directory.listFiles(); - return new CompositeIterator(directoriesIn(files), directoriesInTrees(directoriesIn(files))); - } - - private static Iterator directoriesInTrees(Iterator directories) { - return new CompositeIterator( - new TransformationIterator>(directories) { - @Override - protected Iterator 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 ""; - } - 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 { - dir.mkdirs(); - } - return dir; - } - - /** - * 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()) { - dir.mkdirs(); - } - 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(".")) { - 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("/")) { - 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 canonicalFiles(Iterator files) { - return new TransformationIterator(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 canonicalFiles(Collection 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 canonicalFileNames(Iterator fileNames) { - return new TransformationIterator(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 canonicalFileNames(Collection 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 (CollectionTools.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(); - StringBuffer sb = new StringBuffer(len); - for (int i = 0; i < len; i++) { - char filenameChar = filename.charAt(i); - if (CollectionTools.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) { - if (executingOnWindows()) { - return CollectionTools.contains(WINDOWS_RESERVED_FILE_NAMES, fileName.toLowerCase()); - } - return false; // Unix does not have any "reserved" file names (I think...) - } - - /** - * 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; - } - - StringBuffer sb = new StringBuffer(); - 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, "..."); - } - - 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 ********** - - private static boolean executingOnWindows() { - return executingOn("Windows"); - } - -// private static boolean executingOnLinux() { -// return executingOn("Linux"); -// } -// - private static boolean executingOn(String osName) { - return System.getProperty("os.name").indexOf(osName) != -1; - } - - /** - * Return only the files that fit the filter. - * File#files(FileFilter fileFilter) - */ - public static Iterator filter(Iterator files, final FileFilter fileFilter) { - return new FilteringIterator(files) { - @Override - protected boolean accept(Object next) { - return fileFilter.accept((File) 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("."); - } - - 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 path = new ArrayList(); - 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); - } - File result = new File(".."); - for (int i = len - 1; i-- > 0; ) { - result = new File(result, ".."); - } - 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/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Filter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Filter.java deleted file mode 100644 index 20f95e0c33..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Filter.java +++ /dev/null @@ -1,46 +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.utility.internal; - -/** - * Used by various "pluggable" classes to filter objects. - */ -public interface Filter { - - /** - * 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); - - - final class Null implements Filter { - @SuppressWarnings("unchecked") - public static final Filter INSTANCE = new Null(); - @SuppressWarnings("unchecked") - public static Filter instance() { - return INSTANCE; - } - // ensure single instance - private Null() { - super(); - } - // nothing is filtered - everything is accepted - public boolean accept(S next) { - return true; - } - @Override - public String toString() { - return "Filter.Null"; - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/HashBag.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/HashBag.java deleted file mode 100644 index 5017cf944d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/HashBag.java +++ /dev/null @@ -1,733 +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.utility.internal; - -import java.io.Serializable; -import java.util.AbstractCollection; -import java.util.Collection; -import java.util.Collections; -import java.util.ConcurrentModificationException; -import java.util.Iterator; -import java.util.NoSuchElementException; - -/** - * This class implements the 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 that the order - * will remain constant over time. This class permits the null - * element. - *

- * This class offers constant time performance for the basic operations - * (add, remove, contains and - * size), 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. - *

- * Note that this implementation is not synchronized. If multiple - * threads access a bag concurrently, and at least one of the threads modifies - * the bag, it must 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 - * Collections.synchronizedCollection method. This is - * best done at creation time, to prevent accidental unsynchronized access - * to the bag: - *

- * Collection c = Collections.synchronizedCollection(new HashBag(...));
- * 
- *

- * The iterators returned by this class's iterator method are - * fail-fast: if the bag is modified at any time after the iterator is - * created, in any way except through the iterator's own remove - * method, the iterator throws a 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. - * - * @see Collections#synchronizedCollection(Collection) - */ - -public class HashBag extends AbstractCollection - implements Bag, Cloneable, Serializable { - - /** The hash table. */ - transient Entry[] table; - - /** The total number of entries in the bag. */ - transient int count = 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 (int)(capacity * loadFactor).) - * - * @serial - */ - private int threshold; - - /** - * The load factor for the hash table. - * - * @serial - */ - private 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; - - /** - * Constructs a new, empty bag with the - * default capacity, which is 11, and load factor, which is 0.75. - */ - public HashBag() { - this(11, 0.75f); - } - - /** - * Constructs a new, empty bag with the specified initial capacity - * and default load factor, which is 0.75. - * - * @param initialCapacity the initial capacity of the backing map. - * @throws IllegalArgumentException if the initial capacity is less - * than zero. - */ - public HashBag(int initialCapacity) { - this(initialCapacity, 0.75f); - } - - /** - * Constructs a new, empty bag with - * the specified initial capacity and the specified load factor. - * - * @param initialCapacity the initial capacity of the backing map. - * @param loadFactor the load factor of the backing map. - * @throws IllegalArgumentException if the initial capacity is less - * than zero, or if the load factor is nonpositive. - */ - @SuppressWarnings("unchecked") - public HashBag(int initialCapacity, float loadFactor) { - if (initialCapacity < 0) { - throw new IllegalArgumentException("Illegal Initial Capacity: " + initialCapacity); - } - if (loadFactor <= 0 || Float.isNaN(loadFactor)) { - throw new IllegalArgumentException("Illegal Load factor: " + loadFactor); - } - if (initialCapacity == 0) { - initialCapacity = 1; - } - this.loadFactor = loadFactor; - this.table = new Entry[initialCapacity]; - this.threshold = (int) (initialCapacity * loadFactor); - } - - /** - * Constructs a new bag containing the elements in the specified - * collection. The capacity of the bag is - * twice the size of the specified collection or 11 (whichever is - * greater), and the default load factor, which is 0.75, is used. - * - * @param c the collection whose elements are to be placed into this bag. - */ - public HashBag(Collection c) { - this(Math.max(2*c.size(), 11)); - this.addAll(c); - } - - /** - * This implementation simply returns the maintained count. - */ - @Override - public int size() { - return this.count; - } - - /** - * This implementation simply compares the maintained count to zero. - */ - @Override - public boolean isEmpty() { - return this.count == 0; - } - - /** - * 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 contains(Object o) { - Entry[] tab = this.table; - if (o == null) { - for (Entry e = tab[0]; e != null; e = e.next) { - if (e.object == null) { - return true; - } - } - } else { - int hash = o.hashCode(); - int index = (hash & 0x7FFFFFFF) % tab.length; - for (Entry e = tab[index]; e != null; e = e.next) { - if ((e.hash == hash) && o.equals(e.object)) { - return true; - } - } - } - return false; - } - - /** - * Return the number of times the specified object occurs in the bag. - */ - public int count(Object o) { - Entry[] tab = this.table; - if (o == null) { - for (Entry e = tab[0]; e != null; e = e.next) { - if (e.object == null) { - return e.count; - } - } - } else { - int hash = o.hashCode(); - int index = (hash & 0x7FFFFFFF) % tab.length; - for (Entry e = tab[index]; e != null; e = e.next) { - if ((e.hash == hash) && o.equals(e.object)) { - return e.count; - } - } - } - return 0; - } - - /** - * Rehashes the contents of this bag into a new hash table - * with a larger capacity. This method is called when the - * number of different elements in this map exceeds its - * capacity and load factor. - */ - @SuppressWarnings("unchecked") - private void rehash() { - Entry[] oldMap = this.table; - int oldCapacity = oldMap.length; - - int newCapacity = oldCapacity * 2 + 1; - Entry[] newMap = new Entry[newCapacity]; - - this.modCount++; - this.threshold = (int) (newCapacity * this.loadFactor); - this.table = newMap; - - for (int i = oldCapacity; i-- > 0; ) { - for (Entry old = oldMap[i]; old != null; ) { - Entry e = old; - old = old.next; - - int index = (e.hash & 0x7FFFFFFF) % newCapacity; - e.next = newMap[index]; - newMap[index] = e; - } - } - } - - /** - * 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 - @SuppressWarnings("unchecked") - public boolean add(E o) { - this.modCount++; - Entry[] tab = this.table; - int hash = 0; - int index = 0; - - // if the object is already in the bag, simply bump its count - if (o == null) { - for (Entry e = tab[0]; e != null; e = e.next) { - if (e.object == null) { - e.count++; - this.count++; - return true; - } - } - } else { - hash = o.hashCode(); - index = (hash & 0x7FFFFFFF) % tab.length; - for (Entry e = tab[index]; e != null; e = e.next) { - if ((e.hash == hash) && o.equals(e.object)) { - e.count++; - this.count++; - return true; - } - } - } - - // rehash the table if the threshold is exceeded - if (this.uniqueCount >= this.threshold) { - this.rehash(); - tab = this.table; - index = (hash & 0x7FFFFFFF) % tab.length; - } - - // create the new entry and put it in the table - Entry e = new Entry(hash, o, tab[index]); - tab[index] = e; - this.count++; - this.uniqueCount++; - return true; - } - - /** - * 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) { - Entry[] tab = this.table; - if (o == null) { - for (Entry e = tab[0], prev = null; e != null; prev = e, e = e.next) { - if (e.object == null) { - this.modCount++; - e.count--; - // if we are removing the last one, remove the entry from the table - if (e.count == 0) { - if (prev == null) { - tab[0] = e.next; - } else { - prev.next = e.next; - } - this.uniqueCount--; - } - this.count--; - return true; - } - } - } else { - int hash = o.hashCode(); - int index = (hash & 0x7FFFFFFF) % tab.length; - for (Entry e = tab[index], prev = null; e != null; prev = e, e = e.next) { - if ((e.hash == hash) && o.equals(e.object)) { - this.modCount++; - e.count--; - // if we are removing the last one, remove the entry from the table - if (e.count == 0) { - if (prev == null) { - tab[index] = e.next; - } else { - prev.next = e.next; - } - this.uniqueCount--; - } - this.count--; - return true; - } - } - } - - return false; - } - - /** - * This implementation simply clears out all of the hash table buckets. - */ - @Override - public void clear() { - Entry[] tab = this.table; - this.modCount++; - for (int i = tab.length; --i >= 0; ) { - tab[i] = null; - } - this.count = 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 - @SuppressWarnings("unchecked") - public HashBag clone() { - try { - HashBag clone = (HashBag) super.clone(); - clone.table = new Entry[this.table.length]; - for (int i = this.table.length; i-- > 0; ) { - clone.table[i] = (this.table[i] == null) - ? null : (Entry) this.table[i].clone(); - } - clone.modCount = 0; - return clone; - } catch (CloneNotSupportedException e) { - throw new InternalError(); - } - } - - /** - * Hash table collision list entry. - */ - private static class Entry { - int hash; - E object; - int count; - Entry next; - - Entry(int hash, E object, Entry next) { - this(hash, object, 1, next); - } - - private Entry(int hash, E object, int count, Entry next) { - this.hash = hash; - this.object = object; - this.count = count; - this.next = next; - } - - @Override - @SuppressWarnings("unchecked") - protected Entry clone() { - return new Entry(this.hash, this.object, this.count, - (this.next == null ? null : this.next.clone())); - } - - @Override - public String toString() { - return this.object + "=>" + this.count; - } - } - - @Override - @SuppressWarnings("unchecked") - public Iterator iterator() { - if (this.count == 0) { - return EMPTY_ITERATOR; - } - return new HashIterator(); - } - - /** - * 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. - */ - @SuppressWarnings("unchecked") - public Iterator uniqueIterator() { - if (this.count == 0) { - return EMPTY_ITERATOR; - } - return new UniqueIterator(); - } - - /** - * Empty iterator that does just about nothing. - */ - @SuppressWarnings("unchecked") - private static final Iterator EMPTY_ITERATOR = new EmptyIterator(); - - @SuppressWarnings("unchecked") - 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 { - Entry[] localTable = HashBag.this.table; - int index = this.localTable.length; // start at the end of the table - Entry nextEntry = null; - int nextEntryCount = 0; - Entry 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 = this.nextEntry; - int i = this.index; - Entry[] tab = this.localTable; - // 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 et = this.nextEntry; - int i = this.index; - Entry[] tab = this.localTable; - // 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 = 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(); - } - Entry[] tab = this.localTable; - int slot = (this.lastReturnedEntry.hash & 0x7FFFFFFF) % tab.length; - for (Entry e = tab[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) { - tab[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.count--; - this.lastReturnedEntry = null; // it cannot be removed again - return; - } - } - throw new ConcurrentModificationException(); - } - - } - - - private class UniqueIterator implements Iterator { - Entry[] localTable = HashBag.this.table; - int index = this.localTable.length; // start at the end of the table - Entry nextEntry = null; - Entry 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; - - UniqueIterator() { - super(); - } - - public boolean hasNext() { - Entry e = this.nextEntry; - int i = this.index; - Entry[] tab = this.localTable; - // 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 et = this.nextEntry; - int i = this.index; - Entry[] tab = this.localTable; - // 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 = this.lastReturnedEntry = this.nextEntry; - this.nextEntry = e.next; - return e.object; - } - - public void remove() { - if (this.lastReturnedEntry == null) { - throw new IllegalStateException(); - } - if (HashBag.this.modCount != this.expectedModCount) { - throw new ConcurrentModificationException(); - } - Entry[] tab = this.localTable; - int slot = (this.lastReturnedEntry.hash & 0x7FFFFFFF) % tab.length; - for (Entry e = tab[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) { - tab[slot] = e.next; - } else { - prev.next = e.next; - } - HashBag.this.uniqueCount--; - HashBag.this.count -= this.lastReturnedEntry.count; - this.lastReturnedEntry = null; // it cannot be removed again - return; - } - } - throw new ConcurrentModificationException(); - } - - } - - - @Override - @SuppressWarnings("unchecked") - public boolean equals(Object o) { - if (o == this) { - return true; - } - if ( ! (o instanceof Bag)) { - return false; - } - Bag b = (Bag) o; - if (b.size() != this.size()) { - return false; - } - Bag clone = this.clone(); - for (E e : b) { - if ( ! clone.remove(e)) { - return false; - } - } - return clone.isEmpty(); - } - - @Override - public int hashCode() { - int h = 0; - for (Iterator stream = this.iterator(); stream.hasNext(); ) { - Object next = stream.next(); - if (next != null) { - h += next.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 synchronized 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); - - Entry[] tab = this.table; - // write out elements and counts (alternating) - for (Entry entry : tab) { - 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). - */ - @SuppressWarnings("unchecked") - private synchronized 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 = new Entry[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++) { - E element = (E) s.readObject(); - int elementCount = s.readInt(); - for (int j = 0; j < elementCount; j++) { - this.add(element); - } - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/IndentingPrintWriter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/IndentingPrintWriter.java deleted file mode 100644 index c510c86ebb..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/IndentingPrintWriter.java +++ /dev/null @@ -1,148 +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.utility.internal; - -import java.io.PrintWriter; -import java.io.Writer; - -/** - * Extend 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"; - - - /** - * 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) { - super(out); - this.indent = indent; - this.indentLevel = 0; - 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. - */ - 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() { - return this.indentLevel; - } - - /** - * Allow the indent level to be set directly. - */ - public void setIndentLevel(int indentLevel) { - synchronized (this.lock) { - this.indentLevel = indentLevel; - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/JDBCTools.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/JDBCTools.java deleted file mode 100644 index 23c4f6d39e..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/JDBCTools.java +++ /dev/null @@ -1,348 +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.utility.internal; - -import java.sql.Types; -import java.util.HashMap; - -/** - * 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.javaClassName()); - } - - /** - * 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.getName()); - } - - /** - * 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 JDBC_TO_JAVA_TYPE_MAPPINGS; // pseudo 'final' - lazy-initialized - private static final JavaType DEFAULT_JAVA_TYPE = new JavaType(java.lang.Object.class); // TODO Object is the default? - - - private static JDBCToJavaTypeMapping jdbcToJavaTypeMapping(String jdbcTypeName) { - return jdbcToJavaTypeMappings().get(jdbcTypeName); - } - - private static synchronized HashMap jdbcToJavaTypeMappings() { - if (JDBC_TO_JAVA_TYPE_MAPPINGS == null) { - JDBC_TO_JAVA_TYPE_MAPPINGS = buildJDBCToJavaTypeMappings(); - } - return JDBC_TO_JAVA_TYPE_MAPPINGS; - } - - private static HashMap buildJDBCToJavaTypeMappings() { - HashMap mappings = new HashMap(); - 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 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 -// addJDBCMappingTo(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 mappings) { - // check for duplicates - JDBCType jdbcType = JDBCType.type(jdbcTypeCode); - Object prev = mappings.put(jdbcType.getName(), buildJDBCToJavaTypeMapping(jdbcType, javaClass)); - if (prev != null) { - throw new IllegalArgumentException("duplicate JDBC type: " + jdbcType.getName()); - } - } - - private static JDBCToJavaTypeMapping buildJDBCToJavaTypeMapping(JDBCType jdbcType, Class javaClass) { - return new JDBCToJavaTypeMapping(jdbcType, new JavaType(javaClass)); - } - - - // ********** Java => JDBC ********** - - /** - * Java => JDBC type mappings, keyed by Java class name (e.g. "java.lang.Object") - */ - private static HashMap 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 javaToJDBCTypeMappings() { - if (JAVA_TO_JDBC_TYPE_MAPPINGS == null) { - JAVA_TO_JDBC_TYPE_MAPPINGS = buildJavaToJDBCTypeMappings(); - } - return JAVA_TO_JDBC_TYPE_MAPPINGS; - } - - private static HashMap buildJavaToJDBCTypeMappings() { - HashMap mappings = new HashMap(); - 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 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 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()); - } - } - - private static JavaToJDBCTypeMapping buildJavaToJDBCTypeMapping(Class javaClass, int jdbcTypeCode) { - return new JavaToJDBCTypeMapping(new JavaType(javaClass), JDBCType.type(jdbcTypeCode)); - } - - - // ********** constructor ********** - - /** - * Suppress default constructor, ensuring non-instantiability. - */ - private JDBCTools() { - super(); - throw new UnsupportedOperationException(); - } - - - // ********** member classes ********** - - /** - * JDBC => Java - */ - private 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.getCode() == jdbcTypeCode; - } - - public boolean maps(String jdbcTypeName) { - return this.jdbcType.getName().equals(jdbcTypeName); - } - - public boolean maps(JDBCType type) { - return this.jdbcType == type; - } - - @Override - public String toString() { - StringBuffer sb = new StringBuffer(); - this.appendTo(sb); - return sb.toString(); - } - - public void appendTo(StringBuffer sb) { - this.jdbcType.appendTo(sb); - sb.append(" => "); - this.javaType.appendDeclarationTo(sb); - } - - } - - /** - * Java => JDBC - */ - private 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() { - StringBuffer sb = new StringBuffer(); - this.appendTo(sb); - return sb.toString(); - } - - public void appendTo(StringBuffer sb) { - this.javaType.appendDeclarationTo(sb); - sb.append(" => "); - this.jdbcType.appendTo(sb); - } - - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/JDBCType.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/JDBCType.java deleted file mode 100644 index fccea11fec..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/JDBCType.java +++ /dev/null @@ -1,167 +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.utility.internal; - -import java.io.Serializable; -import java.lang.reflect.Field; -import java.sql.Types; -import java.text.Collator; - -/** - * 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 Comparable, 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 getName() { - return this.name; - } - - - /** - * Return the type code, as defined in java.sql.Types. - */ - public int getCode() { - return this.code; - } - - - // ********** printing and displaying ********** - - public void appendTo(StringBuffer sb) { - sb.append(this.name); - } - - @Override - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append(ClassTools.shortClassNameForObject(this)); - 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(); - } - } - - public int compareTo(JDBCType type) { - return Collator.getInstance().compare(this.name, type.name); - } - - - // ********** 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].getCode() == code) { - return types[i]; - } - } - throw new IllegalArgumentException("invalid JDBC type code: " + code); - } - - /** - * 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].getName().equals(name)) { - return types[i]; - } - } - throw new IllegalArgumentException("invalid JDBC type name: " + name); - } - - /** - * 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/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/JavaType.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/JavaType.java deleted file mode 100644 index 682cda61df..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/JavaType.java +++ /dev/null @@ -1,232 +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.utility.internal; - -import java.io.PrintWriter; -import java.io.Serializable; -import java.text.Collator; - -/** - * This class 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. - */ -public final class JavaType - implements Comparable, 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 long serialVersionUID = 1L; - - - // ********** constructors ********** - - /** - * Construct a Java type with the specified element type and array depth. - */ - public JavaType(String elementTypeName, int arrayDepth) { - super(); - if ((elementTypeName == null) || (elementTypeName.length() == 0)) { - throw new IllegalArgumentException("The element type name is required."); - } - if (ClassTools.arrayDepthForClassNamed(elementTypeName) != 0) { // e.g. "[Ljava.lang.Object;" - throw new IllegalArgumentException("The element type must not be an array: " + elementTypeName + '.'); - } - if (arrayDepth < 0) { - throw new IllegalArgumentException("The array depth must be greater than or equal to zero: " + arrayDepth + '.'); - } - if (elementTypeName.equals(void.class.getName()) && (arrayDepth != 0)) { - throw new IllegalArgumentException("'void' must have an array depth of zero: " + arrayDepth + '.'); - } - 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: - * java.lang.Object - * int - * java.util.Map$Entry - * [Ljava.lang.Object; - * [I - * [Ljava.util.Map$Entry; - */ - public JavaType(String javaClassName) { - this(ClassTools.elementTypeNameForClassNamed(javaClassName), ClassTools.arrayDepthForClassNamed(javaClassName)); - } - - /** - * Construct a Java type for the specified class. - */ - public JavaType(Class javaClass) { - this(javaClass.getName()); - } - - - // ********** accessors ********** - - /** - * Return the name of the type's "element type". - * A member type will have one or more '$' characters in its name. - */ - public String getElementTypeName() { - return this.elementTypeName; - } - - /** - * Return the type's "array depth". - */ - public int getArrayDepth() { - return this.arrayDepth; - } - - - // ********** queries ********** - - public boolean isArray() { - return this.arrayDepth > 0; - } - - public boolean isPrimitive() { - return (this.arrayDepth == 0) && ClassTools.classNamedIsNonReference(this.elementTypeName); - } - - /** - * Return the class corresponding to the type's element type and array depth. - */ - public Class javaClass() throws ClassNotFoundException { - return ClassTools.classForTypeDeclaration(this.elementTypeName, this.arrayDepth); - } - - /** - * Return the version of the type's name that matches that - * returned by java.lang.Class#getName() - * (e.g. "[[J", "[Ljava.lang.Object;", "java.util.Map$Entry"). - */ - public String javaClassName() { - return ClassTools.classNameForTypeDeclaration(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(ClassTools.elementTypeNameForClassNamed(className), ClassTools.arrayDepthForClassNamed(className)); - } - - public boolean describes(Class javaClass) { - return this.describes(javaClass.getName()); - } - - public boolean equals(JavaType other) { - return this.equals(other.elementTypeName, other.arrayDepth); - } - - @Override - public boolean equals(Object o) { - return (o instanceof JavaType) ? this.equals((JavaType) o) : false; - } - - @Override - public int hashCode() { - return this.elementTypeName.hashCode() ^ this.arrayDepth; - } - - public int compareTo(JavaType jt) { - int x = Collator.getInstance().compare(this.elementTypeName, jt.elementTypeName); - return (x != 0) ? x : (this.arrayDepth - jt.arrayDepth); - } - - - // ********** printing and displaying ********** - - /** - * Return the version of the type's name that can be used in source code: - * "[[J" => "long[][]" - * "java.util.Map$Entry" => "java.util.Map.Entry" - */ - public String declaration() { - if (this.arrayDepth == 0) { - return this.elementTypeNameDeclaration(); - } - StringBuffer sb = new StringBuffer(this.elementTypeName.length() + (2 * this.arrayDepth)); - this.appendDeclarationTo(sb); - return sb.toString(); - } - - /** - * Append the version of the type's name that can be used in source code: - * "[[J" => "long[][]" - * "java.util.Map$Entry" => "java.util.Map.Entry" - */ - public void appendDeclarationTo(StringBuffer sb) { - sb.append(this.elementTypeNameDeclaration()); - for (int i = this.arrayDepth; i-- > 0; ) { - sb.append("[]"); - } - } - - /** - * Print the version of the type's name that can be used in source code: - * "[[J" => "long[][]" - * "java.util.Map$Entry" => "java.util.Map.Entry" - */ - public void printDeclarationOn(PrintWriter pw) { - pw.print(this.elementTypeNameDeclaration()); - for (int i = this.arrayDepth; i-- > 0; ) { - pw.print("[]"); - } - } - - /** - * The '$' version of the name is used in Class.forName(String), - * but the '.' verions of the name is used in source code. - * Very irritating.... - */ - private String elementTypeNameDeclaration() { - return this.elementTypeName.replace('$', '.'); - } - - @Override - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append(ClassTools.shortClassNameForObject(this)); - sb.append('('); - this.appendDeclarationTo(sb); - sb.append(')'); - return sb.toString(); - } - - @Override - public Object clone() { - try { - return super.clone(); - } catch (CloneNotSupportedException ex) { - throw new InternalError(); - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/NameTools.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/NameTools.java deleted file mode 100644 index be13c70dcf..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/NameTools.java +++ /dev/null @@ -1,305 +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.utility.internal; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; -import org.eclipse.jpt.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, - * Java-legal name that is either the "root" name or some variation on - * the "root" name (e.g. "root2", "root3",...). - * The names are case-sensitive. - */ - public static String uniqueJavaNameFor(String rootName, Iterator existingNames) { - Collection existingNames2 = CollectionTools.set(existingNames); - existingNames2.addAll(JAVA_RESERVED_WORDS_SET); - return uniqueNameFor(rootName, existingNames2, rootName); - } - - /** - * Given a "root" name and a set of existing names, generate a unique, - * Java-legal name that is either the "root" name or some variation on - * the "root" name (e.g. "root2", "root3",...). - * The names are case-sensitive. - */ - public static String uniqueJavaNameFor(String rootName, Collection existingNames) { - Collection existingNames2 = new HashSet(existingNames); - existingNames2.addAll(JAVA_RESERVED_WORDS_SET); - return uniqueNameFor(rootName, existingNames2, 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 case-sensitive. - */ - public static String uniqueNameFor(String rootName, Iterator 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. - */ - public static String uniqueNameFor(String rootName, Collection 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. - */ - public static String uniqueNameForIgnoreCase(String rootName, Iterator 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. - */ - public static String uniqueNameForIgnoreCase(String rootName, Collection 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 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 Collection convertToLowerCase(Collection strings) { - Collection result = new HashBag(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) { - throw new IllegalArgumentException(); - } - if ((catalog == null) && (schema == null)) { - return name; - } - - StringBuffer sb = new StringBuffer(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 - */ - 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 5.0 - "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 Set JAVA_RESERVED_WORDS_SET = CollectionTools.set(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 javaReservedWords() { - return new ArrayIterator(JAVA_RESERVED_WORDS); - } - - /** - * Convert the specified string to a valid Java identifier - * by substituting an underscore '_' for any invalid characters - * in the string and capitalizing 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 capitalizing the string if it is 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 words is a valid identifier, we just need to tweak it a bit - return StringTools.capitalize(string); - } - return new String(convertToJavaIdentifierInternal(string.toCharArray(), c)); - } - - /** - * Convert the specified string to a valid Java identifier - * by substituting an underscore '_' for any invalid characters - * in the string and capitalizing 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 capitalizing the string if it is a Java - * reserved word. - */ - public static char[] convertToJavaIdentifier(char[] string, char c) { - int length = string.length; - if (length == 0) { - return string; - } - if (JAVA_RESERVED_WORDS_SET.contains(new String(string))) { - // a reserved words is a valid identifier, we just need to tweak it a bit - return StringTools.capitalize(string); - } - return convertToJavaIdentifierInternal(string, c); - } - - private static char[] convertToJavaIdentifierInternal(char[] string, char c) { - if ( ! Character.isJavaIdentifierStart(string[0])) { - if ( ! Character.isJavaIdentifierStart(c)) { - throw new IllegalArgumentException("invalid Java identifier start char: '" + c + "'"); - } - string[0] = c; - } - if ( ! Character.isJavaIdentifierPart(c)) { - throw new IllegalArgumentException("invalid Java identifier part char: '" + c + "'"); - } - for (int i = string.length; i-- > 1; ) { // NB: end with 1 - if ( ! Character.isJavaIdentifierPart(string[i])) { - string[i] = c; - } - } - return string; - } - - - // ********** constructor ********** - - /** - * Suppress default constructor, ensuring non-instantiability. - */ - private NameTools() { - super(); - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Range.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Range.java deleted file mode 100644 index 4dbe48618a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Range.java +++ /dev/null @@ -1,87 +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.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 + ']'; - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ReverseComparator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ReverseComparator.java deleted file mode 100644 index 16ff4584d5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/ReverseComparator.java +++ /dev/null @@ -1,41 +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.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> - implements Comparator, Serializable -{ - private final Comparator comparator; - - public ReverseComparator() { - this(null); - } - - public ReverseComparator(Comparator comparator) { - super(); - this.comparator = comparator; - } - - @SuppressWarnings("unchecked") - public int compare(E e1, E e2) { - return (this.comparator == null) ? - e2.compareTo(e1) - : - this.comparator.compare(e2, e1); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleFilter.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleFilter.java deleted file mode 100644 index c42674eada..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/SimpleFilter.java +++ /dev/null @@ -1,106 +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.utility.internal; - -import java.io.Serializable; - -/** - * Simple, abstract implementation of Filter - * that holds on to a criterion object that can be used in the - * accept(Object) or reject(Object) - * methods. Subclasses can override either of these methods, - * depending on which is easier to implement. Note that at least - * one of these methods must be overridden or - * an infinite loop will occur. If both of them are overridden, - * only the accept(Object) method will be used. - *

- * Simplifies the implementation of straightforward inner classes. - * Here is an example of a filter that can be used by a - * FilteringIterator to return only those strings - * in the nested iterator start with "prefix": - *

- *	Filter filter = new SimpleFilter("prefix") {
- *		public boolean accept(String o) {
- *			return o.startsWith((String) criterion);
- *		}
- *	};
- * 
- */ -public abstract class SimpleFilter - implements Filter, Cloneable, Serializable -{ - protected final S criterion; - - private static final long serialVersionUID = 1L; - - - /** - * More useful constructor. The specified criterion can - * be used by a subclass to "accept" or "reject" objects. - */ - protected SimpleFilter(S criterion) { - super(); - this.criterion = criterion; - } - - /** - * Construct a simple filter with a null criterion - */ - protected SimpleFilter() { - this(null); - } - - /** - * 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); - } - - @Override - @SuppressWarnings("unchecked") - public SimpleFilter clone() { - try { - return (SimpleFilter) super.clone(); - } catch (CloneNotSupportedException ex) { - throw new InternalError(); - } - } - - @Override - public boolean equals(Object o) { - if ( ! (o instanceof SimpleFilter)) { - return false; - } - SimpleFilter other = (SimpleFilter) o; - return (this.criterion == null) ? - (other.criterion == null) : this.criterion.equals(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/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/StringTools.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/StringTools.java deleted file mode 100644 index 5d17b69a15..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/StringTools.java +++ /dev/null @@ -1,2101 +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.utility.internal; - -import java.io.IOException; -import java.io.Writer; -import java.util.Arrays; -import java.util.Iterator; - -import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; - -/** - * Convenience methods related to the java.lang.String class. - */ -public final class StringTools { - - /** carriage return */ - public static final String CR = System.getProperty("line.separator"); - - /** double quote */ - public static final char QUOTE = '"'; - - - - // ********** 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. - * String#pad(int) - */ - 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. - * String#padOn(int, Writer) - */ - 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. - * String#padOn(int, StringBuffer) - */ - 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 the - * specified character at the end. - * String#pad(int, char) - */ - 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); - } - if (stringLength == length) { - return string; - } - return padInternal(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. - * String#padOn(int, char, Writer) - */ - public static void padOn(String string, int length, char c, Writer writer) { - padOn(string.toCharArray(), 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. - * String#padOn(int, char, StringBuffer) - */ - public static void padOn(String string, int length, char c, StringBuffer sb) { - padOn(string.toCharArray(), 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. - * String#pad(int) - */ - 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. - * String#padOn(int, writer) - */ - 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. - * String#padOn(int, StringBuffer) - */ - 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 the - * specified character at the end. - * String#pad(int, char) - */ - 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); - } - if (stringLength == length) { - return string; - } - return padInternal(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. - * String#padOn(int, char, Writer) - */ - 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); - } - if (stringLength == length) { - writeStringOn(string, writer); - } else { - padOnInternal(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. - * String#padOn(int, char, StringBuffer) - */ - 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); - } - if (stringLength == length) { - sb.append(string); - } else { - padOnInternal(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. - * String#padOrTruncate(int) - */ - 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. - * String#padOrTruncateOn(int, Writer) - */ - 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. - * String#padOrTruncateOn(int, StringBuffer) - */ - 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 the - * specified character at the end. - * String#padOrTruncate(int, char) - */ - 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 padInternal(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. - * String#padOrTruncateOn(int, char, Writer) - */ - public static void padOrTruncateOn(String string, int length, char c, Writer writer) { - padOrTruncateOn(string.toCharArray(), 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. - * String#padOrTruncateOn(int, char, StringBuffer) - */ - public static void padOrTruncateOn(String string, int length, char c, StringBuffer sb) { - padOrTruncateOn(string.toCharArray(), 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. - * String#padOrTruncate(int) - */ - 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. - * String#padOrTruncateOn(int, Writer) - */ - 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. - * String#padOrTruncateOn(int, StringBuffer) - */ - 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 the - * specified character at the end. - * String#padOrTruncate(int, char) - */ - 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 padInternal(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. - * String#padOrTruncateOn(int, char, Writer) - */ - 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 { - padOnInternal(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. - * String#padOrTruncateOn(int, char, StringBuffer) - */ - 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 { - padOnInternal(string, length, c, sb); - } - } - - /** - * Pad the specified string without validating the parms. - */ - private static String padInternal(String string, int length, char c) { - return new String(padInternal(string.toCharArray(), length, c)); - } - - /** - * Pad the specified string without validating the parms. - */ - private static char[] padInternal(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 padOnInternal(char[] string, int length, char c, Writer writer) { - writeStringOn(string, writer); - writeStringOn(CollectionTools.fill(new char[length - string.length], c), writer); - } - - /** - * Pad the specified string without validating the parms. - */ - private static void padOnInternal(char[] string, int length, char c, StringBuffer sb) { - sb.append(string); - sb.append(CollectionTools.fill(new char[length - 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 zeros at the front. - * String#zeroPad(int) - */ - 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. - * String#zeroPadOn(int, Writer) - */ - 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. - * String#zeroPadOn(int, StringBuffer) - */ - 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 the - * specified character at the front. - * String#frontPad(int, char) - */ - 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); - } - if (stringLength == length) { - return string; - } - return frontPadInternal(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. - * String#frontPadOn(int, char, Writer) - */ - public static void frontPadOn(String string, int length, char c, Writer writer) { - frontPadOn(string.toCharArray(), 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. - * String#frontPadOn(int, char, StringBuffer) - */ - public static void frontPadOn(String string, int length, char c, StringBuffer sb) { - frontPadOn(string.toCharArray(), 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. - * String#zeroPad(int) - */ - 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. - * String#zeroPadOn(int, Writer) - */ - 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. - * String#zeroPadOn(int, StringBuffer) - */ - 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 the - * specified character at the front. - * String#frontPad(int, char) - */ - 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); - } - if (stringLength == length) { - return string; - } - return frontPadInternal(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. - * String#frontPadOn(int, char, Writer) - */ - 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); - } - if (stringLength == length) { - writeStringOn(string, writer); - } else { - frontPadOnInternal(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. - * String#frontPadOn(int, char, StringBuffer) - */ - 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); - } - if (stringLength == length) { - sb.append(string); - } else { - frontPadOnInternal(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. - * String#zeroPadOrTruncate(int) - */ - 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. - * String#zeroPadOrTruncateOn(int, Writer) - */ - 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. - * String#zeroPadOrTruncateOn(int, StringBuffer) - */ - 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 the - * specified character at the front. - * String#frontPadOrTruncate(int, char) - */ - 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 frontPadInternal(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. - * String#frontPadOrTruncateOn(int, char, Writer) - */ - public static void frontPadOrTruncateOn(String string, int length, char c, Writer writer) { - frontPadOrTruncateOn(string.toCharArray(), 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. - * String#frontPadOrTruncateOn(int, char, StringBuffer) - */ - public static void frontPadOrTruncateOn(String string, int length, char c, StringBuffer sb) { - frontPadOrTruncateOn(string.toCharArray(), 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. - * String#zeroPadOrTruncate(int) - */ - 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. - * String#zeroPadOrTruncateOn(int, Writer) - */ - 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. - * String#zeroPadOrTruncateOn(int, StringBuffer) - */ - 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 the - * specified character at the front. - * String#frontPadOrTruncate(int, char) - */ - 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 frontPadInternal(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. - * String#frontPadOrTruncateOn(int, char, Writer) - */ - 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 { - frontPadOnInternal(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. - * String#frontPadOrTruncateOn(int, char, StringBuffer) - */ - 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 { - frontPadOnInternal(string, length, c, sb); - } - } - - /** - * Front-pad the specified string without validating the parms. - */ - private static String frontPadInternal(String string, int length, char c) { - return new String(frontPadInternal(string.toCharArray(), length, c)); - } - - /** - * Zero-pad the specified string without validating the parms. - */ - private static char[] frontPadInternal(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 frontPadOnInternal(char[] string, int length, char c, Writer writer) { - writeStringOn(CollectionTools.fill(new char[length - string.length], c), writer); - writeStringOn(string, writer); - } - - /** - * Pad the specified string without validating the parms. - */ - private static void frontPadOnInternal(char[] string, int length, char c, StringBuffer sb) { - sb.append(CollectionTools.fill(new char[length - string.length], c)); - sb.append(string); - } - - - // ********** wrapping/quoting ********** - - /** - * Wrap the specified string with double quotes. - */ - public static String quote(String string) { - return wrap(string, QUOTE); - } - - /** - * Wrap the specified string with double quotes. - */ - public static void quoteOn(String string, Writer writer) { - wrapOn(string, QUOTE, writer); - } - - /** - * Wrap the specified string with double quotes. - */ - public static void quoteOn(String string, StringBuffer sb) { - wrapOn(string, QUOTE, sb); - } - - /** - * Wrap each of the specified strings with double quotes. - */ - public static Iterator quote(Iterator strings) { - return new TransformationIterator(strings) { - @Override - protected String transform(String string) { - return StringTools.quote(string); - } - }; - } - - /** - * Wrap the specified string with the specified wrap; i.e. put a copy of - * the wrap at the front and back of the resulting string. - */ - public static String wrap(String string, char wrap) { - return new String(wrap(string.toCharArray(), wrap)); - } - - /** - * Wrap the specified string with the specified wrap; i.e. put a copy of - * the wrap at the front and back of the resulting string. - */ - public static void wrapOn(String string, char wrap, Writer writer) { - wrapOn(string.toCharArray(), wrap, writer); - } - - /** - * Wrap the specified string with the specified wrap; i.e. put a copy of - * the wrap at the front and back of the resulting string. - */ - public static void wrapOn(String string, char wrap, StringBuffer sb) { - wrapOn(string.toCharArray(), wrap, sb); - } - - /** - * Wrap each of the specified strings with the specified wrap; i.e. put a - * copy of the wrap at the front and back of the resulting string. - */ - public static Iterator wrap(Iterator strings, final char wrap) { - return new TransformationIterator(strings) { - @Override - protected String transform(String string) { - return StringTools.wrap(string, wrap); - } - }; - } - - /** - * Wrap the specified string with the specified wrap; i.e. put a copy of - * the wrap at the front and back of the resulting string. - */ - public static String wrap(String string, String wrap) { - return new String(wrap(string.toCharArray(), wrap.toCharArray())); - } - - /** - * Wrap the specified string with the specified wrap; i.e. put a copy of - * the wrap at the front and back of the resulting string. - */ - public static void wrapOn(String string, String wrap, Writer writer) { - wrapOn(string.toCharArray(), wrap.toCharArray(), writer); - } - - /** - * Wrap the specified string with the specified wrap; i.e. put a copy of - * the wrap at the front and back of the resulting string. - */ - public static void wrapOn(String string, String wrap, StringBuffer sb) { - wrapOn(string.toCharArray(), wrap.toCharArray(), sb); - } - - /** - * Wrap each of the specified strings with the specified wrap; i.e. put a - * copy of the wrap at the front and back of the resulting string. - */ - public static Iterator wrap(Iterator strings, final String wrap) { - return new TransformationIterator(strings) { - @Override - protected String transform(String string) { - return StringTools.wrap(string, wrap); - } - }; - } - - /** - * Wrap the specified string with double quotes. - */ - public static char[] quote(char[] string) { - return wrap(string, QUOTE); - } - - /** - * Wrap the specified string with double quotes. - */ - public static void quoteOn(char[] string, Writer writer) { - wrapOn(string, QUOTE, writer); - } - - /** - * Wrap the specified string with double quotes. - */ - public static void quoteOn(char[] string, StringBuffer sb) { - wrapOn(string, QUOTE, sb); - } - - /** - * Wrap each of the specified strings with double quotes. - */ - public static Iterator quoteCharArrays(Iterator strings) { - return new TransformationIterator(strings) { - @Override - protected char[] transform(char[] string) { - return StringTools.quote(string); - } - }; - } - - /** - * Wrap the specified string with the specified wrap; i.e. put a copy of - * the wrap at the front and back of the resulting string. - */ - public static char[] wrap(char[] string, char wrap) { - int len = string.length; - char[] result = new char[len+2]; - result[0] = wrap; - System.arraycopy(string, 0, result, 1, len); - result[len+1] = wrap; - return result; - } - - /** - * Wrap the specified string with the specified wrap; i.e. put a copy of - * the wrap at the front and back of the resulting string. - */ - public static void wrapOn(char[] string, char wrap, Writer writer) { - writeCharOn(wrap, writer); - writeStringOn(string, writer); - writeCharOn(wrap, writer); - } - - /** - * Wrap the specified string with the specified wrap; i.e. put a copy of - * the wrap at the front and back of the resulting string. - */ - public static void wrapOn(char[] string, char wrap, StringBuffer sb) { - sb.append(wrap); - sb.append(string); - sb.append(wrap); - } - - /** - * Wrap each of the specified strings with the specified wrap; i.e. put a - * copy of the wrap at the front and back of the resulting string. - */ - public static Iterator wrapCharArrays(Iterator strings, final char wrap) { - return new TransformationIterator(strings) { - @Override - protected char[] transform(char[] string) { - return StringTools.wrap(string, wrap); - } - }; - } - - /** - * Wrap the specified string with the specified wrap; i.e. put a copy of - * the wrap at the front and back of the resulting string. - */ - public static char[] wrap(char[] string, char[] wrap) { - int stringLength = string.length; - int wrapLength = wrap.length; - char[] result = new char[stringLength+(2*wrapLength)]; - System.arraycopy(wrap, 0, result, 0, wrapLength); - System.arraycopy(string, 0, result, wrapLength, stringLength); - System.arraycopy(wrap, 0, result, stringLength+wrapLength, wrapLength); - return result; - } - - /** - * Wrap the specified string with the specified wrap; i.e. put a copy of - * the wrap at the front and back of the resulting string. - */ - public static void wrapOn(char[] string, char[] wrap, Writer writer) { - writeStringOn(wrap, writer); - writeStringOn(string, writer); - writeStringOn(wrap, writer); - } - - /** - * Wrap the specified string with the specified wrap; i.e. put a copy of - * the wrap at the front and back of the resulting string. - */ - public static void wrapOn(char[] string, char[] wrap, StringBuffer sb) { - sb.append(wrap); - sb.append(string); - sb.append(wrap); - } - - /** - * Wrap each of the specified strings with the specified wrap; i.e. put a - * copy of the wrap at the front and back of the resulting string. - */ - public static Iterator wrapCharArrays(Iterator strings, final char[] wrap) { - return new TransformationIterator(strings) { - @Override - protected char[] transform(char[] string) { - return StringTools.wrap(string, wrap); - } - }; - } - - - // ********** removing characters ********** - - /** - * Remove the first occurrence of the specified character - * from the specified string and return the result. - * String#removeFirstOccurrence(char) - */ - 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. - * String#removeFirstOccurrenceOn(char, Writer) - */ - public static void removeFirstOccurrenceOn(String string, char c, Writer writer) { - removeFirstOccurrenceOn(string.toCharArray(), c, writer); - } - - /** - * Remove the first occurrence of the specified character - * from the specified string and print the result on the specified stream. - * String#removeFirstOccurrenceOn(char, StringBuffer) - */ - public static void removeFirstOccurrenceOn(String string, char c, StringBuffer sb) { - removeFirstOccurrenceOn(string.toCharArray(), c, sb); - } - - /** - * Remove the first occurrence of the specified character - * from the specified string and return the result. - * String#removeFirstOccurrence(char) - */ - public static char[] removeFirstOccurrence(char[] string, char c) { - int index = CollectionTools.indexOf(string, c); - if (index == -1) { - // character not found - return string; - } - - int len = string.length - 1; - char[] result = new char[len]; - if (index == 0) { - // character found at the front of string - System.arraycopy(string, 1, result, 0, len); - } else if (index == len) { - // character found at the end of string - System.arraycopy(string, 0, result, 0, len); - } else { - // character found somewhere in the middle of the string - System.arraycopy(string, 0, result, 0, index); - System.arraycopy(string, index + 1, result, index, len - index); - } - return result; - } - - /** - * Remove the first occurrence of the specified character - * from the specified string and print the result on the specified stream. - * String#removeFirstOccurrenceOn(char, Writer) - */ - public static void removeFirstOccurrenceOn(char[] string, char c, Writer writer) { - int index = CollectionTools.indexOf(string, c); - if (index == -1) { - // character not found - writeStringOn(string, writer); - return; - } - - int len = string.length - 1; - if (index == 0) { - // character found at the front of string - writeStringOn(string, 1, len, writer); - } else if (index == len) { - // character found at the end of string - writeStringOn(string, 0, len, writer); - } else { - // character found somewhere in the middle of the string - writeStringOn(string, 0, index, writer); - writeStringOn(string, index + 1, len - index, writer); - } - } - - /** - * Remove the first occurrence of the specified character - * from the specified string and print the result on the specified stream. - * String#removeFirstOccurrenceOn(char, StringBuffer) - */ - public static void removeFirstOccurrenceOn(char[] string, char c, StringBuffer sb) { - int index = CollectionTools.indexOf(string, c); - if (index == -1) { - // character not found - sb.append(string); - return; - } - - int len = string.length - 1; - if (index == 0) { - // character found at the front of string - sb.append(string, 1, len); - } else if (index == len) { - // character found at the end of string - sb.append(string, 0, len); - } else { - // character found somewhere in the middle of the string - sb.append(string, 0, index); - sb.append(string, index + 1, len - index); - } - } - - /** - * Remove all occurrences of the specified character - * from the specified string and return the result. - * String#removeAllOccurrences(char) - */ - public static String removeAllOccurrences(String string, char c) { - return new String(removeAllOccurrences(string.toCharArray(), c)); - } - - /** - * Remove all occurrences of the specified character - * from the specified string and write the result to the specified stream. - * String#removeAllOccurrencesOn(char, Writer) - */ - public static void removeAllOccurrencesOn(String string, char c, Writer writer) { - removeAllOccurrencesOn(string.toCharArray(), c, writer); - } - - /** - * Remove all occurrences of the specified character - * from the specified string and write the result to the specified stream. - * String#removeAllOccurrencesOn(char, StringBuffer) - */ - public static void removeAllOccurrencesOn(String string, char c, StringBuffer sb) { - removeAllOccurrencesOn(string.toCharArray(), c, sb); - } - - /** - * Remove all occurrences of the specified character - * from the specified string and return the result. - * String#removeAllOccurrences(char) - */ - public static char[] removeAllOccurrences(char[] string, char c) { - StringBuffer sb = new StringBuffer(string.length); - removeAllOccurrencesOn(string, c, sb); - int len = sb.length(); - char[] result = new char[len]; - sb.getChars(0, len, result, 0); - return result; - } - - /** - * Remove all occurrences of the specified character - * from the specified string and write the result to the - * specified writer. - * String#removeAllOccurrencesOn(char, Writer) - */ - public static void removeAllOccurrencesOn(char[] string, char c, Writer writer) { - removeAllOccurrencesOnInternal(string, c, writer); - } - - private static void removeAllOccurrencesOnInternal(char[] string, char c, Writer writer) { - for (char d : string) { - 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. - * String#removeAllOccurrencesOn(char, StringBuffer) - */ - public static void removeAllOccurrencesOn(char[] string, char c, StringBuffer sb) { - for (char d : string) { - if (d != c) { - sb.append(d); - } - } - } - - /** - * Remove all the spaces from the specified string and return the result. - * String#removeAllSpaces() - */ - public static String removeAllSpaces(String string) { - return removeAllOccurrences(string, ' '); - } - - - // ********** common prefix ********** - - /** - * Return the length of the common prefix shared by the specified strings. - * String#commonPrefixLength(String) - */ - 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 commonPrefixLengthInternal(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. - * String#commonPrefixLength(String, int) - */ - 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 commonPrefixLengthInternal(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 commonPrefixLengthInternal(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[] capitalizeInternal(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 capitalizeInternal(string); - } - - /** - * Return the specified string with its first letter capitalized. - * String#capitalize() - */ - public static String capitalize(String string) { - if ((string.length() == 0) || Character.isUpperCase(string.charAt(0))) { - return string; - } - return new String(capitalizeInternal(string.toCharArray())); - } - - /** - * no zero-length check or upper case check - */ - private static void capitalizeOnInternal(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 { - capitalizeOnInternal(string, sb); - } - } - - /** - * Append the specified string to the specified string buffer - * with its first letter capitalized. - * String#capitalizeOn(StringBuffer) - */ - public static void capitalizeOn(String string, StringBuffer sb) { - if (string.length() == 0) { - return; - } - if (Character.isUpperCase(string.charAt(0))) { - sb.append(string); - } else { - capitalizeOnInternal(string.toCharArray(), sb); - } - } - - /** - * no zero-length check or upper case check - */ - private static void capitalizeOnInternal(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 { - capitalizeOnInternal(string, writer); - } - } - - /** - * Append the specified string to the specified string buffer - * with its first letter capitalized. - * String#capitalizeOn(Writer) - */ - public static void capitalizeOn(String string, Writer writer) { - if (string.length() == 0) { - return; - } - if (Character.isUpperCase(string.charAt(0))) { - writeStringOn(string, writer); - } else { - capitalizeOnInternal(string.toCharArray(), writer); - } - } - - /** - * no zero-length check or lower case check - */ - private static char[] uncapitalizeInternal(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 uncapitalizeInternal(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.) - * String#uncapitalize() - */ - public static String uncapitalize(String string) { - if (stringNeedNotBeUncapitalized(string)) { - return string; - } - return new String(uncapitalizeInternal(string.toCharArray())); - } - - /** - * no zero-length check or lower case check - */ - private static void uncapitalizeOnInternal(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 { - uncapitalizeOnInternal(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.) - * String#uncapitalizeOn(StringBuffer) - */ - public static void uncapitalizeOn(String string, StringBuffer sb) { - if (stringNeedNotBeUncapitalized(string)) { - sb.append(string); - } else { - uncapitalizeOnInternal(string.toCharArray(), sb); - } - } - - /** - * no zero-length check or upper case check - */ - private static void uncapitalizeOnInternal(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 { - uncapitalizeOnInternal(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.) - * String#uncapitalizeOn(Writer) - */ - public static void uncapitalizeOn(String string, Writer writer) { - if (stringNeedNotBeUncapitalized(string)) { - writeStringOn(string, writer); - } else { - uncapitalizeOnInternal(string.toCharArray(), writer); - } - } - - - // ********** #toString() helper methods ********** - - /** - * Build a "standard" #toString() result for the specified object - * and additional information: - * ClassName[00F3EE42] (add'l info) - */ - public static String buildToStringFor(Object o, Object additionalInfo) { - StringBuffer sb = new StringBuffer(); - buildSimpleToStringOn(o, sb); - sb.append(" ("); - sb.append(additionalInfo); - sb.append(')'); - return sb.toString(); - } - - /** - * Build a "standard" simple #toString() result for the specified object: - * ClassName[00F3EE42] - */ - public static String buildToStringFor(Object o) { - StringBuffer sb = new StringBuffer(); - buildSimpleToStringOn(o, sb); - return sb.toString(); - } - - /** - * Append a "standard" simple #toString() for the specified object to - * the specified string buffer: - * ClassName[00F3EE42] - */ - public static void buildSimpleToStringOn(Object o, StringBuffer sb) { - sb.append(ClassTools.toStringClassNameForObject(o)); - sb.append('['); - // use System#identityHashCode(Object), since Object#hashCode() may be overridden - sb.append(zeroPad(Integer.toHexString(System.identityHashCode(o)).toUpperCase(), 8)); - sb.append(']'); - } - - - // ********** queries ********** - - /** - * Return whether the specified string is null, empty, or contains - * only whitespace characters. - */ - public static boolean stringIsEmpty(String string) { - if ((string == null) || (string.length() == 0)) { - return true; - } - return stringIsEmptyInternal(string.toCharArray()); - } - - /** - * Return whether the specified string is null, empty, or contains - * only whitespace characters. - */ - public static boolean stringIsEmpty(char[] string) { - if ((string == null) || (string.length == 0)) { - return true; - } - return stringIsEmptyInternal(string); - } - - private static boolean stringIsEmptyInternal(char[] s) { - for (int i = s.length; i-- > 0; ) { - if ( ! Character.isWhitespace(s[i])) { - return false; - } - } - return true; - } - - /** - * Return whether the specified strings are equal, ignoring case. - * Check for nulls. - */ - public static boolean stringsAreEqualIgnoreCase(String s1, String s2) { - if ((s1 == null) && (s2 == null)) { - return true; // both are null - } - if ((s1 == null) || (s2 == null)) { - return false; // one is null but the other is not - } - return s1.equalsIgnoreCase(s2); - } - - /** - * Return whether the specified strings are equal, ignoring case. - * Check for nulls. - */ - public static boolean stringsAreEqualIgnoreCase(char[] s1, char[] s2) { - if ((s1 == null) && (s2 == null)) { - return true; // both are null - } - if ((s1 == null) || (s2 == null)) { - return false; // one is null but the other is not - } - if (s1.length != s2.length) { - return false; - } - for (int i = s1.length; 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) { - if (string.length < prefix.length) { - return false; - } - for (int i = prefix.length; 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 java.lang.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)); - } - - // ********** conversions ********** - - /** - * Convert the specified "camel case" string to an "all caps" string: - * "largeProject" -> "LARGE_PROJECT" - */ - public static String convertCamelCaseToAllCaps(String camelCaseString) { - return new String(convertCamelCaseToAllCaps(camelCaseString.toCharArray())); - } - - /** - * 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; - } - StringBuffer sb = new StringBuffer(len * 2); - convertCamelCaseToAllCapsOnInternal(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) { - convertCamelCaseToAllCapsOn(camelCaseString.toCharArray(), 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) { - convertCamelCaseToAllCapsOnInternal(camelCaseString, len, sb); - } - } - - private static void convertCamelCaseToAllCapsOnInternal(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, Writer writer) { - convertCamelCaseToAllCapsOn(camelCaseString.toCharArray(), 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) { - convertCamelCaseToAllCapsOnInternal(camelCaseString, len, writer); - } - } - - private static void convertCamelCaseToAllCapsOnInternal(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) { - return new String(convertCamelCaseToAllCaps(camelCaseString.toCharArray(), maxLength)); - } - - /** - * 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; - } - StringBuffer sb = new StringBuffer(maxLength); - convertCamelCaseToAllCapsOnInternal(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) { - convertCamelCaseToAllCapsOn(camelCaseString.toCharArray(), maxLength, 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)) { - convertCamelCaseToAllCapsOnInternal(camelCaseString, maxLength, len, sb); - } - } - - private static void convertCamelCaseToAllCapsOnInternal(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, Writer writer) { - convertCamelCaseToAllCapsOn(camelCaseString.toCharArray(), maxLength, 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)) { - convertCamelCaseToAllCapsOnInternal(camelCaseString, maxLength, len, writer); - } - } - - private static void convertCamelCaseToAllCapsOnInternal(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 the specified "underscore" string to a "camel case" string: - * "LARGE_PROJECT" -> "LargeProject" - * Capitalize the first letter. - */ - public static String convertUnderscoresToCamelCase(String underscoreString) { - return new String(convertUnderscoresToCamelCase(underscoreString.toCharArray())); - } - - /** - * 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) { - return new String(convertUnderscoresToCamelCase(underscoreString.toCharArray(), capitalizeFirstLetter)); - } - - /** - * 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; - } - StringBuffer sb = new StringBuffer(len); - convertUnderscoresToCamelCaseOnInternal(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) { - convertUnderscoresToCamelCaseOn(underscoreString.toCharArray(), capitalizeFirstLetter, 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) { - convertUnderscoresToCamelCaseOnInternal(underscoreString, capitalizeFirstLetter, len, sb); - } - } - - private static void convertUnderscoresToCamelCaseOnInternal(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; - if (capitalizeFirstLetter) { - sb.append(Character.toUpperCase(c)); - } else { - sb.append(Character.toLowerCase(c)); - } - } else { - if (prev == '_') { - sb.append(Character.toUpperCase(c)); - } else { - sb.append(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) { - convertUnderscoresToCamelCaseOn(underscoreString.toCharArray(), capitalizeFirstLetter, 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) { - convertUnderscoresToCamelCaseOnInternal(underscoreString, capitalizeFirstLetter, len, writer); - } - } - - private static void convertUnderscoresToCamelCaseOnInternal(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; - if (capitalizeFirstLetter) { - writeCharOn(Character.toUpperCase(c), writer); - } else { - writeCharOn(Character.toLowerCase(c), writer); - } - } else { - if (prev == '_') { - writeCharOn(Character.toUpperCase(c), writer); - } else { - writeCharOn(Character.toLowerCase(c), writer); - } - } - } - } - - - // ********** convenience ********** - - public static char[] convertToCharArray(StringBuffer sb) { - int len = sb.length(); - char[] result = new char[len]; - sb.getChars(0, len, result, 0); - return result; - } - - /** - * checked exceptions suck - */ - private static void writeStringOn(char[] string, Writer writer) { - try { - writer.write(string); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - - /** - * checked exceptions suck - */ - 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); - } - } - - /** - * checked exceptions suck - */ - private static void writeStringOn(String string, Writer writer) { - try { - writer.write(string); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - - /** - * checked exceptions suck - */ - 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/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Transformer.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Transformer.java deleted file mode 100644 index 52c002487a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/Transformer.java +++ /dev/null @@ -1,48 +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.utility.internal; - -/** - * Used by various "pluggable" classes to transform objects. - * Transform an object of type T1 to an object of type T2. - */ -public interface Transformer { - - /** - * Return the transformed object. - * The semantics of "transform" is determined by the - * contract between the client and the server. - */ - T2 transform(T1 o); - - - final class Null implements Transformer { - @SuppressWarnings("unchecked") - public static final Transformer INSTANCE = new Null(); - @SuppressWarnings("unchecked") - public static Transformer 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 "Transformer.Null"; - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/XMLStringEncoder.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/XMLStringEncoder.java deleted file mode 100644 index fd637ebfa9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/XMLStringEncoder.java +++ /dev/null @@ -1,182 +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.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": '/' => "/" - */ -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 (CollectionTools.contains(chars, '&')) { - this.chars = chars; - } else { - this.chars = CollectionTools.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 - StringBuffer sb = new StringBuffer(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) { - StringBuffer sb = new StringBuffer(s.length()); - StringBuffer temp = new StringBuffer(); // 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, StringBuffer 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) && CollectionTools.contains(this.chars, c); - } - - /** - * Append the specified character's XML character reference to the - * specified string buffer (e.g. '/' => "/"). - */ - private void appendCharacterReferenceTo(char c, StringBuffer sb) { - sb.append("&#x"); - sb.append(Integer.toString(c, 16)); - sb.append(';'); - } - - private void decodeTo(Reader reader, StringBuffer sb, StringBuffer temp) { - try { - this.decodeTo_(reader, sb, temp); - } catch (IOException ex) { - throw new RuntimeException(ex); - } - } - - private void decodeTo_(Reader reader, StringBuffer sb, StringBuffer 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, StringBuffer sb, StringBuffer temp) throws IOException { - int c = reader.read(); - this.checkChar(c, '#'); - c = reader.read(); - this.checkChar(c, 'x'); - - temp.setLength(0); - 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"); - } - 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 + "'"); - } - } - - private void checkEndOfStream(int c) { - if (c == -1) { - throw new IllegalStateException("unexpected end of string"); - } - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ArrayIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ArrayIterator.java deleted file mode 100644 index 2874af48ad..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ArrayIterator.java +++ /dev/null @@ -1,72 +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.utility.internal.iterators; - -import java.util.Iterator; -import java.util.NoSuchElementException; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * An ArrayIterator provides an Iterator - * for an array of objects of type E. - */ -public class ArrayIterator - implements Iterator -{ - final E[] array; // private-protected - int nextIndex; // private-protected - private final int maxIndex; - - /** - * 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 specified length. - */ - public ArrayIterator(E[] array, int start, int length) { - if ((start < 0) || (start > array.length)) { - throw new IllegalArgumentException("start: " + start); - } - if ((length < 0) || (length > array.length - start)) { - throw new IllegalArgumentException("length: " + length); - } - this.array = array; - this.nextIndex = start; - this.maxIndex = start + length; - } - - public boolean hasNext() { - return this.nextIndex < this.maxIndex; - } - - public E next() { - if (this.hasNext()) { - return this.array[this.nextIndex++]; - } - throw new NoSuchElementException(); - } - - public void remove() { - throw new UnsupportedOperationException(); - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this, CollectionTools.list(this.array)); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ArrayListIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ArrayListIterator.java deleted file mode 100644 index 5b70ed4721..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ArrayListIterator.java +++ /dev/null @@ -1,78 +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.utility.internal.iterators; - -import java.util.ListIterator; -import java.util.NoSuchElementException; - -/** - * An ArrayListIterator provides a ListIterator - * for an array of objects. - * - * The name might be a bit confusing: - * This is a ListIterator for an Array; - * not an Iterator for an ArrayList. - */ -public class ArrayListIterator - extends ArrayIterator - implements ListIterator -{ - private final int minIndex; - - /** - * 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 specified length. - */ - public ArrayListIterator(E[] array, int start, int length) { - super(array, start, length); - this.minIndex = start; - } - - public int nextIndex() { - return this.nextIndex; - } - - public int previousIndex() { - return this.nextIndex - 1; - } - - public boolean hasPrevious() { - return this.nextIndex > this.minIndex; - } - - public E previous() { - if (this.hasPrevious()) { - return this.array[--this.nextIndex]; - } - 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/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ChainIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ChainIterator.java deleted file mode 100644 index 0f7594f115..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ChainIterator.java +++ /dev/null @@ -1,124 +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.utility.internal.iterators; - -import java.util.Iterator; -import java.util.NoSuchElementException; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * A ChainIterator provides a pluggable Iterator - * that loops over a chain of arbitrarily linked objects. The chain - * should be null-terminated (i.e. a call to the nextLink(Object) - * method should return null when it is passed the last - * link of the chain). - * To use, supply a starting link and supply a Linker or - * subclass ChainIterator and override the - * nextLink(Object) method. - * The starting link will be the first object returned by the iterator. - * If the starting link is null, the iterator will be empty. - * Note that the iterator does not support null elements. - */ -public class ChainIterator - implements Iterator -{ - private E nextLink; - private final Linker linker; - - - /** - * Construct an iterator with the specified starting link - * and a linker that simply returns null, indicating the end of the chain. - * Use this constructor if you want to override the - * nextLink(Object) method instead of building - * a Linker. - */ - public ChainIterator(E startLink) { - this(startLink, Linker.Null.instance()); - } - - /** - * Construct an iterator with the specified starting link - * and linker. - */ - public ChainIterator(E startLink, Linker 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. - */ - protected E nextLink(E currentLink) { - return this.linker.nextLink(currentLink); - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this, this.nextLink); - } - - - //********** inner classes ********** - - /** - * Used by ChainIterator to link - * the elements in the chain. - */ - public interface Linker { - - /** - * Return the next link in the chain. - */ - T nextLink(T currentLink); - - - final class Null implements Linker { - @SuppressWarnings("unchecked") - public static final Linker INSTANCE = new Null(); - @SuppressWarnings("unchecked") - public static Linker 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 "ChainIterator.Linker.Null"; - } - } - - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CloneIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CloneIterator.java deleted file mode 100644 index a7df5c9b92..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CloneIterator.java +++ /dev/null @@ -1,144 +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.utility.internal.iterators; - -import java.util.Collection; -import java.util.Iterator; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * A CloneIterator iterates over a copy of a collection, - * allowing for concurrent access to the original collection. - *

- * The original collection passed to the CloneIterator's - * constructor should be synchronized; otherwise you run the risk of - * a corrupted collection. - *

- * By default, a CloneIterator does not support the - * #remove() operation; this is because it does not have - * access to the original collection. But if the CloneIterator - * is supplied with an Mutator it will delegate the - * #remove() operation to the Mutator. - * Alternatively, a subclass can override the #remove(Object) - * method. - */ -public class CloneIterator - implements Iterator -{ - private final Iterator nestedIterator; - private E current; - private final Mutator mutator; - private boolean removeAllowed; - - - // ********** constructors ********** - - /** - * Construct an iterator on a copy of the specified collection. - * The #remove() method will not be supported, - * unless a subclass overrides the #remove(Object). - */ - public CloneIterator(Collection c) { - this(c, Mutator.ReadOnly.instance()); - } - - /** - * Construct an iterator on a copy of the specified collection. - * Use the specified mutator to remove objects from the - * original collection. - */ - @SuppressWarnings("unchecked") - public CloneIterator(Collection c, Mutator mutator) { - super(); - this.nestedIterator = new ArrayIterator((E[]) c.toArray()); - this.current = null; - this.mutator = mutator; - this.removeAllowed = false; - } - - - // ********** Iterator implementation ********** - - public boolean hasNext() { - return this.nestedIterator.hasNext(); - } - - public E next() { - this.current = this.nestedIterator.next(); - this.removeAllowed = true; - return this.current; - } - - public void remove() { - if ( ! this.removeAllowed) { - throw new IllegalStateException(); - } - this.remove(this.current); - this.removeAllowed = false; - } - - - // ********** internal methods ********** - - /** - * Remove the specified element from the original collection. - *

- * This method can be overridden by a subclass as an - * alternative to building an Mutator. - */ - protected void remove(E e) { - this.mutator.remove(e); - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this); - } - - - //********** member interface ********** - - /** - * Used by CloneIterator to remove - * elements from the original collection; since the iterator - * does not have direct access to the original collection. - */ - public interface Mutator { - - /** - * Remove the specified object from the original collection. - */ - void remove(T current); - - - final class ReadOnly implements Mutator { - @SuppressWarnings("unchecked") - public static final Mutator INSTANCE = new ReadOnly(); - @SuppressWarnings("unchecked") - public static Mutator instance() { - return INSTANCE; - } - // ensure single instance - private ReadOnly() { - super(); - } - // remove is not supported - public void remove(Object current) { - throw new UnsupportedOperationException(); - } - @Override - public String toString() { - return "CloneIterator.Mutator.ReadOnly"; - } - } - - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CloneListIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CloneListIterator.java deleted file mode 100644 index 82d701b442..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CloneListIterator.java +++ /dev/null @@ -1,229 +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.utility.internal.iterators; - -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * A CloneListIterator iterates over a copy of a list, - * allowing for concurrent access to the original list. - *

- * The original list passed to the CloneListIterator's - * constructor should be synchronized; otherwise you run the risk of - * a corrupted list. - *

- * By default, a CloneListIterator does not support the - * modification operations; this is because it does not have - * access to the original list. But if the CloneListIterator - * is supplied with a Mutator it will delegate the - * modification operations to the Mutator. - * Alternatively, a subclass can override the modification methods. - */ -public class CloneListIterator - implements ListIterator -{ - private final ListIterator nestedListIterator; - private int cursor; - private String state; - private final Mutator mutator; - - private static final String UNKNOWN = "unknown"; - private static final String PREVIOUS = "previous"; - private static final String NEXT = "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 list) { - this(list, Mutator.ReadOnly.instance()); - } - - /** - * Construct a list iterator on a copy of the specified list. - * Use the specified list mutator to modify the original list. - */ - @SuppressWarnings("unchecked") - public CloneListIterator(List list, Mutator mutator) { - super(); - // build a copy of the list and keep it in synch with original (if the mutator allows changes) - // that way the nested list iterator will maintain some of our state - this.nestedListIterator = CollectionTools.list((E[]) list.toArray()).listIterator(); - this.mutator = mutator; - this.cursor = 0; - this.state = UNKNOWN; - } - - - // ********** ListIterator implementation ********** - - public boolean hasNext() { - return this.nestedListIterator.hasNext(); - } - - public E next() { - // allow the nested iterator to throw an exception before we modify the index - E next = this.nestedListIterator.next(); - this.cursor++; - this.state = NEXT; - return next; - } - - public void remove() { - // allow the nested iterator to throw an exception before we modify the original list - this.nestedListIterator.remove(); - if (this.state == PREVIOUS) { - this.remove(this.cursor); - } else { - this.cursor--; - this.remove(this.cursor); - } - } - - public int nextIndex() { - return this.nestedListIterator.nextIndex(); - } - - public int previousIndex() { - return this.nestedListIterator.previousIndex(); - } - - public boolean hasPrevious() { - return this.nestedListIterator.hasPrevious(); - } - - public E previous() { - // allow the nested iterator to throw an exception before we modify the index - E previous = this.nestedListIterator.previous(); - this.cursor--; - this.state = PREVIOUS; - return previous; - } - - public void add(E o) { - // allow the nested iterator to throw an exception before we modify the original list - this.nestedListIterator.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.nestedListIterator.set(o); - if (this.state == PREVIOUS) { - this.set(this.cursor, o); - } else { - this.set(this.cursor - 1, o); - } - } - - - // ********** internal methods ********** - - /** - * Add the specified element to the original list. - *

- * This method can be overridden by a subclass as an - * alternative to building a Mutator. - */ - protected void add(int index, E o) { - this.mutator.add(index, o); - } - - /** - * Remove the specified element from the original list. - *

- * This method can be overridden by a subclass as an - * alternative to building a Mutator. - */ - protected void remove(int index) { - this.mutator.remove(index); - } - - /** - * Set the specified element in the original list. - *

- * This method can be overridden by a subclass as an - * alternative to building a Mutator. - */ - protected void set(int index, E o) { - this.mutator.set(index, o); - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this); - } - - - //********** member interface ********** - - /** - * Used by CloneListIterator to remove - * elements from the original list; since the list iterator - * does not have direct access to the original list. - */ - public interface Mutator { - - /** - * 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 implements Mutator { - @SuppressWarnings("unchecked") - public static final Mutator INSTANCE = new ReadOnly(); - @SuppressWarnings("unchecked") - public static Mutator 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 "CloneListIterator.Mutator.ReadOnly"; - } - } - - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CompositeIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CompositeIterator.java deleted file mode 100644 index 40ae0cb879..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CompositeIterator.java +++ /dev/null @@ -1,118 +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.utility.internal.iterators; - -import java.util.Collection; -import java.util.Iterator; -import java.util.NoSuchElementException; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * A CompositeIterator wraps a collection - * of Iterators and makes them appear to be a single - * Iterator. - */ -public class CompositeIterator - implements Iterator -{ - private final Iterator> iterators; - private Iterator currentIterator; - private Iterator lastIteratorToReturnNext; - - - /** - * Construct an iterator with the specified collection of iterators. - */ - public CompositeIterator(Collection> iterators) { - this(iterators.iterator()); - } - - /** - * Construct an iterator with the specified collection of iterators. - */ - public CompositeIterator(Iterator> iterators) { - super(); - this.iterators = iterators; - } - - /** - * Construct an iterator with the specified object prepended - * to the specified iterator. - */ - @SuppressWarnings("unchecked") - public CompositeIterator(E object, Iterator iterator) { - this(new SingleElementIterator(object), iterator); - } - - /** - * Construct an iterator with the specified object appended - * to the specified iterator. - */ - @SuppressWarnings("unchecked") - public CompositeIterator(Iterator iterator, E object) { - this(iterator, new SingleElementIterator(object)); - } - - /** - * Construct an iterator with the specified iterators. - */ - public CompositeIterator(Iterator... iterators) { - this(new ArrayIterator>(iterators)); - } - - 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 currentIterator with the first iterator that 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(); - } - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this, this.iterators); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CompositeListIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CompositeListIterator.java deleted file mode 100644 index 324d3c2f68..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/CompositeListIterator.java +++ /dev/null @@ -1,194 +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.utility.internal.iterators; - -import java.util.List; -import java.util.ListIterator; -import java.util.NoSuchElementException; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * A CompositeListIterator wraps a list - * of ListIterators and makes them appear to be a single - * ListIterator. - */ -public class CompositeListIterator - implements ListIterator -{ - private final ListIterator> iterators; - private ListIterator nextIterator; - private int nextIndex; - /** - * true if "next" was last returned; false if "previous" was last returned; - * this determines the effect of remove(Object) on nextIndex - */ - private boolean nextReturned; - private ListIterator lastIteratorToReturnElement; - - - /** - * Construct a list iterator with the specified list of list iterators. - */ - public CompositeListIterator(List> iterators) { - this(iterators.listIterator()); - } - - /** - * Construct a list iterator with the specified list of list iterators. - */ - public CompositeListIterator(ListIterator> iterators) { - super(); - this.iterators = iterators; - this.nextIndex = 0; - this.nextReturned = false; - } - - /** - * Construct a list iterator with the specified object prepended - * to the specified iterator. - */ - @SuppressWarnings("unchecked") - public CompositeListIterator(E object, ListIterator iterator) { - this(new SingleElementListIterator(object), iterator); - } - - /** - * Construct a list iterator with the specified object appended - * to the specified iterator. - */ - @SuppressWarnings("unchecked") - public CompositeListIterator(ListIterator iterator, E object) { - this(iterator, new SingleElementListIterator(object)); - } - - /** - * Construct a list iterator with the specified list iterators. - */ - public CompositeListIterator(ListIterator... iterators) { - this(new ArrayListIterator>(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 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 nextIterator with the first iterator that 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 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/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyEnumeration.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyEnumeration.java deleted file mode 100644 index d1b989a946..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyEnumeration.java +++ /dev/null @@ -1,55 +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.utility.internal.iterators; - -import java.util.Enumeration; -import java.util.NoSuchElementException; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * A NullEnumeration is just that. - */ -public final class EmptyEnumeration - implements Enumeration -{ - - // singleton - @SuppressWarnings("unchecked") - private static EmptyEnumeration INSTANCE = new EmptyEnumeration(); - - /** - * Return the singleton. - */ - @SuppressWarnings("unchecked") - public static Enumeration 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 StringTools.buildToStringFor(this); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyIterator.java deleted file mode 100644 index b560d45fcf..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyIterator.java +++ /dev/null @@ -1,59 +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.utility.internal.iterators; - -import java.util.Iterator; -import java.util.NoSuchElementException; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * A NullIterator is just that. - */ -public final class EmptyIterator - implements Iterator -{ - - // singleton - @SuppressWarnings("unchecked") - private static EmptyIterator INSTANCE = new EmptyIterator(); - - /** - * Return the singleton. - */ - @SuppressWarnings("unchecked") - public static Iterator 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 StringTools.buildToStringFor(this); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyListIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyListIterator.java deleted file mode 100644 index 0863b24463..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EmptyListIterator.java +++ /dev/null @@ -1,83 +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.utility.internal.iterators; - -import java.util.ListIterator; -import java.util.NoSuchElementException; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * A NullListIterator is just that. - */ -public final class EmptyListIterator - implements ListIterator -{ - - // singleton - @SuppressWarnings("unchecked") - private static EmptyListIterator INSTANCE = new EmptyListIterator(); - - /** - * Return the singleton. - */ - @SuppressWarnings("unchecked") - public static ListIterator 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 StringTools.buildToStringFor(this); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EnumerationIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EnumerationIterator.java deleted file mode 100644 index a75710c4ef..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/EnumerationIterator.java +++ /dev/null @@ -1,50 +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.utility.internal.iterators; - -import java.util.Enumeration; -import java.util.Iterator; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * An EnumerationIterator wraps an - * Enumeration so that it can be treated like an - * Iterator. - */ -public class EnumerationIterator - implements Iterator -{ - private final Enumeration enumeration; - - /** - * Construct an iterator that wraps the specified enumeration. - */ - public EnumerationIterator(Enumeration 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/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/FilteringIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/FilteringIterator.java deleted file mode 100644 index eb0c970933..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/FilteringIterator.java +++ /dev/null @@ -1,130 +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.utility.internal.iterators; - -import java.util.Iterator; -import java.util.NoSuchElementException; -import org.eclipse.jpt.utility.internal.Filter; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * A FilteringIterator wraps another Iterator - * and uses a Filter to determine which elements in the - * nested iterator are to be returned by calls to next(). - *

- * As an alternative to building a Filter, a subclass - * of FilteringIterator can override the - * accept(Object) method. - *

- * One, possibly undesirable, side-effect of using this iterator is that - * the nested iterator's next() method will be invoked - * before the filtered iterator's 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 - * hasNext() method should return true). - * This also prevents a filtered iterator from supporting the optional - * remove() method. - */ -public class FilteringIterator - implements Iterator -{ - private final Iterator nestedIterator; - // trust that the filter is correct - i.e. it will only accept elements of type E - @SuppressWarnings("unchecked") - private final Filter filter; - private E next; - private boolean done; - - - /** - * Construct an iterator with the specified nested - * iterator and a filter that simply accepts every object. - * Use this constructor if you want to override the - * accept(Object) method instead of building - * a Filter. - */ - public FilteringIterator(Iterator nestedIterator) { - this(nestedIterator, Filter.Null.instance()); - } - - /** - * Construct an iterator with the specified nested - * iterator and filter. - */ - @SuppressWarnings("unchecked") - public FilteringIterator(Iterator nestedIterator, Filter filter) { - super(); - this.nestedIterator = nestedIterator; - 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 remove() - * 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 END. - */ - @SuppressWarnings("unchecked") - private void loadNext() { - this.done = true; - while (this.nestedIterator.hasNext() && (this.done)) { - Object o = this.nestedIterator.next(); - if (this.accept(o)) { - // assume that if the object was accepted it is of type E - this.next = (E) o; - this.done = false; - } else { - this.next = null; - this.done = true; - } - } - } - - /** - * Return whether the FilteringIterator - * should return the specified next element from a call to the - * next() method. - *

- * This method can be overridden by a subclass as an - * alternative to building a Filter. - */ - @SuppressWarnings("unchecked") - protected boolean accept(Object o) { - return this.filter.accept(o); - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this, this.nestedIterator); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/GraphIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/GraphIterator.java deleted file mode 100644 index 1542cf16a2..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/GraphIterator.java +++ /dev/null @@ -1,223 +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.utility.internal.iterators; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.NoSuchElementException; -import java.util.Set; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * A GraphIterator is similar to a 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 GraphIterator 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 *neighbors*), but does not provide a method for getting *all* - * 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.) - *

- * If a neighbor has already been visited (determined by using - * equals(Object)), that neighbor is not visited again, - * nor are the neighbors of that object. - *

- * It is up to the user of this class to ensure a *complete* graph. - *

- * To use, supply:

    - *
  • either the initial node of the graph or an Iterator over an - * initial collection of graph nodes - *
  • a MisterRogers that tells who the neighbors are - * of each node - * (alternatively, subclass GraphIterator - * and override the neighbors(Object) method) - *
- *

- * remove() is not supported. This method, if - * desired, must be implemented by the user of this class. - */ -public class GraphIterator - implements Iterator -{ - private final Collection> iterators; - private final Set visitedNeighbors; - private final MisterRogers misterRogers; - - private Iterator currentIterator; - - private E nextNeighbor; - private boolean done; - - - /** - * Construct an iterator with the specified collection of roots - * and a mister rogers that simply returns an empty iterator - * for each of the roots. - * Use this constructor if you want to override the - * children(Object) method instead of building - * a MisterRogers. - */ - public GraphIterator(E... roots) { - this(new ArrayIterator(roots)); - } - - /** - * Construct an iterator with the specified collection of roots - * and a mister rogers that simply returns an empty iterator - * for each of the roots. - * Use this constructor if you want to override the - * children(Object) method instead of building - * a MisterRogers. - */ - public GraphIterator(Iterator roots) { - this(roots, MisterRogers.Null.instance()); - } - - /** - * Construct an iterator with the specified root - * and a mister rogers that simply returns an empty iterator - * for the root. - * Use this constructor if you want to override the - * children(Object) method instead of building - * a MisterRogers. - */ - public GraphIterator(E root) { - this(root, MisterRogers.Null.instance()); - } - - /** - * Construct an iterator with the specified root - * and mister rogers. - */ - public GraphIterator(E root, MisterRogers misterRogers) { - this(new SingleElementIterator(root), misterRogers); - } - - /** - * Construct an iterator with the specified roots - * and mister rogers. - */ - public GraphIterator(Iterator roots, MisterRogers misterRogers) { - super(); - this.currentIterator = roots; - // use a LinkedList since we will be pulling off the front and adding to the end - this.iterators = new LinkedList>(); - this.misterRogers = misterRogers; - this.visitedNeighbors = new HashSet(); - 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 '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> 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 neighbors(E next) { - return this.misterRogers.neighbors(next); - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this, this.currentIterator); - } - - - //********** inner classes ********** - - /** - * Used by GraphIterator to retrieve - * the immediate neighbors of a node in the graph. - * "These are the people in your neighborhood..." - */ - public interface MisterRogers { - - /** - * Return the immediate neighbors of the specified object. - */ - Iterator neighbors(T next); - - - final class Null implements MisterRogers { - @SuppressWarnings("unchecked") - public static final MisterRogers INSTANCE = new Null(); - @SuppressWarnings("unchecked") - public static MisterRogers instance() { - return INSTANCE; - } - // ensure single instance - private Null() { - super(); - } - // return no neighbors - public Iterator neighbors(S next) { - return EmptyIterator.instance(); - } - @Override - public String toString() { - return "GraphIterator.MisterRogers.Null"; - } - } - - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/IteratorEnumeration.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/IteratorEnumeration.java deleted file mode 100644 index 55a4f08b70..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/IteratorEnumeration.java +++ /dev/null @@ -1,47 +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.utility.internal.iterators; - -import java.util.Enumeration; -import java.util.Iterator; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * An IteratorEnumeration wraps an - * Iterator so that it can be treated like an - * Enumeration. - */ -public class IteratorEnumeration - implements Enumeration -{ - private final Iterator iterator; - - /** - * Construct an enumeration that wraps the specified iterator. - */ - public IteratorEnumeration(Iterator 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/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/PeekableIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/PeekableIterator.java deleted file mode 100644 index 316aedcf63..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/PeekableIterator.java +++ /dev/null @@ -1,100 +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.utility.internal.iterators; - -import java.util.Iterator; -import java.util.NoSuchElementException; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * A PeekableIterator wraps another Iterator - * and allows a peek() at the next element to be - * returned by next(). - *

- * One, possibly undesirable, side-effect of using this iterator is that - * the nested iterator's next() method will be invoked - * before the peekable iterator's next() - * method is invoked. This is because the "next" element must be - * pre-loaded for the peek() method. - * This also prevents a peekable iterator from supporting the optional - * remove() method. - */ - -public class PeekableIterator - implements Iterator -{ - private final Iterator nestedIterator; - private E next; - private boolean done; - - - /** - * Construct a peekable iterator that wraps the specified nested - * iterator. - */ - public PeekableIterator(Iterator nestedIterator) { - super(); - this.nestedIterator = nestedIterator; - 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 - * 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 remove() - * method. - */ - public void remove() { - throw new UnsupportedOperationException(); - } - - /** - * Load next with the next entry from the nested - * iterator. If there are none, next is set to END. - */ - private void loadNext() { - if (this.nestedIterator.hasNext()) { - this.next = this.nestedIterator.next(); - } else { - this.next = null; - this.done = true; - } - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this, this.nestedIterator); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ReadOnlyIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ReadOnlyIterator.java deleted file mode 100644 index df0a51333d..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ReadOnlyIterator.java +++ /dev/null @@ -1,61 +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.utility.internal.iterators; - -import java.util.Collection; -import java.util.Iterator; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * A ReadOnlyIterator wraps another Iterator - * and removes support for #remove(). - */ -public class ReadOnlyIterator - implements Iterator -{ - private final Iterator nestedIterator; - - /** - * Construct an iterator on the specified collection that - * disallows removes. - */ - public ReadOnlyIterator(Collection c) { - this(c.iterator()); - } - - /** - * Construct an iterator with the specified nested iterator - * and disallow removes. - */ - public ReadOnlyIterator(Iterator nestedIterator) { - super(); - this.nestedIterator = nestedIterator; - } - - public boolean hasNext() { - // delegate to the nested iterator - return this.nestedIterator.hasNext(); - } - - public E next() { - // delegate to the nested iterator - return this.nestedIterator.next(); - } - - public void remove() { - throw new UnsupportedOperationException(); - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this, this.nestedIterator); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ReadOnlyListIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ReadOnlyListIterator.java deleted file mode 100644 index c3b2591f44..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ReadOnlyListIterator.java +++ /dev/null @@ -1,93 +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.utility.internal.iterators; - -import java.util.List; -import java.util.ListIterator; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * A ReadOnlyListIterator wraps another - * ListIterator and removes support for: - * #remove() - * #set(Object) - * #add(Object) - */ -public class ReadOnlyListIterator - implements ListIterator -{ - private final ListIterator nestedListIterator; - - - /** - * Construct an iterator on the specified list that - * disallows removes, sets, and adds. - */ - public ReadOnlyListIterator(List list) { - this(list.listIterator()); - } - - /** - * Construct an iterator on the specified list iterator that - * disallows removes, sets, and adds. - */ - public ReadOnlyListIterator(ListIterator nestedListIterator) { - super(); - this.nestedListIterator = nestedListIterator; - } - - public boolean hasNext() { - // delegate to the nested iterator - return this.nestedListIterator.hasNext(); - } - - public E next() { - // delegate to the nested iterator - return this.nestedListIterator.next(); - } - - public boolean hasPrevious() { - // delegate to the nested iterator - return this.nestedListIterator.hasPrevious(); - } - - public E previous() { - // delegate to the nested iterator - return this.nestedListIterator.previous(); - } - - public int nextIndex() { - // delegate to the nested iterator - return this.nestedListIterator.nextIndex(); - } - - public int previousIndex() { - // delegate to the nested iterator - return this.nestedListIterator.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.nestedListIterator); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ResultSetIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ResultSetIterator.java deleted file mode 100644 index a8da8442ab..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/ResultSetIterator.java +++ /dev/null @@ -1,154 +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.utility.internal.iterators; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.Iterator; -import java.util.NoSuchElementException; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * A ResultSetIterator wraps a ResultSet - * and transforms its rows for client consumption. Subclasses can override - * #buildNext(ResultSet) to build the expected object from - * the current row of the result set. - *

- * To use, supply:

    - *
  • a ResultSet - *
  • an Adapter that converts a row in the ResultSet - * into the desired object - * (alternatively, subclass ResultSetIterator - * and override the buildNext(ResultSet) method) - *
- *

- */ -public class ResultSetIterator - implements Iterator -{ - private final ResultSet resultSet; - private final Adapter 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 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.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 SQLExceptions will - * be caught and wrapped in a 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 ResultSetIterator to convert a - * ResultSet's current row into the next object - * to be returned by the Iterator. - */ - public interface Adapter { - - /** - * Return an object corresponding to the result set's - * "current" row. Any SQLExceptions will - * be caught and wrapped in a RuntimeException. - * @see java.sql.ResultSet - */ - T buildNext(ResultSet rs) throws SQLException; - - - final class Default implements Adapter { - @SuppressWarnings("unchecked") - public static final Adapter INSTANCE = new Default(); - @SuppressWarnings("unchecked") - public static Adapter 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 "ResultSetIterator.Adapter.Default"; - } - } - - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/SingleElementIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/SingleElementIterator.java deleted file mode 100644 index 75fd9d80fd..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/SingleElementIterator.java +++ /dev/null @@ -1,63 +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.utility.internal.iterators; - -import java.util.Iterator; -import java.util.NoSuchElementException; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * A SingleElementIterator holds a single element - * and returns it with the first call to next(), at - * which point it will return false to any subsequent - * call to hasNext(). - *

- * A SingleElementIterator is equivalent to the - * Iterator returned by: - * java.util.Collections.singleton(element).iterator() - */ -public class SingleElementIterator - implements Iterator -{ - 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/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/SingleElementListIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/SingleElementListIterator.java deleted file mode 100644 index 799cb72aef..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/SingleElementListIterator.java +++ /dev/null @@ -1,94 +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.utility.internal.iterators; - -import java.util.ListIterator; -import java.util.NoSuchElementException; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * A SingleElementListIterator holds a single element - * and returns it with the first call to next(), at - * which point it will return false to any subsequent - * call to hasNext(). Likewise, it will return false - * to a call to hasPrevious() until a call to next(), - * at which point a call to previous() will return the - * single element. - *

- * A SingleElementListIterator is equivalent to the - * Iterator returned by: - * java.util.Collections.singletonList(element).listIterator() - */ -public class SingleElementListIterator - implements ListIterator -{ - 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/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TransformationIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TransformationIterator.java deleted file mode 100644 index cffb59a2e9..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TransformationIterator.java +++ /dev/null @@ -1,80 +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.utility.internal.iterators; - -import java.util.Iterator; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.Transformer; - - -/** - * A TransformationIterator wraps another Iterator - * and transforms its results for client consumption. To use, supply a - * Transformer or subclass TransformationIterator - * and override the transform(Object) method. - * Objects of type E1 are transformed into objects of type E2; - * i.e. the iterator returns objects of type E2. - */ -public class TransformationIterator - implements Iterator -{ - private final Iterator nestedIterator; - private final Transformer transformer; - - - /** - * Construct an iterator with the specified nested iterator - * and a transformer that simply returns the object, unchanged. - * Use this constructor if you want to override the - * transform(Object) method instead of building - * a Transformer. - */ - public TransformationIterator(Iterator nestedIterator) { - this(nestedIterator, Transformer.Null.instance()); - } - - /** - * Construct an iterator with the specified nested iterator - * and transformer. - */ - public TransformationIterator(Iterator nestedIterator, Transformer transformer) { - super(); - this.nestedIterator = nestedIterator; - this.transformer = transformer; - } - - public boolean hasNext() { - // delegate to the nested iterator - return this.nestedIterator.hasNext(); - } - - public E2 next() { - // transform the object returned by the nested iterator before returning it - return this.transform(this.nestedIterator.next()); - } - - public void remove() { - // delegate to the nested iterator - this.nestedIterator.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.nestedIterator); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TransformationListIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TransformationListIterator.java deleted file mode 100644 index 329f3ff142..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TransformationListIterator.java +++ /dev/null @@ -1,108 +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.utility.internal.iterators; - -import java.util.ListIterator; -import org.eclipse.jpt.utility.internal.StringTools; -import org.eclipse.jpt.utility.internal.Transformer; - -/** - * A TransformationListIterator wraps another ListIterator - * and transforms it results for client consumption. To use, supply a - * Transformer or subclass TransformationIterator - * and override the transform(Object) method. - * - * The methods set(Object) and add(Object) - * are left unsupported in this class. - */ -public class TransformationListIterator - implements ListIterator -{ - private final ListIterator nestedIterator; - private final Transformer transformer; - - - /** - * Construct an iterator with the specified nested iterator - * and a transformer that simply returns the object, unchanged. - * Use this constructor if you want to override the - * transform(Object) method instead of building - * a Transformer. - */ - public TransformationListIterator(ListIterator nestedIterator) { - this(nestedIterator, Transformer.Null.instance()); - } - - /** - * Construct an iterator with the specified nested iterator - * and transformer. - */ - public TransformationListIterator(ListIterator nestedIterator, Transformer transformer) { - super(); - this.nestedIterator = nestedIterator; - this.transformer = transformer; - } - - public boolean hasNext() { - // delegate to the nested iterator - return this.nestedIterator.hasNext(); - } - - public E2 next() { - // transform the object returned by the nested iterator before returning it - return this.transform(this.nestedIterator.next()); - } - - public int nextIndex() { - // delegate to the nested iterator - return this.nestedIterator.nextIndex(); - } - - public boolean hasPrevious() { - // delegate to the nested iterator - return this.nestedIterator.hasPrevious(); - } - - public E2 previous() { - // transform the object returned by the nested iterator before returning it - return this.transform(this.nestedIterator.previous()); - } - - public int previousIndex() { - // delegate to the nested iterator - return this.nestedIterator.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.nestedIterator.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.nestedIterator); - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TreeIterator.java b/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TreeIterator.java deleted file mode 100644 index 432c54a7a1..0000000000 --- a/jpa/plugins/org.eclipse.jpt.utility/src/org/eclipse/jpt/utility/internal/iterators/TreeIterator.java +++ /dev/null @@ -1,175 +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.utility.internal.iterators; - -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedList; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * A TreeIterator 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. - *

- * To use, supply:

    - *
  • either the root element of the tree or, if the tree has - * multiple roots, an Iterator over the set of roots - *
  • a Midwife that delivers the children - * of each child - * (alternatively, subclass TreeIterator - * and override the children(Object) method) - *
- *

- */ -public class TreeIterator - implements Iterator -{ - private final Collection> iterators; - private final Midwife midwife; - private Iterator currentIterator; - - - /** - * Construct an iterator with the specified collection of roots - * and a midwife that simply returns an empty iterator - * for each of the roots. - * Use this constructor if you want to override the - * children(Object) method instead of building - * a Midwife. - */ - public TreeIterator(Iterator roots) { - this(roots, Midwife.Null.instance()); - } - - /** - * Construct an iterator with the specified root - * and a midwife that simply returns an empty iterator - * for the root. - * Use this constructor if you want to override the - * children(Object) method instead of building - * a Midwife. - */ - public TreeIterator(E root) { - this(root, Midwife.Null.instance()); - } - - /** - * Construct an iterator with the specified root - * and midwife. - */ - public TreeIterator(E root, Midwife midwife) { - this(new SingleElementIterator(root), midwife); - } - - /** - * Construct an iterator with the specified roots - * and midwife. - */ - public TreeIterator(Iterator roots, Midwife 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>(); - this.midwife = midwife; - } - - public boolean hasNext() { - if (this.currentIterator.hasNext()) { - return true; - } - for (Iterator iterator : this.iterators) { - if (iterator.hasNext()) { - return true; - } - } - return false; - } - - public E next() { - if (this.currentIterator.hasNext()) { - return this.nextInternal(); - } - for (Iterator> 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. - */ - protected Iterator children(E next) { - return this.midwife.children(next); - } - - @Override - public String toString() { - return StringTools.buildToStringFor(this, this.currentIterator); - } - - - //********** inner classes ********** - - /** - * Used by TreeIterator to retrieve - * the immediate children of a node in the tree. - */ - public interface Midwife { - - /** - * Return the immediate children of the specified object. - */ - Iterator children(T o); - - - final class Null implements Midwife { - @SuppressWarnings("unchecked") - public static final Midwife INSTANCE = new Null(); - @SuppressWarnings("unchecked") - public static Midwife instance() { - return INSTANCE; - } - // ensure single instance - private Null() { - super(); - } - // return no neighbors - public Iterator children(S next) { - return EmptyIterator.instance(); - } - @Override - public String toString() { - return "TreeIterator.Midwife.Null"; - } - } - - } - -} diff --git a/jpa/tests/org.eclipse.jpt.core.tests/.classpath b/jpa/tests/org.eclipse.jpt.core.tests/.classpath deleted file mode 100644 index db34e47716..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/.classpath +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/jpa/tests/org.eclipse.jpt.core.tests/.cvsignore b/jpa/tests/org.eclipse.jpt.core.tests/.cvsignore deleted file mode 100644 index ba077a4031..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin diff --git a/jpa/tests/org.eclipse.jpt.core.tests/.project b/jpa/tests/org.eclipse.jpt.core.tests/.project deleted file mode 100644 index 08395a8e86..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.eclipse.jpt.core.tests - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/jpa/tests/org.eclipse.jpt.core.tests/.settings/org.eclipse.core.resources.prefs b/jpa/tests/org.eclipse.jpt.core.tests/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 88638b5d88..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Sun May 27 15:10:20 EDT 2007 -eclipse.preferences.version=1 -encoding/=ISO-8859-1 diff --git a/jpa/tests/org.eclipse.jpt.core.tests/.settings/org.eclipse.jdt.core.prefs b/jpa/tests/org.eclipse.jpt.core.tests/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index a2f6604d54..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -#Sun May 27 14:58:31 EDT 2007 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -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/jpa/tests/org.eclipse.jpt.core.tests/META-INF/MANIFEST.MF b/jpa/tests/org.eclipse.jpt.core.tests/META-INF/MANIFEST.MF deleted file mode 100644 index 3c61d8df4c..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/META-INF/MANIFEST.MF +++ /dev/null @@ -1,25 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: %pluginName -Bundle-Vendor: %providerName -Bundle-SymbolicName: org.eclipse.jpt.core.tests -Bundle-Version: 1.0.1 -Bundle-Localization: plugin -Require-Bundle: org.eclipse.core.resources, - org.eclipse.core.runtime, - org.eclipse.emf.ecore, - org.eclipse.emf.ecore.xmi, - org.eclipse.jdt.core, - org.eclipse.jem, - org.eclipse.jpt.core, - org.eclipse.jpt.utility, - org.eclipse.wst.common.emf, - org.eclipse.wst.common.project.facet.core, - org.junit -Bundle-RequiredExecutionEnvironment: J2SE-1.5 -Export-Package: org.eclipse.jpt.core.tests.internal;x-internal:=true, - org.eclipse.jpt.core.tests.internal.content.java.mappings;x-internal:=true, - org.eclipse.jpt.core.tests.internal.jdtutility;x-internal:=true, - org.eclipse.jpt.core.tests.internal.model;x-internal:=true, - org.eclipse.jpt.core.tests.internal.platform;x-internal:=true, - org.eclipse.jpt.core.tests.internal.projects;x-internal:=true diff --git a/jpa/tests/org.eclipse.jpt.core.tests/about.html b/jpa/tests/org.eclipse.jpt.core.tests/about.html deleted file mode 100644 index 9e73bdabb6..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/about.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - -About - - - - - -

About This Content

- -

June 06, 2007

- -

License

- -

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 -http://www.eclipse.org/org/documents/epl-v10.php. -For purposes of the EPL, "Program" will mean the Content.

- -

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 -http://www.eclipse.org/.

- - - diff --git a/jpa/tests/org.eclipse.jpt.core.tests/build.properties b/jpa/tests/org.eclipse.jpt.core.tests/build.properties deleted file mode 100644 index 9bf11f791e..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/build.properties +++ /dev/null @@ -1,19 +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 -############################################################################### -javacSource = 1.5 -javacTarget = 1.5 -bin.includes = .,\ - META-INF/,\ - about.html,\ - test.xml,\ - plugin.properties -source.. = src/ -output.. = bin/ diff --git a/jpa/tests/org.eclipse.jpt.core.tests/plugin.properties b/jpa/tests/org.eclipse.jpt.core.tests/plugin.properties deleted file mode 100644 index 6ebf8dbed1..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/plugin.properties +++ /dev/null @@ -1,22 +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 -############################################################################### -# ==================================================================== -# 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=Java Persistence API Core Tests -providerName=Eclipse.org diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/JptCoreTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/JptCoreTests.java deleted file mode 100644 index baf5150f80..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/JptCoreTests.java +++ /dev/null @@ -1,38 +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 - ******************************************************************************/ -package org.eclipse.jpt.core.tests.internal; - -import junit.framework.Test; -import junit.framework.TestSuite; -import org.eclipse.jpt.core.tests.internal.content.java.mappings.JptCoreContentJavaMappingsTests; -import org.eclipse.jpt.core.tests.internal.jdtutility.JptCoreJdtUtilityTests; -import org.eclipse.jpt.core.tests.internal.model.JptCoreModelTests; -import org.eclipse.jpt.core.tests.internal.platform.JptCorePlatformTests; - -/** - * Runs all JPT Core Tests - */ -public class JptCoreTests { - - public static Test suite() { - TestSuite suite = new TestSuite(JptCoreTests.class.getName()); - suite.addTest(JptCoreContentJavaMappingsTests.suite()); - suite.addTest(JptCoreModelTests.suite()); - suite.addTest(JptCoreJdtUtilityTests.suite()); - suite.addTest(JptCorePlatformTests.suite()); - return suite; - } - - private JptCoreTests() { - super(); - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/ProjectUtility.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/ProjectUtility.java deleted file mode 100644 index ac9e78a7d6..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/ProjectUtility.java +++ /dev/null @@ -1,91 +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.core.tests.internal; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.AssertionFailedException; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -/** - * Copied from org.eclipse.wst.common.tests - */ -public class ProjectUtility { - public static IProject[] getAllProjects() { - IProject[] projects = new IProject[0]; - try { - projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - } catch (AssertionFailedException ex) { - // Catch Malformed tree exception that occurs from time to time... - } - return projects; - } - public static void deleteAllProjects() throws Exception { - //closing projects and tread work in here is a hack because of a BeanInfo bug holding - //onto jars loaded in another VM - -// for (int i = 0; i < projects.length; i++) { -// if (projects[i].exists()) { -// projects[i].close(null); // This should signal the extra VM to kill itself -// } -// } - // Thread.yield(); // give the VM a chance to die - IWorkspaceRunnable runnable = new IWorkspaceRunnable() { - - public void run(IProgressMonitor monitor) { - IProject[] projects = getAllProjects(); - for (int i = 0; i < projects.length; i++) { - IProject project = projects[i]; - boolean success = false; - Exception lastException = null; - // Don't make 2^12 is about 4 seconds which is the max we - // will wait for the VM to die - for (int j = 0; j < 13 && !success; j++) { - try { - if (project.exists()) { - project.delete(true, true, null); - ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, null); - } - success = true; - } catch (Exception e) { - lastException = e; - if (project.exists()) { - try { - project.close(null); - project.open(null); - } catch (Exception e2) { - // do nothing - } - } - try { - Thread.sleep((int) Math.pow(2, j)); - } catch (InterruptedException e1) { - // do nothing - } // if the VM isn't dead, try sleeping - } - } - if (!success && lastException != null) { - //Logger.getLogger().log("Problem while deleting: " + lastException.getMessage()); -// Assert.fail("Caught Exception=" + -// lastException.getMessage() + " when deleting project=" + project.getName()); - } - } - } - }; - try { - ResourcesPlugin.getWorkspace().run(runnable, null); - } catch (CoreException ce) { - // do nothing - } - //verifyNoProjects(); - } -} \ No newline at end of file diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/content/java/mappings/JavaEntityTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/content/java/mappings/JavaEntityTests.java deleted file mode 100644 index bbf7a950dd..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/content/java/mappings/JavaEntityTests.java +++ /dev/null @@ -1,52 +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.core.tests.internal.content.java.mappings; - -import java.util.Iterator; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jpt.core.internal.content.java.IJavaTypeMapping; -import org.eclipse.jpt.core.internal.content.java.mappings.JPA; -import org.eclipse.jpt.utility.internal.iterators.ArrayIterator; - -public class JavaEntityTests extends JpaJavaTestCase { - - public JavaEntityTests(String name) { - super(name); - } - - private void createTestEntity1() throws CoreException { - this.createTestType(new DefaultAnnotationWriter() { - @Override - public Iterator imports() { - return new ArrayIterator(JPA.ENTITY); - } - @Override - public void appendTypeAnnotationTo(StringBuffer sb) { - sb.append("@Entity"); - } - }); - this.synchPersistenceXml(); - } - - public void testGetName() throws Exception { - this.createTestEntity1(); - IJavaTypeMapping typeMapping = this.javaPersistentTypeNamed(FULLY_QUALIFIED_TYPE_NAME).getMapping(); - assertEquals(TYPE_NAME, typeMapping.getName()); - } - -// TODO we can only execute 1 test for now... -// public void testGetKey() throws Exception { -// this.createTestEntity1(); -// IJavaTypeMapping typeMapping = this.javaPersistentTypeNamed(FULLY_QUALIFIED_TYPE_NAME).getMapping(); -// assertEquals(IMappingKeys.ENTITY_TYPE_MAPPING_KEY, typeMapping.getKey()); -// } -// -} diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/content/java/mappings/JpaJavaTestCase.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/content/java/mappings/JpaJavaTestCase.java deleted file mode 100644 index ba028e9704..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/content/java/mappings/JpaJavaTestCase.java +++ /dev/null @@ -1,62 +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.core.tests.internal.content.java.mappings; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jpt.core.internal.IJpaFile; -import org.eclipse.jpt.core.internal.content.java.JavaPersistentType; -import org.eclipse.jpt.core.internal.content.java.JpaCompilationUnit; -import org.eclipse.jpt.core.internal.jdtutility.Type; -import org.eclipse.jpt.core.internal.synch.SynchronizeClassesJob; -import org.eclipse.jpt.core.tests.internal.jdtutility.AnnotationTestCase; -import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject; -import org.eclipse.jpt.core.tests.internal.projects.TestJpaProject; -import org.eclipse.jpt.utility.internal.ClassTools; - -public abstract class JpaJavaTestCase extends AnnotationTestCase { - - public JpaJavaTestCase(String name) { - super(name); - } - - @Override - protected TestJavaProject buildJavaProject(String projectName, boolean autoBuild) throws Exception { - return new TestJpaProject(projectName, autoBuild); - } - - protected TestJpaProject jpaProject() { - return (TestJpaProject) this.javaProject; - } - - protected JavaPersistentType javaPersistentTypeNamed(String typeName) { - for (IJpaFile jpaFile : this.jpaProject().getJpaProject().jpaFiles(JavaCore.JAVA_SOURCE_CONTENT_TYPE)) { - JpaCompilationUnit cu = (JpaCompilationUnit) jpaFile.getContent(); - for (JavaPersistentType pt : cu.getTypes()) { - if (pt.fullyQualifiedTypeName().equals(typeName)) { - return pt; - } - } - } - throw new IllegalArgumentException("missing type: " + typeName); - } - - protected Type typeNamed(String typeName) { - return this.javaPersistentTypeNamed(typeName).getType(); - } - - protected void synchPersistenceXml() { - SynchronizeClassesJob job = new SynchronizeClassesJob(this.jpaProject().getProject().getFile("src/META-INF/persistence.xml")); - ClassTools.executeMethod(job, "run", IProgressMonitor.class, new NullProgressMonitor()); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/content/java/mappings/JptCoreContentJavaMappingsTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/content/java/mappings/JptCoreContentJavaMappingsTests.java deleted file mode 100644 index ddbb6bd094..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/content/java/mappings/JptCoreContentJavaMappingsTests.java +++ /dev/null @@ -1,28 +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.core.tests.internal.content.java.mappings; - -import junit.framework.Test; -import junit.framework.TestSuite; - -public class JptCoreContentJavaMappingsTests { - - public static Test suite() { - TestSuite suite = new TestSuite(JptCoreContentJavaMappingsTests.class.getName()); -// suite.addTestSuite(JavaEntityTests.class); - return suite; - } - - private JptCoreContentJavaMappingsTests() { - super(); - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/AnnotationTestCase.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/AnnotationTestCase.java deleted file mode 100644 index 87d6169bac..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/AnnotationTestCase.java +++ /dev/null @@ -1,429 +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 - ******************************************************************************/ -package org.eclipse.jpt.core.tests.internal.jdtutility; - -import java.util.Iterator; -import java.util.List; -import junit.framework.TestCase; -import org.eclipse.core.runtime.CoreException; -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.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.SimpleName; -import org.eclipse.jdt.core.dom.SingleMemberAnnotation; -import org.eclipse.jdt.core.dom.StringLiteral; -import org.eclipse.jpt.core.internal.jdtutility.FieldAttribute; -import org.eclipse.jpt.core.internal.jdtutility.MethodAttribute; -import org.eclipse.jpt.core.internal.jdtutility.Type; -import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject; -import org.eclipse.jpt.core.tests.internal.projects.TestJavaProject.SourceWriter; -import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; -import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator; - -/** - * Provide an easy(?) way to build an annotated source file. - * The type must be created by calling one of the #createType() methods - * before calling any of the various helper methods (i.e. the type is *not* - * created during #setUp()). - */ -public abstract class AnnotationTestCase extends TestCase { - protected TestJavaProject javaProject; - - protected static final String CR = System.getProperty("line.separator"); - protected static final String PROJECT_NAME = "AnnotationTestProject"; - protected static final String PACKAGE_NAME = "test"; - protected static final String TYPE_NAME = "AnnotationTestType"; - protected static final String FULLY_QUALIFIED_TYPE_NAME = PACKAGE_NAME + "." + TYPE_NAME; - protected static final String FILE_NAME = TYPE_NAME + ".java"; - - protected 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(PROJECT_NAME, false); // false = no auto-build - } - - protected TestJavaProject buildJavaProject(String projectName, boolean autoBuild) throws Exception { - return new TestJavaProject(projectName, autoBuild); // false = no auto-build - } - - @Override - protected void tearDown() throws Exception { -// this.dumpSource(); - this.javaProject.dispose(); - this.javaProject = null; - super.tearDown(); - } - - protected void dumpSource() throws Exception { - System.out.println("*** " + this.getName() + " ****"); - System.out.println(this.source()); - System.out.println(); - } - - - // ********** type creation ********** - - /** - * create an un-annotated type - */ - protected IType createTestType() throws CoreException { - return this.createTestType(new DefaultAnnotationWriter()); - } - - /** - * shortcut for simply adding an annotation to the 'id' field - */ - protected IType createTestType(final String annotationImport, final String idFieldAnnotation) throws CoreException { - return this.createTestType(new DefaultAnnotationWriter() { - @Override - public Iterator imports() { - return (annotationImport == null) ? - EmptyIterator.instance() - : - new SingleElementIterator(annotationImport); - } - @Override - public void appendIdFieldAnnotationTo(StringBuffer sb) { - sb.append(idFieldAnnotation); - } - }); - } - - /** - * shortcut for simply adding a fully-qualified annotation to the 'id' field - */ - protected IType createTestType(final String idFieldAnnotation) throws CoreException { - return this.createTestType(null, idFieldAnnotation); - } - - protected IType createTestType(AnnotationWriter annotationWriter) throws CoreException { - return this.javaProject.createType(PACKAGE_NAME, FILE_NAME, this.createSourceWriter(annotationWriter)); - } - - protected SourceWriter createSourceWriter(AnnotationWriter annotationWriter) { - return new AnnotatedSourceWriter(annotationWriter); - } - - protected void appendSourceTo(StringBuffer sb, AnnotationWriter annotationWriter) { - sb.append(CR); - for (Iterator stream = annotationWriter.imports(); stream.hasNext(); ) { - sb.append("import "); - sb.append(stream.next()); - sb.append(";"); - sb.append(CR); - } - annotationWriter.appendTypeAnnotationTo(sb); - sb.append(CR); - sb.append("public class ").append(TYPE_NAME).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); - sb.append("}").append(CR); - } - - - // ********** queries ********** - - protected IType jdtType() throws JavaModelException { - return this.javaProject.findType(FULLY_QUALIFIED_TYPE_NAME); - } - - protected Type testType() throws JavaModelException { - return new Type(this.jdtType()); - } - - protected FieldAttribute idField() throws JavaModelException { - return this.fieldNamed("id"); - } - - protected FieldAttribute nameField() throws JavaModelException { - return this.fieldNamed("name"); - } - - protected FieldAttribute fieldNamed(String fieldName) throws JavaModelException { - return new FieldAttribute(this.jdtType().getField(fieldName)); - } - - protected MethodAttribute idGetMethod() throws JavaModelException { - return this.methodNamed("getId"); - } - - protected MethodAttribute nameGetMethod() throws JavaModelException { - return this.methodNamed("getName"); - } - - protected MethodAttribute methodNamed(String methodName) throws JavaModelException { - return this.method(methodName, EMPTY_STRING_ARRAY); - } - - protected MethodAttribute method(String methodName, String[] parameterTypeSignatures) throws JavaModelException { - return new MethodAttribute(this.jdtType().getMethod(methodName, parameterTypeSignatures)); - } - - protected String source() throws JavaModelException { - return this.jdtType().getOpenable().getBuffer().getContents(); - } - - - // ********** test validation ********** - - protected void assertSourceContains(String s) throws JavaModelException { - String source = this.source(); - 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) throws JavaModelException { - String source = this.source(); - 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; - } - - @SuppressWarnings("unchecked") - protected List values(NormalAnnotation na) { - return na.values(); - } - - /** - * check for null member value pair - */ - protected Expression valueInternal(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.valueInternal(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; - } - - /** - * 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 string literal and set its initial value. - */ - protected StringLiteral newStringLiteral(AST ast, String value) { - StringLiteral stringLiteral = ast.newStringLiteral(); - stringLiteral.setLiteralValue(value); - return stringLiteral; - } - - 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)); - } - - /** - * 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)); - } - - - // ********** member classes ********** - - public interface AnnotationWriter { - Iterator imports(); - void appendTypeAnnotationTo(StringBuffer sb); - void appendIdFieldAnnotationTo(StringBuffer sb); - void appendNameFieldAnnotationTo(StringBuffer sb); - void appendGetIdMethodAnnotationTo(StringBuffer sb); - void appendSetIdMethodAnnotationTo(StringBuffer sb); - void appendGetNameMethodAnnotationTo(StringBuffer sb); - void appendSetNameMethodAnnotationTo(StringBuffer sb); - } - - public static class DefaultAnnotationWriter implements AnnotationWriter { - public Iterator imports() {return EmptyIterator.instance();} - public void appendTypeAnnotationTo(StringBuffer sb) {/* do nothing */} - public void appendIdFieldAnnotationTo(StringBuffer sb) {/* do nothing */} - public void appendNameFieldAnnotationTo(StringBuffer sb) {/* do nothing */} - public void appendGetIdMethodAnnotationTo(StringBuffer sb) {/* do nothing */} - public void appendSetIdMethodAnnotationTo(StringBuffer sb) {/* do nothing */} - public void appendGetNameMethodAnnotationTo(StringBuffer sb) {/* do nothing */} - public void appendSetNameMethodAnnotationTo(StringBuffer sb) {/* do nothing */} - } - - public static class AnnotationWriterWrapper implements AnnotationWriter { - private final AnnotationWriter aw; - public AnnotationWriterWrapper(AnnotationWriter aw) { - super(); - this.aw = aw; - } - public Iterator imports() {return aw.imports();} - public void appendTypeAnnotationTo(StringBuffer sb) {aw.appendTypeAnnotationTo(sb);} - public void appendIdFieldAnnotationTo(StringBuffer sb) {aw.appendIdFieldAnnotationTo(sb);} - public void appendNameFieldAnnotationTo(StringBuffer sb) {aw.appendNameFieldAnnotationTo(sb);} - public void appendGetIdMethodAnnotationTo(StringBuffer sb) {aw.appendGetIdMethodAnnotationTo(sb);} - public void appendSetIdMethodAnnotationTo(StringBuffer sb) {aw.appendSetIdMethodAnnotationTo(sb);} - public void appendGetNameMethodAnnotationTo(StringBuffer sb) {aw.appendGetNameMethodAnnotationTo(sb);} - public void appendSetNameMethodAnnotationTo(StringBuffer sb) {aw.appendSetNameMethodAnnotationTo(sb);} - } - - public class AnnotatedSourceWriter implements SourceWriter { - private AnnotationWriter annotationWriter; - public AnnotatedSourceWriter(AnnotationWriter annotationWriter) { - super(); - this.annotationWriter = annotationWriter; - } - public void appendSourceTo(StringBuffer sb) { - AnnotationTestCase.this.appendSourceTo(sb, this.annotationWriter); - } - } - -} diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/CombinationIndexedDeclarationAnnotationAdapterTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/CombinationIndexedDeclarationAnnotationAdapterTests.java deleted file mode 100644 index 10a259ccf7..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/CombinationIndexedDeclarationAnnotationAdapterTests.java +++ /dev/null @@ -1,728 +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 - ******************************************************************************/ -package org.eclipse.jpt.core.tests.internal.jdtutility; - -import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.MemberValuePair; -import org.eclipse.jdt.core.dom.NormalAnnotation; -import org.eclipse.jdt.core.dom.StringLiteral; -import org.eclipse.jpt.core.internal.jdtutility.AnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.CombinationIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.MemberAnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.MemberIndexedAnnotationAdapter; - -public class CombinationIndexedDeclarationAnnotationAdapterTests extends AnnotationTestCase { - - public CombinationIndexedDeclarationAnnotationAdapterTests(String name) { - super(name); - } - - private void createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception { - this.javaProject.createType("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }"); - } - - public void testGetAnnotation1() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID\")"); - DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", 0); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - assertEquals("annot.JoinColumn", annotation.getTypeName().getFullyQualifiedName()); - assertTrue(annotation.isNormalAnnotation()); - } - - public void testGetAnnotation2() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID\")"); - DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", 1); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - } - - public void testGetAnnotation3() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumns(@annot.JoinColumn(name=\"ADDRESS_ID\"))"); - DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", 0); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - assertEquals("annot.JoinColumn", annotation.getTypeName().getFullyQualifiedName()); - assertTrue(annotation.isNormalAnnotation()); - } - - public void testGetAnnotation4() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumns(@annot.JoinColumn(name=\"ADDRESS_ID\"))"); - DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", 1); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - } - - public void testGetAnnotation5() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - 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 MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - assertEquals("annot.JoinColumn", annotation.getTypeName().getFullyQualifiedName()); - assertTrue(annotation.isNormalAnnotation()); - String value = ((StringLiteral) ((MemberValuePair) ((NormalAnnotation) annotation).values().get(0)).getValue()).getLiteralValue(); - assertEquals("ADDRESS_ID2", value); - } - - public void testGetAnnotation6() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - 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 MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - } - - public void testGetAnnotation7() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - 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 MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - assertEquals("annot.JoinColumn", annotation.getTypeName().getFullyQualifiedName()); - assertTrue(annotation.isNormalAnnotation()); - String value = ((StringLiteral) ((MemberValuePair) ((NormalAnnotation) annotation).values().get(0)).getValue()).getLiteralValue(); - assertEquals("ADDRESS_ID2", value); - } - - public void testGetAnnotation8() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - 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 MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - } - - public void testRemoveAnnotation1() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID\")"); - DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", 0); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - aa.removeAnnotation(); - this.assertSourceDoesNotContain("JoinColumn"); - } - - public void testRemoveAnnotation2() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumns(@annot.JoinColumn(name=\"ADDRESS_ID\"))"); - DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", 0); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - aa.removeAnnotation(); - this.assertSourceDoesNotContain("JoinColumns"); - this.assertSourceDoesNotContain("JoinColumn"); - } - - public void testRemoveAnnotation3() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - 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 MemberAnnotationAdapter(this.idField(), daa); - aa.removeAnnotation(); - this.assertSourceDoesNotContain("JoinColumns"); - this.assertSourceDoesNotContain("ADDRESS_ID2"); - this.assertSourceContains("@JoinColumn(name=\"ADDRESS_ID1\")"); - } - - public void testRemoveAnnotation4() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - 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 MemberAnnotationAdapter(this.idField(), daa); - aa.removeAnnotation(); - this.assertSourceDoesNotContain("JoinColumns"); - this.assertSourceDoesNotContain("ADDRESS_ID2"); - this.assertSourceContains("@JoinColumn(name=\"ADDRESS_ID1\")"); - } - - public void testRemoveAnnotation5() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "String comment(); JoinColumn[] columns();"); - 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 MemberAnnotationAdapter(this.idField(), daa); - aa.removeAnnotation(); - this.assertSourceContains("@annot.JoinColumns(comment=\"test\",columns=@annot.JoinColumn(name=\"ADDRESS_ID1\"))"); - } - - public void testRemoveAnnotation6() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumns(null)"); - DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", 0); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - aa.removeAnnotation(); - this.assertSourceContains("@annot.JoinColumns(null)"); - } - - public void testRemoveAnnotation12() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - 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 MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - - aa.removeAnnotation(); - this.assertSourceContains(expected); - this.assertSourceDoesNotContain("JoinColumns"); - } - - public void testRemoveAnnotation13() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumns({null, @annot.JoinColumn(name=\"ADDRESS_ID1\")})"); - this.assertSourceContains("@annot.JoinColumn"); - DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "value", 1); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - - aa.removeAnnotation(); - this.assertSourceDoesNotContain("JoinColumn"); - } - - public void testRemoveAnnotation14() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - 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 MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - - aa.removeAnnotation(); - this.assertSourceContains(expected); - } - - public void testRemoveAnnotation15() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - 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 MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - - aa.removeAnnotation(); - this.assertSourceContains(expected); - } - - public void testRemoveAnnotation16() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - 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 MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - - aa.removeAnnotation(); - this.assertSourceContains(expected); - } - - public void testRemoveAnnotation17() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumns({null, null, @annot.JoinColumn(name=\"ADDRESS_ID2\")})"); - this.assertSourceContains("@annot.JoinColumn"); - DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "value", 2); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - - aa.removeAnnotation(); - this.assertSourceDoesNotContain("JoinColumn"); - } - - public void testNewMarkerAnnotation1() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType(); - this.assertSourceDoesNotContain("JoinColumn"); - DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "columns", 0); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains("JoinColumn"); - this.assertSourceDoesNotContain("JoinColumns"); - } - - public void testNewMarkerAnnotation2() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumn"); - this.assertSourceDoesNotContain("JoinColumns"); - DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "columns", 1); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains("@JoinColumns(columns={@JoinColumn,@JoinColumn})"); - } - - public void testNewMarkerAnnotation3() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn, @annot.JoinColumn})"); - DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "columns", 2); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains("@annot.JoinColumns(columns={@annot.JoinColumn, @annot.JoinColumn," + CR + " @JoinColumn})"); - } - - public void testNewMarkerAnnotation4() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumn(77)"); - DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "columns", 0); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains("JoinColumn"); - this.assertSourceDoesNotContain("JoinColumns"); - this.assertSourceDoesNotContain("77"); - } - - public void testNewMarkerAnnotation5() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumns(columns=@annot.JoinColumn(77))"); - DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "columns", 0); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains("@annot.JoinColumns(columns=@JoinColumn)"); - this.assertSourceDoesNotContain("77"); - } - - public void testNewMarkerAnnotation6() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumns(columns=@annot.JoinColumn(77))"); - DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "columns", 1); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains("@annot.JoinColumns(columns={@annot.JoinColumn(77),@JoinColumn})"); - } - - public void testNewMarkerAnnotation7() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumn(77)"); - DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "columns", 1); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains("@JoinColumns(columns={@JoinColumn(77),@JoinColumn})"); - } - - public void testNewMarkerAnnotation8() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumns(columns={@annot.JoinColumn(77),@annot.JoinColumn(88)})"); - DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "columns", 1); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains("@annot.JoinColumns(columns={@annot.JoinColumn(77),@JoinColumn})"); - } - - public void testNewMarkerAnnotation9() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name(); String text(); int num();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumn(text=\"blah\",num=42)"); - DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "columns", 1); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains("@JoinColumns(columns={@JoinColumn(text=\"blah\", num=42),@JoinColumn})"); - } - - public void testNewMarkerAnnotation23() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name(); String text(); int num();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumn(text=\"blah\",num=42)"); - String expected = "@JoinColumns(columns={@JoinColumn(text=\"blah\", num=42),null,@JoinColumn})"; - this.assertSourceDoesNotContain(expected); - DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "columns", 2); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - aa.newMarkerAnnotation(); - this.assertSourceContains(expected); - } - - public void testNewMarkerAnnotation24() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name(); String text(); int num();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - this.createTestType("@annot.JoinColumn(text=\"blah\",num=42)"); - String expected1 = "@JoinColumns({"; - String expected2 = "@JoinColumn(text=\"blah\", num=42),null,"; - String expected3 = "@JoinColumn})"; - this.assertSourceDoesNotContain(expected1); - this.assertSourceDoesNotContain(expected2); - this.assertSourceDoesNotContain(expected3); - DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "value", 2); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - aa.newMarkerAnnotation(); - this.assertSourceContains(expected1); - this.assertSourceContains(expected2); - this.assertSourceContains(expected3); - } - - public void testNewMarkerAnnotation25() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - 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); - this.assertSourceDoesNotContain(expected2); - DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "columns", 4); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - aa.newMarkerAnnotation(); - this.assertSourceContains(expected1); - this.assertSourceContains(expected2); - } - - public void testNewMarkerAnnotation26() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - 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); - this.assertSourceDoesNotContain(expected2); - DeclarationAnnotationAdapter daa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "value", 4); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - aa.newMarkerAnnotation(); - this.assertSourceContains(expected1); - this.assertSourceContains(expected2); - } - - public void testMoveAnnotation1() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID0\")"); - String expected = "@JoinColumns(columns={null,@JoinColumn(name=\"ADDRESS_ID0\")})"; - this.assertSourceDoesNotContain(expected); - IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "columns", 0); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(); - assertNotNull(annotation); - - iaa.moveAnnotation(1); - this.assertSourceContains(expected); - } - - public void testMoveAnnotation2() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - 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 MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(); - assertNotNull(annotation); - - iaa.moveAnnotation(0); - this.assertSourceContains(expected); - this.assertSourceDoesNotContain("JoinColumns"); - } - - public void testMoveAnnotation2a() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - 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 MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(); - assertNotNull(annotation); - - iaa.moveAnnotation(0); - this.assertSourceContains(expected); - this.assertSourceDoesNotContain("JoinColumns"); - } - - public void testMoveAnnotation3() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - 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); - IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "columns", 3); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(); - assertNotNull(annotation); - - iaa.moveAnnotation(0); - this.assertSourceContains(expected); - } - - public void testMoveAnnotation4() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - 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); - IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "columns", 3); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(); - assertNotNull(annotation); - - iaa.moveAnnotation(0); - this.assertSourceContains(expected); - } - - public void testMoveAnnotation5() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - 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); - IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "columns", 2); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(); - assertNotNull(annotation); - - iaa.moveAnnotation(3); - this.assertSourceContains(expected); - } - - public void testMoveAnnotation6() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - 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); - IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "columns", 0); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(); - assertNotNull(annotation); - - iaa.moveAnnotation(3); - this.assertSourceContains(expected); - } - - public void testMoveAnnotation7() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - 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); - IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "columns", 3); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(); - assertNull(annotation); - - iaa.moveAnnotation(0); - this.assertSourceContains(expected); - } - - public void testMoveAnnotation8() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - 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); - IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "columns", 3); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(); - assertNull(annotation); - - iaa.moveAnnotation(0); - this.assertSourceContains(expected); - } - - 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\")})"; - this.createTestType(expected); // the source should be unchanged - IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "columns", 0); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(); - assertNull(annotation); - - iaa.moveAnnotation(3); - this.assertSourceContains(expected); - } - - public void testMoveAnnotation10() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - 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 MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(); - assertNull(annotation); - - iaa.moveAnnotation(1); - this.assertSourceContains(expected); - this.assertSourceDoesNotContain("@annot.JoinColumns"); - } - - public void testMoveAnnotation10a() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] value();"); - 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 MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(); - assertNull(annotation); - - iaa.moveAnnotation(1); - this.assertSourceContains(expected); - this.assertSourceDoesNotContain("@annot.JoinColumns"); - } - - public void testMoveAnnotation11() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - this.createTestType("@annot.JoinColumn(name=\"ADDRESS_ID0\")"); - IndexedDeclarationAnnotationAdapter cidaa = new CombinationIndexedDeclarationAnnotationAdapter( - "annot.JoinColumn", "annot.JoinColumns", "columns", 1); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(); - assertNull(annotation); - - iaa.moveAnnotation(0); - this.assertSourceDoesNotContain("JoinColumn"); - } - - public void testMoveAnnotation12() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - 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 MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(); - assertNotNull(annotation); - - iaa.moveAnnotation(0); - this.assertSourceContains(expected); - this.assertSourceDoesNotContain("@annot.JoinColumns"); - } - - public void testMoveAnnotation13() throws Exception { - this.createAnnotationAndMembers("JoinColumn", "String name();"); - this.createAnnotationAndMembers("JoinColumns", "JoinColumn[] columns();"); - 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 MemberIndexedAnnotationAdapter(this.idField(), cidaa); - Annotation annotation = iaa.getAnnotation(); - assertNotNull(annotation); - - iaa.moveAnnotation(0); - this.assertSourceContains(expected); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/JDTToolsTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/JDTToolsTests.java deleted file mode 100644 index 706e606261..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/JDTToolsTests.java +++ /dev/null @@ -1,86 +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 - ******************************************************************************/ -package org.eclipse.jpt.core.tests.internal.jdtutility; - -import org.eclipse.jdt.core.dom.Name; -import org.eclipse.jpt.core.internal.jdtutility.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.jdtutility.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.jdtutility.FieldAttribute; -import org.eclipse.jpt.core.internal.jdtutility.JDTTools; -import org.eclipse.jpt.core.internal.jdtutility.SimpleDeclarationAnnotationAdapter; - -public class JDTToolsTests extends AnnotationTestCase { - - public JDTToolsTests(String name) { - super(name); - } - - private void createEnumAndMembers(String enumName, String enumBody) throws Exception { - this.javaProject.createType("enums", enumName + ".java", "public enum " + enumName + " { " + enumBody + " }"); - } - - private void createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception { - this.javaProject.createType("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }"); - } - - public void testResolveEnum1() throws Exception { - this.createEnumAndMembers("TestEnum", "FOO, BAR, BAZ"); - this.createAnnotationAndMembers("TestAnnotation", "TestEnum foo();"); - - this.createTestType("@annot.TestAnnotation(foo=enums.TestEnum.BAZ)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.TestAnnotation"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo"); - FieldAttribute field = this.idField(); - - String actual = JDTTools.resolveEnum((Name) field.annotationElementExpression(daea)); - assertEquals("enums.TestEnum.BAZ", actual); - } - - public void testResolveEnum2() throws Exception { - this.createEnumAndMembers("TestEnum", "FOO, BAR, BAZ"); - this.createAnnotationAndMembers("TestAnnotation", "TestEnum foo();"); - - this.createTestType("static enums.TestEnum.BAZ", "@annot.TestAnnotation(foo=BAZ)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.TestAnnotation"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo"); - FieldAttribute field = this.idField(); - - String actual = JDTTools.resolveEnum((Name) field.annotationElementExpression(daea)); - assertEquals("enums.TestEnum.BAZ", actual); - } - - public void testResolveEnum3() throws Exception { - this.createEnumAndMembers("TestEnum", "FOO, BAR, BAZ"); - this.createAnnotationAndMembers("TestAnnotation", "TestEnum foo();"); - - this.createTestType("static enums.TestEnum.*", "@annot.TestAnnotation(foo=BAZ)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.TestAnnotation"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo"); - FieldAttribute field = this.idField(); - - String actual = JDTTools.resolveEnum((Name) field.annotationElementExpression(daea)); - assertEquals("enums.TestEnum.BAZ", actual); - } - - public void testResolveEnum4() throws Exception { - this.createEnumAndMembers("TestEnum", "FOO, BAR, BAZ"); - this.createAnnotationAndMembers("TestAnnotation", "TestEnum foo();"); - - this.createTestType("enums.TestEnum", "@annot.TestAnnotation(foo=TestEnum.BAZ)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.TestAnnotation"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo"); - FieldAttribute field = this.idField(); - - String actual = JDTTools.resolveEnum((Name) field.annotationElementExpression(daea)); - assertEquals("enums.TestEnum.BAZ", actual); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/JptCoreJdtUtilityTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/JptCoreJdtUtilityTests.java deleted file mode 100644 index a6a0fb6b52..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/JptCoreJdtUtilityTests.java +++ /dev/null @@ -1,34 +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 - ******************************************************************************/ -package org.eclipse.jpt.core.tests.internal.jdtutility; - -import junit.framework.Test; -import junit.framework.TestSuite; - -public class JptCoreJdtUtilityTests { - - public static Test suite() { - TestSuite suite = new TestSuite(JptCoreJdtUtilityTests.class.getName()); - suite.addTestSuite(MemberAnnotationElementAdapterTests.class); - suite.addTestSuite(CombinationIndexedDeclarationAnnotationAdapterTests.class); - suite.addTestSuite(JDTToolsTests.class); - suite.addTestSuite(NestedDeclarationAnnotationAdapterTests.class); - suite.addTestSuite(NestedIndexedDeclarationAnnotationAdapterTests.class); - suite.addTestSuite(SimpleDeclarationAnnotationAdapterTests.class); - suite.addTestSuite(TypeTests.class); - return suite; - } - - private JptCoreJdtUtilityTests() { - super(); - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/MemberAnnotationElementAdapterTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/MemberAnnotationElementAdapterTests.java deleted file mode 100644 index b07c31488a..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/MemberAnnotationElementAdapterTests.java +++ /dev/null @@ -1,948 +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 - ******************************************************************************/ -package org.eclipse.jpt.core.tests.internal.jdtutility; - -import java.util.Arrays; - -import org.eclipse.jpt.core.internal.ITextRange; -import org.eclipse.jpt.core.internal.jdtutility.ASTNodeTextRange; -import org.eclipse.jpt.core.internal.jdtutility.AnnotationElementAdapter; -import org.eclipse.jpt.core.internal.jdtutility.AnnotationStringArrayExpressionConverter; -import org.eclipse.jpt.core.internal.jdtutility.BooleanStringExpressionConverter; -import org.eclipse.jpt.core.internal.jdtutility.CharacterStringExpressionConverter; -import org.eclipse.jpt.core.internal.jdtutility.ConversionDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.jdtutility.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.DeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.jdtutility.EnumArrayDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.jdtutility.EnumDeclarationAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.jdtutility.ExpressionConverter; -import org.eclipse.jpt.core.internal.jdtutility.MemberAnnotationElementAdapter; -import org.eclipse.jpt.core.internal.jdtutility.NestedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.NumberStringExpressionConverter; -import org.eclipse.jpt.core.internal.jdtutility.PrimitiveTypeStringExpressionConverter; -import org.eclipse.jpt.core.internal.jdtutility.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.SimpleTypeStringExpressionConverter; -import org.eclipse.jpt.core.internal.jdtutility.StringExpressionConverter; - -public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { - - public MemberAnnotationElementAdapterTests(String name) { - super(name); - } - - private void createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception { - this.javaProject.createType("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }"); - } - - private void createEnum(String enumName, String enumBody) throws Exception { - this.javaProject.createType("enums", enumName + ".java", "public enum " + enumName + " { " + enumBody + " }"); - } - - public void testGetValue1() throws Exception { - this.createAnnotationAndMembers("Foo", "String bar();"); - this.createTestType("@annot.Foo(bar=\"xxx\")"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("xxx", aea.getValue()); - } - - public void testGetValue2() throws Exception { - this.createAnnotationAndMembers("Foo", "int bar();"); - this.createTestType("@annot.Foo(bar=48)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", NumberStringExpressionConverter.instance()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("48", aea.getValue()); - } - - public void testGetValue3() throws Exception { - this.createAnnotationAndMembers("Foo", "char bar();"); - this.createTestType("@annot.Foo(bar='c')"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", CharacterStringExpressionConverter.instance()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("c", aea.getValue()); - } - - public void testGetValue4() throws Exception { - this.createAnnotationAndMembers("Foo", "boolean bar();"); - this.createTestType("@annot.Foo(bar=false)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", BooleanStringExpressionConverter.instance()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("false", aea.getValue()); - } - - public void testGetValue5() throws Exception { - this.createAnnotationAndMembers("Baz", "boolean fred();"); - this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();"); - this.createAnnotationAndMembers("Foo", "annot.Bar value();"); - 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 daea = new ConversionDeclarationAnnotationElementAdapter(daa3, "fred", BooleanStringExpressionConverter.instance()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("false", aea.getValue()); - } - - public void testGetValue6() throws Exception { - this.createAnnotationAndMembers("Foo", "boolean value();"); - this.createTestType("@annot.Foo(false)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, BooleanStringExpressionConverter.instance()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("false", aea.getValue()); - } - - public void testGetValueNull1() throws Exception { - this.createAnnotationAndMembers("Foo", "String bar();"); - this.createTestType("@annot.Foo"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertNull(aea.getValue()); - } - - public void testGetValueNull2() throws Exception { - this.createAnnotationAndMembers("Foo", "String bar();"); - this.createTestType(); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertNull(aea.getValue()); - } - - public void testGetValueNull3() throws Exception { - this.createAnnotationAndMembers("Baz", "String fred();"); - this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();"); - this.createAnnotationAndMembers("Foo", "annot.Bar value();"); - 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 daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa3, "fred"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertNull(aea.getValue()); - } - - public void testGetValueStringConcatenation() throws Exception { - this.createAnnotationAndMembers("Foo", "String bar();"); - this.createTestType("@annot.Foo(bar=\"xxx\" + \"yyy\" + \"zzz\")"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("xxxyyyzzz", aea.getValue()); - } - - public void testGetValueStringConstant() throws Exception { - this.createAnnotationAndMembers("Foo", "String bar();"); - // just a bit hacky: - this.createTestType("private static final String FOO_BAR = \"xxx\"; @annot.Foo(bar=FOO_BAR + \"yyy\" + \"zzz\")"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("xxxyyyzzz", aea.getValue()); - } - - public void testGetValueNumberArithmetic() throws Exception { - this.createAnnotationAndMembers("Foo", "int bar();"); - this.createTestType("@annot.Foo(bar=47 - 7 + 2 * 1 / 1)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forNumbers(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("42", aea.getValue()); - } - - public void testGetValueNumberShift() throws Exception { - this.createAnnotationAndMembers("Foo", "int bar();"); - this.createTestType("@annot.Foo(bar=2 << 2)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forNumbers(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("8", aea.getValue()); - } - - public void testGetValueNumberConstant() throws Exception { - this.createAnnotationAndMembers("Foo", "int bar();"); - // just a bit hacky: - this.createTestType("private static final int FOO_BAR = 77; @annot.Foo(bar=FOO_BAR)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forNumbers(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("77", aea.getValue()); - } - - public void testGetValueCharacterConstant() throws Exception { - this.createAnnotationAndMembers("Foo", "char bar();"); - // just a bit hacky: - this.createTestType("private static final char FOO_BAR = 'Q'; @annot.Foo(bar=FOO_BAR)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forCharacters(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("Q", aea.getValue()); - } - - public void testGetValueCharacterCast() throws Exception { - this.createAnnotationAndMembers("Foo", "char bar();"); - this.createTestType("@annot.Foo(bar=(char) 0x41)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forCharacters(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("A", aea.getValue()); - } - - public void testGetValueBooleanOperator1() throws Exception { - this.createAnnotationAndMembers("Foo", "boolean bar();"); - this.createTestType("@annot.Foo(bar=7 > 2)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forBooleans(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("true", aea.getValue()); - } - - public void testGetValueBooleanOperator2() throws Exception { - this.createAnnotationAndMembers("Foo", "boolean bar();"); - this.createTestType("@annot.Foo(bar=7 == 2)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forBooleans(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("false", aea.getValue()); - } - - public void testGetValueBooleanOperator3() throws Exception { - this.createAnnotationAndMembers("Foo", "boolean bar();"); - this.createTestType("@annot.Foo(bar=(7 != 2) && false)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forBooleans(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("false", aea.getValue()); - } - - public void testGetValueBooleanOperator4() throws Exception { - this.createAnnotationAndMembers("Foo", "boolean bar();"); - this.createTestType("@annot.Foo(bar=(7 != 2) ? false : true)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forBooleans(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("false", aea.getValue()); - } - - public void testGetValueInvalidValue1() throws Exception { - this.createAnnotationAndMembers("Foo", "String bar();"); - this.createTestType("@annot.Foo(bar=77)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertNull(aea.getValue()); - } - - public void testGetValueInvalidValue2() throws Exception { - this.createAnnotationAndMembers("Foo", "String bar();"); - this.createTestType("@annot.Foo(bar=bazzzz)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertNull(aea.getValue()); - } - - public void testGetValueInvalidValue3() throws Exception { - this.createAnnotationAndMembers("Foo", "boolean bar();"); - this.createTestType("@annot.Foo(bar=bazzzz)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forBooleans(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertNull(aea.getValue()); - } - - public void testGetValueInvalidValue4() throws Exception { - this.createAnnotationAndMembers("Foo", "char bar();"); - this.createTestType("@annot.Foo(bar=\"bazzzz\")"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forCharacters(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertNull(aea.getValue()); - } - - public void testGetValueInvalidValue5() throws Exception { - this.createAnnotationAndMembers("Foo", "Class bar();"); - this.createTestType("@annot.Foo(bar=\"java.lang.Object\")"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", SimpleTypeStringExpressionConverter.instance()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertNull(aea.getValue()); - } - - public void testGetValueInvalidValue6() throws Exception { - this.createEnum("TestEnum", "XXX, YYY, ZZZ"); - this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();"); - this.createTestType("@annot.Foo(bar=enums.TestEnum.class)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertNull(aea.getValue()); - } - - public void testGetValueInvalidValue7() 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 + ")))"; - 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 daea = new ConversionDeclarationAnnotationElementAdapter(daa3, "fred", BooleanStringExpressionConverter.instance()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertNull(aea.getValue()); - } - - public void testGetValueInvalidValue8() throws Exception { - this.createAnnotationAndMembers("Foo", "String[] bar();"); - this.createTestType("@annot.Foo(bar={true, false})"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertTrue(Arrays.equals(new String[] {null, null}, aea.getValue())); - } - - public void testGetValueInvalidValue9() throws Exception { - this.createAnnotationAndMembers("Foo", "String[] bar();"); - this.createTestType("@annot.Foo(bar=77)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertTrue(Arrays.equals(new String[] {null}, aea.getValue())); - } - - public void testASTNode1() throws Exception { - this.createAnnotationAndMembers("Foo", "String bar();"); - String value = "\"xxx\""; - String element = "bar=" + value; - String annotation = "@annot.Foo(" + element + ")"; - this.createTestType(annotation); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - - ITextRange textRange = new ASTNodeTextRange(aea.astNode()); - assertEquals(this.source().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 + ")))"; - 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 daea = new ConversionDeclarationAnnotationElementAdapter(daa3, "fred", BooleanStringExpressionConverter.instance()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("false", aea.getValue()); - ITextRange textRange = new ASTNodeTextRange(aea.astNode()); - assertEquals(value.length(), textRange.getLength()); - } - - public void testASTNode3() throws Exception { - this.createAnnotationAndMembers("Foo", "String value();"); - String element = "\"xxx\""; - String annotation = "@annot.Foo(" + element + ")"; - this.createTestType(annotation); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - - ITextRange textRange = new ASTNodeTextRange(aea.astNode()); - assertEquals(this.source().indexOf(element), textRange.getOffset()); - assertEquals(element.length(), textRange.getLength()); - } - - public void testASTNode4() throws Exception { - this.createAnnotationAndMembers("Foo", "String value();"); - String annotation = "@annot.Foo"; - this.createTestType(annotation); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - - ITextRange textRange = new ASTNodeTextRange(aea.astNode()); - assertEquals(this.source().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\")"; - this.createTestType(annotation); - this.assertSourceContains(annotation); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - - aea.setValue(null); - this.assertSourceDoesNotContain("Foo"); - } - - public void testSetValue2() throws Exception { - this.createAnnotationAndMembers("Foo", "String bar();"); - String annotation = "@annot.Foo(bar=\"xxx\")"; - this.createTestType(annotation); - this.assertSourceContains(annotation); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar", false); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - - aea.setValue(null); - this.assertSourceDoesNotContain(annotation); - this.assertSourceContains("@Foo"); - } - - 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)))"; - this.createTestType(annotation); - this.assertSourceContains(annotation); - DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar"); - DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa3, "fred", BooleanStringExpressionConverter.instance()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - - aea.setValue(null); - this.assertSourceDoesNotContain(annotation); - this.assertSourceDoesNotContain("Foo"); - this.assertSourceDoesNotContain("Bar"); - } - - 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)))"; - this.createTestType(annotation); - this.assertSourceContains(annotation); - DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar", false); - DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz", false); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa3, "fred", BooleanStringExpressionConverter.instance()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - - aea.setValue(null); - this.assertSourceDoesNotContain(annotation); - this.assertSourceContains("@annot.Foo(@Bar)"); - } - - public void testSetValue4() throws Exception { - this.createAnnotationAndMembers("Foo", "String bar();"); - this.createTestType(); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - - aea.setValue("xxx"); - this.assertSourceContains("@Foo(bar=\"xxx\")"); - } - - 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)))"; - this.createTestType(annotation); - this.assertSourceContains(annotation); - DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar"); - DeclarationAnnotationAdapter daa3 = new NestedDeclarationAnnotationAdapter(daa2, "jimmy", "annot.Baz"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa3, "fred", BooleanStringExpressionConverter.instance()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - - aea.setValue("true"); - this.assertSourceDoesNotContain(annotation); - this.assertSourceContains("@annot.Foo(@annot.Bar(jimmy=@annot.Baz(fred=true)))"); - } - - public void testSetValue6() throws Exception { - this.createAnnotationAndMembers("Baz", "boolean fred();"); - this.createAnnotationAndMembers("Bar", "annot.Baz jimmy();"); - this.createAnnotationAndMembers("Foo", "annot.Bar value();"); - 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 daea = new ConversionDeclarationAnnotationElementAdapter(daa3, "fred", BooleanStringExpressionConverter.instance()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - - aea.setValue("true"); - this.assertSourceContains("@Foo(@Bar(jimmy=@Baz(fred=true)))"); - } - - public void testSetValue7() throws Exception { - this.createAnnotationAndMembers("Foo", "String bar();"); - String annotation = "@annot.Foo(bar=\"xxx\")"; - this.createTestType(annotation); - this.assertSourceContains(annotation); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - - aea.setValue("yyy"); - this.assertSourceDoesNotContain(annotation); - this.assertSourceContains("@annot.Foo(bar=\"yyy\")"); - } - - public void testSetValue8() throws Exception { - this.createAnnotationAndMembers("Foo", "String bar();"); - String annotation = "@annot.Foo"; - this.createTestType(annotation); - this.assertSourceContains(annotation); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - - aea.setValue("xxx"); - this.assertSourceContains("@Foo(bar=\"xxx\")"); - } - - public void testSetValue9() throws Exception { - this.createAnnotationAndMembers("Foo", "String value(); String bar();"); - String annotation = "@annot.Foo(\"zzz\")"; - this.createTestType(annotation); - this.assertSourceContains(annotation); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - - aea.setValue("xxx"); - this.assertSourceDoesNotContain(annotation); - this.assertSourceContains("@Foo(value=\"zzz\", bar=\"xxx\")"); - } - - public void testSetValue10() throws Exception { - this.createAnnotationAndMembers("Foo", "String bar(); String baz();"); - String annotation = "@annot.Foo(bar=\"xxx\")"; - this.createTestType(annotation); - this.assertSourceContains(annotation); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "baz"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - - aea.setValue("yyy"); - this.assertSourceDoesNotContain(annotation); - this.assertSourceContains("@annot.Foo(bar=\"xxx\", baz = \"yyy\")"); - } - - 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)}))"; - this.createTestType(annotation); - this.assertSourceContains(annotation); - DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationAdapter daa2 = new NestedDeclarationAnnotationAdapter(daa1, "value", "annot.Bar"); - DeclarationAnnotationAdapter daa3 = new NestedIndexedDeclarationAnnotationAdapter(daa2, "jimmy", 2, "annot.Baz"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa3, "fred", NumberStringExpressionConverter.instance()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - - assertEquals("2", aea.getValue()); - aea.setValue("48"); - this.assertSourceContains("@annot.Foo(@annot.Bar(jimmy={@annot.Baz(fred=0), @annot.Baz(fred=1), @annot.Baz(fred=48), @annot.Baz(fred=3)}))"); - } - - public void testSetValue12() throws Exception { - this.createAnnotationAndMembers("Foo", "String value();"); - String annotation = "@annot.Foo"; - this.createTestType(annotation); - this.assertSourceContains(annotation); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "value"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - - aea.setValue("xxx"); - this.assertSourceContains("@Foo(\"xxx\")"); - } - - public void testSetValue13() throws Exception { - this.createAnnotationAndMembers("Foo", "String value();"); - String annotation = "@annot.Foo(\"zzz\")"; - this.createTestType(annotation); - this.assertSourceContains(annotation); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "value"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - - aea.setValue("xxx"); - this.assertSourceDoesNotContain(annotation); - this.assertSourceContains("@annot.Foo(\"xxx\")"); - } - - public void testSimpleTypeLiteral1() throws Exception { - this.createAnnotationAndMembers("Foo", "Class bar();"); - this.createTestType("@annot.Foo(bar=java.lang.Object.class)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", SimpleTypeStringExpressionConverter.instance()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("java.lang.Object", aea.getValue()); - } - - public void testSimpleTypeLiteral2() throws Exception { - this.createAnnotationAndMembers("Foo", "Class bar();"); - this.createTestType(); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", SimpleTypeStringExpressionConverter.instance()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - aea.setValue("java.lang.Object"); - this.assertSourceContains("@Foo(bar=java.lang.Object.class)"); - } - - public void testSimpleTypeLiteral3() throws Exception { - this.createAnnotationAndMembers("Foo", "Class bar();"); - this.createTestType("@annot.Foo(bar=int.class)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", SimpleTypeStringExpressionConverter.instance()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertNull(aea.getValue()); - } - - public void testSimpleTypeLiteral4() throws Exception { - this.createAnnotationAndMembers("Foo", "Class bar();"); - this.createTestType("@annot.Foo(bar=java.util.Map.Entry.class)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", SimpleTypeStringExpressionConverter.instance()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("java.util.Map.Entry", aea.getValue()); - } - - public void testPrimitiveTypeLiteral1() throws Exception { - this.createAnnotationAndMembers("Foo", "Class bar();"); - this.createTestType("@annot.Foo(bar=int.class)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", PrimitiveTypeStringExpressionConverter.instance()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("int", aea.getValue()); - } - - public void testPrimitiveTypeLiteral2() throws Exception { - this.createAnnotationAndMembers("Foo", "Class bar();"); - this.createTestType(); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", PrimitiveTypeStringExpressionConverter.instance()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - aea.setValue("int"); - this.assertSourceContains("@Foo(bar=int.class)"); - } - - public void testPrimitiveTypeLiteral3() throws Exception { - this.createAnnotationAndMembers("Foo", "Class bar();"); - this.createTestType("@annot.Foo(bar=java.lang.Object.class)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", PrimitiveTypeStringExpressionConverter.instance()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertNull(aea.getValue()); - } - - public void testPrimitiveTypeLiteral4() throws Exception { - this.createAnnotationAndMembers("Foo", "Class bar();"); - this.createTestType("@annot.Foo(bar=void.class)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", PrimitiveTypeStringExpressionConverter.instance()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("void", aea.getValue()); - } - - public void testGetValueEnum1() throws Exception { - this.createEnum("TestEnum", "XXX, YYY, ZZZ"); - this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();"); - this.createTestType("@annot.Foo(bar=enums.TestEnum.XXX)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("enums.TestEnum.XXX", aea.getValue()); - } - - public void testGetValueEnum2() throws Exception { - this.createEnum("TestEnum", "XXX, YYY, ZZZ"); - this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();"); - this.createTestType("static enums.TestEnum.XXX", "@annot.Foo(bar=XXX)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertEquals("enums.TestEnum.XXX", aea.getValue()); - } - - public void testGetValueEnum3() throws Exception { - this.createEnum("TestEnum", "XXX, YYY, ZZZ"); - this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();"); - this.createTestType("@annot.Foo"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertNull(aea.getValue()); - } - - public void testGetValueEnum4() throws Exception { - this.createEnum("TestEnum", "XXX, YYY, ZZZ"); - this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();"); - this.createTestType("enums.TestEnum", "@annot.Foo(bar=TestEnum.XXX)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), 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 annotation = "@annot.Foo(bar=XXX)"; - this.createTestType("static enums.TestEnum.XXX", annotation); - this.assertSourceContains(annotation); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - aea.setValue(null); - this.assertSourceDoesNotContain("Foo"); - } - - public void testSetValueEnum2() throws Exception { - this.createEnum("TestEnum", "XXX, YYY, ZZZ"); - this.createAnnotationAndMembers("Foo", "enums.TestEnum bar();"); - String annotation = "@Foo(bar=XXX)"; - this.createTestType(); - this.assertSourceDoesNotContain(annotation); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new EnumDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - aea.setValue("enums.TestEnum.XXX"); - this.assertSourceContains("import static enums.TestEnum.XXX;"); - this.assertSourceContains(annotation); - } - - public void testGetValueStringArray() throws Exception { - this.createAnnotationAndMembers("Foo", "String[] bar();"); - this.createTestType("@annot.Foo(bar={\"string0\", \"string1\"})"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertTrue(Arrays.equals(new String[] {"string0", "string1"}, aea.getValue())); - } - - public void testGetValueStringArrayConcatenation() throws Exception { - this.createAnnotationAndMembers("Foo", "String[] bar();"); - this.createTestType("@annot.Foo(bar={\"stri\" + \"ng0\", \"s\" + \"tring1\"})"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertTrue(Arrays.equals(new String[] {"string0", "string1"}, aea.getValue())); - } - - public void testGetValueStringArrayEmpty() throws Exception { - this.createAnnotationAndMembers("Foo", "String[] bar();"); - this.createTestType("@annot.Foo(bar={})"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertTrue(Arrays.equals(new String[0], aea.getValue())); - } - - public void testGetValueStringArraySingleElement() throws Exception { - this.createAnnotationAndMembers("Foo", "String[] bar();"); - this.createTestType("@annot.Foo(bar=\"string0\")"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertTrue(Arrays.equals(new String[] {"string0"}, aea.getValue())); - } - - public void testGetValueNullStringArray() throws Exception { - this.createAnnotationAndMembers("Foo", "String[] bar();"); - this.createTestType("@annot.Foo()"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertTrue(Arrays.equals(new String[0], aea.getValue())); - } - - public void testSetValueStringArray() throws Exception { - this.createAnnotationAndMembers("Foo", "String[] bar();"); - String annotation = "@Foo(bar={\"string0\",\"string1\"})"; - this.createTestType(); - this.assertSourceDoesNotContain(annotation); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - aea.setValue(new String[] {"string0", "string1"}); - this.assertSourceContains(annotation); - } - - public void testSetValueStringArrayEmptyRemove() throws Exception { - this.createAnnotationAndMembers("Foo", "String[] bar();"); - String annotation = "@Foo"; - this.createTestType(); - this.assertSourceDoesNotContain(annotation); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - aea.setValue(new String[0]); - this.assertSourceDoesNotContain(annotation); - } - - public void testSetValueStringArrayEmpty() throws Exception { - this.createAnnotationAndMembers("Foo", "String[] bar();"); - String annotation = "@Foo(bar={})"; - this.createTestType(); - this.assertSourceDoesNotContain(annotation); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - ExpressionConverter expressionConverter = new AnnotationStringArrayExpressionConverter(StringExpressionConverter.instance(), false); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", expressionConverter); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - aea.setValue(new String[0]); - this.assertSourceContains(annotation); - } - - public void testSetValueStringArraySingleElement() throws Exception { - this.createAnnotationAndMembers("Foo", "String[] bar();"); - String annotation = "@Foo(bar=\"string0\")"; - this.createTestType(); - this.assertSourceDoesNotContain(annotation); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - aea.setValue(new String[] {"string0"}); - this.assertSourceContains(annotation); - } - - public void testGetValueEnumArray() throws Exception { - this.createEnum("TestEnum", "XXX, YYY, ZZZ"); - this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();"); - this.createTestType("@annot.Foo(bar={enums.TestEnum.XXX, enums.TestEnum.YYY})"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertTrue(Arrays.equals(new String[] {"enums.TestEnum.XXX", "enums.TestEnum.YYY"}, aea.getValue())); - } - - public void testGetValueEnumArrayInvalidEntry() throws Exception { - this.createEnum("TestEnum", "XXX, YYY, ZZZ"); - this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();"); - this.createTestType("@annot.Foo(bar={enums.TestEnum.XXX, 88})"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertTrue(Arrays.equals(new String[] {"enums.TestEnum.XXX", null}, aea.getValue())); - } - - public void testGetValueEnumArrayEmpty() throws Exception { - this.createEnum("TestEnum", "XXX, YYY, ZZZ"); - this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();"); - this.createTestType("@annot.Foo(bar={})"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertTrue(Arrays.equals(new String[0], aea.getValue())); - } - - public void testGetValueEnumArraySingleElement() throws Exception { - this.createEnum("TestEnum", "XXX, YYY, ZZZ"); - this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();"); - this.createTestType("@annot.Foo(bar=enums.TestEnum.XXX)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertTrue(Arrays.equals(new String[] {"enums.TestEnum.XXX"}, aea.getValue())); - } - - public void testGetValueEnumArraySingleElementInvalid() throws Exception { - this.createEnum("TestEnum", "XXX, YYY, ZZZ"); - this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();"); - this.createTestType("@annot.Foo(bar=\"\")"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertTrue(Arrays.equals(new String[] {null}, aea.getValue())); - } - - public void testGetValueNullEnumArray() throws Exception { - this.createEnum("TestEnum", "XXX, YYY, ZZZ"); - this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();"); - this.createTestType("@annot.Foo()"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), 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 annotation = "@Foo(bar={XXX,YYY})"; - this.createTestType(); - this.assertSourceDoesNotContain(annotation); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - aea.setValue(new String[] {"enums.TestEnum.XXX", "enums.TestEnum.YYY"}); - this.assertSourceContains("import static enums.TestEnum.XXX;"); - this.assertSourceContains("import static enums.TestEnum.YYY;"); - this.assertSourceContains(annotation); - } - - public void testSetValueEnumArrayEmptyRemove() throws Exception { - this.createEnum("TestEnum", "XXX, YYY, ZZZ"); - this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();"); - String annotation = "@Foo"; - this.createTestType(); - this.assertSourceDoesNotContain(annotation); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - aea.setValue(new String[0]); - this.assertSourceDoesNotContain(annotation); - } - - public void testSetValueEnumArrayEmpty() throws Exception { - this.createEnum("TestEnum", "XXX, YYY, ZZZ"); - this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();"); - String annotation = "@Foo(bar={})"; - this.createTestType(); - this.assertSourceDoesNotContain(annotation); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar", true, false); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - aea.setValue(new String[0]); - this.assertSourceContains(annotation); - } - - public void testSetValueEnumArraySingleElement() throws Exception { - this.createEnum("TestEnum", "XXX, YYY, ZZZ"); - this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();"); - String annotation = "@Foo(bar=XXX)"; - this.createTestType(); - this.assertSourceDoesNotContain(annotation); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar"); - AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - aea.setValue(new String[] {"enums.TestEnum.XXX"}); - this.assertSourceContains("import static enums.TestEnum.XXX;"); - this.assertSourceContains(annotation); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/NestedDeclarationAnnotationAdapterTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/NestedDeclarationAnnotationAdapterTests.java deleted file mode 100644 index e82d42c7c4..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/NestedDeclarationAnnotationAdapterTests.java +++ /dev/null @@ -1,763 +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 - ******************************************************************************/ -package org.eclipse.jpt.core.tests.internal.jdtutility; - -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.core.internal.jdtutility.AnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.Member; -import org.eclipse.jpt.core.internal.jdtutility.MemberAnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.ModifiedDeclaration; -import org.eclipse.jpt.core.internal.jdtutility.NestedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.SimpleDeclarationAnnotationAdapter; - -public class NestedDeclarationAnnotationAdapterTests extends AnnotationTestCase { - - public NestedDeclarationAnnotationAdapterTests(String name) { - super(name); - } - - private void createAnnotationAndMembers(String annotationName, String annotationBody) throws Exception { - this.javaProject.createType("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }"); - } - - public void testGetAnnotation1() throws Exception { - this.createAnnotationAndMembers("Bar", "String value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();"); - this.createTestType("@annot.Foo(nestedAnnotation=@annot.Bar)"); - - DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - assertEquals("annot.Bar", annotation.getTypeName().getFullyQualifiedName()); - assertTrue(annotation.isMarkerAnnotation()); - } - - public void testGetAnnotation2() throws Exception { - this.createAnnotationAndMembers("Baz", "String value();"); - this.createAnnotationAndMembers("Bar", "annot.Baz yana();"); - this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();"); - 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 MemberAnnotationAdapter(this.idField(), daa3); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - assertEquals("annot.Baz", annotation.getTypeName().getFullyQualifiedName()); - assertTrue(annotation.isMarkerAnnotation()); - } - - public void testGetAnnotationNull1() throws Exception { - this.createAnnotationAndMembers("Bar", "String value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();"); - this.createTestType("@annot.Foo()"); - - DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - } - - public void testGetAnnotationNull2() throws Exception { - this.createAnnotationAndMembers("Bar", "String value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();"); - this.createTestType(); - - DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - } - - public void testGetAnnotationNull3() throws Exception { - this.createAnnotationAndMembers("Bar", "String value();"); - this.createAnnotationAndMembers("Foo", "String nestedAnnotation();"); - this.createTestType("@annot.Foo(nestedAnnotation=\"annot.Bar\")"); - - DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - } - - public void testGetAnnotationNull4() throws Exception { - this.createAnnotationAndMembers("Bar", "String value();"); - this.createAnnotationAndMembers("Bar2", "String value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar2 nestedAnnotation();"); - this.createTestType("@annot.Foo(nestedAnnotation=@annot.Bar2)"); - - DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - 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)"; - this.createTestType(na); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - - aa.removeAnnotation(); - this.assertSourceDoesNotContain(na); - this.assertSourceDoesNotContain("Foo"); - } - - public void testRemoveAnnotation1a() throws Exception { - this.createAnnotationAndMembers("Bar", "String value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();"); - String na = "@annot.Foo(nestedAnnotation=@annot.Bar)"; - this.createTestType(na); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar", false); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - - aa.removeAnnotation(); - this.assertSourceDoesNotContain(na); - this.assertSourceContains("Foo"); - } - - public void testRemoveAnnotation2() throws Exception { - this.createAnnotationAndMembers("Bar", "String value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();"); - this.createTestType(); - this.assertSourceDoesNotContain("Foo"); - - DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.removeAnnotation(); - this.assertSourceDoesNotContain("Foo"); - } - - public void testRemoveAnnotation3() throws Exception { - this.createAnnotationAndMembers("Bar", "String value();"); - this.createAnnotationAndMembers("Foo", "String nestedAnnotation();"); - String na = "@annot.Foo(nestedAnnotation=\"annot.Bar\")"; - this.createTestType(na); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.removeAnnotation(); - this.assertSourceContains(na); - } - - 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)"; - this.createTestType(na); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.removeAnnotation(); - this.assertSourceContains(na); - } - - 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))"; - this.createTestType(na); - this.assertSourceContains(na); - - 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 MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - - aa.removeAnnotation(); - this.assertSourceDoesNotContain(na); - this.assertSourceDoesNotContain("Foo"); - this.assertSourceDoesNotContain("Bar"); - this.assertSourceDoesNotContain("Baz"); - } - - 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))"; - this.createTestType(na); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daaFoo = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationAdapter daaBar = new NestedDeclarationAnnotationAdapter(daaFoo, "nestedAnnotation1", "annot.Bar", false); - DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter(daaBar, "nestedAnnotation2", "annot.Baz", false); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - - aa.removeAnnotation(); - this.assertSourceDoesNotContain(na); - this.assertSourceContains("@annot.Foo(nestedAnnotation1=@Bar)"); - } - - public void testNewMarkerAnnotation1() throws Exception { - this.createAnnotationAndMembers("Bar", "String value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();"); - this.createTestType(); - this.assertSourceDoesNotContain("Foo"); - - DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains("@Foo(nestedAnnotation=@Bar)"); - } - - public void testNewMarkerAnnotation2() throws Exception { - this.createAnnotationAndMembers("Bar", "String value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar value();"); - this.createTestType(); - this.assertSourceDoesNotContain("Foo"); - - DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains("@Foo(@Bar)"); - } - - public void testNewMarkerAnnotation3() throws Exception { - this.createAnnotationAndMembers("Bar", "String value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();"); - this.createTestType("@annot.Foo"); - String expected = "@Foo(nestedAnnotation=@Bar)"; - this.assertSourceDoesNotContain(expected); - - DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains(expected); - } - - public void testNewMarkerAnnotation4() throws Exception { - this.createAnnotationAndMembers("Bar", "String value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar value();"); - this.createTestType("@annot.Foo"); - String expected = "@Foo(@Bar)"; - this.assertSourceDoesNotContain(expected); - - DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains(expected); - } - - public void testNewMarkerAnnotation5() throws Exception { - this.createAnnotationAndMembers("Bar", "String value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation(); String value();"); - this.createTestType("@annot.Foo(\"something\")"); - String expected = "@Foo(value=\"something\", nestedAnnotation=@Bar)"; - this.assertSourceDoesNotContain(expected); - - DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains(expected); - } - - public void testNewMarkerAnnotation6() throws Exception { - this.createAnnotationAndMembers("Bar", "String value();"); - this.createAnnotationAndMembers("Foo", "Object value();"); - this.createTestType("@annot.Foo(\"something\")"); - String expected = "@annot.Foo(@Bar)"; - this.assertSourceDoesNotContain(expected); - - DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains(expected); - } - - public void testNewMarkerAnnotation7() throws Exception { - this.createAnnotationAndMembers("Bar", "String value();"); - this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar nestedAnnotation();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); - String expected = "@annot.Foo(xxx=\"something\", nestedAnnotation = @Bar)"; - this.assertSourceDoesNotContain(expected); - - DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotation", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains(expected); - } - - public void testNewMarkerAnnotation8() throws Exception { - this.createAnnotationAndMembers("Bar", "String value();"); - this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar value();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); - String expected = "@annot.Foo(xxx=\"something\", value = @Bar)"; - this.assertSourceDoesNotContain(expected); - - DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains(expected); - } - - public void testNewSingleMemberAnnotation1() throws Exception { - this.createAnnotationAndMembers("Bar", "String value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar nestedAnnotation();"); - this.createTestType(); - this.assertSourceDoesNotContain("Foo"); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation1(declaration); - } - }); - this.assertSourceContains("@Foo(nestedAnnotation=@Bar(\"test string literal\"))"); - } - - 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();"); - this.createTestType(); - this.assertSourceDoesNotContain("Foo"); - - DeclarationAnnotationAdapter daa = new NestedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - SingleMemberAnnotation annotation = (SingleMemberAnnotation) aa.getAnnotation(); - assertNull(annotation); - - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation2(declaration); - } - }); - this.assertSourceContains("@Foo(@Bar(\"test string literal\"))"); - } - - 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();"); - this.createTestType("@annot.Foo"); - String expected = "@Foo(nestedAnnotation=@Bar(\"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation3(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo"); - String expected = "@Foo(@Bar(\"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation4(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(\"something\")"); - String expected = "@Foo(value=\"something\", nestedAnnotation=@Bar(\"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation5(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(\"something\")"); - String expected = "@annot.Foo(@Bar(\"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation6(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); - String expected = "@annot.Foo(xxx=\"something\", nestedAnnotation = @Bar(\"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation7(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); - String expected = "@annot.Foo(xxx=\"something\", value = @Bar(\"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation8(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType(); - this.assertSourceDoesNotContain("Foo"); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation1(declaration); - } - }); - this.assertSourceContains("@Foo(nestedAnnotation=@Bar(yyy=\"test string literal\"))"); - } - - 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();"); - this.createTestType(); - this.assertSourceDoesNotContain("Foo"); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation2(declaration); - } - }); - this.assertSourceContains("@Foo(@Bar(yyy=\"test string literal\"))"); - } - - 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();"); - this.createTestType("@annot.Foo"); - String expected = "@Foo(nestedAnnotation=@Bar(yyy=\"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation3(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo"); - String expected = "@Foo(@Bar(yyy=\"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation4(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(\"something\")"); - String expected = "@Foo(value=\"something\", nestedAnnotation=@Bar(yyy=\"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation5(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(\"something\")"); - String expected = "@annot.Foo(@Bar(yyy=\"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation6(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); - String expected = "@annot.Foo(xxx=\"something\", nestedAnnotation = @Bar(yyy = \"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation7(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); - String expected = "@annot.Foo(xxx=\"something\", value = @Bar(yyy = \"test string literal\"))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation8(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/NestedIndexedDeclarationAnnotationAdapterTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/NestedIndexedDeclarationAnnotationAdapterTests.java deleted file mode 100644 index e361b43ff7..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/NestedIndexedDeclarationAnnotationAdapterTests.java +++ /dev/null @@ -1,2209 +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 - ******************************************************************************/ -package org.eclipse.jpt.core.tests.internal.jdtutility; - -import org.eclipse.jdt.core.dom.ASTNode; -import org.eclipse.jdt.core.dom.Annotation; -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.core.internal.jdtutility.AnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.IndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.IndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.Member; -import org.eclipse.jpt.core.internal.jdtutility.MemberAnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.MemberIndexedAnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.ModifiedDeclaration; -import org.eclipse.jpt.core.internal.jdtutility.NestedIndexedDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.SimpleDeclarationAnnotationAdapter; - -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.createType("annot", annotationName + ".java", "public @interface " + annotationName + " { " + annotationBody + " }"); - } - - public void testGetAnnotation1() throws Exception { - this.createAnnotationAndMembers("Bar", "String value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - 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 MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - 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 MemberAnnotationAdapter(this.idField(), daa); - annotation = aa.getAnnotation(); - assertNotNull(annotation); - assertEquals("annot.Bar", annotation.getTypeName().getFullyQualifiedName()); - assertTrue(annotation.isSingleMemberAnnotation()); - } - - public void testGetAnnotation2() throws Exception { - this.createAnnotation("Baz"); - this.createAnnotationAndMembers("Bar", "annot.Baz[] yana();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - 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 MemberAnnotationAdapter(this.idField(), daa3); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - assertEquals("annot.Baz", annotation.getTypeName().getFullyQualifiedName()); - assertTrue(annotation.isMarkerAnnotation()); - } - - public void testGetAnnotation3() throws Exception { - this.createAnnotation("Baz"); - this.createAnnotationAndMembers("Bar", "annot.Baz[] yana();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - 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 MemberAnnotationAdapter(this.idField(), daa3); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - assertEquals("annot.Baz", annotation.getTypeName().getFullyQualifiedName()); - assertTrue(annotation.isMarkerAnnotation()); - - // name mismatch - daa3 = new NestedIndexedDeclarationAnnotationAdapter(daa2, "yana", 0, "annot.Xyz"); - aa = new MemberAnnotationAdapter(this.idField(), daa3); - annotation = aa.getAnnotation(); - assertNull(annotation); - } - - public void testGetAnnotationNull1() throws Exception { - this.createAnnotation("Bar"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo()"); - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - } - - public void testGetAnnotationNull2() throws Exception { - this.createAnnotation("Bar"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType(); - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - } - - public void testGetAnnotationNull3() throws Exception { - this.createAnnotation("Bar"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=\"annot.Bar\")"); - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - } - - public void testGetAnnotationNull4() throws Exception { - this.createAnnotation("NotBar"); - this.createAnnotation("Bar"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)"); - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - } - - public void testGetAnnotationNull5() throws Exception { - this.createAnnotationAndMembers("Bar", "String value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - 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 MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - } - - public void testGetAnnotationNull6() throws Exception { - this.createAnnotation("Xyz"); - this.createAnnotation("Baz"); - this.createAnnotationAndMembers("Bar", "annot.Baz[] yana();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - 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 MemberAnnotationAdapter(this.idField(), daa3); - Annotation annotation = aa.getAnnotation(); - 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)})"; - this.createTestType(na); - this.assertSourceDoesNotContain(expected); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - - aa.removeAnnotation(); - this.assertSourceDoesNotContain(na); - this.assertSourceContains(expected); - } - - public void testRemoveAnnotation2() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType(); - this.assertSourceDoesNotContain("Foo"); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.removeAnnotation(); - this.assertSourceDoesNotContain("Foo"); - } - - 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\"})"; - this.createTestType(na); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.removeAnnotation(); - this.assertSourceContains(na); - } - - 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)})"; - this.createTestType(na); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.removeAnnotation(); - this.assertSourceContains(na); - } - - public void testRemoveAnnotation5() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - String na = "@annot.Foo(nestedAnnotations=@annot.Bar)"; - this.createTestType(na); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - - aa.removeAnnotation(); - assertNull(aa.getAnnotation()); - this.assertSourceDoesNotContain(na); - this.assertSourceDoesNotContain("Foo"); - } - - public void testRemoveAnnotation5a() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - String na = "@annot.Foo(nestedAnnotations=@annot.Bar)"; - this.createTestType(na); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); - DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 0, "annot.Bar", false); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(); - assertNotNull(annotation); - - aa2.removeAnnotation(); - assertTrue(aa1.getAnnotation().isMarkerAnnotation()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains("import annot.Foo;"); - this.assertSourceContains("@Foo"); - } - - public void testRemoveAnnotation6() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "String[] nestedAnnotations();"); - String na = "@annot.Foo(nestedAnnotations=\"annot.Bar\")"; - this.createTestType(na); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.removeAnnotation(); - this.assertSourceContains(na); - } - - 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)"; - this.createTestType(na); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.removeAnnotation(); - this.assertSourceContains(na); - } - - 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)})"; - this.createTestType(na); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); - DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 2, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(); - assertNotNull(annotation); - - aa2.removeAnnotation(); - assertTrue(aa1.getAnnotation().isNormalAnnotation()); - assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(), "nestedAnnotations").getNodeType()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains("@annot.Foo(nestedAnnotations={@annot.Bar(0), @annot.Bar(1), null, @annot.Bar(3)})"); - } - - 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)})"; - this.createTestType(na); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); - DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 2, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(); - assertNotNull(annotation); - - aa2.removeAnnotation(); - assertTrue(aa1.getAnnotation().isSingleMemberAnnotation()); - assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(), "value").getNodeType()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains("@annot.Foo({@annot.Bar(0), @annot.Bar(1), null, @annot.Bar(3)})"); - } - - 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)})"; - this.createTestType(na); - this.assertSourceDoesNotContain(expected); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 0, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(); - assertNotNull(annotation); - - aa2.removeAnnotation(); - this.assertSourceDoesNotContain(na); - this.assertSourceContains(expected); - } - - 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))"; - this.createTestType(na); - this.assertSourceDoesNotContain(expected); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); - DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 1, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(); - assertNotNull(annotation); - - aa2.removeAnnotation(); - assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(), "value").getNodeType()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains(expected); - } - - 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))"; - this.createTestType(na); - this.assertSourceDoesNotContain(expected); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); - DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 2, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(); - assertNotNull(annotation); - - aa2.removeAnnotation(); - assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(), "value").getNodeType()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains(expected); - } - - public void testRemoveAnnotation13() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - String na = "@annot.Foo({null, @annot.Bar(1)})"; - this.createTestType(na); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 1, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(); - assertNotNull(annotation); - - aa2.removeAnnotation(); - this.assertSourceDoesNotContain("Foo"); - } - - 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))"; - this.createTestType(na); - this.assertSourceDoesNotContain(expected); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); - DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 2, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(); - assertNotNull(annotation); - - aa2.removeAnnotation(); - assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(), "value").getNodeType()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains(expected); - } - - 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)})"; - this.createTestType(na); - this.assertSourceDoesNotContain(expected); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); - DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 2, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(); - assertNotNull(annotation); - - aa2.removeAnnotation(); - assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(), "value").getNodeType()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains(expected); - } - - 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)})"; - this.createTestType(na); - this.assertSourceDoesNotContain(expected); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); - DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "value", 3, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(); - assertNotNull(annotation); - - aa2.removeAnnotation(); - assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(), "value").getNodeType()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains(expected); - } - - 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))"; - this.createTestType(na); - this.assertSourceDoesNotContain(expected); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); - DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 2, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(); - assertNotNull(annotation); - - aa2.removeAnnotation(); - assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(), "nestedAnnotations").getNodeType()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains(expected); - } - - 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)})"; - this.createTestType(na); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 1, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(); - assertNotNull(annotation); - - aa2.removeAnnotation(); - this.assertSourceDoesNotContain("Foo"); - } - - 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))"; - this.createTestType(na); - this.assertSourceDoesNotContain(expected); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); - DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 2, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(); - assertNotNull(annotation); - - aa2.removeAnnotation(); - assertEquals(ASTNode.SINGLE_MEMBER_ANNOTATION, this.annotationElementValue(aa1.getAnnotation(), "nestedAnnotations").getNodeType()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains(expected); - } - - 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)})"; - this.createTestType(na); - this.assertSourceDoesNotContain(expected); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); - DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 2, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(); - assertNotNull(annotation); - - aa2.removeAnnotation(); - assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(), "nestedAnnotations").getNodeType()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains(expected); - } - - 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)})"; - this.createTestType(na); - this.assertSourceDoesNotContain(expected); - this.assertSourceContains(na); - - DeclarationAnnotationAdapter daa1 = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa1 = new MemberAnnotationAdapter(this.idField(), daa1); - DeclarationAnnotationAdapter daa2 = new NestedIndexedDeclarationAnnotationAdapter(daa1, "nestedAnnotations", 3, "annot.Bar"); - AnnotationAdapter aa2 = new MemberAnnotationAdapter(this.idField(), daa2); - Annotation annotation = aa2.getAnnotation(); - assertNotNull(annotation); - - aa2.removeAnnotation(); - assertEquals(ASTNode.ARRAY_INITIALIZER, this.annotationElementValue(aa1.getAnnotation(), "nestedAnnotations").getNodeType()); - this.assertSourceDoesNotContain(na); - this.assertSourceContains(expected); - } - - public void testNewMarkerAnnotation1() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType(); - this.assertSourceDoesNotContain("Foo"); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains("@Foo(nestedAnnotations=@Bar)"); - } - - public void testNewMarkerAnnotation2() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType(); - this.assertSourceDoesNotContain("Foo"); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains("@Foo(@Bar)"); - } - - public void testNewMarkerAnnotation3() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo"); - String expected = "@Foo(nestedAnnotations=@Bar)"; - this.assertSourceDoesNotContain(expected); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains(expected); - } - - public void testNewMarkerAnnotation4() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo"); - String expected = "@Foo(@Bar)"; - this.assertSourceDoesNotContain(expected); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains(expected); - } - - public void testNewMarkerAnnotation5() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "String value(); annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(\"something\")"); - String expected = "@Foo(value=\"something\", nestedAnnotations=@Bar)"; - this.assertSourceDoesNotContain(expected); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains(expected); - } - - public void testNewMarkerAnnotation6() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo(\"something\")"); - String expected = "@annot.Foo(@Bar)"; - this.assertSourceDoesNotContain(expected); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains(expected); - } - - public void testNewMarkerAnnotation7() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); - String expected = "@annot.Foo(xxx=\"something\", nestedAnnotations = @Bar)"; - this.assertSourceDoesNotContain(expected); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains(expected); - } - - public void testNewMarkerAnnotation8() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "String xxx(); annot.Bar[] value();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); - String expected = "@annot.Foo(xxx=\"something\", value = @Bar)"; - this.assertSourceDoesNotContain(expected); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains(expected); - } - - public void testNewMarkerAnnotation9() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType(); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - assertNull(aa.getAnnotation()); - - aa.newMarkerAnnotation(); - this.assertSourceContains("@Foo(nestedAnnotations={null,null,null,null,null,@Bar})"); - } - - public void testNewMarkerAnnotation10() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "String value(); annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(\"something\")"); - this.assertSourceDoesNotContain("Bar"); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains("@Foo(value=\"something\", nestedAnnotations={null,null,null,null,null,@Bar})"); - } - - public void testNewMarkerAnnotation11() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo({\"one\", \"two\"})"); - String expected = "@annot.Foo({@Bar, \"two\"})"; - this.assertSourceDoesNotContain(expected); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains(expected); - } - - public void testNewMarkerAnnotation12() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo({\"one\", \"two\"})"); - this.assertSourceDoesNotContain("Bar"); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains("Bar})"); // split line - } - - public void testNewMarkerAnnotation13() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo(7)"); - String expected = "@annot.Foo(@Bar)"; - this.assertSourceDoesNotContain(expected); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains(expected); - } - - public void testNewMarkerAnnotation14() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo(7)"); - this.assertSourceDoesNotContain("Bar"); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains("@annot.Foo({7,null,null,null,null,@Bar})"); - } - - public void testNewMarkerAnnotation15() throws Exception { - this.createAnnotationAndMembers("NotBar", "int value();"); - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo(@annot.NotBar)"); - String expected = "@annot.Foo(@Bar)"; - this.assertSourceDoesNotContain(expected); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains(expected); - } - - public void testNewMarkerAnnotation16() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo(@annot.Bar(55))"); - String expected = "@annot.Foo({@annot.Bar(55),@Bar})"; - this.assertSourceDoesNotContain(expected); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 1, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains(expected); - } - - public void testNewMarkerAnnotation17() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})"); - String expected = "@annot.Foo(nestedAnnotations={@Bar})"; - this.assertSourceDoesNotContain(expected); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains(expected); - } - - public void testNewMarkerAnnotation18() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})"); - this.assertSourceDoesNotContain("Bar"); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains("Bar})"); // split line - } - - public void testNewMarkerAnnotation19() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=\"something\")"); - String expected = "@annot.Foo(nestedAnnotations=@Bar)"; - this.assertSourceDoesNotContain(expected); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains(expected); - } - - public void testNewMarkerAnnotation20() throws Exception { - this.createAnnotationAndMembers("NotBar", "int value();"); - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)"); - String expected = "@annot.Foo(nestedAnnotations=@Bar)"; - this.assertSourceDoesNotContain(expected); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains(expected); - } - - public void testNewMarkerAnnotation21() throws Exception { - this.createAnnotationAndMembers("NotBar", "int value();"); - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)"); - this.assertSourceDoesNotContain("@Bar"); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains("@annot.Foo(nestedAnnotations={@annot.NotBar,null,null,null,null,@Bar})"); - } - - public void testNewMarkerAnnotation22() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(88))"); - String expected = "@annot.Foo(nestedAnnotations=@Bar)"; - this.assertSourceDoesNotContain(expected); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 0, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - aa.newMarkerAnnotation(); - this.assertSourceContains(expected); - } - - public void testNewMarkerAnnotation23() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(88))"); - String expected = "@annot.Foo(nestedAnnotations={@annot.Bar(88),null,@Bar})"; - this.assertSourceDoesNotContain(expected); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 2, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - aa.newMarkerAnnotation(); - this.assertSourceContains(expected); - } - - public void testNewMarkerAnnotation24() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo(@annot.Bar(88))"); - String expected = "@annot.Foo({@annot.Bar(88),null,@Bar})"; - this.assertSourceDoesNotContain(expected); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 2, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - aa.newMarkerAnnotation(); - this.assertSourceContains(expected); - } - - public void testNewMarkerAnnotation25() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();"); - 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); - this.assertSourceDoesNotContain(expected2); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 4, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - aa.newMarkerAnnotation(); - this.assertSourceContains(expected1); - this.assertSourceContains(expected2); - } - - public void testNewMarkerAnnotation26() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "Object[] value();"); - 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); - this.assertSourceDoesNotContain(expected2); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 4, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - aa.newMarkerAnnotation(); - this.assertSourceContains(expected1); - this.assertSourceContains(expected2); - } - - public void testNewSingleMemberAnnotation1() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType(); - this.assertSourceDoesNotContain("@Foo"); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation1(declaration); - } - }); - this.assertSourceContains("@Foo(nestedAnnotations=@Bar(88))"); - } - - 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();"); - this.createTestType(); - this.assertSourceDoesNotContain("@Foo"); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation2(declaration); - } - }); - this.assertSourceContains("@Foo(@Bar(88))"); - } - - 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();"); - this.createTestType("@annot.Foo"); - String expected = "@Foo(nestedAnnotations=@Bar(88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation3(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo"); - String expected = "@Foo(@Bar(88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation4(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(\"something\")"); - String expected = "@Foo(value=\"something\", nestedAnnotations=@Bar(88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation5(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(\"something\")"); - String expected = "@annot.Foo(@Bar(88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation6(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); - String expected = "@annot.Foo(xxx=\"something\", nestedAnnotations = @Bar(88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation7(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); - String expected = "@annot.Foo(xxx=\"something\", value = @Bar(88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation8(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType(); - this.assertSourceDoesNotContain("@Bar"); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newSingleMemberAnnotation(); - this.assertSourceContains("@Foo(nestedAnnotations={null,null,null,null,null,@Bar(MISSING)})"); // ??? - } - - public void testNewSingleMemberAnnotation10() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "String value(); annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(\"something\")"); - this.assertSourceDoesNotContain("@Bar"); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newSingleMemberAnnotation(); - this.assertSourceContains("@Foo(value=\"something\", nestedAnnotations={null,null,null,null,null,@Bar(MISSING)})"); // ??? - } - - public void testNewSingleMemberAnnotation11() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo({\"one\", \"two\"})"); - String expected = "@annot.Foo({@Bar(88), \"two\"})"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation11(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo({\"one\", \"two\"})"); - this.assertSourceDoesNotContain("@Bar"); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newSingleMemberAnnotation(); - this.assertSourceContains("@Bar(MISSING)})"); // split line - } - - public void testNewSingleMemberAnnotation13() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo(7)"); - String expected = "@annot.Foo(@Bar(88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation13(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(7)"); - this.assertSourceDoesNotContain("@Bar"); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newSingleMemberAnnotation(); - this.assertSourceContains("@annot.Foo({7,null,null,null,null,@Bar(MISSING)})"); - } - - public void testNewSingleMemberAnnotation15() throws Exception { - this.createAnnotationAndMembers("NotBar", "int value();"); - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo(@annot.NotBar)"); - String expected = "@annot.Foo(@Bar(88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation15(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(@annot.Bar(55))"); - String expected = "@annot.Foo({@annot.Bar(55),@Bar(88)})"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation16(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})"); - String expected = "@annot.Foo(nestedAnnotations={@Bar(88)})"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation17(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})"); - this.assertSourceDoesNotContain("@Bar"); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newSingleMemberAnnotation(); - this.assertSourceContains("@Bar(MISSING)})"); // ??? - } - - public void testNewSingleMemberAnnotation19() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=\"something\")"); - String expected = "@annot.Foo(nestedAnnotations=@Bar(88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation19(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)"); - String expected = "@annot.Foo(nestedAnnotations=@Bar(88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation20(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)"); - this.assertSourceDoesNotContain("@Bar"); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newSingleMemberAnnotation(); - this.assertSourceContains("@annot.Foo(nestedAnnotations={@annot.NotBar,null,null,null,null,@Bar(MISSING)})"); - } - - public void testNewSingleMemberAnnotation22() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(77))"); - String expected = "@annot.Foo(nestedAnnotations=@Bar(88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation22(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType(); - this.assertSourceDoesNotContain("@Foo"); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation1(declaration); - } - }); - this.assertSourceContains("@Foo(nestedAnnotations=@Bar(xxx=88))"); - } - - 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();"); - this.createTestType(); - this.assertSourceDoesNotContain("@Foo"); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation2(declaration); - } - }); - this.assertSourceContains("@Foo(@Bar(xxx=88))"); - } - - 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();"); - this.createTestType("@annot.Foo"); - String expected = "@Foo(nestedAnnotations=@Bar(xxx=88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation3(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo"); - String expected = "@Foo(@Bar(xxx=88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation4(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(\"something\")"); - String expected = "@Foo(value=\"something\", nestedAnnotations=@Bar(xxx=88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation5(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(\"something\")"); - String expected = "@annot.Foo(@Bar(xxx=88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation6(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); - String expected = "@annot.Foo(xxx=\"something\", nestedAnnotations = @Bar(xxx = 88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation7(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(xxx=\"something\")"); - String expected = "@annot.Foo(xxx=\"something\", value = @Bar(xxx = 88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation8(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType(); - this.assertSourceDoesNotContain("@Bar"); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newNormalAnnotation(); - this.assertSourceContains("@Foo(nestedAnnotations={null,null,null,null,null,@Bar()})"); - } - - public void testNewNormalAnnotation10() throws Exception { - this.createAnnotationAndMembers("Bar", "int xxx();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] nestedAnnotations(); String value();"); - this.createTestType("@annot.Foo(\"something\")"); - this.assertSourceDoesNotContain("@Bar"); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newNormalAnnotation(); - this.assertSourceContains("@Foo(value=\"something\", nestedAnnotations={null,null,null,null,null,@Bar()})"); - } - - public void testNewNormalAnnotation11() throws Exception { - this.createAnnotationAndMembers("Bar", "int xxx();"); - this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo({\"one\", \"two\"})"); - String expected = "@annot.Foo({@Bar(xxx=88), \"two\"})"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation11(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo({\"one\", \"two\"})"); - this.assertSourceDoesNotContain("@Bar"); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newNormalAnnotation(); - this.assertSourceContains("@Bar()})"); // split line - } - - public void testNewNormalAnnotation13() throws Exception { - this.createAnnotationAndMembers("Bar", "int xxx();"); - this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo(7)"); - String expected = "@annot.Foo(@Bar(xxx=88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation13(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(7)"); - this.assertSourceDoesNotContain("@Bar"); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newNormalAnnotation(); - this.assertSourceContains("@annot.Foo({7,null,null,null,null,@Bar()})"); - } - - public void testNewNormalAnnotation15() throws Exception { - this.createAnnotationAndMembers("NotBar", "int xxx();"); - this.createAnnotationAndMembers("Bar", "int xxx();"); - this.createAnnotationAndMembers("Foo", "Object[] value();"); - this.createTestType("@annot.Foo(@annot.NotBar)"); - String expected = "@annot.Foo(@Bar(xxx=88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation15(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(@annot.Bar(55))"); - String expected = "@annot.Foo({@annot.Bar(55),@Bar(xxx=88)})"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation16(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})"); - String expected = "@annot.Foo(nestedAnnotations={@Bar(xxx=88)})"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation17(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(nestedAnnotations={\"something\"})"); - this.assertSourceDoesNotContain("@Bar"); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newNormalAnnotation(); - this.assertSourceContains("@Bar()})"); // split line - } - - public void testNewNormalAnnotation19() throws Exception { - this.createAnnotationAndMembers("Bar", "int xxx();"); - this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=\"something\")"); - String expected = "@annot.Foo(nestedAnnotations=@Bar(xxx=88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation19(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)"); - String expected = "@annot.Foo(nestedAnnotations=@Bar(xxx=88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation20(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.NotBar)"); - this.assertSourceDoesNotContain("@Bar"); - - DeclarationAnnotationAdapter daa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "nestedAnnotations", 5, "annot.Bar"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newNormalAnnotation(); - this.assertSourceContains("@annot.Foo(nestedAnnotations={@annot.NotBar,null,null,null,null,@Bar()})"); - } - - public void testNewNormalAnnotation22() throws Exception { - this.createAnnotationAndMembers("Bar", "int xxx();"); - this.createAnnotationAndMembers("Foo", "Object[] nestedAnnotations();"); - this.createTestType("@annot.Foo(nestedAnnotations=@annot.Bar(77))"); - String expected = "@annot.Foo(nestedAnnotations=@Bar(xxx=88))"; - this.assertSourceDoesNotContain(expected); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - NestedIndexedDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation22(declaration); - } - }); - this.assertSourceContains(expected); - } - - 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();"); - this.createTestType("@annot.Foo(@annot.Bar(00))"); - String expected = "@annot.Foo({null,@annot.Bar(00)})"; - this.assertSourceDoesNotContain(expected); - - IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar"); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(); - assertNotNull(annotation); - - iaa.moveAnnotation(1); - this.assertSourceContains(expected); - } - - public void testMoveAnnotation2() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo({null, @annot.Bar(11)})"); - String expected = "@annot.Foo(@annot.Bar(11))"; - this.assertSourceDoesNotContain(expected); - - IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 1, "annot.Bar"); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(); - assertNotNull(annotation); - - iaa.moveAnnotation(0); - this.assertSourceContains(expected); - } - - public void testMoveAnnotation3() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - 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); - - IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 3, "annot.Bar"); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(); - assertNotNull(annotation); - - iaa.moveAnnotation(0); - this.assertSourceContains(expected); - } - - public void testMoveAnnotation4() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - 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); - - IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 3, "annot.Bar"); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(); - assertNotNull(annotation); - - iaa.moveAnnotation(0); - this.assertSourceContains(expected); - } - - public void testMoveAnnotation5() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - 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); - - IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 2, "annot.Bar"); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(); - assertNotNull(annotation); - - iaa.moveAnnotation(3); - this.assertSourceContains(expected); - } - - public void testMoveAnnotation6() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - 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); - - IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar"); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(); - assertNotNull(annotation); - - iaa.moveAnnotation(3); - this.assertSourceContains(expected); - } - - public void testMoveAnnotation7() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - 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); - - IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 3, "annot.Bar"); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(); - assertNull(annotation); - - iaa.moveAnnotation(0); - this.assertSourceContains(expected); - } - - public void testMoveAnnotation8() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - 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); - - IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 3, "annot.Bar"); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(); - assertNull(annotation); - - iaa.moveAnnotation(0); - this.assertSourceContains(expected); - } - - 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)})"; - this.createTestType(expected); // the source should be unchanged - - IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 0, "annot.Bar"); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(); - assertNull(annotation); - - iaa.moveAnnotation(3); - this.assertSourceContains(expected); - } - - public void testMoveAnnotation10() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - 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 MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(); - assertNull(annotation); - iaa.moveAnnotation(1); - this.assertSourceContains(expected); - } - - public void testMoveAnnotation11() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - this.createTestType("@annot.Foo(@annot.Bar(00))"); - - IndexedDeclarationAnnotationAdapter idaa = new NestedIndexedDeclarationAnnotationAdapter( - new SimpleDeclarationAnnotationAdapter("annot.Foo"), "value", 1, "annot.Bar"); - IndexedAnnotationAdapter iaa = new MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(); - assertNull(annotation); - - iaa.moveAnnotation(0); - this.assertSourceDoesNotContain("Foo"); - } - - public void testMoveAnnotation12() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - 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 MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(); - assertNotNull(annotation); - - iaa.moveAnnotation(0); - this.assertSourceContains(expected); - } - - public void testMoveAnnotation13() throws Exception { - this.createAnnotationAndMembers("Bar", "int value();"); - this.createAnnotationAndMembers("Foo", "annot.Bar[] value();"); - 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 MemberIndexedAnnotationAdapter(this.idField(), idaa); - Annotation annotation = iaa.getAnnotation(); - assertNotNull(annotation); - - iaa.moveAnnotation(0); - this.assertSourceContains(expected); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/SimpleDeclarationAnnotationAdapterTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/SimpleDeclarationAnnotationAdapterTests.java deleted file mode 100644 index 0e014b66b5..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/SimpleDeclarationAnnotationAdapterTests.java +++ /dev/null @@ -1,204 +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 - ******************************************************************************/ -package org.eclipse.jpt.core.tests.internal.jdtutility; - -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.core.internal.jdtutility.AnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.DeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.Member; -import org.eclipse.jpt.core.internal.jdtutility.MemberAnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.ModifiedDeclaration; -import org.eclipse.jpt.core.internal.jdtutility.SimpleDeclarationAnnotationAdapter; - -public class SimpleDeclarationAnnotationAdapterTests extends AnnotationTestCase { - - public SimpleDeclarationAnnotationAdapterTests(String name) { - super(name); - } - - private void createAnnotation(String annotationName) throws Exception { - this.javaProject.createType("annot", annotationName + ".java", "public @interface " + annotationName + " {}"); - } - - public void testGetAnnotation1() throws Exception { - this.createAnnotation("Foo"); - this.createTestType("@annot.Foo"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - assertEquals("annot.Foo", annotation.getTypeName().getFullyQualifiedName()); - assertTrue(annotation.isMarkerAnnotation()); - } - - public void testGetAnnotation2() throws Exception { - this.createAnnotation("Foo"); - this.createTestType("@annot.Foo(1) @annot.Foo(2)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - 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 testGetAnnotation3() throws Exception { - this.createAnnotation("Foo"); - this.createTestType("annot.Foo", "@Foo"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - assertEquals("Foo", annotation.getTypeName().getFullyQualifiedName()); - assertTrue(annotation.isMarkerAnnotation()); - } - - public void testGetAnnotationNull1() throws Exception { - this.createAnnotation("Foo"); - this.createTestType(); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - } - - public void testGetAnnotationNull2() throws Exception { - this.createAnnotation("Foo"); - this.createAnnotation("Fop"); - this.createTestType("@annot.Fop"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - this.assertSourceContains("@annot.Fop"); - } - - public void testGetAnnotationNull3() throws Exception { - this.createAnnotation("Foo"); - this.createTestType("@annot.Foo"); - // un-qualified name - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("Foo"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - this.assertSourceContains("@annot.Foo"); - } - - public void testRemoveAnnotation1() throws Exception { - this.createAnnotation("Foo"); - this.createTestType("@annot.Foo"); - this.assertSourceContains("@annot.Foo"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - - aa.removeAnnotation(); - this.assertSourceDoesNotContain("@annot.Foo"); - } - - public void testRemoveAnnotation2() throws Exception { - this.createAnnotation("Foo"); - this.createTestType("@annot.Foo(1) @annot.Foo(2)"); - this.assertSourceContains("@annot.Foo(1) @annot.Foo(2)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - - aa.removeAnnotation(); - this.assertSourceDoesNotContain("@annot.Foo(1)"); - this.assertSourceContains("@annot.Foo(2)"); - } - - public void testNewMarkerAnnotation1() throws Exception { - this.createAnnotation("Foo"); - this.createTestType(); - this.assertSourceDoesNotContain("@annot.Foo"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains("import annot.Foo;"); - this.assertSourceContains("@Foo"); - } - - public void testNewMarkerAnnotation2() throws Exception { - this.createAnnotation("Foo"); - this.createTestType("@annot.Foo(88)"); - DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - AnnotationAdapter aa = new MemberAnnotationAdapter(this.idField(), daa); - Annotation annotation = aa.getAnnotation(); - assertNotNull(annotation); - - aa.newMarkerAnnotation(); - this.assertSourceContains("import annot.Foo;"); - this.assertSourceContains("@Foo"); - this.assertSourceDoesNotContain("@annot.Foo(88)"); - } - - public void testNewSingleMemberAnnotation() throws Exception { - this.createAnnotation("Foo"); - this.createTestType(); - this.assertSourceDoesNotContain("@Foo"); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - SimpleDeclarationAnnotationAdapterTests.this.editNewSingleMemberAnnotation(declaration); - } - }); - this.assertSourceContains("import annot.Foo;"); - this.assertSourceContains("@Foo(\"test string literal\")"); - } - - 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"); - this.createTestType(); - this.assertSourceDoesNotContain("@Foo"); - this.idField().edit(new Member.Editor() { - public void edit(ModifiedDeclaration declaration) { - SimpleDeclarationAnnotationAdapterTests.this.editNewNormalAnnotation(declaration); - } - }); - this.assertSourceContains("import annot.Foo;"); - this.assertSourceContains("@Foo(bar=\"test string literal\")"); - } - - 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); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/TypeTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/TypeTests.java deleted file mode 100644 index 637115678b..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/TypeTests.java +++ /dev/null @@ -1,67 +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 - ******************************************************************************/ -package org.eclipse.jpt.core.tests.internal.jdtutility; - -import org.eclipse.jdt.core.IType; -import org.eclipse.jpt.core.internal.ITextRange; -import org.eclipse.jpt.core.internal.jdtutility.Type; - -public class TypeTests extends AnnotationTestCase { - - private IType jdtType; - private Type testType; - - - public TypeTests(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - this.jdtType = this.createTestType(); - this.testType = new Type(this.jdtType); - } - - @Override - protected void tearDown() throws Exception { - this.testType = null; - this.jdtType = null; - super.tearDown(); - } - - public void testGetJdtMember() throws Exception { - assertEquals(this.jdtType, this.testType.getJdtMember()); - } - - public void testIsAbstract() throws Exception { - assertFalse(this.testType.isAbstract()); - } - - public void testTopLevelDeclaringType() throws Exception { - assertEquals(this.testType, this.testType.topLevelDeclaringType()); - } - - public void testGetDeclaringType() throws Exception { - assertNull(this.testType.getDeclaringType()); - } - - public void testGetName() throws Exception { - assertEquals(TYPE_NAME, this.testType.getName()); - } - - public void testTextRange() throws Exception { - String source = this.jdtType.getOpenable().getBuffer().getContents(); - ITextRange textRange = this.testType.textRange(); - String body = source.substring(textRange.getOffset()); - assertTrue(body.startsWith("public class " + TYPE_NAME)); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JptCoreModelTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JptCoreModelTests.java deleted file mode 100644 index d7d2ffe080..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/JptCoreModelTests.java +++ /dev/null @@ -1,27 +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.core.tests.internal.model; - -import junit.framework.Test; -import junit.framework.TestSuite; - -public class JptCoreModelTests { - - public static Test suite() { - TestSuite suite = new TestSuite(JptCoreModelTests.class.getPackage().getName()); - suite.addTestSuite(ModelInitializationTests.class); - return suite; - } - - private JptCoreModelTests() { - super(); - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/ModelInitializationTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/ModelInitializationTests.java deleted file mode 100644 index 620ec258a1..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/model/ModelInitializationTests.java +++ /dev/null @@ -1,90 +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 - ******************************************************************************/ -package org.eclipse.jpt.core.tests.internal.model; - -import junit.framework.TestCase; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; -import org.eclipse.jpt.core.internal.IJpaModel; -import org.eclipse.jpt.core.internal.IJpaProject; -import org.eclipse.jpt.core.internal.JptCorePlugin; -import org.eclipse.jpt.core.tests.internal.ProjectUtility; -import org.eclipse.jpt.core.tests.internal.projects.TestFacetedProject; -import org.eclipse.jpt.utility.internal.ClassTools; -import org.eclipse.jpt.utility.internal.CollectionTools; - -public class ModelInitializationTests extends TestCase { - private IJpaModel jpaModel; - - - public ModelInitializationTests(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - ProjectUtility.deleteAllProjects(); - this.jpaModel = JptCorePlugin.getJpaModel(); - } - - @Override - protected void tearDown() throws Exception { - ProjectUtility.deleteAllProjects(); - this.jpaModel = null; - super.tearDown(); - } - - /** - * Builds a project with the java and utility facets installed, and with - * pre-existing entities added. - */ - private TestFacetedProject buildTestProject() throws CoreException { - TestFacetedProject testProject = new TestFacetedProject(ClassTools.shortClassNameForObject(this), true); - testProject.installFacet("jst.java", "5.0"); - testProject.installFacet("jst.utility", "1.0"); - testProject.createFile( - new Path("src/test.pkg/TestEntity.java"), - "package test.pkg; @Entity public class TestEntity {}"); - testProject.createFile( - new Path("src/test.pkg/TestEntity2.java"), - "package test.pkg; @Entity public class TestEntity2 {}"); - return testProject; - } - - public void testBasic() { - assertNotNull(this.jpaModel); - } - - public void testFacetInstallation() throws CoreException { - TestFacetedProject testProject = buildTestProject(); - assertNull(this.jpaModel.getJpaProject(testProject.getProject())); - testProject.installFacet("jpt.jpa", "1.0"); - assertEquals(1, CollectionTools.size(this.jpaModel.jpaProjects())); - IJpaProject jpaProject = this.jpaModel.getJpaProject(testProject.getProject()); - assertNotNull(jpaProject); - assertEquals(4, CollectionTools.size(jpaProject.jpaFiles())); - assertNotNull(jpaProject.getJpaFile(testProject.getProject().getFile(new Path("src/test.pkg/TestEntity.java")))); - assertNotNull(jpaProject.getJpaFile(testProject.getProject().getFile(new Path("src/test.pkg/TestEntity2.java")))); - } - - public void testProjectOpening() throws CoreException { - TestFacetedProject testProject = buildTestProject(); - testProject.installFacet("jpt.jpa", "1.0"); - testProject.close(); - assertTrue(! testProject.getProject().isOpen()); - testProject.open(); - IJpaProject jpaProject = this.jpaModel.getJpaProject(testProject.getProject()); - assertNotNull(jpaProject); - assertNotNull(jpaProject.getJpaFile(testProject.getProject().getFile(new Path("src/test.pkg/TestEntity.java")))); - assertNotNull(jpaProject.getJpaFile(testProject.getProject().getFile(new Path("src/test.pkg/TestEntity2.java")))); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/BaseJpaPlatformTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/BaseJpaPlatformTests.java deleted file mode 100644 index 94c306e4f0..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/BaseJpaPlatformTests.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.eclipse.jpt.core.tests.internal.platform; - -import java.io.IOException; -import junit.framework.TestCase; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jpt.core.internal.IJpaFile; -import org.eclipse.jpt.core.internal.content.orm.EntityMappingsInternal; -import org.eclipse.jpt.core.internal.content.orm.OrmFactory; -import org.eclipse.jpt.core.internal.content.orm.XmlEntityInternal; -import org.eclipse.jpt.core.internal.content.orm.XmlRootContentNode; -import org.eclipse.jpt.core.internal.content.persistence.JavaClassRef; -import org.eclipse.jpt.core.internal.content.persistence.Persistence; -import org.eclipse.jpt.core.internal.content.persistence.PersistenceFactory; -import org.eclipse.jpt.core.internal.content.persistence.PersistenceXmlRootContentNode; -import org.eclipse.jpt.core.tests.internal.projects.TestJpaProject; -import org.eclipse.jpt.utility.internal.CollectionTools; - -public class BaseJpaPlatformTests extends TestCase -{ - protected TestJpaProject jpaProject; - - protected static final String PROJECT_NAME = "PlatformTestProject"; - protected static final String PACKAGE_NAME = "platform.test"; - protected static final String PERSISTENCE_XML_LOCATION = "src/META-INF/persistence.xml"; - protected static final String ORM_XML_LOCATION = "src/META-INF/orm.xml"; - - - public BaseJpaPlatformTests(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - jpaProject = this.buildJpaProject(PROJECT_NAME, false); // false = no auto-build - } - - protected TestJpaProject buildJpaProject(String projectName, boolean autoBuild) throws Exception { - return new TestJpaProject(projectName, autoBuild); // false = no auto-build - } - - @Override - protected void tearDown() throws Exception { - jpaProject.dispose(); - jpaProject = null; - super.tearDown(); - } - - - public void testPersistentTypes() throws CoreException, IOException { - IFile persistenceXmlIFile = jpaProject.getProject().getFile(PERSISTENCE_XML_LOCATION); - IJpaFile persistenceXmlJpaFile = jpaProject.getJpaProject().getJpaFile(persistenceXmlIFile); - PersistenceXmlRootContentNode persistenceRoot = (PersistenceXmlRootContentNode) persistenceXmlJpaFile.getContent(); - Persistence persistence = persistenceRoot.getPersistence(); - - IFile ormXmlIFile = jpaProject.getProject().getFile(ORM_XML_LOCATION); - IJpaFile ormXmlJpaFile = jpaProject.getJpaProject().getJpaFile(ormXmlIFile); - XmlRootContentNode ormRoot = (XmlRootContentNode) ormXmlJpaFile.getContent(); - EntityMappingsInternal entityMappings = ormRoot.getEntityMappings(); - - // add xml persistent type - XmlEntityInternal xmlEntity = OrmFactory.eINSTANCE.createXmlEntityInternal(); - xmlEntity.setSpecifiedName("XmlEntity"); - entityMappings.getTypeMappings().add(xmlEntity); - entityMappings.eResource().save(null); - - assertEquals(1, CollectionTools.size(jpaProject.getJpaProject().getPlatform().persistentTypes(PROJECT_NAME))); - - // add java persistent type - jpaProject.createType(PACKAGE_NAME, "JavaEntity.java", - "@Entity public class JavaEntity {}" - ); - JavaClassRef javaClassRef = PersistenceFactory.eINSTANCE.createJavaClassRef(); - javaClassRef.setJavaClass(PACKAGE_NAME + ".JavaEntity"); - persistence.getPersistenceUnits().get(0).getClasses().add(javaClassRef); - persistence.eResource().save(null); - - assertEquals(2, CollectionTools.size(jpaProject.getJpaProject().getPlatform().persistentTypes(PROJECT_NAME))); - } -} diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/JptCorePlatformTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/JptCorePlatformTests.java deleted file mode 100644 index 589e63112e..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/platform/JptCorePlatformTests.java +++ /dev/null @@ -1,28 +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.core.tests.internal.platform; - -import junit.framework.Test; -import junit.framework.TestSuite; - -public class JptCorePlatformTests -{ - public static Test suite() { - TestSuite suite = new TestSuite(JptCorePlatformTests.class.getName()); -// suite.addTestSuite(BaseJpaPlatformTests.class); - return suite; - } - - private JptCorePlatformTests() { - super(); - throw new UnsupportedOperationException(); - } -} diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestFacetedProject.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestFacetedProject.java deleted file mode 100644 index 6b638fa21b..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestFacetedProject.java +++ /dev/null @@ -1,48 +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.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; - -public class TestFacetedProject extends TestPlatformProject { - private IFacetedProject facetedProject; - - - // ********** 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 { - IProjectFacetVersion facetVersion = ProjectFacetsManager.getProjectFacet(facetName).getVersion(versionName); - this.facetedProject.installProjectFacet(facetVersion, null, null); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestJavaProject.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestJavaProject.java deleted file mode 100644 index a19529b0e1..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestJavaProject.java +++ /dev/null @@ -1,148 +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.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.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.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jdt.core.search.IJavaSearchConstants; -import org.eclipse.jdt.core.search.SearchEngine; -import org.eclipse.jdt.core.search.SearchPattern; -import org.eclipse.jdt.core.search.TypeNameRequestor; -import org.eclipse.jpt.utility.internal.CollectionTools; - -/** - * This builds and holds a "Java" project. - * Support for adding packages and types. - */ -public class TestJavaProject extends TestFacetedProject { - - private IJavaProject javaProject; - private IPackageFragmentRoot sourceFolder; - - - // ********** constructors/initialization ********** - - public TestJavaProject() throws CoreException { - this("TestJavaProject"); - } - - 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")); - } - - protected 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(CollectionTools.add(this.javaProject.getRawClasspath(), entry), null); - } - - - // ********** public methods ********** - - 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 IType createType(String packageName, String compilationUnitName, String source) throws CoreException { - return this.createType(this.createPackage(packageName), compilationUnitName, new SimpleSourceWriter(source)); - } - - /** - * The source should NOT contain a package declaration; - * it will be added here. - */ - public IType createType(String packageName, String compilationUnitName, SourceWriter sourceWriter) throws CoreException { - return this.createType(this.createPackage(packageName), compilationUnitName, sourceWriter); - } - - /** - * The source should NOT contain a package declaration; - * it will be added here. - */ - public IType createType(IPackageFragment packageFragment, String compilationUnitName, SourceWriter sourceWriter) throws CoreException { - StringBuffer sb = new StringBuffer(2000); - sb.append("package ").append(packageFragment.getElementName()).append(";").append(CR); - sb.append(CR); - sourceWriter.appendSourceTo(sb); - String source = sb.toString(); - ICompilationUnit cu = packageFragment.createCompilationUnit(compilationUnitName, source, false, null); // false = "no force" - return cu.findPrimaryType(); - } - - public IType findType(String fullyQualifiedName) throws JavaModelException { - return this.javaProject.findType(fullyQualifiedName); - } - - @Override - public void dispose() throws CoreException { - this.waitForIndexer(); - this.sourceFolder = null; - this.javaProject = null; - super.dispose(); - } - - - // ********** internal methods ********** - - private void waitForIndexer() throws JavaModelException { - new SearchEngine().searchAllTypeNames( - null, - SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE, - null, - SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE, - IJavaSearchConstants.CLASS, - SearchEngine.createJavaSearchScope(new IJavaElement[0]), - new TypeNameRequestor() {/* do nothing */}, - IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, - null - ); - } - - - // ********** member classes ********** - - public interface SourceWriter { - void appendSourceTo(StringBuffer sb); - } - - public class SimpleSourceWriter implements SourceWriter { - private final String source; - public SimpleSourceWriter(String source) { - super(); - this.source = source; - } - public void appendSourceTo(StringBuffer sb) { - sb.append(source); - } - } - -} diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestJpaProject.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestJpaProject.java deleted file mode 100644 index 68f01e8f2b..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestJpaProject.java +++ /dev/null @@ -1,60 +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.core.tests.internal.projects; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jpt.core.internal.IJpaProject; -import org.eclipse.jpt.core.internal.JptCorePlugin; - -public class TestJpaProject extends TestJavaProject { - private IJpaProject jpaProject; - - public static final String JAR_NAME_SYSTEM_PROPERTY = "org.eclipse.jpt.jpa.jar"; - - // ********** constructors/initialization ********** - - public TestJpaProject() throws CoreException { - this("TestJpaProject"); - } - - public TestJpaProject(String projectName) throws CoreException { - this(projectName, false); - } - - public TestJpaProject(String projectName, boolean autoBuild) throws CoreException { - super(projectName, autoBuild); - this.installFacet("jst.utility", "1.0"); - this.installFacet("jpt.jpa", "1.0"); - this.addJar(this.jarName()); - this.jpaProject = JptCorePlugin.getJpaProject(this.getProject()); - } - - protected String jarName() { - String jarName = System.getProperty(JAR_NAME_SYSTEM_PROPERTY); - if (jarName == null) { - throw new RuntimeException("missing Java system property: \"" + JAR_NAME_SYSTEM_PROPERTY + "\""); - } - return jarName; - } - - - // ********** public methods ********** - - public IJpaProject getJpaProject() { - return this.jpaProject; - } - - @Override - public void dispose() throws CoreException { - this.jpaProject = null; - super.dispose(); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestPlatformProject.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestPlatformProject.java deleted file mode 100644 index 7fbca7957d..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/projects/TestPlatformProject.java +++ /dev/null @@ -1,195 +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.core.tests.internal.projects; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -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.IProjectDescription; -import org.eclipse.core.resources.IWorkspaceDescription; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.jpt.utility.internal.CollectionTools; - -/** - * This builds and holds a "general" project. - * Support for adding natures, folders, and files. - */ -public class TestPlatformProject { - - private final IProject project; - - /** carriage return */ - public static final String CR = System.getProperty("line.separator"); - - - // ********** constructors/initialization ********** - - public TestPlatformProject() throws CoreException { - this(false); - } - - public TestPlatformProject(boolean autoBuild) throws CoreException { - this("TestProject", autoBuild); - } - - public TestPlatformProject(String projectName, boolean autoBuild) throws CoreException { - super(); - this.setAutoBuild(autoBuild); // workspace-wide setting - this.project = this.createPlatformProject(projectName); - } - - private void setAutoBuild(boolean autoBuild) throws CoreException { - IWorkspaceDescription description = ResourcesPlugin.getWorkspace().getDescription(); - description.setAutoBuilding(autoBuild); - ResourcesPlugin.getWorkspace().setDescription(description); - } - - private IProject createPlatformProject(String projectName) throws CoreException { - IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); - p.create(null); - p.open(null); - return p; - } - - - // ********** public methods ********** - - public IProject getProject() { - return this.project; - } - - public void addProjectNature(String natureID) throws CoreException { - IProjectDescription description = this.project.getDescription(); - description.setNatureIds((String[]) CollectionTools.add(description.getNatureIds(), natureID)); - this.project.setDescription(description, null); - } - - public void removeProjectNature(String natureID) throws CoreException { - IProjectDescription description = this.project.getDescription(); - description.setNatureIds((String[]) CollectionTools.removeAllOccurrences(description.getNatureIds(), natureID)); - this.project.setDescription(description, null); - } - - /** - * Create a folder with the specified name directly under the project. - */ - public IFolder createFolder(String folderName) throws CoreException { - return this.createFolder(this.project, new Path(folderName)); - } - - /** - * Create a folder in the specified container with the specified name. - */ - public IFolder createFolder(IContainer container, String folderName) throws CoreException { - return this.createFolder(container, new Path(folderName)); - } - - /** - * Create a folder in the specified container with the specified path. - */ - public IFolder createFolder(IContainer container, IPath folderPath) throws CoreException { - IFolder folder = container.getFolder(folderPath); - if ( ! folder.exists()) { - folder.create(false, true, null); // false = "no force"; true = "local" - } - return folder; - } - - /** - * Create a file with the specified name and content directly under the project. - */ - public IFile createFile(String fileName, String content) throws CoreException { - return this.createFile(this.project, fileName, content); - } - - /** - * Create a file in the specified container with the specified name and content. - */ - public IFile createFile(IContainer container, String fileName, String content) throws CoreException { - return createFile(container, new Path(fileName), content); - } - - /** - * Create a file in the project with the specified [relative] path - * and content. - */ - public IFile createFile(IPath filePath, String content) throws CoreException { - return this.createFile(this.project, filePath, content); - } - - /** - * Create a file in the specified container with the specified path and content. - */ - public IFile createFile(IContainer container, IPath filePath, String content) throws CoreException { - return this.createFile(container, filePath, new ByteArrayInputStream(content.getBytes())); - } - - /** - * Create a file in the specified container with the specified path and contents. - */ - public IFile createFile(IContainer container, IPath filePath, InputStream content) throws CoreException { - int len = filePath.segmentCount() - 1; - for (int i = 0; i < len; i++) { - container = container.getFolder(new Path(filePath.segment(i))); - if ( ! container.exists()) { - ((IFolder) container).create(true, true, null); // true = "force"; true = "local" - } - } - - IFile file = container.getFile(new Path(filePath.lastSegment())); - if (file.exists()) { - file.delete(true, null); // true = "force" - } - file.create(content, true, null); // true = "force" - return file; - } - - public void open() throws CoreException { - this.project.open(null); - waitForJobs(); - } - - public void close() throws CoreException { - this.project.close(null); - waitForJobs(); - } - - public void dispose() throws CoreException { - this.project.delete(true, true, null); // true = "delete content"; true = "force" - for (int i = 1; this.project.exists(); i++) { - waitForJobs(); - System.out.println("Project still exists: " + i); - } - } - - - // ********** static methods ********** - - /** - * Wait until all background tasks are complete. - */ - public static void waitForJobs() { - while (Job.getJobManager().currentJob() != null) { - try { - Thread.sleep(100); // let other threads get something done - } catch (InterruptedException ex) { - throw new RuntimeException(ex); - } - } - } - -} diff --git a/jpa/tests/org.eclipse.jpt.core.tests/test.xml b/jpa/tests/org.eclipse.jpt.core.tests/test.xml deleted file mode 100644 index 702dee3626..0000000000 --- a/jpa/tests/org.eclipse.jpt.core.tests/test.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/jpa/tests/org.eclipse.jpt.db.tests/.classpath b/jpa/tests/org.eclipse.jpt.db.tests/.classpath deleted file mode 100644 index 751c8f2e50..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/jpa/tests/org.eclipse.jpt.db.tests/.cvsignore b/jpa/tests/org.eclipse.jpt.db.tests/.cvsignore deleted file mode 100644 index ba077a4031..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin diff --git a/jpa/tests/org.eclipse.jpt.db.tests/.project b/jpa/tests/org.eclipse.jpt.db.tests/.project deleted file mode 100644 index f5b0127a1e..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.eclipse.jpt.db.tests - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/jpa/tests/org.eclipse.jpt.db.tests/META-INF/MANIFEST.MF b/jpa/tests/org.eclipse.jpt.db.tests/META-INF/MANIFEST.MF deleted file mode 100644 index eb01aca9ac..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/META-INF/MANIFEST.MF +++ /dev/null @@ -1,16 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: %pluginName -Bundle-Vendor: %providerName -Bundle-SymbolicName: org.eclipse.jpt.db.tests -Bundle-Version: 1.0.0.qualifier -Bundle-Activator: org.eclipse.jpt.db.tests.internal.JptDbTestsPlugin -Bundle-Localization: plugin -Eclipse-LazyStart: false -Require-Bundle: org.eclipse.core.runtime, - org.junit, - org.eclipse.datatools.connectivity, - org.eclipse.datatools.connectivity.db.generic, - org.eclipse.jpt.utility, - org.eclipse.jpt.db -Export-Package: org.eclipse.jpt.db.tests.internal.platforms diff --git a/jpa/tests/org.eclipse.jpt.db.tests/build.properties b/jpa/tests/org.eclipse.jpt.db.tests/build.properties deleted file mode 100644 index cd0d010fd1..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/build.properties +++ /dev/null @@ -1,15 +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 -############################################################################### -source.. = src/ -output.. = bin/ -bin.includes = .,\ - META-INF/,\ - plugin.properties diff --git a/jpa/tests/org.eclipse.jpt.db.tests/config/derby101.properties b/jpa/tests/org.eclipse.jpt.db.tests/config/derby101.properties deleted file mode 100644 index 6101413bc8..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/config/derby101.properties +++ /dev/null @@ -1,30 +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 -############################################################################### -# Platform Property names & Default -# -# profileName - jpatest -# profileDescription - JDBC Profile for JPA Testing -# userName - jpatest -# userPassword - (empty) -# databasedriverJarList - (mandatory) -# databaseName - testdb -# databaseUrl - (mandatory) -# -profileName = derby101 -profileDescription = Derby Embedded JDBC Profile for Testing -# set user name -userName = jpatest -userPassword = -# set path to Derby driver here (example: databasedriverJarList = c:/derbydb/lib/derby.jar ) -databasedriverJarList = -databaseName = testdb -# set database URL here (example: databaseUrl = jdbc:derby:c:/derbydb/testdb;create=true ) -databaseUrl = diff --git a/jpa/tests/org.eclipse.jpt.db.tests/config/oracle10g.properties b/jpa/tests/org.eclipse.jpt.db.tests/config/oracle10g.properties deleted file mode 100644 index 498fc7deb5..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/config/oracle10g.properties +++ /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 -############################################################################### -# Platform Property names & Default -# -# profileName - jpatest -# profileDescription - JDBC Profile for JPA Testing -# userName - jpatest -# userPassword - (empty) -# databasedriverJarList - jar list separate by comma (mandatory) -# databaseName - testdb -# databaseUrl - (mandatory) -# -profileName = oracleXE10g -profileDescription = XE 10g Release 2 (10.2) Thin JDBC Profile for Testing -userName = scott -userPassword = tiger -# set path to Oracle driver here (example: databasedriverJarList = c:/oracle/jdbc/lib/ojdbc14.jar ) -databasedriverJarList = -databaseName = testdb -# set database URL here (example: databaseUrl = jdbc:oracle:thin:@localhost:1521:testdb ) -databaseUrl = diff --git a/jpa/tests/org.eclipse.jpt.db.tests/config/oracle9i.properties b/jpa/tests/org.eclipse.jpt.db.tests/config/oracle9i.properties deleted file mode 100644 index 3207919153..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/config/oracle9i.properties +++ /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 -############################################################################### -# Platform Property names & Default -# -# profileName - jpatest -# profileDescription - JDBC Profile for JPA Testing -# userName - jpatest -# userPassword - (empty) -# databasedriverJarList - jar list separate by comma (mandatory) -# databaseName - testdb -# databaseUrl - (mandatory) -# -profileName = oracle9i -profileDescription = Oracle Thin JDBC Profile for Testing -userName = scott -userPassword = tiger -# set path to Oracle driver here (example: databasedriverJarList = c:/oracle/jdbc/lib/ojdbc14.jar ) -databasedriverJarList = -databaseName = testdb -# set database URL here (example: databaseUrl = jdbc:oracle:thin:@server:1521:testdb ) -databaseUrl = diff --git a/jpa/tests/org.eclipse.jpt.db.tests/config/sqlserver2005.properties b/jpa/tests/org.eclipse.jpt.db.tests/config/sqlserver2005.properties deleted file mode 100644 index 8451351e83..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/config/sqlserver2005.properties +++ /dev/null @@ -1,30 +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 -############################################################################### -# Platform Property names & Default -# -# profileName - jpatest -# profileDescription - JDBC Profile for JPA Testing -# userName - jpatest -# userPassword - (empty) -# databasedriverJarList - (mandatory) -# databaseName - testdb -# databaseUrl - (mandatory) -# -profileName = sqlserver2005 -profileDescription = MS SQL Server 2005 JDBC Profile for Testing -# set user name -userName = -userPassword = -# set path to Derby driver here (example: databasedriverJarList = c:/sqlserver/lib/sqljdbc.jar ) -databasedriverJarList = -databaseName = testdb -# set database URL here (example: databaseUrl = jdbc:sqlserver://localhost:1433;databaseName=testdb ) -databaseUrl = diff --git a/jpa/tests/org.eclipse.jpt.db.tests/plugin.properties b/jpa/tests/org.eclipse.jpt.db.tests/plugin.properties deleted file mode 100644 index b04fe27976..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/plugin.properties +++ /dev/null @@ -1,25 +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 -############################################################################### -# ==================================================================== -# 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 = JPA DB Tests -providerName = Eclipse.org - diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/JptDbTests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/JptDbTests.java deleted file mode 100644 index 2326ea3d94..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/JptDbTests.java +++ /dev/null @@ -1,39 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.tests.internal; - -import junit.framework.Test; -import junit.framework.TestSuite; -import junit.swingui.TestRunner; -import org.eclipse.jpt.db.tests.internal.platforms.AllPlatformTests; -import org.eclipse.jpt.utility.internal.ClassTools; - -/** - * JptDbTests - */ -public class JptDbTests { - - public static void main( String[] args) { - TestRunner.main( new String[] { "-c", JptDbTests.class.getName()}); - } - - public static Test suite() { - TestSuite suite = new TestSuite( ClassTools.packageNameFor( JptDbTests.class)); - - suite.addTest( AllPlatformTests.suite()); - - return suite; - } - - private JptDbTests() { - super(); - throw new UnsupportedOperationException(); - } -} diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/JptDbTestsPlugin.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/JptDbTestsPlugin.java deleted file mode 100644 index dfced34598..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/JptDbTestsPlugin.java +++ /dev/null @@ -1,54 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.tests.internal; - -import org.eclipse.core.runtime.Plugin; -import org.osgi.framework.BundleContext; - -/** - * JptDbTestsPlugin - */ -public class JptDbTestsPlugin extends Plugin { - - // The shared instance - private static JptDbTestsPlugin plugin; - - public static final String BUNDLE_ID = "org.eclipse.jpt.db.tests"; //$NON-NLS-1$ - - /** - * Returns the shared instance - */ - public static JptDbTestsPlugin getDefault() { - return plugin; - } - - /** - * The constructor - */ - public JptDbTestsPlugin() { - super(); - plugin = this; - } - - /** - * This method is called upon plug-in activation - */ - public void start(BundleContext context) throws Exception { - super.start(context); - } - - /** - * This method is called when the plug-in is stopped - */ - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } -} diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/AllPlatformTests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/AllPlatformTests.java deleted file mode 100644 index af9c4233cc..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/AllPlatformTests.java +++ /dev/null @@ -1,42 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.tests.internal.platforms; - -import junit.framework.Test; -import junit.framework.TestSuite; -import junit.swingui.TestRunner; -import org.eclipse.jpt.utility.internal.ClassTools; - -/** - * AllPlatformTests - */ -public class AllPlatformTests { - - public static void main( String[] args) { - TestRunner.main( new String[] { "-c", AllPlatformTests.class.getName()}); - } - - public static Test suite() { - TestSuite suite = new TestSuite( ClassTools.packageNameFor( AllPlatformTests.class)); - - // TODO - Uncomment the platform to test. -// suite.addTest( Derby101Tests.suite()); -// suite.addTest( Oracle9iTests.suite()); -// suite.addTest( Oracle10gTests.suite()); -// suite.addTest( SQLServer2005Tests.suite()); - - return suite; - } - - private AllPlatformTests() { - super(); - } - -} \ No newline at end of file diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/DTPPlatformTests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/DTPPlatformTests.java deleted file mode 100644 index 46deffc7a6..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/DTPPlatformTests.java +++ /dev/null @@ -1,385 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.tests.internal.platforms; - -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collection; -import java.util.NoSuchElementException; -import java.util.Properties; -import junit.framework.Assert; -import junit.framework.TestCase; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Platform; -import org.eclipse.datatools.connectivity.ConnectionProfileException; -import org.eclipse.datatools.connectivity.IConnectionProfile; -import org.eclipse.datatools.connectivity.ProfileManager; -import org.eclipse.datatools.connectivity.db.generic.IDBDriverDefinitionConstants; -import org.eclipse.datatools.connectivity.drivers.IDriverMgmtConstants; -import org.eclipse.datatools.connectivity.drivers.IPropertySet; -import org.eclipse.datatools.connectivity.drivers.PropertySetImpl; -import org.eclipse.datatools.connectivity.drivers.XMLFileManager; -import org.eclipse.datatools.connectivity.internal.ConnectivityPlugin; -import org.eclipse.jpt.db.internal.Connection; -import org.eclipse.jpt.db.internal.ConnectionProfile; -import org.eclipse.jpt.db.internal.ConnectionProfileRepository; -import org.eclipse.jpt.db.internal.DTPConnectionProfileWrapper; -import org.eclipse.jpt.db.internal.Database; -import org.eclipse.jpt.db.internal.Schema; -import org.eclipse.jpt.db.internal.Table; -import org.eclipse.jpt.db.tests.internal.JptDbTestsPlugin; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.StringTools; - -/** - * Base class for all supported DTP platform. - */ -public abstract class DTPPlatformTests extends TestCase { - - protected ConnectionProfileRepository connectionRepository; - - private Properties platformProperties; - private String currentDbVendor; - private String currentDbVersion; - - private static final String PLATFORM_CONFIG_DIRECTORY = "config"; //$NON-NLS-1$ - - private static final String PROFILE_NAME_PROPERTY = "profileName"; //$NON-NLS-1$ - private static final String PROFILE_DESCRIPTION_PROPERTY = "profileDescription"; //$NON-NLS-1$ - private static final String USER_NAME_PROPERTY = "userName"; //$NON-NLS-1$ - private static final String USER_PASSWORD_PROPERTY = "userPassword"; //$NON-NLS-1$ - private static final String DB_DRIVER_JAR_PROPERTY = "databasedriverJarList"; //$NON-NLS-1$ - private static final String DB_NAME_PROPERTY = "databaseName"; //$NON-NLS-1$ - private static final String DB_URL_PROPERTY = "databaseUrl"; //$NON-NLS-1$ - - private static final String PROFILE_NAME_DEFAULT = "jpatest"; //$NON-NLS-1$ - private static final String PROFILE_DESCRIPTION_DEFAULT = "JDBC Profile for JPA Testing"; //$NON-NLS-1$ - private static final String USER_NAME_DEFAULT = "userName"; //$NON-NLS-1$ - private static final String USER_PASSWORD_DEFAULT = ""; //$NON-NLS-1$ - private static final String DB_NAME_DEFAULT = "testdb"; //$NON-NLS-1$ - - private static final String MISSING_PROPERTY_MESSAGE = "Enter missing property in platform config file (config/database.properties)"; - - public DTPPlatformTests( String name) { - super( name); - - this.connectionRepository = ConnectionProfileRepository.instance(); - } - - protected void setUp() throws Exception { - super.setUp(); - this.connectionRepository.initializeListeners(); - - if( this.platformIsNew()) { - this.loadPlatformProperties(); - - this.buildDriverDefinitionFile( IDriverMgmtConstants.DRIVER_FILE); - this.buildConnectionProfile( this.profileName()); - this.currentDbVendor = this.databaseVendor(); - this.currentDbVersion = this.databaseVersion(); - } - this.verifyProfileNamed( this.profileName()); - } - - protected void tearDown() throws Exception { - super.tearDown(); - - this.connectionRepository.disposeListeners(); - } - - // ********** tests ********** - - public void testConnection() throws Exception { - - this.connect(); - - this.verifyDatabaseVersionNumber(); - this.verifyConnection(); - this.verifyDatabaseContent(); - - this.disconnect(); - } - - public void testGetProfiles() { - // Getting the profile directly from DTP ProfileManager - IConnectionProfile[] profiles = ProfileManager.getInstance().getProfiles(); - Assert.assertNotNull( profiles); - Assert.assertTrue( profiles.length > 0); - } - - public void testGetProfilesByProvider() { - // Get Profiles By ProviderID - IConnectionProfile[] profiles = ProfileManager.getInstance().getProfileByProviderID( this.getProfile().getProviderId()); - Assert.assertNotNull( profiles); - Assert.assertTrue( profiles.length > 0); - } - - public void testGetProfileByName() { - // Get Profile By Name - IConnectionProfile dtpProfile = ProfileManager.getInstance().getProfileByName( this.profileName()); - Assert.assertNotNull( dtpProfile); - Assert.assertTrue( dtpProfile.getName().equals( this.profileName())); - } - - public void testGetProfileByInstanceId() { - // Get Profile By InstanceID - IConnectionProfile dtpProfile = ProfileManager.getInstance().getProfileByInstanceID( this.getProfile().getInstanceId()); - Assert.assertNotNull( dtpProfile); - Assert.assertTrue( dtpProfile.getName().equals( this.profileName())); - } - - // ********** internal tests ********** - - private void verifyDatabaseVersionNumber() { - Database database = this.getProfile().getDatabase(); - Assert.assertNotNull( database); - - String actualVersionNumber = database.getVersion(); - String expectedVersionNumber = this.databaseVersion(); - String errorMessage = "Expected version number: " + expectedVersionNumber + " but the actual version number was: " + actualVersionNumber; - assertTrue( errorMessage, actualVersionNumber.indexOf( expectedVersionNumber) != -1); - - String actualVendor = database.getVendor(); - String expectedVendor = this.databaseVendor(); - errorMessage = "Expected vendor: " + expectedVendor + " but the actual vendor was: " + actualVendor; - assertEquals( errorMessage, actualVendor, expectedVendor); - } - - private void verifyConnection() { - Connection connection = this.getProfile().getConnection(); - Assert.assertNotNull( connection); - - String actualFactory = connection.getFactoryId(); - String expectedFactory = DTPConnectionProfileWrapper.CONNECTION_TYPE; - String errorMessage = "Expected factory: " + expectedFactory + " but the actual factory was: " + actualFactory; - assertEquals( errorMessage, actualFactory, expectedFactory); - } - - private void verifyDatabaseContent() { - Database database = this.getProfile().getDatabase(); - Assert.assertTrue( database.schemataSize() > 0); - - Schema schema = database.schemaNamed( this.getProfile().getUserName()); - if( schema != null) { - Assert.assertTrue( schema.sequencesSize() >= 0); - - Object[] tableNames = CollectionTools.array( schema.tableNames()); - if( tableNames.length >= 1) { - Table table = schema.tableNamed(( String)tableNames[ 0]); - Assert.assertTrue( table.columnsSize() >= 0); - Assert.assertTrue( table.foreignKeyColumnsSize() >= 0); - Assert.assertTrue( table.foreignKeysSize() >= 0); - Assert.assertTrue( table.primaryKeyColumnsSize() >= 0); - } - } - } - - private void verifyProfileNamed( String profileName) { - - ConnectionProfile profile = this.getProfileNamed( profileName); - Assert.assertTrue( "ConnectionProfile not found", profileName.equals( profile.getName())); - } - - // ***** Platform specific behavior ***** - - protected abstract String databaseVendor(); - protected abstract String databaseVersion(); - - protected abstract String driverName(); - protected abstract String driverDefinitionType(); - protected abstract String driverDefinitionId(); - protected abstract String driverClass(); - - protected abstract String getConfigName(); - - // ***** Behavior ***** - - protected void connect() { - - this.getProfile().connect(); - Assert.assertTrue( "Connect failed.", this.getProfile().isConnected()); - } - - protected void disconnect() { - - this.getProfile().disconnect(); - Assert.assertFalse( "Disconnect failed.", this.getProfile().isConnected()); - } - - // ********** queries ********** - - protected Schema getSchemaNamed( String schemaName) { - - return this.getProfile().getDatabase().schemaNamed( schemaName); - } - - protected Collection getTables() { - - Schema schema = this.getSchemaNamed( this.getProfile().getUserName()); - if( schema == null) { - return new ArrayList(); - } - return CollectionTools.collection( schema.tables()); - } - - protected Table getTableNamed( String tableName) { - - Schema schema = this.getSchemaNamed( this.getProfile().getUserName()); - Assert.assertNotNull( schema); - - return schema.tableNamed( tableName); - } - - protected String providerId() { - return DTPConnectionProfileWrapper.CONNECTION_PROFILE_TYPE; - } - - protected String passwordIsSaved() { - return "true"; - } - - protected String profileName() { - return this.platformProperties.getProperty( PROFILE_NAME_PROPERTY, PROFILE_NAME_DEFAULT); - } - - protected String profileDescription() { - return this.platformProperties.getProperty( PROFILE_DESCRIPTION_PROPERTY, PROFILE_DESCRIPTION_DEFAULT); - } - - protected String userName() { - return this.platformProperties.getProperty( USER_NAME_PROPERTY, USER_NAME_DEFAULT); - } - - protected String userPassword() { - return this.platformProperties.getProperty( USER_PASSWORD_PROPERTY, USER_PASSWORD_DEFAULT); - } - - protected String databaseName() { - return this.platformProperties.getProperty( DB_NAME_PROPERTY, DB_NAME_DEFAULT); - } - - protected String databasedriverJarList() { - String dbDriverJarList = this.platformProperties.getProperty( DB_DRIVER_JAR_PROPERTY); - if ( StringTools.stringIsEmpty( dbDriverJarList)) { - throw new NoSuchElementException( MISSING_PROPERTY_MESSAGE); - } - return dbDriverJarList; - } - - protected String databaseUrl() { - String dbUrl = this.platformProperties.getProperty( DB_URL_PROPERTY); - if ( StringTools.stringIsEmpty( dbUrl)) { - throw new NoSuchElementException( MISSING_PROPERTY_MESSAGE); - } - return dbUrl; - } - - private ConnectionProfile getProfile() { - - return this.getProfileNamed( this.profileName()); - } - - protected ConnectionProfile getProfileNamed( String profileName) { - - return ConnectionProfileRepository.instance().profileNamed( profileName); - } - - private String getTestPluginBundleId() { - return JptDbTestsPlugin.BUNDLE_ID; - } - - private IPath getDriverDefinitionLocation() { - return ConnectivityPlugin.getDefault().getStateLocation(); - } - - private String getConfigPath() { - return this.getConfigDir() + "/" + this.getConfigName(); - } - - private String getConfigDir() { - return PLATFORM_CONFIG_DIRECTORY; - } - - private boolean platformIsNew() { - return( !this.databaseVendor().equals( this.currentDbVendor) || this.databaseVersion().equals( this.currentDbVersion)); - } - - private void loadPlatformProperties() throws IOException { - - if( this.platformProperties == null) { - URL configUrl = Platform.getBundle( this.getTestPluginBundleId()).getEntry( this.getConfigPath()); - - this.platformProperties = new Properties(); - this.platformProperties.load( configUrl.openStream()); - } - } - - private Properties buildDriverProperties() { - Properties driverProperties = new Properties(); - driverProperties.setProperty( DTPConnectionProfileWrapper.DRIVER_DEFINITION_TYPE_PROP_ID, this.driverDefinitionType()); - driverProperties.setProperty( DTPConnectionProfileWrapper.DRIVER_JAR_LIST_PROP_ID, this.databasedriverJarList()); - driverProperties.setProperty( IDBDriverDefinitionConstants.USERNAME_PROP_ID, this.userName()); - driverProperties.setProperty( IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID, this.driverClass()); - driverProperties.setProperty( IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID, this.databaseName()); - driverProperties.setProperty( IDBDriverDefinitionConstants.PASSWORD_PROP_ID, this.userPassword()); - driverProperties.setProperty( IDBDriverDefinitionConstants.URL_PROP_ID, this.databaseUrl()); - driverProperties.setProperty( IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, this.databaseVendor()); - driverProperties.setProperty( IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID, this.databaseVersion()); - return driverProperties; - } - - private Properties buildBasicProperties() { - Properties basicProperties = new Properties(); - basicProperties.setProperty( IDBDriverDefinitionConstants.DATABASE_NAME_PROP_ID, this.databaseName()); - basicProperties.setProperty( IDBDriverDefinitionConstants.USERNAME_PROP_ID, this.userName()); - basicProperties.setProperty( IDBDriverDefinitionConstants.PASSWORD_PROP_ID, this.userPassword()); - basicProperties.setProperty( DTPConnectionProfileWrapper.DRIVER_DEFINITION_PROP_ID, this.driverDefinitionId()); - - basicProperties.setProperty( IDBDriverDefinitionConstants.DRIVER_CLASS_PROP_ID, this.driverClass()); - basicProperties.setProperty( IDBDriverDefinitionConstants.URL_PROP_ID, this.databaseUrl()); - basicProperties.setProperty( IDBDriverDefinitionConstants.DATABASE_VENDOR_PROP_ID, this.databaseVendor()); - basicProperties.setProperty( IDBDriverDefinitionConstants.DATABASE_VERSION_PROP_ID, this.databaseVersion()); - - basicProperties.setProperty( DTPConnectionProfileWrapper.DATABASE_SAVE_PWD_PROP_ID, this.passwordIsSaved()); - return basicProperties; - } - - private void buildConnectionProfile( String profileName) throws ConnectionProfileException { - - ProfileManager profileManager = ProfileManager.getInstance(); - Assert.assertNotNull( profileManager); - IConnectionProfile profile = profileManager.getProfileByName( profileName); - if( profile == null) { - Properties basicProperties = buildBasicProperties(); - ProfileManager.getInstance().createProfile( profileName, this.profileDescription(), this.providerId(), basicProperties); - } - } - - private void buildDriverDefinitionFile( String driverFileName) throws CoreException { - - XMLFileManager.setStorageLocation( this.getDriverDefinitionLocation()); - XMLFileManager.setFileName( driverFileName); - IPropertySet[] propsets = new IPropertySet[ 1]; - String driverName = this.driverName(); - String driverId = this.driverDefinitionId(); - PropertySetImpl propertySet = new PropertySetImpl( driverName, driverId); - propertySet.setProperties( driverId, this.buildDriverProperties()); - propsets[ 0] = propertySet; - - XMLFileManager.saveNamedPropertySet( propsets); - - File driverDefinitioneFile = this.getDriverDefinitionLocation().append( driverFileName).toFile(); - Assert.assertTrue( driverDefinitioneFile.exists()); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Derby101Tests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Derby101Tests.java deleted file mode 100644 index 7e510cfd43..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Derby101Tests.java +++ /dev/null @@ -1,64 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.tests.internal.platforms; - -import junit.framework.Test; -import junit.framework.TestSuite; -import junit.swingui.TestRunner; - -/** - * Derby 10.1 Embedded Driver Test - */ -public class Derby101Tests extends DTPPlatformTests { - - public static void main( String[] args) { - TestRunner.main( new String[] { "-c", Derby101Tests.class.getName()}); - } - - public static Test suite() { - return new TestSuite( Derby101Tests.class); - } - - public Derby101Tests( String name) { - super( name); - } - - protected String databaseVendor() { - return "Derby"; - } - - protected String databaseVersion() { - return "10.1"; - } - - protected String providerId() { - return "org.eclipse.datatools.connectivity.db.derby.embedded.connectionProfile"; - } - - protected String driverName() { - return "Derby Embedded JDBC Driver"; - } - - protected String driverDefinitionType() { - return "org.eclipse.datatools.connectivity.db.derby101.genericDriverTemplate"; - } - - protected String driverDefinitionId() { - return "DriverDefn.Derby Embedded JDBC Driver"; - } - - protected String driverClass() { - return "org.apache.derby.jdbc.EmbeddedDriver"; - } - - protected String getConfigName() { - return "derby101.properties"; - } -} diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle10gTests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle10gTests.java deleted file mode 100644 index 70d3a3d55f..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle10gTests.java +++ /dev/null @@ -1,60 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.tests.internal.platforms; - -import junit.framework.Test; -import junit.framework.TestSuite; -import junit.swingui.TestRunner; - -/** - * Oracle 10g Thin Driver Test - */ -public class Oracle10gTests extends DTPPlatformTests { - - public static void main( String[] args) { - TestRunner.main( new String[] { "-c", Oracle10gTests.class.getName()}); - } - - public static Test suite() { - return new TestSuite( Oracle10gTests.class); - } - - public Oracle10gTests( String name) { - super( name); - } - - protected String databaseVendor() { - return "Oracle"; - } - - protected String databaseVersion() { - return "10"; - } - - protected String driverClass() { - return "oracle.jdbc.OracleDriver"; - } - - protected String driverDefinitionId() { - return "DriverDefn.Oracle Thin Driver"; - } - - protected String driverDefinitionType() { - return "org.eclipse.datatools.enablement.oracle.10.driverTemplate"; - } - - protected String driverName() { - return "Oracle 10g Thin Driver"; - } - - protected String getConfigName() { - return "oracle10g.properties"; - } -} diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle9iTests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle9iTests.java deleted file mode 100644 index 3923081244..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/Oracle9iTests.java +++ /dev/null @@ -1,60 +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 - ******************************************************************************/ -package org.eclipse.jpt.db.tests.internal.platforms; - -import junit.framework.Test; -import junit.framework.TestSuite; -import junit.swingui.TestRunner; - -/** - * Oracle 9i Thin Driver Test - */ -public class Oracle9iTests extends DTPPlatformTests { - - public static void main( String[] args) { - TestRunner.main( new String[] { "-c", Oracle9iTests.class.getName()}); - } - - public static Test suite() { - return new TestSuite( Oracle9iTests.class); - } - - public Oracle9iTests( String name) { - super( name); - } - - protected String databaseVendor() { - return "Oracle"; - } - - protected String databaseVersion() { - return "9"; - } - - protected String driverClass() { - return "oracle.jdbc.OracleDriver"; - } - - protected String driverDefinitionId() { - return "DriverDefn.Oracle Thin Driver"; - } - - protected String driverDefinitionType() { - return "org.eclipse.datatools.enablement.oracle.9.driverTemplate"; - } - - protected String driverName() { - return "Oracle 9i Thin Driver"; - } - - protected String getConfigName() { - return "oracle9i.properties"; - } -} diff --git a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/SQLServer2005Tests.java b/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/SQLServer2005Tests.java deleted file mode 100644 index a0f5034f6d..0000000000 --- a/jpa/tests/org.eclipse.jpt.db.tests/src/org/eclipse/jpt/db/tests/internal/platforms/SQLServer2005Tests.java +++ /dev/null @@ -1,64 +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.db.tests.internal.platforms; - -import junit.framework.Test; -import junit.framework.TestSuite; -import junit.swingui.TestRunner; - -/** - * SQL Server 2005 Driver Test - */ -public class SQLServer2005Tests extends DTPPlatformTests { - - public static void main( String[] args) { - TestRunner.main( new String[] { "-c", SQLServer2005Tests.class.getName()}); - } - - public static Test suite() { - return new TestSuite( SQLServer2005Tests.class); - } - - public SQLServer2005Tests( String name) { - super( name); - } - - protected String databaseVendor() { - return "SQLServer"; - } - - protected String databaseVersion() { - return "2005"; - } - - protected String providerId() { - return "org.eclipse.datatools.connectivity.db.generic.connectionProfile"; - } - - protected String driverName() { - return "Microsoft SQL Server 2005 JDBC Driver"; - } - - protected String driverDefinitionType() { - return "org.eclipse.datatools.enablement.msft.sqlserver.2005.driverTemplate"; - } - - protected String driverDefinitionId() { - return "DriverDefn.Microsoft SQL Server 2005 JDBC Driver"; - } - - protected String driverClass() { - return "com.microsoft.sqlserver.jdbc.SQLServerDriver"; - } - - protected String getConfigName() { - return "sqlserver2005.properties"; - } -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/.classpath b/jpa/tests/org.eclipse.jpt.utility.tests/.classpath deleted file mode 100644 index 304e86186a..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/.cvsignore b/jpa/tests/org.eclipse.jpt.utility.tests/.cvsignore deleted file mode 100644 index ba077a4031..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -bin diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/.project b/jpa/tests/org.eclipse.jpt.utility.tests/.project deleted file mode 100644 index aa5271e003..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.eclipse.jpt.utility.tests - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/.settings/org.eclipse.core.resources.prefs b/jpa/tests/org.eclipse.jpt.utility.tests/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index c74f41d1cd..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,3 +0,0 @@ -#Sun May 27 15:11:44 EDT 2007 -eclipse.preferences.version=1 -encoding/=ISO-8859-1 diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/.settings/org.eclipse.jdt.core.prefs b/jpa/tests/org.eclipse.jpt.utility.tests/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 84b5c4c710..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,7 +0,0 @@ -#Sun May 27 14:55:58 EDT 2007 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 -org.eclipse.jdt.core.compiler.compliance=1.5 -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/jpa/tests/org.eclipse.jpt.utility.tests/META-INF/MANIFEST.MF b/jpa/tests/org.eclipse.jpt.utility.tests/META-INF/MANIFEST.MF deleted file mode 100644 index 1870613633..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/META-INF/MANIFEST.MF +++ /dev/null @@ -1,12 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: %pluginName -Bundle-Vendor: %providerName -Bundle-SymbolicName: org.eclipse.jpt.utility.tests -Bundle-Version: 1.0.0 -Bundle-Localization: plugin -Require-Bundle: org.eclipse.jpt.utility, - org.junit;bundle-version="[3.0.0,4.0.0)" -Bundle-RequiredExecutionEnvironment: J2SE-1.5 -Export-Package: org.eclipse.jpt.utility.tests.internal;x-internal:=true, - org.eclipse.jpt.utility.tests.internal.iterators;x-internal:=true diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/about.html b/jpa/tests/org.eclipse.jpt.utility.tests/about.html deleted file mode 100644 index 9e73bdabb6..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/about.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - -About - - - - - -

About This Content

- -

June 06, 2007

- -

License

- -

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 -http://www.eclipse.org/org/documents/epl-v10.php. -For purposes of the EPL, "Program" will mean the Content.

- -

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 -http://www.eclipse.org/.

- - - diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/build.properties b/jpa/tests/org.eclipse.jpt.utility.tests/build.properties deleted file mode 100644 index ebe9c08ef9..0000000000 --- a/jpa/tests/org.eclipse.jpt.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/jpa/tests/org.eclipse.jpt.utility.tests/plugin.properties b/jpa/tests/org.eclipse.jpt.utility.tests/plugin.properties deleted file mode 100644 index 9995768587..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/plugin.properties +++ /dev/null @@ -1,24 +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 -################################################################################ -# ==================================================================== -# 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 = Java Persistence API Utility Tests -providerName = Eclipse.org - diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BitToolsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BitToolsTests.java deleted file mode 100644 index ed3e6f2814..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/BitToolsTests.java +++ /dev/null @@ -1,59 +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 - ******************************************************************************/ -package org.eclipse.jpt.utility.tests.internal; - -import junit.framework.TestCase; -import org.eclipse.jpt.utility.internal.BitTools; - -public class BitToolsTests extends TestCase { - - public BitToolsTests(String name) { - super(name); - } - - 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 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 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 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 })); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClassToolsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClassToolsTests.java deleted file mode 100644 index 504b621daa..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClassToolsTests.java +++ /dev/null @@ -1,548 +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.utility.tests.internal; - -import java.lang.reflect.Array; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Vector; -import java.util.Map.Entry; -import junit.framework.TestCase; -import org.eclipse.jpt.utility.internal.ClassTools; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; - -public class ClassToolsTests extends TestCase { - - private static String testStaticField; - - public ClassToolsTests(String name) { - super(name); - } - - /** - * 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; - Field[] fields = ClassTools.allFields(java.util.Vector.class); - assertEquals(fieldCount, fields.length); - assertTrue(CollectionTools.contains(this.names(fields), "modCount")); - assertTrue(CollectionTools.contains(this.names(fields), "serialVersionUID")); - assertTrue(CollectionTools.contains(this.names(fields), "capacityIncrement")); - assertTrue(CollectionTools.contains(this.names(fields), "elementCount")); - assertTrue(CollectionTools.contains(this.names(fields), "elementData")); - assertTrue(fields[0].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; - Method[] methods = ClassTools.allMethods(java.util.Vector.class); - assertEquals(methodCount, methods.length); - assertTrue(CollectionTools.contains(this.names(methods), "wait")); - assertTrue(CollectionTools.contains(this.names(methods), "addElement")); - assertTrue(methods[0].isAccessible()); - } - - public void testNewInstanceClass() { - Vector v = ClassTools.newInstance(java.util.Vector.class); - assertNotNull(v); - assertEquals(0, v.size()); - } - - public void testNewInstanceClassClassObject() { - int initialCapacity = 200; - Vector v = ClassTools.newInstance(java.util.Vector.class, int.class, new Integer(initialCapacity)); - assertNotNull(v); - assertEquals(0, v.size()); - Object[] elementData = (Object[]) ClassTools.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 = ClassTools.newInstance(java.util.Vector.class, parmTypes, parms); - assertNotNull(v); - assertEquals(0, v.size()); - Object[] elementData = (Object[]) ClassTools.getFieldValue(v, "elementData"); - assertEquals(initialCapacity, elementData.length); - - parms[0] = new Integer(-1); - boolean exCaught = false; - try { - v = ClassTools.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 = ClassTools.attemptNewInstance(java.util.Vector.class, parmTypes, parms); - } catch (NoSuchMethodException ex) { - exCaught = true; - } - assertTrue("NoSuchMethodException not thrown", exCaught); - } - - public void testGetFieldValue() { - int initialCapacity = 200; - Vector v = new Vector(initialCapacity); - Object[] elementData = (Object[]) ClassTools.getFieldValue(v, "elementData"); - assertEquals(initialCapacity, elementData.length); - - // test inherited field - Integer modCountInteger = (Integer) ClassTools.getFieldValue(v, "modCount"); - int modCount = modCountInteger.intValue(); - assertEquals(0, modCount); - - boolean exCaught = false; - Object bogusFieldValue = null; - try { - bogusFieldValue = ClassTools.attemptToGetFieldValue(v, "bogusField"); - } catch (NoSuchFieldException ex) { - exCaught = true; - } - assertTrue("NoSuchFieldException not thrown: " + bogusFieldValue, exCaught); - } - - public void testExecuteMethodObjectString() { - Vector v = new Vector(); - int size = ((Integer) ClassTools.executeMethod(v, "size")).intValue(); - assertEquals(0, size); - - v.addElement("foo"); - size = ((Integer) ClassTools.executeMethod(v, "size")).intValue(); - assertEquals(1, size); - } - - public void testExecuteMethodObjectStringClassObject() { - Vector v = new Vector(); - boolean booleanResult = ((Boolean) ClassTools.executeMethod(v, "add", Object.class, "foo")).booleanValue(); - assertTrue(booleanResult); - assertTrue(v.contains("foo")); - Object voidResult = ClassTools.executeMethod(v, "addElement", Object.class, "bar"); - assertNull(voidResult); - } - - public void testExecuteMethodObjectStringClassArrayObjectArray() { - Vector v = new Vector(); - Class[] parmTypes = new Class[1]; - parmTypes[0] = java.lang.Object.class; - Object[] parms = new Object[1]; - parms[0] = "foo"; - boolean booleanResult = ((Boolean) ClassTools.executeMethod(v, "add", parmTypes, parms)).booleanValue(); - assertTrue(booleanResult); - assertTrue(v.contains("foo")); - - boolean exCaught = false; - Object bogusMethodReturnValue = null; - try { - bogusMethodReturnValue = ClassTools.attemptToExecuteMethod(v, "bogusMethod", parmTypes, parms); - } catch (NoSuchMethodException ex) { - exCaught = true; - } - assertTrue("NoSuchMethodException not thrown: " + bogusMethodReturnValue, exCaught); - } - - public void testExecuteStaticMethodClassString() { - Double randomObject = (Double) ClassTools.executeStaticMethod(java.lang.Math.class, "random"); - assertNotNull(randomObject); - double random = randomObject.doubleValue(); - assertTrue(random >= 0); - assertTrue(random < 1); - } - - public void testExecuteStaticMethodClassStringClassObject() { - String s = (String) ClassTools.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) ClassTools.executeStaticMethod(java.lang.String.class, "valueOf", parmTypes, parms); - assertNotNull(s); - assertEquals("true", s); - - boolean exCaught = false; - Object bogusStaticMethodReturnValue = null; - try { - bogusStaticMethodReturnValue = ClassTools.attemptToExecuteStaticMethod(java.lang.String.class, "bogusStaticMethod", parmTypes, parms); - } catch (NoSuchMethodException ex) { - exCaught = true; - } - assertTrue("NoSuchMethodException not thrown: " + bogusStaticMethodReturnValue, exCaught); - - // test non-static method - exCaught = false; - try { - bogusStaticMethodReturnValue = ClassTools.attemptToExecuteStaticMethod(java.lang.String.class, "toString"); - } catch (NoSuchMethodException ex) { - exCaught = true; - } - assertTrue("NoSuchMethodException not thrown: " + bogusStaticMethodReturnValue, exCaught); - } - - public void testSetFieldValue() { - Vector v = new Vector(); - Object[] newElementData = new Object[5]; - newElementData[0] = "foo"; - ClassTools.setFieldValue(v, "elementData", newElementData); - ClassTools.setFieldValue(v, "elementCount", new Integer(1)); - // test inherited field - ClassTools.setFieldValue(v, "modCount", new Integer(1)); - assertTrue(v.contains("foo")); - - boolean exCaught = false; - try { - ClassTools.attemptToSetFieldValue(v, "bogusField", "foo"); - } catch (NoSuchFieldException ex) { - exCaught = true; - } - assertTrue("NoSuchFieldException not thrown", exCaught); - } - - public void testSetStaticFieldValue() { - ClassTools.setStaticFieldValue(this.getClass(), "testStaticField", "new value"); - assertEquals(testStaticField, "new value"); - - boolean exCaught = false; - try { - ClassTools.attemptToSetStaticFieldValue(this.getClass(), "bogusStaticField", "new value"); - } catch (NoSuchFieldException ex) { - exCaught = true; - } - assertTrue("NoSuchFieldException not thrown", exCaught); - } - - public void testShortName() { - assertEquals("Vector", ClassTools.shortClassNameForObject(new java.util.Vector())); - assertEquals("Vector", ClassTools.shortNameFor(java.util.Vector.class)); - } - - public void testNestedName() { - Map map = new HashMap(); - map.put("foo", "bar"); - Entry entry = map.entrySet().iterator().next(); - assertEquals("Entry", ClassTools.nestedClassNameForObject(entry)); - assertEquals("Entry", ClassTools.nestedNameFor(java.util.Map.Entry.class)); - } - - public void testPackageName() { - assertEquals("java.util", ClassTools.packageNameFor(java.util.Vector.class)); - assertEquals("java.util", ClassTools.packageNameFor(java.util.Map.Entry.class)); - } - - public void testArrayDepthFor() { - assertEquals(0, ClassTools.arrayDepthFor(java.util.Vector.class)); - assertEquals(0, ClassTools.arrayDepthFor(int.class)); - assertEquals(0, ClassTools.arrayDepthFor(void.class)); - assertEquals(1, ClassTools.arrayDepthFor(java.util.Vector[].class)); - assertEquals(1, ClassTools.arrayDepthFor(int[].class)); - assertEquals(3, ClassTools.arrayDepthFor(java.util.Vector[][][].class)); - assertEquals(3, ClassTools.arrayDepthFor(int[][][].class)); - } - - public void testArrayDepthForObject() { - assertEquals(0, ClassTools.arrayDepthForObject(new java.util.Vector())); - assertEquals(1, ClassTools.arrayDepthForObject(new java.util.Vector[0])); - assertEquals(1, ClassTools.arrayDepthForObject(new int[0])); - assertEquals(3, ClassTools.arrayDepthForObject(new java.util.Vector[0][0][0])); - assertEquals(3, ClassTools.arrayDepthForObject(new int[0][0][0])); - } - - public void testArrayDepthForClassNamed() { - assertEquals(0, ClassTools.arrayDepthForClassNamed(java.util.Vector.class.getName())); - assertEquals(0, ClassTools.arrayDepthForClassNamed(int.class.getName())); - assertEquals(0, ClassTools.arrayDepthForClassNamed(void.class.getName())); - assertEquals(1, ClassTools.arrayDepthForClassNamed(java.util.Vector[].class.getName())); - assertEquals(1, ClassTools.arrayDepthForClassNamed(int[].class.getName())); - assertEquals(3, ClassTools.arrayDepthForClassNamed(java.util.Vector[][][].class.getName())); - assertEquals(3, ClassTools.arrayDepthForClassNamed(int[][][].class.getName())); - } - - public void testElementTypeFor() { - assertEquals(java.util.Vector.class, ClassTools.elementTypeFor(java.util.Vector.class)); - assertEquals(int.class, ClassTools.elementTypeFor(int.class)); - assertEquals(void.class, ClassTools.elementTypeFor(void.class)); - assertEquals(java.util.Vector.class, ClassTools.elementTypeFor(java.util.Vector[].class)); - assertEquals(int.class, ClassTools.elementTypeFor(int[].class)); - assertEquals(java.util.Vector.class, ClassTools.elementTypeFor(java.util.Vector[][][].class)); - assertEquals(int.class, ClassTools.elementTypeFor(int[][][].class)); - } - - public void testElementTypeForObject() { - assertEquals(java.util.Vector.class, ClassTools.elementTypeForObject(new java.util.Vector())); - assertEquals(java.util.Vector.class, ClassTools.elementTypeForObject(new java.util.Vector[0])); - assertEquals(int.class, ClassTools.elementTypeForObject(new int[0])); - assertEquals(java.util.Vector.class, ClassTools.elementTypeForObject(new java.util.Vector[0][0][0])); - assertEquals(int.class, ClassTools.elementTypeForObject(new int[0][0][0])); - } - - public void testElementTypeNameFor() { - assertEquals(java.util.Vector.class.getName(), ClassTools.elementTypeNameFor(java.util.Vector.class)); - assertEquals(int.class.getName(), ClassTools.elementTypeNameFor(int.class)); - assertEquals(void.class.getName(), ClassTools.elementTypeNameFor(void.class)); - assertEquals(java.util.Vector.class.getName(), ClassTools.elementTypeNameFor(java.util.Vector[].class)); - assertEquals(int.class.getName(), ClassTools.elementTypeNameFor(int[].class)); - assertEquals(java.util.Vector.class.getName(), ClassTools.elementTypeNameFor(java.util.Vector[][][].class)); - assertEquals(int.class.getName(), ClassTools.elementTypeNameFor(int[][][].class)); - } - - public void testElementTypeNameForClassNamed() { - assertEquals(java.util.Vector.class.getName(), ClassTools.elementTypeNameForClassNamed(java.util.Vector.class.getName())); - assertEquals(int.class.getName(), ClassTools.elementTypeNameForClassNamed(int.class.getName())); - assertEquals(void.class.getName(), ClassTools.elementTypeNameForClassNamed(void.class.getName())); - assertEquals(java.util.Vector.class.getName(), ClassTools.elementTypeNameForClassNamed(java.util.Vector[].class.getName())); - assertEquals(int.class.getName(), ClassTools.elementTypeNameForClassNamed(int[].class.getName())); - assertEquals(java.util.Vector.class.getName(), ClassTools.elementTypeNameForClassNamed(java.util.Vector[][][].class.getName())); - assertEquals(int.class.getName(), ClassTools.elementTypeNameForClassNamed(int[][][].class.getName())); - } - - public void testClassCodes() { - assertEquals("byte", ClassTools.classNameForCode('B')); - assertEquals("char", ClassTools.classNameForCode('C')); - assertEquals("double", ClassTools.classNameForCode('D')); - assertEquals("float", ClassTools.classNameForCode('F')); - assertEquals("int", ClassTools.classNameForCode('I')); - assertEquals("long", ClassTools.classNameForCode('J')); - assertEquals("short", ClassTools.classNameForCode('S')); - assertEquals("boolean", ClassTools.classNameForCode('Z')); - assertEquals("void", ClassTools.classNameForCode('V')); - - boolean exCaught = false; - try { - ClassTools.classNameForCode('X'); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue("IllegalArgumentException not thrown", exCaught); - } - - public void testClassNamedIsTopLevel() throws Exception { - assertTrue(ClassTools.classNamedIsTopLevel(java.util.Map.class.getName())); // top-level - assertFalse(ClassTools.classNamedIsTopLevel(java.util.Map.Entry.class.getName())); // member - assertFalse(ClassTools.classNamedIsTopLevel(Class.forName(munge(this.getClass().getName() + "$1$LocalClass")).getName())); // local - assertFalse(ClassTools.classNamedIsTopLevel(Class.forName("java.util.Vector$1").getName())); // anonymous - - Object[] array = new java.util.Map[0]; // top-level - assertFalse(ClassTools.classNamedIsTopLevel(array.getClass().getName())); - array = new java.util.Map.Entry[0]; // member - assertFalse(ClassTools.classNamedIsTopLevel(array.getClass().getName())); - Class localClass = Class.forName(munge(this.getClass().getName() + "$1$LocalClass")); // local - array = (Object[]) Array.newInstance(localClass, 0); - assertFalse(ClassTools.classNamedIsTopLevel(array.getClass().getName())); - Class anonClass = Class.forName("java.util.Vector$1"); // local - array = (Object[]) Array.newInstance(anonClass, 0); - assertFalse(ClassTools.classNamedIsTopLevel(array.getClass().getName())); - } - - public void testClassNamedIsMember() throws Exception { - assertFalse(ClassTools.classNamedIsMember(java.util.Map.class.getName())); // top-level - assertTrue(ClassTools.classNamedIsMember(java.util.Map.Entry.class.getName())); // member - assertFalse(ClassTools.classNamedIsMember(Class.forName(munge(this.getClass().getName() + "$1$LocalClass")).getName())); // local - assertFalse(ClassTools.classNamedIsMember(Class.forName("java.util.Vector$1").getName())); // anonymous - - Object[] array = new java.util.Map[0]; // top-level - assertFalse(ClassTools.classNamedIsMember(array.getClass().getName())); - array = new java.util.Map.Entry[0]; // member - assertFalse(ClassTools.classNamedIsMember(array.getClass().getName())); - Class localClass = Class.forName(munge(this.getClass().getName() + "$1$LocalClass")); // local - array = (Object[]) Array.newInstance(localClass, 0); - assertFalse(ClassTools.classNamedIsMember(array.getClass().getName())); - Class anonClass = Class.forName("java.util.Vector$1"); // local - array = (Object[]) Array.newInstance(anonClass, 0); - assertFalse(ClassTools.classNamedIsMember(array.getClass().getName())); - - // test a few edge cases - assertTrue(ClassTools.classNamedIsMember("java.util.Map$a1")); - assertTrue(ClassTools.classNamedIsMember("java.util.Map$a1$aaa$bbb")); - assertFalse(ClassTools.classNamedIsMember("java.util.Map$1a1$aaa")); - assertFalse(ClassTools.classNamedIsMember("java.util.Map$1a")); - assertTrue(ClassTools.classNamedIsMember("java.util.Map$a12345$b12345")); - assertFalse(ClassTools.classNamedIsMember("java.util.Map$12345a")); - assertFalse(ClassTools.classNamedIsMember("java.util.Map$333")); - assertFalse(ClassTools.classNamedIsMember("java.util.Map3$333")); - } - - public void testClassNamedIsLocal() throws Exception { - class LocalClass { - void foo() { - System.getProperty("foo"); - } - } - new LocalClass().foo(); - assertFalse(ClassTools.classNamedIsLocal(java.util.Map.class.getName())); // top-level - assertFalse(ClassTools.classNamedIsLocal(java.util.Map.Entry.class.getName())); // member - assertTrue(ClassTools.classNamedIsLocal(Class.forName(munge(this.getClass().getName() + "$1$LocalClass")).getName())); // local - assertFalse(ClassTools.classNamedIsLocal(Class.forName("java.util.Vector$1").getName())); // anonymous - - Object[] array = new java.util.Map[0]; // top-level - assertFalse(ClassTools.classNamedIsLocal(array.getClass().getName())); - array = new java.util.Map.Entry[0]; // member - assertFalse(ClassTools.classNamedIsLocal(array.getClass().getName())); - Class localClass = Class.forName(munge(this.getClass().getName() + "$1$LocalClass")); // local - array = (Object[]) Array.newInstance(localClass, 0); - assertFalse(ClassTools.classNamedIsLocal(array.getClass().getName())); - Class anonClass = Class.forName("java.util.Vector$1"); // local - array = (Object[]) Array.newInstance(anonClass, 0); - assertFalse(ClassTools.classNamedIsLocal(array.getClass().getName())); - - // test a few edge cases - assertFalse(ClassTools.classNamedIsLocal("java.util.Map$a1")); - assertFalse(ClassTools.classNamedIsLocal("java.util.Map$a1$aaa$bbb")); - assertTrue(ClassTools.classNamedIsLocal("java.util.Map$11$aaa")); - assertTrue(ClassTools.classNamedIsLocal("java.util.Map$1$a")); // eclipse naming convention - assertTrue(ClassTools.classNamedIsLocal("java.util.Map$2$abc")); // eclipse naming convention - assertTrue(ClassTools.classNamedIsLocal("java.util.Map$2$abc1")); // eclipse naming convention - assertTrue(ClassTools.classNamedIsLocal("java.util.Map$1a")); // jdk naming convention - assertTrue(ClassTools.classNamedIsLocal("java.util.Map$2abc")); // jdk naming convention - assertTrue(ClassTools.classNamedIsLocal("java.util.Map$2abc1")); // jdk naming convention - assertFalse(ClassTools.classNamedIsLocal("java.util.Map$a12345$b12345")); - assertTrue(ClassTools.classNamedIsLocal("java.util.Map$12345$a1234")); - assertFalse(ClassTools.classNamedIsLocal("java.util.Map$333")); - assertFalse(ClassTools.classNamedIsLocal("java.util.Map3$333")); - } - - public void testClassNamedIsAnonymous() throws Exception { - assertFalse(ClassTools.classNamedIsAnonymous(java.util.Map.class.getName())); // top-level - assertFalse(ClassTools.classNamedIsAnonymous(java.util.Map.Entry.class.getName())); // member - assertFalse(ClassTools.classNamedIsAnonymous(Class.forName(munge(this.getClass().getName() + "$1$LocalClass")).getName())); // local - assertTrue(ClassTools.classNamedIsAnonymous(Class.forName("java.util.Vector$1").getName())); // anonymous - - Object[] array = new java.util.Map[0]; // top-level - assertFalse(ClassTools.classNamedIsAnonymous(array.getClass().getName())); - array = new java.util.Map.Entry[0]; // member - assertFalse(ClassTools.classNamedIsAnonymous(array.getClass().getName())); - Class localClass = Class.forName(munge(this.getClass().getName() + "$1$LocalClass")); // local - array = (Object[]) Array.newInstance(localClass, 0); - assertFalse(ClassTools.classNamedIsAnonymous(array.getClass().getName())); - Class anonClass = Class.forName("java.util.Vector$1"); // local - array = (Object[]) Array.newInstance(anonClass, 0); - assertFalse(ClassTools.classNamedIsAnonymous(array.getClass().getName())); - - // test a few edge cases - assertFalse(ClassTools.classNamedIsAnonymous("java.util.Map$a1")); - assertFalse(ClassTools.classNamedIsAnonymous("java.util.Map$a1$aaa$bbb")); - assertFalse(ClassTools.classNamedIsAnonymous("java.util.Map$1a1$aaa")); - assertFalse(ClassTools.classNamedIsAnonymous("java.util.Map$1$a")); - assertFalse(ClassTools.classNamedIsAnonymous("java.util.Map$1a")); - assertFalse(ClassTools.classNamedIsAnonymous("java.util.Map$a12345$b12345")); - assertFalse(ClassTools.classNamedIsAnonymous("java.util.Map$12345$a1234")); - assertTrue(ClassTools.classNamedIsAnonymous("java.util.Map$333")); - assertTrue(ClassTools.classNamedIsAnonymous("java.util.Map3$333")); - } - - public void testCodeForClass() { - assertEquals('I', ClassTools.codeForClass(int.class)); - assertEquals('B', ClassTools.codeForClass(byte.class)); - } - - public void testCodeForClassNamed() { - assertEquals('I', ClassTools.codeForClassNamed(int.class.getName())); - assertEquals('I', ClassTools.codeForClassNamed("int")); - assertEquals('B', ClassTools.codeForClassNamed(byte.class.getName())); - assertEquals('B', ClassTools.codeForClassNamed("byte")); - } - - public void testClassForTypeDeclaration() throws Exception { - assertEquals(int.class, ClassTools.classForTypeDeclaration("int", 0)); - assertEquals(int[].class, ClassTools.classForTypeDeclaration("int", 1)); - assertEquals(int[][][].class, ClassTools.classForTypeDeclaration("int", 3)); - - assertEquals(Object.class, ClassTools.classForTypeDeclaration("java.lang.Object", 0)); - assertEquals(Object[][][].class, ClassTools.classForTypeDeclaration("java.lang.Object", 3)); - - assertEquals(void.class, ClassTools.classForTypeDeclaration("void", 0)); - try { - ClassTools.classForTypeDeclaration(void.class.getName(), 1); - fail("should not get here..."); - } catch (ClassNotFoundException ex) { - // expected - } - } - - public void testClassNameForTypeDeclaration() throws Exception { - assertEquals(int.class.getName(), ClassTools.classNameForTypeDeclaration("int", 0)); - assertEquals(int[].class.getName(), ClassTools.classNameForTypeDeclaration("int", 1)); - assertEquals(int[][][].class.getName(), ClassTools.classNameForTypeDeclaration("int", 3)); - - assertEquals(Object.class.getName(), ClassTools.classNameForTypeDeclaration("java.lang.Object", 0)); - assertEquals(Object[][][].class.getName(), ClassTools.classNameForTypeDeclaration("java.lang.Object", 3)); - - assertEquals(void.class.getName(), ClassTools.classNameForTypeDeclaration("void", 0)); - try { - ClassTools.classNameForTypeDeclaration(void.class.getName(), 1); - fail("should not get here..."); - } catch (IllegalArgumentException ex) { - // expected - } - } - - private Iterator names(Field[] fields) { - return new TransformationIterator(CollectionTools.iterator(fields)) { - @Override - protected String transform(Field field) { - return field.getName(); - } - }; - } - - private Iterator names(Method[] methods) { - return new TransformationIterator(CollectionTools.iterator(methods)) { - @Override - protected String transform(Method method) { - return method.getName(); - } - }; - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClasspathTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClasspathTests.java deleted file mode 100644 index 54beea0c81..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ClasspathTests.java +++ /dev/null @@ -1,289 +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.utility.tests.internal; - -import java.io.File; -import java.io.IOException; -import java.net.URL; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import junit.framework.TestCase; -import org.eclipse.jpt.utility.internal.Classpath; -import org.eclipse.jpt.utility.internal.CollectionTools; - -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().path(); - 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().path(); - 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().path(); - 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().path(); - 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().path(); - 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().path(); - 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().path(); - 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().path(); - 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().path(); - 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().path(); - 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 testConvertToClassFileName() { - char sc = File.separatorChar; - String fileName = Classpath.convertToClassFileName(java.lang.String.class); - assertEquals("java" + sc + "lang" + sc + "String.class", fileName); - } - - public void testConvertToJavaFileName() { - char sc = File.separatorChar; - String fileName = Classpath.convertToJavaFileName(java.lang.String.class.getName()); - assertEquals("java" + sc + "lang" + sc + "String.java", fileName); - } - - public void testConvertToURLs() { - 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")).urls(); - int i = 0; - assertEquals(this.morphURL("/C:/jdk/rt.jar"), entries[i++].getPath()); - assertEquals(this.morphURL("/C:/jdk/i18n.jar"), entries[i++].getPath()); - assertEquals(this.morphURL("/C:/jdk/jaws.jar"), entries[i++].getPath()); - assertEquals(this.morphURL("/C:/foo/classes"), entries[i++].getPath()); - assertEquals(this.morphURL("/C:/bar/bar.jar"), entries[i++].getPath()); - assertEquals(i, entries.length); - } - - public void testEntries() { - 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;")); - Classpath.Entry[] entries = cp.getEntries(); - int i = 0; - assertEquals(this.morph("C:\\jdk\\rt.jar"), entries[i++].fileName()); - assertEquals(this.morph("."), entries[i++].fileName()); - assertEquals(this.morph("C:\\jdk\\i18n.jar"), entries[i++].fileName()); - assertEquals(this.morph("C:\\jdk\\jaws.jar"), entries[i++].fileName()); - assertEquals(this.morph("C:\\foo\\classes"), entries[i++].fileName()); - assertEquals(this.morph("C:\\bar\\bar.jar"), entries[i++].fileName()); - assertEquals(this.morph("C:\\bar\\bar.jar"), entries[i++].fileName()); - assertEquals(i, entries.length); - - cp = cp.compressed(); - entries = cp.getEntries(); - i = 0; - assertEquals(this.morph("C:\\jdk\\rt.jar"), entries[i++].fileName()); - assertEquals(this.morph("."), entries[i++].fileName()); - assertEquals(this.morph("C:\\jdk\\i18n.jar"), entries[i++].fileName()); - assertEquals(this.morph("C:\\jdk\\jaws.jar"), entries[i++].fileName()); - assertEquals(this.morph("C:\\foo\\classes"), entries[i++].fileName()); - assertEquals(this.morph("C:\\bar\\bar.jar"), entries[i++].fileName()); - assertEquals(i, entries.length); - } - - public void testEntryForFileNamed() { - 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")).entryForFileNamed("rt.jar"); - assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.fileName()); - - // 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")).entryForFileNamed("rt.jar"); - assertEquals("rt.jar", entry.fileName()); - - // 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")).entryForFileNamed("rt.jar"); - assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.fileName()); - - // 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")).entryForFileNamed("rt.jar"); - assertEquals("rt.jar", entry.fileName()); - - // 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")).entryForFileNamed("rt.jar"); - assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.fileName()); - - // 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")).entryForFileNamed("rt.jar"); - assertEquals("rt.jar", entry.fileName()); - - // alone - qualified - entry = new Classpath(this.morph("C:\\jdk\\rt.jar")).entryForFileNamed("rt.jar"); - assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.fileName()); - - // alone - unqualified - entry = new Classpath("rt.jar").entryForFileNamed("rt.jar"); - assertEquals("rt.jar", entry.fileName()); - - // 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")).entryForFileNamed("rt.jar"); - assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.fileName()); - - // 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")).entryForFileNamed("rt.jar"); - assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.fileName()); - - // 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")).entryForFileNamed("rt.jar"); - assertEquals(this.morph("C:\\jdk\\rt.jar"), entry.fileName()); - - // 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")).entryForFileNamed("rt.jar"); - assertEquals("path entry should not be found", null, entry); - - } - - 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().classNames(), java.util.Vector.class.getName())); - assertTrue("File is missing from JRE class names", CollectionTools.contains(Classpath.bootClasspath().classNames(), 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, CollectionTools.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(), CollectionTools.contains(Classpath.javaExtensionDirectories(), stdExtDir)); - } - - //Commented out due to incompatibility with IBM JDK (used in Eclipse WTP Build) - //TODO Test should be revised to be compatible with IBM JDK - // public void testJavaExtensionClasspathEntries() { - // char sep = File.separatorChar; - // String jdk = System.getProperty("java.version"); - // if (jdk.startsWith("1.4") || jdk.startsWith("1.5")) { - // Collection jarNames = new ArrayList(); - // Classpath.Entry[] entries = Classpath.javaExtensionClasspath().getEntries(); - // for (int i = 0; i < entries.length; i++) { - // jarNames.add(entries[i].fileName()); - // } - // String stdExtJarName = JAVA_HOME + sep + "lib" + sep + "ext" + sep + "dnsns.jar"; - // assertTrue("jdk 1.4.x standard extension jar missing: " + stdExtJarName, jarNames.contains(stdExtJarName)); - // } else { - // fail("we need to update this test for the current jdk"); - // } - // } - - //Commented out due to incompatibility with IBM JDK (used in Eclipse WTP Build) - //TODO Test should be revised to be compatible with IBM JDK - // public void testJavaExtensionClassNames() { - // String jdk = System.getProperty("java.version"); - // if (jdk.startsWith("1.4") || jdk.startsWith("1.5")) { - // String className = "sun.net.spi.nameservice.dns.DNSNameService"; - // assertTrue("jdk 1.4.x standard extension class missing: " + className, - // CollectionTools.contains(Classpath.javaExtensionClasspath().classNames(), className)); - // } 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().classNames(), className)); - } - } - - /** - * 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 (!CollectionTools.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 (!CollectionTools.contains(File.listRoots(), new File("C:\\"))) { - result = result.replaceAll("/C:", ""); - } - return result; - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CollectionToolsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CollectionToolsTests.java deleted file mode 100644 index 29da4a7d7d..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/CollectionToolsTests.java +++ /dev/null @@ -1,1990 +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.utility.tests.internal; - -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.List; -import java.util.ListIterator; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; -import java.util.Vector; -import junit.framework.TestCase; -import org.eclipse.jpt.utility.internal.Bag; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.HashBag; -import org.eclipse.jpt.utility.internal.Range; -import org.eclipse.jpt.utility.internal.ReverseComparator; -import org.eclipse.jpt.utility.internal.iterators.ArrayIterator; -import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; - -public class CollectionToolsTests extends TestCase { - - public CollectionToolsTests(String name) { - super(name); - } - - public void testAddObjectArrayObject1() { - Object[] a = CollectionTools.add(this.buildObjectArray1(), "twenty"); - assertEquals(4, a.length); - assertTrue(CollectionTools.contains(a, "twenty")); - assertEquals("twenty", a[a.length-1]); - } - - public void testAddObjectArrayObject2() { - String[] a = CollectionTools.add(this.buildStringArray1(), "twenty"); - assertEquals(4, a.length); - assertTrue(CollectionTools.contains(a, "twenty")); - assertEquals("twenty", a[a.length-1]); - } - - public void testAddObjectArrayIntObject1() { - Object[] a = new Object[] { "a", "b", "c", "d" }; - a = CollectionTools.add(a, 2, "X"); - assertEquals(5, a.length); - assertTrue(CollectionTools.contains(a, "X")); - assertTrue(Arrays.equals(new Object[] { "a", "b", "X", "c", "d" }, a)); - } - - public void testAddObjectArrayIntObject2() { - String[] a = new String[] { "a", "b", "c", "d" }; - a = CollectionTools.add(a, 2, "X"); - assertEquals(5, a.length); - assertTrue(CollectionTools.contains(a, "X")); - assertTrue(Arrays.equals(new String[] { "a", "b", "X", "c", "d" }, a)); - } - - public void testAddObjectArrayIntObjectException() { - Object[] a = new Object[] { "a", "b", "c", "d" }; - boolean exCaught = false; - try { - a = CollectionTools.add(a, 33, "X"); - } catch (IndexOutOfBoundsException ex) { - exCaught = true; - } - assertTrue(exCaught); - } - - public void testAddCharArrayChar() { - char[] a = CollectionTools.add(this.buildCharArray(), 'd'); - assertEquals(4, a.length); - assertTrue(CollectionTools.contains(a, 'd')); - } - - public void testAddCharArrayIntChar() { - char[] a = new char[] { 'a', 'b', 'c', 'd' }; - a = CollectionTools.add(a, 2, 'X'); - assertEquals(5, a.length); - assertTrue(CollectionTools.contains(a, 'X')); - assertTrue(Arrays.equals(new char[] { 'a', 'b', 'X', 'c', 'd' }, a)); - } - - public void testAddIntArrayInt() { - int[] a = CollectionTools.add(this.buildIntArray(), 30); - assertEquals(4, a.length); - assertTrue(CollectionTools.contains(a, 30)); - } - - public void testAddIntArrayIntInt() { - int[] a = new int[] { 1, 2, 3, 4 }; - a = CollectionTools.add(a, 2, 99); - assertEquals(5, a.length); - assertTrue(CollectionTools.contains(a, 99)); - assertTrue(Arrays.equals(new int[] { 1, 2, 99, 3, 4 }, a)); - } - - public void testAddAllCollectionIterator1() { - List l1 = this.buildStringList1(); - List l2 = this.buildStringList2(); - Set s1 = this.buildStringSet1(); - List l3 = this.buildStringList1(); // same elements as s1 - - assertTrue(CollectionTools.addAll(l1, l2.iterator())); - assertEquals(6, l1.size()); - assertTrue(l1.containsAll(l2)); - - assertFalse(CollectionTools.addAll(s1, l3.iterator())); - assertEquals(3, s1.size()); - assertTrue(s1.containsAll(l3)); - } - - public void testAddAllCollectionIterator2() { - List l1 = this.buildObjectList1(); - List l2 = this.buildStringList2(); - Set s1 = this.buildObjectSet1(); - List l3 = this.buildStringList1(); // same elements as s1 - - assertTrue(CollectionTools.addAll(l1, l2.iterator())); - assertEquals(6, l1.size()); - assertTrue(l1.containsAll(l2)); - - assertFalse(CollectionTools.addAll(s1, l3.iterator())); - assertEquals(3, s1.size()); - assertTrue(s1.containsAll(l3)); - } - - public void testAddAllCollectionObjectArray1() { - List l = this.buildStringList1(); - String[] a = this.buildStringArray1(); - Set s = this.buildStringSet1(); - - assertTrue(CollectionTools.addAll(l, a)); - assertEquals(6, l.size()); - assertTrue(l.containsAll(CollectionTools.collection(a))); - - assertFalse(CollectionTools.addAll(s, a)); - assertEquals(3, s.size()); - assertTrue(s.containsAll(CollectionTools.collection(a))); - } - - public void testAddAllCollectionObjectArray2() { - List l = this.buildObjectList1(); - String[] a = this.buildStringArray1(); - Set s = this.buildObjectSet1(); - - assertTrue(CollectionTools.addAll(l, a)); - assertEquals(6, l.size()); - assertTrue(l.containsAll(CollectionTools.collection(a))); - - assertFalse(CollectionTools.addAll(s, a)); - assertEquals(3, s.size()); - assertTrue(s.containsAll(CollectionTools.collection(a))); - } - - public void testAddAllObjectArrayCollection1() { - String[] a = this.buildStringArray1(); - Collection c = this.buildStringList2(); - String[] newArray = CollectionTools.addAll(a, c); - - assertEquals(6, newArray.length); - assertTrue(CollectionTools.containsAll(newArray, c)); - } - - public void testAddAllObjectArrayCollection2() { - Object[] a = this.buildObjectArray1(); - Collection c = this.buildStringList2(); - Object[] newArray = CollectionTools.addAll(a, c); - - assertEquals(6, newArray.length); - assertTrue(CollectionTools.containsAll(newArray, c)); - } - - public void testAddAllObjectArrayIterator1() { - String[] a = this.buildStringArray1(); - Iterator i = this.buildStringList1().iterator(); - String[] newArray = CollectionTools.addAll(a, i); - - assertEquals(6, newArray.length); - assertTrue(CollectionTools.containsAll(newArray, this.buildStringList1())); - } - - public void testAddAllObjectArrayIterator2() { - String[] a = this.buildStringArray1(); - Iterator i = this.buildObjectList1().iterator(); - Object[] newArray = CollectionTools.addAll(a, i); - - assertEquals(6, newArray.length); - assertTrue(CollectionTools.containsAll(newArray, this.buildObjectList1())); - } - - public void testAddAllObjectArrayObjectArray1() { - Object[] a1 = this.buildObjectArray1(); - Object[] a2 = this.buildObjectArray2(); - Object[] newArray = CollectionTools.addAll(a1, a2); - - assertEquals(6, newArray.length); - assertTrue(CollectionTools.containsAll(newArray, a1)); - assertTrue(CollectionTools.containsAll(newArray, a2)); - } - - public void testAddAllObjectArrayObjectArray2() { - String[] a1 = this.buildStringArray1(); - String[] a2 = this.buildStringArray2(); - String[] newArray = CollectionTools.addAll(a1, a2); - - assertEquals(6, newArray.length); - assertTrue(CollectionTools.containsAll(newArray, a1)); - assertTrue(CollectionTools.containsAll(newArray, a2)); - } - - public void testAddAllObjectArrayObjectArray3() { - Object[] a1 = this.buildObjectArray1(); - String[] a2 = this.buildStringArray2(); - Object[] newArray = CollectionTools.addAll(a1, a2); - - assertEquals(6, newArray.length); - assertTrue(CollectionTools.containsAll(newArray, a1)); - assertTrue(CollectionTools.containsAll(newArray, a2)); - } - - public void testAddAllObjectArrayIntObjectArray1() { - Object[] a = new Object[] { "a", "b", "c", "d" }; - a = CollectionTools.addAll(a, 2, new Object[] { "X", "X", "X" }); - assertEquals(7, a.length); - assertTrue(CollectionTools.contains(a, "X")); - assertTrue(Arrays.equals(new Object[] { "a", "b", "X", "X", "X", "c", "d" }, a)); - } - - public void testAddAllObjectArrayIntObjectArray2() { - String[] a = new String[] { "a", "b", "c", "d" }; - a = CollectionTools.addAll(a, 2, new String[] { "X", "X", "X" }); - assertEquals(7, a.length); - assertTrue(CollectionTools.contains(a, "X")); - assertTrue(Arrays.equals(new String[] { "a", "b", "X", "X", "X", "c", "d" }, a)); - } - - public void testAddAllObjectArrayIntObjectArray3() { - Object[] a = new Object[] { "a", "b", "c", "d" }; - a = CollectionTools.addAll(a, 2, new String[] { "X", "X", "X" }); - assertEquals(7, a.length); - assertTrue(CollectionTools.contains(a, "X")); - assertTrue(Arrays.equals(new Object[] { "a", "b", "X", "X", "X", "c", "d" }, a)); - } - - public void testAddAllCharArrayCharArray() { - char[] a = CollectionTools.addAll(this.buildCharArray(), new char[] { 'd', 'e' }); - assertEquals(5, a.length); - assertTrue(CollectionTools.contains(a, 'd')); - assertTrue(CollectionTools.contains(a, 'e')); - } - - public void testAddAllCharArrayIntCharArray() { - char[] a = new char[] { 'a', 'b', 'c', 'd' }; - a = CollectionTools.addAll(a, 2, new char[] { 'X', 'X', 'X' }); - assertEquals(7, a.length); - assertTrue(CollectionTools.contains(a, 'X')); - assertTrue(Arrays.equals(new char[] { 'a', 'b', 'X', 'X', 'X', 'c', 'd' }, a)); - } - - public void testAddAllIntArrayIntArray() { - int[] a = CollectionTools.addAll(this.buildIntArray(), new int[] { 30, 40 }); - assertEquals(5, a.length); - assertTrue(CollectionTools.contains(a, 30)); - assertTrue(CollectionTools.contains(a, 40)); - } - - public void testAddAllIntArrayIntIntArray() { - int[] a = new int[] { 1, 2, 3, 4 }; - a = CollectionTools.addAll(a, 2, new int[] { 99, 99, 99 }); - assertEquals(7, a.length); - assertTrue(CollectionTools.contains(a, 99)); - assertTrue(Arrays.equals(new int[] { 1, 2, 99, 99, 99, 3, 4 }, a)); - } - - public void testArrayIterator() { - Object[] a = CollectionTools.array(this.buildStringList1().iterator()); - assertEquals(3, a.length); - assertTrue(CollectionTools.containsAll(a, this.buildStringList1().iterator())); - } - - public void testArrayIteratorObjectArray1() { - String[] a = CollectionTools.array(this.buildStringList1().iterator(), new String[0]); - assertEquals(3, a.length); - assertTrue(CollectionTools.containsAll(a, this.buildStringList1().iterator())); - } - - public void testArrayIteratorObjectArray2() { - Object[] a = CollectionTools.array(this.buildStringList1().iterator(), new Object[0]); - assertEquals(3, a.length); - assertTrue(CollectionTools.containsAll(a, this.buildStringList1().iterator())); - } - - public void testBagEnumeration1() { - Bag b = CollectionTools.bag(this.buildStringVector1().elements()); - assertEquals(3, b.size()); - assertTrue(b.containsAll(this.buildStringVector1())); - } - - public void testBagEnumeration2() { - Bag b = CollectionTools.bag(this.buildStringVector1().elements()); - assertEquals(3, b.size()); - assertTrue(b.containsAll(this.buildStringVector1())); - } - - public void testBagIterator1() { - Bag b = CollectionTools.bag(this.buildStringList1().iterator()); - assertEquals(3, b.size()); - assertTrue(b.containsAll(this.buildStringList1())); - } - - public void testBagIterator2() { - Collection c = new ArrayList(); - c.add("zero"); - c.add("one"); - c.add("two"); - c.add("three"); - Bag b = CollectionTools.bag(c.iterator()); - assertEquals(4, b.size()); - assertTrue(b.containsAll(c)); - } - - public void testBagObjectArray1() { - Bag b = CollectionTools.bag(this.buildStringArray1()); - assertEquals(3, b.size()); - assertTrue(CollectionTools.containsAll(b, this.buildStringArray1())); - } - - public void testBagObjectArray2() { - Bag b = CollectionTools.bag("foo", "bar", "baz"); - assertEquals(3, b.size()); - assertTrue(CollectionTools.containsAll(b, new Object[]{"foo", "bar", "baz"})); - } - - public void testCollectionEnumeration1() { - Collection c = CollectionTools.collection(this.buildStringVector1().elements()); - assertEquals(3, c.size()); - assertTrue(c.containsAll(this.buildStringVector1())); - } - - public void testCollectionEnumeration2() { - Collection c = CollectionTools.collection(this.buildStringVector1().elements()); - assertEquals(3, c.size()); - assertTrue(c.containsAll(this.buildStringVector1())); - } - - public void testCollectionIterator1() { - Collection c = CollectionTools.collection(this.buildStringList1().iterator()); - assertEquals(3, c.size()); - assertTrue(c.containsAll(this.buildStringList1())); - } - - public void testCollectionIterator2() { - Collection c = CollectionTools.collection(this.buildStringList1().iterator()); - assertEquals(3, c.size()); - assertTrue(c.containsAll(this.buildStringList1())); - } - - public void testCollectionObjectArray() { - Collection c = CollectionTools.collection(this.buildStringArray1()); - assertEquals(3, c.size()); - assertTrue(CollectionTools.containsAll(c, this.buildStringArray1())); - } - - public void testContainsEnumerationObject1() { - Vector 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 testContainsEnumerationObject2() { - Vector c = new Vector(); - 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 testContainsIteratorObject1() { - Collection 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 testContainsIteratorObject2() { - Collection c = new HashBag(); - 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)); - } - - public void testContainsObjectArrayObject() { - Object[] a = this.buildObjectArray1(); - assertTrue(CollectionTools.contains(a, "one")); - assertFalse(CollectionTools.contains(a, null)); - Object[] a2 = CollectionTools.add(a, null); - assertTrue(CollectionTools.contains(a2, null)); - } - - public void testContainsCharArrayChar() { - char[] a = this.buildCharArray(); - assertTrue(CollectionTools.contains(a, 'a')); - assertFalse(CollectionTools.contains(a, 'z')); - char[] a2 = CollectionTools.add(a, 'z'); - assertTrue(CollectionTools.contains(a2, 'z')); - } - - public void testContainsIntArrayInt() { - int[] a = this.buildIntArray(); - assertTrue(CollectionTools.contains(a, 10)); - assertFalse(CollectionTools.contains(a, 55)); - int[] a2 = CollectionTools.add(a, 55); - assertTrue(CollectionTools.contains(a2, 55)); - } - - public void testContainsAllCollectionIterator1() { - assertTrue(CollectionTools.containsAll(this.buildStringList1(), this.buildStringList1().iterator())); - } - - public void testContainsAllCollectionIterator2() { - Collection c1 = new ArrayList(); - c1.add("zero"); - c1.add("one"); - c1.add("two"); - Collection c2 = new ArrayList(); - c2.add("two"); - c2.add("zero"); - c2.add("one"); - assertTrue(CollectionTools.containsAll(c1, c2.iterator())); - } - - public void testContainsAllCollectionObjectArray1() { - assertTrue(CollectionTools.containsAll(this.buildStringList1(), this.buildObjectArray1())); - } - - public void testContainsAllCollectionObjectArray2() { - Object[] a = new Object[] { "zero", "one", "two" }; - assertTrue(CollectionTools.containsAll(this.buildStringList1(), a)); - } - - public void testContainsAllIteratorCollection1() { - assertTrue(CollectionTools.containsAll(this.buildStringList1().iterator(), this.buildStringList1())); - } - - public void testContainsAllIteratorCollection2() { - Collection c1 = new ArrayList(); - c1.add("zero"); - c1.add("one"); - c1.add("two"); - Collection c2 = new ArrayList(); - c2.add("zero"); - c2.add("one"); - c2.add("two"); - assertTrue(CollectionTools.containsAll(c1.iterator(), c2)); - } - - public void testContainsAllIteratorIterator1() { - assertTrue(CollectionTools.containsAll(this.buildStringList1().iterator(), this.buildStringList1().iterator())); - } - - public void testContainsAllIteratorIterator2() { - Collection c1 = new ArrayList(); - c1.add("zero"); - c1.add("one"); - c1.add("two"); - Collection c2 = new ArrayList(); - c2.add("zero"); - c2.add("one"); - c2.add("two"); - assertTrue(CollectionTools.containsAll(c1.iterator(), c2.iterator())); - } - - public void testContainsAllIteratorObjectArray() { - assertTrue(CollectionTools.containsAll(this.buildStringList1().iterator(), this.buildObjectArray1())); - } - - public void testContainsAllObjectArrayCollection() { - assertTrue(CollectionTools.containsAll(this.buildObjectArray1(), this.buildStringList1())); - } - - public void testContainsAllObjectArrayIterator() { - assertTrue(CollectionTools.containsAll(this.buildObjectArray1(), this.buildStringList1().iterator())); - } - - public void testContainsAllObjectArrayObjectArray() { - assertTrue(CollectionTools.containsAll(this.buildObjectArray1(), this.buildObjectArray1())); - } - - public void testContainsAllCharArrayCharArray() { - assertTrue(CollectionTools.containsAll(this.buildCharArray(), this.buildCharArray())); - } - - public void testContainsAllIntArrayIntArray() { - assertTrue(CollectionTools.containsAll(this.buildIntArray(), this.buildIntArray())); - } - - 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, CollectionTools.diffEnd(array1, array2)); - - array1 = new String[] { a }; - array2 = new String[] { a_ }; - assertEquals(-1, CollectionTools.diffEnd(array1, array2)); - - array1 = new String[] { b, c, d, e }; - array2 = new String[] { a_, b_, c_, d_, e_ }; - assertEquals(4, CollectionTools.diffEnd(array1, array2)); - - array1 = new String[] { a, b, c, d, e }; - array2 = new String[] { b_, c_, d_, e_ }; - assertEquals(4, CollectionTools.diffEnd(array1, array2)); - - array1 = new String[0]; - array2 = new String[] { a_, b_, c_, d_, e_ }; - assertEquals(4, CollectionTools.diffEnd(array1, array2)); - - array1 = new String[] { a, b, c, d, e }; - array2 = new String[0]; - assertEquals(4, CollectionTools.diffEnd(array1, array2)); - - array1 = new String[0]; - array2 = new String[0]; - assertEquals(-1, CollectionTools.diffEnd(array1, array2)); - - array1 = new String[] { a, b, c, d, e }; - array2 = new String[] { b_, c_, a_, d_, e_ }; - assertEquals(2, CollectionTools.diffEnd(array1, array2)); - - array1 = new String[] { b, c, d, e }; - array2 = new String[] { a_, c_, d_, e_ }; - assertEquals(0, CollectionTools.diffEnd(array1, array2)); - - array1 = new String[] { a, b, c, e }; - array2 = new String[] { a_, b_, c_, d_ }; - assertEquals(3, CollectionTools.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, CollectionTools.diffEnd(array1, array2)); - - array1 = new String[] { a, b, null, d, e }; - array2 = new String[] { a_, b_, c_, d_, e_ }; - assertEquals(2, CollectionTools.diffEnd(array1, array2)); - - array1 = new String[] { a, b, null, d, e }; - array2 = new String[] { a_, b_, null, d_, e_ }; - assertEquals(-1, CollectionTools.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), CollectionTools.diffRange(array1, array2)); - - array1 = new String[] { a }; - array2 = new String[] { a_ }; - assertEquals(new Range(1, -1), CollectionTools.diffRange(array1, array2)); - - array1 = new String[] { b, c, d, e }; - array2 = new String[] { a_, b_, c_, d_, e_ }; - assertEquals(new Range(0, 4), CollectionTools.diffRange(array1, array2)); - - array1 = new String[] { a, b, c, d, e }; - array2 = new String[] { b_, c_, d_, e_ }; - assertEquals(new Range(0, 4), CollectionTools.diffRange(array1, array2)); - - array1 = new String[0]; - array2 = new String[] { a_, b_, c_, d_, e_ }; - assertEquals(new Range(0, 4), CollectionTools.diffRange(array1, array2)); - - array1 = new String[] { a, b, c, d, e }; - array2 = new String[0]; - assertEquals(new Range(0, 4), CollectionTools.diffRange(array1, array2)); - - array1 = new String[0]; - array2 = new String[0]; - assertEquals(new Range(0, -1), CollectionTools.diffRange(array1, array2)); - - array1 = new String[] { a, b, c, d, e }; - array2 = new String[] { b_, c_, a_, d_, e_ }; - assertEquals(new Range(0, 2), CollectionTools.diffRange(array1, array2)); - - array1 = new String[] { b, c, d, e }; - array2 = new String[] { a_, c_, d_, e_ }; - assertEquals(new Range(0, 0), CollectionTools.diffRange(array1, array2)); - - array1 = new String[] { a, b, c, e }; - array2 = new String[] { a_, b_, c_, d_ }; - assertEquals(new Range(3, 3), CollectionTools.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), CollectionTools.diffRange(array1, array2)); - - array1 = new String[] { a, b, null, d, e }; - array2 = new String[] { a_, b_, c_, d_, e_ }; - assertEquals(new Range(2, 2), CollectionTools.diffRange(array1, array2)); - - array1 = new String[] { a, b, null, d, e }; - array2 = new String[] { a_, b_, null, d_, e_ }; - assertEquals(new Range(5, -1), CollectionTools.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, CollectionTools.diffStart(array1, array2)); - - array1 = new String[] { a }; - array2 = new String[] { a_ }; - assertEquals(1, CollectionTools.diffStart(array1, array2)); - - array1 = new String[] { a, b, c, d }; - array2 = new String[] { a_, b_, c_, d_, e_ }; - assertEquals(4, CollectionTools.diffStart(array1, array2)); - - array1 = new String[] { a, b, c, d, e }; - array2 = new String[] { a_, b_, c_, d_ }; - assertEquals(4, CollectionTools.diffStart(array1, array2)); - - array1 = new String[0]; - array2 = new String[] { a_, b_, c_, d_, e_ }; - assertEquals(0, CollectionTools.diffStart(array1, array2)); - - array1 = new String[] { a, b, c, d, e }; - array2 = new String[0]; - assertEquals(0, CollectionTools.diffStart(array1, array2)); - - array1 = new String[0]; - array2 = new String[0]; - assertEquals(0, CollectionTools.diffStart(array1, array2)); - - array1 = new String[] { a, b, c, d, e }; - array2 = new String[] { a_, b_, e_, c_, d_ }; - assertEquals(2, CollectionTools.diffStart(array1, array2)); - - array1 = new String[] { a, b, c, e }; - array2 = new String[] { a_, b_, c_, d_ }; - assertEquals(3, CollectionTools.diffStart(array1, array2)); - - array1 = new String[] { b, c, d, e }; - array2 = new String[] { a_, c_, d_, e_ }; - assertEquals(0, CollectionTools.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, CollectionTools.diffStart(array1, array2)); - - array1 = new String[] { a, b, null, d, e }; - array2 = new String[] { a_, b_, c_, d_, e_ }; - assertEquals(2, CollectionTools.diffStart(array1, array2)); - - array1 = new String[] { a, b, null, d, e }; - array2 = new String[] { a_, b_, null, d_, e_ }; - assertEquals(5, CollectionTools.diffStart(array1, array2)); - } - - public void testEqualsListIteratorListIterator() { - List list1 = new ArrayList(); - list1.add("1000"); - list1.add("2000"); - list1.add("3000"); - list1.add("4000"); - - List list2 = new ArrayList(); - for (int i = 0; i < list1.size(); i++) { - list2.add(String.valueOf((i + 1) * 1000)); - } - assertFalse(CollectionTools.identical(list1.listIterator(), list2.listIterator())); - assertTrue(CollectionTools.equals(list1.listIterator(), list2.listIterator())); - } - - public void testGetListIteratorInt() { - List list = this.buildStringList1(); - String o = CollectionTools.get(list.listIterator(), 1); - assertEquals("one", o); - list.add(null); - o = CollectionTools.get(list.listIterator(), list.size() - 1); - assertNull(o); - - boolean exCaught = false; - try { - CollectionTools.get(list.listIterator(), list.size()); - } catch (IndexOutOfBoundsException ex) { - exCaught = true; - } - assertTrue(exCaught); - } - - public void testIdenticalObjectArrayObjectArray() { - 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(CollectionTools.identical(a1, a2)); - a2[2] = "2000"; - assertFalse(CollectionTools.identical(a1, a2)); - assertTrue(Arrays.equals(a1, a2)); - } - - public void testIdenticalListIteratorListIterator() { - List list1 = new ArrayList(); - list1.add("0"); - list1.add("1"); - list1.add("2"); - list1.add("3"); - - List list2 = new ArrayList(); - for (String s : list1) { - list2.add(s); - } - assertTrue(CollectionTools.identical(list1.listIterator(), list2.listIterator())); - assertTrue(CollectionTools.equals(list1.listIterator(), list2.listIterator())); - } - - 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, CollectionTools.identityDiffEnd(array1, array2)); - - array1 = new String[] { a }; - array2 = new String[] { a_ }; - assertEquals(-1, CollectionTools.identityDiffEnd(array1, array2)); - - array1 = new String[] { b, c, d, e }; - array2 = new String[] { a_, b_, c_, d_, e_ }; - assertEquals(4, CollectionTools.identityDiffEnd(array1, array2)); - - array1 = new String[] { a, b, c, d, e }; - array2 = new String[] { b_, c_, d_, e_ }; - assertEquals(4, CollectionTools.identityDiffEnd(array1, array2)); - - array1 = new String[0]; - array2 = new String[] { a_, b_, c_, d_, e_ }; - assertEquals(4, CollectionTools.identityDiffEnd(array1, array2)); - - array1 = new String[] { a, b, c, d, e }; - array2 = new String[0]; - assertEquals(4, CollectionTools.identityDiffEnd(array1, array2)); - - array1 = new String[0]; - array2 = new String[0]; - assertEquals(-1, CollectionTools.identityDiffEnd(array1, array2)); - - array1 = new String[] { a, b, c, d, e }; - array2 = new String[] { b_, c_, a_, d_, e_ }; - assertEquals(2, CollectionTools.identityDiffEnd(array1, array2)); - - array1 = new String[] { b, c, d, e }; - array2 = new String[] { a_, c_, d_, e_ }; - assertEquals(0, CollectionTools.identityDiffEnd(array1, array2)); - - array1 = new String[] { a, b, c, e }; - array2 = new String[] { a_, b_, c_, d_ }; - assertEquals(3, CollectionTools.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, CollectionTools.identityDiffEnd(array1, array2)); - - array1 = new String[] { a, b, null, d, e }; - array2 = new String[] { a_, b_, c_, d_, e_ }; - assertEquals(2, CollectionTools.identityDiffEnd(array1, array2)); - - array1 = new String[] { a, b, null, d, e }; - array2 = new String[] { a_, b_, null, d_, e_ }; - assertEquals(-1, CollectionTools.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), CollectionTools.identityDiffRange(array1, array2)); - - array1 = new String[] { a }; - array2 = new String[] { a_ }; - assertEquals(new Range(1, -1), CollectionTools.identityDiffRange(array1, array2)); - - array1 = new String[] { b, c, d, e }; - array2 = new String[] { a_, b_, c_, d_, e_ }; - assertEquals(new Range(0, 4), CollectionTools.identityDiffRange(array1, array2)); - - array1 = new String[] { a, b, c, d, e }; - array2 = new String[] { b_, c_, d_, e_ }; - assertEquals(new Range(0, 4), CollectionTools.identityDiffRange(array1, array2)); - - array1 = new String[0]; - array2 = new String[] { a_, b_, c_, d_, e_ }; - assertEquals(new Range(0, 4), CollectionTools.identityDiffRange(array1, array2)); - - array1 = new String[] { a, b, c, d, e }; - array2 = new String[0]; - assertEquals(new Range(0, 4), CollectionTools.identityDiffRange(array1, array2)); - - array1 = new String[0]; - array2 = new String[0]; - assertEquals(new Range(0, -1), CollectionTools.identityDiffRange(array1, array2)); - - array1 = new String[] { a, b, c, d, e }; - array2 = new String[] { b_, c_, a_, d_, e_ }; - assertEquals(new Range(0, 2), CollectionTools.identityDiffRange(array1, array2)); - - array1 = new String[] { b, c, d, e }; - array2 = new String[] { a_, c_, d_, e_ }; - assertEquals(new Range(0, 0), CollectionTools.identityDiffRange(array1, array2)); - - array1 = new String[] { a, b, c, e }; - array2 = new String[] { a_, b_, c_, d_ }; - assertEquals(new Range(3, 3), CollectionTools.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), CollectionTools.identityDiffRange(array1, array2)); - - array1 = new String[] { a, b, null, d, e }; - array2 = new String[] { a_, b_, c_, d_, e_ }; - assertEquals(new Range(2, 2), CollectionTools.identityDiffRange(array1, array2)); - - array1 = new String[] { a, b, null, d, e }; - array2 = new String[] { a_, b_, null, d_, e_ }; - assertEquals(new Range(5, -1), CollectionTools.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, CollectionTools.identityDiffStart(array1, array2)); - - array1 = new String[] { a }; - array2 = new String[] { a_ }; - assertEquals(1, CollectionTools.identityDiffStart(array1, array2)); - - array1 = new String[] { a, b, c, d }; - array2 = new String[] { a_, b_, c_, d_, e_ }; - assertEquals(4, CollectionTools.identityDiffStart(array1, array2)); - - array1 = new String[] { a, b, c, d, e }; - array2 = new String[] { a_, b_, c_, d_ }; - assertEquals(4, CollectionTools.identityDiffStart(array1, array2)); - - array1 = new String[0]; - array2 = new String[] { a_, b_, c_, d_, e_ }; - assertEquals(0, CollectionTools.identityDiffStart(array1, array2)); - - array1 = new String[] { a, b, c, d, e }; - array2 = new String[0]; - assertEquals(0, CollectionTools.identityDiffStart(array1, array2)); - - array1 = new String[0]; - array2 = new String[0]; - assertEquals(0, CollectionTools.identityDiffStart(array1, array2)); - - array1 = new String[] { a, b, c, d, e }; - array2 = new String[] { a_, b_, e_, c_, d_ }; - assertEquals(2, CollectionTools.identityDiffStart(array1, array2)); - - array1 = new String[] { a, b, c, e }; - array2 = new String[] { a_, b_, c_, d_ }; - assertEquals(3, CollectionTools.identityDiffStart(array1, array2)); - - array1 = new String[] { b, c, d, e }; - array2 = new String[] { a_, c_, d_, e_ }; - assertEquals(0, CollectionTools.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, CollectionTools.identityDiffStart(array1, array2)); - - array1 = new String[] { a, b, null, d, e }; - array2 = new String[] { a_, b_, c_, d_, e_ }; - assertEquals(2, CollectionTools.identityDiffStart(array1, array2)); - - array1 = new String[] { a, b, null, d, e }; - array2 = new String[] { a_, b_, null, d_, e_ }; - assertEquals(5, CollectionTools.identityDiffStart(array1, array2)); - } - - public void testIndexOfListIteratorObject1() { - List list = this.buildStringList1(); - assertEquals(1, CollectionTools.indexOf(list.listIterator(), "one")); - list.add(null); - assertEquals(list.size() - 1, CollectionTools.indexOf(list.listIterator(), null)); - } - - public void testIndexOfListIteratorObject2() { - List list = new ArrayList(); - list.add("0"); - list.add("1"); - list.add("2"); - list.add("3"); - - String one = "1"; - assertEquals(1, CollectionTools.indexOf(list.listIterator(), one)); - list.add(null); - assertEquals(list.size() - 1, CollectionTools.indexOf(list.listIterator(), null)); - } - - public void testIndexOfObjectArrayObject() { - Object[] a = this.buildObjectArray1(); - assertEquals(1, CollectionTools.indexOf(a, "one")); - a = CollectionTools.add(a, null); - assertEquals(a.length - 1, CollectionTools.indexOf(a, null)); - } - - public void testIndexOfCharArrayChar() { - char[] a = this.buildCharArray(); - assertEquals(1, CollectionTools.indexOf(a, 'b')); - a = CollectionTools.add(a, 'd'); - assertEquals(a.length - 1, CollectionTools.indexOf(a, 'd')); - } - - public void testIndexOfIntArrayInt() { - int[] a = this.buildIntArray(); - assertEquals(1, CollectionTools.indexOf(a, 10)); - a = CollectionTools.add(a, 30); - assertEquals(a.length - 1, CollectionTools.indexOf(a, 30)); - } - - public void testInsertionIndexOfListComparable() { - List 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 testInsertionIndexOfListObjectComparator() { - Comparator c = new ReverseComparator(); - List 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 testInsertionIndexOfObjectArrayComparable() { - String[] a = new String[] { "A", "C", "D" }; - assertEquals(1, CollectionTools.insertionIndexOf(a, "B")); - - a = new String[] { "A", "B", "C", "D" }; - assertEquals(2, CollectionTools.insertionIndexOf(a, "B")); - - a = new String[] { "A", "B", "B", "B", "C", "D" }; - assertEquals(4, CollectionTools.insertionIndexOf(a, "B")); - - a = new String[] { "A", "B", "B", "B", "C", "D" }; - assertEquals(6, CollectionTools.insertionIndexOf(a, "E")); - - a = new String[] { "B", "B", "B", "C", "D" }; - assertEquals(0, CollectionTools.insertionIndexOf(a, "A")); - - a = new String[] { "A", "A", "B", "B", "C", "D" }; - assertEquals(2, CollectionTools.insertionIndexOf(a, "A")); - } - - public void testInsertionIndexOfObjectArrayObjectComparator() { - Comparator c = new ReverseComparator(); - String[] a = new String[] { "D", "C", "A" }; - assertEquals(2, CollectionTools.insertionIndexOf(a, "B", c)); - - a = new String[] { "D", "C", "B", "A" }; - assertEquals(3, CollectionTools.insertionIndexOf(a, "B", c)); - - a = new String[] { "D", "C", "B", "B", "B", "A" }; - assertEquals(5, CollectionTools.insertionIndexOf(a, "B", c)); - - a = new String[] { "D", "C", "B", "B", "B", "A" }; - assertEquals(0, CollectionTools.insertionIndexOf(a, "E", c)); - - a = new String[] { "D", "C", "B", "B", "B" }; - assertEquals(5, CollectionTools.insertionIndexOf(a, "A", c)); - - a = new String[] { "D", "C", "B", "B", "A", "A" }; - assertEquals(6, CollectionTools.insertionIndexOf(a, "A", c)); - } - - public void testIterable() { - Iterator emptyIterator = EmptyIterator.instance(); - Iterable emptyIterable = CollectionTools.iterable(emptyIterator); - - assertEquals(emptyIterator, emptyIterable.iterator()); - - boolean exceptionThrown = false; - try { - emptyIterable.iterator(); - } - catch (IllegalStateException ise) { - exceptionThrown = true; - } - assertTrue("IllegalStateException not thrown.", exceptionThrown); - - } - - public void testIteratorObjectArray() { - String[] a = this.buildStringArray1(); - int i = 0; - for (Iterator stream = CollectionTools.iterator(a); stream.hasNext(); i++) { - assertEquals(a[i], stream.next()); - } - } - - public void testLastIndexOfListIteratorObject() { - List list = this.buildStringList1(); - assertEquals(1, CollectionTools.lastIndexOf(list.listIterator(), "one")); - list.add(null); - assertEquals(list.size() - 1, CollectionTools.lastIndexOf(list.listIterator(), null)); - } - - public void testLastIndexOfObjectArrayObject() { - Object[] a = this.buildObjectArray1(); - assertEquals(1, CollectionTools.lastIndexOf(a, "one")); - a = CollectionTools.add(a, null); - assertEquals(a.length - 1, CollectionTools.lastIndexOf(a, null)); - } - - public void testLastIndexOfCharArrayChar() { - char[] a = this.buildCharArray(); - assertEquals(1, CollectionTools.lastIndexOf(a, 'b')); - a = CollectionTools.add(a, 'd'); - assertEquals(a.length - 1, CollectionTools.lastIndexOf(a, 'd')); - } - - public void testLastIndexOfIntArrayInt() { - int[] a = this.buildIntArray(); - assertEquals(1, CollectionTools.lastIndexOf(a, 10)); - a = CollectionTools.add(a, 30); - assertEquals(a.length - 1, CollectionTools.lastIndexOf(a, 30)); - } - - public void testListIterator1() { - List list = CollectionTools.list(this.buildStringList1().iterator()); - assertEquals(this.buildStringList1(), list); - } - - public void testListIterator2() { - List list1 = new ArrayList(); - list1.add("0"); - list1.add("1"); - list1.add("2"); - list1.add("3"); - - List list2 = CollectionTools.list(list1.iterator()); - assertEquals(list1, list2); - } - - public void testListObjectArray() { - List list = CollectionTools.list(this.buildStringArray1()); - assertEquals(this.buildStringList1(), list); - } - - public void testListIteratorObjectArray() { - String[] a = this.buildStringArray1(); - int i = 0; - for (ListIterator stream = CollectionTools.listIterator(a); stream.hasNext(); i++) { - assertEquals(a[i], stream.next()); - } - } - - public void testListIteratorObjectArrayInt() { - String[] a = this.buildStringArray1(); - int i = 1; - for (ListIterator stream = CollectionTools.listIterator(a, 1); stream.hasNext(); i++) { - assertEquals(a[i], stream.next()); - } - } - - public void testMaxCharArray() { - assertEquals('c', CollectionTools.max(this.buildCharArray())); - } - - public void testMaxIntArray() { - assertEquals(20, CollectionTools.max(this.buildIntArray())); - } - - public void testMinCharArray() { - assertEquals('a', CollectionTools.min(this.buildCharArray())); - } - - public void testMinIntArray() { - assertEquals(0, CollectionTools.min(this.buildIntArray())); - } - - 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 = CollectionTools.removeAll(a1, a2); - assertTrue(Arrays.equals(new String[] { "A", "A", "C", "C", "D", "D", "F", "F" }, 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' }, CollectionTools.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 }, CollectionTools.removeAll(a1, a2))); - } - - public void testRemoveObjectArrayObject1() { - Object[] a = this.buildObjectArray1(); - a = CollectionTools.add(a, "three"); - a = CollectionTools.add(a, "four"); - a = CollectionTools.add(a, "five"); - - assertEquals(6, a.length); - assertTrue(CollectionTools.contains(a, "three")); - a = CollectionTools.remove(a, "three"); - assertEquals(5, a.length); - assertFalse(CollectionTools.contains(a, "three")); - assertTrue(CollectionTools.contains(a, "four")); - assertTrue(CollectionTools.contains(a, "five")); - } - - public void testRemoveObjectArrayObject2() { - String[] a = this.buildStringArray1(); - a = CollectionTools.add(a, "three"); - a = CollectionTools.add(a, "four"); - a = CollectionTools.add(a, "five"); - - assertEquals(6, a.length); - assertTrue(CollectionTools.contains(a, "three")); - a = CollectionTools.remove(a, "three"); - assertEquals(5, a.length); - assertFalse(CollectionTools.contains(a, "three")); - assertTrue(CollectionTools.contains(a, "four")); - assertTrue(CollectionTools.contains(a, "five")); - } - - public void testRemoveCharArrayChar() { - char[] a = this.buildCharArray(); - a = CollectionTools.add(a, 'd'); - a = CollectionTools.add(a, 'e'); - a = CollectionTools.add(a, 'f'); - - assertEquals(6, a.length); - assertTrue(CollectionTools.contains(a, 'd')); - a = CollectionTools.remove(a, 'd'); - assertEquals(5, a.length); - assertFalse(CollectionTools.contains(a, 'd')); - assertTrue(CollectionTools.contains(a, 'e')); - assertTrue(CollectionTools.contains(a, 'f')); - } - - public void testRemoveIntArrayInt() { - int[] a = this.buildIntArray(); - a = CollectionTools.add(a, 30); - a = CollectionTools.add(a, 40); - a = CollectionTools.add(a, 50); - - assertEquals(6, a.length); - assertTrue(CollectionTools.contains(a, 30)); - a = CollectionTools.remove(a, 30); - assertEquals(5, a.length); - assertFalse(CollectionTools.contains(a, 30)); - assertTrue(CollectionTools.contains(a, 40)); - assertTrue(CollectionTools.contains(a, 50)); - } - - public void testRemoveAllCollectionIterator1() { - Collection 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); - } - - public void testRemoveAllCollectionIterator2() { - Collection c = new ArrayList(); - 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, new ArrayIterator(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, new ArrayIterator(a))); - } - - public void testRemoveAllCollectionIterator3() { - Collection c = new ArrayList(); - 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, new ArrayIterator(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, new ArrayIterator(a))); - } - - public void testRemoveAllCollectionObjectArray1() { - Collection 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); - } - - public void testRemoveAllCollectionObjectArray2() { - Collection c = new ArrayList(); - 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, 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, a)); - } - - public void testRemoveAllCollectionObjectArray3() { - Collection c = new ArrayList(); - 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, 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, a)); - } - - public void testRemoveAllOccurrencesCollectionObject() { - Collection 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()); - } - - public void testRemoveAllOccurrencesObjectArrayObject() { - String[] a = this.buildStringArray1(); - assertEquals(3, a.length); - a = CollectionTools.removeAllOccurrences(a, "three"); - assertEquals(3, a.length); - a = CollectionTools.removeAllOccurrences(a, "two"); - assertEquals(2, a.length); - a = CollectionTools.removeAllOccurrences(a, "two"); - assertEquals(2, a.length); - - a = CollectionTools.add(a, "five"); - a = CollectionTools.add(a, "five"); - a = CollectionTools.add(a, "five"); - assertEquals(5, a.length); - a = CollectionTools.removeAllOccurrences(a, "five"); - assertEquals(2, a.length); - a = CollectionTools.removeAllOccurrences(a, "five"); - assertEquals(2, a.length); - - a = CollectionTools.add(a, null); - a = CollectionTools.add(a, null); - a = CollectionTools.add(a, null); - assertEquals(5, a.length); - a = CollectionTools.removeAllOccurrences(a, null); - assertEquals(2, a.length); - a = CollectionTools.removeAllOccurrences(a, null); - assertEquals(2, a.length); - } - - public void testRemoveAllOccurrencesCharArrayChar() { - char[] a = this.buildCharArray(); - assertEquals(3, a.length); - a = CollectionTools.removeAllOccurrences(a, 'd'); - assertEquals(3, a.length); - a = CollectionTools.removeAllOccurrences(a, 'b'); - assertEquals(2, a.length); - a = CollectionTools.removeAllOccurrences(a, 'b'); - assertEquals(2, a.length); - - a = CollectionTools.add(a, 'g'); - a = CollectionTools.add(a, 'g'); - a = CollectionTools.add(a, 'g'); - assertEquals(5, a.length); - a = CollectionTools.removeAllOccurrences(a, 'g'); - assertEquals(2, a.length); - a = CollectionTools.removeAllOccurrences(a, 'g'); - assertEquals(2, a.length); - } - - public void testRemoveAllOccurrencesIntArrayInt() { - int[] a = this.buildIntArray(); - assertEquals(3, a.length); - a = CollectionTools.removeAllOccurrences(a, 55); - assertEquals(3, a.length); - a = CollectionTools.removeAllOccurrences(a, 10); - assertEquals(2, a.length); - a = CollectionTools.removeAllOccurrences(a, 10); - assertEquals(2, a.length); - - a = CollectionTools.add(a, 77); - a = CollectionTools.add(a, 77); - a = CollectionTools.add(a, 77); - assertEquals(5, a.length); - a = CollectionTools.removeAllOccurrences(a, 77); - assertEquals(2, a.length); - a = CollectionTools.removeAllOccurrences(a, 77); - assertEquals(2, a.length); - } - - public void testRemoveElementAtIndexObjectArrayInt() { - String[] a = new String[] { "A", "B", "A", "C", "A", "D" }; - a = CollectionTools.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 = CollectionTools.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 = CollectionTools.removeElementAtIndex(a, 3); - assertTrue(Arrays.equals(new int[] { 8, 6, 7, 2, 11 }, a)); - } - - public void testReplaceAllObjectArray1() { - Object[] a = new Object[] { "A", "B", "A", "C", "A", "D" }; - a = CollectionTools.replaceAll(a, "A", "Z"); - assertTrue(Arrays.equals(new Object[] { "Z", "B", "Z", "C", "Z", "D" }, a)); - } - - public void testReplaceAllObjectArray2() { - String[] a = new String[] { "A", "B", "A", "C", "A", "D" }; - a = CollectionTools.replaceAll(a, "A", "Z"); - assertTrue(Arrays.equals(new String[] { "Z", "B", "Z", "C", "Z", "D" }, a)); - } - - public void testReplaceAllCharArray() { - char[] a = new char[] { 'A', 'B', 'A', 'C', 'A', 'D' }; - a = CollectionTools.replaceAll(a, 'A', 'Z'); - assertTrue(Arrays.equals(new char[] { 'Z', 'B', 'Z', 'C', 'Z', 'D' }, a)); - } - - public void testReplaceAllIntArray() { - int[] a = new int[] { 0, 1, 0, 7, 0, 99 }; - a = CollectionTools.replaceAll(a, 0, 13); - assertTrue(Arrays.equals(new int[] { 13, 1, 13, 7, 13, 99 }, a)); - } - - public void testRetainAllCollectionIterator1() { - Collection 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 testRetainAllCollectionIterator2() { - Collection c1 = new ArrayList(); - c1.add("zero"); - c1.add("one"); - c1.add("two"); - - Collection c2 = new ArrayList(); - c2.add("zero"); - c2.add("one"); - c2.add("two"); - - assertFalse(CollectionTools.retainAll(c1, c2.iterator())); - assertEquals(c2.size(), c1.size()); - assertEquals(c2, c1); - - Collection c3 = new ArrayList(); - c3.add("three"); - c3.add("four"); - c3.add("five"); - - assertTrue(CollectionTools.retainAll(c1, c3.iterator())); - assertEquals(0, c1.size()); - assertFalse(c1.contains("one")); - assertFalse(c1.contains("two")); - assertFalse(c1.contains("three")); - } - - public void testRetainAllCollectionObjectArray() { - Collection 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 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" }, CollectionTools.retainAll(a1, a2))); - } - - 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' }, CollectionTools.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 }, CollectionTools.retainAll(a1, a2))); - } - - public void testReverseObjectArray1() { - Object[] a = this.buildObjectArray1(); - a = CollectionTools.reverse(a); - assertEquals("two", a[0]); - assertEquals("one", a[1]); - assertEquals("zero", a[2]); - } - - public void testReverseObjectArray2() { - String[] a = this.buildStringArray1(); - a = CollectionTools.reverse(a); - assertEquals("two", a[0]); - assertEquals("one", a[1]); - assertEquals("zero", a[2]); - } - - public void testReverseCharArray() { - char[] a = this.buildCharArray(); - a = CollectionTools.reverse(a); - assertEquals('c', a[0]); - assertEquals('b', a[1]); - assertEquals('a', a[2]); - } - - public void testReverseIntArray() { - int[] a = this.buildIntArray(); - a = CollectionTools.reverse(a); - assertEquals(20, a[0]); - assertEquals(10, a[1]); - assertEquals(0, a[2]); - } - - public void testReverseListIterator1() { - List actual = CollectionTools.reverseList(this.buildStringList1().iterator()); - List expected = this.buildStringList1(); - Collections.reverse(expected); - assertEquals(expected, actual); - } - - public void testReverseListIterator2() { - List actual = CollectionTools.reverseList(this.buildStringList1().iterator()); - List expected = this.buildObjectList1(); - Collections.reverse(expected); - assertEquals(expected, actual); - } - - public void testRotateObjectArray() { - String[] a = this.buildStringArray1(); - a = CollectionTools.rotate(a); - assertEquals("two", a[0]); - assertEquals("zero", a[1]); - assertEquals("one", a[2]); - } - - public void testRotateObjectArrayInt() { - String[] a = this.buildStringArray1(); - a = CollectionTools.rotate(a, 2); - assertEquals("one", a[0]); - assertEquals("two", a[1]); - assertEquals("zero", a[2]); - } - - public void testRotateCharArray() { - char[] a = this.buildCharArray(); - a = CollectionTools.rotate(a); - assertEquals('c', a[0]); - assertEquals('a', a[1]); - assertEquals('b', a[2]); - } - - public void testRotateCharArrayInt() { - char[] a = this.buildCharArray(); - a = CollectionTools.rotate(a, 2); - assertEquals('b', a[0]); - assertEquals('c', a[1]); - assertEquals('a', a[2]); - } - - public void testRotateIntArray() { - int[] a = this.buildIntArray(); - a = CollectionTools.rotate(a); - assertEquals(20, a[0]); - assertEquals(0, a[1]); - assertEquals(10, a[2]); - } - - public void testRotateIntArrayInt() { - int[] a = this.buildIntArray(); - a = CollectionTools.rotate(a, 2); - assertEquals(10, a[0]); - assertEquals(20, a[1]); - assertEquals(0, a[2]); - } - - public void testSetIterator1() { - assertEquals(this.buildStringSet1(), CollectionTools.set(this.buildStringSet1().iterator())); - } - - public void testSetIterator2() { - Set set1 = new HashSet(); - set1.add("0"); - set1.add("1"); - set1.add("2"); - set1.add("3"); - - Set set2 = CollectionTools.set(set1.iterator()); - assertEquals(set1, set2); - } - - public void testSetObjectArray() { - assertEquals(this.buildStringSet1(), CollectionTools.set(this.buildStringSet1().toArray())); - } - - public void testShuffleObjectArray() { - String[] array1 = this.buildStringArray1(); - String[] array2 = CollectionTools.shuffle(this.buildStringArray1()); - assertEquals(array1.length, array2.length); - assertTrue(CollectionTools.containsAll(array1, array2)); - } - - public void testShuffleCharArray() { - char[] array1 = this.buildCharArray(); - char[] array2 = CollectionTools.shuffle(this.buildCharArray()); - assertEquals(array1.length, array2.length); - assertTrue(CollectionTools.containsAll(array1, array2)); - } - - public void testShuffleIntArray() { - int[] array1 = this.buildIntArray(); - int[] array2 = CollectionTools.shuffle(this.buildIntArray()); - assertEquals(array1.length, array2.length); - assertTrue(CollectionTools.containsAll(array1, array2)); - } - - public void testSingletonIterator1() { - Iterator stream = CollectionTools.singletonIterator("foo"); - assertTrue(stream.hasNext()); - assertEquals("foo", stream.next()); - } - - public void testSingletonIterator2() { - Iterator stream = CollectionTools.singletonIterator("foo"); - assertTrue(stream.hasNext()); - assertEquals("foo", stream.next()); - } - - public void testSingletonIterator3() { - Iterator stream = CollectionTools.singletonIterator((Object) "foo"); - assertTrue(stream.hasNext()); - assertEquals("foo", stream.next()); - } - - public void testSizeIterator() { - assertEquals(3, CollectionTools.size(this.buildObjectList1().iterator())); - } - - public void testSortedSetIterator1() { - assertEquals(this.buildSortedStringSet1(), CollectionTools.set(this.buildSortedStringSet1().iterator())); - } - - public void testSortedSetIterator2() { - SortedSet ss1 = new TreeSet(); - ss1.add("0"); - ss1.add("2"); - ss1.add("3"); - ss1.add("1"); - - SortedSet set2 = CollectionTools.sortedSet(ss1.iterator()); - assertEquals(ss1, set2); - } - - public void testSortedSetObjectArray() { - assertEquals(this.buildSortedStringSet1(), CollectionTools.set(this.buildSortedStringSet1().toArray())); - } - - public void testSwapObjectArray() { - String[] a = this.buildStringArray1(); - a = CollectionTools.swap(a, 1, 2); - assertEquals("zero", a[0]); - assertEquals("two", a[1]); - assertEquals("one", a[2]); - } - - public void testSwapCharArray() { - char[] a = this.buildCharArray(); - a = CollectionTools.swap(a, 1, 2); - assertEquals('a', a[0]); - assertEquals('c', a[1]); - assertEquals('b', a[2]); - } - - public void testSwapIntArray() { - int[] a = this.buildIntArray(); - a = CollectionTools.swap(a, 1, 2); - assertEquals(0, a[0]); - assertEquals(20, a[1]); - assertEquals(10, a[2]); - } - - public void testRemoveDuplicateElementsList() { - List list = this.buildStringVector1(); - list.add("zero"); - list.add("zero"); - list.add("two"); - list.add("zero"); - list = 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 testRemoveDuplicateElementsObjectArray1() { - List list = this.buildStringVector1(); - list.add("zero"); - list.add("zero"); - list.add("two"); - list.add("zero"); - String[] array = CollectionTools.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 testRemoveDuplicateElementsObjectArray2() { - List list = this.buildStringVector1(); - list.add("zero"); - list.add("zero"); - list.add("two"); - list.add("zero"); - String[] array = CollectionTools.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 testVectorIterator1() { - Vector v = CollectionTools.vector(this.buildStringList1().iterator()); - assertEquals(3, v.size()); - assertTrue(v.containsAll(this.buildStringList1())); - } - - public void testVectorIterator2() { - Vector v = CollectionTools.vector(this.buildStringList1().iterator()); - assertEquals(3, v.size()); - assertTrue(v.containsAll(this.buildStringList1())); - } - - public void testVectorObjectArray() { - Vector v = CollectionTools.vector(this.buildStringArray1()); - assertEquals(3, v.size()); - assertTrue(v.containsAll(this.buildStringList1())); - } - - 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 Vector buildStringVector1() { - Vector v = new Vector(); - this.addToCollection1(v); - return v; - } - - private List buildStringList1() { - List l = new ArrayList(); - this.addToCollection1(l); - return l; - } - - private List buildObjectList1() { - List l = new ArrayList(); - this.addToCollection1(l); - return l; - } - - private void addToCollection1(Collection c) { - c.add("zero"); - c.add("one"); - c.add("two"); - } - - private List buildStringList2() { - List l = new ArrayList(); - this.addToCollection2(l); - return l; - } - - private void addToCollection2(Collection c) { - c.add("three"); - c.add("four"); - c.add("five"); - } - - private Set buildStringSet1() { - Set s = new HashSet(); - this.addToCollection1(s); - return s; - } - - private Set buildObjectSet1() { - Set s = new HashSet(); - this.addToCollection1(s); - return s; - } - - private SortedSet buildSortedStringSet1() { - SortedSet s = new TreeSet(); - this.addToCollection1(s); - return s; - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/FileToolsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/FileToolsTests.java deleted file mode 100644 index adcccf0992..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/FileToolsTests.java +++ /dev/null @@ -1,594 +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.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.utility.internal.ClassTools; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.FileTools; - -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 files = CollectionTools.collection(FileTools.filesIn(this.tempDir.getPath())); - assertEquals("invalid file count", 3, files.size()); - } - - public void testDirectoriesIn() { - Collection files = CollectionTools.collection(FileTools.directoriesIn(this.tempDir.getPath())); - assertEquals("invalid directory count", 2, files.size()); - } - - public void testFilesInTree() { - Collection files = CollectionTools.collection(FileTools.filesInTree(this.tempDir.getPath())); - assertEquals("invalid file count", 9, files.size()); - } - - public void testDirectoriesInTree() { - Collection 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); - } - - 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 filteredFilesIterator = FileTools.filter(FileTools.filesIn(this.tempDir), filter); - Collection 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); - } - - private boolean isExecutingOnWindows() { - return this.isExecutingOn("Windows"); - } - - // private boolean isExecutingOnLinux() { - // return this.isExecutingOn("Linux"); - // } - // - private boolean isExecutingOn(String osName) { - return System.getProperty("os.name").indexOf(osName) != -1; - } - - public void testPathFiles() { - File[] expected; - File[] actual; - - if (this.isExecutingOnWindows()) { - 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[]) ClassTools.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) ClassTools.executeStaticMethod(FileTools.class, "relativeParentFile", int.class, new Integer(len)); - } - - public void testConvertToRelativeFile() { - String prefix = this.isExecutingOnWindows() ? "C:" : ""; - File file; - File dir; - File relativeFile; - - if (this.isExecutingOnWindows()) { - // 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 = this.isExecutingOnWindows() ? "C:" : ""; - File file; - File dir; - File absoluteFile; - - if (this.isExecutingOnWindows()) { - // 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 = this.isExecutingOnWindows(); - 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 = this.isExecutingOnWindows(); - 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 (this.isExecutingOnWindows()) { - 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 (this.isExecutingOnWindows()) { - 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 (this.isExecutingOnWindows()) { - 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 (this.isExecutingOnWindows()) { - 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(ClassTools.shortClassNameForObject(this) + "." + 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/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/HashBagTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/HashBagTests.java deleted file mode 100644 index 51120c9eb2..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/HashBagTests.java +++ /dev/null @@ -1,448 +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.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.utility.internal.Bag; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.HashBag; - -public class HashBagTests extends TestCase { - private HashBag bag; - - public HashBagTests(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - this.bag = this.buildBag(); - } - - private HashBag buildBag() { - HashBag b = new HashBag(); - 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 buildCollection() { - Collection c = new ArrayList(); - 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 c = this.buildCollection(); - Bag b = new HashBag(c); - for (String s : c) { - assertTrue("missing element", b.contains(s)); - } - } - - public void testCtorIntFloat() { - boolean exCaught; - - exCaught = false; - try { - this.bag = new HashBag(-20, 0.66f); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue("IllegalArgumentException not thrown", exCaught); - - exCaught = false; - try { - this.bag = new HashBag(20, -0.66f); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue("IllegalArgumentException not thrown", exCaught); - } - - public void testAdd() { - // the other adds took place in setUp - assertTrue("incorrect return value", this.bag.add("five")); - - assertTrue("missing element", this.bag.contains("one")); - assertTrue("missing element", this.bag.contains("two")); - assertTrue("missing element", this.bag.contains("three")); - assertTrue("missing element", this.bag.contains("four")); - assertTrue("missing element", this.bag.contains("five")); - } - - public void testAddAll() { - Collection c = this.buildCollection(); - assertTrue("incorrect return value", this.bag.addAll(c)); - for (String s : c) { - assertTrue("missing element", this.bag.contains(s)); - } - } - - public void testClear() { - assertTrue("missing element", this.bag.contains("one")); - assertTrue("missing element", this.bag.contains("two")); - assertTrue("missing element", this.bag.contains("three")); - assertTrue("missing element", this.bag.contains("four")); - assertTrue("missing element", this.bag.contains(null)); - assertEquals("invalid size", 11, this.bag.size()); - this.bag.clear(); - assertFalse("malingering element", this.bag.contains("one")); - assertFalse("malingering element", this.bag.contains("two")); - assertFalse("malingering element", this.bag.contains("three")); - assertFalse("malingering element", this.bag.contains("four")); - assertFalse("malingering element", this.bag.contains(null)); - assertEquals("invalid size", 0, this.bag.size()); - } - - public void testClone() { - Bag 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("missing element", this.bag.contains(null)); - assertTrue("missing element", this.bag.contains("one")); - assertTrue("missing element", this.bag.contains("two")); - assertTrue("missing element", this.bag.contains("three")); - assertTrue("missing element", this.bag.contains("four")); - assertTrue("missing element", this.bag.contains(new String("four"))); - assertTrue("missing element", this.bag.contains("fo" + "ur")); - assertFalse("element found", this.bag.contains("five")); - } - - public void testContainsAll() { - Collection c = new ArrayList(); - c.add(null); - c.add(new String("one")); - c.add(new String("two")); - c.add(new String("three")); - c.add(new String("four")); - assertTrue("missing element(s)", this.bag.containsAll(c)); - } - - public void testCount() { - assertEquals("bad count", 0, this.bag.count("zero")); - assertEquals("bad count", 1, this.bag.count("one")); - assertEquals("bad count", 2, this.bag.count("two")); - assertEquals("bad count", 3, this.bag.count("three")); - assertEquals("bad count", 4, this.bag.count("four")); - assertEquals("bad count", 0, this.bag.count("five")); - } - - public void testEquals() { - Bag bag2 = this.buildBag(); - assertEquals("bags are not equal", this.bag, bag2); - bag2.add("five"); - assertFalse("bags are equal", this.bag.equals(bag2)); - Collection c = new ArrayList(this.bag); - assertFalse("bags are not equal to collections", this.bag.equals(c)); - } - - public void testHashCode() { - Bag bag2 = this.buildBag(); - assertEquals("bad hash code", this.bag.hashCode(), bag2.hashCode()); - } - - public void testIsEmpty() { - assertFalse("bag is empty", this.bag.isEmpty()); - this.bag.clear(); - assertTrue("bag is not empty", this.bag.isEmpty()); - this.bag.add("foo"); - assertFalse("bag is empty", this.bag.isEmpty()); - } - - public void testEmptyIterator() { - this.bag.clear(); - Iterator iterator = this.bag.iterator(); - assertFalse("iterator is not empty", 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 iterator = this.bag.iterator(); - assertTrue("iterator is empty", iterator.hasNext()); - while (iterator.hasNext()) { - iterator.next(); - i++; - } - assertEquals("invalid hasNext() loop", 11, i); - assertFalse("iterator should be empty now", 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("iterator did not remove element", 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 iterator = this.bag.uniqueIterator(); - assertTrue("iterator is empty", iterator.hasNext()); - while (iterator.hasNext()) { - iterator.next(); - i++; - } - assertEquals("invalid hasNext() loop", 5, i); - assertFalse("iterator should be empty now", iterator.hasNext()); - - boolean exCaught = false; - Object element = null; - try { - element = iterator.next(); - } catch (NoSuchElementException ex) { - exCaught = true; - } - assertTrue("NoSuchElementException not thrown: " + element, exCaught); - - // start over - iterator = this.bag.uniqueIterator(); - Object next = null; - while (iterator.hasNext() && !"four".equals(next)) { - next = iterator.next(); - } - iterator.remove(); - assertEquals("iterator did not remove all copies of element", 7, this.bag.size()); - - exCaught = false; - try { - iterator.remove(); - } catch (IllegalStateException ex) { - exCaught = true; - } - assertTrue("IllegalStateException not thrown", exCaught); - - // start over - iterator = this.bag.uniqueIterator(); - this.bag.add("five"); - exCaught = false; - try { - iterator.next(); - } catch (ConcurrentModificationException ex) { - exCaught = true; - } - assertTrue("ConcurrentModificationException not thrown", exCaught); - } - - public void testHashingDistribution() throws Exception { - Bag bigBag = new HashBag(); - 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); - assertTrue("WARNING - poor load factor: " + loadFactor, loadFactor > 0.20); - assertTrue("WARNING - poor load factor: " + loadFactor, loadFactor < 0.75); - } - - public void testRemove() { - assertTrue("incorrect return value", this.bag.remove("one")); - assertFalse("element still present", this.bag.contains("one")); - assertFalse("incorrect return value", this.bag.remove("one")); - - assertTrue("incorrect return value", this.bag.remove("two")); - assertTrue("incorrect return value", this.bag.remove("two")); - assertFalse("element still present", this.bag.contains("one")); - assertFalse("incorrect return value", this.bag.remove("one")); - } - - public void testRemoveAll() { - Collection c = new ArrayList(); - c.add("one"); - c.add("three"); - assertTrue("incorrect return value", this.bag.removeAll(c)); - assertFalse("element still present", this.bag.contains("one")); - assertFalse("element still present", this.bag.contains("three")); - assertFalse("incorrect return value", this.bag.remove("one")); - assertFalse("incorrect return value", this.bag.remove("three")); - assertFalse("incorrect return value", this.bag.removeAll(c)); - } - - public void testRetainAll() { - Collection c = new ArrayList(); - c.add("one"); - c.add("three"); - assertTrue("incorrect return value", this.bag.retainAll(c)); - assertTrue("element removed", this.bag.contains("one")); - assertTrue("element removed", this.bag.contains("three")); - assertFalse("element still present", this.bag.contains("two")); - assertFalse("element still present", this.bag.contains("four")); - assertFalse("incorrect return value", this.bag.remove("two")); - assertFalse("incorrect return value", this.bag.remove("four")); - assertFalse("incorrect return value", this.bag.retainAll(c)); - } - - public void testSize() { - assertTrue("incorrect size", 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("incorrect size", 16, this.bag.size()); - } - - public void testSerialization() throws Exception { - Bag bag2 = TestTools.serialize(this.bag); - - assertTrue("same object?", this.bag != bag2); - assertEquals("incorrect size", 11, bag2.size()); - assertEquals("unequal bag", this.bag, bag2); - // look for similar elements - assertTrue("missing element", bag2.contains(null)); - assertTrue("missing element", bag2.contains("one")); - assertTrue("missing element", bag2.contains("two")); - assertTrue("missing element", bag2.contains("three")); - assertTrue("missing element", 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("bad element count", 1, nullCount); - assertEquals("bad element count", 1, oneCount); - assertEquals("bad element count", 2, twoCount); - assertEquals("bad element count", 3, threeCount); - assertEquals("bad element count", 4, fourCount); - } - - public void testToArray() { - Object[] a = this.bag.toArray(); - assertEquals("incorrect length", 11, a.length); - assertTrue("missing element", CollectionTools.contains(a, null)); - assertTrue("missing element", CollectionTools.contains(a, "one")); - assertTrue("missing element", CollectionTools.contains(a, "two")); - assertTrue("missing element", CollectionTools.contains(a, "three")); - assertTrue("missing element", CollectionTools.contains(a, "four")); - } - - public void testToArrayObjectArray() { - String[] a = new String[12]; - a[11] = "not null"; - String[] b = this.bag.toArray(a); - assertEquals("different array", a, b); - assertEquals("incorrect length", 12, a.length); - assertTrue("missing element", CollectionTools.contains(a, null)); - assertTrue("missing element", CollectionTools.contains(a, "one")); - assertTrue("missing element", CollectionTools.contains(a, "two")); - assertTrue("missing element", CollectionTools.contains(a, "three")); - assertTrue("missing element", CollectionTools.contains(a, "four")); - assertTrue("missing null element", a[11] == null); - } - - public void testToString() { - String s = this.bag.toString(); - assertTrue("invalid string prefix", s.startsWith("[")); - assertTrue("invalid string suffix", 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("missing element toString()", s.indexOf("one") != -1); - assertTrue("missing element toString()", s.indexOf("two") != -1); - assertTrue("missing element toString()", s.indexOf("three") != -1); - assertTrue("missing element toString()", s.indexOf("four") != -1); - assertTrue("missing element toString()", s.indexOf("null") != -1); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/IndentingPrintWriterTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/IndentingPrintWriterTests.java deleted file mode 100644 index c96213249b..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/IndentingPrintWriterTests.java +++ /dev/null @@ -1,107 +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.utility.tests.internal; - -import java.io.StringWriter; -import junit.framework.TestCase; -import org.eclipse.jpt.utility.internal.IndentingPrintWriter; - -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/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JDBCTypeTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JDBCTypeTests.java deleted file mode 100644 index 40f152dfa9..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JDBCTypeTests.java +++ /dev/null @@ -1,66 +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.utility.tests.internal; - -import java.sql.Types; -import junit.framework.TestCase; -import org.eclipse.jpt.utility.internal.JDBCType; - -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.getName()); - - jdbcType = JDBCType.type(Types.INTEGER); - assertEquals("INTEGER", jdbcType.getName()); - } - - public void testCode() { - JDBCType jdbcType; - jdbcType = JDBCType.type(Types.VARCHAR); - assertEquals(Types.VARCHAR, jdbcType.getCode()); - - jdbcType = JDBCType.type(Types.INTEGER); - assertEquals(Types.INTEGER, jdbcType.getCode()); - } - - 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/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JavaTypeTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JavaTypeTests.java deleted file mode 100644 index 1a0c0b826f..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JavaTypeTests.java +++ /dev/null @@ -1,250 +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.utility.tests.internal; - -import junit.framework.TestCase; -import org.eclipse.jpt.utility.internal.JavaType; - -public class JavaTypeTests extends TestCase { - - public JavaTypeTests(String name) { - super(name); - } - - public void testInvalidElementTypeNull() throws Exception { - boolean exCaught = false; - try { - JavaType javaType = new JavaType(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 JavaType("", 0); - fail("invalid JavaType: " + javaType); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - } - - public void testInvalidElementTypeArray() throws Exception { - boolean exCaught = false; - try { - JavaType javaType = new JavaType(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 JavaType(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 JavaType(void.class.getName(), 2); - fail("invalid JavaType: " + javaType); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue(exCaught); - } - - public void testElementTypeName() throws Exception { - JavaType javaType; - javaType = new JavaType(java.lang.Object.class); - assertEquals("java.lang.Object", javaType.getElementTypeName()); - - javaType = new JavaType(java.lang.Object[].class); - assertEquals("java.lang.Object", javaType.getElementTypeName()); - - javaType = new JavaType(int.class); - assertEquals("int", javaType.getElementTypeName()); - - javaType = new JavaType(int[].class); - assertEquals("int", javaType.getElementTypeName()); - - javaType = new JavaType(void.class); - assertEquals("void", javaType.getElementTypeName()); - - javaType = new JavaType(java.util.Map.Entry.class); - assertEquals("java.util.Map$Entry", javaType.getElementTypeName()); - - javaType = new JavaType(java.util.Map.Entry[][].class); - assertEquals("java.util.Map$Entry", javaType.getElementTypeName()); - } - - public void testArrayDepth() throws Exception { - JavaType javaType; - javaType = new JavaType(java.lang.Object.class); - assertEquals(0, javaType.getArrayDepth()); - - javaType = new JavaType(java.lang.Object[].class); - assertEquals(1, javaType.getArrayDepth()); - - javaType = new JavaType(int.class); - assertEquals(0, javaType.getArrayDepth()); - - javaType = new JavaType(int[].class); - assertEquals(1, javaType.getArrayDepth()); - - javaType = new JavaType(void.class); - assertEquals(0, javaType.getArrayDepth()); - - javaType = new JavaType(java.util.Map.Entry.class); - assertEquals(0, javaType.getArrayDepth()); - - javaType = new JavaType(java.util.Map.Entry[][].class); - assertEquals(2, javaType.getArrayDepth()); - } - - public void testIsArray() throws Exception { - JavaType javaType; - javaType = new JavaType(java.lang.Object.class); - assertFalse(javaType.isArray()); - - javaType = new JavaType(java.lang.Object[].class); - assertTrue(javaType.isArray()); - - javaType = new JavaType(int.class); - assertFalse(javaType.isArray()); - - javaType = new JavaType(int[].class); - assertTrue(javaType.isArray()); - - javaType = new JavaType(void.class); - assertFalse(javaType.isArray()); - - javaType = new JavaType(java.util.Map.Entry.class); - assertFalse(javaType.isArray()); - - javaType = new JavaType(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 JavaType(javaClass); - assertEquals(javaClass, javaType.javaClass()); - } - - public void testJavaClassName() throws Exception { - JavaType javaType; - javaType = new JavaType(java.lang.Object.class); - assertEquals("java.lang.Object", javaType.javaClassName()); - - javaType = new JavaType(java.lang.Object[].class); - assertEquals("[Ljava.lang.Object;", javaType.javaClassName()); - - javaType = new JavaType(int.class); - assertEquals("int", javaType.javaClassName()); - - javaType = new JavaType(int[].class); - assertEquals("[I", javaType.javaClassName()); - - javaType = new JavaType(void.class); - assertEquals("void", javaType.javaClassName()); - - javaType = new JavaType(java.util.Map.Entry.class); - assertEquals("java.util.Map$Entry", javaType.javaClassName()); - - javaType = new JavaType(java.util.Map.Entry[][].class); - assertEquals("[[Ljava.util.Map$Entry;", javaType.javaClassName()); - } - - 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 JavaType(javaClass); - assertTrue(javaType.describes(javaClass)); - } - - public void testDeclaration() throws Exception { - JavaType javaType; - javaType = new JavaType(java.lang.Object.class); - assertEquals("java.lang.Object", javaType.declaration()); - - javaType = new JavaType(java.lang.Object[].class); - assertEquals("java.lang.Object[]", javaType.declaration()); - - javaType = new JavaType(int.class); - assertEquals("int", javaType.declaration()); - - javaType = new JavaType(int[].class); - assertEquals("int[]", javaType.declaration()); - - javaType = new JavaType(void.class); - assertEquals("void", javaType.declaration()); - - javaType = new JavaType(java.util.Map.Entry.class); - assertEquals("java.util.Map.Entry", javaType.declaration()); - - javaType = new JavaType(java.util.Map.Entry[][].class); - assertEquals("java.util.Map.Entry[][]", javaType.declaration()); - } - - public void testIsPrimitive() throws Exception { - JavaType javaType; - javaType = new JavaType(java.lang.Object.class); - assertFalse(javaType.isPrimitive()); - - javaType = new JavaType(java.lang.Object[].class); - assertFalse(javaType.isPrimitive()); - - javaType = new JavaType(int.class); - assertTrue(javaType.isPrimitive()); - - javaType = new JavaType(int[].class); - assertFalse(javaType.isPrimitive()); - - javaType = new JavaType(void.class); - assertTrue(javaType.isPrimitive()); - - javaType = new JavaType(java.util.Map.Entry.class); - assertFalse(javaType.isPrimitive()); - - javaType = new JavaType(java.util.Map.Entry[][].class); - assertFalse(javaType.isPrimitive()); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JptUtilityTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JptUtilityTests.java deleted file mode 100644 index 82143f3bb4..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/JptUtilityTests.java +++ /dev/null @@ -1,49 +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.utility.tests.internal; - -import junit.framework.Test; -import junit.framework.TestSuite; -import org.eclipse.jpt.utility.internal.ClassTools; -import org.eclipse.jpt.utility.tests.internal.iterators.JptUtilityIteratorsTests; - -/** - * decentralize test creation code - */ -public class JptUtilityTests { - - public static Test suite() { - TestSuite suite = new TestSuite(ClassTools.packageNameFor(JptUtilityTests.class)); - - suite.addTest(JptUtilityIteratorsTests.suite()); - - suite.addTestSuite(BitToolsTests.class); - suite.addTestSuite(ClasspathTests.class); - suite.addTestSuite(ClassToolsTests.class); - suite.addTestSuite(CollectionToolsTests.class); - suite.addTestSuite(FileToolsTests.class); - suite.addTestSuite(HashBagTests.class); - suite.addTestSuite(IndentingPrintWriterTests.class); - suite.addTestSuite(JavaTypeTests.class); - suite.addTestSuite(JDBCTypeTests.class); - suite.addTestSuite(NameToolsTests.class); - suite.addTestSuite(ReverseComparatorTests.class); - suite.addTestSuite(StringToolsTests.class); - suite.addTestSuite(XMLStringEncoderTests.class); - - return suite; - } - - private JptUtilityTests() { - super(); - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/NameToolsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/NameToolsTests.java deleted file mode 100644 index 164fa49e03..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/NameToolsTests.java +++ /dev/null @@ -1,214 +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.utility.tests.internal; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import junit.framework.TestCase; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.NameTools; - -public class NameToolsTests extends TestCase { - - public NameToolsTests(String name) { - super(name); - } - - public void testStringAbsentIgnoreCase() { - List colorCollection = this.buildColorCollection(); - String returned = NameTools.uniqueNameForIgnoreCase("Taupe", colorCollection); - assertEquals("Taupe", returned); - } - - public void testStringPresentCaseDiffers() { - List colorCollection = this.buildColorCollection(); - String returned = NameTools.uniqueNameFor("green", colorCollection); - assertEquals("green", returned); - } - - public void testStringPresentIgnoreCase() { - List colorCollection = this.buildColorCollection(); - String returned = NameTools.uniqueNameForIgnoreCase("green", colorCollection); - assertEquals("green2", returned); - } - - public void testStringPresentWithAppendices() { - List 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 buildColorCollection() { - List colorCollection = new ArrayList(); - 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 strings = new ArrayList(); - 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 strings = new ArrayList(); - 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 strings = new ArrayList(); - strings.add("Oracle"); - strings.add("Oracle"); - strings.add("Oracle2"); - strings.add("Oracle1"); - - assertEquals("Oracle3", NameTools.uniqueNameFor("Oracle", strings)); - } - - public void testUniqueNameForIterator1() { - Collection strings = new ArrayList(); - 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 strings = new ArrayList(); - 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 strings = new ArrayList(); - strings.add("Oracle"); - strings.add("Oracle"); - strings.add("Oracle2"); - strings.add("Oracle1"); - - assertEquals("Oracle3", NameTools.uniqueNameFor("Oracle", strings.iterator())); - } - - public void testUniqueJavaNameForCollection() { - Collection strings = new ArrayList(); - strings.add("Oracle"); - strings.add("Oracle"); - strings.add("Oracle2"); - strings.add("Oracle1"); - - assertEquals("private2", NameTools.uniqueJavaNameFor("private", strings.iterator())); - assertEquals("class2", NameTools.uniqueJavaNameFor("class", 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("_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("$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); - - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/RangeTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/RangeTests.java deleted file mode 100644 index d7f2cce428..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/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.utility.tests.internal; - -import junit.framework.TestCase; -import org.eclipse.jpt.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/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ReverseComparatorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ReverseComparatorTests.java deleted file mode 100644 index 7ae00fdc2e..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/ReverseComparatorTests.java +++ /dev/null @@ -1,101 +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.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.utility.internal.ReverseComparator; - -public class ReverseComparatorTests extends TestCase { - private Comparator naturalReverseComparator; - private Comparator customComparator; - private Comparator customReverseComparator; - - public ReverseComparatorTests(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - this.naturalReverseComparator = new ReverseComparator(); - this.customComparator = this.buildCustomComparator(); - this.customReverseComparator = new ReverseComparator(this.customComparator); - } - - private Comparator buildCustomComparator() { - return new Comparator() { - 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 buildUnsortedList() { - List result = new ArrayList(); - 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 buildNaturallySortedList() { - List result = new ArrayList(this.buildUnsortedList()); - Collections.sort(result); - return result; - } - - private List buildCustomSortedList() { - List result = new ArrayList(this.buildUnsortedList()); - Collections.sort(result, this.customComparator); - return result; - } - - @Override - protected void tearDown() throws Exception { - TestTools.clear(this); - super.tearDown(); - } - - public void testNatural() { - List list = this.buildUnsortedList(); - Collections.sort(list, this.naturalReverseComparator); - this.verifyList(this.buildNaturallySortedList(), list); - } - - public void testCustom() { - List list = this.buildUnsortedList(); - Collections.sort(list, this.customReverseComparator); - this.verifyList(this.buildCustomSortedList(), list); - } - - private void verifyList(List normal, List 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/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/StringToolsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/StringToolsTests.java deleted file mode 100644 index 454cb81651..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/StringToolsTests.java +++ /dev/null @@ -1,833 +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.utility.tests.internal; - -import java.io.StringWriter; -import java.io.Writer; -import junit.framework.TestCase; -import org.eclipse.jpt.utility.internal.StringTools; - -public class StringToolsTests extends TestCase { - - public StringToolsTests(String name) { - super(name); - } - - // ********** 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", new String(StringTools.pad(new char[] { 'f', 'r', 'e', 'd' }, 4))); - assertEquals("fred ", new String(StringTools.pad(new char[] { 'f', 'r', 'e', 'd' }, 6))); - boolean exThrown = false; - try { - assertEquals("fr", new String(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 testPadOrTruncate() { - assertEquals("fred", StringTools.padOrTruncate("fred", 4)); - assertEquals("fred ", StringTools.padOrTruncate("fred", 6)); - assertEquals("fr", StringTools.padOrTruncate("fred", 2)); - } - - public void testPadOrTruncateCharArray() { - assertEquals("fred", new String(StringTools.padOrTruncate(new char[] { 'f', 'r', 'e', 'd' }, 4))); - assertEquals("fred ", new String(StringTools.padOrTruncate(new char[] { 'f', 'r', 'e', 'd' }, 6))); - assertEquals("fr", new String(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 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", new String(StringTools.zeroPad(new char[] { '1', '2', '3', '4' }, 4))); - assertEquals("001234", new String(StringTools.zeroPad(new char[] { '1', '2', '3', '4' }, 6))); - boolean exThrown = false; - try { - assertEquals("12", new String(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 testZeroPadOrTruncate() { - assertEquals("1234", StringTools.zeroPadOrTruncate("1234", 4)); - assertEquals("001234", StringTools.zeroPadOrTruncate("1234", 6)); - assertEquals("34", StringTools.zeroPadOrTruncate("1234", 2)); - } - - public void testZeroPadOrTruncateCharArray() { - assertEquals("1234", new String(StringTools.zeroPadOrTruncate(new char[] { '1', '2', '3', '4' }, 4))); - assertEquals("001234", new String(StringTools.zeroPadOrTruncate(new char[] { '1', '2', '3', '4' }, 6))); - assertEquals("34", new String(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()); - } - - // ********** wrapping ********** - - public void testWrap() { - this.verifyWrap("Employee", "123", "123Employee123"); - this.verifyWrap("123", "123", "123123123"); - this.verifyWrap("", "123", "123123"); - } - - private void verifyWrap(String string, String wrap, String expectedString) { - assertEquals(expectedString, StringTools.wrap(string, wrap)); - } - - public void testWrapOnWriter() { - this.verifyWrapOnWriter("Employee", "123", "123Employee123"); - this.verifyWrapOnWriter("123", "123", "123123123"); - this.verifyWrapOnWriter("", "123", "123123"); - } - - private void verifyWrapOnWriter(String string, String wrap, String expectedString) { - Writer writer = new StringWriter(); - StringTools.wrapOn(string, wrap, writer); - assertEquals(expectedString, writer.toString()); - } - - public void testWrapOnStringBuffer() { - this.verifyWrapOnStringBuffer("Employee", "123", "123Employee123"); - this.verifyWrapOnStringBuffer("123", "123", "123123123"); - this.verifyWrapOnStringBuffer("", "123", "123123"); - } - - private void verifyWrapOnStringBuffer(String string, String wrap, String expectedString) { - StringBuffer sb = new StringBuffer(); - StringTools.wrapOn(string, wrap, sb); - assertEquals(expectedString, sb.toString()); - } - - public void testQuote() { - this.verifyQuote("Employee", "\"Employee\""); - this.verifyQuote("123", "\"123\""); - this.verifyQuote("", "\"\""); - } - - 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("", "\"\""); - } - - 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("", "\"\""); - } - - private void verifyQuoteOnStringBuffer(String string, String expectedString) { - StringBuffer sb = new StringBuffer(); - 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, new String(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 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, new String(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()); - } - - // ********** 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, new String(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 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 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, new String(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 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 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()); - } - - // ********** 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 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')); - } - - // ********** conversions ********** - - 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 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 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()); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/TestTools.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/TestTools.java deleted file mode 100644 index 04a3d84786..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/TestTools.java +++ /dev/null @@ -1,161 +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.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.StringWriter; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import junit.framework.TestCase; -import junit.framework.TestFailure; -import junit.framework.TestResult; - -/** - * various tools that can be used by test cases - */ -public final class TestTools { - - /** - * test an object's implementation of Serializable by serializing the - * specified object to a byte array; then de-serializing the byte array and - * returning the resultant object - */ - public static 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 readObject(ObjectInput objectInput) throws IOException, ClassNotFoundException { - return (T) objectInput.readObject(); - } - - /** - * some tests require access to the Web (e.g. any tests that parse an XML - * document that specifies a DTD or Schema that is loaded from the Web); use - * this method to configure the JDK proxy settings - */ - public static void setUpOracleProxy() { - System.setProperty("http.proxyHost", "www-proxy.us.oracle.com"); - System.setProperty("http.proxyPort", "80"); - } - - /** - * some tests require access to the Web (e.g. any tests that parse an XML - * document that specifies a DTD or Schema that is loaded from the Web); use - * this method to configure the JDK proxy settings via the command-line - */ - public static String[] buildOracleProxyCommandLineOptions() { - return new String[] { "-Dhttp.proxyHost=www-proxy.us.oracle.com", "-Dhttp.proxyPort=80" }; - } - - /** - * 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); - } - - /** - * execute the specified test and dump the results to the console - */ - 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 = (TestFailure) result.failures().nextElement(); - } else { - failure = (TestFailure) 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(); - } - - private static final Class TestCase_class = TestCase.class; - - /** - * 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 #tearDown() method. - */ - public static void clear(TestCase testCase) throws IllegalAccessException { - for (Class tempClass = testCase.getClass(); tempClass != TestCase_class; tempClass = tempClass.getSuperclass()) { - Field[] fields = tempClass.getDeclaredFields(); - for (int i = fields.length; i-- > 0;) { - Field field = fields[i]; - // 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); - } - } - } - - /** - * Workaround for a JUnit bug: JUnit does not configure the testing Thread - * with a context class loader. This should probably happen in - * TestRunner.doRunTest(Test), just before starting the thread. - */ - public static void setUpJUnitThreadContextClassLoader() { - Thread.currentThread().setContextClassLoader(TestTools.class.getClassLoader()); - } - - private TestTools() { - super(); - throw new UnsupportedOperationException(); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/XMLStringEncoderTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/XMLStringEncoderTests.java deleted file mode 100644 index 3b104b9b89..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/XMLStringEncoderTests.java +++ /dev/null @@ -1,135 +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.utility.tests.internal; - -import junit.framework.TestCase; -import org.eclipse.jpt.utility.internal.FileTools; -import org.eclipse.jpt.utility.internal.XMLStringEncoder; - -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 = "?foo?"; - assertEquals(expected, encoder.encode(s)); - - s = "?foo&123"; - expected = "?foo&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 = "?foo?"; - String expected = "?foo?"; - assertEquals(expected, encoder.decode(s)); - - s = "?foo&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"); - } - - 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/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ArrayIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ArrayIteratorTests.java deleted file mode 100644 index d7cf76ad44..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ArrayIteratorTests.java +++ /dev/null @@ -1,126 +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.utility.tests.internal.iterators; - -import java.util.Iterator; -import java.util.NoSuchElementException; -import junit.framework.TestCase; -import org.eclipse.jpt.utility.internal.iterators.ArrayIterator; - -public class ArrayIteratorTests extends TestCase { - - public ArrayIteratorTests(String name) { - super(name); - } - - public void testHasNext() { - int i = 0; - for (Iterator stream = this.buildIterator(); stream.hasNext();) { - stream.next(); - i++; - } - assertEquals(this.buildArray().length, i); - } - - public void testNext() { - int i = 0; - for (Iterator stream = this.buildIterator(); stream.hasNext();) { - assertEquals("bogus element", ++i, Integer.parseInt(stream.next())); - } - } - - public void testNoSuchElementException() { - boolean exCaught = false; - Iterator 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 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] = 0; - integers[1] = 1; - integers[2] = 2; - int i = 0; - for (Iterator stream = new ArrayIterator(integers); stream.hasNext();) { - assertEquals(i++, stream.next().intValue()); - } - assertEquals(integers.length, i); - } - - public void testVarargs() { - int i = 0; - for (Iterator stream = new ArrayIterator(0, 1, 2); stream.hasNext();) { - assertEquals(i++, stream.next().intValue()); - } - assertEquals(3, i); - } - - public void triggerIllegalArgumentException(int start, int length) { - boolean exCaught = false; - Iterator stream = null; - try { - stream = this.buildIterator(start, length); - } catch (IllegalArgumentException ex) { - exCaught = true; - } - assertTrue("IllegalArgumentException not thrown: " + stream, exCaught); - } - - Iterator buildIterator() { - return this.buildIterator(this.buildArray()); - } - - Iterator buildIterator(String[] array) { - return new ArrayIterator(array); - } - - Iterator buildIterator(int start, int length) { - return this.buildIterator(this.buildArray(), start, length); - } - - Iterator buildIterator(String[] array, int start, int length) { - return new ArrayIterator(array, start, length); - } - - String[] buildArray() { - return new String[] { "1", "2", "3", "4", "5", "6", "7", "8" }; - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ArrayListIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ArrayListIteratorTests.java deleted file mode 100644 index 9d82950b94..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ArrayListIteratorTests.java +++ /dev/null @@ -1,150 +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.utility.tests.internal.iterators; - -import java.util.Iterator; -import java.util.ListIterator; -import java.util.NoSuchElementException; -import org.eclipse.jpt.utility.internal.iterators.ArrayListIterator; - -public class ArrayListIteratorTests extends ArrayIteratorTests { - - public ArrayListIteratorTests(String name) { - super(name); - } - - public void testHasPrevious() { - ListIterator 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 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 stream = this.buildListIterator(); - while (stream.hasNext()) { - assertEquals(i, stream.nextIndex()); - stream.next(); - i++; - } - assertEquals(i, stream.nextIndex()); - } - - public void testPreviousIndex() { - int i = 0; - ListIterator 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 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 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 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 - public void testGenerics() { - Integer[] integers = new Integer[3]; - integers[0] = 0; - integers[1] = 1; - integers[2] = 2; - int i = 0; - for (Iterator stream = new ArrayListIterator(integers); stream.hasNext();) { - assertEquals(i++, stream.next().intValue()); - } - assertEquals(integers.length, i); - } - - @Override - public void testVarargs() { - int i = 0; - for (Iterator stream = new ArrayListIterator(0, 1, 2); stream.hasNext();) { - assertEquals(i++, stream.next().intValue()); - } - assertEquals(3, i); - } - - private ListIterator buildListIterator() { - return this.buildListIterator(this.buildArray()); - } - - private ListIterator buildListIterator(String[] array) { - return new ArrayListIterator(array); - } - - @Override - Iterator buildIterator(String[] array) { - return new ArrayListIterator(array); - } - - @Override - Iterator buildIterator(String[] array, int start, int length) { - return new ArrayListIterator(array, start, length); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ChainIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ChainIteratorTests.java deleted file mode 100644 index 59cd3073b9..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ChainIteratorTests.java +++ /dev/null @@ -1,119 +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.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.utility.internal.iterators.ChainIterator; - -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> stream = this.buildIterator(); stream.hasNext();) { - stream.next(); - i++; - } - assertEquals(VECTOR_HIERARCHY.length, i); - } - - public void testInnerHasNext() { - int i = 0; - for (Iterator> stream = this.buildInnerIterator(); stream.hasNext();) { - stream.next(); - i++; - } - assertEquals(VECTOR_HIERARCHY.length, i); - } - - public void testNext() { - int i = 0; - for (Iterator> stream = this.buildIterator(); stream.hasNext(); i++) { - assertEquals("bogus link", VECTOR_HIERARCHY[i], stream.next()); - } - } - - public void testInnerNext() { - int i = 0; - for (Iterator> stream = this.buildInnerIterator(); stream.hasNext(); i++) { - assertEquals("bogus link", VECTOR_HIERARCHY[i], stream.next()); - } - } - - public void testNoSuchElementException() { - boolean exCaught = false; - Iterator> 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> 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> buildIterator() { - return this.buildChainIterator(Vector.class, this.buildLinker()); - } - - private Iterator> buildInnerIterator() { - return this.buildInnerChainIterator(Vector.class); - } - - private Iterator> buildChainIterator(Class startLink, ChainIterator.Linker> linker) { - return new ChainIterator>(startLink, linker); - } - - private ChainIterator.Linker> buildLinker() { - // chain up the class's hierarchy - return new ChainIterator.Linker>() { - public Class nextLink(Class currentLink) { - return currentLink.getSuperclass(); - } - }; - } - - private Iterator> buildInnerChainIterator(Class startLink) { - // chain up the class's hierarchy - return new ChainIterator>(startLink) { - @Override - protected Class nextLink(Class currentLink) { - return currentLink.getSuperclass(); - } - }; - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CloneIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CloneIteratorTests.java deleted file mode 100644 index e3afdb585f..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CloneIteratorTests.java +++ /dev/null @@ -1,252 +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.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.utility.internal.iterators.CloneIterator; -import org.eclipse.jpt.utility.tests.internal.TestTools; - -public class CloneIteratorTests extends TestCase { - Collection originalCollection; - - private boolean concurrentProblem; - private Collection concurrentCollection; - - public CloneIteratorTests(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - this.originalCollection = this.buildCollection(); - } - - @Override - protected void tearDown() throws Exception { - TestTools.clear(this); - super.tearDown(); - } - - public void testHasNext() { - int originalSize = this.originalCollection.size(); - int i = 0; - for (Iterator 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 nestedIterator = this.originalCollection.iterator(); - for (Iterator stream = this.buildCloneIterator(); stream.hasNext();) { - assertEquals("bogus element", nestedIterator.next(), stream.next()); - } - } - - public void testNoSuchElementException() { - boolean exCaught = false; - Iterator 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 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.Mutator eliminator = new CloneIterator.Mutator() { - public void remove(String current) { - CloneIteratorTests.this.originalCollection.remove(current); - } - }; - this.verifyRemove(new CloneIterator(this.originalCollection, eliminator)); - } - - public void testRemoveSubclass() { - this.verifyRemove(new CloneIterator(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 slow = new SlowCollection(); - this.populateCollection(slow); - // using the unsynchronized collection will cause the test to fail - // this.originalCollection = slow; - this.originalCollection = Collections.synchronizedCollection(slow); - - this.concurrentProblem = false; - this.concurrentCollection = new ArrayList(); - Thread thread = new Thread(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"); - while (thread.isAlive()) { - // wait for the other thread to finish - Thread.yield(); - } - assertFalse(this.concurrentProblem); - Collection expected = new ArrayList(); - this.populateCollection(expected); - assertEquals(expected, this.concurrentCollection); - } - - private Runnable buildRunnable() { - return new Runnable() { - public void run() { - CloneIteratorTests.this.loopWithCloneIterator(); - } - }; - } - - /** - * use a clone iterator to loop over the "slow" collection and copy its - * contents to the concurrent collection - */ - void loopWithCloneIterator() { - try { - for (Iterator stream = this.buildCloneIterator(); stream.hasNext();) { - this.concurrentCollection.add(stream.next()); - } - } catch (Throwable t) { - this.concurrentProblem = true; - } - } - - private void verifyRemove(Iterator 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 buildCloneIterator() { - return this.buildCloneIterator(this.originalCollection); - } - - private Iterator buildCloneIterator(Collection c) { - return new CloneIterator(c); - } - - private Collection buildCollection() { - Collection c = this.buildEmptyCollection(); - this.populateCollection(c); - return c; - } - - protected Collection buildEmptyCollection() { - return new ArrayList(); - } - - private void populateCollection(Collection 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 extends ArrayList { - 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 - try { - Thread.sleep(100); - } catch (InterruptedException ex) { - throw new RuntimeException(ex); - } - return super.toArray(); - } - - synchronized void setHasStartedClone(boolean hasStartedClone) { - this.hasStartedClone = hasStartedClone; - } - - synchronized boolean hasStartedClone() { - return this.hasStartedClone; - } - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CloneListIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CloneListIteratorTests.java deleted file mode 100644 index c6045a9f12..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CloneListIteratorTests.java +++ /dev/null @@ -1,408 +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.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 junit.framework.TestCase; -import org.eclipse.jpt.utility.internal.iterators.CloneListIterator; -import org.eclipse.jpt.utility.tests.internal.TestTools; - -public class CloneListIteratorTests extends TestCase { - List originalList; - - private boolean concurrentProblem; - private List concurrentList; - - public CloneListIteratorTests(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - this.originalList = this.buildList(); - } - - @Override - protected void tearDown() throws Exception { - TestTools.clear(this); - super.tearDown(); - } - - public void testHasNext() { - int originalSize = this.originalList.size(); - int i = 0; - for (ListIterator 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 nestedListIterator = this.buildNestedListIterator(); - for (ListIterator stream = this.buildCloneListIterator(); stream.hasNext();) { - assertEquals("bogus element", nestedListIterator.next(), stream.next()); - } - } - - public void testIndex() { - ListIterator cloneListIterator = this.buildCloneListIterator(); - ListIterator 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 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 nestedListIterator = this.buildNestedListIterator(); - ListIterator 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 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 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 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 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(this.originalList, this.buildMutator())); - } - - public void testModifyMutatorPrevious() { - this.verifyModifyPrevious(new CloneListIterator(this.originalList, this.buildMutator())); - } - - private CloneListIterator.Mutator buildMutator() { - return new CloneListIterator.Mutator() { - 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 buildSubclass() { - return new CloneListIterator(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 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("IllegalStateException not thrown", 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("IllegalStateException not thrown", 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 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 buildCloneListIterator() { - return this.buildCloneListIterator(this.originalList); - } - - private ListIterator buildCloneListIterator(List list) { - return new CloneListIterator(list); - } - - private ListIterator buildNestedListIterator() { - return this.originalList.listIterator(); - } - - private List buildList() { - List list = this.buildEmptyList(); - this.populateList(list); - return list; - } - - private void populateList(List 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 buildEmptyList() { - return new ArrayList(); - } - - /** - * 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 slow = new CloneIteratorTests.SlowCollection(); - this.populateList(slow); - // using the unsynchronized list will cause the test to fail - // this.originalList = slow; - this.originalList = Collections.synchronizedList(slow); - - this.concurrentProblem = false; - this.concurrentList = new ArrayList(); - Thread thread = new Thread(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"); - while (thread.isAlive()) { - // wait for the other thread to finish - Thread.yield(); - } - assertFalse(this.concurrentProblem); - List expected = new ArrayList(); - this.populateList(expected); - assertEquals(expected, this.concurrentList); - } - - private Runnable buildRunnable() { - return new Runnable() { - public void run() { - CloneListIteratorTests.this.loopWithCloneListIterator(); - } - }; - } - - /** - * use a clone iterator to loop over the "slow" collection and copy its - * contents to the concurrent collection - */ - void loopWithCloneListIterator() { - try { - for (ListIterator stream = this.buildCloneListIterator(); stream.hasNext();) { - this.concurrentList.add(stream.next()); - } - } catch (Throwable t) { - this.concurrentProblem = true; - } - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CompositeIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CompositeIteratorTests.java deleted file mode 100644 index d7173cefa8..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CompositeIteratorTests.java +++ /dev/null @@ -1,334 +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.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.utility.internal.iterators.CompositeIterator; - -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 stream) { - this.verifyHasAnother(8, stream); - } - - void verifyHasAnother(int expected, Iterator 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 stream) { - this.verifyAnother(1, stream); - } - - void verifyAnother(int start, Iterator stream) { - int index = start; - while (stream.hasNext()) { - assertEquals("bogus element", String.valueOf(index++), stream.next().substring(0, 1)); - } - } - - public void testRemove() { - List list1 = this.buildList1(); - Object lastElement1 = list1.get(list1.size() - 1); - List list2 = this.buildList2(); - List list3 = this.buildList3(); - - List> list = new ArrayList>(); - list.add(list1.listIterator()); - list.add(list2.listIterator()); - list.add(list3.listIterator()); - - Iterator 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 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 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(this.buildCompositeIterator()); - } - - void verifyIllegalStateException(Iterator 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 stream) { - int i = 0; - while (stream.hasNext()) { - stream.next(); - i++; - } - assertEquals(0, i); - } - - public void testEmptyNoSuchElementException1() { - this.verifyNoSuchElementException(this.buildEmptyCompositeIterator1()); - } - - public void testEmptyIllegalStateException1() { - this.verifyIllegalStateException(this.buildEmptyCompositeIterator1()); - } - - public void testEmptyHasAnother2() { - this.verifyEmptyHasAnother(this.buildEmptyCompositeIterator2()); - } - - public void testEmptyNoSuchElementException2() { - this.verifyNoSuchElementException(this.buildEmptyCompositeIterator2()); - } - - public void testEmptyIllegalStateException2() { - this.verifyIllegalStateException(this.buildEmptyCompositeIterator2()); - } - - Iterator buildCompositeIterator() { - return this.buildCompositeIterator(this.buildIterators()); - } - - Iterator buildEmptyCompositeIterator1() { - return this.buildCompositeIterator(this.buildEmptyIterators1()); - } - - Iterator buildEmptyCompositeIterator2() { - return this.buildCompositeIterator(this.buildEmptyIterators2()); - } - - Iterator buildUnmodifiableCompositeIterator() { - return this.buildCompositeIterator(this.buildUnmodifiableIterators()); - } - - // leave unchecked so we can override in subclass - @SuppressWarnings("unchecked") - Iterator buildCompositeIterator(Iterator iterators) { - return new CompositeIterator(iterators); - } - - // use vararg constructor - @SuppressWarnings("unchecked") - Iterator buildCompositeIterator2() { - return new CompositeIterator(this.buildIterator1(), this.buildIterator2(), this.buildIterator3()); - } - - // use vararg constructor - @SuppressWarnings("unchecked") - Iterator buildCompositeIterator3() { - return new CompositeIterator(new Iterator[] { this.buildIterator1(), this.buildIterator2(), this.buildIterator3() }); - } - - Iterator buildCompositeIterator(String string, Iterator iterator) { - return new CompositeIterator(string, iterator); - } - - ListIterator> buildIterators() { - List> list = new ArrayList>(); - list.add(this.buildIterator1()); - list.add(this.buildIterator2()); - list.add(this.buildIterator3()); - return list.listIterator(); - } - - ListIterator> buildEmptyIterators1() { - return this.buildEmptyIteratorIterator(); - } - - ListIterator> buildEmptyIterators2() { - List> list = new ArrayList>(); - list.add(this.buildEmptyStringIterator()); - list.add(this.buildEmptyStringIterator()); - list.add(this.buildEmptyStringIterator()); - return list.listIterator(); - } - - ListIterator> buildUnmodifiableIterators() { - List> list = new ArrayList>(); - list.add(this.buildUnmodifiableIterator1()); - list.add(this.buildUnmodifiableIterator2()); - list.add(this.buildUnmodifiableIterator3()); - return list.listIterator(); - } - - ListIterator buildIterator1() { - return this.buildList1().listIterator(); - } - - ListIterator buildIterator2() { - return this.buildList2().listIterator(); - } - - ListIterator buildIterator3() { - return this.buildList3().listIterator(); - } - - ListIterator buildUnmodifiableIterator1() { - return this.buildUnmodifiableList1().listIterator(); - } - - ListIterator buildUnmodifiableIterator2() { - return this.buildUnmodifiableList2().listIterator(); - } - - ListIterator buildUnmodifiableIterator3() { - return this.buildUnmodifiableList3().listIterator(); - } - - ListIterator> buildEmptyIteratorIterator() { - return (new ArrayList>()).listIterator(); - } - - ListIterator buildEmptyStringIterator() { - return (new ArrayList()).listIterator(); - } - - List buildList1() { - List list = new ArrayList(); - list.add("1"); - list.add("22"); - list.add("333"); - list.add("4444"); - return list; - } - - List buildList2() { - return new ArrayList(); - } - - List buildList3() { - List list = new ArrayList(); - list.add("55555"); - list.add("666666"); - list.add("7777777"); - list.add("88888888"); - return list; - } - - List buildUnmodifiableList1() { - return Collections.unmodifiableList(this.buildList1()); - } - - List buildUnmodifiableList2() { - return Collections.unmodifiableList(this.buildList2()); - } - - List buildUnmodifiableList3() { - return Collections.unmodifiableList(this.buildList3()); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CompositeListIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CompositeListIteratorTests.java deleted file mode 100644 index f2de1d1426..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/CompositeListIteratorTests.java +++ /dev/null @@ -1,404 +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.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.utility.internal.iterators.CompositeListIterator; - -public class CompositeListIteratorTests extends CompositeIteratorTests { - - public CompositeListIteratorTests(String name) { - super(name); - } - - @Override - void verifyHasAnother(Iterator stream) { - super.verifyHasAnother(stream); - ListIterator stream2 = (ListIterator) stream; - int i = 0; - while (stream2.hasPrevious()) { - stream2.previous(); - i++; - } - assertEquals(8, i); - } - - @Override - void verifyAnother(Iterator stream) { - super.verifyAnother(stream); - int i = 8; - ListIterator stream2 = (ListIterator) stream; - while (stream2.hasPrevious()) { - assertEquals("bogus element", String.valueOf(i--), stream2.previous().substring(0, 1)); - } - } - - @Override - public void testRemove() { - super.testRemove(); - List list1 = this.buildList1(); - List list2 = this.buildList2(); - List list3 = this.buildList3(); - Object firstElement3 = list3.get(0); - - List> list = new ArrayList>(); - list.add(list1.listIterator()); - list.add(list2.listIterator()); - list.add(list3.listIterator()); - - ListIterator stream = (ListIterator) 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 list1 = this.buildList1(); - Object lastElement1 = list1.get(list1.size() - 1); - List list2 = this.buildList2(); - List list3 = this.buildList3(); - Object firstElement3 = list3.get(0); - - List> list = new ArrayList>(); - list.add(list1.listIterator()); - list.add(list2.listIterator()); - list.add(list3.listIterator()); - - ListIterator stream = (ListIterator) 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) this.buildCompositeIterator(); - stream.add("blah"); - assertFalse("added element should be placed BEFORE the \"cursor\"", stream.next().equals("blah")); - - stream = (ListIterator) this.buildCompositeIterator(); - stream.add("blah"); - assertTrue("added element should be placed BEFORE the \"cursor\"", stream.previous().equals("blah")); - - stream = (ListIterator) 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) 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) this.buildCompositeIterator(); - stream.next(); - stream.add("blah"); - assertFalse("added element should be placed BEFORE the \"cursor\"", stream.next().equals("blah")); - - stream = (ListIterator) this.buildCompositeIterator(); - stream.next(); - stream.add("blah"); - assertTrue("added element should be placed BEFORE the \"cursor\"", stream.previous().equals("blah")); - - stream = (ListIterator) 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) 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) this.buildCompositeIterator(); - while (stream.hasNext()) { - stream.next(); - } - stream.add("blah"); - assertFalse("added element should be placed BEFORE the \"cursor\"", stream.hasNext()); - - stream = (ListIterator) 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 list1 = this.buildList1(); - Object lastElement1 = list1.get(list1.size() - 1); - List list2 = this.buildList2(); - List list3 = this.buildList3(); - Object firstElement3 = list3.get(0); - - List> list = new ArrayList>(); - list.add(list1.listIterator()); - list.add(list2.listIterator()); - list.add(list3.listIterator()); - - ListIterator stream = (ListIterator) 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)); - } - - public void testNextIndexPreviousIndex() { - int i = 0; - ListIterator stream = (ListIterator) 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); - } - - public void testPreviousIndex() { - // TODO - } - - @Override - void verifyNoSuchElementException(Iterator stream) { - super.verifyNoSuchElementException(stream); - ListIterator stream2 = (ListIterator) 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 stream) { - super.verifyUnsupportedOperationException(stream); - boolean exCaught = false; - ListIterator stream2 = (ListIterator) 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 stream) { - super.verifyIllegalStateException(stream); - ListIterator stream2 = (ListIterator) stream; - boolean exCaught = false; - try { - stream2.set("junk"); - } catch (IllegalStateException ex) { - exCaught = true; - } - assertTrue("IllegalStateException not thrown", exCaught); - } - - @Override - void verifyEmptyHasAnother(Iterator stream) { - super.verifyEmptyHasAnother(stream); - ListIterator stream2 = (ListIterator) 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 buildCompositeIterator(Iterator iterators) { - return new CompositeListIterator((ListIterator>) iterators); - } - - @Override - @SuppressWarnings("unchecked") - Iterator buildCompositeIterator2() { - return new CompositeListIterator(this.buildIterator1(), this.buildIterator2(), this.buildIterator3()); - } - - @Override - @SuppressWarnings("unchecked") - Iterator buildCompositeIterator3() { - return new CompositeListIterator(new ListIterator[] { this.buildIterator1(), this.buildIterator2(), this.buildIterator3() }); - } - - Iterator buildCompositeIterator(String string, ListIterator iterator) { - return this.buildCompositeListIterator(string, iterator); - } - - ListIterator buildCompositeListIterator(String string, ListIterator iterator) { - return new CompositeListIterator(string, iterator); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyEnumerationTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyEnumerationTests.java deleted file mode 100644 index 98697897b7..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyEnumerationTests.java +++ /dev/null @@ -1,53 +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.utility.tests.internal.iterators; - -import java.util.Enumeration; -import java.util.NoSuchElementException; -import junit.framework.TestCase; -import org.eclipse.jpt.utility.internal.iterators.EmptyEnumeration; - -public class EmptyEnumerationTests extends TestCase { - - public EmptyEnumerationTests(String name) { - super(name); - } - - public void testHasMoreElements() { - int i = 0; - for (Enumeration stream = EmptyEnumeration.instance(); stream.hasMoreElements();) { - stream.nextElement(); - i++; - } - assertEquals(0, i); - } - - public void testNextElement() { - for (Enumeration stream = EmptyEnumeration.instance(); stream.hasMoreElements();) { - fail("bogus element: " + stream.nextElement()); - } - } - - public void testNoSuchElementException() { - boolean exCaught = false; - Enumeration 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/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyIteratorTests.java deleted file mode 100644 index 6985ad4ffa..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyIteratorTests.java +++ /dev/null @@ -1,63 +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.utility.tests.internal.iterators; - -import java.util.Iterator; -import java.util.NoSuchElementException; -import junit.framework.TestCase; -import org.eclipse.jpt.utility.internal.iterators.EmptyIterator; - -public class EmptyIteratorTests extends TestCase { - - public EmptyIteratorTests(String name) { - super(name); - } - - public void testHasNext() { - int i = 0; - for (Iterator stream = EmptyIterator.instance(); stream.hasNext();) { - stream.next(); - i++; - } - assertEquals(0, i); - } - - public void testNext() { - for (Iterator stream = EmptyIterator.instance(); stream.hasNext();) { - fail("bogus element: " + stream.next()); - } - } - - public void testNoSuchElementException() { - boolean exCaught = false; - Iterator 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/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyListIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyListIteratorTests.java deleted file mode 100644 index 35c8efc011..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EmptyListIteratorTests.java +++ /dev/null @@ -1,127 +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.utility.tests.internal.iterators; - -import java.util.ListIterator; -import java.util.NoSuchElementException; -import junit.framework.TestCase; -import org.eclipse.jpt.utility.internal.iterators.EmptyListIterator; - -public class EmptyListIteratorTests extends TestCase { - - public EmptyListIteratorTests(String name) { - super(name); - } - - public void testHasNext() { - int i = 0; - for (ListIterator stream = EmptyListIterator.instance(); stream.hasNext();) { - stream.next(); - i++; - } - assertEquals(0, i); - } - - public void testNext() { - for (ListIterator stream = EmptyListIterator.instance(); stream.hasNext();) { - fail("bogus element: " + stream.next()); - } - } - - public void testNextIndex() { - ListIterator stream = EmptyListIterator.instance(); - assertEquals(0, stream.nextIndex()); - } - - public void testHasPrevious() { - ListIterator 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 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 stream = EmptyListIterator.instance(); - assertEquals(-1, stream.previousIndex()); - } - - public void testNoSuchElementException() { - boolean exCaught = false; - ListIterator 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/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EnumerationIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EnumerationIteratorTests.java deleted file mode 100644 index 528f101110..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/EnumerationIteratorTests.java +++ /dev/null @@ -1,119 +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.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.utility.internal.iterators.EnumerationIterator; - -public class EnumerationIteratorTests extends TestCase { - - public EnumerationIteratorTests(String name) { - super(name); - } - - public void testHasNext() { - int i = 0; - for (Iterator stream = this.buildIterator(); stream.hasNext();) { - stream.next(); - i++; - } - assertEquals(this.buildVector().size(), i); - } - - public void testHasNextUpcast() { - int i = 0; - for (Iterator stream = this.buildIteratorUpcast(); stream.hasNext();) { - stream.next(); - i++; - } - assertEquals(this.buildVector().size(), i); - } - - public void testNext() { - Enumeration enumeration = this.buildEnumeration(); - for (Iterator stream = this.buildIterator(); stream.hasNext();) { - assertEquals("bogus element", enumeration.nextElement(), stream.next()); - } - } - - public void testNextUpcast() { - Enumeration enumeration = this.buildEnumeration(); - for (Iterator stream = this.buildIteratorUpcast(); stream.hasNext();) { - assertEquals("bogus element", enumeration.nextElement(), stream.next()); - } - } - - public void testNoSuchElementException() { - boolean exCaught = false; - Iterator 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 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 buildIterator() { - return this.buildIterator(this.buildEnumeration()); - } - - private Iterator buildIterator(Enumeration enumeration) { - return new EnumerationIterator(enumeration); - } - - private Enumeration buildEnumeration() { - return this.buildVector().elements(); - } - - private Vector buildVector() { - Vector v = new Vector(); - 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 buildIteratorUpcast() { - return this.buildIteratorUpcast(this.buildEnumeration()); - } - - private Iterator buildIteratorUpcast(Enumeration enumeration) { - return new EnumerationIterator(enumeration); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/FilteringIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/FilteringIteratorTests.java deleted file mode 100644 index c268245304..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/FilteringIteratorTests.java +++ /dev/null @@ -1,285 +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.utility.tests.internal.iterators; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.NoSuchElementException; -import junit.framework.TestCase; -import org.eclipse.jpt.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.Filter; -import org.eclipse.jpt.utility.internal.SimpleFilter; -import org.eclipse.jpt.utility.internal.iterators.FilteringIterator; - -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 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 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 stream = this.buildAcceptIterator(); stream.hasNext();) { - stream.next(); - i++; - } - assertEquals(6, i); - } - - public void testAcceptNext() { - for (Iterator stream = this.buildAcceptIterator(); stream.hasNext();) { - assertTrue("bogus accept", stream.next().startsWith(PREFIX)); - } - } - - public void testInnerHasNext() { - int i = 0; - for (Iterator stream = this.buildInnerIterator(); stream.hasNext();) { - stream.next(); - i++; - } - assertEquals(6, i); - } - - public void testInnerNext() { - for (Iterator stream = this.buildInnerIterator(); stream.hasNext();) { - assertTrue("bogus accept", stream.next().startsWith(PREFIX)); - } - } - - public void testRejectHasNext() { - int i = 0; - for (Iterator stream = this.buildRejectIterator(); stream.hasNext();) { - stream.next(); - i++; - } - assertEquals(2, i); - } - - public void testRejectNext() { - for (Iterator 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 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 stream = this.buildInnerIterator2(); stream.hasNext();) { - assertTrue("bogus accept", stream.next().startsWith(PREFIX)); - } - } - - // test a filtered iterator with a nested iterator of a sub-type (Number vs. Integer) - public void testGenerics1() { - List integers = new ArrayList(); - integers.add(new Integer(0)); - integers.add(new Integer(1)); - integers.add(new Integer(2)); - integers.add(new Integer(3)); - Iterator stream = new FilteringIterator(integers.iterator()) { - @Override - protected boolean accept(Object o) { - return ((Number) o).intValue() > 1; - } - }; - assertEquals(2, CollectionTools.size(stream)); - } - - // test a filtered iterator with a nested iterator of a super-type (Integer vs. Number) - // i.e. trust that Filter will only return the appropriate sub-type objects - public void testGenerics2() { - List integers = new ArrayList(); - integers.add(new Integer(0)); - integers.add(new Long(1)); - integers.add(new Integer(2)); - integers.add(new Float(3)); - Iterator stream = new FilteringIterator(integers.iterator()) { - @Override - protected boolean accept(Object o) { - return o instanceof Integer; - } - }; - assertEquals(2, CollectionTools.size(stream)); - } - - public void testFilterHasNext() { - int i = 0; - for (Iterator stream = this.buildFilterIterator(); stream.hasNext();) { - stream.next(); - i++; - } - assertEquals(6, i); - } - - public void testFilterNext() { - for (Iterator stream = this.buildFilterIterator(); stream.hasNext();) { - assertTrue("bogus accept", stream.next().startsWith(PREFIX)); - } - } - - private Iterator buildFilteredIterator(Iterator nestedIterator, Filter filter) { - return new FilteringIterator(nestedIterator, filter); - } - - private Iterator buildInnerFilteredIterator(Iterator nestedIterator) { - return new FilteringIterator(nestedIterator) { - @Override - protected boolean accept(Object o) { - return ((String) o).startsWith(PREFIX); - } - }; - } - - String getPrefix() { - return PREFIX; - } - - // this inner iterator will call the "outer" object - private Iterator buildInnerFilteredIterator2(Iterator nestedIterator) { - return new FilteringIterator(nestedIterator) { - @Override - protected boolean accept(Object o) { - return ((String) o).startsWith(FilteringIteratorTests.this.getPrefix()); - } - }; - } - - private Iterator buildNestedIterator() { - Collection c = new ArrayList(); - 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 buildAcceptIterator() { - return this.buildFilteredIterator(this.buildNestedIterator(), this.buildAcceptFilter(PREFIX)); - } - - private Iterator buildInnerIterator() { - return this.buildInnerFilteredIterator(this.buildNestedIterator()); - } - - // this inner iterator will call the "outer" object - private Iterator buildInnerIterator2() { - return this.buildInnerFilteredIterator2(this.buildNestedIterator()); - } - - private Iterator buildFilterIterator() { - return this.buildFilteredIterator(this.buildNestedIterator(), this.buildFilterFilter(PREFIX)); - } - - private Filter buildAcceptFilter(String prefix) { - return new SimpleFilter(prefix) { - private static final long serialVersionUID = 1L; - - @Override - public boolean accept(String s) { - return s.startsWith(this.criterion); - } - }; - } - - private Iterator buildRejectIterator() { - return this.buildFilteredIterator(this.buildNestedIterator(), this.buildRejectFilter(PREFIX)); - } - - private Filter buildRejectFilter(String prefix) { - return new SimpleFilter(prefix) { - private static final long serialVersionUID = 1L; - - @Override - public boolean reject(String s) { - return s.startsWith(this.criterion); - } - }; - } - - // use anonymous inner Filter - private Filter buildFilterFilter(final String prefix) { - return new Filter() { - public boolean accept(String s) { - return s.startsWith(prefix); - } - }; - } - - private Iterator buildBothIterator() { - return this.buildFilteredIterator(this.buildNestedIterator(), this.buildBothFilter(PREFIX)); - } - - private Filter buildBothFilter(String prefix) { - return new SimpleFilter(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); - } - }; - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/GraphIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/GraphIteratorTests.java deleted file mode 100644 index d7f884c04e..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/GraphIteratorTests.java +++ /dev/null @@ -1,183 +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.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.utility.internal.CollectionTools; -import org.eclipse.jpt.utility.internal.iterators.GraphIterator; -import org.eclipse.jpt.utility.tests.internal.TestTools; - -public class GraphIteratorTests extends TestCase { - /** this will be populated with all the nodes created for the test */ - Collection nodes = new ArrayList(); - - 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 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 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 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 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); - } - - /** - * build a graph iterator with an explicit misterRogers - */ - private Iterator buildGraphIterator1() { - return new GraphIterator(this.buildGraphRoot(), this.buildMisterRogers()); - } - - private GraphIterator.MisterRogers buildMisterRogers() { - return new GraphIterator.MisterRogers() { - public Iterator neighbors(GraphNode next) { - return next.neighbors(); - } - }; - } - - /** - * build a graph iterator with an override - */ - private Iterator buildGraphIterator2() { - return new GraphIterator(this.buildGraphRoot()) { - @Override - public Iterator 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; - } - - private class GraphNode { - private String name; - - private Collection neighbors = new ArrayList(); - - 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 neighbors() { - return this.neighbors.iterator(); - } - - public int neighborsSize() { - return this.neighbors.size(); - } - - @Override - public String toString() { - return "GraphNode(" + this.name + ")"; - } - } -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/IteratorEnumerationTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/IteratorEnumerationTests.java deleted file mode 100644 index 42d8eb459e..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/IteratorEnumerationTests.java +++ /dev/null @@ -1,98 +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.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.utility.internal.iterators.IteratorEnumeration; - -public class IteratorEnumerationTests extends TestCase { - - public IteratorEnumerationTests(String name) { - super(name); - } - - public void testHasMoreElements() { - int i = 0; - for (Enumeration stream = this.buildEnumeration(); stream.hasMoreElements();) { - stream.nextElement(); - i++; - } - assertEquals(this.buildVector().size(), i); - } - - public void testHasMoreElementsUpcast() { - int i = 0; - for (Enumeration stream = this.buildEnumerationUpcast(); stream.hasMoreElements();) { - stream.nextElement(); - i++; - } - assertEquals(this.buildVector().size(), i); - } - - public void testNextElement() { - Iterator iterator = this.buildIterator(); - for (Enumeration stream = this.buildEnumeration(); stream.hasMoreElements();) { - assertEquals("bogus element", iterator.next(), stream.nextElement()); - } - } - - public void testNoSuchElementException() { - boolean exCaught = false; - Enumeration 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 buildEnumeration() { - return this.buildEnumeration(this.buildIterator()); - } - - private Enumeration buildEnumerationUpcast() { - return this.buildEnumerationUpcast(this.buildIterator()); - } - - private Enumeration buildEnumeration(Iterator iterator) { - return new IteratorEnumeration(iterator); - } - - private Enumeration buildEnumerationUpcast(Iterator iterator) { - return new IteratorEnumeration(iterator); - } - - private Iterator buildIterator() { - return this.buildVector().iterator(); - } - - private Vector buildVector() { - Vector v = new Vector(); - 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/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/JptUtilityIteratorsTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/JptUtilityIteratorsTests.java deleted file mode 100644 index 76e6717b34..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/JptUtilityIteratorsTests.java +++ /dev/null @@ -1,53 +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.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(EmptyEnumerationTests.class); - suite.addTestSuite(EmptyIteratorTests.class); - suite.addTestSuite(EmptyListIteratorTests.class); - suite.addTestSuite(EnumerationIteratorTests.class); - suite.addTestSuite(FilteringIteratorTests.class); - suite.addTestSuite(GraphIteratorTests.class); - suite.addTestSuite(IteratorEnumerationTests.class); - suite.addTestSuite(PeekableIteratorTests.class); - suite.addTestSuite(ReadOnlyIteratorTests.class); - suite.addTestSuite(ReadOnlyListIteratorTests.class); - suite.addTestSuite(SingleElementIteratorTests.class); - suite.addTestSuite(SingleElementListIteratorTests.class); - suite.addTestSuite(TransformationIteratorTests.class); - suite.addTestSuite(TransformationListIteratorTests.class); - suite.addTestSuite(TreeIteratorTests.class); - - return suite; - } - - private JptUtilityIteratorsTests() { - super(); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/PeekableIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/PeekableIteratorTests.java deleted file mode 100644 index 1a3b47b78f..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/PeekableIteratorTests.java +++ /dev/null @@ -1,140 +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.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.utility.internal.iterators.PeekableIterator; - -public class PeekableIteratorTests extends TestCase { - - public PeekableIteratorTests(String name) { - super(name); - } - - public void testUnsupportedOperationException() { - boolean exCaught = false; - for (Iterator 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 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 stream = this.buildPeekableIterator(); stream.hasNext();) { - stream.next(); - i++; - } - assertEquals(6, i); - } - - public void testHasNextUpcast() { - int i = 0; - for (Iterator stream = this.buildPeekableIteratorUpcast(); stream.hasNext();) { - stream.next(); - i++; - } - assertEquals(6, i); - } - - public void testNext() { - Iterator 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 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 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 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 buildPeekableIterator() { - return this.buildPeekableIterator(this.buildNestedIterator()); - } - - private PeekableIterator buildPeekableIteratorUpcast() { - return this.buildPeekableIteratorUpcast(this.buildNestedIterator()); - } - - private PeekableIterator buildPeekableIterator(Iterator nestedIterator) { - return new PeekableIterator(nestedIterator); - } - - private PeekableIterator buildPeekableIteratorUpcast(Iterator nestedIterator) { - return new PeekableIterator(nestedIterator); - } - - private Iterator buildNestedIterator() { - Collection c = new ArrayList(); - c.add("zero"); - c.add("one"); - c.add("two"); - c.add("three"); - c.add("four"); - c.add("five"); - return c.iterator(); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ReadOnlyIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ReadOnlyIteratorTests.java deleted file mode 100644 index 4defa2e414..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ReadOnlyIteratorTests.java +++ /dev/null @@ -1,118 +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.utility.tests.internal.iterators; - -import java.util.Iterator; -import java.util.NoSuchElementException; -import java.util.Vector; -import junit.framework.TestCase; -import org.eclipse.jpt.utility.internal.iterators.ReadOnlyIterator; - -public class ReadOnlyIteratorTests extends TestCase { - - public ReadOnlyIteratorTests(String name) { - super(name); - } - - public void testHasNext() { - int i = 0; - for (Iterator stream = this.buildReadOnlyIterator(); stream.hasNext();) { - stream.next(); - i++; - } - assertEquals(this.buildVector().size(), i); - } - - public void testHasNextUpcast() { - int i = 0; - for (Iterator stream = this.buildReadOnlyIteratorUpcast(); stream.hasNext();) { - stream.next(); - i++; - } - assertEquals(this.buildVector().size(), i); - } - - public void testNext() { - Iterator nestedIterator = this.buildNestedIterator(); - for (Iterator stream = this.buildReadOnlyIterator(); stream.hasNext();) { - assertEquals("bogus element", nestedIterator.next(), stream.next()); - } - } - - public void testNextUpcast() { - Iterator nestedIterator = this.buildNestedIterator(); - for (Iterator stream = this.buildReadOnlyIteratorUpcast(); stream.hasNext();) { - assertEquals("bogus element", nestedIterator.next(), stream.next()); - } - } - - public void testNoSuchElementException() { - boolean exCaught = false; - Iterator 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 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 buildReadOnlyIterator() { - return this.buildReadOnlyIterator(this.buildNestedIterator()); - } - - private Iterator buildReadOnlyIteratorUpcast() { - return this.buildReadOnlyIteratorUpcast(this.buildNestedIterator()); - } - - private Iterator buildReadOnlyIterator(Iterator nestedIterator) { - return new ReadOnlyIterator(nestedIterator); - } - - private Iterator buildReadOnlyIteratorUpcast(Iterator nestedIterator) { - return new ReadOnlyIterator(nestedIterator); - } - - private Iterator buildNestedIterator() { - return this.buildVector().iterator(); - } - - private Vector buildVector() { - Vector v = new Vector(); - 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/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ReadOnlyListIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ReadOnlyListIteratorTests.java deleted file mode 100644 index 4db72f6754..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/ReadOnlyListIteratorTests.java +++ /dev/null @@ -1,203 +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.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.utility.internal.iterators.ReadOnlyListIterator; - -public class ReadOnlyListIteratorTests extends TestCase { - - public ReadOnlyListIteratorTests(String name) { - super(name); - } - - public void testHasNextAndHasPrevious() { - int i = 0; - ListIterator 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 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 nestedListIterator = this.buildNestedListIterator(); - ListIterator 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 nestedListIterator = this.buildNestedListIterator(); - ListIterator 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 nestedListIterator = this.buildNestedListIterator(); - ListIterator 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 nestedListIterator = this.buildNestedListIterator(); - ListIterator 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 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 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 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 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 buildReadOnlyListIterator() { - return this.buildReadOnlyListIterator(this.buildNestedListIterator()); - } - - private ListIterator buildReadOnlyListIteratorUpcast() { - return this.buildReadOnlyListIteratorUpcast(this.buildNestedListIterator()); - } - - private ListIterator buildReadOnlyListIterator(ListIterator nestedListIterator) { - return new ReadOnlyListIterator(nestedListIterator); - } - - private ListIterator buildReadOnlyListIteratorUpcast(ListIterator nestedListIterator) { - return new ReadOnlyListIterator(nestedListIterator); - } - - private ListIterator buildNestedListIterator() { - return this.buildList().listIterator(); - } - - private List buildList() { - List l = new ArrayList(); - 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/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/SingleElementIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/SingleElementIteratorTests.java deleted file mode 100644 index e84657c93d..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/SingleElementIteratorTests.java +++ /dev/null @@ -1,71 +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.utility.tests.internal.iterators; - -import java.util.Iterator; -import java.util.NoSuchElementException; -import junit.framework.TestCase; -import org.eclipse.jpt.utility.internal.iterators.SingleElementIterator; - -public class SingleElementIteratorTests extends TestCase { - - public SingleElementIteratorTests(String name) { - super(name); - } - - public void testHasNext() { - int i = 0; - for (Iterator stream = this.buildSingleElementIterator(); stream.hasNext();) { - stream.next(); - i++; - } - assertEquals(1, i); - } - - public void testNext() { - for (Iterator stream = this.buildSingleElementIterator(); stream.hasNext();) { - assertEquals("bogus element", this.singleElement(), stream.next()); - } - } - - public void testNoSuchElementException() { - boolean exCaught = false; - Iterator 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 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 buildSingleElementIterator() { - return new SingleElementIterator(this.singleElement()); - } - - protected String singleElement() { - return "single element"; - } -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/SingleElementListIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/SingleElementListIteratorTests.java deleted file mode 100644 index e3e4197c7d..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/SingleElementListIteratorTests.java +++ /dev/null @@ -1,111 +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.utility.tests.internal.iterators; - -import java.util.Iterator; -import java.util.ListIterator; -import org.eclipse.jpt.utility.internal.iterators.SingleElementListIterator; - -public class SingleElementListIteratorTests extends SingleElementIteratorTests { - - public SingleElementListIteratorTests(String name) { - super(name); - } - - public void testNextIndex() { - ListIterator 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 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 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 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 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 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 buildSingleElementIterator() { - return new SingleElementListIterator(this.singleElement()); - } - - protected ListIterator buildSingleElementListIterator() { - return (ListIterator) this.buildSingleElementIterator(); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TransformationIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TransformationIteratorTests.java deleted file mode 100644 index 6ec0d082b1..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TransformationIteratorTests.java +++ /dev/null @@ -1,216 +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.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.utility.internal.Transformer; -import org.eclipse.jpt.utility.internal.iterators.TransformationIterator; - -public class TransformationIteratorTests extends TestCase { - - public TransformationIteratorTests(String name) { - super(name); - } - - public void testHasNext() { - int i = 0; - for (Iterator stream = this.buildIterator(); stream.hasNext();) { - stream.next(); - i++; - } - assertEquals(8, i); - } - - public void testHasNextUpcast() { - int i = 0; - for (Iterator stream = this.buildIteratorUpcast(); stream.hasNext();) { - stream.next(); - i++; - } - assertEquals(8, i); - } - - public void testInnerHasNext() { - int i = 0; - for (Iterator stream = this.buildInnerIterator(); stream.hasNext();) { - stream.next(); - i++; - } - assertEquals(8, i); - } - - public void testNext() { - int i = 0; - for (Iterator stream = this.buildIterator(); stream.hasNext();) { - assertEquals("bogus transformation", ++i, stream.next().intValue()); - } - } - - public void testNextUpcast() { - int i = 0; - for (Iterator stream = this.buildIteratorUpcast(); stream.hasNext();) { - assertEquals("bogus transformation", ++i, ((Integer) stream.next()).intValue()); - } - } - - public void testInnerNext() { - int i = 0; - for (Iterator stream = this.buildInnerIterator(); stream.hasNext();) { - assertEquals("bogus transformation", ++i, stream.next().intValue()); - } - } - - public void testRemove() { - Collection c = this.buildCollection(); - for (Iterator 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 c = this.buildCollection(); - for (Iterator 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 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 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 buildIterator() { - return this.buildTransformationIterator(this.buildNestedIterator(), this.buildTransformer()); - } - - private Iterator buildIteratorUpcast() { - return this.buildTransformationIteratorUpcast(this.buildNestedIterator(), this.buildTransformerUpcast()); - } - - private Iterator buildInnerIterator() { - return this.buildInnerTransformationIterator(this.buildNestedIterator()); - } - - private Iterator buildUnmodifiableIterator() { - return this.buildTransformationIterator(this.buildUnmodifiableNestedIterator(), this.buildTransformer()); - } - - private Iterator buildTransformationIterator(Iterator nestedIterator, Transformer transformer) { - return new TransformationIterator(nestedIterator, transformer); - } - - private Iterator buildTransformationIteratorUpcast(Iterator nestedIterator, Transformer transformer) { - return new TransformationIterator(nestedIterator, transformer); - } - - private Transformer buildTransformer() { - // transform each string into an integer with a value of the string's length - return new Transformer() { - public Integer transform(String next) { - return new Integer(next.length()); - } - }; - } - - private Transformer buildTransformerUpcast() { - // transform each string into an integer with a value of the string's length - return new Transformer() { - public Integer transform(Object next) { - return new Integer(((String) next).length()); - } - }; - } - - private Iterator buildInnerTransformationIterator(Iterator nestedIterator) { - // transform each string into an integer with a value of the string's length - return new TransformationIterator(nestedIterator) { - @Override - protected Integer transform(String next) { - return new Integer(next.length()); - } - }; - } - - private Iterator buildNestedIterator() { - return this.buildCollection().iterator(); - } - - private Iterator buildUnmodifiableNestedIterator() { - return this.buildUnmodifiableCollection().iterator(); - } - - private Collection buildCollection() { - Collection c = new ArrayList(); - 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 buildUnmodifiableCollection() { - return Collections.unmodifiableCollection(this.buildCollection()); - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TransformationListIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TransformationListIteratorTests.java deleted file mode 100644 index fb507d5af4..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TransformationListIteratorTests.java +++ /dev/null @@ -1,306 +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.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.utility.internal.Transformer; -import org.eclipse.jpt.utility.internal.iterators.TransformationListIterator; - -public class TransformationListIteratorTests extends TestCase { - public TransformationListIteratorTests(String name) { - super(name); - } - - public void testHasNextAndHasPrevious() { - int i = 0; - ListIterator 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 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 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 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 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 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 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 l = this.buildList(); - for (ListIterator 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 l = this.buildList(); - for (ListIterator 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 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 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 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 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 buildIterator() { - return this.buildTransformationListIterator(this.buildNestedIterator(), this.buildTransformer()); - } - - private ListIterator buildIteratorUpcast() { - return this.buildTransformationListIteratorUpcast(this.buildNestedIterator(), this.buildTransformerUpcast()); - } - - private ListIterator buildInnerIterator() { - return this.buildInnerTransformationListIterator(this.buildNestedIterator()); - } - - private ListIterator buildUnmodifiableIterator() { - return this.buildTransformationListIterator(this.buildUnmodifiableNestedIterator(), this.buildTransformer()); - } - - private ListIterator buildTransformationListIterator(ListIterator nestedIterator, Transformer transformer) { - return new TransformationListIterator(nestedIterator, transformer); - } - - private ListIterator buildTransformationListIteratorUpcast(ListIterator nestedIterator, Transformer transformer) { - return new TransformationListIterator(nestedIterator, transformer); - } - - private Transformer buildTransformer() { - // transform each string into an integer with a value of the string's length - return new Transformer() { - public Integer transform(String next) { - return new Integer(next.length()); - } - }; - } - - private Transformer buildTransformerUpcast() { - // transform each string into an integer with a value of the string's length - return new Transformer() { - public Integer transform(Object next) { - return new Integer(((String) next).length()); - } - }; - } - - private ListIterator buildInnerTransformationListIterator(ListIterator nestedIterator) { - // transform each string into an integer with a value of the string's length - return new TransformationListIterator(nestedIterator) { - @Override - protected Integer transform(String next) { - return new Integer(next.length()); - } - }; - } - - private ListIterator buildNestedIterator() { - return this.buildList().listIterator(); - } - - private ListIterator buildUnmodifiableNestedIterator() { - return this.buildUnmodifiableList().listIterator(); - } - - private List buildList() { - List l = new ArrayList(); - 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 buildUnmodifiableList() { - return Collections.unmodifiableList(this.buildList()); - } -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TreeIteratorTests.java b/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TreeIteratorTests.java deleted file mode 100644 index 655d0835c0..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/src/org/eclipse/jpt/utility/tests/internal/iterators/TreeIteratorTests.java +++ /dev/null @@ -1,197 +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.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.utility.internal.iterators.TreeIterator; -import org.eclipse.jpt.utility.tests.internal.TestTools; - -public class TreeIteratorTests extends TestCase { - /** this will be populated with all the nodes created for the test */ - Collection nodes = new ArrayList(); - - 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 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 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 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 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 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 buildTreeIterator1() { - return new TreeIterator(this.buildTree(), this.buildMidwife()); - } - - private TreeIterator.Midwife buildMidwife() { - return new TreeIterator.Midwife() { - public Iterator children(TreeNode next) { - return next.children(); - } - }; - } - - /** - * build a tree iterator with an override - */ - private Iterator buildTreeIterator2() { - return new TreeIterator(this.buildTree()) { - @Override - public Iterator 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; - } - - private class TreeNode { - private String name; - private Collection children = new ArrayList(); - - 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 children() { - return this.children.iterator(); - } - - public int childrenSize() { - return this.children.size(); - } - - @Override - public String toString() { - return "TreeNode(" + this.name + ")"; - } - } - -} diff --git a/jpa/tests/org.eclipse.jpt.utility.tests/test.xml b/jpa/tests/org.eclipse.jpt.utility.tests/test.xml deleted file mode 100644 index 8598dc69f7..0000000000 --- a/jpa/tests/org.eclipse.jpt.utility.tests/test.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file -- cgit v1.2.3