Author: tfmorris
Date: 2007-10-10 16:57:31-0700
New Revision: 13659
Modified:
trunk/src/model-mdr/src/org/argouml/model/mdr/ModelManagementHelperMDRImpl.java
Log:
Switch from Vector to List in public API methods
Modified: trunk/src/model-mdr/src/org/argouml/model/mdr/ModelManagementHelperMDRImpl.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/model-mdr/src/org/argouml/model/mdr/ModelManagementHelperMDRImpl.java?view=diff&rev=13659&p1=trunk/src/model-mdr/src/org/argouml/model/mdr/ModelManagementHelperMDRImpl.java&p2=trunk/src/model-mdr/src/org/argouml/model/mdr/ModelManagementHelperMDRImpl.java&r1=13658&r2=13659
==============================================================================
--- trunk/src/model-mdr/src/org/argouml/model/mdr/ModelManagementHelperMDRImpl.java (original)
+++ trunk/src/model-mdr/src/org/argouml/model/mdr/ModelManagementHelperMDRImpl.java 2007-10-10 16:57:31-0700
@@ -36,6 +36,7 @@
import javax.jmi.model.MofClass;
import javax.jmi.reflect.InvalidObjectException;
import javax.jmi.reflect.RefClass;
+import javax.jmi.reflect.RefObject;
import javax.jmi.reflect.RefPackage;
import org.argouml.model.InvalidElementException;
@@ -44,6 +45,7 @@
import org.omg.uml.behavioralelements.commonbehavior.Instance;
import org.omg.uml.foundation.core.BehavioralFeature;
import org.omg.uml.foundation.core.Classifier;
+import org.omg.uml.foundation.core.Element;
import org.omg.uml.foundation.core.GeneralizableElement;
import org.omg.uml.foundation.core.ModelElement;
import org.omg.uml.foundation.core.Namespace;
@@ -326,24 +328,23 @@
return vmes;
}
-
+ @Deprecated
public Object getElement(Vector path, Object theRootNamespace) {
- ModelElement root = (ModelElement) theRootNamespace;
- Object name;
- int i;
+ return getElement((List) path, theRootNamespace);
+ }
+ public Object getElement(List<String> path, Object theRootNamespace) {
+ ModelElement root = (ModelElement) theRootNamespace;
// TODO: This is very inefficient. Investigate a direct method - tfm
- for (i = 0; i < path.size(); i++) {
+ for (int i = 0; i < path.size(); i++) {
if (root == null || !(root instanceof Namespace)) {
return null;
}
- name = path.get(i);
- Iterator it = ((Namespace) root).getOwnedElement().iterator();
+ String name = path.get(i);
root = null;
- while (it.hasNext()) {
- ModelElement me = (ModelElement) it.next();
+ for (ModelElement me : ((Namespace) root).getOwnedElement()) {
if (i < path.size() - 1 && !(me instanceof Namespace)) {
continue;
}
@@ -355,15 +356,14 @@
}
return root;
}
-
- public Vector getPath(Object element) {
- Vector path;
+ public Vector<String> getPath(Object element) {
+ Vector<String> path;
// TODO: This only returns the path to the innermost nested Model.
// We should have a version that returns the full path. - tfm
if (element == null || element instanceof Model) {
- return new Vector();
+ return new Vector<String>();
}
path = getPath(modelImpl.getFacade().getModelElementContainer(element));
@@ -372,6 +372,21 @@
return path;
}
+ public List<String> getPathList(Object element) {
+
+ if (element == null) {
+ return new ArrayList<String>();
+ }
+ if (!(element instanceof RefObject)) {
+ throw new IllegalArgumentException();
+ }
+
+ List<String> path = getPathList(((RefObject) element)
+ .refImmediateComposite());
+ path.add(modelImpl.getFacade().getName(element));
+
+ return path;
+ }
public Object getCorrespondingElement(Object elem, Object model) {
return getCorrespondingElement(elem, model, true);
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.