source: trunk/autoquest-plugin-mfc/src/main/java/de/ugoe/cs/autoquest/plugin/mfc/commands/CMDconvertToXml.java @ 927

Last change on this file since 927 was 927, checked in by sherbold, 12 years ago
  • added copyright under the Apache License, Version 2.0
File size: 2.0 KB
Line 
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
15package de.ugoe.cs.autoquest.plugin.mfc.commands;
16
17import java.io.FileNotFoundException;
18import java.io.IOException;
19import java.util.List;
20
21import de.ugoe.cs.autoquest.plugin.mfc.LogPreprocessor;
22import de.ugoe.cs.util.console.Command;
23import de.ugoe.cs.util.console.Console;
24
25/**
26 * <p>
27 * Command to pre-process a single file.
28 * </p>
29 *
30 * @author Steffen Herbold
31 * @version 1.0
32 */
33public class CMDconvertToXml 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 "convertToXml <sourceFile> <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 source = (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).convertToXml(source, target);
64                } catch (FileNotFoundException e) {
65                        Console.printerrln(e.getMessage());
66                } catch (IOException e) {
67                        Console.printerrln(e.getMessage());
68                }
69
70        }
71
72}
Note: See TracBrowser for help on using the repository browser.