1 | package de.uka.sdq.pcm.transformations; |
2 | |
3 | import org.eclipse.emf.ecore.EObject; |
4 | |
5 | import de.fzi.se.quality.qualityannotation.CharacterisedPCMParameterPartition; |
6 | import de.uka.ipd.sdq.pcm.seff.AbstractAction; |
7 | import de.uka.ipd.sdq.pcm.seff.ResourceDemandingSEFF; |
8 | |
9 | public class Helper { |
10 | public static String removeAllSpecialChars(String s) { |
11 | return s.replace('\n',' ').replace('\t', ' ').replace('\r', ' '); |
12 | } |
13 | |
14 | /** |
15 | * @param eObject The object. |
16 | * @return The file name of the resource containing the object. |
17 | */ |
18 | public static String getResourceFileName(ResourceDemandingSEFF eObject) { |
19 | return eObject.eResource().getURI().toFileString(); |
20 | } |
21 | |
22 | /** |
23 | * @param eObject The object. |
24 | * @return The file name of the resource containing the object. |
25 | */ |
26 | public static String getResourceFileName(CharacterisedPCMParameterPartition eObject) { |
27 | return eObject.eResource().getURI().toFileString(); |
28 | } |
29 | |
30 | /** |
31 | * @param action The action. |
32 | * @return The {@link ResourceDemandingSEFF} containing the action or {@code null} if none could be found. |
33 | */ |
34 | public static ResourceDemandingSEFF getRdseff(AbstractAction action) { |
35 | EObject src = action; |
36 | while (src.eContainer() != null && !(src instanceof ResourceDemandingSEFF)) { |
37 | src = src.eContainer(); |
38 | } |
39 | return (ResourceDemandingSEFF) src; |
40 | } |
41 | } |