001: package org.concern.model;
002:
003: import org.concern.model.parser.ParseException;
004:
005: public abstract class Activity extends Element implements
006: Implementable, Interactable {
007:
008: String implementation;
009: String precondition;
010: String postcondition;
011: Interaction interaction;
012: boolean reentrant;
013:
014: private transient SimpleNegatedFormVisitor simpleNegatedFormVisitor = new SimpleNegatedFormVisitor();
015:
016: public Activity() {
017: super (null);
018: }
019:
020: public Activity(String name) {
021: super (name);
022: }
023:
024: public Activity(String name, String implementation) {
025: super (name);
026: this .implementation = implementation;
027: }
028:
029: public String getImplementation() {
030: return implementation;
031: }
032:
033: public void setImplementation(String implementation) {
034: Object old = this .implementation;
035: this .implementation = implementation;
036: changes.firePropertyChange("implementation", old,
037: implementation);
038: }
039:
040: public String getPrecondition() {
041: return precondition;
042: }
043:
044: public void setPrecondition(String precondition) {
045: try {
046: precondition = getSimpleNegatedFormVisitor()
047: .transformCondition(precondition);
048: } catch (ParseException e) {
049: throw new RuntimeException(e);
050: }
051: Object old = this .precondition;
052: this .precondition = precondition;
053: changes.firePropertyChange("precondition", old, precondition);
054: }
055:
056: public String getPostcondition() {
057: return postcondition;
058: }
059:
060: public void setPostcondition(String postcondition) {
061: try {
062: postcondition = getSimpleNegatedFormVisitor()
063: .transformCondition(postcondition);
064: } catch (ParseException e) {
065: throw new RuntimeException(e);
066: }
067: Object old = this .postcondition;
068: this .postcondition = postcondition;
069: changes.firePropertyChange("postcondition", old, postcondition);
070: }
071:
072: public Interaction getInteraction() {
073: return interaction;
074: }
075:
076: public void setInteraction(Interaction interaction) {
077: Object old = this .interaction;
078: this .interaction = interaction;
079: changes.firePropertyChange("interaction", old, interaction);
080: }
081:
082: public boolean isReentrant() {
083: return reentrant;
084: }
085:
086: public void setReentrant(boolean reentrant) {
087: boolean old = this .reentrant;
088: this .reentrant = reentrant;
089: changes.firePropertyChange("reentrant", old, reentrant);
090: }
091:
092: private SimpleNegatedFormVisitor getSimpleNegatedFormVisitor() {
093: if (simpleNegatedFormVisitor == null)
094: simpleNegatedFormVisitor = new SimpleNegatedFormVisitor();
095: return simpleNegatedFormVisitor;
096: }
097:
098: public Object clone() {
099: Interactable interactable = (Interactable) super .clone();
100: if (interaction != null)
101: interactable.setInteraction((Interaction) getInteraction()
102: .clone());
103: return interactable;
104: }
105:
106: }
|