ingo@322: package de.intevation.flys.artifacts.states; ingo@322: ingo@322: import org.apache.log4j.Logger; ingo@322: ingo@322: ingo@322: /** ingo@322: * @author Ingo Weinzierl ingo@322: */ ingo@322: public abstract class RangeState extends DefaultState { ingo@322: ingo@322: /** The logger that is used in this class.*/ ingo@322: private static Logger logger = Logger.getLogger(RangeState.class); ingo@322: ingo@322: ingo@322: public RangeState() { ingo@322: } ingo@322: ingo@322: ingo@322: /** ingo@322: * Validates a given range with a given valid range. ingo@322: * ingo@322: * @param fromValid Valid lower value of the range. ingo@322: * @param toValid Valid upper value of the range. ingo@322: * @param from The lower value. ingo@322: * @param to The upper value. ingo@322: * @param step The step width. ingo@322: * ingo@322: * @return true, if everything was fine, otherwise an exception is thrown. ingo@322: */ ingo@322: protected boolean validateRange( ingo@322: double fromValid, double toValid, ingo@322: double from, double to, double step) ingo@322: throws IllegalArgumentException ingo@322: { ingo@322: logger.debug("RangeState.validateRange"); ingo@322: ingo@322: if (from < fromValid) { ingo@322: logger.error( ingo@322: "Invalid 'from'. " + from + " is smaller than " + fromValid); ingo@322: throw new IllegalArgumentException("error_feed_from_out_of_range"); ingo@322: } ingo@322: else if (to > toValid) { ingo@322: logger.error( ingo@322: "Invalid 'to'. " + to + " is bigger than " + toValid); ingo@322: throw new IllegalArgumentException("error_feed_to_out_of_range"); ingo@322: } ingo@322: else if (from > to) { ingo@322: throw new IllegalArgumentException("error_feed_from_bigger_to"); ingo@322: } ingo@322: ingo@322: return true; ingo@322: } ingo@322: } ingo@322: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :