Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/utils/InputValidator.java @ 787:6cd8492019d8
Validate wkt string and display error messages if the validation failed (issue214).
gnv-artifacts/trunk@869 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 30 Mar 2010 16:51:20 +0000 |
parents | e764cab8c885 |
children | feae2f9d6c6f |
comparison
equal
deleted
inserted
replaced
786:c907636c0288 | 787:6cd8492019d8 |
---|---|
63 return returnValue; | 63 return returnValue; |
64 } | 64 } |
65 | 65 |
66 public static boolean isInputValid(String input, String type) { | 66 public static boolean isInputValid(String input, String type) { |
67 log.debug("InputValidator.isInputValid " + input + " " + type); | 67 log.debug("InputValidator.isInputValid " + input + " " + type); |
68 | |
69 // Let's check polygons and linestrings first, because they might | |
70 // contain comma. A splitting at comma characters wouldn't be good here. | |
71 if ("Polygon".equalsIgnoreCase(type) || "Linestring".equalsIgnoreCase(type)) | |
72 { | |
73 try { | |
74 WKTReader reader = new WKTReader(); | |
75 reader.read(input); | |
76 | |
77 return true; | |
78 } | |
79 catch (ParseException pe) { | |
80 log.warn(pe, pe); | |
81 return false; | |
82 } | |
83 } | |
84 | |
85 // Check all the other input here | |
68 boolean returnValue = false; | 86 boolean returnValue = false; |
69 String[] values = input.split(","); | 87 String[] values = input.split(","); |
88 | |
70 for (int i = 0; i < values.length; i++) { | 89 for (int i = 0; i < values.length; i++) { |
71 boolean valid; | 90 boolean valid; |
72 | 91 |
73 if (NODATASELECTEDVALUE.equals(values[i].trim())){ | 92 if (NODATASELECTEDVALUE.equals(values[i].trim())){ |
74 valid = true; | 93 valid = true; |