source: trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/commands/CMDgenerateFixedLengthSequences.java @ 117

Last change on this file since 117 was 103, checked in by sherbold, 13 years ago
  • uses java.util.Collection instead of java.util.Set and Java.util.List with java.util.Collection where required
  • Property svn:mime-type set to text/plain
File size: 1.6 KB
Line 
1package de.ugoe.cs.eventbench.commands;
2
3import java.security.InvalidParameterException;
4import java.util.Collection;
5import java.util.List;
6
7import de.ugoe.cs.eventbench.data.Event;
8import de.ugoe.cs.eventbench.data.GlobalDataContainer;
9import de.ugoe.cs.eventbench.models.IStochasticProcess;
10import de.ugoe.cs.util.console.Command;
11import de.ugoe.cs.util.console.Console;
12
13public class CMDgenerateFixedLengthSequences implements Command {
14
15        @Override
16        public void run(List<Object> parameters) {
17                String modelname;
18                String sequencesName;
19                int length;
20                try {
21                        modelname = (String) parameters.get(0);
22                        sequencesName = (String) parameters.get(1);
23                        length = Integer.parseInt((String) parameters.get(2));
24                }
25                catch (Exception e) {
26                        throw new InvalidParameterException();
27                }
28               
29                IStochasticProcess model = null;
30                Object dataObject = GlobalDataContainer.getInstance().getData(modelname);
31                if( dataObject==null ) {
32                        Console.println("Model " + modelname + " not found in storage.");
33                }
34                else if( !(dataObject instanceof IStochasticProcess) ) {
35                        Console.println("Object " + modelname + " not of type MarkovModel!");
36                } else {
37                        model = (IStochasticProcess) dataObject;
38                        Collection<List<? extends Event<?>>> sequences = model.generateValidSequences(length+2);
39                        if( GlobalDataContainer.getInstance().addData(sequencesName, sequences) ) {
40                                Console.traceln("Old data \"" + sequencesName + "\" overwritten");
41                        }
42                }
43        }
44
45        @Override
46        public void help() {
47                Console.println("Usage: generateFixedLengthSequences <modelname> <sequencesName> <length>");
48        }
49
50}
Note: See TracBrowser for help on using the repository browser.