comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RangeState.java @ 322:448d0dc64357

The inserted ranges (distance and WQ ranges) are validated in the feed() operation. flys-artifacts/trunk@1716 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 18 Apr 2011 12:36:08 +0000
parents
children c21fb8de54f8
comparison
equal deleted inserted replaced
321:9581b88f2920 322:448d0dc64357
1 package de.intevation.flys.artifacts.states;
2
3 import org.apache.log4j.Logger;
4
5
6 /**
7 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
8 */
9 public abstract class RangeState extends DefaultState {
10
11 /** The logger that is used in this class.*/
12 private static Logger logger = Logger.getLogger(RangeState.class);
13
14
15 public RangeState() {
16 }
17
18
19 /**
20 * Validates a given range with a given valid range.
21 *
22 * @param fromValid Valid lower value of the range.
23 * @param toValid Valid upper value of the range.
24 * @param from The lower value.
25 * @param to The upper value.
26 * @param step The step width.
27 *
28 * @return true, if everything was fine, otherwise an exception is thrown.
29 */
30 protected boolean validateRange(
31 double fromValid, double toValid,
32 double from, double to, double step)
33 throws IllegalArgumentException
34 {
35 logger.debug("RangeState.validateRange");
36
37 if (from < fromValid) {
38 logger.error(
39 "Invalid 'from'. " + from + " is smaller than " + fromValid);
40 throw new IllegalArgumentException("error_feed_from_out_of_range");
41 }
42 else if (to > toValid) {
43 logger.error(
44 "Invalid 'to'. " + to + " is bigger than " + toValid);
45 throw new IllegalArgumentException("error_feed_to_out_of_range");
46 }
47 else if (from > to) {
48 throw new IllegalArgumentException("error_feed_from_bigger_to");
49 }
50
51 return true;
52 }
53 }
54 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org