# HG changeset patch # User Felix Wolfsteller # Date 1317197836 0 # Node ID 6662b0ea20c12b0851be7521ac93a7aef23566b3 # Parent 3efc3942b76571998084aeb2fc91a12193ed7bf4 Added 'unbracket' StringUtil method (extracted from WaterlevelSelectState). flys-backend/trunk@2848 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 3efc3942b765 -r 6662b0ea20c1 flys-backend/ChangeLog --- a/flys-backend/ChangeLog Tue Sep 27 13:37:34 2011 +0000 +++ b/flys-backend/ChangeLog Wed Sep 28 08:17:16 2011 +0000 @@ -1,3 +1,8 @@ +2011-09-28 Felix Wolfsteller + + * src/main/java/de/intevation/flys/utils/StringUtil.java: + (unbracket): New method (extracted from WaterlevelSelectState). + 2011-09-27 Sascha L. Teichmann * src/main/java/de/intevation/flys/model/CrossSectionLine.java: diff -r 3efc3942b765 -r 6662b0ea20c1 flys-backend/src/main/java/de/intevation/flys/utils/StringUtil.java --- a/flys-backend/src/main/java/de/intevation/flys/utils/StringUtil.java Tue Sep 27 13:37:34 2011 +0000 +++ b/flys-backend/src/main/java/de/intevation/flys/utils/StringUtil.java Wed Sep 28 08:17:16 2011 +0000 @@ -23,6 +23,7 @@ import java.io.StringWriter; import java.io.PrintWriter; + public final class StringUtil { final static String NUMBER_SEPERATOR = ";"; final static String LINE_SEPERATOR = ":"; @@ -74,6 +75,29 @@ return array2D; } + /** + * Remove first occurrence of "[" and "]" (if both do occur). + * @param value String to be stripped of [] (might be null). + * @return input string but with [ and ] removed, or input string if no + * brackets were found. + */ + public static final String unbracket(String value) { + // null- guard + if (value == null) return value; + + int start = value.indexOf("["); + int end = value.indexOf("]"); + + if (start < 0 || end < 0) { + return value; + } + + value = value.substring(start + 1, end); + + return value; + } + + public static final String [] splitLines(String s) { if (s == null) { return null;