[927] | 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 |
|
---|
[922] | 15 | package de.ugoe.cs.autoquest.plugin.mfc.commands;
|
---|
[1] | 16 |
|
---|
| 17 | import java.io.FileNotFoundException;
|
---|
| 18 | import java.io.IOException;
|
---|
| 19 | import java.util.List;
|
---|
| 20 |
|
---|
[922] | 21 | import de.ugoe.cs.autoquest.plugin.mfc.LogPreprocessor;
|
---|
[1] | 22 | import de.ugoe.cs.util.console.Command;
|
---|
| 23 | import de.ugoe.cs.util.console.Console;
|
---|
| 24 |
|
---|
[171] | 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 | */
|
---|
[1] | 33 | public class CMDconvertDirToXml implements Command {
|
---|
| 34 |
|
---|
[171] | 35 | /*
|
---|
| 36 | * (non-Javadoc)
|
---|
| 37 | *
|
---|
| 38 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
| 39 | */
|
---|
[1] | 40 | @Override
|
---|
[664] | 41 | public String help() {
|
---|
[728] | 42 | return "convertDirToXml <sourceDirectory> <targetFile> {<base64>}";
|
---|
[1] | 43 | }
|
---|
| 44 |
|
---|
[171] | 45 | /*
|
---|
| 46 | * (non-Javadoc)
|
---|
| 47 | *
|
---|
| 48 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
| 49 | */
|
---|
[1] | 50 | @Override
|
---|
| 51 | public void run(List<Object> parameters) {
|
---|
[171] | 52 | if (parameters.size() < 2) {
|
---|
[766] | 53 | throw new IllegalArgumentException();
|
---|
[1] | 54 | }
|
---|
| 55 | String path = (String) parameters.get(0);
|
---|
| 56 | String target = (String) parameters.get(1);
|
---|
| 57 | boolean base64 = false;
|
---|
[171] | 58 | if (parameters.size() == 3) {
|
---|
[1] | 59 | base64 = Boolean.parseBoolean((String) parameters.get(2));
|
---|
| 60 | }
|
---|
[171] | 61 |
|
---|
[1] | 62 | try {
|
---|
| 63 | new LogPreprocessor(base64).convertDirToXml(path, target);
|
---|
| 64 | } catch (FileNotFoundException e) {
|
---|
[244] | 65 | Console.printerrln(e.getMessage());
|
---|
[1] | 66 | } catch (IOException e) {
|
---|
[244] | 67 | Console.printerrln(e.getMessage());
|
---|
[1] | 68 | }
|
---|
[171] | 69 |
|
---|
[1] | 70 | }
|
---|
| 71 |
|
---|
| 72 | }
|
---|