1 package org.andromda.translation.ocl.syntax;
2
3 import org.andromda.core.translation.TranslationUtils;
4
5
6
7
8
9
10 public class OCLFeatures
11 {
12
13
14
15 private static final String ALL_INSTANCES = "(\\s*\\w*\\s*(\\w+|::)*)?\\s*allInstances\\s*\\(\\s*\\)";
16
17
18
19
20 private static final String OCL_IS_KIND_OF = "oclIsKindOf\\s*\\(\\s*" + OCLPatterns.SCOPE_PATH
21 + "\\s*\\)\\s*";
22
23
24
25
26 private static final String OCL_IS_TYPE_OF = "oclIsTypeOf\\s*\\(\\s*" + OCLPatterns.SCOPE_PATH
27 + "\\s*\\)\\s*";
28
29
30
31
32 private static final String CONCAT = "concat\\s*\\(\\s*" + OCLPatterns.NAVIGATIONAL_PATH
33 + "\\s*\\)\\s*";
34
35
36
37
38 private static final String ALL_PATTERNS = ALL_INSTANCES + '|' + OCL_IS_KIND_OF + '|'
39 + OCL_IS_TYPE_OF + '|' + CONCAT;
40
41
42
43
44
45
46
47 public static boolean isAllInstances(Object expression)
48 {
49 return TranslationUtils.deleteWhitespace(expression).matches(OCLFeatures.ALL_INSTANCES);
50 }
51
52
53
54
55
56
57
58 public static boolean isConcat(Object expression)
59 {
60 return TranslationUtils.deleteWhitespace(expression).matches(OCLFeatures.CONCAT);
61 }
62
63
64
65
66
67
68
69 public static boolean isOclIsTypeOf(Object expression)
70 {
71 return TranslationUtils.deleteWhitespace(expression).matches(OCLFeatures.OCL_IS_TYPE_OF);
72 }
73
74
75
76
77
78
79
80 public static boolean isOclIsKindOf(Object expression)
81 {
82 return TranslationUtils.deleteWhitespace(expression).matches(OCLFeatures.OCL_IS_KIND_OF);
83 }
84
85
86
87
88
89
90
91
92 public static boolean isOclFeature(Object expression)
93 {
94 return TranslationUtils.deleteWhitespace(expression).matches(ALL_PATTERNS);
95 }
96
97
98
99
100 private static final String SELF = "self";
101
102
103
104
105
106
107
108
109 public static boolean isSelf(Object expression)
110 {
111 return TranslationUtils.deleteWhitespace(expression).matches(SELF);
112 }
113 }