Mercurial > dive4elements > gnv-client
diff 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 |
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/utils/InputValidator.java Tue Mar 30 14:16:07 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/utils/InputValidator.java Tue Mar 30 16:51:20 2010 +0000 @@ -65,8 +65,27 @@ public static boolean isInputValid(String input, String type) { log.debug("InputValidator.isInputValid " + input + " " + type); + + // Let's check polygons and linestrings first, because they might + // contain comma. A splitting at comma characters wouldn't be good here. + if ("Polygon".equalsIgnoreCase(type) || "Linestring".equalsIgnoreCase(type)) + { + try { + WKTReader reader = new WKTReader(); + reader.read(input); + + return true; + } + catch (ParseException pe) { + log.warn(pe, pe); + return false; + } + } + + // Check all the other input here boolean returnValue = false; String[] values = input.split(","); + for (int i = 0; i < values.length; i++) { boolean valid;