01: package newprocess.validation;
02:
03: import java.util.Iterator;
04:
05: import newprocess.Actor;
06:
07: import org.eclipse.emf.common.util.EList;
08:
09: /**
10: * @author sh
11: *
12: */
13: public class ActorValidatorImpl implements ActorValidator {
14:
15: // singleton
16: public static final ActorValidatorImpl INSTANCE = new ActorValidatorImpl();
17:
18: /**
19: * validates the name of the Actor
20: * @param act
21: * @return
22: */
23: public boolean validateName(Actor act) {
24: String actName = act.getName();
25: if (actName == null || actName == "")
26: return false;
27:
28: // uniqueness check
29: EList<Actor> actors = ((newprocess.Process) act.eContainer())
30: .getHasActors();
31: for (Iterator iterator = actors.iterator(); iterator.hasNext();) {
32: Actor actor = (Actor) iterator.next();
33: if (actor == act)
34: continue;
35: String curName = actor.getName();
36: if (curName != null && curName.equals(actName))
37: return false;
38: }
39: return true;
40: }
41:
42: /**
43: * validates the implementation of the Actor
44: * @param act
45: * @return
46: */
47: public boolean validateImplementation(Actor act) {
48: if (ImplementationValidator.INSTANCE.validate(act))
49: return true;
50: return false;
51: }
52: }
|