Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.java @ 5540:25c2505df28f
Merged
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Wed, 03 Apr 2013 16:00:21 +0200 |
parents | e1cd77ddcbc4 |
children |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.java Wed Apr 03 15:59:01 2013 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.java Wed Apr 03 16:00:21 2013 +0200 @@ -149,17 +149,16 @@ public int getRiverId() { if (riverId == 0) { - String ids = artifact.getDataAsString("ids"); - String[] parts = ids.split(";"); + String rid = getIdPart(0); try { - riverId = Integer.parseInt(parts[0]); + riverId = Integer.parseInt(rid); } catch (NumberFormatException nfe) { - logger.error("Cannot parse river id from '" + parts[0] + "'"); + logger.error("Cannot parse river id from '" + + artifact.getDataAsString("ids") + "'"); } } - return riverId; } @@ -178,18 +177,33 @@ */ public String getName() { if (name == null) { - String ids = artifact.getDataAsString("ids"); - - String parts[] = ids != null ? ids.split(";") : null; - - if (parts != null && parts.length >= 2) { - name = parts[1]; - } + name = getIdPart(1); } return name; } + /** + * Returns a part of the ID string. This method splits the + * 'ids' data string. It is expected, that the 'ids' string is + * seperated by ';'. + * + * @param number the position of the id data string + * + * @return the part of the id string at position number. + * Null if number was out of bounds. + */ + public String getIdPart(int number) { + String ids = artifact.getDataAsString("ids"); + + String parts[] = ids != null ? ids.split(";") : null; + + if (parts != null && parts.length >= number + 1) { + return parts[number]; + } + return null; + } + /** * Returns the name of the layer (returned by getName()) or the layer