01: /**
02: *
03: */package newprocess.validation;
04:
05: import org.eclipse.core.runtime.IStatus;
06: import org.eclipse.jdt.core.JavaConventions;
07: import org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
08:
09: /**
10: * This validator is used by the EnvEntryValidatorImpl to determinate the correctness of
11: * type properties.
12: *
13: * A type has to be a simple idetifier.
14: *
15: * @author sh
16: */
17: public class EnvEntryValidatorImpl implements EnvEntryValidator {
18:
19: // singleton
20: public static final EnvEntryValidatorImpl INSTANCE = new EnvEntryValidatorImpl();
21:
22: // deafault types available for the environment entry type property
23: public static final String[] TYPES = new String[] { "boolean",
24: "byte", "char", "String", "short", "int", "long", "float",
25: "double" };
26:
27: /* (non-Javadoc)
28: * @see newprocess.validation.EnvEntryValidator#validate()
29: */
30: @Override
31: public String validate() {
32: return null;
33: }
34:
35: /* (non-Javadoc)
36: * @see newprocess.validation.EnvEntryValidator#validateName(java.lang.String)
37: */
38: @Override
39: public String validateName(String value) {
40: return null;
41: }
42:
43: /* (non-Javadoc)
44: * @see newprocess.validation.EnvEntryValidator#validateType(java.lang.String)
45: */
46: @Override
47: public String validateType(String value) {
48: // check if the selected value exists in the default type collection
49: boolean contained = false;
50: for (int j = 0; j < TYPES.length; j++) {
51: String type = TYPES[j];
52: if (type.equals(value))
53: contained = true;
54: }
55:
56: // if not, check if the current value is valid
57: if (!contained) {
58: IStatus status = JavaConventions.validateJavaTypeName(
59: value, CompilerOptions.VERSION_1_3,
60: CompilerOptions.VERSION_1_3);
61: if (status.isOK())
62: return null;
63: else if (status.ERROR == IStatus.ERROR) {
64: return status.getMessage();
65: }
66: }
67: return null;
68: }
69:
70: /* (non-Javadoc)
71: * @see newprocess.validation.EnvEntryValidator#validateValue(java.lang.String)
72: */
73: @Override
74: public String validateValue(String value) {
75: return null;
76: }
77: }
|