1 | public Collection<BehavioralFeature> getAllBehavioralFeatures(Object element) { | | 1 | public Collection getAllBehavioralFeatures(Object ns) { |
2 | if (!(element instanceof ModelElement)) { | | 2 | // Get Classifiers in Namespace |
3 | throw new IllegalArgumentException(); | | 3 | ArrayList features = new ArrayList(); |
4 | } | | 4 | try { |
5 | List contents = new ArrayList(); | | 5 | Collection classifiers = getAllModelElementsOfKind(ns, |
6 | List<BehavioralFeature> result = new ArrayList<BehavioralFeature>(); | | 6 | modelImpl.getMetaTypes().getClassifier()); |
7 | try { | | 7 | Iterator i = classifiers.iterator(); |
8 | contents.addAll(Model.getFacade() | | 8 | // Get Features owned by those Classifiers |
9 | .getTaggedValuesCollection(element)); | | 9 | while (i.hasNext()) { |
10 | contents.addAll(((ModelElement) element).getTemplateParameter()); | | 10 | features.addAll(modelImpl.getFacade().getFeatures(i.next())); |
11 | Iterator it = contents.iterator(); | | 11 | } |
12 | while (it.hasNext()) { | | 12 | } catch (InvalidObjectException e) { |
13 | Object o = it.next(); | | 13 | throw new InvalidElementException(e); |
14 | if (o instanceof Classifier) { | | 14 | } |
15 | Classifier clazz = (Classifier) o; | | 15 | // Select those Features which are BehavioralFeatures |
16 | if (!(clazz instanceof DataType)) { | | 16 | ArrayList behavioralfeatures = new ArrayList(); |
17 | for (Object o1 : clazz.getFeature()) { | | 17 | Iterator ii = features.iterator(); |
18 | if (o1 instanceof BehavioralFeature) { | | 18 | while (ii.hasNext()) { |
19 | result.add((BehavioralFeature) o1); | | 19 | Object f = ii.next(); |
20 | } | | 20 | if (f instanceof BehavioralFeature) { |
21 | } | | 21 | behavioralfeatures.add(f); |
22 | } | | 22 | } |
23 | } else { | | 23 | } |
24 | // TODO: 2nd next() for single hasNext() | | 24 | return behavioralfeatures; |
25 | result.addAll(getAllBehavioralFeatures(it.next())); | | 25 | } |
26 | } | | | |
27 | } | | | |
28 | } catch (InvalidObjectException e) { | | | |
29 | throw new InvalidElementException(e); | | | |
30 | } | | | |
31 | return result; | | | |
32 | } | | | |