Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/RangeState.java @ 430:7ab81ff32111 2.3
merged flys-artifacts/2.3
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Fri, 28 Sep 2012 12:14:10 +0200 |
parents | c21fb8de54f8 |
children | acf3b49ec31f |
comparison
equal
deleted
inserted
replaced
290:a6f56ed9238b | 430:7ab81ff32111 |
---|---|
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 validateBounds( | |
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 : |