01: package newprocess.validation;
02:
03: import java.util.Iterator;
04:
05: import newprocess.Condition;
06:
07: import org.eclipse.emf.common.util.EList;
08:
09: /**
10: * validate conditions
11: * @author sh
12: *
13: */
14: public class ConditionValidatorImpl implements ConditionValidator {
15:
16: // singelton
17: public static ConditionValidatorImpl INSTANCE = new ConditionValidatorImpl();
18:
19: /**
20: * check if the conditions has a correct name
21: *
22: * @param
23: * @author sh
24: */
25: public boolean validateName(Condition con) {
26: String conName = con.getName();
27: // name check
28: if (conName == null || conName == "")
29: return false;
30:
31: // uniqueness check
32: if (con.eContainer() instanceof Process) {
33: EList<Condition> conditions = ((newprocess.Process) con
34: .eContainer()).getHasGlobals().getHasCondition();
35: for (Iterator<Condition> iterator = conditions.iterator(); iterator
36: .hasNext();) {
37: Condition aktCond = (Condition) iterator.next();
38: if (aktCond == con)
39: continue;
40:
41: String itName = aktCond.getName();
42: if (itName.equals(conName))
43: return false;
44: }
45: }
46: return true;
47: }
48:
49: /**
50: * determinate the correctness of implementation property
51: *
52: * @param con
53: * @author sh
54: */
55: public boolean validateImplementation(Condition con) {
56: if (ImplementationValidator.INSTANCE.validate(con))
57: return true;
58: return false;
59: }
60: }
|