Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/WMSDBArtifact.java @ 5403:e1cd77ddcbc4
Generalize parsing of ids data string
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 25 Mar 2013 15:01:16 +0100 |
parents | dc0d37715e16 |
children |
comparison
equal
deleted
inserted
replaced
5402:1564ca2cb224 | 5403:e1cd77ddcbc4 |
---|---|
147 return null; | 147 return null; |
148 } | 148 } |
149 | 149 |
150 public int getRiverId() { | 150 public int getRiverId() { |
151 if (riverId == 0) { | 151 if (riverId == 0) { |
152 String ids = artifact.getDataAsString("ids"); | 152 String rid = getIdPart(0); |
153 String[] parts = ids.split(";"); | |
154 | 153 |
155 try { | 154 try { |
156 riverId = Integer.parseInt(parts[0]); | 155 riverId = Integer.parseInt(rid); |
157 } | 156 } |
158 catch (NumberFormatException nfe) { | 157 catch (NumberFormatException nfe) { |
159 logger.error("Cannot parse river id from '" + parts[0] + "'"); | 158 logger.error("Cannot parse river id from '" + |
159 artifact.getDataAsString("ids") + "'"); | |
160 } | 160 } |
161 } | 161 } |
162 | |
163 return riverId; | 162 return riverId; |
164 } | 163 } |
165 | 164 |
166 protected String getLayer() { | 165 protected String getLayer() { |
167 String type = getFacetType(); | 166 String type = getFacetType(); |
176 * | 175 * |
177 * @return the name of the WMS layer. | 176 * @return the name of the WMS layer. |
178 */ | 177 */ |
179 public String getName() { | 178 public String getName() { |
180 if (name == null) { | 179 if (name == null) { |
181 String ids = artifact.getDataAsString("ids"); | 180 name = getIdPart(1); |
182 | |
183 String parts[] = ids != null ? ids.split(";") : null; | |
184 | |
185 if (parts != null && parts.length >= 2) { | |
186 name = parts[1]; | |
187 } | |
188 } | 181 } |
189 | 182 |
190 return name; | 183 return name; |
184 } | |
185 | |
186 /** | |
187 * Returns a part of the ID string. This method splits the | |
188 * 'ids' data string. It is expected, that the 'ids' string is | |
189 * seperated by ';'. | |
190 * | |
191 * @param number the position of the id data string | |
192 * | |
193 * @return the part of the id string at position number. | |
194 * Null if number was out of bounds. | |
195 */ | |
196 public String getIdPart(int number) { | |
197 String ids = artifact.getDataAsString("ids"); | |
198 | |
199 String parts[] = ids != null ? ids.split(";") : null; | |
200 | |
201 if (parts != null && parts.length >= number + 1) { | |
202 return parts[number]; | |
203 } | |
204 return null; | |
191 } | 205 } |
192 | 206 |
193 | 207 |
194 /** | 208 /** |
195 * Returns the name of the layer (returned by getName()) or the layer | 209 * Returns the name of the layer (returned by getName()) or the layer |