# HG changeset patch # User Ingo Weinzierl # Date 1351058660 -7200 # Node ID d952372e7083aea6b53ea5eeaf4081b9101a9db0 # Parent b3aa91e45010f262756822f22cc4db16e21732f4 Added getQs() and getWs() to HistoricalDischargeAccess class and added some Javadoc to its methods. diff -r b3aa91e45010 -r d952372e7083 flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/HistoricalDischargeAccess.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/HistoricalDischargeAccess.java Wed Oct 24 07:25:35 2012 +0200 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/HistoricalDischargeAccess.java Wed Oct 24 08:04:20 2012 +0200 @@ -13,23 +13,43 @@ } public static final String DATA_EVALUATION_TIME = "year_range"; + public static final String DATA_EVALUATION_MODE = "historical_mode"; + public static final String DATA_INPUT_VALUES = "historical_values"; private Timerange evaluationTimerange; private EvaluationMode evaluationMode; + private double[] qs; + private double[] ws; + public HistoricalDischargeAccess(FLYSArtifact artifact) { super(artifact); } + /** + * This method returns the evaluation mode. The evaluation mode W is set, if + * the DATA_EVALUATION_MODE is 0. Otherwise, the evaluation mode Q is + * set. + * + * @return EvaluationMode.W if the parameter historical_mode is set + * to 0, otherwise EvaluationMode.Q. + */ public EvaluationMode getEvaluationMode() { if (evaluationMode == null) { - int mode = getInteger("historical_mode"); + int mode = getInteger(DATA_EVALUATION_MODE); evaluationMode = mode == 0 ? EvaluationMode.W : EvaluationMode.Q; } return evaluationMode; } + /** + * This method returns the time range specified by year_range + * parameter. This parameter has to be a string that consists of two long + * values (time millis since 1970) separated by a ';'. + * + * @return the evaluation time range specified by year_range. + */ public Timerange getEvaluationTimerange() { if (evaluationTimerange == null) { long[] startend = getLongArray(DATA_EVALUATION_TIME); @@ -44,4 +64,46 @@ return evaluationTimerange; } + + /** + * This method returns the input Q values if the evaluation mode Q is set. + * Otherwise, this method will return a double array of length 0. The values + * returned by this method are extracted from string parameter + * historical_values. + * + * @return the input Q values or a double array of length 0. + */ + public double[] getQs() { + if (qs == null) { + if (getEvaluationMode() == EvaluationMode.Q) { + qs = getDoubleArray(DATA_INPUT_VALUES); + } + else { + qs = new double[0]; + } + } + + return qs; + } + + /** + * This method returns the input W values if the evaluation mode W is set. + * Otherwise, this method will return a double array of length 0. The values + * returned by this method are extracted from string parameter + * historical_values. + * + * @return the input W values or a double array of length 0. + */ + public double[] getWs() { + if (ws == null) { + if (getEvaluationMode() == EvaluationMode.W) { + ws = getDoubleArray(DATA_INPUT_VALUES); + } + else { + ws = new double[0]; + } + } + + return ws; + } }