1 | // Copyright 2012 Georg-August-Universität Göttingen, Germany
|
---|
2 | //
|
---|
3 | // Licensed under the Apache License, Version 2.0 (the "License");
|
---|
4 | // you may not use this file except in compliance with the License.
|
---|
5 | // You may obtain a copy of the License at
|
---|
6 | //
|
---|
7 | // http://www.apache.org/licenses/LICENSE-2.0
|
---|
8 | //
|
---|
9 | // Unless required by applicable law or agreed to in writing, software
|
---|
10 | // distributed under the License is distributed on an "AS IS" BASIS,
|
---|
11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
12 | // See the License for the specific language governing permissions and
|
---|
13 | // limitations under the License.
|
---|
14 |
|
---|
15 | package de.ugoe.cs.autoquest.plugin.mfc.commands;
|
---|
16 |
|
---|
17 | import java.io.FileNotFoundException;
|
---|
18 | import java.io.IOException;
|
---|
19 | import java.util.List;
|
---|
20 |
|
---|
21 | import de.ugoe.cs.autoquest.plugin.mfc.LogPreprocessor;
|
---|
22 | import de.ugoe.cs.util.console.Command;
|
---|
23 | import de.ugoe.cs.util.console.Console;
|
---|
24 |
|
---|
25 | /**
|
---|
26 | * <p>
|
---|
27 | * Command to pre-process all files in a folder.
|
---|
28 | * </p>
|
---|
29 | *
|
---|
30 | * @author Steffen Herbold
|
---|
31 | * @version 1.0
|
---|
32 | */
|
---|
33 | public class CMDconvertDirToXml implements Command {
|
---|
34 |
|
---|
35 | /*
|
---|
36 | * (non-Javadoc)
|
---|
37 | *
|
---|
38 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
39 | */
|
---|
40 | @Override
|
---|
41 | public String help() {
|
---|
42 | return "convertDirToXml <sourceDirectory> <targetFile> {<base64>}";
|
---|
43 | }
|
---|
44 |
|
---|
45 | /*
|
---|
46 | * (non-Javadoc)
|
---|
47 | *
|
---|
48 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
49 | */
|
---|
50 | @Override
|
---|
51 | public void run(List<Object> parameters) {
|
---|
52 | if (parameters.size() < 2) {
|
---|
53 | throw new IllegalArgumentException();
|
---|
54 | }
|
---|
55 | String path = (String) parameters.get(0);
|
---|
56 | String target = (String) parameters.get(1);
|
---|
57 | boolean base64 = false;
|
---|
58 | if (parameters.size() == 3) {
|
---|
59 | base64 = Boolean.parseBoolean((String) parameters.get(2));
|
---|
60 | }
|
---|
61 |
|
---|
62 | try {
|
---|
63 | new LogPreprocessor(base64).convertDirToXml(path, target);
|
---|
64 | } catch (FileNotFoundException e) {
|
---|
65 | Console.printerrln(e.getMessage());
|
---|
66 | } catch (IOException e) {
|
---|
67 | Console.printerrln(e.getMessage());
|
---|
68 | }
|
---|
69 |
|
---|
70 | }
|
---|
71 |
|
---|
72 | }
|
---|