edu.cmu.sei.aadl.modelsupport.util
Class AadlUtil

java.lang.Object
  extended by edu.cmu.sei.aadl.modelsupport.util.AadlUtil

public final class AadlUtil
extends java.lang.Object

Static utility methods for processing AADL meta model objects.

Author:
phf

Method Summary
static boolean canImplement(ComponentImplementation impl, ComponentType type)
          Check to see that a component type and a component implementation have the same category
static boolean canImplement(FlowImplementation fi, FlowSpecification fs)
          Check whether the flow specification and flow implementation are both flow paths, flow sources, or flow sinks
static
<T extends org.eclipse.emf.ecore.EObject>
java.util.List<T>
copyList(java.util.List<? extends T> list)
          Returns a list of the self-contained copies of each EObject in the given list.
static int countElementsBySubclass(Element root, java.lang.Class clazz)
          For the subtree rooted at the given node, count the number of model elements whose class extends from the given model element type.
static ConnectionInstance findConnectionInstance(InstanceObject src, InstanceObject dst)
          find the connection instance with src as its source and dst as its destination
static org.eclipse.emf.common.util.EList<NamedElement> findDoubleNamedElementsInList(java.util.List<?> el)
          Check to see if all NamedElements in the Elist have a unique name.
static Element findElement(Element modelelement, int location)
          Find the Element whose location reference is close to the line number.
static org.eclipse.emf.ecore.EClass findMetaModelClass(java.lang.String classname)
          find Meta model class object in meta model packages
static NamedElement findNamedElementInList(java.util.List<?> el, java.lang.String name)
          find (first) Named Element matching name in the Elist; any elements that are not NamedElements are skipped.
static org.eclipse.emf.common.util.EList<NamedElement> findNamedElementsInList(java.util.List<?> el, java.lang.String name)
          find all Named Elements matching name in the Elist; any elements that are not NamedElements are skipped.
static org.eclipse.emf.common.util.EList<ComponentImplementation> getAllComponentImpl()
          Get all component implementations; in all anon. name spaces and from all packages (public and private parts)
static org.eclipse.emf.common.util.EList<Property> getAllPropertyDefinitions()
          Get all the property definitions.
static org.eclipse.emf.common.util.EList<Property> getAllUsedPropertyDefinition(SystemImplementation si)
          Get all property definitions that are used in the Aadl model.
static Element getElement(java.lang.Object object)
          Try to generate an Element from an object.
static org.eclipse.emf.common.util.EList<FeatureGroupConnection> getFeatureGroupConnection(java.util.Collection<?> portconn)
          extract the set of feature group connections from the list of connections
static Element getInstanceOrigin(InstanceObject io)
           
static java.lang.String getName(org.eclipse.emf.common.util.URI uri)
          extracts the name of the model object referenced by the uri The name is looked up if the uri format is that of AADL XPath returns null if the uri points to an unnamed model object
static org.eclipse.emf.common.util.EList<FeatureGroupConnection> getPortGroupConnection(java.util.Collection<? extends Connection> portconn)
          extract the set of feature group connections from the list of connections
static java.lang.String getQualifiedClassName(java.lang.String classname)
          find Meta model class in meta model packages
static java.lang.String getQualifiedName(org.eclipse.emf.common.util.URI uri)
           
static boolean hasOutgoingPortSubcomponents(org.eclipse.emf.common.util.EList<? extends ComponentInstance> subcompinstances)
          determine whether a component instance has subcomponents that can have outgoing connections
static boolean hasPortComponents(ComponentImplementation compimpl)
          determine whether a component instance has subcomponents with ports
static boolean isOutgoingPort(Feature f)
          determine whether the feature is an outgoing port or feature group
static void makeSureFoldersExist(org.eclipse.core.runtime.IPath path)
          make sure the parent folders exist.
static boolean matchingClassifier(Classifier source, Classifier dest)
          check to see that the source classifier matches that of the destination implementations must be the same, types must be the same; if the source is an implementation and the destination is a type their types must match In case of the feature group the feature group types must match
static boolean oncePerMode(java.util.List<? extends ModalElement> list, java.util.List<? extends Mode> allModes)
          Check to ensure that there is at most one list element per mode
static boolean sameCategory(Subcomponent sub, ComponentClassifier c)
          Check to see if the category of the subcomponent and the classifier match
static boolean sameEClass(org.eclipse.emf.ecore.EObject c1, org.eclipse.emf.ecore.EObject c2)
          Compare the EClass of the two EObjects
static boolean uniqueNamedElementList(java.util.List<?> el)
          Check to see if all NamedElements in the Elist have a unique name.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

findNamedElementInList

public static NamedElement findNamedElementInList(java.util.List<?> el,
                                                  java.lang.String name)
find (first) Named Element matching name in the Elist; any elements that are not NamedElements are skipped.

Parameters:
el - Elist of NamedElements
name - String
Returns:
NamedElement

findNamedElementsInList

public static org.eclipse.emf.common.util.EList<NamedElement> findNamedElementsInList(java.util.List<?> el,
                                                                                      java.lang.String name)
find all Named Elements matching name in the Elist; any elements that are not NamedElements are skipped.

Parameters:
el - Elist of NamedElements
name - String
Returns:
EList of NamedElements that match the name

findDoubleNamedElementsInList

public static org.eclipse.emf.common.util.EList<NamedElement> findDoubleNamedElementsInList(java.util.List<?> el)
Check to see if all NamedElements in the Elist have a unique name. The list can contain object that are not NamedElements. This implementation utilizes List Iterators.

Parameters:
el - EList or NamedElements or other objects
Returns:
EList of NameElements that are defining a previously defined name

uniqueNamedElementList

public static boolean uniqueNamedElementList(java.util.List<?> el)
Check to see if all NamedElements in the Elist have a unique name. The list can contain object that are not NamedElements. This implementation utilizes List Iterators.

Parameters:
el - EList or NamedELements or other objects
Returns:
boolean true if the list is unique.

sameEClass

public static boolean sameEClass(org.eclipse.emf.ecore.EObject c1,
                                 org.eclipse.emf.ecore.EObject c2)
Compare the EClass of the two EObjects

Parameters:
c1 - EObject
c2 - EObject
Returns:
true if their EClasses are the same

oncePerMode

public static boolean oncePerMode(java.util.List<? extends ModalElement> list,
                                  java.util.List<? extends Mode> allModes)
Check to ensure that there is at most one list element per mode

Parameters:
list - list of ModeMembers
Returns:
true if at most one element per mode

canImplement

public static boolean canImplement(FlowImplementation fi,
                                   FlowSpecification fs)
Check whether the flow specification and flow implementation are both flow paths, flow sources, or flow sinks

Parameters:
fi - flow implementation
fs - flow specification
Returns:
true if the both are paths, or both sources, or both sinks

canImplement

public static boolean canImplement(ComponentImplementation impl,
                                   ComponentType type)
Check to see that a component type and a component implementation have the same category

Parameters:
impl - ComponentImplementation
type - ComponentType
Returns:
true if their categories match

sameCategory

public static boolean sameCategory(Subcomponent sub,
                                   ComponentClassifier c)
Check to see if the category of the subcomponent and the classifier match

Parameters:
sub - Subcomponent
c - ComponentClassifier
Returns:
true if the categories match

matchingClassifier

public static boolean matchingClassifier(Classifier source,
                                         Classifier dest)
check to see that the source classifier matches that of the destination implementations must be the same, types must be the same; if the source is an implementation and the destination is a type their types must match In case of the feature group the feature group types must match

Parameters:
source - Classifier
dest - Classifier
Returns:
true if their classifiers match

getFeatureGroupConnection

public static org.eclipse.emf.common.util.EList<FeatureGroupConnection> getFeatureGroupConnection(java.util.Collection<?> portconn)
extract the set of feature group connections from the list of connections

Parameters:
portconn - list of port connections
Returns:
list of feature group connections

copyList

public static <T extends org.eclipse.emf.ecore.EObject> java.util.List<T> copyList(java.util.List<? extends T> list)
Returns a list of the self-contained copies of each EObject in the given list.

Parameters:
list - the list of objects to copy.
Returns:
the list of copies.
See Also:
EcoreUtil.copy(org.eclipse.emf.ecore.EObject)

getElement

public static Element getElement(java.lang.Object object)
Try to generate an Element from an object. This method is intended to be used with objects that obtained from a selection event, i.e., from the ISelectionChangedListener.selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) method.

If the object is an Element, it is returned. Otherwise, the method tries to adapt the object to an Element.

Parameters:
object - The object to get an Element from.
Returns:
The Element, or null if no Element can be obtained from the given object.

getQualifiedClassName

public static java.lang.String getQualifiedClassName(java.lang.String classname)
find Meta model class in meta model packages

Parameters:
classname - the class name to be qualified with the package name
Returns:
String qualified class name

findMetaModelClass

public static org.eclipse.emf.ecore.EClass findMetaModelClass(java.lang.String classname)
find Meta model class object in meta model packages

Parameters:
classname - the class name to be found
Returns:
EClass classs object

findElement

public static Element findElement(Element modelelement,
                                  int location)
Find the Element whose location reference is close to the line number.

Parameters:
modelelement - The model element used as root of the search
location - line number
Returns:
Element

getQualifiedName

public static java.lang.String getQualifiedName(org.eclipse.emf.common.util.URI uri)

getName

public static java.lang.String getName(org.eclipse.emf.common.util.URI uri)
extracts the name of the model object referenced by the uri The name is looked up if the uri format is that of AADL XPath returns null if the uri points to an unnamed model object

Parameters:
uri - refering to a model object
Returns:
String name or null

getInstanceOrigin

public static Element getInstanceOrigin(InstanceObject io)

countElementsBySubclass

public static int countElementsBySubclass(Element root,
                                          java.lang.Class clazz)
For the subtree rooted at the given node, count the number of model elements whose class extends from the given model element type. For example,
 int numSubs = AadlUtil.countElementsBySubclass(root, Subcomponent.class);
 

Parameters:
root - The root of the subtree.
clazz - The class to count instances of.
Returns:
The number of model elements in the given subtree that are instances of the given class or one of its subclasses.

hasPortComponents

public static boolean hasPortComponents(ComponentImplementation compimpl)
determine whether a component instance has subcomponents with ports

Parameters:
subcompinstances - list of sub component instances

makeSureFoldersExist

public static void makeSureFoldersExist(org.eclipse.core.runtime.IPath path)
make sure the parent folders exist. If not they will be created. The final/last element is not tested

Parameters:
path -

getAllPropertyDefinitions

public static org.eclipse.emf.common.util.EList<Property> getAllPropertyDefinitions()
Get all the property definitions.


hasOutgoingPortSubcomponents

public static boolean hasOutgoingPortSubcomponents(org.eclipse.emf.common.util.EList<? extends ComponentInstance> subcompinstances)
determine whether a component instance has subcomponents that can have outgoing connections

Parameters:
subcompinstances - list of sub component instances

isOutgoingPort

public static boolean isOutgoingPort(Feature f)
determine whether the feature is an outgoing port or feature group

Parameters:
f - Feature
Returns:
boolean true if outgoing

getPortGroupConnection

public static org.eclipse.emf.common.util.EList<FeatureGroupConnection> getPortGroupConnection(java.util.Collection<? extends Connection> portconn)
extract the set of feature group connections from the list of connections

Parameters:
portconn - list of port connections
Returns:
list of feature group connections

findConnectionInstance

public static ConnectionInstance findConnectionInstance(InstanceObject src,
                                                        InstanceObject dst)
find the connection instance with src as its source and dst as its destination

Parameters:
src - InstanceObject
dst - InstanceObject
Returns:
ConnectionInstance or null if not found

getAllUsedPropertyDefinition

public static org.eclipse.emf.common.util.EList<Property> getAllUsedPropertyDefinition(SystemImplementation si)
Get all property definitions that are used in the Aadl model. This includes the predeclared properties and any property definitions in user declared property sets.

Parameters:
si - System Implementation
Returns:
property definitions

getAllComponentImpl

public static org.eclipse.emf.common.util.EList<ComponentImplementation> getAllComponentImpl()
Get all component implementations; in all anon. name spaces and from all packages (public and private parts)

Returns:
EList of component impl