https://bugs.eclipse.org/bugs/show_bug.cgi?id=73931
diff --git a/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/ProfileOperations.java b/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/ProfileOperations.java
index 0c71a6a..12c9083 100644
--- a/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/ProfileOperations.java
+++ b/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/ProfileOperations.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM - Initial API and implementation
*
- * $Id: ProfileOperations.java,v 1.8.2.4 2004/08/11 21:31:18 khussey Exp $
+ * $Id: ProfileOperations.java,v 1.8.2.5 2004/09/15 14:04:50 khussey Exp $
*/
package org.eclipse.uml2.internal.operation;
@@ -128,8 +128,9 @@
*/
public static String getEPackageName(Profile profile) {
return getValidIdentifier(isEmpty(profile.getQualifiedName())
- ? profile.getName() : profile.getQualifiedName().replace(':', '_'))
- + '_' + getVersion(profile);
+ ? profile.getName()
+ : profile.getQualifiedName().replace(':', '_')) + '_'
+ + getVersion(profile);
}
/**
@@ -142,8 +143,8 @@
*/
public static String getEClassifierName(Classifier classifier) {
return getValidIdentifier(isEmpty(classifier.getQualifiedName())
- ? classifier.getName() : classifier.getQualifiedName().replace(':',
- '_'));
+ ? classifier.getName()
+ : classifier.getQualifiedName().replace(':', '_'));
}
/**
@@ -625,9 +626,11 @@
if (Element.class.isInstance(eObject)) {
Element element = (Element) eObject;
- List appliedStereotypes = getEAnnotation(
+ EAnnotation appliedStereotypesEAnnotation = getEAnnotation(
StereotypeOperations.ANNOTATION_SOURCE__APPLIED_STEREOTYPES,
- element).getContents();
+ element);
+ List appliedStereotypes = appliedStereotypesEAnnotation
+ .getContents();
for (Iterator stereotypeApplications = getStereotypeApplications(
profile, element).iterator(); stereotypeApplications
@@ -636,19 +639,30 @@
EObject oldStereotypeApplication = (EObject) stereotypeApplications
.next();
- EClass eClass = StereotypeOperations.getEClass(
- StereotypeOperations
- .getStereotype(oldStereotypeApplication),
- profile.getVersion());
- EObject newStereotypeApplication = eClass.getEPackage()
- .getEFactoryInstance().create(eClass);
+ Stereotype stereotype = StereotypeOperations
+ .getStereotype(oldStereotypeApplication);
- copyValues(oldStereotypeApplication,
- newStereotypeApplication);
+ if (null == stereotype) {
+ appliedStereotypes.remove(oldStereotypeApplication);
+ } else {
+ EClass eClass = StereotypeOperations.getEClass(
+ stereotype, profile.getVersion());
+ EObject newStereotypeApplication = eClass
+ .getEPackage().getEFactoryInstance().create(
+ eClass);
- appliedStereotypes.set(appliedStereotypes
- .indexOf(oldStereotypeApplication),
- newStereotypeApplication);
+ copyValues(oldStereotypeApplication,
+ newStereotypeApplication);
+
+ appliedStereotypes.set(appliedStereotypes
+ .indexOf(oldStereotypeApplication),
+ newStereotypeApplication);
+ }
+ }
+
+ if (appliedStereotypes.isEmpty()) {
+ element.getEAnnotations().remove(
+ appliedStereotypesEAnnotation);
}
}
}
@@ -736,7 +750,8 @@
EObject targetValue = targetEClass.getEPackage()
.getEFactoryInstance().create(targetEClass);
copyValues((EObject) (sourceEStructuralFeature.isMany()
- ? ((EList) sourceValue).get(0) : sourceValue), targetValue);
+ ? ((EList) sourceValue).get(0)
+ : sourceValue), targetValue);
targetEObject.eSet(targetEStructuralFeature, targetValue);
}
}
@@ -777,7 +792,8 @@
.createFromString(targetEDataType, sourceEFactory
.convertToString(sourceEDataType, sourceEStructuralFeature
.isMany()
- ? ((EList) sourceValue).get(0) : sourceValue)));
+ ? ((EList) sourceValue).get(0)
+ : sourceValue)));
}
}
@@ -808,8 +824,8 @@
targetEObject.eSet(targetEStructuralFeature, targetEEnum
.getEEnumLiteral(
((EEnumLiteral) (sourceEStructuralFeature.isMany()
- ? ((EList) sourceValue).get(0) : sourceValue))
- .getName()).getInstance());
+ ? ((EList) sourceValue).get(0)
+ : sourceValue)).getName()).getInstance());
}
}
@@ -830,11 +846,9 @@
String version = getVersion(profile);
getOrCreateEAnnotation(ANNOTATION_SOURCE__ATTRIBUTES, profile)
- .getDetails().put(
- ANNOTATION_DETAILS_KEY__VERSION,
- null == version
- ? String.valueOf(0) : String.valueOf(new Integer(Integer
- .parseInt(version) + 1)));
+ .getDetails().put(ANNOTATION_DETAILS_KEY__VERSION, null == version
+ ? String.valueOf(0)
+ : String.valueOf(new Integer(Integer.parseInt(version) + 1)));
getOrCreateEAnnotation(ANNOTATION_SOURCE__E_PACKAGES, profile)
.getContents().add(0, createEPackage(profile));
@@ -955,9 +969,10 @@
element).getContents().iterator(); appliedStereotypes.hasNext();) {
EObject stereotypeApplication = (EObject) appliedStereotypes.next();
+ Stereotype stereotype = StereotypeOperations
+ .getStereotype(stereotypeApplication);
- if (profile == StereotypeOperations.getStereotype(
- stereotypeApplication).getProfile()) {
+ if (null != stereotype && profile == stereotype.getProfile()) {
stereotypeApplications.add(stereotypeApplication);
}
}
@@ -1000,7 +1015,8 @@
*/
public static boolean isDefined(Profile profile) {
return null == profile
- ? false : getEAnnotation(ANNOTATION_SOURCE__E_PACKAGES, profile)
+ ? false
+ : getEAnnotation(ANNOTATION_SOURCE__E_PACKAGES, profile)
.getContents().size() > 0;
}
diff --git a/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/StereotypeOperations.java b/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/StereotypeOperations.java
index 5746a11..59b3335 100644
--- a/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/StereotypeOperations.java
+++ b/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/StereotypeOperations.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM - Initial API and implementation
*
- * $Id: StereotypeOperations.java,v 1.10 2004/06/09 18:04:16 khussey Exp $
+ * $Id: StereotypeOperations.java,v 1.10.2.1 2004/09/15 14:04:50 khussey Exp $
*/
package org.eclipse.uml2.internal.operation;
@@ -140,8 +140,25 @@
* object.
*/
public static Stereotype getStereotype(EObject eObject) {
- return (Stereotype) getEAnnotation(ANNOTATION_SOURCE__STEREOTYPE,
- eObject.eClass()).getReferences().get(0);
+ return null == eObject
+ ? null
+ : getStereotype(eObject.eClass());
+ }
+
+ /**
+ * Retrieves the stereotype represented by the specified Ecore class.
+ *
+ * @param eClass
+ * The Ecore class for which to retrieve the stereotype.
+ * @return The stereotype represented by the Ecore class.
+ */
+ protected static Stereotype getStereotype(EClass eClass) {
+ EAnnotation stereotypeEAnnotation = getEAnnotation(
+ ANNOTATION_SOURCE__STEREOTYPE, eClass);
+
+ return stereotypeEAnnotation.getReferences().isEmpty()
+ ? null
+ : (Stereotype) stereotypeEAnnotation.getReferences().get(0);
}
/**
@@ -155,9 +172,13 @@
*/
public static EnumerationLiteral getEnumerationLiteral(
EEnumLiteral eEnumLiteral) {
- return (EnumerationLiteral) getEAnnotation(
- ANNOTATION_SOURCE__ENUMERATION_LITERAL, eEnumLiteral)
- .getReferences().get(0);
+ EAnnotation enumerationLiteralEAnnotation = getEAnnotation(
+ ANNOTATION_SOURCE__ENUMERATION_LITERAL, eEnumLiteral);
+
+ return enumerationLiteralEAnnotation.getReferences().isEmpty()
+ ? null
+ : (EnumerationLiteral) enumerationLiteralEAnnotation.getReferences()
+ .get(0);
}
/**
@@ -649,11 +670,7 @@
: eObject.eGet(eStructuralFeature));
} else {
- if (null == eObject
- && stereotype != getEAnnotation(
- ANNOTATION_SOURCE__STEREOTYPE, eClass).getReferences()
- .get(0)) {
-
+ if (null == eObject && stereotype != getStereotype(eClass)) {
throw new IllegalArgumentException(String
.valueOf(propertyName));
}
diff --git a/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/UML2Operations.java b/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/UML2Operations.java
index 2c46e8a..4b9305a 100644
--- a/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/UML2Operations.java
+++ b/deprecated/plugins/org.eclipse.uml2/src/org/eclipse/uml2/internal/operation/UML2Operations.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM - Initial API and implementation
*
- * $Id: UML2Operations.java,v 1.8 2004/06/21 21:01:36 khussey Exp $
+ * $Id: UML2Operations.java,v 1.8.2.1 2004/09/15 14:04:50 khussey Exp $
*/
package org.eclipse.uml2.internal.operation;
@@ -388,21 +388,23 @@
}
StringBuffer validIdentifier = new StringBuffer();
+ char char_0 = name.charAt(0);
- if (Character.isJavaIdentifierStart(name.charAt(0))) {
- validIdentifier.append(name.charAt(0));
+ if (Character.isJavaIdentifierStart(char_0)) {
+ validIdentifier.append(char_0);
} else {
validIdentifier.append('_');
- if (Character.isJavaIdentifierPart(name.charAt(0))) {
- validIdentifier.append(name.charAt(0));
+ if (Character.isJavaIdentifierPart(char_0)) {
+ validIdentifier.append(char_0);
}
}
for (int i = 1; i < name.length(); ++i) {
+ char char_i = name.charAt(i);
- if (Character.isJavaIdentifierPart(name.charAt(i))) {
- validIdentifier.append(name.charAt(i));
+ if (Character.isJavaIdentifierPart(char_i)) {
+ validIdentifier.append(char_i);
}
}