01: package org.andromda.metafacades.emf.uml2;
02:
03: import java.util.List;
04:
05: import org.andromda.core.translation.Expression;
06: import org.andromda.core.translation.ExpressionTranslator;
07: import org.andromda.metafacades.uml.UMLMetafacadeUtils;
08: import org.andromda.translation.ocl.ExpressionKinds;
09:
10: /**
11: * MetafacadeLogic implementation for
12: * org.andromda.metafacades.uml.ConstraintFacade.
13: *
14: * @see org.andromda.metafacades.uml.ConstraintFacade
15: */
16: public class ConstraintFacadeLogicImpl extends ConstraintFacadeLogic {
17: public ConstraintFacadeLogicImpl(
18: final org.eclipse.uml2.Constraint metaObject,
19: final String context) {
20: super (metaObject, context);
21: }
22:
23: /**
24: * @see org.andromda.metafacades.uml.ConstraintFacade#getBody()
25: */
26: protected java.lang.String handleGetBody() {
27: String body = null;
28: if (this .metaObject.getSpecification() != null) {
29: body = this .metaObject.getSpecification().stringValue();
30: }
31: return body;
32: }
33:
34: /**
35: * @see org.andromda.metafacades.uml.ConstraintFacade#isInvariant()
36: */
37: protected boolean handleIsInvariant() {
38: return UMLMetafacadeUtils.isConstraintKind(this .getBody(),
39: ExpressionKinds.INV);
40: }
41:
42: /**
43: * @see org.andromda.metafacades.uml.ConstraintFacade#isPreCondition()
44: */
45: protected boolean handleIsPreCondition() {
46: return UMLMetafacadeUtils.isConstraintKind(this .getBody(),
47: ExpressionKinds.PRE);
48: }
49:
50: /**
51: * @see org.andromda.metafacades.uml.ConstraintFacade#isPostCondition()
52: */
53: protected boolean handleIsPostCondition() {
54: return UMLMetafacadeUtils.isConstraintKind(this .getBody(),
55: ExpressionKinds.POST);
56: }
57:
58: /**
59: * @see org.andromda.metafacades.uml.ConstraintFacade#isDefinition()
60: */
61: protected boolean handleIsDefinition() {
62: return UMLMetafacadeUtils.isConstraintKind(this .getBody(),
63: ExpressionKinds.DEF);
64: }
65:
66: /**
67: * @see org.andromda.metafacades.uml.ConstraintFacade#isBodyExpression()
68: */
69: protected boolean handleIsBodyExpression() {
70: return UMLMetafacadeUtils.isConstraintKind(this .getBody(),
71: ExpressionKinds.BODY);
72: }
73:
74: /**
75: * @see org.andromda.metafacades.uml.ConstraintFacade#getTranslation(java.lang.String)
76: */
77: protected java.lang.String handleGetTranslation(
78: final java.lang.String language) {
79: final Expression expression = ExpressionTranslator.instance()
80: .translate(language, this .getBody(),
81: this .getContextElement());
82: return expression == null ? null : expression
83: .getTranslatedExpression();
84: }
85:
86: /**
87: * @see org.andromda.metafacades.uml.ConstraintFacade#getContextElement()
88: */
89: protected java.lang.Object handleGetContextElement() {
90: Object element = null;
91: final List elements = this .metaObject.getConstrainedElements();
92: if (elements != null && !elements.isEmpty()) {
93: element = elements.get(0);
94: }
95: return element;
96: }
97: }
|