1 package org.andromda.translation.ocl.syntax;
2
3 import org.andromda.core.translation.TranslationUtils;
4
5
6
7
8
9
10 public class OCLPatterns
11 {
12
13
14
15 static final String SCOPE_PATH = "[\\w+|::]+";
16
17
18
19
20 static final String NAVIGATIONAL_PATH = "[\\w*[\\.]*]+";
21
22
23
24
25
26
27
28 public static boolean isOperation(Object expression)
29 {
30 return TranslationUtils.deleteWhitespace(expression).matches(OPERATION);
31 }
32
33 private static final String OPERATION = ".+\\(.*\\).*";
34
35
36
37
38
39
40
41 public static boolean isCollectionOperationCall(Object expression)
42 {
43 return TranslationUtils.deleteWhitespace(expression).matches(COLLECTION_CALL);
44 }
45
46 private static final String COLLECTION_CALL = ".+->.+";
47
48
49
50
51
52
53
54
55 public static boolean isCollectionOperationResultNavigationalPath(Object expression)
56 {
57 return TranslationUtils.deleteWhitespace(expression).matches(COLLECTION_CALL_RESULT_NAVIGATIONAL_PATH);
58 }
59
60
61
62
63
64
65
66
67 public static boolean isNavigationalPath(Object expression)
68 {
69 return TranslationUtils.deleteWhitespace(expression).matches(NAVIGATIONAL_PATH);
70 }
71
72 private static final String COLLECTION_CALL_RESULT_NAVIGATIONAL_PATH = ".+->" + OPERATION + NAVIGATIONAL_PATH;
73
74
75
76
77 private static final String AND_OR_OR_OPERATOR = "or\\s+.*|and\\s+.*";
78
79
80
81
82
83
84
85
86 public static boolean isAndOrOrExpression(Object expression)
87 {
88 return TranslationUtils.trimToEmpty(expression).matches(AND_OR_OR_OPERATOR);
89 }
90 }