Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/states/DefaultState.java @ 8615:054d1b57ae4a
(issue1755) Clarify how default mecahnism works and remove unused config value.
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Wed, 25 Mar 2015 11:41:36 +0100 |
parents | 97e148487186 |
children | 7d1a32a543cb |
comparison
equal
deleted
inserted
replaced
8614:e7a2234e7c3f | 8615:054d1b57ae4a |
---|---|
45 public class DefaultState extends AbstractState { | 45 public class DefaultState extends AbstractState { |
46 | 46 |
47 /** The log that is used in this class. */ | 47 /** The log that is used in this class. */ |
48 private static Logger log = Logger.getLogger(DefaultState.class); | 48 private static Logger log = Logger.getLogger(DefaultState.class); |
49 | 49 |
50 | |
51 /** Determines, if the DESCRIBE document should contain default values or | |
52 * not. */ | |
53 public static final boolean USE_DEFAULTS = | |
54 Boolean.getBoolean("flys.use.default.values"); | |
55 | 50 |
56 /** The three possible compute types. */ | 51 /** The three possible compute types. */ |
57 public static enum ComputeType { | 52 public static enum ComputeType { |
58 FEED, ADVANCE, INIT | 53 FEED, ADVANCE, INIT |
59 } | 54 } |
205 } | 200 } |
206 } | 201 } |
207 | 202 |
208 | 203 |
209 /** | 204 /** |
210 * This method returns the default value and description for <i>data</i>. | 205 * This method returns the default value and label for <i>data</i>. |
211 * Note, that this method returns the defaults only if <i>USE_DEFAULTS</i> | 206 * |
212 * is set; otherwise, null is returned. | 207 * Override this method in a subclass to set an appropiate default |
208 * value. | |
209 * The default label can be ignored by the client (e.g. the gwt-client). | |
210 * but shall not be null. | |
211 * | |
212 * Example implementation: | |
213 * if (data != null && data.getName().equals("the_answer")) { | |
214 * return new String[] {"42", "the_answer"}; | |
215 * } | |
216 * | |
213 * @param context The CallContext used for i18n. | 217 * @param context The CallContext used for i18n. |
214 * @param data The data objects that the defaults are for. | 218 * @param data The data objects that the defaults are for. |
215 * @return a String[] with [default value, default label]. | 219 * @return a String[] with [default value, default label]. |
216 */ | 220 */ |
217 protected String[] getDefaultsFor(CallContext context, StateData data) { | 221 protected String[] getDefaultsFor(CallContext context, StateData data) { |
218 if (USE_DEFAULTS) { | |
219 String defValue = (String) data.getValue(); | |
220 String defDesc = null; | |
221 | |
222 if (defValue != null && defValue.length() > 0) { | |
223 defDesc = Resources.getMsg( | |
224 context.getMeta(), | |
225 defValue, | |
226 defValue); | |
227 } | |
228 | |
229 if (defValue != null && defDesc != null) { | |
230 return new String[] { defValue, defDesc }; | |
231 } | |
232 } | |
233 | |
234 return null; | 222 return null; |
235 } | 223 } |
236 | 224 |
237 | 225 |
238 public Element describe( | 226 public Element describe( |