1 | package de.ugoe.cs.eventbench.windows.commands;
|
---|
2 |
|
---|
3 | import java.io.FileNotFoundException;
|
---|
4 | import java.io.IOException;
|
---|
5 | import java.security.InvalidParameterException;
|
---|
6 | import java.util.List;
|
---|
7 |
|
---|
8 | import de.ugoe.cs.eventbench.windows.LogPreprocessor;
|
---|
9 | import de.ugoe.cs.util.console.Command;
|
---|
10 | import de.ugoe.cs.util.console.Console;
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * <p>
|
---|
14 | * Command to pre-process all files in a folder.
|
---|
15 | * </p>
|
---|
16 | *
|
---|
17 | * @author Steffen Herbold
|
---|
18 | * @version 1.0
|
---|
19 | */
|
---|
20 | public class CMDconvertDirToXml implements Command {
|
---|
21 |
|
---|
22 | /*
|
---|
23 | * (non-Javadoc)
|
---|
24 | *
|
---|
25 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
26 | */
|
---|
27 | @Override
|
---|
28 | public void help() {
|
---|
29 | Console.println("Usage: convertToXml <sourceFolder> <targetFile> {<base64>}");
|
---|
30 | }
|
---|
31 |
|
---|
32 | /*
|
---|
33 | * (non-Javadoc)
|
---|
34 | *
|
---|
35 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
36 | */
|
---|
37 | @Override
|
---|
38 | public void run(List<Object> parameters) {
|
---|
39 | if (parameters.size() < 2) {
|
---|
40 | throw new InvalidParameterException();
|
---|
41 | }
|
---|
42 | String path = (String) parameters.get(0);
|
---|
43 | String target = (String) parameters.get(1);
|
---|
44 | boolean base64 = false;
|
---|
45 | if (parameters.size() == 3) {
|
---|
46 | base64 = Boolean.parseBoolean((String) parameters.get(2));
|
---|
47 | }
|
---|
48 |
|
---|
49 | try {
|
---|
50 | new LogPreprocessor(base64).convertDirToXml(path, target);
|
---|
51 | } catch (FileNotFoundException e) {
|
---|
52 | Console.println(e.getMessage());
|
---|
53 | } catch (IOException e) {
|
---|
54 | Console.println(e.getMessage());
|
---|
55 | }
|
---|
56 |
|
---|
57 | }
|
---|
58 |
|
---|
59 | }
|
---|