Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/utils/InputValidator.java @ 171:7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
gnv-artifacts/trunk@208 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Fri, 09 Oct 2009 07:54:48 +0000 |
parents | 820238357bab |
children | 1b2fc94766c9 |
comparison
equal
deleted
inserted
replaced
170:7be22e76c270 | 171:7fb9441dd8af |
---|---|
8 | 8 |
9 import de.intevation.gnv.geobackend.util.DateUtils; | 9 import de.intevation.gnv.geobackend.util.DateUtils; |
10 | 10 |
11 /** | 11 /** |
12 * @author Tim Englich <tim.englich@intevation.de> | 12 * @author Tim Englich <tim.englich@intevation.de> |
13 * | 13 * |
14 */ | 14 */ |
15 public class InputValidator { | 15 public class InputValidator { |
16 /** | 16 /** |
17 * the logger, used to log exceptions and additonaly information | 17 * the logger, used to log exceptions and additonaly information |
18 */ | 18 */ |
22 * Constructor | 22 * Constructor |
23 */ | 23 */ |
24 public InputValidator() { | 24 public InputValidator() { |
25 super(); | 25 super(); |
26 } | 26 } |
27 | 27 |
28 public boolean isInputValid(String input, String type){ | 28 public boolean isInputValid(String input, String type) { |
29 log.debug("InputValidator.isInputValid " + input+ " "+type); | 29 log.debug("InputValidator.isInputValid " + input + " " + type); |
30 boolean returnValue = false; | 30 boolean returnValue = false; |
31 String[] values = input.split(","); | 31 String[] values = input.split(","); |
32 for (int i = 0; i < values.length; i++){ | 32 for (int i = 0; i < values.length; i++) { |
33 boolean valid; | 33 boolean valid; |
34 if ("Integer".equalsIgnoreCase(type)){ | 34 if ("Integer".equalsIgnoreCase(type)) { |
35 valid = GenericValidator.isInt(values[i].trim()); | 35 valid = GenericValidator.isInt(values[i].trim()); |
36 }else if ("Double".equalsIgnoreCase(type)){ | 36 } else if ("Double".equalsIgnoreCase(type)) { |
37 valid = GenericValidator.isDouble(values[i].trim()); | 37 valid = GenericValidator.isDouble(values[i].trim()); |
38 }else if ("String".equalsIgnoreCase(type)){ | 38 } else if ("String".equalsIgnoreCase(type)) { |
39 valid = GenericValidator.matchRegexp(values[i], "[a-zA-Z0-9]"); // TODO: FIXME: VALIDATE REGEXP | 39 valid = GenericValidator.matchRegexp(values[i], "[a-zA-Z0-9]"); // TODO: |
40 }else if ("Date".equalsIgnoreCase(type)){ | 40 // FIXME: |
41 valid = GenericValidator.isDate(values[i].trim(), DateUtils.DATE_PATTERN, true); | 41 // VALIDATE |
42 }else if ("Point".equalsIgnoreCase(type)){ | 42 // REGEXP |
43 valid = GenericValidator.matchRegexp(values[i], "[0-9]"); // TODO: FIXME: VALIDATE REGEXP | 43 } else if ("Date".equalsIgnoreCase(type)) { |
44 }else if ("AttributeName".equalsIgnoreCase(type)){ | 44 valid = GenericValidator.isDate(values[i].trim(), |
45 valid = org.apache.commons.validator.GenericValidator.matchRegexp(values[i], "[a-zA-Z0-9]"); // TODO: FIXME: VALIDATE REGEXP | 45 DateUtils.DATE_PATTERN, true); |
46 }else{ | 46 } else if ("Point".equalsIgnoreCase(type)) { |
47 valid = GenericValidator.matchRegexp(values[i], "[0-9]"); // TODO: | |
48 // FIXME: | |
49 // VALIDATE | |
50 // REGEXP | |
51 } else if ("AttributeName".equalsIgnoreCase(type)) { | |
52 valid = org.apache.commons.validator.GenericValidator | |
53 .matchRegexp(values[i], "[a-zA-Z0-9]"); // TODO: FIXME: | |
54 // VALIDATE | |
55 // REGEXP | |
56 } else { | |
47 valid = false; | 57 valid = false; |
48 } | 58 } |
49 if (!valid){ | 59 if (!valid) { |
50 returnValue = false; | 60 returnValue = false; |
51 break; | 61 break; |
52 }else{ | 62 } else { |
53 returnValue = true; | 63 returnValue = true; |
54 } | 64 } |
55 } | 65 } |
56 log.debug("Is valid? "+returnValue); | 66 log.debug("Is valid? " + returnValue); |
57 return returnValue; | 67 return returnValue; |
58 } | 68 } |
59 | 69 |
60 } | 70 } |