[1242] | 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.html.commands;
|
---|
| 16 |
|
---|
| 17 | import java.io.File;
|
---|
| 18 | import java.util.List;
|
---|
| 19 |
|
---|
| 20 | import de.ugoe.cs.autoquest.plugin.html.HTMLLogTextInputPseudomizer;
|
---|
| 21 | import de.ugoe.cs.util.console.Command;
|
---|
| 22 | import de.ugoe.cs.util.console.Console;
|
---|
| 23 |
|
---|
| 24 | /**
|
---|
| 25 | * <p>
|
---|
| 26 | * TODO comment
|
---|
| 27 | * </p>
|
---|
| 28 | *
|
---|
| 29 | * @author Patrick Harms
|
---|
| 30 | * @version 1.0
|
---|
| 31 | */
|
---|
| 32 | public class CMDpseudomizeHTMLTextInputs implements Command {
|
---|
| 33 |
|
---|
| 34 | /*
|
---|
| 35 | * (non-Javadoc)
|
---|
| 36 | *
|
---|
| 37 | * @see de.ugoe.cs.util.console.Command#run(java.util.List)
|
---|
| 38 | */
|
---|
| 39 | @Override
|
---|
| 40 | public void run(List<Object> parameters) {
|
---|
| 41 | String path;
|
---|
| 42 |
|
---|
| 43 | try {
|
---|
| 44 | path = (String) parameters.get(0);
|
---|
| 45 | }
|
---|
| 46 | catch (Exception e) {
|
---|
| 47 | throw new IllegalArgumentException("illegal parameters provided: " + e);
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | File directory = new File(path);
|
---|
| 51 | if (!directory.isDirectory()) {
|
---|
| 52 | Console.printerrln(path + " is not a directory");
|
---|
| 53 | return;
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | pseudomizeTextInputsInDirectory(directory);
|
---|
| 57 |
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | /**
|
---|
| 61 | *
|
---|
| 62 | */
|
---|
| 63 | private void pseudomizeTextInputsInDirectory(File directory) {
|
---|
| 64 | if (directory.isDirectory()) {
|
---|
| 65 | File[] children = directory.listFiles();
|
---|
| 66 |
|
---|
| 67 | for (File child : children) {
|
---|
| 68 | pseudomizeTextInputsInDirectory(child);
|
---|
| 69 | }
|
---|
| 70 | }
|
---|
| 71 | else if (directory.isFile()) {
|
---|
| 72 | HTMLLogTextInputPseudomizer pseudomizer = new HTMLLogTextInputPseudomizer();
|
---|
| 73 | pseudomizer.pseudomizeFile(directory);
|
---|
| 74 | }
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | /*
|
---|
| 78 | * (non-Javadoc)
|
---|
| 79 | *
|
---|
| 80 | * @see de.ugoe.cs.util.console.Command#help()
|
---|
| 81 | */
|
---|
| 82 | @Override
|
---|
| 83 | public String help() {
|
---|
| 84 | return "pseudomizeHTMLTextInputs <directory>";
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | }
|
---|