comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java @ 661:fdc898a134a7

Use java.util.List instead of java.util.Vector. Removed superfluous imports. flys-artifacts/trunk@2069 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 07 Jun 2011 15:05:12 +0000
parents ed7c901ee712
children 3dc61e00385e d45c3ddaed1b
comparison
equal deleted inserted replaced
660:627be3ca1ab6 661:fdc898a134a7
5 import java.util.Collections; 5 import java.util.Collections;
6 import java.util.HashMap; 6 import java.util.HashMap;
7 import java.util.List; 7 import java.util.List;
8 import java.util.Map; 8 import java.util.Map;
9 import java.util.Set; 9 import java.util.Set;
10 import java.util.Vector;
11 10
12 import javax.xml.xpath.XPathConstants; 11 import javax.xml.xpath.XPathConstants;
13 12
14 import gnu.trove.TDoubleArrayList; 13 import gnu.trove.TDoubleArrayList;
15 14
84 83
85 /** The identifier of the current state. */ 84 /** The identifier of the current state. */
86 protected String currentStateId; 85 protected String currentStateId;
87 86
88 /** The identifiers of previous states on a stack.*/ 87 /** The identifiers of previous states on a stack.*/
89 protected Vector<String> previousStateIds; 88 protected List<String> previousStateIds;
90 89
91 /** The name of the artifact.*/ 90 /** The name of the artifact.*/
92 protected String name; 91 protected String name;
93 92
94 /** The data that have been inserted into this artifact.*/ 93 /** The data that have been inserted into this artifact.*/
98 /** 97 /**
99 * The default constructor that creates an empty FLYSArtifact. 98 * The default constructor that creates an empty FLYSArtifact.
100 */ 99 */
101 public FLYSArtifact() { 100 public FLYSArtifact() {
102 data = new HashMap<String, StateData>(); 101 data = new HashMap<String, StateData>();
103 previousStateIds = new Vector<String>(); 102 previousStateIds = new ArrayList<String>();
104 } 103 }
105 104
106 105
107 /** 106 /**
108 * Returns the name of the concrete artifact. 107 * Returns the name of the concrete artifact.
222 logger.info("FLYSArtifact.advance() to '" + targetState + "'"); 221 logger.info("FLYSArtifact.advance() to '" + targetState + "'");
223 222
224 if (isStateReachable(targetState, context)) { 223 if (isStateReachable(targetState, context)) {
225 logger.info("Advance: Step forward"); 224 logger.info("Advance: Step forward");
226 225
227 Vector<String> prev = getPreviousStateIds(); 226 List<String> prev = getPreviousStateIds();
228 prev.add(getCurrentStateId()); 227 prev.add(getCurrentStateId());
229 228
230 setCurrentStateId(targetState); 229 setCurrentStateId(targetState);
231 230
232 return describe(target, context); 231 return describe(target, context);
233 } 232 }
234 else if (isPreviousState(targetState, context)) { 233 else if (isPreviousState(targetState, context)) {
235 logger.info("Advance: Step back to"); 234 logger.info("Advance: Step back to");
236 235
237 Vector<String> prevs = getPreviousStateIds(); 236 List<String> prevs = getPreviousStateIds();
238 int targetIdx = prevs.indexOf(targetState); 237 int targetIdx = prevs.indexOf(targetState);
239 int start = prevs.size() - 1; 238 int start = prevs.size() - 1;
240 239
241 for (int i = start; i >= targetIdx; i--) { 240 for (int i = start; i >= targetIdx; i--) {
242 String prev = prevs.get(i); 241 String prev = prevs.get(i);
308 /** 307 /**
309 * Returns the vector of previous state identifiers. 308 * Returns the vector of previous state identifiers.
310 * 309 *
311 * @return the vector of previous state identifiers. 310 * @return the vector of previous state identifiers.
312 */ 311 */
313 protected Vector<String> getPreviousStateIds() { 312 protected List<String> getPreviousStateIds() {
314 return previousStateIds; 313 return previousStateIds;
315 } 314 }
316 315
317 316
318 /** 317 /**
420 * @param context The context object. 419 * @param context The context object.
421 */ 420 */
422 protected boolean isPreviousState(String stateId, Object context) { 421 protected boolean isPreviousState(String stateId, Object context) {
423 logger.debug("Determine if the state '" + stateId + "' is old."); 422 logger.debug("Determine if the state '" + stateId + "' is old.");
424 423
425 Vector<String> prevs = getPreviousStateIds(); 424 List<String> prevs = getPreviousStateIds();
426 if (prevs.contains(stateId)) { 425 if (prevs.contains(stateId)) {
427 return true; 426 return true;
428 } 427 }
429 428
430 return false; 429 return false;
1018 1017
1019 logger.debug("- " + name + ": " + value); 1018 logger.debug("- " + name + ": " + value);
1020 } 1019 }
1021 1020
1022 logger.debug("------ DUMP PREVIOUS STATES ------"); 1021 logger.debug("------ DUMP PREVIOUS STATES ------");
1023 Vector<String> stateIds = getPreviousStateIds(); 1022 List<String> stateIds = getPreviousStateIds();
1024 1023
1025 for (String id: stateIds) { 1024 for (String id: stateIds) {
1026 logger.debug("- State: " + id); 1025 logger.debug("- State: " + id);
1027 } 1026 }
1028 1027

http://dive4elements.wald.intevation.org