-- cgit v1.2.3 From 25d98ec77068e5b1500e9e36f61602b220d5b70e Mon Sep 17 00:00:00 2001 From: kmoore Date: Thu, 12 Jul 2007 19:30:37 +0000 Subject: 195719 - applied patch - Property.setName() and .setValue() go to elements not attributes --- .../content/persistence/resource/PersistenceTranslator.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/resource/PersistenceTranslator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/resource/PersistenceTranslator.java index 123d1815e3..1e8e0b9c42 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/resource/PersistenceTranslator.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/resource/PersistenceTranslator.java @@ -123,7 +123,7 @@ public class PersistenceTranslator extends RootTranslator } private static Translator createPropertyTranslator() { - GenericTranslator translator = new GenericTranslator(PROPERTY, PERSISTENCE_PKG.getProperties_Properties()); + GenericTranslator translator = new GenericTranslator(PROPERTY, PERSISTENCE_PKG.getProperties_Properties(), END_TAG_NO_INDENT); translator.setChildren( new Translator[] { createPropertyNameTranslator(), @@ -134,10 +134,10 @@ public class PersistenceTranslator extends RootTranslator } private static Translator createPropertyNameTranslator() { - return new Translator(PROPERTY_NAME, PERSISTENCE_PKG.getProperty_Name()); + return new Translator(PROPERTY_NAME, PERSISTENCE_PKG.getProperty_Name(), DOM_ATTRIBUTE); } private static Translator createPropertyValueTranslator() { - return new Translator(PROPERTY_VALUE, PERSISTENCE_PKG.getProperty_Value()); + return new Translator(PROPERTY_VALUE, PERSISTENCE_PKG.getProperty_Value(), DOM_ATTRIBUTE); } } -- cgit v1.2.3 From 0873e1c9e2f69ceeebb2497ce154c34714ae66d3 Mon Sep 17 00:00:00 2001 From: kmoore Date: Mon, 16 Jul 2007 15:52:08 +0000 Subject: 194807 - applied patch - Need a way to add persistence.xml editing in the JPA Details and Structure View for extenders --- .../org.eclipse.jpt.core/model/persistence.ecore | 4 ++-- .../internal/content/persistence/Persistence.java | 19 ++++++++++++++++++- .../content/persistence/PersistencePackage.java | 2 ++ .../internal/content/persistence/PersistenceUnit.java | 8 +++++++- .../persistence/PersistenceXmlRootContentNode.java | 6 ++++-- .../resource/IPersistenceXmlContentNodes.java | 2 ++ .../content/persistence/util/PersistenceSwitch.java | 12 ++++++++---- 7 files changed, 43 insertions(+), 10 deletions(-) diff --git a/jpa/plugins/org.eclipse.jpt.core/model/persistence.ecore b/jpa/plugins/org.eclipse.jpt.core/model/persistence.ecore index b26c36781e..2cc54004f3 100644 --- a/jpa/plugins/org.eclipse.jpt.core/model/persistence.ecore +++ b/jpa/plugins/org.eclipse.jpt.core/model/persistence.ecore @@ -7,7 +7,7 @@ - + - + @@ -39,7 +42,7 @@ import org.eclipse.jpt.core.internal.XmlEObject; * @model kind="class" * @generated */ -public class Persistence extends XmlEObject +public class Persistence extends XmlEObject implements IJpaContentNode { /** * The cached value of the '{@link #getPersistenceUnits() Persistence Units}' containment reference list. @@ -345,4 +348,18 @@ public class Persistence extends XmlEObject IJpaFile file = getJpaFile(); return (file == null) ? null : file.getJpaProject(); } + + public IJpaContentNode getContentNode(int offset) { + for (Iterator i = getPersistenceUnits().iterator(); i.hasNext();) { + PersistenceUnit persistenceUnit = i.next(); + if (persistenceUnit.getNode().contains(offset)) { + return persistenceUnit; + } + } + return this; + } + + public Object getId() { + return IPersistenceXmlContentNodes.PERSISTENCEXML_ROOT_ID; + } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistencePackage.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistencePackage.java index 92f9870d35..6c9dea2b53 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistencePackage.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistencePackage.java @@ -1056,7 +1056,9 @@ public class PersistencePackage extends EPackageImpl persistenceXmlRootContentNodeEClass.getESuperTypes().add(theJpaCorePackage.getXmlEObject()); persistenceXmlRootContentNodeEClass.getESuperTypes().add(theJpaCorePackage.getIJpaRootContentNode()); persistenceEClass.getESuperTypes().add(theJpaCorePackage.getXmlEObject()); + persistenceEClass.getESuperTypes().add(theJpaCorePackage.getIJpaContentNode()); persistenceUnitEClass.getESuperTypes().add(theJpaCorePackage.getXmlEObject()); + persistenceUnitEClass.getESuperTypes().add(theJpaCorePackage.getIJpaContentNode()); mappingFileRefEClass.getESuperTypes().add(theJpaCorePackage.getXmlEObject()); javaClassRefEClass.getESuperTypes().add(theJpaCorePackage.getXmlEObject()); propertiesEClass.getESuperTypes().add(theJpaCorePackage.getXmlEObject()); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistenceUnit.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistenceUnit.java index b0e2df65b8..e4bb36c638 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistenceUnit.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistenceUnit.java @@ -18,7 +18,9 @@ import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.emf.ecore.util.EDataTypeEList; import org.eclipse.emf.ecore.util.EObjectContainmentEList; import org.eclipse.emf.ecore.util.InternalEList; +import org.eclipse.jpt.core.internal.IJpaContentNode; import org.eclipse.jpt.core.internal.XmlEObject; +import org.eclipse.jpt.core.internal.content.persistence.resource.IPersistenceXmlContentNodes; /** * @@ -46,7 +48,7 @@ import org.eclipse.jpt.core.internal.XmlEObject; * @model kind="class" * @generated */ -public class PersistenceUnit extends XmlEObject +public class PersistenceUnit extends XmlEObject implements IJpaContentNode { /** * The default value of the '{@link #getDescription() Description}' attribute. @@ -874,4 +876,8 @@ public class PersistenceUnit extends XmlEObject result.append(')'); return result.toString(); } + + public Object getId() { + return IPersistenceXmlContentNodes.PERSISTENCE_UNIT_ID; + } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistenceXmlRootContentNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistenceXmlRootContentNode.java index 77bd8ad516..f19b7294a3 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistenceXmlRootContentNode.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/PersistenceXmlRootContentNode.java @@ -346,8 +346,10 @@ public class PersistenceXmlRootContentNode extends XmlEObject } public IJpaContentNode getContentNode(int offset) { - // TODO Auto-generated method stub - return null; + if (getPersistence() == null || !getPersistence().getNode().contains(offset)) { + return this; + } + return getPersistence().getContentNode(offset); } public Object getId() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/resource/IPersistenceXmlContentNodes.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/resource/IPersistenceXmlContentNodes.java index 699518b3bb..3c389ad3e0 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/resource/IPersistenceXmlContentNodes.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/resource/IPersistenceXmlContentNodes.java @@ -14,4 +14,6 @@ public interface IPersistenceXmlContentNodes { String PERSISTENCEXML_ROOT_ID = JptCorePlugin.PLUGIN_ID + ".persistencexml.Root"; + String PERSISTENCE_UNIT_ID = JptCorePlugin.PLUGIN_ID + ".persistencexml.PersistenceUnit"; + } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/util/PersistenceSwitch.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/util/PersistenceSwitch.java index 0d2cb561a1..d115ee55dd 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/util/PersistenceSwitch.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/persistence/util/PersistenceSwitch.java @@ -126,14 +126,16 @@ public class PersistenceSwitch T result = casePersistence(persistence); if (result == null) result = caseXmlEObject(persistence); + if (result == null) + result = caseIJpaContentNode(persistence); if (result == null) result = caseJpaEObject(persistence); if (result == null) result = caseIXmlEObject(persistence); - if (result == null) - result = caseIJpaEObject(persistence); if (result == null) result = caseIJpaSourceObject(persistence); + if (result == null) + result = caseIJpaEObject(persistence); if (result == null) result = defaultCase(theEObject); return result; @@ -143,14 +145,16 @@ public class PersistenceSwitch T result = casePersistenceUnit(persistenceUnit); if (result == null) result = caseXmlEObject(persistenceUnit); + if (result == null) + result = caseIJpaContentNode(persistenceUnit); if (result == null) result = caseJpaEObject(persistenceUnit); if (result == null) result = caseIXmlEObject(persistenceUnit); - if (result == null) - result = caseIJpaEObject(persistenceUnit); if (result == null) result = caseIJpaSourceObject(persistenceUnit); + if (result == null) + result = caseIJpaEObject(persistenceUnit); if (result == null) result = defaultCase(theEObject); return result; -- cgit v1.2.3 From bbc2042e6b84a70e54cad1e47ae00242676c5293 Mon Sep 17 00:00:00 2001 From: nhauge Date: Wed, 18 Jul 2007 21:10:53 +0000 Subject: 196877 - Doc errors prevent adopters from translating files properly --- jpa/plugins/org.eclipse.jpt.doc.user/about.html | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/concept_mapping.htm | 4 ++-- .../org.eclipse.jpt.doc.user/concept_persistence.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/concepts.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/concepts001.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/concepts002.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/concepts003.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/dcommon/html/cpyr.htm | 1 + jpa/plugins/org.eclipse.jpt.doc.user/getting_started.htm | 2 +- .../org.eclipse.jpt.doc.user/getting_started001.htm | 2 +- .../org.eclipse.jpt.doc.user/getting_started002.htm | 2 +- .../org.eclipse.jpt.doc.user/getting_started003.htm | 2 +- .../org.eclipse.jpt.doc.user/getting_started004.htm | 2 +- .../org.eclipse.jpt.doc.user/getting_started005.htm | 2 +- .../org.eclipse.jpt.doc.user/getting_started006.htm | 2 +- .../org.eclipse.jpt.doc.user/getting_started007.htm | 2 +- .../org.eclipse.jpt.doc.user/getting_started008.htm | 2 +- .../org.eclipse.jpt.doc.user/getting_started009.htm | 2 +- .../org.eclipse.jpt.doc.user/getting_started010.htm | 2 +- .../org.eclipse.jpt.doc.user/getting_started011.htm | 2 +- .../org.eclipse.jpt.doc.user/getting_started012.htm | 2 +- .../org.eclipse.jpt.doc.user/getting_started013.htm | 2 +- .../org.eclipse.jpt.doc.user/getting_started014.htm | 2 +- .../org.eclipse.jpt.doc.user/getting_started015.htm | 2 +- .../org.eclipse.jpt.doc.user/getting_started016.htm | 2 +- .../org.eclipse.jpt.doc.user/getting_started017.htm | 2 +- .../org.eclipse.jpt.doc.user/getting_started018.htm | 2 +- .../org.eclipse.jpt.doc.user/getting_started019.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/legal.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/ref_details_orm.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/ref_jpa_facet.htm | 2 +- .../org.eclipse.jpt.doc.user/ref_mapping_general.htm | 14 +++++++------- .../org.eclipse.jpt.doc.user/ref_new_jpa_project.htm | 2 +- .../ref_new_jpa_project_wizard.htm | 2 +- .../org.eclipse.jpt.doc.user/ref_persistence_map_view.htm | 2 +- .../org.eclipse.jpt.doc.user/ref_persistence_outline.htm | 2 +- .../ref_persistence_perspective.htm | 2 +- .../org.eclipse.jpt.doc.user/ref_persistence_prop_view.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/ref_primary_key.htm | 8 ++++---- .../org.eclipse.jpt.doc.user/ref_project_properties.htm | 4 ++-- jpa/plugins/org.eclipse.jpt.doc.user/reference.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/reference001.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/reference002.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/reference003.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/reference004.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/reference005.htm | 8 ++++---- jpa/plugins/org.eclipse.jpt.doc.user/reference006.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/reference007.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/reference008.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/reference009.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/reference010.htm | 4 ++-- jpa/plugins/org.eclipse.jpt.doc.user/reference011.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/reference012.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/reference013.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/reference014.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/reference015.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/reference016.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/reference017.htm | 2 +- .../org.eclipse.jpt.doc.user/task_add_persistence.htm | 2 +- .../org.eclipse.jpt.doc.user/task_additonal_tables.htm | 2 +- .../org.eclipse.jpt.doc.user/task_create_new_project.htm | 2 +- .../org.eclipse.jpt.doc.user/task_generate_entities.htm | 4 ++-- jpa/plugins/org.eclipse.jpt.doc.user/task_inheritance.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/task_manage_orm.htm | 2 +- .../org.eclipse.jpt.doc.user/task_manage_persistence.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/task_mapping.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/tasks.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/tasks001.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/tasks002.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/tasks003.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/tasks004.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/tasks005.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/tasks006.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/tasks007.htm | 10 +++++----- jpa/plugins/org.eclipse.jpt.doc.user/tasks008.htm | 10 +++++----- jpa/plugins/org.eclipse.jpt.doc.user/tasks009.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/tasks010.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/tasks011.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/tasks012.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/tasks013.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/tasks014.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/tasks015.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/tasks016.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/tasks017.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/tasks018.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/tasks019.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/tasks020.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/tasks021.htm | 8 ++++---- jpa/plugins/org.eclipse.jpt.doc.user/tips_and_tricks.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/toc.xml | 1 + jpa/plugins/org.eclipse.jpt.doc.user/whats_new.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/whats_new001.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/whats_new002.htm | 2 +- jpa/plugins/org.eclipse.jpt.doc.user/whats_new003.htm | 2 +- 94 files changed, 121 insertions(+), 119 deletions(-) diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/about.html b/jpa/plugins/org.eclipse.jpt.doc.user/about.html index 794af750a6..8f21cb851d 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/about.html +++ b/jpa/plugins/org.eclipse.jpt.doc.user/about.html @@ -4,8 +4,8 @@ -About this content +About this content diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/concept_mapping.htm b/jpa/plugins/org.eclipse.jpt.doc.user/concept_mapping.htm index c17e916319..1b826a5bd0 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/concept_mapping.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/concept_mapping.htm @@ -4,8 +4,8 @@ -Understanding OR mappings +Understanding OR mappings @@ -29,7 +29,7 @@ -

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.

+

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
diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/concept_persistence.htm b/jpa/plugins/org.eclipse.jpt.doc.user/concept_persistence.htm index cf984163c4..8f339e52ab 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/concept_persistence.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/concept_persistence.htm @@ -4,8 +4,8 @@ -Understanding Java persistence +Understanding Java persistence diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/concepts.htm b/jpa/plugins/org.eclipse.jpt.doc.user/concepts.htm index e709730f90..38f63d8dd5 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/concepts.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/concepts.htm @@ -4,8 +4,8 @@ -Concepts +Concepts diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/concepts001.htm b/jpa/plugins/org.eclipse.jpt.doc.user/concepts001.htm index c9ac9b2dae..9ad5cc172d 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/concepts001.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/concepts001.htm @@ -4,8 +4,8 @@ -Understanding EJB 3.0 Java Persistence API +Understanding EJB 3.0 Java Persistence API diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/concepts002.htm b/jpa/plugins/org.eclipse.jpt.doc.user/concepts002.htm index 2d86027a37..40716b5963 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/concepts002.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/concepts002.htm @@ -4,8 +4,8 @@ -The persistence.xml file +The persistence.xml file diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/concepts003.htm b/jpa/plugins/org.eclipse.jpt.doc.user/concepts003.htm index 5f4bd90908..80395b0896 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/concepts003.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/concepts003.htm @@ -4,8 +4,8 @@ -The orm.xml file +The orm.xml 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 index 382ec67619..fe52e9587f 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/dcommon/html/cpyr.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/dcommon/html/cpyr.htm @@ -3,6 +3,7 @@ + diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started.htm index c0f78f6584..658022b0e9 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started.htm @@ -4,8 +4,8 @@ -Getting started +Getting started diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started001.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started001.htm index ffee83ab0d..e17ea9100a 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started001.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started001.htm @@ -4,8 +4,8 @@ -Requirements and installation +Requirements and installation diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started002.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started002.htm index efba0eb9f3..52f4e25f3d 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started002.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started002.htm @@ -4,8 +4,8 @@ -Dali quick start +Dali quick start diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started003.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started003.htm index c0bc5e6268..dc0cbed0fc 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started003.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started003.htm @@ -4,8 +4,8 @@ -Creating a new project +Creating a new project diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started004.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started004.htm index da7900a1b5..8bc6b26b3e 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started004.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started004.htm @@ -4,8 +4,8 @@ -Creating a Java persistent entity +Creating a Java persistent entity diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started005.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started005.htm index f3e564ea9f..53017e7f28 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started005.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started005.htm @@ -4,8 +4,8 @@ -Mapping an entity +Mapping an entity diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started006.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started006.htm index 28dc86e8e6..2dde4a28a3 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started006.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started006.htm @@ -4,8 +4,8 @@ -Dali basic tutorial +Dali basic tutorial diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started007.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started007.htm index 909ad1f3c6..654b0c9b83 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started007.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started007.htm @@ -4,8 +4,8 @@ -Generate the tutorial database schema +Generate the tutorial database schema diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started008.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started008.htm index 4e4585c8c8..e277fed35d 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started008.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started008.htm @@ -4,8 +4,8 @@ -Create a database connection +Create a database connection diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started009.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started009.htm index c9190e570d..fed0cfa4cf 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started009.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started009.htm @@ -4,8 +4,8 @@ -Create a JPA project +Create a JPA project diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started010.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started010.htm index df685ef8ac..69ec202bed 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started010.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started010.htm @@ -4,8 +4,8 @@ -Create persistent Java entities +Create persistent Java 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 index 55ab05f72f..0cd45a966f 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started011.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started011.htm @@ -4,8 +4,8 @@ -Add fields to the entities +Add fields to the entities diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started012.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started012.htm index 3b0879844d..5f6950e564 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started012.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started012.htm @@ -4,8 +4,8 @@ -Associate the entity with a database table +Associate the entity with a database table diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started013.htm b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started013.htm index 785a659348..d1928e6894 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started013.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started013.htm @@ -4,8 +4,8 @@ -Create OR mappings +Create OR 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 index de4447d1ed..a4cda760ef 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started014.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started014.htm @@ -4,8 +4,8 @@ -Create ID mappings +Create ID 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 index 63e9f803f7..3d5ff04ea4 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started015.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started015.htm @@ -4,8 +4,8 @@ -Create basic mappings +Create basic 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 index 0b21fc1fde..e57c4f5a0e 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started016.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started016.htm @@ -4,8 +4,8 @@ -Create one-to-one mappings +Create one-to-one 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 index d75a00d3ff..3b69b34c4f 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started017.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started017.htm @@ -4,8 +4,8 @@ -Create one-to-many mappings +Create one-to-many 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 index f2627f0553..2798be877b 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started018.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started018.htm @@ -4,8 +4,8 @@ -Create many-to-one mappings +Create many-to-one 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 index 92230820b6..3b8c883853 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/getting_started019.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/getting_started019.htm @@ -4,8 +4,8 @@ -Create version mappings +Create version mappings diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/legal.htm b/jpa/plugins/org.eclipse.jpt.doc.user/legal.htm index a36a2165a5..12d8b69f02 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/legal.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/legal.htm @@ -4,8 +4,8 @@ -Legal +Legal 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 index 3e14b3edd7..32768d4e3d 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_details_orm.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/ref_details_orm.htm @@ -4,8 +4,8 @@ -JPA Details view (for orm.xml) +JPA Details view (for orm.xml) 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 index 305de4fead..bdfd5fd4c8 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_jpa_facet.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/ref_jpa_facet.htm @@ -4,8 +4,8 @@ -JPA Facet page +JPA Facet page 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 index 85af149d8e..400f2420ef 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_mapping_general.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/ref_mapping_general.htm @@ -4,8 +4,8 @@ -General information +General information @@ -72,10 +72,10 @@ Defines how data is loaded from the database:
  • -

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

    +

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

  • -

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

    +

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

@@ -101,13 +101,13 @@ Specifies if this field is one of the following:
  • -

    Date – java.sql.Date

    +

    Date - java.sql.Date

  • -

    Time – java.sql.Time

    +

    Time - java.sql.Time

  • -

    Timestamp – java.sql.Timestamp

    +

    Timestamp - java.sql.Timestamp

This field corresponds to the @Temporal annotation.

@@ -142,7 +142,7 @@ Specify which operations are propagated throughout the entity.
  • -

    All – All operations

    +

    All - All operations

  • Persist

    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 index 2a498d7bff..be37cfa4ff 100644 --- 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 @@ -4,8 +4,8 @@ -New JPA Project page +New JPA Project page 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 index b68d3feaab..4fcec9cde4 100644 --- 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 @@ -4,8 +4,8 @@ -Create New JPA Project wizard +Create New JPA Project wizard 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 index 12fffe6c47..b93ae33148 100644 --- 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 @@ -4,8 +4,8 @@ -JPA Details view (for attributes) +JPA Details view (for attributes) 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 index 083c276125..92cc34df6a 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_outline.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_outline.htm @@ -4,8 +4,8 @@ -JPA Structure view +JPA Structure view 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 index 92641ca69c..1dbc7925ff 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_perspective.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/ref_persistence_perspective.htm @@ -4,8 +4,8 @@ -JPA Development perspective +JPA Development perspective 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 index 83e0d102ef..a6ea107ed4 100644 --- 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 @@ -4,8 +4,8 @@ -JPA Details view (for entities) +JPA Details view (for entities) 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 index 887580090e..d5084e785e 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_primary_key.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/ref_primary_key.htm @@ -4,8 +4,8 @@ -Primary Key Generation information +Primary Key Generation information @@ -51,13 +51,13 @@
    • Auto
    • -

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

      +

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

    • -

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

      +

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

    • -

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

      +

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

    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 index 9b7ac94a87..9fc5005afd 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/ref_project_properties.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/ref_project_properties.htm @@ -4,8 +4,8 @@ -Project Properties page - JPA Options +Project Properties page - JPA Options @@ -25,7 +25,7 @@
    -

    Project Properties page – JPA Options

    +

    Project Properties page - JPA Options

    diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference.htm index 7e82de0d86..5dc89a2b7c 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/reference.htm @@ -4,8 +4,8 @@ -Reference +Reference diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference001.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference001.htm index cc6300ff36..d0a856b8a8 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference001.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/reference001.htm @@ -4,8 +4,8 @@ -Wizards +Wizards diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference002.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference002.htm index 8a6374bf83..b5a99a9a91 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference002.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/reference002.htm @@ -4,8 +4,8 @@ -Property pages +Property pages diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference003.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference003.htm index 57d9770f64..58601b1aa8 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference003.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/reference003.htm @@ -4,8 +4,8 @@ -General information +General information diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference004.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference004.htm index b695f6856c..74775a8a8f 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference004.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/reference004.htm @@ -4,8 +4,8 @@ -Secondary table information +Secondary table information diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference005.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference005.htm index 6fa75a1e4a..c905aae94d 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference005.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/reference005.htm @@ -4,8 +4,8 @@ -Inheritance information +Inheritance information @@ -45,13 +45,13 @@ Specify the strategy to use when mapping a class or class hierarchy:
    • -

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

      +

      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.

      +

      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.

      +

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

    diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference006.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference006.htm index e6dee40319..45b9c12628 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference006.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/reference006.htm @@ -4,8 +4,8 @@ -Join Table Information +Join Table Information diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference007.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference007.htm index 9ca50cdeaa..fb51f2e3ca 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference007.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/reference007.htm @@ -4,8 +4,8 @@ -Join Columns Information +Join Columns Information diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference008.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference008.htm index ec9b54d253..8e8197130d 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference008.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/reference008.htm @@ -4,8 +4,8 @@ -General information +General information diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference009.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference009.htm index efc2cf7b67..5a84da5463 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference009.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/reference009.htm @@ -4,8 +4,8 @@ -Persistence Unit information +Persistence Unit information diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference010.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference010.htm index bf02a646bd..87bfc6bafa 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference010.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/reference010.htm @@ -4,8 +4,8 @@ -Preferences +Preferences @@ -32,7 +32,7 @@

    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 index ff0ec97ca8..942eaf52af 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference011.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/reference011.htm @@ -4,8 +4,8 @@ -Dialogs +Dialogs diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference012.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference012.htm index 6c01c652ff..510ecb3bd8 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference012.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/reference012.htm @@ -4,8 +4,8 @@ -Edit Join Columns Dialog +Edit Join Columns Dialog diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference013.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference013.htm index 8f9da2fc87..08937e2298 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference013.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/reference013.htm @@ -4,8 +4,8 @@ -Icons and buttons +Icons and buttons diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference014.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference014.htm index 22e9292c83..043d0a0b88 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference014.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/reference014.htm @@ -4,8 +4,8 @@ -Icons +Icons diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference015.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference015.htm index 40e1ef2249..37531beb60 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference015.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/reference015.htm @@ -4,8 +4,8 @@ -Buttons +Buttons diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference016.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference016.htm index 7c7c5271e5..701274392a 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference016.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/reference016.htm @@ -4,8 +4,8 @@ -Javadoc +Javadoc diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/reference017.htm b/jpa/plugins/org.eclipse.jpt.doc.user/reference017.htm index 67612290f6..080d092f48 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/reference017.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/reference017.htm @@ -4,8 +4,8 @@ -Dali Developer Documentation +Dali Developer Documentation 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 index 9463c8bb14..fbb1ed01e7 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/task_add_persistence.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/task_add_persistence.htm @@ -4,8 +4,8 @@ -Adding persistence to a class +Adding persistence to a class 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 index 0674fcdf7d..141620504f 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/task_additonal_tables.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/task_additonal_tables.htm @@ -4,8 +4,8 @@ -Specifying additional tables +Specifying additional tables 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 index 61239561d9..b6d33fa961 100644 --- 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 @@ -4,8 +4,8 @@ -Creating a new JPA project +Creating a new JPA project 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 index 4ac1b09dc7..743ece14af 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/task_generate_entities.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/task_generate_entities.htm @@ -4,8 +4,8 @@ -Generate Entities from Tables dialog +Generate Entities from Tables dialog @@ -50,7 +50,7 @@ Tables -Select 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. +Select 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. diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/task_inheritance.htm b/jpa/plugins/org.eclipse.jpt.doc.user/task_inheritance.htm index 9073764a6b..42015c065f 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/task_inheritance.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/task_inheritance.htm @@ -4,8 +4,8 @@ -Specifying entity inheritance +Specifying entity inheritance 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 index 5246efcd81..c749d97a64 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/task_manage_orm.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/task_manage_orm.htm @@ -4,8 +4,8 @@ -Managing the orm.xml file +Managing 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 index 8150519565..18bd864c0d 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/task_manage_persistence.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/task_manage_persistence.htm @@ -4,8 +4,8 @@ -Managing the persistence.xml file +Managing 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 index e9bb1c3e38..8c1d6df3f1 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/task_mapping.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/task_mapping.htm @@ -4,8 +4,8 @@ -Mapping an entity +Mapping an entity diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks.htm index 0e1b27c20c..720983393b 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tasks.htm @@ -4,8 +4,8 @@ -Tasks +Tasks diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks001.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks001.htm index 48e3c132b8..5b643a44d5 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks001.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tasks001.htm @@ -4,8 +4,8 @@ -Working with persistence.xml file +Working with 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 index 13aa22b2c7..2f1129c4da 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks002.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tasks002.htm @@ -4,8 +4,8 @@ -Synchronizing classes +Synchronizing classes diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks003.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks003.htm index 400091dab9..c652365a23 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks003.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tasks003.htm @@ -4,8 +4,8 @@ -Working with orm.xml file +Working with 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 index feddf4d807..1330b04c6b 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks004.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tasks004.htm @@ -4,8 +4,8 @@ -Entity +Entity diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks005.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks005.htm index 1d220dd4b7..4fea3e075d 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks005.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tasks005.htm @@ -4,8 +4,8 @@ -Embeddable +Embeddable diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks006.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks006.htm index 7486209ff6..0012aa273b 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks006.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tasks006.htm @@ -4,8 +4,8 @@ -Mapped superclass +Mapped superclass diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks007.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks007.htm index 10bb4cb5ae..4ad3ef63d4 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks007.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tasks007.htm @@ -4,8 +4,8 @@ -Basic mapping +Basic mapping @@ -103,16 +103,16 @@ The database column mapped to the entity attribute. See "Column" for details.
    • -

      Name – Name of the database column.

      +

      Name - Name of the database column.

    • -

      Table – Name of the database table.

      +

      Table - Name of the database table.

    • -

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

      +

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

    • -

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

      +

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

    diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks008.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks008.htm index f621a37aeb..bdbba7168e 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks008.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tasks008.htm @@ -4,8 +4,8 @@ -Embedded mapping +Embedded mapping @@ -66,16 +66,16 @@ The database column (and its table) mapped to the entity attribute. See "Column" for details.
    • -

      Name – Name of the database column.

      +

      Name - Name of the database column.

    • -

      Table – Name of the database table.

      +

      Table - Name of the database table.

    • -

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

      +

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

    • -

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

      +

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

    diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks009.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks009.htm index 1df9648d7f..6999dd180c 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks009.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tasks009.htm @@ -4,8 +4,8 @@ -Embedded ID mapping +Embedded ID mapping diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks010.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks010.htm index e8a4380d02..5472078fe4 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks010.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tasks010.htm @@ -4,8 +4,8 @@ -ID mapping +ID mapping diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks011.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks011.htm index d8c2ff90f9..ae12cc0852 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks011.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tasks011.htm @@ -4,8 +4,8 @@ -Many-to-many mapping +Many-to-many mapping diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks012.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks012.htm index 71bcf3d3df..82abc53480 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks012.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tasks012.htm @@ -4,8 +4,8 @@ -Many-to-one mapping +Many-to-one mapping diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks013.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks013.htm index 61a72af99b..5c5ac094b2 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks013.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tasks013.htm @@ -4,8 +4,8 @@ -One-to-many mapping +One-to-many mapping diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks014.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks014.htm index 99d29fa51c..c67cbd61d0 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks014.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tasks014.htm @@ -4,8 +4,8 @@ -One-to-one mapping +One-to-one mapping diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks015.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks015.htm index 92643c4ccd..acf9215dcb 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks015.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tasks015.htm @@ -4,8 +4,8 @@ -Transient mapping +Transient mapping diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks016.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks016.htm index 3043de54ce..c1b4291a6c 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks016.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tasks016.htm @@ -4,8 +4,8 @@ -Version mapping +Version mapping diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks017.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks017.htm index 571448f71f..7959ad3a39 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks017.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tasks017.htm @@ -4,8 +4,8 @@ -Generating entities from tables +Generating entities from tables diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks018.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks018.htm index e9cee0e579..986b4faf38 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks018.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tasks018.htm @@ -4,8 +4,8 @@ -Validating mappings and reporting problems +Validating mappings and reporting problems diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks019.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks019.htm index 060ae2d105..1ea8850003 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks019.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tasks019.htm @@ -4,8 +4,8 @@ -Error messages +Error messages diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks020.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks020.htm index 3cc8ed877d..01861dfe39 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks020.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tasks020.htm @@ -4,8 +4,8 @@ -Warning messages +Warning messages diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/tasks021.htm b/jpa/plugins/org.eclipse.jpt.doc.user/tasks021.htm index 16bd18b438..f0956b7831 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tasks021.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tasks021.htm @@ -4,8 +4,8 @@ -Modifying persistent project properties +Modifying persistent project properties @@ -35,11 +35,11 @@
  • Right-click the project in the Explorer view and select Properties. The Properties page appears.

    -

    Properties – Persistence Page

    +

    Properties - Persistence Page

    This figure shows the JPA options on the Properties dialog.
  • -

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

    +

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

    @@ -70,7 +70,7 @@

     

    Related reference

    -Project Properties page – JPA Options +Project Properties page - JPA Options

     

    Related concept

    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 index f4175473f6..739ecbb1cf 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/tips_and_tricks.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/tips_and_tricks.htm @@ -4,8 +4,8 @@ -Tips and tricks +Tips and tricks diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/toc.xml b/jpa/plugins/org.eclipse.jpt.doc.user/toc.xml index 0dc1abbc1d..2bc9ee82a6 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/toc.xml +++ b/jpa/plugins/org.eclipse.jpt.doc.user/toc.xml @@ -1,4 +1,5 @@ + diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new.htm b/jpa/plugins/org.eclipse.jpt.doc.user/whats_new.htm index 4d4da1ebca..8c777d1ff9 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/whats_new.htm @@ -4,8 +4,8 @@ -What's new +What's new diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new001.htm b/jpa/plugins/org.eclipse.jpt.doc.user/whats_new001.htm index 65fd8a9b8c..26654ca1e6 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new001.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/whats_new001.htm @@ -4,8 +4,8 @@ -Generate Persistent Entities from Tables wizard +Generate Persistent Entities from Tables wizard diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new002.htm b/jpa/plugins/org.eclipse.jpt.doc.user/whats_new002.htm index 4fd22af74e..455826bdea 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new002.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/whats_new002.htm @@ -4,8 +4,8 @@ -Create and Manage the persistence.xml file +Create and Manage the persistence.xml file diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new003.htm b/jpa/plugins/org.eclipse.jpt.doc.user/whats_new003.htm index f02aba41d4..b75c0a95fb 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/whats_new003.htm +++ b/jpa/plugins/org.eclipse.jpt.doc.user/whats_new003.htm @@ -4,8 +4,8 @@ -Create and Manage the orm.xml file +Create and Manage the orm.xml file -- cgit v1.2.3 From f1d2adb71ae94013e93ad5453a98fb4903cd10b3 Mon Sep 17 00:00:00 2001 From: bvosburgh Date: Thu, 19 Jul 2007 13:56:22 +0000 Subject: [196086] problems with arrays of strings or enums --- .../java/mappings/JavaUniqueConstraint.java | 11 +- .../jdtutility/AbstractExpressionConverter.java | 18 ++- .../AnnotationStringArrayExpressionConverter.java | 102 ++++++++++++++++ ...versionDeclarationAnnotationElementAdapter.java | 2 +- .../DeclarationAnnotationElementAdapter.java | 3 +- ...umArrayDeclarationAnnotationElementAdapter.java | 53 ++++++-- .../jdtutility/StringArrayExpressionConverter.java | 49 ++++++-- .../MemberAnnotationElementAdapterTests.java | 133 +++++++++++++++++++-- 8 files changed, 333 insertions(+), 38 deletions(-) create mode 100644 jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AnnotationStringArrayExpressionConverter.java diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaUniqueConstraint.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaUniqueConstraint.java index 2e8165fe67..1d7978cfbd 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaUniqueConstraint.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaUniqueConstraint.java @@ -11,16 +11,18 @@ package org.eclipse.jpt.core.internal.content.java.mappings; import java.util.Collection; import java.util.Iterator; + import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.util.EDataTypeEList; import org.eclipse.jdt.core.dom.Annotation; -import org.eclipse.jdt.core.dom.ArrayInitializer; import org.eclipse.jdt.core.dom.CompilationUnit; +import org.eclipse.jdt.core.dom.Expression; import org.eclipse.jpt.core.internal.ITextRange; import org.eclipse.jpt.core.internal.content.java.JavaEObject; import org.eclipse.jpt.core.internal.jdtutility.AnnotationElementAdapter; +import org.eclipse.jpt.core.internal.jdtutility.AnnotationStringArrayExpressionConverter; import org.eclipse.jpt.core.internal.jdtutility.ConversionDeclarationAnnotationElementAdapter; import org.eclipse.jpt.core.internal.jdtutility.DeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.jdtutility.DeclarationAnnotationElementAdapter; @@ -32,7 +34,6 @@ import org.eclipse.jpt.core.internal.jdtutility.MemberIndexedAnnotationAdapter; import org.eclipse.jpt.core.internal.jdtutility.NestedIndexedDeclarationAnnotationAdapter; import org.eclipse.jpt.core.internal.jdtutility.ShortCircuitArrayAnnotationElementAdapter; import org.eclipse.jpt.core.internal.jdtutility.SimpleDeclarationAnnotationAdapter; -import org.eclipse.jpt.core.internal.jdtutility.StringArrayExpressionConverter; import org.eclipse.jpt.core.internal.mappings.IUniqueConstraint; import org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage; import org.eclipse.jpt.utility.internal.CollectionTools; @@ -97,11 +98,11 @@ public class JavaUniqueConstraint extends JavaEObject } protected static DeclarationAnnotationElementAdapter buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return buildArrayAnnotationElementAdapter(annotationAdapter, elementName, StringArrayExpressionConverter.forStringLiterals()); + return buildArrayAnnotationElementAdapter(annotationAdapter, elementName, AnnotationStringArrayExpressionConverter.forStringLiterals()); } - protected static DeclarationAnnotationElementAdapter buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter converter) { - return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false, converter); + protected static DeclarationAnnotationElementAdapter buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter converter) { + return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false, converter); } @Override diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AbstractExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AbstractExpressionConverter.java index c299099d36..cd87259db9 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AbstractExpressionConverter.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AbstractExpressionConverter.java @@ -27,7 +27,14 @@ public abstract class AbstractExpressionConverter } public E convert(T object, AST ast) { - return (object == null) ? null : this.convert_(object, ast); + return (object == null) ? this.convertNull(ast) : this.convert_(object, ast); + } + + /** + * Return the expression for a null object. + */ + protected E convertNull(AST ast) { + return null; } /** @@ -37,7 +44,14 @@ public abstract class AbstractExpressionConverter protected abstract E convert_(T object, AST ast); public T convert(E expression) { - return (expression == null) ? null : this.convert_(expression); + return (expression == null) ? this.convertNull() : this.convert_(expression); + } + + /** + * Return the object for a null expression. + */ + protected T convertNull() { + return null; } /** diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AnnotationStringArrayExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AnnotationStringArrayExpressionConverter.java new file mode 100644 index 0000000000..ad49351540 --- /dev/null +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AnnotationStringArrayExpressionConverter.java @@ -0,0 +1,102 @@ +/******************************************************************************* + * 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.internal.jdtutility; + +import org.eclipse.jdt.core.dom.AST; +import org.eclipse.jdt.core.dom.ASTNode; +import org.eclipse.jdt.core.dom.ArrayInitializer; +import org.eclipse.jdt.core.dom.Expression; +import org.eclipse.jdt.core.dom.Name; +import org.eclipse.jdt.core.dom.StringLiteral; + +/** + * Convert an array initializer or single expression to/from an array of + * strings (e.g. {"text0", "text1"}). + * E is the type of the expressions to be found either standalone or + * as elements in the array initializer. + */ +public class AnnotationStringArrayExpressionConverter + extends AbstractExpressionConverter +{ + private final ExpressionConverter elementConverter; + private final StringArrayExpressionConverter arrayConverter; + + + /** + * The default behavior is to remove the array initializer if it is empty. + */ + public AnnotationStringArrayExpressionConverter(ExpressionConverter elementConverter) { + this(elementConverter, true); + } + + public AnnotationStringArrayExpressionConverter(ExpressionConverter elementConverter, boolean removeArrayInitializerWhenEmpty) { + super(); + this.elementConverter = elementConverter; + this.arrayConverter = new StringArrayExpressionConverter(elementConverter, removeArrayInitializerWhenEmpty); + } + + /** + * if we only have a single string in the array return the single expression, + * without braces, instead of an array initializer + */ + @Override + protected Expression convert_(String[] strings, AST ast) { + return (strings.length == 1) ? + this.elementConverter.convert(strings[0], ast) + : + this.arrayConverter.convert_(strings, ast); + } + + @Override + protected String[] convertNull() { + return this.arrayConverter.convertNull(); + } + + /** + * check for a single expression with no surrounding braces, implying a + * single-entry array + */ + @Override + protected String[] convert_(Expression expression) { + return (expression.getNodeType() == ASTNode.ARRAY_INITIALIZER) ? + this.arrayConverter.convert_((ArrayInitializer) expression) + : + new String[] {this.elementConverter.convert(this.downcastExpression(expression))}; + } + + @SuppressWarnings("unchecked") + private E downcastExpression(Expression expression) { + return (E) expression; + } + + + // ********** factory methods ********** + + /** + * Build an expression converter for an annotation element of type String[]. + * @Foo(bar={"text0", "text1"}) + * or + * @Foo(bar="text0") + */ + public static AnnotationStringArrayExpressionConverter forStringLiterals() { + return new AnnotationStringArrayExpressionConverter(StringExpressionConverter.instance()); + } + + /** + * Build an expression converter for an annotation element of type []. + * @Foo(bar={BAZ, BAT}) + * or + * @Foo(bar=BAZ) + */ + public static AnnotationStringArrayExpressionConverter forNames() { + return new AnnotationStringArrayExpressionConverter(NameStringExpressionConverter.instance()); + } + +} diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ConversionDeclarationAnnotationElementAdapter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ConversionDeclarationAnnotationElementAdapter.java index 11ead9d281..088fa0cad4 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ConversionDeclarationAnnotationElementAdapter.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ConversionDeclarationAnnotationElementAdapter.java @@ -96,7 +96,7 @@ public class ConversionDeclarationAnnotationElementAdapter { /** * Given the specified declaration, return the value of the - * annotation element. Return null if the element is not present. + * annotation element. Return null or an empty array + * if the element is not present. */ T getValue(ModifiedDeclaration declaration); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/EnumArrayDeclarationAnnotationElementAdapter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/EnumArrayDeclarationAnnotationElementAdapter.java index 7d153b9b21..de08d4ac8e 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/EnumArrayDeclarationAnnotationElementAdapter.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/EnumArrayDeclarationAnnotationElementAdapter.java @@ -10,6 +10,7 @@ package org.eclipse.jpt.core.internal.jdtutility; import java.util.List; + import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.ArrayInitializer; import org.eclipse.jdt.core.dom.Expression; @@ -25,7 +26,9 @@ public class EnumArrayDeclarationAnnotationElementAdapter /** * The wrapped adapter that returns and takes name strings (enums). */ - private final ConversionDeclarationAnnotationElementAdapter adapter; + private final ConversionDeclarationAnnotationElementAdapter adapter; + + private static final String[] EMPTY_STRING_ARRAY = new String[0]; // ********** constructors ********** @@ -40,21 +43,28 @@ public class EnumArrayDeclarationAnnotationElementAdapter /** * The default behavior is to remove the annotation when the last - * element is removed. + * element is removed and remove the array initializer if it is empty. */ public EnumArrayDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { this(annotationAdapter, elementName, true); } + /** + * The default behavior is to remove the array initializer if it is empty. + */ public EnumArrayDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, boolean removeAnnotationWhenEmpty) { - this(new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, removeAnnotationWhenEmpty, buildExpressionConverter())); + this(annotationAdapter, elementName, removeAnnotationWhenEmpty, true); } - private static ExpressionConverter buildExpressionConverter() { - return new StringArrayExpressionConverter(NameStringExpressionConverter.instance()); + public EnumArrayDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, boolean removeAnnotationWhenEmpty, boolean removeArrayInitializerWhenEmpty) { + this(new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, removeAnnotationWhenEmpty, buildExpressionConverter(removeArrayInitializerWhenEmpty))); } - protected EnumArrayDeclarationAnnotationElementAdapter(ConversionDeclarationAnnotationElementAdapter adapter) { + private static ExpressionConverter buildExpressionConverter(boolean removeArrayInitializerWhenEmpty) { + return new AnnotationStringArrayExpressionConverter(NameStringExpressionConverter.instance(), removeArrayInitializerWhenEmpty); + } + + protected EnumArrayDeclarationAnnotationElementAdapter(ConversionDeclarationAnnotationElementAdapter adapter) { super(); this.adapter = adapter; } @@ -63,6 +73,7 @@ public class EnumArrayDeclarationAnnotationElementAdapter // ********** DeclarationAnnotationElementAdapter implementation ********** public String[] getValue(ModifiedDeclaration declaration) { + // ignore the adapter's getValue() - we want the expression return this.resolve(this.adapter.expression(declaration), declaration); } @@ -82,29 +93,49 @@ public class EnumArrayDeclarationAnnotationElementAdapter // ********** internal methods ********** /** - * resolve the enums + * resolve the enums, which can be + * null + * or + * {FOO, BAR, BAZ} + * or + * FOO */ protected String[] resolve(Expression enumsExpression, ModifiedDeclaration declaration) { if (enumsExpression == null) { - return null; + return EMPTY_STRING_ARRAY; + } else if (enumsExpression.getNodeType() == ASTNode.ARRAY_INITIALIZER) { + return this.resolveArray((ArrayInitializer) enumsExpression, declaration); + } else { + return this.resolveSingleElement(enumsExpression, declaration); } - ArrayInitializer ai = (ArrayInitializer) enumsExpression; + } + + protected String[] resolveArray(ArrayInitializer ai, ModifiedDeclaration declaration) { List expressions = this.expressions(ai); int len = expressions.size(); String[] enums = new String[len]; for (int i = len; i-- > 0; ) { - enums[i] = JDTTools.resolveEnum(declaration.iCompilationUnit(), expressions.get(i)); + enums[i] = this.resolveEnum(expressions.get(i), declaration); } return enums; } + protected String[] resolveSingleElement(Expression enumExpression, ModifiedDeclaration declaration) { + return new String[] {this.resolveEnum(enumExpression, declaration)}; + } + + protected String resolveEnum(Expression enumExpression, ModifiedDeclaration declaration) { + return JDTTools.resolveEnum(declaration.iCompilationUnit(), enumExpression); + } + @SuppressWarnings("unchecked") private List expressions(ArrayInitializer arrayInitializer) { return arrayInitializer.expressions(); } /** - * convert the fully-qualified enums to static imports and short names + * convert the fully-qualified enums to static imports and short names; + * NB: the imports are added as a side-effect :-( */ protected String[] convertToShortNames(String[] enums, ModifiedDeclaration declaration) { if (enums == null) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/StringArrayExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/StringArrayExpressionConverter.java index 08f9fe1b08..02d081ab7b 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/StringArrayExpressionConverter.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/StringArrayExpressionConverter.java @@ -13,24 +13,47 @@ import java.util.List; import org.eclipse.jdt.core.dom.AST; import org.eclipse.jdt.core.dom.ArrayInitializer; import org.eclipse.jdt.core.dom.Expression; -import org.eclipse.jdt.core.dom.StringLiteral; /** * Convert an array initializer to/from an array of strings (e.g. {"text0", "text1"}). * E is the type of the expressions to be found in the array initializer. + * + * Do NOT use this class for converting array initializers in annotation elements. + * Java5 has a bit of syntactic sugar that allows a single-element array + * initializer to not have curly braces. This converter will barf if it encounters + * anything other than an array initializer. */ public class StringArrayExpressionConverter extends AbstractExpressionConverter { private final ExpressionConverter elementConverter; + private final boolean removeArrayInitializerWhenEmpty; + + private static final String[] EMPTY_STRING_ARRAY = new String[0]; + + /** + * The default behavior is to remove the array initializer if it is empty. + */ public StringArrayExpressionConverter(ExpressionConverter elementConverter) { + this(elementConverter, true); + } + + public StringArrayExpressionConverter(ExpressionConverter elementConverter, boolean removeArrayInitializerWhenEmpty) { super(); this.elementConverter = elementConverter; + this.removeArrayInitializerWhenEmpty = removeArrayInitializerWhenEmpty; } @Override - protected ArrayInitializer convert_(String[] strings, AST ast) { + /* + * this method is 'public' so it can be called by + * AnnotationStringArrayExpressionConverter + */ + public ArrayInitializer convert_(String[] strings, AST ast) { + if ((strings.length == 0) && this.removeArrayInitializerWhenEmpty) { + return null; + } ArrayInitializer arrayInitializer = ast.newArrayInitializer(); List expressions = this.expressions(arrayInitializer); for (String string : strings) { @@ -45,7 +68,19 @@ public class StringArrayExpressionConverter } @Override - protected String[] convert_(ArrayInitializer arrayInitializer) { + /* + * this method is 'public' so it can be called by + * AnnotationStringArrayExpressionConverter + */ + public String[] convertNull() { + return EMPTY_STRING_ARRAY; + } + + @Override + /* + * 'public' in support of AnnotationStringArrayExpressionConverter + */ + public String[] convert_(ArrayInitializer arrayInitializer) { List expressions = this.downcastExpressions(arrayInitializer); int len = expressions.size(); String[] strings = new String[len]; @@ -60,12 +95,4 @@ public class StringArrayExpressionConverter return arrayInitializer.expressions(); } - /** - * Build an expression converter for an annotation element of type String[]. - * @Foo(bar={"text0", "text1"}) - */ - public static StringArrayExpressionConverter forStringLiterals() { - return new StringArrayExpressionConverter(StringExpressionConverter.instance()); - } - } 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 index a13cf24929..9f16dc1086 100644 --- 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 @@ -10,14 +10,17 @@ package org.eclipse.jpt.core.tests.internal.jdtutility; import java.util.Arrays; -import org.eclipse.jdt.core.dom.ArrayInitializer; + import org.eclipse.jdt.core.dom.BooleanLiteral; import org.eclipse.jdt.core.dom.CharacterLiteral; +import org.eclipse.jdt.core.dom.Expression; import org.eclipse.jdt.core.dom.NumberLiteral; +import org.eclipse.jdt.core.dom.StringLiteral; import org.eclipse.jdt.core.dom.TypeLiteral; 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; @@ -25,6 +28,7 @@ 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; @@ -32,7 +36,7 @@ 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.StringArrayExpressionConverter; +import org.eclipse.jpt.core.internal.jdtutility.StringExpressionConverter; public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { @@ -551,18 +555,36 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { this.createAnnotationAndMembers("Foo", "String[] bar();"); this.createTestType("@annot.Foo(bar={\"string0\", \"string1\"})"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", StringArrayExpressionConverter.forStringLiterals()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStringLiterals()); 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.forStringLiterals()); + 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.forStringLiterals()); + 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", StringArrayExpressionConverter.forStringLiterals()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStringLiterals()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertNull(aea.getValue()); + assertTrue(Arrays.equals(new String[0], aea.getValue())); } public void testSetValueStringArray() throws Exception { @@ -571,12 +593,49 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { this.createTestType(); this.assertSourceDoesNotContain(annotation); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", StringArrayExpressionConverter.forStringLiterals()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStringLiterals()); 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.forStringLiterals()); + 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.forStringLiterals()); + 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();"); @@ -587,6 +646,26 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { assertTrue(Arrays.equals(new String[] {"enums.TestEnum.XXX", "enums.TestEnum.YYY"}, 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 testGetValueNullEnumArray() throws Exception { this.createEnum("TestEnum", "XXX, YYY, ZZZ"); this.createAnnotationAndMembers("Foo", "enums.TestEnum[] bar();"); @@ -594,7 +673,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); DeclarationAnnotationElementAdapter daea = new EnumArrayDeclarationAnnotationElementAdapter(daa, "bar"); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); - assertNull(aea.getValue()); + assertTrue(Arrays.equals(new String[0], aea.getValue())); } public void testSetValueEnumArray() throws Exception { @@ -612,4 +691,44 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { 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); + } + } -- cgit v1.2.3 From 88ef81b14bab6ec9a3caca827e3832069d783b0e Mon Sep 17 00:00:00 2001 From: kmoore Date: Tue, 24 Jul 2007 14:00:04 +0000 Subject: 196167 - apply patch - could not create a new jpa project if more than 2 user libraries defined --- .../internal/facet/JpaFacetDataModelProvider.java | 23 ++++++---------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetDataModelProvider.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetDataModelProvider.java index 5703ecb580..3d5631119b 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetDataModelProvider.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/facet/JpaFacetDataModelProvider.java @@ -10,7 +10,6 @@ package org.eclipse.jpt.core.internal.facet; import java.util.Arrays; -import java.util.Comparator; import java.util.Set; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; @@ -99,25 +98,15 @@ public class JpaFacetDataModelProvider public DataModelPropertyDescriptor[] getValidPropertyDescriptors(String propertyName) { if (JPA_LIBRARY.equals(propertyName)) { String[] libraries = JavaCore.getUserLibraryNames(); + Arrays.sort(libraries); DataModelPropertyDescriptor[] descriptors = new DataModelPropertyDescriptor[libraries.length + 1]; - for (int i = 0; i < libraries.length ; i ++) { - descriptors[i + 1] = new DataModelPropertyDescriptor(libraries[i], libraries[i]); - } - - if(descriptors.length > 2){ - Arrays.sort(descriptors, 0, descriptors.length - 2, - new Comparator() { - public int compare(Object arg0, Object arg1) { - DataModelPropertyDescriptor d1 = (DataModelPropertyDescriptor)arg0; - DataModelPropertyDescriptor d2 = (DataModelPropertyDescriptor)arg1; - return d1.getPropertyDescription().compareTo(d2.getPropertyDescription()); - } - } - ); - } - descriptors[0] = new DataModelPropertyDescriptor("", WTPCommonPlugin.getResourceString(WTPCommonMessages.RUNTIME_NONE, null)); + + int i = 1; + for (String library : libraries) { + descriptors[i++] = new DataModelPropertyDescriptor(library, library); + } return descriptors; } -- cgit v1.2.3 From a30494c0bc4ff3d8cf873c42b80389c0fc69a7da Mon Sep 17 00:00:00 2001 From: kmoore Date: Tue, 24 Jul 2007 16:00:27 +0000 Subject: 197281 - applied patch - check that only PRIMARY_WORKING_COPY flag is set before returning from JPA java model update --- .../org/eclipse/jpt/core/internal/content/java/JpaCompilationUnit.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JpaCompilationUnit.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JpaCompilationUnit.java index 1d8bdbc48e..aab555f9c6 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JpaCompilationUnit.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JpaCompilationUnit.java @@ -379,7 +379,8 @@ public class JpaCompilationUnit extends JavaEObject private void synchCompilationUnitWithJavaDelta(IJavaElementDelta delta) { // ignore changes to/from primary working copy - no content has changed - if ((delta.getFlags() & IJavaElementDelta.F_PRIMARY_WORKING_COPY) != 0) { + // this checks that no flags other than F_PRIMARY_WORKING_COPY are set + if ((delta.getFlags() & ~IJavaElementDelta.F_PRIMARY_WORKING_COPY) == 0) { return; } // synchronize if the change is for this compilation unit -- cgit v1.2.3 From dcd3782dc6ff15883e14a76345dd22417bd846a2 Mon Sep 17 00:00:00 2001 From: kmoore Date: Tue, 24 Jul 2007 17:51:37 +0000 Subject: 191113 - applied patch - mappedBy combo needs to update when mappedBy is set to null --- .../org/eclipse/jpt/ui/internal/mappings/details/MappedByCombo.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/MappedByCombo.java b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/MappedByCombo.java index b0993475ca..593988c654 100644 --- a/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/MappedByCombo.java +++ b/jpa/plugins/org.eclipse.jpt.ui/src/org/eclipse/jpt/ui/internal/mappings/details/MappedByCombo.java @@ -109,6 +109,9 @@ public class MappedByCombo extends BaseJpaController this.combo.setText(mappedBy); } } + else { + this.combo.setText(""); + } } @Override -- cgit v1.2.3 From da54e25c757ae08a5a033bd8581eb96553e05a2e Mon Sep 17 00:00:00 2001 From: kmoore Date: Mon, 30 Jul 2007 18:21:30 +0000 Subject: 198303 - changed IJpaPlatformUI to IJpaPlatformUi in the ui jpaPlatform extension point --- jpa/plugins/org.eclipse.jpt.ui/schema/jpaPlatform.exsd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jpa/plugins/org.eclipse.jpt.ui/schema/jpaPlatform.exsd b/jpa/plugins/org.eclipse.jpt.ui/schema/jpaPlatform.exsd index 92d1085e5e..6790dbe439 100644 --- a/jpa/plugins/org.eclipse.jpt.ui/schema/jpaPlatform.exsd +++ b/jpa/plugins/org.eclipse.jpt.ui/schema/jpaPlatform.exsd @@ -64,7 +64,7 @@ - + -- cgit v1.2.3 From 81cb087af81d36bbb5ba2bf8ca3db24ac47e705a Mon Sep 17 00:00:00 2001 From: pfullbright Date: Fri, 10 Aug 2007 00:02:32 +0000 Subject: bug 193606 --- .../org/eclipse/jpt/core/internal/JpaModel.java | 11 +-- .../eclipse/jpt/core/internal/JpaModelManager.java | 90 ++++++++++++++++++---- .../org/eclipse/jpt/core/internal/JpaProject.java | 57 +++++++++----- 3 files changed, 113 insertions(+), 45 deletions(-) diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaModel.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaModel.java index 5245e2628d..b968016ec0 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaModel.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaModel.java @@ -165,19 +165,10 @@ public class JpaModel extends JpaEObject implements IJpaModel */ void dispose() { for (Iterator stream = new CloneIterator(getProjects()); stream.hasNext();) { - disposeProject((JpaProject) stream.next()); + ((JpaProject) stream.next()).dispose(); } } - /** - * INTERNAL ONLY - * Dispose project and remove it - */ - void disposeProject(JpaProject jpaProject) { - jpaProject.dispose(); - getProjects().remove(jpaProject); - } - /** * INTERNAL ONLY * Handle java element change event. diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaModelManager.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaModelManager.java index a92adec995..2de2b44c77 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaModelManager.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaModelManager.java @@ -33,6 +33,8 @@ import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jpt.core.internal.prefs.JpaPreferenceConstants; import org.eclipse.wst.common.project.facet.core.FacetedProjectFramework; +import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent; +import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener; public class JpaModelManager { @@ -59,6 +61,11 @@ public class JpaModelManager * Processes resource changes */ private IResourceChangeListener resourceChangeListener; + + /** + * Processes changes to project facets + */ + private final IFacetedProjectListener facetedProjectListener; /** * Process element changes @@ -75,6 +82,7 @@ public class JpaModelManager super(); model = JpaCoreFactory.eINSTANCE.createJpaModel(); resourceChangeListener = new ResourceChangeListener(); + facetedProjectListener = new FacetedProjectListener(); elementChangeListener = new ElementChangeListener(); preferencesListener = new PreferencesListener(); } @@ -83,6 +91,7 @@ public class JpaModelManager try { buildWorkspace(); ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceChangeListener); + FacetedProjectFramework.addListener(facetedProjectListener, IFacetedProjectEvent.Type.values()); JavaCore.addElementChangedListener(elementChangeListener); JptCorePlugin.getPlugin().getPluginPreferences().addPropertyChangeListener(preferencesListener); } @@ -216,7 +225,7 @@ public class JpaModelManager * Dispose the IJpaProject */ public void disposeJpaProject(IJpaProject jpaProject) { - model.disposeProject((JpaProject) jpaProject); + ((JpaProject) jpaProject).dispose(); } /** @@ -310,6 +319,7 @@ public class JpaModelManager switch (event.getType()){ case IResourceChangeEvent.PRE_DELETE : + case IResourceChangeEvent.PRE_CLOSE : try { if ((resource.getType() == IResource.PROJECT) && (FacetedProjectFramework.hasProjectFacet( @@ -328,9 +338,6 @@ public class JpaModelManager checkForFilesBeingAddedOrRemoved(delta); } return; - - case IResourceChangeEvent.PRE_CLOSE : - return; } } } @@ -417,19 +424,7 @@ public class JpaModelManager JptCorePlugin.log(ce); } } - } - else { - // project has been closed. dispose jpa project if it exists. - if (jpaProject != null) { - model.disposeProject(jpaProject); - } } - } - else if ((delta.getFlags() & IResourceDelta.DESCRIPTION) != 0) { - // again, not sure ... - } - else { - // ... } break; } @@ -449,7 +444,7 @@ public class JpaModelManager private void projectBeingDeleted(IProject project) { // could be problems here ... JpaProject jpaProject = (JpaProject) model.getJpaProject(project); - model.disposeProject(jpaProject); + jpaProject.dispose(); } /** @@ -495,6 +490,67 @@ public class JpaModelManager } + private static class FacetedProjectListener + implements IFacetedProjectListener + { + ThreadLocal processors = + new ThreadLocal(); + + FacetedProjectListener() { + super(); + } + + public void handleEvent(IFacetedProjectEvent event) { + getProcessor().handleEvent(event); + } + + public FacetedProjectChangeProcessor getProcessor() { + FacetedProjectChangeProcessor processor = processors.get(); + if (processor == null) { + processor = new FacetedProjectChangeProcessor(); + processors.set(processor); + } + return processor; + } + } + + + private static class FacetedProjectChangeProcessor + { + private JpaModel model; + + FacetedProjectChangeProcessor() { + model = JpaModelManager.instance().model; + } + + protected void handleEvent(IFacetedProjectEvent event) { + IProject project = event.getProject().getProject(); + JpaProject jpaProject = (JpaProject) model.getJpaProject(project); + boolean jpaFacetExists = false; + try { + jpaFacetExists = FacetedProjectFramework.hasProjectFacet(project, JptCorePlugin.FACET_ID); + } + catch (CoreException ce) { + // nothing to do, assume facet doesn't exist + JptCorePlugin.log(ce); + } + + if (jpaFacetExists && jpaProject == null) { + try { + JpaModelManager.instance().createFilledJpaProject(project); + } + catch (CoreException ce) { + // nothing to do, nothing we *can* do + JptCorePlugin.log(ce); + } + } + else if (jpaProject != null && ! jpaFacetExists) { + jpaProject.dispose(); + } + } + } + + private static class ElementChangeListener implements IElementChangedListener { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java index 5eadeb8b41..ff5db48870 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java @@ -142,6 +142,12 @@ public class JpaProject extends JpaEObject implements IJpaProject * This is set to false when that job is completed */ boolean resynching = false; + + /** + * Flag to indicate that the disposing job has been scheduled or is running + * (or has been run, in some cases) + */ + boolean disposing = false; /** * Flag to indicate that the resynchJob needs to be run. This is @@ -171,7 +177,7 @@ public class JpaProject extends JpaEObject implements IJpaProject } private Job buildResynchJob() { - return new Job("Resynching JPA model ...") { + Job job = new Job("Resynching JPA model ...") { @Override protected IStatus run(IProgressMonitor monitor) { IContext contextHierarchy = getPlatform().buildProjectContext(); @@ -179,6 +185,8 @@ public class JpaProject extends JpaEObject implements IJpaProject return Status.OK_STATUS; } }; + job.setRule(project); + return job; } private IJobChangeListener buildResynchJobListener() { @@ -187,8 +195,11 @@ public class JpaProject extends JpaEObject implements IJpaProject public void done(IJobChangeEvent event) { super.done(event); if (event.getJob() == JpaProject.this.resynchJob) { - JpaProject.this.resynching = false; - if (JpaProject.this.needsToResynch) { + resynching = false; + if (event.getResult().matches(IStatus.CANCEL)) { + needsToResynch = false; + } + else if (needsToResynch) { resynch(); } } @@ -563,22 +574,30 @@ public class JpaProject extends JpaEObject implements IJpaProject /** * INTERNAL ONLY - * Dispose of project before it is removed + * Dispose and remove project */ void dispose() { - for (Iterator stream = new CloneIterator(getFiles()); stream.hasNext();) { - disposeFile((JpaFile) stream.next()); + if (disposing) return; + + disposing = true; + + Job job = new Job("Disposing JPA project ...") { + @Override + protected IStatus run(IProgressMonitor monitor) { + dispose_(); + return Status.OK_STATUS; + } + }; + job.setRule(project); + job.schedule(); + } + + private void dispose_() { + Job.getJobManager().removeJobChangeListener(resynchJobListener); + for (IJpaFile jpaFile : new ArrayList(getFiles())) { + ((JpaFile) jpaFile).dispose(); } - Job.getJobManager().removeJobChangeListener(this.resynchJobListener); - } - - /** - * INTERNAL ONLY - * Dispose file and remove it - */ - void disposeFile(JpaFile jpaFile) { - jpaFile.dispose(); - getFiles().remove(jpaFile); + ((JpaModel) getModel()).getProjects().remove(this); } /** @@ -609,7 +628,7 @@ public class JpaProject extends JpaEObject implements IJpaProject case IResourceDelta.REMOVED : JpaFile jpaFile = (JpaFile) getJpaFile(file); if (jpaFile != null) { - disposeFile(jpaFile); + jpaFile.dispose(); JpaProject.this.resynch();//TODO different api for this? } break; @@ -659,7 +678,9 @@ public class JpaProject extends JpaEObject implements IJpaProject //passing it on to the JpaModel. We don't currently support //multiple projects having cross-references public void resynch() { - if (!this.resynching) { + if (disposing) return; + + if (! resynching) { this.resynching = true; this.needsToResynch = false; this.resynchJob.schedule(); -- cgit v1.2.3 From 63049b3244abd96792be835c7e505fd2380e8ee6 Mon Sep 17 00:00:00 2001 From: tle Date: Mon, 13 Aug 2007 23:22:46 +0000 Subject: *** empty log message *** --- jpa/plugins/org.eclipse.jpt.db/.cvsignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jpa/plugins/org.eclipse.jpt.db/.cvsignore b/jpa/plugins/org.eclipse.jpt.db/.cvsignore index 814c6a80a6..e043cc4e2c 100644 --- a/jpa/plugins/org.eclipse.jpt.db/.cvsignore +++ b/jpa/plugins/org.eclipse.jpt.db/.cvsignore @@ -1,3 +1,3 @@ bin build.xml -javaCompiler...args \ No newline at end of file +javaCompiler...args -- cgit v1.2.3 From 6e54456708f59329bb955ff4ee859fb660e52901 Mon Sep 17 00:00:00 2001 From: tle Date: Wed, 15 Aug 2007 22:08:58 +0000 Subject: Fix for [193014] Obsolete values in plugin.xml --- jpa/plugins/org.eclipse.jpt.doc.user/plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jpa/plugins/org.eclipse.jpt.doc.user/plugin.xml b/jpa/plugins/org.eclipse.jpt.doc.user/plugin.xml index e7d121acd2..a267bbc742 100644 --- a/jpa/plugins/org.eclipse.jpt.doc.user/plugin.xml +++ b/jpa/plugins/org.eclipse.jpt.doc.user/plugin.xml @@ -1,6 +1,6 @@ - + -- cgit v1.2.3 From 71eb1763c14ce0a5a4d81cd56f2692d758a02550 Mon Sep 17 00:00:00 2001 From: kmoore Date: Mon, 20 Aug 2007 18:17:00 +0000 Subject: 198934 - applied patch from head - resolve Constant Expressions --- .../eclipse/jpt/core/internal/IJpaContentNode.java | 12 +- .../internal/content/java/JpaCompilationUnit.java | 9 +- .../internal/content/java/mappings/JavaBasic.java | 3 +- .../internal/content/java/mappings/JavaEntity.java | 3 +- .../content/java/mappings/JavaGenerator.java | 3 +- .../java/mappings/JavaMappedSuperclass.java | 3 +- .../content/java/mappings/JavaNamedColumn.java | 7 +- .../java/mappings/JavaRelationshipMapping.java | 8 +- .../mappings/JavaSingleRelationshipMapping.java | 10 +- .../java/mappings/JavaUniqueConstraint.java | 9 +- .../jdtutility/AbstractExpressionConverter.java | 39 ++- .../AnnotationStringArrayExpressionConverter.java | 39 ++- .../BooleanStringExpressionConverter.java | 18 +- .../CharacterStringExpressionConverter.java | 18 +- ...versionDeclarationAnnotationElementAdapter.java | 150 ++++++++--- ...umArrayDeclarationAnnotationElementAdapter.java | 29 +-- .../EnumDeclarationAnnotationElementAdapter.java | 12 +- .../internal/jdtutility/ExpressionConverter.java | 7 +- .../jpt/core/internal/jdtutility/JDTTools.java | 151 ++++------- .../jpt/core/internal/jdtutility/Member.java | 25 +- .../internal/jdtutility/ModifiedDeclaration.java | 40 ++- .../jdtutility/NameStringExpressionConverter.java | 15 +- .../jdtutility/NullExpressionConverter.java | 6 +- .../NumberStringExpressionConverter.java | 18 +- .../PrimitiveTypeStringExpressionConverter.java | 15 +- .../SimpleTypeStringExpressionConverter.java | 15 +- .../jdtutility/StringArrayExpressionConverter.java | 39 ++- .../jdtutility/StringExpressionConverter.java | 18 +- .../tests/internal/jdtutility/JDTToolsTests.java | 9 +- .../MemberAnnotationElementAdapterTests.java | 282 ++++++++++++++++++--- 30 files changed, 638 insertions(+), 374 deletions(-) diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaContentNode.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaContentNode.java index 5d83c12bbf..5676d2e104 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaContentNode.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/IJpaContentNode.java @@ -1,8 +1,8 @@ /******************************************************************************* * 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. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. * * Contributors: * Oracle - initial API and implementation @@ -34,12 +34,6 @@ public interface IJpaContentNode extends IJpaSourceObject */ Object getId(); - /** - * Return the text range for this contentNode. This is the all-inclusive - * text range to be used for finding a particular content node given a source location. - */ - ITextRange fullTextRange(); - /** * Return the text range to be used for selection. This is the text you want selected * when selecting the object in the editor. StructureView uses this for selection diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JpaCompilationUnit.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JpaCompilationUnit.java index aab555f9c6..346e6e179d 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JpaCompilationUnit.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JpaCompilationUnit.java @@ -34,7 +34,6 @@ import org.eclipse.jpt.core.internal.IJpaRootContentNode; import org.eclipse.jpt.core.internal.ITextRange; import org.eclipse.jpt.core.internal.JpaCorePackage; import org.eclipse.jpt.core.internal.JpaFile; -import org.eclipse.jpt.core.internal.jdtutility.ASTNodeTextRange; import org.eclipse.jpt.core.internal.jdtutility.AttributeAnnotationTools; import org.eclipse.jpt.core.internal.jdtutility.JDTTools; import org.eclipse.jpt.utility.internal.Filter; @@ -288,10 +287,6 @@ public class JpaCompilationUnit extends JavaEObject return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); } - public ITextRange fullTextRange() { - return new ASTNodeTextRange(this.astRoot()); - } - public ITextRange validationTextRange() { return this.selectionTextRange(); } @@ -444,8 +439,8 @@ public class JpaCompilationUnit extends JavaEObject return EmptyIterator.instance(); } - public CompilationUnit astRoot() { - return JDTTools.createASTRoot(this.compilationUnit); + private CompilationUnit astRoot() { + return JDTTools.buildASTRoot(this.compilationUnit); } public void dispose() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaBasic.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaBasic.java index 7ab0f41a1a..8208e19bdf 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaBasic.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaBasic.java @@ -21,7 +21,6 @@ import org.eclipse.jdt.core.ITypeHierarchy; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.Signature; import org.eclipse.jdt.core.WorkingCopyOwner; -import org.eclipse.jdt.core.dom.BooleanLiteral; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.IMappingKeys; import org.eclipse.jpt.core.internal.jdtutility.AnnotationAdapter; @@ -740,7 +739,7 @@ public class JavaBasic extends JavaAttributeMapping implements IBasic // ********** static methods ********** private static DeclarationAnnotationElementAdapter buildOptionalAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.BASIC__OPTIONAL, false, BooleanStringExpressionConverter.instance()); + return new ConversionDeclarationAnnotationElementAdapter(DECLARATION_ANNOTATION_ADAPTER, JPA.BASIC__OPTIONAL, false, BooleanStringExpressionConverter.instance()); } private static DeclarationAnnotationElementAdapter buildFetchAdapter() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaEntity.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaEntity.java index a648186d8c..70585b91a6 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaEntity.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaEntity.java @@ -23,7 +23,6 @@ import org.eclipse.emf.ecore.util.EObjectEList; import org.eclipse.emf.ecore.util.InternalEList; import org.eclipse.jdt.core.dom.Annotation; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.TypeLiteral; import org.eclipse.jpt.core.internal.IMappingKeys; import org.eclipse.jpt.core.internal.IPersistentAttribute; import org.eclipse.jpt.core.internal.IPersistentType; @@ -2994,6 +2993,6 @@ public class JavaEntity extends JavaTypeMapping implements IEntity // ********** static methods ********** private static DeclarationAnnotationElementAdapter buildIdClassValueAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(ID_CLASS_ADAPTER, JPA.ID_CLASS__VALUE, false, SimpleTypeStringExpressionConverter.instance()); + return new ConversionDeclarationAnnotationElementAdapter(ID_CLASS_ADAPTER, JPA.ID_CLASS__VALUE, false, SimpleTypeStringExpressionConverter.instance()); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaGenerator.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaGenerator.java index 8066e5356c..25c53ac257 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaGenerator.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaGenerator.java @@ -13,7 +13,6 @@ import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.NumberLiteral; import org.eclipse.jpt.core.internal.ITextRange; import org.eclipse.jpt.core.internal.content.java.JavaEObject; import org.eclipse.jpt.core.internal.jdtutility.AnnotationElementAdapter; @@ -565,6 +564,6 @@ public abstract class JavaGenerator extends JavaEObject implements IGenerator } protected static DeclarationAnnotationElementAdapter buildNumberAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, NumberStringExpressionConverter.instance()); + return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, NumberStringExpressionConverter.instance()); } } // JavaGenerator diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMappedSuperclass.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMappedSuperclass.java index ec505b2f52..8342396ae4 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMappedSuperclass.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaMappedSuperclass.java @@ -14,7 +14,6 @@ import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.TypeLiteral; import org.eclipse.jpt.core.internal.IMappingKeys; import org.eclipse.jpt.core.internal.IPersistentAttribute; import org.eclipse.jpt.core.internal.jdtutility.AnnotationAdapter; @@ -325,6 +324,6 @@ public class JavaMappedSuperclass extends JavaTypeMapping // ********** static methods ********** private static DeclarationAnnotationElementAdapter buildIdClassValueAdapter() { - return new ConversionDeclarationAnnotationElementAdapter(ID_CLASS_ADAPTER, JPA.ID_CLASS__VALUE, false, SimpleTypeStringExpressionConverter.instance()); + return new ConversionDeclarationAnnotationElementAdapter(ID_CLASS_ADAPTER, JPA.ID_CLASS__VALUE, false, SimpleTypeStringExpressionConverter.instance()); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedColumn.java index 61b7da6e2d..abfb4c3c9d 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedColumn.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedColumn.java @@ -10,12 +10,11 @@ package org.eclipse.jpt.core.internal.content.java.mappings; import java.util.Iterator; + import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.jdt.core.dom.BooleanLiteral; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.NumberLiteral; import org.eclipse.jpt.core.internal.ITextRange; import org.eclipse.jpt.core.internal.content.java.JavaEObject; import org.eclipse.jpt.core.internal.jdtutility.AnnotationElementAdapter; @@ -152,11 +151,11 @@ public abstract class JavaNamedColumn extends JavaEObject } protected DeclarationAnnotationElementAdapter buildBooleanElementAdapter(String elementName) { - return new ConversionDeclarationAnnotationElementAdapter(this.daa, elementName, BooleanStringExpressionConverter.instance()); + return new ConversionDeclarationAnnotationElementAdapter(this.daa, elementName, BooleanStringExpressionConverter.instance()); } protected DeclarationAnnotationElementAdapter buildIntElementAdapter(String elementName) { - return new ConversionDeclarationAnnotationElementAdapter(this.daa, elementName, NumberStringExpressionConverter.instance()); + return new ConversionDeclarationAnnotationElementAdapter(this.daa, elementName, NumberStringExpressionConverter.instance()); } protected AnnotationElementAdapter buildShortCircuitElementAdapter(DeclarationAnnotationElementAdapter daea) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaRelationshipMapping.java index 9deacff895..1b16973e04 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaRelationshipMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaRelationshipMapping.java @@ -10,6 +10,7 @@ package org.eclipse.jpt.core.internal.content.java.mappings; import java.util.Iterator; + import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.ecore.EClass; @@ -18,7 +19,6 @@ import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.Signature; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.Expression; import org.eclipse.jpt.core.internal.IPersistentType; import org.eclipse.jpt.core.internal.ITypeMapping; import org.eclipse.jpt.core.internal.jdtutility.AnnotationElementAdapter; @@ -562,7 +562,7 @@ public abstract class JavaRelationshipMapping extends JavaAttributeMapping if (this.cascade != null) { ((JavaCascade) this.cascade).updateFromJava(astRoot); } - else if (cascadeAdapter().expression(getAttribute().modifiedDeclaration()) != null) { + else if (cascadeAdapter().expression(getAttribute().modifiedDeclaration(astRoot)) != null) { setCascade(createCascade()); ((JavaCascade) this.cascade).updateFromJava(astRoot); } @@ -654,8 +654,8 @@ public abstract class JavaRelationshipMapping extends JavaAttributeMapping return buildAnnotationElementAdapter(annotationAdapter, elementName, StringExpressionConverter.instance()); } - protected static DeclarationAnnotationElementAdapter buildAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter converter) { - return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false, converter); + protected static DeclarationAnnotationElementAdapter buildAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter converter) { + return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false, converter); } protected static DeclarationAnnotationElementAdapter buildEnumAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSingleRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSingleRelationshipMapping.java index 73dd74fbd3..ceee378b92 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSingleRelationshipMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSingleRelationshipMapping.java @@ -1,8 +1,8 @@ /******************************************************************************* * 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. + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0, which accompanies this distribution + * and is available at http://www.eclipse.org/legal/epl-v10.html. * * Contributors: * Oracle - initial API and implementation @@ -12,6 +12,7 @@ package org.eclipse.jpt.core.internal.content.java.mappings; import java.util.Collection; import java.util.Iterator; import java.util.List; + import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.common.util.EList; @@ -20,7 +21,6 @@ import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.impl.ENotificationImpl; import org.eclipse.emf.ecore.util.EObjectContainmentEList; import org.eclipse.emf.ecore.util.InternalEList; -import org.eclipse.jdt.core.dom.BooleanLiteral; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jpt.core.internal.jdtutility.AnnotationElementAdapter; import org.eclipse.jpt.core.internal.jdtutility.Attribute; @@ -681,6 +681,6 @@ public abstract class JavaSingleRelationshipMapping // ********** static methods ********** protected static DeclarationAnnotationElementAdapter buildOptionalAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false, BooleanStringExpressionConverter.instance()); + return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false, BooleanStringExpressionConverter.instance()); } } // JavaSingleRelationshipMapping diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaUniqueConstraint.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaUniqueConstraint.java index 1d7978cfbd..2c425e8214 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaUniqueConstraint.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaUniqueConstraint.java @@ -11,14 +11,12 @@ package org.eclipse.jpt.core.internal.content.java.mappings; import java.util.Collection; import java.util.Iterator; - import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.util.EDataTypeEList; import org.eclipse.jdt.core.dom.Annotation; import org.eclipse.jdt.core.dom.CompilationUnit; -import org.eclipse.jdt.core.dom.Expression; import org.eclipse.jpt.core.internal.ITextRange; import org.eclipse.jpt.core.internal.content.java.JavaEObject; import org.eclipse.jpt.core.internal.jdtutility.AnnotationElementAdapter; @@ -98,13 +96,14 @@ public class JavaUniqueConstraint extends JavaEObject } protected static DeclarationAnnotationElementAdapter buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return buildArrayAnnotationElementAdapter(annotationAdapter, elementName, AnnotationStringArrayExpressionConverter.forStringLiterals()); + return buildArrayAnnotationElementAdapter(annotationAdapter, elementName, AnnotationStringArrayExpressionConverter.forStrings()); } - protected static DeclarationAnnotationElementAdapter buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter converter) { - return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false, converter); + protected static DeclarationAnnotationElementAdapter buildArrayAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter converter) { + return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false, converter); } + @Override protected void notifyChanged(Notification notification) { super.notifyChanged(notification); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AbstractExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AbstractExpressionConverter.java index cd87259db9..11f4ad34ca 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AbstractExpressionConverter.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AbstractExpressionConverter.java @@ -14,26 +14,35 @@ import org.eclipse.jdt.core.dom.Expression; import org.eclipse.jpt.utility.internal.StringTools; /** - * Gather together just the tiniest bit of common behavior. - * E is the expression type. + * Gather together the common implementation behavior. * T is the type of the object to be converted to and from an expression. + * + * We're still figuring out Java Generics here.... The methods in this abstract + * class work fine with any subclass of Expression E; but a ClassCastException + * will occur as soon as we call any method implemented by a subclass + * (e.g. StringExpressionConverter) that expects a particular subclass of + * Expression (e.g. StringLiteral). */ -public abstract class AbstractExpressionConverter - implements ExpressionConverter +public abstract class AbstractExpressionConverter + implements ExpressionConverter { protected AbstractExpressionConverter() { super(); } - public E convert(T object, AST ast) { - return (object == null) ? this.convertNull(ast) : this.convert_(object, ast); + + // ********** object -> expression ********** + + public Expression convert(T object, AST ast) { + return (object == null) ? this.convertNull(ast) : this.convertObject(object, ast); } /** - * Return the expression for a null object. + * Return the expression for a null object. By default, a null object will + * be converted into a null expression. */ - protected E convertNull(AST ast) { + protected Expression convertNull(AST ast) { return null; } @@ -41,14 +50,18 @@ public abstract class AbstractExpressionConverter * The specified object is not null. * @see #convert(T, AST) */ - protected abstract E convert_(T object, AST ast); + protected abstract Expression convertObject(T object, AST ast); + + + // ********** expression -> object ********** - public T convert(E expression) { - return (expression == null) ? this.convertNull() : this.convert_(expression); + public T convert(Expression expression) { + return (expression == null) ? this.convertNull() : this.convertExpression(expression); } /** - * Return the object for a null expression. + * Return the object for a null expression. By default, a null expression will + * be converted into a null object. */ protected T convertNull() { return null; @@ -58,7 +71,7 @@ public abstract class AbstractExpressionConverter * The specified expression is not null. * @see #convert(Expression) */ - protected abstract T convert_(E expression); + protected abstract T convertExpression(Expression expression); @Override public String toString() { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AnnotationStringArrayExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AnnotationStringArrayExpressionConverter.java index ad49351540..21557f6944 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AnnotationStringArrayExpressionConverter.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/AnnotationStringArrayExpressionConverter.java @@ -13,8 +13,6 @@ import org.eclipse.jdt.core.dom.AST; import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.ArrayInitializer; import org.eclipse.jdt.core.dom.Expression; -import org.eclipse.jdt.core.dom.Name; -import org.eclipse.jdt.core.dom.StringLiteral; /** * Convert an array initializer or single expression to/from an array of @@ -22,24 +20,24 @@ import org.eclipse.jdt.core.dom.StringLiteral; * E is the type of the expressions to be found either standalone or * as elements in the array initializer. */ -public class AnnotationStringArrayExpressionConverter - extends AbstractExpressionConverter +public class AnnotationStringArrayExpressionConverter + extends AbstractExpressionConverter { - private final ExpressionConverter elementConverter; - private final StringArrayExpressionConverter arrayConverter; + private final ExpressionConverter elementConverter; + private final StringArrayExpressionConverter arrayConverter; /** * The default behavior is to remove the array initializer if it is empty. */ - public AnnotationStringArrayExpressionConverter(ExpressionConverter elementConverter) { + public AnnotationStringArrayExpressionConverter(ExpressionConverter elementConverter) { this(elementConverter, true); } - public AnnotationStringArrayExpressionConverter(ExpressionConverter elementConverter, boolean removeArrayInitializerWhenEmpty) { + public AnnotationStringArrayExpressionConverter(ExpressionConverter elementConverter, boolean removeArrayInitializerWhenEmpty) { super(); this.elementConverter = elementConverter; - this.arrayConverter = new StringArrayExpressionConverter(elementConverter, removeArrayInitializerWhenEmpty); + this.arrayConverter = new StringArrayExpressionConverter(elementConverter, removeArrayInitializerWhenEmpty); } /** @@ -47,11 +45,11 @@ public class AnnotationStringArrayExpressionConverter * without braces, instead of an array initializer */ @Override - protected Expression convert_(String[] strings, AST ast) { + protected Expression convertObject(String[] strings, AST ast) { return (strings.length == 1) ? this.elementConverter.convert(strings[0], ast) : - this.arrayConverter.convert_(strings, ast); + this.arrayConverter.convertObject(strings, ast); } @Override @@ -64,16 +62,11 @@ public class AnnotationStringArrayExpressionConverter * single-entry array */ @Override - protected String[] convert_(Expression expression) { + protected String[] convertExpression(Expression expression) { return (expression.getNodeType() == ASTNode.ARRAY_INITIALIZER) ? - this.arrayConverter.convert_((ArrayInitializer) expression) + this.arrayConverter.convertArrayInitializer((ArrayInitializer) expression) : - new String[] {this.elementConverter.convert(this.downcastExpression(expression))}; - } - - @SuppressWarnings("unchecked") - private E downcastExpression(Expression expression) { - return (E) expression; + new String[] {this.elementConverter.convert(expression)}; } @@ -85,8 +78,8 @@ public class AnnotationStringArrayExpressionConverter * or * @Foo(bar="text0") */ - public static AnnotationStringArrayExpressionConverter forStringLiterals() { - return new AnnotationStringArrayExpressionConverter(StringExpressionConverter.instance()); + public static AnnotationStringArrayExpressionConverter forStrings() { + return new AnnotationStringArrayExpressionConverter(StringExpressionConverter.instance()); } /** @@ -95,8 +88,8 @@ public class AnnotationStringArrayExpressionConverter * or * @Foo(bar=BAZ) */ - public static AnnotationStringArrayExpressionConverter forNames() { - return new AnnotationStringArrayExpressionConverter(NameStringExpressionConverter.instance()); + public static AnnotationStringArrayExpressionConverter forNames() { + return new AnnotationStringArrayExpressionConverter(NameStringExpressionConverter.instance()); } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/BooleanStringExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/BooleanStringExpressionConverter.java index 0f5854e5d6..f7bf5d6063 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/BooleanStringExpressionConverter.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/BooleanStringExpressionConverter.java @@ -10,22 +10,22 @@ package org.eclipse.jpt.core.internal.jdtutility; import org.eclipse.jdt.core.dom.AST; -import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.BooleanLiteral; +import org.eclipse.jdt.core.dom.Expression; /** * Convert a boolean literal to/from a string representation of a boolean * (e.g. "true"). */ public final class BooleanStringExpressionConverter - extends AbstractExpressionConverter + extends AbstractExpressionConverter { - private static ExpressionConverter INSTANCE; + private static ExpressionConverter INSTANCE; /** * Return the singleton. */ - public static ExpressionConverter instance() { + public static ExpressionConverter instance() { if (INSTANCE == null) { INSTANCE = new BooleanStringExpressionConverter(); } @@ -40,16 +40,14 @@ public final class BooleanStringExpressionConverter } @Override - protected BooleanLiteral convert_(String string, AST ast) { + protected BooleanLiteral convertObject(String string, AST ast) { return ast.newBooleanLiteral(Boolean.valueOf(string).booleanValue()); } @Override - protected String convert_(BooleanLiteral booleanLiteral) { - return (booleanLiteral.getNodeType() == ASTNode.BOOLEAN_LITERAL) ? - Boolean.toString(booleanLiteral.booleanValue()) - : - null; + protected String convertExpression(Expression expression) { + Object value = expression.resolveConstantExpressionValue(); + return (value instanceof Boolean) ? ((Boolean) value).toString() : null; } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/CharacterStringExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/CharacterStringExpressionConverter.java index 1fa055d707..dfc2fdcc71 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/CharacterStringExpressionConverter.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/CharacterStringExpressionConverter.java @@ -10,22 +10,22 @@ package org.eclipse.jpt.core.internal.jdtutility; import org.eclipse.jdt.core.dom.AST; -import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.CharacterLiteral; +import org.eclipse.jdt.core.dom.Expression; /** * Convert a character literal to/from a string representation of a character * (e.g. "A"). */ public final class CharacterStringExpressionConverter - extends AbstractExpressionConverter + extends AbstractExpressionConverter { - private static ExpressionConverter INSTANCE; + private static ExpressionConverter INSTANCE; /** * Return the singleton. */ - public static ExpressionConverter instance() { + public static ExpressionConverter instance() { if (INSTANCE == null) { INSTANCE = new CharacterStringExpressionConverter(); } @@ -40,18 +40,16 @@ public final class CharacterStringExpressionConverter } @Override - protected CharacterLiteral convert_(String string, AST ast) { + protected CharacterLiteral convertObject(String string, AST ast) { CharacterLiteral characterLiteral = ast.newCharacterLiteral(); characterLiteral.setCharValue(string.charAt(0)); return characterLiteral; } @Override - protected String convert_(CharacterLiteral characterLiteral) { - return (characterLiteral.getNodeType() == ASTNode.CHARACTER_LITERAL) ? - Character.toString(characterLiteral.charValue()) - : - null; + protected String convertExpression(Expression expression) { + Object value = expression.resolveConstantExpressionValue(); + return (value instanceof Character) ? ((Character) value).toString() : null; } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ConversionDeclarationAnnotationElementAdapter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ConversionDeclarationAnnotationElementAdapter.java index 088fa0cad4..f6cf01060f 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ConversionDeclarationAnnotationElementAdapter.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ConversionDeclarationAnnotationElementAdapter.java @@ -11,78 +11,51 @@ package org.eclipse.jpt.core.internal.jdtutility; import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.Expression; -import org.eclipse.jdt.core.dom.StringLiteral; import org.eclipse.jpt.utility.internal.StringTools; /** * Wrap a declaration annotation element adapter that deals with AST * expressions, converting them to/from various other objects. * T is the type of the object to be passed to and returned by the adapter. - * E is the type of the expression to be converted by the converter. */ -public class ConversionDeclarationAnnotationElementAdapter +public class ConversionDeclarationAnnotationElementAdapter implements DeclarationAnnotationElementAdapter { /** * The wrapped adapter that returns and takes AST expressions. */ - private final DeclarationAnnotationElementAdapter adapter; + private final DeclarationAnnotationElementAdapter adapter; /** * The converter that converts AST expressions to other objects * (e.g. Strings). */ - private final ExpressionConverter converter; + private final ExpressionConverter converter; // ********** constructors ********** - /** - * The default element name is "value"; the default behavior is to - * remove the annotation when the last element is removed; - * the default expression converter expects string literals. - */ - public static ConversionDeclarationAnnotationElementAdapter forStrings(DeclarationAnnotationAdapter annotationAdapter) { - return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, StringExpressionConverter.instance()); - } - /** * The default element name is "value"; the default behavior is to * remove the annotation when the last element is removed. */ - public ConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, ExpressionConverter converter) { - this(new ExpressionDeclarationAnnotationElementAdapter(annotationAdapter), converter); - } - - /** - * The default behavior is to remove the annotation when the last - * element is removed; the default expression converter expects - * string literals. - */ - public static ConversionDeclarationAnnotationElementAdapter forStrings(DeclarationAnnotationAdapter annotationAdapter, String elementName) { - return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, StringExpressionConverter.instance()); + public ConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, ExpressionConverter converter) { + this(new ExpressionDeclarationAnnotationElementAdapter(annotationAdapter), converter); } /** * The default behavior is to remove the annotation when the last * element is removed. */ - public ConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter converter) { - this(new ExpressionDeclarationAnnotationElementAdapter(annotationAdapter, elementName), converter); - } - - /** - * The default expression converter expects string literals. - */ - public static ConversionDeclarationAnnotationElementAdapter forStrings(DeclarationAnnotationAdapter annotationAdapter, String elementName, boolean removeAnnotationWhenEmpty) { - return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, removeAnnotationWhenEmpty, StringExpressionConverter.instance()); + public ConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, ExpressionConverter converter) { + this(new ExpressionDeclarationAnnotationElementAdapter(annotationAdapter, elementName), converter); } - public ConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, boolean removeAnnotationWhenEmpty, ExpressionConverter converter) { - this(new ExpressionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, removeAnnotationWhenEmpty), converter); + public ConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, boolean removeAnnotationWhenEmpty, ExpressionConverter converter) { + this(new ExpressionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, removeAnnotationWhenEmpty), converter); } - public ConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationElementAdapter adapter, ExpressionConverter converter) { + public ConversionDeclarationAnnotationElementAdapter(DeclarationAnnotationElementAdapter adapter, ExpressionConverter converter) { super(); this.adapter = adapter; this.converter = converter; @@ -112,4 +85,107 @@ public class ConversionDeclarationAnnotationElementAdapter forStrings(DeclarationAnnotationAdapter annotationAdapter) { + return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, StringExpressionConverter.instance()); + } + + /** + * The default behavior is to remove the annotation when the last + * element is removed; the default expression converter expects + * string constant expressions. + */ + public static ConversionDeclarationAnnotationElementAdapter forStrings(DeclarationAnnotationAdapter annotationAdapter, String elementName) { + return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, StringExpressionConverter.instance()); + } + + /** + * The default expression converter expects string constant expressions. + */ + public static ConversionDeclarationAnnotationElementAdapter forStrings(DeclarationAnnotationAdapter annotationAdapter, String elementName, boolean removeAnnotationWhenEmpty) { + return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, removeAnnotationWhenEmpty, StringExpressionConverter.instance()); + } + + /** + * The default element name is "value"; the default behavior is to + * remove the annotation when the last element is removed; + * the default expression converter expects number constant expressions. + */ + public static ConversionDeclarationAnnotationElementAdapter forNumbers(DeclarationAnnotationAdapter annotationAdapter) { + return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, NumberStringExpressionConverter.instance()); + } + + /** + * The default behavior is to remove the annotation when the last + * element is removed; the default expression converter expects + * number constant expressions. + */ + public static ConversionDeclarationAnnotationElementAdapter forNumbers(DeclarationAnnotationAdapter annotationAdapter, String elementName) { + return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, NumberStringExpressionConverter.instance()); + } + + /** + * The default expression converter expects number constant expressions. + */ + public static ConversionDeclarationAnnotationElementAdapter forNumbers(DeclarationAnnotationAdapter annotationAdapter, String elementName, boolean removeAnnotationWhenEmpty) { + return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, removeAnnotationWhenEmpty, NumberStringExpressionConverter.instance()); + } + + /** + * The default element name is "value"; the default behavior is to + * remove the annotation when the last element is removed; + * the default expression converter expects boolean constant expressions. + */ + public static ConversionDeclarationAnnotationElementAdapter forBooleans(DeclarationAnnotationAdapter annotationAdapter) { + return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, BooleanStringExpressionConverter.instance()); + } + + /** + * The default behavior is to remove the annotation when the last + * element is removed; the default expression converter expects + * boolean constant expressions. + */ + public static ConversionDeclarationAnnotationElementAdapter forBooleans(DeclarationAnnotationAdapter annotationAdapter, String elementName) { + return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, BooleanStringExpressionConverter.instance()); + } + + /** + * The default expression converter expects boolean constant expressions. + */ + public static ConversionDeclarationAnnotationElementAdapter forBooleans(DeclarationAnnotationAdapter annotationAdapter, String elementName, boolean removeAnnotationWhenEmpty) { + return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, removeAnnotationWhenEmpty, BooleanStringExpressionConverter.instance()); + } + + /** + * The default element name is "value"; the default behavior is to + * remove the annotation when the last element is removed; + * the default expression converter expects character constant expressions. + */ + public static ConversionDeclarationAnnotationElementAdapter forCharacters(DeclarationAnnotationAdapter annotationAdapter) { + return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, CharacterStringExpressionConverter.instance()); + } + + /** + * The default behavior is to remove the annotation when the last + * element is removed; the default expression converter expects + * character constant expressions. + */ + public static ConversionDeclarationAnnotationElementAdapter forCharacters(DeclarationAnnotationAdapter annotationAdapter, String elementName) { + return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, CharacterStringExpressionConverter.instance()); + } + + /** + * The default expression converter expects character constant expressions. + */ + public static ConversionDeclarationAnnotationElementAdapter forCharacters(DeclarationAnnotationAdapter annotationAdapter, String elementName, boolean removeAnnotationWhenEmpty) { + return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, removeAnnotationWhenEmpty, CharacterStringExpressionConverter.instance()); + } + } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/EnumArrayDeclarationAnnotationElementAdapter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/EnumArrayDeclarationAnnotationElementAdapter.java index de08d4ac8e..633088588a 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/EnumArrayDeclarationAnnotationElementAdapter.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/EnumArrayDeclarationAnnotationElementAdapter.java @@ -14,7 +14,6 @@ import java.util.List; import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.ArrayInitializer; import org.eclipse.jdt.core.dom.Expression; -import org.eclipse.jdt.core.dom.Name; /** * Wrap a declaration annotation element adapter and simply @@ -26,7 +25,7 @@ public class EnumArrayDeclarationAnnotationElementAdapter /** * The wrapped adapter that returns and takes name strings (enums). */ - private final ConversionDeclarationAnnotationElementAdapter adapter; + private final ConversionDeclarationAnnotationElementAdapter adapter; private static final String[] EMPTY_STRING_ARRAY = new String[0]; @@ -57,14 +56,14 @@ public class EnumArrayDeclarationAnnotationElementAdapter } public EnumArrayDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, boolean removeAnnotationWhenEmpty, boolean removeArrayInitializerWhenEmpty) { - this(new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, removeAnnotationWhenEmpty, buildExpressionConverter(removeArrayInitializerWhenEmpty))); + this(new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, removeAnnotationWhenEmpty, buildExpressionConverter(removeArrayInitializerWhenEmpty))); } - private static ExpressionConverter buildExpressionConverter(boolean removeArrayInitializerWhenEmpty) { - return new AnnotationStringArrayExpressionConverter(NameStringExpressionConverter.instance(), removeArrayInitializerWhenEmpty); + private static ExpressionConverter buildExpressionConverter(boolean removeArrayInitializerWhenEmpty) { + return new AnnotationStringArrayExpressionConverter(NameStringExpressionConverter.instance(), removeArrayInitializerWhenEmpty); } - protected EnumArrayDeclarationAnnotationElementAdapter(ConversionDeclarationAnnotationElementAdapter adapter) { + protected EnumArrayDeclarationAnnotationElementAdapter(ConversionDeclarationAnnotationElementAdapter adapter) { super(); this.adapter = adapter; } @@ -100,13 +99,13 @@ public class EnumArrayDeclarationAnnotationElementAdapter * or * FOO */ - protected String[] resolve(Expression enumsExpression, ModifiedDeclaration declaration) { - if (enumsExpression == null) { + protected String[] resolve(Expression expression, ModifiedDeclaration declaration) { + if (expression == null) { return EMPTY_STRING_ARRAY; - } else if (enumsExpression.getNodeType() == ASTNode.ARRAY_INITIALIZER) { - return this.resolveArray((ArrayInitializer) enumsExpression, declaration); + } else if (expression.getNodeType() == ASTNode.ARRAY_INITIALIZER) { + return this.resolveArray((ArrayInitializer) expression, declaration); } else { - return this.resolveSingleElement(enumsExpression, declaration); + return this.resolveSingleElement(expression, declaration); } } @@ -115,17 +114,17 @@ public class EnumArrayDeclarationAnnotationElementAdapter int len = expressions.size(); String[] enums = new String[len]; for (int i = len; i-- > 0; ) { - enums[i] = this.resolveEnum(expressions.get(i), declaration); + enums[i] = this.resolveEnum(expressions.get(i)); } return enums; } protected String[] resolveSingleElement(Expression enumExpression, ModifiedDeclaration declaration) { - return new String[] {this.resolveEnum(enumExpression, declaration)}; + return new String[] {this.resolveEnum(enumExpression)}; } - protected String resolveEnum(Expression enumExpression, ModifiedDeclaration declaration) { - return JDTTools.resolveEnum(declaration.iCompilationUnit(), enumExpression); + protected String resolveEnum(Expression expression) { + return JDTTools.resolveEnum(expression); } @SuppressWarnings("unchecked") diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/EnumDeclarationAnnotationElementAdapter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/EnumDeclarationAnnotationElementAdapter.java index 838860f486..2f0c1f704b 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/EnumDeclarationAnnotationElementAdapter.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/EnumDeclarationAnnotationElementAdapter.java @@ -23,7 +23,7 @@ public class EnumDeclarationAnnotationElementAdapter /** * The wrapped adapter that returns and takes name strings (enums). */ - private final ConversionDeclarationAnnotationElementAdapter adapter; + private final ConversionDeclarationAnnotationElementAdapter adapter; // ********** constructors ********** @@ -45,10 +45,10 @@ public class EnumDeclarationAnnotationElementAdapter } public EnumDeclarationAnnotationElementAdapter(DeclarationAnnotationAdapter annotationAdapter, String elementName, boolean removeAnnotationWhenEmpty) { - this(new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, removeAnnotationWhenEmpty, NameStringExpressionConverter.instance())); + this(new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, removeAnnotationWhenEmpty, NameStringExpressionConverter.instance())); } - protected EnumDeclarationAnnotationElementAdapter(ConversionDeclarationAnnotationElementAdapter adapter) { + protected EnumDeclarationAnnotationElementAdapter(ConversionDeclarationAnnotationElementAdapter adapter) { super(); this.adapter = adapter; } @@ -57,7 +57,7 @@ public class EnumDeclarationAnnotationElementAdapter // ********** DeclarationAnnotationElementAdapter implementation ********** public String getValue(ModifiedDeclaration declaration) { - return this.resolve(this.adapter.expression(declaration), declaration); + return this.resolve(this.adapter.expression(declaration)); } public void setValue(String value, ModifiedDeclaration declaration) { @@ -78,8 +78,8 @@ public class EnumDeclarationAnnotationElementAdapter /** * resolve the enum */ - protected String resolve(Expression enumExpression, ModifiedDeclaration declaration) { - return (enumExpression == null) ? null : JDTTools.resolveEnum(declaration.iCompilationUnit(), enumExpression); + protected String resolve(Expression expression) { + return JDTTools.resolveEnum(expression); } /** diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ExpressionConverter.java index 4bce4344d9..fce8284cfa 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ExpressionConverter.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ExpressionConverter.java @@ -15,10 +15,9 @@ import org.eclipse.jdt.core.dom.Expression; /** * Define the protocol for converting an AST expression back and forth * from an arbitrary type (e.g. StringLiteral <=> String). - * E is the expression type. * T is the type of the object to be converted to and from an expression. */ -public interface ExpressionConverter { +public interface ExpressionConverter { /** * Convert the specified object to an @@ -26,12 +25,12 @@ public interface ExpressionConverter { * The type of the object is determined by the * contract specified by the client. */ - E convert(T object, AST ast); + Expression convert(T object, AST ast); /** * Convert the specified expression to an object of some * pre-determined type. */ - T convert(E expression); + T convert(Expression expression); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/JDTTools.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/JDTTools.java index 3491df0858..5c513e62a3 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/JDTTools.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/JDTTools.java @@ -9,84 +9,85 @@ ******************************************************************************/ package org.eclipse.jpt.core.internal.jdtutility; -import org.eclipse.jdt.core.Flags; import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IImportDeclaration; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.Signature; -import org.eclipse.jdt.core.compiler.CategorizedProblem; import org.eclipse.jdt.core.dom.AST; +import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.ASTParser; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.dom.Expression; -import org.eclipse.jdt.internal.codeassist.ISelectionRequestor; -import org.eclipse.jdt.internal.codeassist.SelectionEngine; -import org.eclipse.jdt.internal.core.DefaultWorkingCopyOwner; -import org.eclipse.jdt.internal.core.JavaProject; -import org.eclipse.jdt.internal.core.SearchableEnvironment; +import org.eclipse.jdt.core.dom.IBinding; +import org.eclipse.jdt.core.dom.IVariableBinding; +import org.eclipse.jdt.core.dom.Name; import org.eclipse.jpt.core.internal.JptCorePlugin; public class JDTTools { + // TODO get rid of the "lightweight" methods after reworking how + // ValidationMessages determine line numbers /** - * add a "normal" import, as opposed to a "static" import + * Build an AST for the specified member's compilation unit or + * (source-attached) class file. Build the AST without its bindings + * resolved. */ - public static IImportDeclaration addImport(ICompilationUnit compilationUnit, String importElement) { - return addImport(compilationUnit, importElement, Flags.AccDefault); + public static CompilationUnit buildLightweightASTRoot(IMember member) { + return buildASTRoot(member, false); } /** - * this doesn't work yet... see eclipse bugzilla 143684 + * Build an AST for the specified member's compilation unit or + * (source-attached) class file. Build the AST with its bindings + * resolved (and the resultant performance hit). */ - public static IImportDeclaration addStaticImport(ICompilationUnit compilationUnit, String importElement) { - return addImport(compilationUnit, importElement, Flags.AccStatic); - } - - public static IImportDeclaration addImport(ICompilationUnit compilationUnit, String importElement, int flags) { - try { - return compilationUnit.createImport(importElement, null, flags, null); // null = place at end of import list; null = no progress monitor - } catch (JavaModelException ex) { - throw new RuntimeException(ex); - } + public static CompilationUnit buildASTRoot(IMember member) { + return buildASTRoot(member, true); } /** - * Build an AST for the specified member's compilation unit or class file. + * Build an AST for the specified member's compilation unit or + * (source-attached) class file. */ - public static CompilationUnit createASTRoot(IMember member) { + private static CompilationUnit buildASTRoot(IMember member, boolean resolveBindings) { return (member.isBinary()) ? - createASTRoot(member.getClassFile()) // the class file must have a source attachment + buildASTRoot(member.getClassFile(), resolveBindings) // the class file must have a source attachment : - createASTRoot(member.getCompilationUnit()); + buildASTRoot(member.getCompilationUnit(), resolveBindings); } - public static CompilationUnit createASTRoot(IClassFile classFile) { + public static CompilationUnit buildASTRoot(IClassFile classFile) { + return buildASTRoot(classFile, true); + } + + private static CompilationUnit buildASTRoot(IClassFile classFile, boolean resolveBindings) { ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setSource(classFile); + parser.setResolveBindings(resolveBindings); return (CompilationUnit) parser.createAST(null); - } - public static CompilationUnit createASTRoot(ICompilationUnit compilationUnit) { + public static CompilationUnit buildASTRoot(ICompilationUnit compilationUnit) { + return buildASTRoot(compilationUnit, true); + } + + private static CompilationUnit buildASTRoot(ICompilationUnit compilationUnit, boolean resolveBindings) { ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setSource(compilationUnit); + parser.setResolveBindings(resolveBindings); return (CompilationUnit) parser.createAST(null); } public static IType findType(String packageName, String qualifiedTypeName, IJavaProject javaProject) { try { - if (javaProject != null) { - return javaProject.findType(packageName, qualifiedTypeName.replace('$', '.')); - } - } - catch (JavaModelException jme) { - JptCorePlugin.log(jme); + return javaProject.findType(packageName, qualifiedTypeName.replace('$', '.')); + } catch (JavaModelException ex) { + JptCorePlugin.log(ex); + return null; } - return null; } /** @@ -117,7 +118,7 @@ public class JDTTools { } /** - * Resolve the specified type name in the scope of the specified jdt type. + * Resolve the specified type name in the scope of the specified JDT type. * Return the fully-qualified type name or return null if it cannot be * resolved unambiguously. */ @@ -149,71 +150,29 @@ public class JDTTools { return Signature.getTypeSignatureKind(signature) == Signature.BASE_TYPE_SIGNATURE; } - public static String resolveEnum(ICompilationUnit sourceUnit, Expression enumExpression) { - return resolveEnum(sourceUnit, enumExpression.getStartPosition(), enumExpression.getStartPosition() + enumExpression.getLength() - 1); - } - - public static String resolveEnum(ICompilationUnit sourceUnit, int enumSourceStart, int enumSourceEnd) { - try { - return resolveEnum_(sourceUnit, enumSourceStart, enumSourceEnd); - } catch (JavaModelException ex) { - throw new RuntimeException(ex); + public static String resolveEnum(Expression expression) { + if (expression == null) { + return null; + } + switch (expression.getNodeType()) { + case ASTNode.QUALIFIED_NAME: + case ASTNode.SIMPLE_NAME: + return resolveEnum((Name) expression); + default: + return null; } } - private static String resolveEnum_(ICompilationUnit sourceUnit, int enumSourceStart, int enumSourceEnd) throws JavaModelException { - String[][] resolvedEnums = resolveField_((org.eclipse.jdt.internal.core.CompilationUnit) sourceUnit, enumSourceStart, enumSourceEnd); - // if more than one resolved enum is returned, the enum name is ambiguous - if (resolvedEnums == null) { - return null; + public static String resolveEnum(Name enumExpression) { + IBinding binding = enumExpression.resolveBinding(); + if (binding == null) { + return null; // TODO figure why this is null sometimes } - if (resolvedEnums.length > 1) { + if (binding.getKind() != IBinding.VARIABLE) { return null; } - return resolvedEnums[0][0] + "." + resolvedEnums[0][1] + "." + resolvedEnums[0][2]; + IVariableBinding variableBinding = (IVariableBinding) binding; + return variableBinding.getType().getQualifiedName() + "." + variableBinding.getName(); } - // code lifted from SourceType.resolveType(String, WorkingCopyOwner) - private static String[][] resolveField_(org.eclipse.jdt.internal.core.CompilationUnit sourceUnit, int selectionSourceStart, int selectionSourceEnd) throws JavaModelException { - class TypeResolveRequestor implements ISelectionRequestor { - String[][] answers = null; - public void acceptType(char[] packageName, char[] tName, int modifiers, boolean isDeclaration, char[] uniqueKey, int start, int end) { - // ignore - } - public void acceptError(CategorizedProblem error) { - // ignore - } - public void acceptField(char[] declaringTypePackageName, char[] declaringTypeName, char[] fieldName, boolean isDeclaration, char[] uniqueKey, int start, int end) { - String[] answer = new String[] {new String(declaringTypePackageName), new String(declaringTypeName), new String(fieldName) }; - if (this.answers == null) { - this.answers = new String[][]{ answer }; - } else { - int len = this.answers.length; - System.arraycopy(this.answers, 0, this.answers = new String[len+1][], 0, len); - this.answers[len] = answer; - } - } - public void acceptMethod(char[] declaringTypePackageName, char[] declaringTypeName, String enclosingDeclaringTypeSignature, char[] selector, char[][] parameterPackageNames, char[][] parameterTypeNames, String[] parameterSignatures, char[][] typeParameterNames, char[][][] typeParameterBoundNames, boolean isConstructor, boolean isDeclaration, char[] uniqueKey, int start, int end) { - // ignore - } - public void acceptPackage(char[] packageName){ - // ignore - } - public void acceptTypeParameter(char[] declaringTypePackageName, char[] declaringTypeName, char[] typeParameterName, boolean isDeclaration, int start, int end) { - // ignore - } - public void acceptMethodTypeParameter(char[] declaringTypePackageName, char[] declaringTypeName, char[] selector, int selectorStart, int selcetorEnd, char[] typeParameterName, boolean isDeclaration, int start, int end) { - // ignore - } - - } - TypeResolveRequestor requestor = new TypeResolveRequestor(); - JavaProject project = (JavaProject) sourceUnit.getJavaProject(); - SearchableEnvironment environment = project.newSearchableNameEnvironment(DefaultWorkingCopyOwner.PRIMARY); - - SelectionEngine engine = new SelectionEngine(environment, requestor, project.getOptions(true)); - - engine.select(sourceUnit, selectionSourceStart, selectionSourceEnd); - return requestor.answers; - } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/Member.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/Member.java index e76927bb9a..b7eb3bf5df 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/Member.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/Member.java @@ -88,7 +88,14 @@ public abstract class Member { * note: this creates a *new* AST */ public CompilationUnit astRoot() { - return JDTTools.createASTRoot(this.jdtMember); + return JDTTools.buildASTRoot(this.jdtMember); + } + + /** + * note: this creates a *new* AST + */ + private CompilationUnit lightweightASTRoot() { + return JDTTools.buildLightweightASTRoot(this.jdtMember); } public ModifiedDeclaration modifiedDeclaration() { @@ -104,7 +111,7 @@ public abstract class Member { } public ITextRange textRange() { - return this.textRange(this.astRoot()); + return this.textRange(this.lightweightASTRoot()); } public ITextRange textRange(CompilationUnit astRoot) { @@ -116,27 +123,27 @@ public abstract class Member { } public ITextRange nameTextRange() { - return this.nameTextRange(this.astRoot()); + return this.nameTextRange(this.lightweightASTRoot()); } public ITextRange nameTextRange(CompilationUnit astRoot) { ISourceRange sourceRange = this.nameSourceRange(); - return + return new SimpleTextRange( sourceRange.getOffset(), sourceRange.getLength(), - astRoot.getLineNumber(sourceRange.getOffset())); + astRoot.getLineNumber(sourceRange.getOffset()) + ); } private ISourceRange nameSourceRange() { try { - return getJdtMember().getNameRange(); - } - catch (JavaModelException ex) { + return this.jdtMember.getNameRange(); + } catch (JavaModelException ex) { throw new RuntimeException(ex); } } - + /** * this will throw a NPE for a top-level type */ diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ModifiedDeclaration.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ModifiedDeclaration.java index 18c85208fe..9af69a287f 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ModifiedDeclaration.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/ModifiedDeclaration.java @@ -20,6 +20,7 @@ import org.eclipse.jdt.core.dom.Annotation; import org.eclipse.jdt.core.dom.BodyDeclaration; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.core.dom.IExtendedModifier; +import org.eclipse.jdt.core.dom.ITypeBinding; import org.eclipse.jdt.core.dom.ImportDeclaration; import org.eclipse.jdt.core.dom.SingleVariableDeclaration; import org.eclipse.jdt.core.dom.VariableDeclarationExpression; @@ -71,7 +72,7 @@ public class ModifiedDeclaration { * Return the "declaration" AST node. */ public ASTNode getDeclaration() { - return this.adapter.getDeclaration(); + return this.adapter.declaration(); } /** @@ -277,19 +278,30 @@ public class ModifiedDeclaration { } private String qualifiedName(Annotation annotation) { - String name = annotation.getTypeName().getFullyQualifiedName(); - if (name.indexOf('.') != -1) { - return name; // name is already qualified - } - String resolvedName = JDTTools.resolve(name, this.type()); - if (resolvedName != null) { - return resolvedName; + ITypeBinding typeBinding = annotation.resolveTypeBinding(); + if (typeBinding != null) { + String resolvedName = typeBinding.getQualifiedName(); + if (resolvedName != null) { + return resolvedName; + } } // hack(?): check for a matching import because when moving a stand-alone // annotation to its container in CombinationIndexedDeclarationAnnotationAdapter // the container's import is added but then it won't "resolve" upon // subsequent lookups... :-( - return this.importFor(name); // look for a matching import + return this.importFor(annotation.getTypeName().getFullyQualifiedName()); // look for a matching import + + // OLD METHOD SOURCE: +// String name = annotation.getTypeName().getFullyQualifiedName(); +// if (name.indexOf('.') != -1) { +// return name; // name is already qualified +// } +// String resolvedName = JDTTools.resolve(name, this.type()); +// // hack(?): check for a matching import because when moving a stand-alone +// // annotation to its container in CombinationIndexedDeclarationAnnotationAdapter +// // the container's import is added but then it won't "resolve" upon +// // subsequent lookups... :-( +// return this.importFor(name); // look for a matching import } /** @@ -353,7 +365,7 @@ public class ModifiedDeclaration { /** * Return the adapted "declaration". */ - ASTNode getDeclaration(); + ASTNode declaration(); /** * Return the "declaration"'s list of modifiers. @@ -369,7 +381,7 @@ public class ModifiedDeclaration { super(); this.declaration = declaration; } - public ASTNode getDeclaration() { + public ASTNode declaration() { return this.declaration; } @SuppressWarnings("unchecked") @@ -388,7 +400,7 @@ public class ModifiedDeclaration { super(); this.declaration = declaration; } - public ASTNode getDeclaration() { + public ASTNode declaration() { return this.declaration; } @SuppressWarnings("unchecked") @@ -407,7 +419,7 @@ public class ModifiedDeclaration { super(); this.declaration = declaration; } - public ASTNode getDeclaration() { + public ASTNode declaration() { return this.declaration; } @SuppressWarnings("unchecked") @@ -426,7 +438,7 @@ public class ModifiedDeclaration { super(); this.declaration = declaration; } - public ASTNode getDeclaration() { + public ASTNode declaration() { return this.declaration; } @SuppressWarnings("unchecked") diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NameStringExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NameStringExpressionConverter.java index 078835e845..0aaa703172 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NameStringExpressionConverter.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NameStringExpressionConverter.java @@ -11,6 +11,7 @@ package org.eclipse.jpt.core.internal.jdtutility; import org.eclipse.jdt.core.dom.AST; import org.eclipse.jdt.core.dom.ASTNode; +import org.eclipse.jdt.core.dom.Expression; import org.eclipse.jdt.core.dom.Name; /** @@ -18,14 +19,14 @@ import org.eclipse.jdt.core.dom.Name; * (e.g. "com.xxx.Foo.VALUE1" or "value"). */ public final class NameStringExpressionConverter - extends AbstractExpressionConverter + extends AbstractExpressionConverter { - private static ExpressionConverter INSTANCE; + private static ExpressionConverter INSTANCE; /** * Return the singleton. */ - public static ExpressionConverter instance() { + public static ExpressionConverter instance() { if (INSTANCE == null) { INSTANCE = new NameStringExpressionConverter(); } @@ -40,16 +41,16 @@ public final class NameStringExpressionConverter } @Override - protected Name convert_(String string, AST ast) { + protected Name convertObject(String string, AST ast) { return ast.newName(string); } @Override - protected String convert_(Name name) { - switch (name.getNodeType()) { + protected String convertExpression(Expression expression) { + switch (expression.getNodeType()) { case ASTNode.QUALIFIED_NAME: case ASTNode.SIMPLE_NAME: - return name.getFullyQualifiedName(); + return ((Name) expression).getFullyQualifiedName(); default: return null; } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NullExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NullExpressionConverter.java index e58f3af09b..b45c0ce64c 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NullExpressionConverter.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NullExpressionConverter.java @@ -17,16 +17,16 @@ import org.eclipse.jpt.utility.internal.StringTools; * No conversion. */ public final class NullExpressionConverter - implements ExpressionConverter + implements ExpressionConverter { // singleton - private static ExpressionConverter INSTANCE = new NullExpressionConverter(); + private static ExpressionConverter INSTANCE = new NullExpressionConverter(); /** * Return the singleton. */ - public static ExpressionConverter instance() { + public static ExpressionConverter instance() { if (INSTANCE == null) { INSTANCE = new NullExpressionConverter(); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NumberStringExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NumberStringExpressionConverter.java index 0b312fb720..ead2da9168 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NumberStringExpressionConverter.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/NumberStringExpressionConverter.java @@ -10,7 +10,7 @@ package org.eclipse.jpt.core.internal.jdtutility; import org.eclipse.jdt.core.dom.AST; -import org.eclipse.jdt.core.dom.ASTNode; +import org.eclipse.jdt.core.dom.Expression; import org.eclipse.jdt.core.dom.NumberLiteral; /** @@ -18,14 +18,14 @@ import org.eclipse.jdt.core.dom.NumberLiteral; * (e.g. "48"). */ public final class NumberStringExpressionConverter - extends AbstractExpressionConverter + extends AbstractExpressionConverter { - private static ExpressionConverter INSTANCE; + private static ExpressionConverter INSTANCE; /** * Return the singleton. */ - public static ExpressionConverter instance() { + public static ExpressionConverter instance() { if (INSTANCE == null) { INSTANCE = new NumberStringExpressionConverter(); } @@ -40,16 +40,14 @@ public final class NumberStringExpressionConverter } @Override - protected NumberLiteral convert_(String string, AST ast) { + protected NumberLiteral convertObject(String string, AST ast) { return ast.newNumberLiteral(string); } @Override - protected String convert_(NumberLiteral numberLiteral) { - return (numberLiteral.getNodeType() == ASTNode.NUMBER_LITERAL) ? - numberLiteral.getToken() - : - null; + protected String convertExpression(Expression expression) { + Object value = expression.resolveConstantExpressionValue(); + return (value instanceof Number) ? ((Number) value).toString() : null; } } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/PrimitiveTypeStringExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/PrimitiveTypeStringExpressionConverter.java index 49f6d99166..910d735492 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/PrimitiveTypeStringExpressionConverter.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/PrimitiveTypeStringExpressionConverter.java @@ -11,6 +11,7 @@ package org.eclipse.jpt.core.internal.jdtutility; import org.eclipse.jdt.core.dom.AST; import org.eclipse.jdt.core.dom.ASTNode; +import org.eclipse.jdt.core.dom.Expression; import org.eclipse.jdt.core.dom.PrimitiveType; import org.eclipse.jdt.core.dom.TypeLiteral; @@ -19,14 +20,14 @@ import org.eclipse.jdt.core.dom.TypeLiteral; * (e.g. "int"). */ public final class PrimitiveTypeStringExpressionConverter - extends AbstractExpressionConverter + extends AbstractExpressionConverter { - private static ExpressionConverter INSTANCE; + private static ExpressionConverter INSTANCE; /** * Return the singleton. */ - public static ExpressionConverter instance() { + public static ExpressionConverter instance() { if (INSTANCE == null) { INSTANCE = new PrimitiveTypeStringExpressionConverter(); } @@ -41,7 +42,7 @@ public final class PrimitiveTypeStringExpressionConverter } @Override - protected TypeLiteral convert_(String string, AST ast) { + protected TypeLiteral convertObject(String string, AST ast) { org.eclipse.jdt.core.dom.Type type = ast.newPrimitiveType(PrimitiveType.toCode(string)); TypeLiteral typeLiteral = ast.newTypeLiteral(); typeLiteral.setType(type); @@ -49,9 +50,9 @@ public final class PrimitiveTypeStringExpressionConverter } @Override - protected String convert_(TypeLiteral typeLiteral) { - if (typeLiteral.getNodeType() == ASTNode.TYPE_LITERAL) { - org.eclipse.jdt.core.dom.Type type = typeLiteral.getType(); + protected String convertExpression(Expression expression) { + if (expression.getNodeType() == ASTNode.TYPE_LITERAL) { + org.eclipse.jdt.core.dom.Type type = ((TypeLiteral) expression).getType(); if (type.getNodeType() == ASTNode.PRIMITIVE_TYPE) { return ((PrimitiveType) type).getPrimitiveTypeCode().toString(); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/SimpleTypeStringExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/SimpleTypeStringExpressionConverter.java index 43566cb864..e596a33a94 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/SimpleTypeStringExpressionConverter.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/SimpleTypeStringExpressionConverter.java @@ -11,6 +11,7 @@ package org.eclipse.jpt.core.internal.jdtutility; import org.eclipse.jdt.core.dom.AST; import org.eclipse.jdt.core.dom.ASTNode; +import org.eclipse.jdt.core.dom.Expression; import org.eclipse.jdt.core.dom.Name; import org.eclipse.jdt.core.dom.SimpleType; import org.eclipse.jdt.core.dom.TypeLiteral; @@ -20,14 +21,14 @@ import org.eclipse.jdt.core.dom.TypeLiteral; * (e.g. "java.lang.Object"). */ public final class SimpleTypeStringExpressionConverter - extends AbstractExpressionConverter + extends AbstractExpressionConverter { - private static ExpressionConverter INSTANCE; + private static ExpressionConverter INSTANCE; /** * Return the singleton. */ - public static ExpressionConverter instance() { + public static ExpressionConverter instance() { if (INSTANCE == null) { INSTANCE = new SimpleTypeStringExpressionConverter(); } @@ -42,7 +43,7 @@ public final class SimpleTypeStringExpressionConverter } @Override - protected TypeLiteral convert_(String string, AST ast) { + protected TypeLiteral convertObject(String string, AST ast) { Name name = ast.newName(string); org.eclipse.jdt.core.dom.Type type = ast.newSimpleType(name); TypeLiteral typeLiteral = ast.newTypeLiteral(); @@ -51,9 +52,9 @@ public final class SimpleTypeStringExpressionConverter } @Override - protected String convert_(TypeLiteral typeLiteral) { - if (typeLiteral.getNodeType() == ASTNode.TYPE_LITERAL) { - org.eclipse.jdt.core.dom.Type type = typeLiteral.getType(); + protected String convertExpression(Expression expression) { + if (expression.getNodeType() == ASTNode.TYPE_LITERAL) { + org.eclipse.jdt.core.dom.Type type = ((TypeLiteral) expression).getType(); if (type.getNodeType() == ASTNode.SIMPLE_TYPE) { return ((SimpleType) type).getName().getFullyQualifiedName(); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/StringArrayExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/StringArrayExpressionConverter.java index 02d081ab7b..31d61abcf6 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/StringArrayExpressionConverter.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/StringArrayExpressionConverter.java @@ -10,23 +10,28 @@ package org.eclipse.jpt.core.internal.jdtutility; import java.util.List; + import org.eclipse.jdt.core.dom.AST; +import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.ArrayInitializer; import org.eclipse.jdt.core.dom.Expression; /** * Convert an array initializer to/from an array of strings (e.g. {"text0", "text1"}). - * E is the type of the expressions to be found in the array initializer. * * Do NOT use this class for converting array initializers in annotation elements. * Java5 has a bit of syntactic sugar that allows a single-element array - * initializer to not have curly braces. This converter will barf if it encounters + * initializer to not have curly braces. This converter will return null if it encounters * anything other than an array initializer. + * + * Invalid entries in the array initializer will result in null elements in the + * resulting string array. This allows clients to manipulate elements at + * the appropriate index. */ -public class StringArrayExpressionConverter - extends AbstractExpressionConverter +public class StringArrayExpressionConverter + extends AbstractExpressionConverter { - private final ExpressionConverter elementConverter; + private final ExpressionConverter elementConverter; private final boolean removeArrayInitializerWhenEmpty; private static final String[] EMPTY_STRING_ARRAY = new String[0]; @@ -35,11 +40,11 @@ public class StringArrayExpressionConverter /** * The default behavior is to remove the array initializer if it is empty. */ - public StringArrayExpressionConverter(ExpressionConverter elementConverter) { + public StringArrayExpressionConverter(ExpressionConverter elementConverter) { this(elementConverter, true); } - public StringArrayExpressionConverter(ExpressionConverter elementConverter, boolean removeArrayInitializerWhenEmpty) { + public StringArrayExpressionConverter(ExpressionConverter elementConverter, boolean removeArrayInitializerWhenEmpty) { super(); this.elementConverter = elementConverter; this.removeArrayInitializerWhenEmpty = removeArrayInitializerWhenEmpty; @@ -50,7 +55,7 @@ public class StringArrayExpressionConverter * this method is 'public' so it can be called by * AnnotationStringArrayExpressionConverter */ - public ArrayInitializer convert_(String[] strings, AST ast) { + public ArrayInitializer convertObject(String[] strings, AST ast) { if ((strings.length == 0) && this.removeArrayInitializerWhenEmpty) { return null; } @@ -67,21 +72,29 @@ public class StringArrayExpressionConverter return arrayInitializer.expressions(); } - @Override /* * this method is 'public' so it can be called by * AnnotationStringArrayExpressionConverter */ + @Override public String[] convertNull() { return EMPTY_STRING_ARRAY; } @Override + protected String[] convertExpression(Expression expression) { + return (expression.getNodeType() == ASTNode.ARRAY_INITIALIZER) ? + this.convertArrayInitializer((ArrayInitializer) expression) + : + EMPTY_STRING_ARRAY; + } + /* - * 'public' in support of AnnotationStringArrayExpressionConverter + * this method is 'public' so it can be called by + * AnnotationStringArrayExpressionConverter */ - public String[] convert_(ArrayInitializer arrayInitializer) { - List expressions = this.downcastExpressions(arrayInitializer); + public String[] convertArrayInitializer(ArrayInitializer arrayInitializer) { + List expressions = this.downcastExpressions(arrayInitializer); int len = expressions.size(); String[] strings = new String[len]; for (int i = len; i-- > 0; ) { @@ -91,7 +104,7 @@ public class StringArrayExpressionConverter } @SuppressWarnings("unchecked") - private List downcastExpressions(ArrayInitializer arrayInitializer) { + private List downcastExpressions(ArrayInitializer arrayInitializer) { return arrayInitializer.expressions(); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/StringExpressionConverter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/StringExpressionConverter.java index 444650f53e..9560ca286f 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/StringExpressionConverter.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/StringExpressionConverter.java @@ -10,21 +10,21 @@ package org.eclipse.jpt.core.internal.jdtutility; import org.eclipse.jdt.core.dom.AST; -import org.eclipse.jdt.core.dom.ASTNode; +import org.eclipse.jdt.core.dom.Expression; import org.eclipse.jdt.core.dom.StringLiteral; /** * Convert a string literal to/from a string (e.g. "text"). */ public final class StringExpressionConverter - extends AbstractExpressionConverter + extends AbstractExpressionConverter { - private static ExpressionConverter INSTANCE; + private static ExpressionConverter INSTANCE; /** * Return the singleton. */ - public static ExpressionConverter instance() { + public static ExpressionConverter instance() { if (INSTANCE == null) { INSTANCE = new StringExpressionConverter(); } @@ -39,18 +39,16 @@ public final class StringExpressionConverter } @Override - protected StringLiteral convert_(String string, AST ast) { + protected StringLiteral convertObject(String string, AST ast) { StringLiteral stringLiteral = ast.newStringLiteral(); stringLiteral.setLiteralValue(string); return stringLiteral; } @Override - protected String convert_(StringLiteral stringLiteral) { - return (stringLiteral.getNodeType() == ASTNode.STRING_LITERAL) ? - stringLiteral.getLiteralValue() - : - null; + protected String convertExpression(Expression expression) { + Object value = expression.resolveConstantExpressionValue(); + return (value instanceof String) ? (String) value : null; } } 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 index 5176595367..1e22611a3b 100644 --- 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 @@ -10,6 +10,7 @@ package org.eclipse.jpt.core.tests.internal.jdtutility; import org.eclipse.jdt.core.Signature; +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; @@ -118,7 +119,7 @@ public class JDTToolsTests extends AnnotationTestCase { DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo"); FieldAttribute field = this.idField(); - String actual = JDTTools.resolveEnum(this.jdtType().getCompilationUnit(), field.annotationElementExpression(daea)); + String actual = JDTTools.resolveEnum((Name) field.annotationElementExpression(daea)); assertEquals("enums.TestEnum.BAZ", actual); } @@ -131,7 +132,7 @@ public class JDTToolsTests extends AnnotationTestCase { DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo"); FieldAttribute field = this.idField(); - String actual = JDTTools.resolveEnum(this.jdtType().getCompilationUnit(), field.annotationElementExpression(daea)); + String actual = JDTTools.resolveEnum((Name) field.annotationElementExpression(daea)); assertEquals("enums.TestEnum.BAZ", actual); } @@ -144,7 +145,7 @@ public class JDTToolsTests extends AnnotationTestCase { DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo"); FieldAttribute field = this.idField(); - String actual = JDTTools.resolveEnum(this.jdtType().getCompilationUnit(), field.annotationElementExpression(daea)); + String actual = JDTTools.resolveEnum((Name) field.annotationElementExpression(daea)); assertEquals("enums.TestEnum.BAZ", actual); } @@ -157,7 +158,7 @@ public class JDTToolsTests extends AnnotationTestCase { DeclarationAnnotationElementAdapter daea = ConversionDeclarationAnnotationElementAdapter.forStrings(daa, "foo"); FieldAttribute field = this.idField(); - String actual = JDTTools.resolveEnum(this.jdtType().getCompilationUnit(), field.annotationElementExpression(daea)); + 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/MemberAnnotationElementAdapterTests.java b/jpa/tests/org.eclipse.jpt.core.tests/src/org/eclipse/jpt/core/tests/internal/jdtutility/MemberAnnotationElementAdapterTests.java index 9f16dc1086..b07c31488a 100644 --- 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 @@ -11,12 +11,6 @@ package org.eclipse.jpt.core.tests.internal.jdtutility; import java.util.Arrays; -import org.eclipse.jdt.core.dom.BooleanLiteral; -import org.eclipse.jdt.core.dom.CharacterLiteral; -import org.eclipse.jdt.core.dom.Expression; -import org.eclipse.jdt.core.dom.NumberLiteral; -import org.eclipse.jdt.core.dom.StringLiteral; -import org.eclipse.jdt.core.dom.TypeLiteral; import org.eclipse.jpt.core.internal.ITextRange; import org.eclipse.jpt.core.internal.jdtutility.ASTNodeTextRange; import org.eclipse.jpt.core.internal.jdtutility.AnnotationElementAdapter; @@ -65,7 +59,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { 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()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", NumberStringExpressionConverter.instance()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); assertEquals("48", aea.getValue()); } @@ -74,7 +68,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { 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()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", CharacterStringExpressionConverter.instance()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); assertEquals("c", aea.getValue()); } @@ -83,7 +77,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { 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()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", BooleanStringExpressionConverter.instance()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); assertEquals("false", aea.getValue()); } @@ -96,7 +90,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { 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()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa3, "fred", BooleanStringExpressionConverter.instance()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); assertEquals("false", aea.getValue()); } @@ -105,7 +99,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { this.createAnnotationAndMembers("Foo", "boolean value();"); this.createTestType("@annot.Foo(false)"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, BooleanStringExpressionConverter.instance()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, BooleanStringExpressionConverter.instance()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); assertEquals("false", aea.getValue()); } @@ -141,6 +135,197 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { 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\""; @@ -168,7 +353,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { 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()); + 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()); @@ -239,7 +424,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { 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()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa3, "fred", BooleanStringExpressionConverter.instance()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); aea.setValue(null); @@ -258,7 +443,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { 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()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa3, "fred", BooleanStringExpressionConverter.instance()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); aea.setValue(null); @@ -287,7 +472,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { 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()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa3, "fred", BooleanStringExpressionConverter.instance()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); aea.setValue("true"); @@ -303,7 +488,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { 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()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa3, "fred", BooleanStringExpressionConverter.instance()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); aea.setValue("true"); @@ -375,7 +560,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { 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()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa3, "fred", NumberStringExpressionConverter.instance()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); assertEquals("2", aea.getValue()); @@ -414,7 +599,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { 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()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", SimpleTypeStringExpressionConverter.instance()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); assertEquals("java.lang.Object", aea.getValue()); } @@ -423,7 +608,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { this.createAnnotationAndMembers("Foo", "Class bar();"); this.createTestType(); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", SimpleTypeStringExpressionConverter.instance()); + 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)"); @@ -433,7 +618,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { 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()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", SimpleTypeStringExpressionConverter.instance()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); assertNull(aea.getValue()); } @@ -442,7 +627,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { 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()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", SimpleTypeStringExpressionConverter.instance()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); assertEquals("java.util.Map.Entry", aea.getValue()); } @@ -451,7 +636,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { 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()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", PrimitiveTypeStringExpressionConverter.instance()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); assertEquals("int", aea.getValue()); } @@ -460,7 +645,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { this.createAnnotationAndMembers("Foo", "Class bar();"); this.createTestType(); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", PrimitiveTypeStringExpressionConverter.instance()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", PrimitiveTypeStringExpressionConverter.instance()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); aea.setValue("int"); this.assertSourceContains("@Foo(bar=int.class)"); @@ -470,7 +655,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { 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()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", PrimitiveTypeStringExpressionConverter.instance()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); assertNull(aea.getValue()); } @@ -479,7 +664,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { 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()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", PrimitiveTypeStringExpressionConverter.instance()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); assertEquals("void", aea.getValue()); } @@ -555,7 +740,16 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { 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.forStringLiterals()); + 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())); } @@ -564,7 +758,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { this.createAnnotationAndMembers("Foo", "String[] bar();"); this.createTestType("@annot.Foo(bar={})"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStringLiterals()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); assertTrue(Arrays.equals(new String[0], aea.getValue())); } @@ -573,7 +767,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { this.createAnnotationAndMembers("Foo", "String[] bar();"); this.createTestType("@annot.Foo(bar=\"string0\")"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStringLiterals()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); assertTrue(Arrays.equals(new String[] {"string0"}, aea.getValue())); } @@ -582,7 +776,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { this.createAnnotationAndMembers("Foo", "String[] bar();"); this.createTestType("@annot.Foo()"); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStringLiterals()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); assertTrue(Arrays.equals(new String[0], aea.getValue())); } @@ -593,7 +787,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { this.createTestType(); this.assertSourceDoesNotContain(annotation); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStringLiterals()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); aea.setValue(new String[] {"string0", "string1"}); this.assertSourceContains(annotation); @@ -605,7 +799,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { this.createTestType(); this.assertSourceDoesNotContain(annotation); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStringLiterals()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); aea.setValue(new String[0]); this.assertSourceDoesNotContain(annotation); @@ -617,8 +811,8 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { 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); + 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); @@ -630,7 +824,7 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { this.createTestType(); this.assertSourceDoesNotContain(annotation); DeclarationAnnotationAdapter daa = new SimpleDeclarationAnnotationAdapter("annot.Foo"); - DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStringLiterals()); + DeclarationAnnotationElementAdapter daea = new ConversionDeclarationAnnotationElementAdapter(daa, "bar", AnnotationStringArrayExpressionConverter.forStrings()); AnnotationElementAdapter aea = new MemberAnnotationElementAdapter(this.idField(), daea); aea.setValue(new String[] {"string0"}); this.assertSourceContains(annotation); @@ -646,6 +840,16 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { 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();"); @@ -666,6 +870,16 @@ public class MemberAnnotationElementAdapterTests extends AnnotationTestCase { 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();"); -- cgit v1.2.3 From 319ecc9f60e86a8d53ae42606f26189d9479399a Mon Sep 17 00:00:00 2001 From: kmoore Date: Tue, 21 Aug 2007 17:25:07 +0000 Subject: 200679 - added IColumn defaultLength, defaultPrecision, defaultScale --- .../src/org/eclipse/jpt/core/internal/JpaProject.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java index 6276876487..73c056447c 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java @@ -191,10 +191,7 @@ public class JpaProject extends JpaEObject implements IJpaProject @Override protected IStatus run(IProgressMonitor monitor) { IContext contextHierarchy = getPlatform().buildProjectContext(); - long start = System.currentTimeMillis(); getPlatform().resynch(contextHierarchy); - long end = System.currentTimeMillis(); - System.out.println((end - start) + " ms - resynch"); return Status.OK_STATUS; } }; @@ -504,7 +501,6 @@ public class JpaProject extends JpaEObject implements IJpaProject if (filled) { return; } - long start = System.currentTimeMillis(); IResourceProxyVisitor visitor = new IResourceProxyVisitor() { public boolean visit(IResourceProxy resource) throws CoreException { switch (resource.getType()) { @@ -522,8 +518,6 @@ public class JpaProject extends JpaEObject implements IJpaProject } }; getProject().accept(visitor, IResource.NONE); - long end = System.currentTimeMillis(); - System.out.println(end - start + " ms - fill"); filled = true; resynch(); } -- cgit v1.2.3 From bbe27640fdb0718b6db6016ce12db55e92fe1132 Mon Sep 17 00:00:00 2001 From: kmoore Date: Tue, 21 Aug 2007 17:29:17 +0000 Subject: 200679 - defaultLength, defaultScale, defaultPrecision added to IColumn in an effort to improve performance --- jpa/plugins/org.eclipse.jpt.core/model/core.ecore | 17 +- .../org.eclipse.jpt.core/model/coreModels.genmodel | 6 + .../org/eclipse/jpt/core/internal/JpaProject.java | 15 +- .../internal/content/java/mappings/JavaColumn.java | 240 ++++++++++++------- .../content/java/mappings/JavaNamedColumn.java | 1 - .../java/mappings/JavaRelationshipMapping.java | 1 - .../mappings/JavaSingleRelationshipMapping.java | 1 - .../java/mappings/JavaUniqueConstraint.java | 1 - .../java/mappings/JpaJavaMappingsPackage.java | 33 ++- .../jpt/core/internal/content/orm/OrmPackage.java | 39 ++- .../jpt/core/internal/content/orm/XmlColumn.java | 264 ++++++++++++++------- .../EnumDeclarationAnnotationElementAdapter.java | 1 - .../jpt/core/internal/mappings/IColumn.java | 118 +++++++-- .../internal/mappings/JpaCoreMappingsPackage.java | 115 ++++++++- 14 files changed, 628 insertions(+), 224 deletions(-) diff --git a/jpa/plugins/org.eclipse.jpt.core/model/core.ecore b/jpa/plugins/org.eclipse.jpt.core/model/core.ecore index eaf0f0e918..9f78292dc4 100644 --- a/jpa/plugins/org.eclipse.jpt.core/model/core.ecore +++ b/jpa/plugins/org.eclipse.jpt.core/model/core.ecore @@ -231,10 +231,21 @@ + + + - - + changeable="false" volatile="true" derived="true"/> + + + + + diff --git a/jpa/plugins/org.eclipse.jpt.core/model/coreModels.genmodel b/jpa/plugins/org.eclipse.jpt.core/model/coreModels.genmodel index 13b24dc6e9..2298138067 100644 --- a/jpa/plugins/org.eclipse.jpt.core/model/coreModels.genmodel +++ b/jpa/plugins/org.eclipse.jpt.core/model/coreModels.genmodel @@ -225,8 +225,14 @@ + + + + + + diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java index ff5db48870..8a14e5c8b0 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/JpaProject.java @@ -142,7 +142,7 @@ public class JpaProject extends JpaEObject implements IJpaProject * This is set to false when that job is completed */ boolean resynching = false; - + /** * Flag to indicate that the disposing job has been scheduled or is running * (or has been run, in some cases) @@ -577,10 +577,9 @@ public class JpaProject extends JpaEObject implements IJpaProject * Dispose and remove project */ void dispose() { - if (disposing) return; - + if (disposing) + return; disposing = true; - Job job = new Job("Disposing JPA project ...") { @Override protected IStatus run(IProgressMonitor monitor) { @@ -591,7 +590,7 @@ public class JpaProject extends JpaEObject implements IJpaProject job.setRule(project); job.schedule(); } - + private void dispose_() { Job.getJobManager().removeJobChangeListener(resynchJobListener); for (IJpaFile jpaFile : new ArrayList(getFiles())) { @@ -678,9 +677,9 @@ public class JpaProject extends JpaEObject implements IJpaProject //passing it on to the JpaModel. We don't currently support //multiple projects having cross-references public void resynch() { - if (disposing) return; - - if (! resynching) { + if (disposing) + return; + if (!resynching) { this.resynching = true; this.needsToResynch = false; this.resynchJob.schedule(); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaColumn.java index 6fd3bdb728..1015c950d9 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaColumn.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaColumn.java @@ -42,17 +42,27 @@ public class JavaColumn extends AbstractJavaColumn implements IColumn * @generated * @ordered */ - protected static final int LENGTH_EDEFAULT = 255; + protected static final int LENGTH_EDEFAULT = 0; /** - * The cached value of the '{@link #getLength() Length}' attribute. + * The default value of the '{@link #getSpecifiedLength() Specified Length}' attribute. * * - * @see #getLength() + * @see #getSpecifiedLength() * @generated * @ordered */ - protected int length = LENGTH_EDEFAULT; + protected static final int SPECIFIED_LENGTH_EDEFAULT = -1; + + /** + * The cached value of the '{@link #getSpecifiedLength() Specified Length}' attribute. + * + * + * @see #getSpecifiedLength() + * @generated + * @ordered + */ + protected int specifiedLength = SPECIFIED_LENGTH_EDEFAULT; /** * The default value of the '{@link #getPrecision() Precision}' attribute. @@ -65,14 +75,24 @@ public class JavaColumn extends AbstractJavaColumn implements IColumn protected static final int PRECISION_EDEFAULT = 0; /** - * The cached value of the '{@link #getPrecision() Precision}' attribute. + * The default value of the '{@link #getSpecifiedPrecision() Specified Precision}' attribute. * * - * @see #getPrecision() + * @see #getSpecifiedPrecision() + * @generated + * @ordered + */ + protected static final int SPECIFIED_PRECISION_EDEFAULT = -1; + + /** + * The cached value of the '{@link #getSpecifiedPrecision() Specified Precision}' attribute. + * + * + * @see #getSpecifiedPrecision() * @generated * @ordered */ - protected int precision = PRECISION_EDEFAULT; + protected int specifiedPrecision = SPECIFIED_PRECISION_EDEFAULT; /** * The default value of the '{@link #getScale() Scale}' attribute. @@ -85,14 +105,24 @@ public class JavaColumn extends AbstractJavaColumn implements IColumn protected static final int SCALE_EDEFAULT = 0; /** - * The cached value of the '{@link #getScale() Scale}' attribute. + * The default value of the '{@link #getSpecifiedScale() Specified Scale}' attribute. * * - * @see #getScale() + * @see #getSpecifiedScale() * @generated * @ordered */ - protected int scale = SCALE_EDEFAULT; + protected static final int SPECIFIED_SCALE_EDEFAULT = -1; + + /** + * The cached value of the '{@link #getSpecifiedScale() Specified Scale}' attribute. + * + * + * @see #getSpecifiedScale() + * @generated + * @ordered + */ + protected int specifiedScale = SPECIFIED_SCALE_EDEFAULT; private final IntAnnotationElementAdapter lengthAdapter; @@ -178,104 +208,130 @@ public class JavaColumn extends AbstractJavaColumn implements IColumn return JpaJavaMappingsPackage.Literals.JAVA_COLUMN; } + public int getLength() { + return (this.getSpecifiedLength() == SPECIFIED_LENGTH_EDEFAULT) ? getDefaultLength() : this.getSpecifiedLength(); + } + /** - * Returns the value of the 'Length' attribute. - * The default value is "255". + * Returns the value of the 'Specified Length' attribute. + * The default value is "-1". * *

    - * If the meaning of the 'Length' attribute isn't clear, + * If the meaning of the 'Specified Length' attribute isn't clear, * there really should be more of a description here... *

    * - * @return the value of the 'Length' attribute. - * @see #setLength(int) - * @see org.eclipse.jpt.core.internal.content.java.mappings.JpaJavaMappingsPackage#getIColumn_Length() - * @model default="255" + * @return the value of the 'Specified Length' attribute. + * @see #setSpecifiedLength(int) + * @see org.eclipse.jpt.core.internal.content.java.mappings.JpaJavaMappingsPackage#getIColumn_SpecifiedLength() + * @model default="-1" * @generated */ - public int getLength() { - return length; + public int getSpecifiedLength() { + return specifiedLength; } /** - * Sets the value of the '{@link org.eclipse.jpt.core.internal.content.java.mappings.JavaColumn#getLength Length}' attribute. + * Sets the value of the '{@link org.eclipse.jpt.core.internal.content.java.mappings.JavaColumn#getSpecifiedLength Specified Length}' attribute. * * - * @param value the new value of the 'Length' attribute. - * @see #getLength() + * @param value the new value of the 'Specified Length' attribute. + * @see #getSpecifiedLength() * @generated */ - public void setLength(int newLength) { - int oldLength = length; - length = newLength; + public void setSpecifiedLength(int newSpecifiedLength) { + int oldSpecifiedLength = specifiedLength; + specifiedLength = newSpecifiedLength; if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, JpaJavaMappingsPackage.JAVA_COLUMN__LENGTH, oldLength, length)); + eNotify(new ENotificationImpl(this, Notification.SET, JpaJavaMappingsPackage.JAVA_COLUMN__SPECIFIED_LENGTH, oldSpecifiedLength, specifiedLength)); + } + + public int getPrecision() { + return (this.getSpecifiedPrecision() == SPECIFIED_PRECISION_EDEFAULT) ? getDefaultPrecision() : this.getSpecifiedPrecision(); } /** - * Returns the value of the 'Precision' attribute. + * Returns the value of the 'Specified Precision' attribute. + * The default value is "-1". * *

    - * If the meaning of the 'Precision' attribute isn't clear, + * If the meaning of the 'Specified Precision' attribute isn't clear, * there really should be more of a description here... *

    * - * @return the value of the 'Precision' attribute. - * @see #setPrecision(int) - * @see org.eclipse.jpt.core.internal.content.java.mappings.JpaJavaMappingsPackage#getIColumn_Precision() - * @model + * @return the value of the 'Specified Precision' attribute. + * @see #setSpecifiedPrecision(int) + * @see org.eclipse.jpt.core.internal.content.java.mappings.JpaJavaMappingsPackage#getIColumn_SpecifiedPrecision() + * @model default="-1" * @generated */ - public int getPrecision() { - return precision; + public int getSpecifiedPrecision() { + return specifiedPrecision; } /** - * Sets the value of the '{@link org.eclipse.jpt.core.internal.content.java.mappings.JavaColumn#getPrecision Precision}' attribute. + * Sets the value of the '{@link org.eclipse.jpt.core.internal.content.java.mappings.JavaColumn#getSpecifiedPrecision Specified Precision}' attribute. * * - * @param value the new value of the 'Precision' attribute. - * @see #getPrecision() + * @param value the new value of the 'Specified Precision' attribute. + * @see #getSpecifiedPrecision() * @generated */ - public void setPrecision(int newPrecision) { - int oldPrecision = precision; - precision = newPrecision; + public void setSpecifiedPrecision(int newSpecifiedPrecision) { + int oldSpecifiedPrecision = specifiedPrecision; + specifiedPrecision = newSpecifiedPrecision; if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, JpaJavaMappingsPackage.JAVA_COLUMN__PRECISION, oldPrecision, precision)); + eNotify(new ENotificationImpl(this, Notification.SET, JpaJavaMappingsPackage.JAVA_COLUMN__SPECIFIED_PRECISION, oldSpecifiedPrecision, specifiedPrecision)); + } + + public int getScale() { + return (this.getSpecifiedScale() == SPECIFIED_SCALE_EDEFAULT) ? getDefaultScale() : this.getSpecifiedScale(); } /** - * Returns the value of the 'Scale' attribute. + * Returns the value of the 'Specified Scale' attribute. + * The default value is "-1". * *

    - * If the meaning of the 'Scale' attribute isn't clear, + * If the meaning of the 'Specified Scale' attribute isn't clear, * there really should be more of a description here... *

    * - * @return the value of the 'Scale' attribute. - * @see #setScale(int) - * @see org.eclipse.jpt.core.internal.content.java.mappings.JpaJavaMappingsPackage#getIColumn_Scale() - * @model + * @return the value of the 'Specified Scale' attribute. + * @see #setSpecifiedScale(int) + * @see org.eclipse.jpt.core.internal.content.java.mappings.JpaJavaMappingsPackage#getIColumn_SpecifiedScale() + * @model default="-1" * @generated */ - public int getScale() { - return scale; + public int getSpecifiedScale() { + return specifiedScale; } /** - * Sets the value of the '{@link org.eclipse.jpt.core.internal.content.java.mappings.JavaColumn#getScale Scale}' attribute. + * Sets the value of the '{@link org.eclipse.jpt.core.internal.content.java.mappings.JavaColumn#getSpecifiedScale Specified Scale}' attribute. * * - * @param value the new value of the 'Scale' attribute. - * @see #getScale() + * @param value the new value of the 'Specified Scale' attribute. + * @see #getSpecifiedScale() * @generated */ - public void setScale(int newScale) { - int oldScale = scale; - scale = newScale; + public void setSpecifiedScale(int newSpecifiedScale) { + int oldSpecifiedScale = specifiedScale; + specifiedScale = newSpecifiedScale; if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, JpaJavaMappingsPackage.JAVA_COLUMN__SCALE, oldScale, scale)); + eNotify(new ENotificationImpl(this, Notification.SET, JpaJavaMappingsPackage.JAVA_COLUMN__SPECIFIED_SCALE, oldSpecifiedScale, specifiedScale)); + } + + public int getDefaultLength() { + return DEFAULT_LENGTH; + } + + public int getDefaultPrecision() { + return DEFAULT_PRECISION; + } + + public int getDefaultScale() { + return DEFAULT_SCALE; } /** @@ -288,10 +344,16 @@ public class JavaColumn extends AbstractJavaColumn implements IColumn switch (featureID) { case JpaJavaMappingsPackage.JAVA_COLUMN__LENGTH : return new Integer(getLength()); + case JpaJavaMappingsPackage.JAVA_COLUMN__SPECIFIED_LENGTH : + return new Integer(getSpecifiedLength()); case JpaJavaMappingsPackage.JAVA_COLUMN__PRECISION : return new Integer(getPrecision()); + case JpaJavaMappingsPackage.JAVA_COLUMN__SPECIFIED_PRECISION : + return new Integer(getSpecifiedPrecision()); case JpaJavaMappingsPackage.JAVA_COLUMN__SCALE : return new Integer(getScale()); + case JpaJavaMappingsPackage.JAVA_COLUMN__SPECIFIED_SCALE : + return new Integer(getSpecifiedScale()); } return super.eGet(featureID, resolve, coreType); } @@ -304,14 +366,14 @@ public class JavaColumn extends AbstractJavaColumn implements IColumn @Override public void eSet(int featureID, Object newValue) { switch (featureID) { - case JpaJavaMappingsPackage.JAVA_COLUMN__LENGTH : - setLength(((Integer) newValue).intValue()); + case JpaJavaMappingsPackage.JAVA_COLUMN__SPECIFIED_LENGTH : + setSpecifiedLength(((Integer) newValue).intValue()); return; - case JpaJavaMappingsPackage.JAVA_COLUMN__PRECISION : - setPrecision(((Integer) newValue).intValue()); + case JpaJavaMappingsPackage.JAVA_COLUMN__SPECIFIED_PRECISION : + setSpecifiedPrecision(((Integer) newValue).intValue()); return; - case JpaJavaMappingsPackage.JAVA_COLUMN__SCALE : - setScale(((Integer) newValue).intValue()); + case JpaJavaMappingsPackage.JAVA_COLUMN__SPECIFIED_SCALE : + setSpecifiedScale(((Integer) newValue).intValue()); return; } super.eSet(featureID, newValue); @@ -325,14 +387,14 @@ public class JavaColumn extends AbstractJavaColumn implements IColumn @Override public void eUnset(int featureID) { switch (featureID) { - case JpaJavaMappingsPackage.JAVA_COLUMN__LENGTH : - setLength(LENGTH_EDEFAULT); + case JpaJavaMappingsPackage.JAVA_COLUMN__SPECIFIED_LENGTH : + setSpecifiedLength(SPECIFIED_LENGTH_EDEFAULT); return; - case JpaJavaMappingsPackage.JAVA_COLUMN__PRECISION : - setPrecision(PRECISION_EDEFAULT); + case JpaJavaMappingsPackage.JAVA_COLUMN__SPECIFIED_PRECISION : + setSpecifiedPrecision(SPECIFIED_PRECISION_EDEFAULT); return; - case JpaJavaMappingsPackage.JAVA_COLUMN__SCALE : - setScale(SCALE_EDEFAULT); + case JpaJavaMappingsPackage.JAVA_COLUMN__SPECIFIED_SCALE : + setSpecifiedScale(SPECIFIED_SCALE_EDEFAULT); return; } super.eUnset(featureID); @@ -347,11 +409,17 @@ public class JavaColumn extends AbstractJavaColumn implements IColumn public boolean eIsSet(int featureID) { switch (featureID) { case JpaJavaMappingsPackage.JAVA_COLUMN__LENGTH : - return length != LENGTH_EDEFAULT; + return getLength() != LENGTH_EDEFAULT; + case JpaJavaMappingsPackage.JAVA_COLUMN__SPECIFIED_LENGTH : + return specifiedLength != SPECIFIED_LENGTH_EDEFAULT; case JpaJavaMappingsPackage.JAVA_COLUMN__PRECISION : - return precision != PRECISION_EDEFAULT; + return getPrecision() != PRECISION_EDEFAULT; + case JpaJavaMappingsPackage.JAVA_COLUMN__SPECIFIED_PRECISION : + return specifiedPrecision != SPECIFIED_PRECISION_EDEFAULT; case JpaJavaMappingsPackage.JAVA_COLUMN__SCALE : - return scale != SCALE_EDEFAULT; + return getScale() != SCALE_EDEFAULT; + case JpaJavaMappingsPackage.JAVA_COLUMN__SPECIFIED_SCALE : + return specifiedScale != SPECIFIED_SCALE_EDEFAULT; } return super.eIsSet(featureID); } @@ -367,10 +435,16 @@ public class JavaColumn extends AbstractJavaColumn implements IColumn switch (derivedFeatureID) { case JpaJavaMappingsPackage.JAVA_COLUMN__LENGTH : return JpaCoreMappingsPackage.ICOLUMN__LENGTH; + case JpaJavaMappingsPackage.JAVA_COLUMN__SPECIFIED_LENGTH : + return JpaCoreMappingsPackage.ICOLUMN__SPECIFIED_LENGTH; case JpaJavaMappingsPackage.JAVA_COLUMN__PRECISION : return JpaCoreMappingsPackage.ICOLUMN__PRECISION; + case JpaJavaMappingsPackage.JAVA_COLUMN__SPECIFIED_PRECISION : + return JpaCoreMappingsPackage.ICOLUMN__SPECIFIED_PRECISION; case JpaJavaMappingsPackage.JAVA_COLUMN__SCALE : return JpaCoreMappingsPackage.ICOLUMN__SCALE; + case JpaJavaMappingsPackage.JAVA_COLUMN__SPECIFIED_SCALE : + return JpaCoreMappingsPackage.ICOLUMN__SPECIFIED_SCALE; default : return -1; } @@ -389,10 +463,16 @@ public class JavaColumn extends AbstractJavaColumn implements IColumn switch (baseFeatureID) { case JpaCoreMappingsPackage.ICOLUMN__LENGTH : return JpaJavaMappingsPackage.JAVA_COLUMN__LENGTH; + case JpaCoreMappingsPackage.ICOLUMN__SPECIFIED_LENGTH : + return JpaJavaMappingsPackage.JAVA_COLUMN__SPECIFIED_LENGTH; case JpaCoreMappingsPackage.ICOLUMN__PRECISION : return JpaJavaMappingsPackage.JAVA_COLUMN__PRECISION; + case JpaCoreMappingsPackage.ICOLUMN__SPECIFIED_PRECISION : + return JpaJavaMappingsPackage.JAVA_COLUMN__SPECIFIED_PRECISION; case JpaCoreMappingsPackage.ICOLUMN__SCALE : return JpaJavaMappingsPackage.JAVA_COLUMN__SCALE; + case JpaCoreMappingsPackage.ICOLUMN__SPECIFIED_SCALE : + return JpaJavaMappingsPackage.JAVA_COLUMN__SPECIFIED_SCALE; default : return -1; } @@ -410,12 +490,12 @@ public class JavaColumn extends AbstractJavaColumn implements IColumn if (eIsProxy()) return super.toString(); StringBuffer result = new StringBuffer(super.toString()); - result.append(" (length: "); - result.append(length); - result.append(", precision: "); - result.append(precision); - result.append(", scale: "); - result.append(scale); + result.append(" (specifiedLength: "); + result.append(specifiedLength); + result.append(", specifiedPrecision: "); + result.append(specifiedPrecision); + result.append(", specifiedScale: "); + result.append(specifiedScale); result.append(')'); return result.toString(); } @@ -428,9 +508,9 @@ public class JavaColumn extends AbstractJavaColumn implements IColumn @Override public void updateFromJava(CompilationUnit astRoot) { super.updateFromJava(astRoot); - this.setLength(this.lengthAdapter.getValue(astRoot)); - this.setPrecision(this.precisionAdapter.getValue(astRoot)); - this.setScale(this.scaleAdapter.getValue(astRoot)); + this.setSpecifiedLength(this.lengthAdapter.getValue(astRoot)); + this.setSpecifiedPrecision(this.precisionAdapter.getValue(astRoot)); + this.setSpecifiedScale(this.scaleAdapter.getValue(astRoot)); } public void refreshDefaults(DefaultsContext defaultsContext) { diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedColumn.java index abfb4c3c9d..37023600eb 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedColumn.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaNamedColumn.java @@ -10,7 +10,6 @@ package org.eclipse.jpt.core.internal.content.java.mappings; import java.util.Iterator; - import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.impl.ENotificationImpl; diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaRelationshipMapping.java index 1b16973e04..d5889176e3 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaRelationshipMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaRelationshipMapping.java @@ -10,7 +10,6 @@ package org.eclipse.jpt.core.internal.content.java.mappings; import java.util.Iterator; - import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.ecore.EClass; diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSingleRelationshipMapping.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSingleRelationshipMapping.java index ceee378b92..ffefd899cb 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSingleRelationshipMapping.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaSingleRelationshipMapping.java @@ -12,7 +12,6 @@ package org.eclipse.jpt.core.internal.content.java.mappings; import java.util.Collection; import java.util.Iterator; import java.util.List; - import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.notify.NotificationChain; import org.eclipse.emf.common.util.EList; diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaUniqueConstraint.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaUniqueConstraint.java index 2c425e8214..51ec6eea66 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaUniqueConstraint.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JavaUniqueConstraint.java @@ -103,7 +103,6 @@ public class JavaUniqueConstraint extends JavaEObject return new ConversionDeclarationAnnotationElementAdapter(annotationAdapter, elementName, false, converter); } - @Override protected void notifyChanged(Notification notification) { super.notifyChanged(notification); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JpaJavaMappingsPackage.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JpaJavaMappingsPackage.java index da4c6465bf..d5061b251d 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JpaJavaMappingsPackage.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/mappings/JpaJavaMappingsPackage.java @@ -2390,6 +2390,15 @@ public class JpaJavaMappingsPackage extends EPackageImpl */ public static final int JAVA_COLUMN__LENGTH = ABSTRACT_JAVA_COLUMN_FEATURE_COUNT + 0; + /** + * The feature id for the 'Specified Length' attribute. + * + * + * @generated + * @ordered + */ + public static final int JAVA_COLUMN__SPECIFIED_LENGTH = ABSTRACT_JAVA_COLUMN_FEATURE_COUNT + 1; + /** * The feature id for the 'Precision' attribute. * @@ -2397,7 +2406,16 @@ public class JpaJavaMappingsPackage extends EPackageImpl * @generated * @ordered */ - public static final int JAVA_COLUMN__PRECISION = ABSTRACT_JAVA_COLUMN_FEATURE_COUNT + 1; + public static final int JAVA_COLUMN__PRECISION = ABSTRACT_JAVA_COLUMN_FEATURE_COUNT + 2; + + /** + * The feature id for the 'Specified Precision' attribute. + * + * + * @generated + * @ordered + */ + public static final int JAVA_COLUMN__SPECIFIED_PRECISION = ABSTRACT_JAVA_COLUMN_FEATURE_COUNT + 3; /** * The feature id for the 'Scale' attribute. @@ -2406,7 +2424,16 @@ public class JpaJavaMappingsPackage extends EPackageImpl * @generated * @ordered */ - public static final int JAVA_COLUMN__SCALE = ABSTRACT_JAVA_COLUMN_FEATURE_COUNT + 2; + public static final int JAVA_COLUMN__SCALE = ABSTRACT_JAVA_COLUMN_FEATURE_COUNT + 4; + + /** + * The feature id for the 'Specified Scale' attribute. + * + * + * @generated + * @ordered + */ + public static final int JAVA_COLUMN__SPECIFIED_SCALE = ABSTRACT_JAVA_COLUMN_FEATURE_COUNT + 5; /** * The number of structural features of the 'Java Column' class. @@ -2415,7 +2442,7 @@ public class JpaJavaMappingsPackage extends EPackageImpl * @generated * @ordered */ - public static final int JAVA_COLUMN_FEATURE_COUNT = ABSTRACT_JAVA_COLUMN_FEATURE_COUNT + 3; + public static final int JAVA_COLUMN_FEATURE_COUNT = ABSTRACT_JAVA_COLUMN_FEATURE_COUNT + 6; /** * The feature id for the 'Name' attribute. diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/OrmPackage.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/OrmPackage.java index 6494a6e5f5..10e5d2d947 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/OrmPackage.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/OrmPackage.java @@ -3581,6 +3581,15 @@ public class OrmPackage extends EPackageImpl */ public static final int XML_COLUMN__LENGTH = ABSTRACT_XML_COLUMN_FEATURE_COUNT + 0; + /** + * The feature id for the 'Specified Length' attribute. + * + * + * @generated + * @ordered + */ + public static final int XML_COLUMN__SPECIFIED_LENGTH = ABSTRACT_XML_COLUMN_FEATURE_COUNT + 1; + /** * The feature id for the 'Precision' attribute. * @@ -3588,7 +3597,16 @@ public class OrmPackage extends EPackageImpl * @generated * @ordered */ - public static final int XML_COLUMN__PRECISION = ABSTRACT_XML_COLUMN_FEATURE_COUNT + 1; + public static final int XML_COLUMN__PRECISION = ABSTRACT_XML_COLUMN_FEATURE_COUNT + 2; + + /** + * The feature id for the 'Specified Precision' attribute. + * + * + * @generated + * @ordered + */ + public static final int XML_COLUMN__SPECIFIED_PRECISION = ABSTRACT_XML_COLUMN_FEATURE_COUNT + 3; /** * The feature id for the 'Scale' attribute. @@ -3597,7 +3615,16 @@ public class OrmPackage extends EPackageImpl * @generated * @ordered */ - public static final int XML_COLUMN__SCALE = ABSTRACT_XML_COLUMN_FEATURE_COUNT + 2; + public static final int XML_COLUMN__SCALE = ABSTRACT_XML_COLUMN_FEATURE_COUNT + 4; + + /** + * The feature id for the 'Specified Scale' attribute. + * + * + * @generated + * @ordered + */ + public static final int XML_COLUMN__SPECIFIED_SCALE = ABSTRACT_XML_COLUMN_FEATURE_COUNT + 5; /** * The feature id for the 'Length For Xml' attribute. @@ -3606,7 +3633,7 @@ public class OrmPackage extends EPackageImpl * @generated * @ordered */ - public static final int XML_COLUMN__LENGTH_FOR_XML = ABSTRACT_XML_COLUMN_FEATURE_COUNT + 3; + public static final int XML_COLUMN__LENGTH_FOR_XML = ABSTRACT_XML_COLUMN_FEATURE_COUNT + 6; /** * The feature id for the 'Precision For Xml' attribute. @@ -3615,7 +3642,7 @@ public class OrmPackage extends EPackageImpl * @generated * @ordered */ - public static final int XML_COLUMN__PRECISION_FOR_XML = ABSTRACT_XML_COLUMN_FEATURE_COUNT + 4; + public static final int XML_COLUMN__PRECISION_FOR_XML = ABSTRACT_XML_COLUMN_FEATURE_COUNT + 7; /** * The feature id for the 'Scale For Xml' attribute. @@ -3624,7 +3651,7 @@ public class OrmPackage extends EPackageImpl * @generated * @ordered */ - public static final int XML_COLUMN__SCALE_FOR_XML = ABSTRACT_XML_COLUMN_FEATURE_COUNT + 5; + public static final int XML_COLUMN__SCALE_FOR_XML = ABSTRACT_XML_COLUMN_FEATURE_COUNT + 8; /** * The number of structural features of the 'Xml Column' class. @@ -3633,7 +3660,7 @@ public class OrmPackage extends EPackageImpl * @generated * @ordered */ - public static final int XML_COLUMN_FEATURE_COUNT = ABSTRACT_XML_COLUMN_FEATURE_COUNT + 6; + public static final int XML_COLUMN_FEATURE_COUNT = ABSTRACT_XML_COLUMN_FEATURE_COUNT + 9; /** * The meta object id for the '{@link org.eclipse.jpt.core.internal.content.orm.XmlJoinColumn Xml Join Column}' class. diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlColumn.java index 009f658495..fae6f916f7 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlColumn.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlColumn.java @@ -47,17 +47,27 @@ public class XmlColumn extends AbstractXmlColumn implements IColumn * @generated * @ordered */ - protected static final int LENGTH_EDEFAULT = 255; + protected static final int LENGTH_EDEFAULT = 0; /** - * The cached value of the '{@link #getLength() Length}' attribute. + * The default value of the '{@link #getSpecifiedLength() Specified Length}' attribute. * * - * @see #getLength() + * @see #getSpecifiedLength() * @generated * @ordered */ - protected int length = LENGTH_EDEFAULT; + protected static final int SPECIFIED_LENGTH_EDEFAULT = -1; + + /** + * The cached value of the '{@link #getSpecifiedLength() Specified Length}' attribute. + * + * + * @see #getSpecifiedLength() + * @generated + * @ordered + */ + protected int specifiedLength = SPECIFIED_LENGTH_EDEFAULT; /** * The default value of the '{@link #getPrecision() Precision}' attribute. @@ -70,14 +80,24 @@ public class XmlColumn extends AbstractXmlColumn implements IColumn protected static final int PRECISION_EDEFAULT = 0; /** - * The cached value of the '{@link #getPrecision() Precision}' attribute. + * The default value of the '{@link #getSpecifiedPrecision() Specified Precision}' attribute. * * - * @see #getPrecision() + * @see #getSpecifiedPrecision() + * @generated + * @ordered + */ + protected static final int SPECIFIED_PRECISION_EDEFAULT = -1; + + /** + * The cached value of the '{@link #getSpecifiedPrecision() Specified Precision}' attribute. + * + * + * @see #getSpecifiedPrecision() * @generated * @ordered */ - protected int precision = PRECISION_EDEFAULT; + protected int specifiedPrecision = SPECIFIED_PRECISION_EDEFAULT; /** * The default value of the '{@link #getScale() Scale}' attribute. @@ -90,14 +110,24 @@ public class XmlColumn extends AbstractXmlColumn implements IColumn protected static final int SCALE_EDEFAULT = 0; /** - * The cached value of the '{@link #getScale() Scale}' attribute. + * The default value of the '{@link #getSpecifiedScale() Specified Scale}' attribute. * * - * @see #getScale() + * @see #getSpecifiedScale() * @generated * @ordered */ - protected int scale = SCALE_EDEFAULT; + protected static final int SPECIFIED_SCALE_EDEFAULT = -1; + + /** + * The cached value of the '{@link #getSpecifiedScale() Specified Scale}' attribute. + * + * + * @see #getSpecifiedScale() + * @generated + * @ordered + */ + protected int specifiedScale = SPECIFIED_SCALE_EDEFAULT; /** * The default value of the '{@link #getLengthForXml() Length For Xml}' attribute. @@ -152,134 +182,148 @@ public class XmlColumn extends AbstractXmlColumn implements IColumn return OrmPackage.Literals.XML_COLUMN; } + public int getLength() { + return (this.getSpecifiedLength() == SPECIFIED_LENGTH_EDEFAULT) ? getDefaultLength() : this.getSpecifiedLength(); + } + /** - * Returns the value of the 'Length' attribute. - * The default value is "255". + * Returns the value of the 'Specified Length' attribute. + * The default value is "-1". * *

    - * If the meaning of the 'Length' attribute isn't clear, + * If the meaning of the 'Specified Length' attribute isn't clear, * there really should be more of a description here... *

    * - * @return the value of the 'Length' attribute. - * @see #setLength(int) - * @see org.eclipse.jpt.core.internal.content.orm.OrmPackage#getIColumn_Length() - * @model default="255" + * @return the value of the 'Specified Length' attribute. + * @see #setSpecifiedLength(int) + * @see org.eclipse.jpt.core.internal.content.orm.OrmPackage#getIColumn_SpecifiedLength() + * @model default="-1" * @generated */ - public int getLength() { - return length; + public int getSpecifiedLength() { + return specifiedLength; } /** - * Sets the value of the '{@link org.eclipse.jpt.core.internal.content.orm.XmlColumn#getLength Length}' attribute. + * Sets the value of the '{@link org.eclipse.jpt.core.internal.content.orm.XmlColumn#getSpecifiedLength Specified Length}' attribute. * * - * @param value the new value of the 'Length' attribute. - * @see #getLength() + * @param value the new value of the 'Specified Length' attribute. + * @see #getSpecifiedLength() * @generated */ - public void setLengthGen(int newLength) { - int oldLength = length; - length = newLength; + public void setSpecifiedLengthGen(int newSpecifiedLength) { + int oldSpecifiedLength = specifiedLength; + specifiedLength = newSpecifiedLength; if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_COLUMN__LENGTH, oldLength, length)); + eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_COLUMN__SPECIFIED_LENGTH, oldSpecifiedLength, specifiedLength)); } - public void setLength(int newLength) { - setLengthGen(newLength); - if (newLength != LENGTH_EDEFAULT) { + public void setSpecifiedLength(int newSpecifiedLength) { + setSpecifiedLengthGen(newSpecifiedLength); + if (newSpecifiedLength != LENGTH_EDEFAULT) { getColumnMapping().makeColumnForXmlNonNull(); } - setLengthForXml(newLength); + setLengthForXml(newSpecifiedLength); if (isAllFeaturesUnset()) { getColumnMapping().makeColumnForXmlNull(); } } + public int getPrecision() { + return (this.getSpecifiedPrecision() == SPECIFIED_PRECISION_EDEFAULT) ? getDefaultPrecision() : this.getSpecifiedPrecision(); + } + /** - * Returns the value of the 'Precision' attribute. + * Returns the value of the 'Specified Precision' attribute. + * The default value is "-1". * *

    - * If the meaning of the 'Precision' attribute isn't clear, + * If the meaning of the 'Specified Precision' attribute isn't clear, * there really should be more of a description here... *

    * - * @return the value of the 'Precision' attribute. - * @see #setPrecision(int) - * @see org.eclipse.jpt.core.internal.content.orm.OrmPackage#getIColumn_Precision() - * @model + * @return the value of the 'Specified Precision' attribute. + * @see #setSpecifiedPrecision(int) + * @see org.eclipse.jpt.core.internal.content.orm.OrmPackage#getIColumn_SpecifiedPrecision() + * @model default="-1" * @generated */ - public int getPrecision() { - return precision; + public int getSpecifiedPrecision() { + return specifiedPrecision; } /** - * Sets the value of the '{@link org.eclipse.jpt.core.internal.content.orm.XmlColumn#getPrecision Precision}' attribute. + * Sets the value of the '{@link org.eclipse.jpt.core.internal.content.orm.XmlColumn#getSpecifiedPrecision Specified Precision}' attribute. * * - * @param value the new value of the 'Precision' attribute. - * @see #getPrecision() + * @param value the new value of the 'Specified Precision' attribute. + * @see #getSpecifiedPrecision() * @generated */ - public void setPrecisionGen(int newPrecision) { - int oldPrecision = precision; - precision = newPrecision; + public void setSpecifiedPrecisionGen(int newSpecifiedPrecision) { + int oldSpecifiedPrecision = specifiedPrecision; + specifiedPrecision = newSpecifiedPrecision; if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_COLUMN__PRECISION, oldPrecision, precision)); + eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_COLUMN__SPECIFIED_PRECISION, oldSpecifiedPrecision, specifiedPrecision)); } - public void setPrecision(int newPrecision) { - setPrecisionGen(newPrecision); - if (newPrecision != PRECISION_EDEFAULT) { + public void setSpecifiedPrecision(int newSpecifiedPrecision) { + setSpecifiedPrecisionGen(newSpecifiedPrecision); + if (newSpecifiedPrecision != PRECISION_EDEFAULT) { getColumnMapping().makeColumnForXmlNonNull(); } - setPrecisionForXml(newPrecision); + setPrecisionForXml(newSpecifiedPrecision); if (isAllFeaturesUnset()) { getColumnMapping().makeColumnForXmlNull(); } } + public int getScale() { + return (this.getSpecifiedScale() == SPECIFIED_SCALE_EDEFAULT) ? getDefaultScale() : this.getSpecifiedScale(); + } + /** - * Returns the value of the 'Scale' attribute. + * Returns the value of the 'Specified Scale' attribute. + * The default value is "-1". * *

    - * If the meaning of the 'Scale' attribute isn't clear, + * If the meaning of the 'Specified Scale' attribute isn't clear, * there really should be more of a description here... *

    * - * @return the value of the 'Scale' attribute. - * @see #setScale(int) - * @see org.eclipse.jpt.core.internal.content.orm.OrmPackage#getIColumn_Scale() - * @model + * @return the value of the 'Specified Scale' attribute. + * @see #setSpecifiedScale(int) + * @see org.eclipse.jpt.core.internal.content.orm.OrmPackage#getIColumn_SpecifiedScale() + * @model default="-1" * @generated */ - public int getScale() { - return scale; + public int getSpecifiedScale() { + return specifiedScale; } /** - * Sets the value of the '{@link org.eclipse.jpt.core.internal.content.orm.XmlColumn#getScale Scale}' attribute. + * Sets the value of the '{@link org.eclipse.jpt.core.internal.content.orm.XmlColumn#getSpecifiedScale Specified Scale}' attribute. * * - * @param value the new value of the 'Scale' attribute. - * @see #getScale() + * @param value the new value of the 'Specified Scale' attribute. + * @see #getSpecifiedScale() * @generated */ - public void setScaleGen(int newScale) { - int oldScale = scale; - scale = newScale; + public void setSpecifiedScaleGen(int newSpecifiedScale) { + int oldSpecifiedScale = specifiedScale; + specifiedScale = newSpecifiedScale; if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_COLUMN__SCALE, oldScale, scale)); + eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_COLUMN__SPECIFIED_SCALE, oldSpecifiedScale, specifiedScale)); } - public void setScale(int newScale) { - setScaleGen(newScale); - if (newScale != SCALE_EDEFAULT) { + public void setSpecifiedScale(int newSpecifiedScale) { + setSpecifiedScaleGen(newSpecifiedScale); + if (newSpecifiedScale != SCALE_EDEFAULT) { getColumnMapping().makeColumnForXmlNonNull(); } - setScaleForXml(newScale); + setScaleForXml(newSpecifiedScale); if (isAllFeaturesUnset()) { getColumnMapping().makeColumnForXmlNull(); } @@ -313,7 +357,7 @@ public class XmlColumn extends AbstractXmlColumn implements IColumn * @generated NOT */ public void setLengthForXml(int newLengthForXml) { - setLengthGen(newLengthForXml); + setSpecifiedLengthGen(newLengthForXml); if (eNotificationRequired()) //pass in oldValue of null because we don't store the value from the xml, see super.eNotify() eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_COLUMN__LENGTH_FOR_XML, null, newLengthForXml)); @@ -346,7 +390,7 @@ public class XmlColumn extends AbstractXmlColumn implements IColumn * @generated NOT */ public void setPrecisionForXml(int newPrecisionForXml) { - setPrecisionGen(newPrecisionForXml); + setSpecifiedPrecisionGen(newPrecisionForXml); if (eNotificationRequired()) //pass in oldValue of null because we don't store the value from the xml, see super.eNotify() eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_COLUMN__PRECISION_FOR_XML, null, newPrecisionForXml)); @@ -379,12 +423,24 @@ public class XmlColumn extends AbstractXmlColumn implements IColumn * @generated NOT */ public void setScaleForXml(int newScaleForXml) { - setScaleGen(newScaleForXml); + setSpecifiedScaleGen(newScaleForXml); if (eNotificationRequired()) //pass in oldValue of null because we don't store the value from the xml, see super.eNotify() eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_COLUMN__SCALE_FOR_XML, null, newScaleForXml)); } + public int getDefaultLength() { + return DEFAULT_LENGTH; + } + + public int getDefaultPrecision() { + return DEFAULT_PRECISION; + } + + public int getDefaultScale() { + return DEFAULT_SCALE; + } + /** * * @@ -395,10 +451,16 @@ public class XmlColumn extends AbstractXmlColumn implements IColumn switch (featureID) { case OrmPackage.XML_COLUMN__LENGTH : return new Integer(getLength()); + case OrmPackage.XML_COLUMN__SPECIFIED_LENGTH : + return new Integer(getSpecifiedLength()); case OrmPackage.XML_COLUMN__PRECISION : return new Integer(getPrecision()); + case OrmPackage.XML_COLUMN__SPECIFIED_PRECISION : + return new Integer(getSpecifiedPrecision()); case OrmPackage.XML_COLUMN__SCALE : return new Integer(getScale()); + case OrmPackage.XML_COLUMN__SPECIFIED_SCALE : + return new Integer(getSpecifiedScale()); case OrmPackage.XML_COLUMN__LENGTH_FOR_XML : return new Integer(getLengthForXml()); case OrmPackage.XML_COLUMN__PRECISION_FOR_XML : @@ -417,14 +479,14 @@ public class XmlColumn extends AbstractXmlColumn implements IColumn @Override public void eSet(int featureID, Object newValue) { switch (featureID) { - case OrmPackage.XML_COLUMN__LENGTH : - setLength(((Integer) newValue).intValue()); + case OrmPackage.XML_COLUMN__SPECIFIED_LENGTH : + setSpecifiedLength(((Integer) newValue).intValue()); return; - case OrmPackage.XML_COLUMN__PRECISION : - setPrecision(((Integer) newValue).intValue()); + case OrmPackage.XML_COLUMN__SPECIFIED_PRECISION : + setSpecifiedPrecision(((Integer) newValue).intValue()); return; - case OrmPackage.XML_COLUMN__SCALE : - setScale(((Integer) newValue).intValue()); + case OrmPackage.XML_COLUMN__SPECIFIED_SCALE : + setSpecifiedScale(((Integer) newValue).intValue()); return; case OrmPackage.XML_COLUMN__LENGTH_FOR_XML : setLengthForXml(((Integer) newValue).intValue()); @@ -447,14 +509,14 @@ public class XmlColumn extends AbstractXmlColumn implements IColumn @Override public void eUnset(int featureID) { switch (featureID) { - case OrmPackage.XML_COLUMN__LENGTH : - setLength(LENGTH_EDEFAULT); + case OrmPackage.XML_COLUMN__SPECIFIED_LENGTH : + setSpecifiedLength(SPECIFIED_LENGTH_EDEFAULT); return; - case OrmPackage.XML_COLUMN__PRECISION : - setPrecision(PRECISION_EDEFAULT); + case OrmPackage.XML_COLUMN__SPECIFIED_PRECISION : + setSpecifiedPrecision(SPECIFIED_PRECISION_EDEFAULT); return; - case OrmPackage.XML_COLUMN__SCALE : - setScale(SCALE_EDEFAULT); + case OrmPackage.XML_COLUMN__SPECIFIED_SCALE : + setSpecifiedScale(SPECIFIED_SCALE_EDEFAULT); return; case OrmPackage.XML_COLUMN__LENGTH_FOR_XML : setLengthForXml(LENGTH_FOR_XML_EDEFAULT); @@ -478,11 +540,17 @@ public class XmlColumn extends AbstractXmlColumn implements IColumn public boolean eIsSet(int featureID) { switch (featureID) { case OrmPackage.XML_COLUMN__LENGTH : - return length != LENGTH_EDEFAULT; + return getLength() != LENGTH_EDEFAULT; + case OrmPackage.XML_COLUMN__SPECIFIED_LENGTH : + return specifiedLength != SPECIFIED_LENGTH_EDEFAULT; case OrmPackage.XML_COLUMN__PRECISION : - return precision != PRECISION_EDEFAULT; + return getPrecision() != PRECISION_EDEFAULT; + case OrmPackage.XML_COLUMN__SPECIFIED_PRECISION : + return specifiedPrecision != SPECIFIED_PRECISION_EDEFAULT; case OrmPackage.XML_COLUMN__SCALE : - return scale != SCALE_EDEFAULT; + return getScale() != SCALE_EDEFAULT; + case OrmPackage.XML_COLUMN__SPECIFIED_SCALE : + return specifiedScale != SPECIFIED_SCALE_EDEFAULT; case OrmPackage.XML_COLUMN__LENGTH_FOR_XML : return getLengthForXml() != LENGTH_FOR_XML_EDEFAULT; case OrmPackage.XML_COLUMN__PRECISION_FOR_XML : @@ -504,10 +572,16 @@ public class XmlColumn extends AbstractXmlColumn implements IColumn switch (derivedFeatureID) { case OrmPackage.XML_COLUMN__LENGTH : return JpaCoreMappingsPackage.ICOLUMN__LENGTH; + case OrmPackage.XML_COLUMN__SPECIFIED_LENGTH : + return JpaCoreMappingsPackage.ICOLUMN__SPECIFIED_LENGTH; case OrmPackage.XML_COLUMN__PRECISION : return JpaCoreMappingsPackage.ICOLUMN__PRECISION; + case OrmPackage.XML_COLUMN__SPECIFIED_PRECISION : + return JpaCoreMappingsPackage.ICOLUMN__SPECIFIED_PRECISION; case OrmPackage.XML_COLUMN__SCALE : return JpaCoreMappingsPackage.ICOLUMN__SCALE; + case OrmPackage.XML_COLUMN__SPECIFIED_SCALE : + return JpaCoreMappingsPackage.ICOLUMN__SPECIFIED_SCALE; default : return -1; } @@ -526,10 +600,16 @@ public class XmlColumn extends AbstractXmlColumn implements IColumn switch (baseFeatureID) { case JpaCoreMappingsPackage.ICOLUMN__LENGTH : return OrmPackage.XML_COLUMN__LENGTH; + case JpaCoreMappingsPackage.ICOLUMN__SPECIFIED_LENGTH : + return OrmPackage.XML_COLUMN__SPECIFIED_LENGTH; case JpaCoreMappingsPackage.ICOLUMN__PRECISION : return OrmPackage.XML_COLUMN__PRECISION; + case JpaCoreMappingsPackage.ICOLUMN__SPECIFIED_PRECISION : + return OrmPackage.XML_COLUMN__SPECIFIED_PRECISION; case JpaCoreMappingsPackage.ICOLUMN__SCALE : return OrmPackage.XML_COLUMN__SCALE; + case JpaCoreMappingsPackage.ICOLUMN__SPECIFIED_SCALE : + return OrmPackage.XML_COLUMN__SPECIFIED_SCALE; default : return -1; } @@ -547,12 +627,12 @@ public class XmlColumn extends AbstractXmlColumn implements IColumn if (eIsProxy()) return super.toString(); StringBuffer result = new StringBuffer(super.toString()); - result.append(" (length: "); - result.append(length); - result.append(", precision: "); - result.append(precision); - result.append(", scale: "); - result.append(scale); + result.append(" (specifiedLength: "); + result.append(specifiedLength); + result.append(", specifiedPrecision: "); + result.append(specifiedPrecision); + result.append(", specifiedScale: "); + result.append(specifiedScale); result.append(')'); return result.toString(); } diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/EnumDeclarationAnnotationElementAdapter.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/EnumDeclarationAnnotationElementAdapter.java index 2f0c1f704b..eda5853562 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/EnumDeclarationAnnotationElementAdapter.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/jdtutility/EnumDeclarationAnnotationElementAdapter.java @@ -11,7 +11,6 @@ package org.eclipse.jpt.core.internal.jdtutility; import org.eclipse.jdt.core.dom.ASTNode; import org.eclipse.jdt.core.dom.Expression; -import org.eclipse.jdt.core.dom.Name; /** * Wrap a declaration annotation element adapter and simply diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/IColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/IColumn.java index aaf84672e9..9abbc8f498 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/IColumn.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/IColumn.java @@ -20,8 +20,11 @@ import org.eclipse.jpt.core.internal.platform.DefaultsContext; * The following features are supported: *
      *
    • {@link org.eclipse.jpt.core.internal.mappings.IColumn#getLength Length}
    • + *
    • {@link org.eclipse.jpt.core.internal.mappings.IColumn#getSpecifiedLength Specified Length}
    • *
    • {@link org.eclipse.jpt.core.internal.mappings.IColumn#getPrecision Precision}
    • + *
    • {@link org.eclipse.jpt.core.internal.mappings.IColumn#getSpecifiedPrecision Specified Precision}
    • *
    • {@link org.eclipse.jpt.core.internal.mappings.IColumn#getScale Scale}
    • + *
    • {@link org.eclipse.jpt.core.internal.mappings.IColumn#getSpecifiedScale Specified Scale}
    • *
    *

    * @@ -31,9 +34,14 @@ import org.eclipse.jpt.core.internal.platform.DefaultsContext; */ public interface IColumn extends IAbstractColumn { + int DEFAULT_LENGTH = 255; + + int DEFAULT_PRECISION = 0; + + int DEFAULT_SCALE = 0; + /** * Returns the value of the 'Length' attribute. - * The default value is "255". * *

    * If the meaning of the 'Length' attribute isn't clear, @@ -41,22 +49,38 @@ public interface IColumn extends IAbstractColumn *

    * * @return the value of the 'Length' attribute. - * @see #setLength(int) * @see org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage#getIColumn_Length() - * @model default="255" + * @model changeable="false" volatile="true" derived="true" * @generated */ int getLength(); /** - * Sets the value of the '{@link org.eclipse.jpt.core.internal.mappings.IColumn#getLength Length}' attribute. + * Returns the value of the 'Specified Length' attribute. + * The default value is "-1". + * + *

    + * If the meaning of the 'Specified Length' attribute isn't clear, + * there really should be more of a description here... + *

    + * + * @return the value of the 'Specified Length' attribute. + * @see #setSpecifiedLength(int) + * @see org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage#getIColumn_SpecifiedLength() + * @model default="-1" + * @generated + */ + int getSpecifiedLength(); + + /** + * Sets the value of the '{@link org.eclipse.jpt.core.internal.mappings.IColumn#getSpecifiedLength Specified Length}' attribute. * * - * @param value the new value of the 'Length' attribute. - * @see #getLength() + * @param value the new value of the 'Specified Length' attribute. + * @see #getSpecifiedLength() * @generated */ - void setLength(int value); + void setSpecifiedLength(int value); /** * Returns the value of the 'Precision' attribute. @@ -67,22 +91,38 @@ public interface IColumn extends IAbstractColumn *

    * * @return the value of the 'Precision' attribute. - * @see #setPrecision(int) * @see org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage#getIColumn_Precision() - * @model + * @model changeable="false" volatile="true" derived="true" * @generated */ int getPrecision(); /** - * Sets the value of the '{@link org.eclipse.jpt.core.internal.mappings.IColumn#getPrecision Precision}' attribute. + * Returns the value of the 'Specified Precision' attribute. + * The default value is "-1". + * + *

    + * If the meaning of the 'Specified Precision' attribute isn't clear, + * there really should be more of a description here... + *

    + * + * @return the value of the 'Specified Precision' attribute. + * @see #setSpecifiedPrecision(int) + * @see org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage#getIColumn_SpecifiedPrecision() + * @model default="-1" + * @generated + */ + int getSpecifiedPrecision(); + + /** + * Sets the value of the '{@link org.eclipse.jpt.core.internal.mappings.IColumn#getSpecifiedPrecision Specified Precision}' attribute. * * - * @param value the new value of the 'Precision' attribute. - * @see #getPrecision() + * @param value the new value of the 'Specified Precision' attribute. + * @see #getSpecifiedPrecision() * @generated */ - void setPrecision(int value); + void setSpecifiedPrecision(int value); /** * Returns the value of the 'Scale' attribute. @@ -93,22 +133,62 @@ public interface IColumn extends IAbstractColumn *

    * * @return the value of the 'Scale' attribute. - * @see #setScale(int) * @see org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage#getIColumn_Scale() - * @model + * @model changeable="false" volatile="true" derived="true" * @generated */ int getScale(); /** - * Sets the value of the '{@link org.eclipse.jpt.core.internal.mappings.IColumn#getScale Scale}' attribute. + * Returns the value of the 'Specified Scale' attribute. + * The default value is "-1". + * + *

    + * If the meaning of the 'Specified Scale' attribute isn't clear, + * there really should be more of a description here... + *

    + * + * @return the value of the 'Specified Scale' attribute. + * @see #setSpecifiedScale(int) + * @see org.eclipse.jpt.core.internal.mappings.JpaCoreMappingsPackage#getIColumn_SpecifiedScale() + * @model default="-1" + * @generated + */ + int getSpecifiedScale(); + + /** + * Sets the value of the '{@link org.eclipse.jpt.core.internal.mappings.IColumn#getSpecifiedScale Specified Scale}' attribute. + * + * + * @param value the new value of the 'Specified Scale' attribute. + * @see #getSpecifiedScale() + * @generated + */ + void setSpecifiedScale(int value); + + /** + * + * + * @model kind="operation" + * @generated + */ + int getDefaultLength(); + + /** + * + * + * @model kind="operation" + * @generated + */ + int getDefaultPrecision(); + + /** * * - * @param value the new value of the 'Scale' attribute. - * @see #getScale() + * @model kind="operation" * @generated */ - void setScale(int value); + int getDefaultScale(); void refreshDefaults(DefaultsContext defaultsContext); diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/JpaCoreMappingsPackage.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/JpaCoreMappingsPackage.java index 35eb236fa6..2cd8c084dc 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/JpaCoreMappingsPackage.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/mappings/JpaCoreMappingsPackage.java @@ -826,6 +826,15 @@ public class JpaCoreMappingsPackage extends EPackageImpl */ public static final int ICOLUMN__LENGTH = IABSTRACT_COLUMN_FEATURE_COUNT + 0; + /** + * The feature id for the 'Specified Length' attribute. + * + * + * @generated + * @ordered + */ + public static final int ICOLUMN__SPECIFIED_LENGTH = IABSTRACT_COLUMN_FEATURE_COUNT + 1; + /** * The feature id for the 'Precision' attribute. * @@ -833,7 +842,16 @@ public class JpaCoreMappingsPackage extends EPackageImpl * @generated * @ordered */ - public static final int ICOLUMN__PRECISION = IABSTRACT_COLUMN_FEATURE_COUNT + 1; + public static final int ICOLUMN__PRECISION = IABSTRACT_COLUMN_FEATURE_COUNT + 2; + + /** + * The feature id for the 'Specified Precision' attribute. + * + * + * @generated + * @ordered + */ + public static final int ICOLUMN__SPECIFIED_PRECISION = IABSTRACT_COLUMN_FEATURE_COUNT + 3; /** * The feature id for the 'Scale' attribute. @@ -842,7 +860,16 @@ public class JpaCoreMappingsPackage extends EPackageImpl * @generated * @ordered */ - public static final int ICOLUMN__SCALE = IABSTRACT_COLUMN_FEATURE_COUNT + 2; + public static final int ICOLUMN__SCALE = IABSTRACT_COLUMN_FEATURE_COUNT + 4; + + /** + * The feature id for the 'Specified Scale' attribute. + * + * + * @generated + * @ordered + */ + public static final int ICOLUMN__SPECIFIED_SCALE = IABSTRACT_COLUMN_FEATURE_COUNT + 5; /** * The number of structural features of the 'IColumn' class. @@ -851,7 +878,7 @@ public class JpaCoreMappingsPackage extends EPackageImpl * @generated * @ordered */ - public static final int ICOLUMN_FEATURE_COUNT = IABSTRACT_COLUMN_FEATURE_COUNT + 3; + public static final int ICOLUMN_FEATURE_COUNT = IABSTRACT_COLUMN_FEATURE_COUNT + 6; /** * The meta object id for the '{@link org.eclipse.jpt.core.internal.mappings.IColumnMapping IColumn Mapping}' class. @@ -4732,6 +4759,19 @@ public class JpaCoreMappingsPackage extends EPackageImpl return (EAttribute) iColumnEClass.getEStructuralFeatures().get(0); } + /** + * Returns the meta object for the attribute '{@link org.eclipse.jpt.core.internal.mappings.IColumn#getSpecifiedLength Specified Length}'. + * + * + * @return the meta object for the attribute 'Specified Length'. + * @see org.eclipse.jpt.core.internal.mappings.IColumn#getSpecifiedLength() + * @see #getIColumn() + * @generated + */ + public EAttribute getIColumn_SpecifiedLength() { + return (EAttribute) iColumnEClass.getEStructuralFeatures().get(1); + } + /** * Returns the meta object for the attribute '{@link org.eclipse.jpt.core.internal.mappings.IColumn#getPrecision Precision}'. * @@ -4742,7 +4782,20 @@ public class JpaCoreMappingsPackage extends EPackageImpl * @generated */ public EAttribute getIColumn_Precision() { - return (EAttribute) iColumnEClass.getEStructuralFeatures().get(1); + return (EAttribute) iColumnEClass.getEStructuralFeatures().get(2); + } + + /** + * Returns the meta object for the attribute '{@link org.eclipse.jpt.core.internal.mappings.IColumn#getSpecifiedPrecision Specified Precision}'. + * + * + * @return the meta object for the attribute 'Specified Precision'. + * @see org.eclipse.jpt.core.internal.mappings.IColumn#getSpecifiedPrecision() + * @see #getIColumn() + * @generated + */ + public EAttribute getIColumn_SpecifiedPrecision() { + return (EAttribute) iColumnEClass.getEStructuralFeatures().get(3); } /** @@ -4755,7 +4808,20 @@ public class JpaCoreMappingsPackage extends EPackageImpl * @generated */ public EAttribute getIColumn_Scale() { - return (EAttribute) iColumnEClass.getEStructuralFeatures().get(2); + return (EAttribute) iColumnEClass.getEStructuralFeatures().get(4); + } + + /** + * Returns the meta object for the attribute '{@link org.eclipse.jpt.core.internal.mappings.IColumn#getSpecifiedScale Specified Scale}'. + * + * + * @return the meta object for the attribute 'Specified Scale'. + * @see org.eclipse.jpt.core.internal.mappings.IColumn#getSpecifiedScale() + * @see #getIColumn() + * @generated + */ + public EAttribute getIColumn_SpecifiedScale() { + return (EAttribute) iColumnEClass.getEStructuralFeatures().get(5); } /** @@ -6594,8 +6660,11 @@ public class JpaCoreMappingsPackage extends EPackageImpl createEAttribute(iAbstractColumnEClass, IABSTRACT_COLUMN__DEFAULT_TABLE); iColumnEClass = createEClass(ICOLUMN); createEAttribute(iColumnEClass, ICOLUMN__LENGTH); + createEAttribute(iColumnEClass, ICOLUMN__SPECIFIED_LENGTH); createEAttribute(iColumnEClass, ICOLUMN__PRECISION); + createEAttribute(iColumnEClass, ICOLUMN__SPECIFIED_PRECISION); createEAttribute(iColumnEClass, ICOLUMN__SCALE); + createEAttribute(iColumnEClass, ICOLUMN__SPECIFIED_SCALE); iColumnMappingEClass = createEClass(ICOLUMN_MAPPING); iBasicEClass = createEClass(IBASIC); createEAttribute(iBasicEClass, IBASIC__FETCH); @@ -6872,9 +6941,15 @@ public class JpaCoreMappingsPackage extends EPackageImpl initEAttribute(getIAbstractColumn_SpecifiedTable(), ecorePackage.getEString(), "specifiedTable", null, 0, 1, IAbstractColumn.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getIAbstractColumn_DefaultTable(), ecorePackage.getEString(), "defaultTable", null, 0, 1, IAbstractColumn.class, !IS_TRANSIENT, !IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEClass(iColumnEClass, IColumn.class, "IColumn", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getIColumn_Length(), ecorePackage.getEInt(), "length", "255", 0, 1, IColumn.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getIColumn_Precision(), ecorePackage.getEInt(), "precision", null, 0, 1, IColumn.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getIColumn_Scale(), ecorePackage.getEInt(), "scale", null, 0, 1, IColumn.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getIColumn_Length(), ecorePackage.getEInt(), "length", null, 0, 1, IColumn.class, !IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + initEAttribute(getIColumn_SpecifiedLength(), theEcorePackage.getEInt(), "specifiedLength", "-1", 0, 1, IColumn.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getIColumn_Precision(), ecorePackage.getEInt(), "precision", null, 0, 1, IColumn.class, !IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + initEAttribute(getIColumn_SpecifiedPrecision(), theEcorePackage.getEInt(), "specifiedPrecision", "-1", 0, 1, IColumn.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getIColumn_Scale(), ecorePackage.getEInt(), "scale", null, 0, 1, IColumn.class, !IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + initEAttribute(getIColumn_SpecifiedScale(), theEcorePackage.getEInt(), "specifiedScale", "-1", 0, 1, IColumn.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + addEOperation(iColumnEClass, theEcorePackage.getEInt(), "getDefaultLength", 0, 1, IS_UNIQUE, IS_ORDERED); + addEOperation(iColumnEClass, theEcorePackage.getEInt(), "getDefaultPrecision", 0, 1, IS_UNIQUE, IS_ORDERED); + addEOperation(iColumnEClass, theEcorePackage.getEInt(), "getDefaultScale", 0, 1, IS_UNIQUE, IS_ORDERED); initEClass(iColumnMappingEClass, IColumnMapping.class, "IColumnMapping", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); addEOperation(iColumnMappingEClass, this.getIColumn(), "getColumn", 0, 1, IS_UNIQUE, IS_ORDERED); initEClass(iBasicEClass, IBasic.class, "IBasic", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); @@ -7532,6 +7607,14 @@ public class JpaCoreMappingsPackage extends EPackageImpl */ public static final EAttribute ICOLUMN__LENGTH = eINSTANCE.getIColumn_Length(); + /** + * The meta object literal for the 'Specified Length' attribute feature. + * + * + * @generated + */ + public static final EAttribute ICOLUMN__SPECIFIED_LENGTH = eINSTANCE.getIColumn_SpecifiedLength(); + /** * The meta object literal for the 'Precision' attribute feature. * @@ -7540,6 +7623,14 @@ public class JpaCoreMappingsPackage extends EPackageImpl */ public static final EAttribute ICOLUMN__PRECISION = eINSTANCE.getIColumn_Precision(); + /** + * The meta object literal for the 'Specified Precision' attribute feature. + * + * + * @generated + */ + public static final EAttribute ICOLUMN__SPECIFIED_PRECISION = eINSTANCE.getIColumn_SpecifiedPrecision(); + /** * The meta object literal for the 'Scale' attribute feature. * @@ -7548,6 +7639,14 @@ public class JpaCoreMappingsPackage extends EPackageImpl */ public static final EAttribute ICOLUMN__SCALE = eINSTANCE.getIColumn_Scale(); + /** + * The meta object literal for the 'Specified Scale' attribute feature. + * + * + * @generated + */ + public static final EAttribute ICOLUMN__SPECIFIED_SCALE = eINSTANCE.getIColumn_SpecifiedScale(); + /** * The meta object literal for the '{@link org.eclipse.jpt.core.internal.mappings.IColumnMapping IColumn Mapping}' class. * -- cgit v1.2.3 From 1933ef25f0b213c657438d8b560de62874148a8a Mon Sep 17 00:00:00 2001 From: kmoore Date: Tue, 21 Aug 2007 18:05:33 +0000 Subject: 200712 - annotations on properties are not read the first time updating from java --- .../internal/content/java/JavaPersistentType.java | 23 +++++++++------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JavaPersistentType.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JavaPersistentType.java index 8266ee960e..a73ff129be 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JavaPersistentType.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/java/JavaPersistentType.java @@ -662,28 +662,23 @@ public class JavaPersistentType extends JavaEObject implements IPersistentType } private void updatePersistentFields(CompilationUnit astRoot, List persistentAttributesToRemove) { - for (IField field : this.jdtPersistableFields()) { - JavaPersistentAttribute persistentAttribute = persistentAttributeFor(field); - if (persistentAttribute == null) { - persistentAttribute = addJavaPersistentAttribute(field); - } - else { - persistentAttributesToRemove.remove(persistentAttribute); - } - persistentAttribute.updateFromJava(astRoot); - } + updatePersistentAttributes(astRoot, persistentAttributesToRemove, this.jdtPersistableFields()); } private void updatePersistentProperties(CompilationUnit astRoot, List persistentAttributesToRemove) { - for (IMethod method : this.jdtPersistableProperties()) { - JavaPersistentAttribute persistentAttribute = persistentAttributeFor(method); + updatePersistentAttributes(astRoot, persistentAttributesToRemove, this.jdtPersistableProperties()); + } + + private void updatePersistentAttributes(CompilationUnit astRoot, List persistentAttributesToRemove, IMember[] members) { + for (IMember member : members) { + JavaPersistentAttribute persistentAttribute = persistentAttributeFor(member); if (persistentAttribute == null) { - addJavaPersistentAttribute(method); + persistentAttribute = addJavaPersistentAttribute(member); } else { persistentAttributesToRemove.remove(persistentAttribute); - persistentAttribute.updateFromJava(astRoot); } + persistentAttribute.updateFromJava(astRoot); } } -- cgit v1.2.3 From 91b3d8130f5e81f6744048e8764f7c97d2cd3588 Mon Sep 17 00:00:00 2001 From: kmoore Date: Tue, 21 Aug 2007 22:29:02 +0000 Subject: 200679 - added IColumn defaultLength, defaultPrecision, defaultScale --- .../src/org/eclipse/jpt/core/internal/content/orm/XmlColumn.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlColumn.java b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlColumn.java index fae6f916f7..bdc3d50101 100644 --- a/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlColumn.java +++ b/jpa/plugins/org.eclipse.jpt.core/src/org/eclipse/jpt/core/internal/content/orm/XmlColumn.java @@ -646,10 +646,10 @@ public class XmlColumn extends AbstractXmlColumn implements IColumn eUnset(OrmPackage.XML_COLUMN__SPECIFIED_TABLE); eUnset(OrmPackage.XML_COLUMN__COLUMN_DEFINITION); eUnset(OrmPackage.XML_COLUMN__INSERTABLE); - eUnset(OrmPackage.XML_COLUMN__LENGTH); + eUnset(OrmPackage.XML_COLUMN__SPECIFIED_LENGTH); eUnset(OrmPackage.XML_COLUMN__NULLABLE); - eUnset(OrmPackage.XML_COLUMN__PRECISION); - eUnset(OrmPackage.XML_COLUMN__SCALE); + eUnset(OrmPackage.XML_COLUMN__SPECIFIED_PRECISION); + eUnset(OrmPackage.XML_COLUMN__SPECIFIED_SCALE); eUnset(OrmPackage.XML_COLUMN__UNIQUE); eUnset(OrmPackage.XML_COLUMN__UPDATABLE); } -- cgit v1.2.3 From 81bdc83e4f3dc2f12541325ae417b02c6df5fc64 Mon Sep 17 00:00:00 2001 From: tle Date: Tue, 21 Aug 2007 23:14:28 +0000 Subject: Reverted version number. --- assembly/plugins/org.eclipse.jpt/.cvsignore | 2 +- assembly/plugins/org.eclipse.jpt/META-INF/MANIFEST.MF | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assembly/plugins/org.eclipse.jpt/.cvsignore b/assembly/plugins/org.eclipse.jpt/.cvsignore index 9a150f4dcb..c9401a2c83 100644 --- a/assembly/plugins/org.eclipse.jpt/.cvsignore +++ b/assembly/plugins/org.eclipse.jpt/.cvsignore @@ -1,2 +1,2 @@ build.xml -org.eclipse.jpt_2.0.0.* \ No newline at end of file +org.eclipse.jpt_1.0.0.* \ No newline at end of file diff --git a/assembly/plugins/org.eclipse.jpt/META-INF/MANIFEST.MF b/assembly/plugins/org.eclipse.jpt/META-INF/MANIFEST.MF index 293a9e0e63..5ac613eda7 100644 --- a/assembly/plugins/org.eclipse.jpt/META-INF/MANIFEST.MF +++ b/assembly/plugins/org.eclipse.jpt/META-INF/MANIFEST.MF @@ -2,6 +2,6 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %pluginName Bundle-SymbolicName: org.eclipse.jpt; singleton:=true -Bundle-Version: 2.0.0.qualifier +Bundle-Version: 1.0.0.qualifier Bundle-Localization: plugin Bundle-Vendor: %providerName -- cgit v1.2.3 From 39d3005720fd65f2e1671e1510e4b24bb642c71d Mon Sep 17 00:00:00 2001 From: tle Date: Tue, 21 Aug 2007 23:32:42 +0000 Subject: Reverted version number. --- assembly/features/org.eclipse.jpt/.cvsignore | 2 +- assembly/features/org.eclipse.jpt/feature.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/assembly/features/org.eclipse.jpt/.cvsignore b/assembly/features/org.eclipse.jpt/.cvsignore index 516632badf..de8b73fb72 100644 --- a/assembly/features/org.eclipse.jpt/.cvsignore +++ b/assembly/features/org.eclipse.jpt/.cvsignore @@ -1,2 +1,2 @@ build.xml -org.eclipse.jpt_2.0.0.* +org.eclipse.jpt_1.0.0.* diff --git a/assembly/features/org.eclipse.jpt/feature.xml b/assembly/features/org.eclipse.jpt/feature.xml index b4adfd9fae..fdae5614e9 100644 --- a/assembly/features/org.eclipse.jpt/feature.xml +++ b/assembly/features/org.eclipse.jpt/feature.xml @@ -2,7 +2,7 @@ -- cgit v1.2.3