/*
* Copyright (c) 2002 Cunningham & Cunningham, Inc.
* Copyright (c) 2009-2015 by Jochen Wierum & Cologne Intelligence
*
* This file is part of FitGoodies.
*
* FitGoodies is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* FitGoodies is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with FitGoodies. If not, see <http://www.gnu.org/licenses/>.
*/
package de.cologneintelligence.fitgoodies.file;
import de.cologneintelligence.fitgoodies.ActionFixture;
import de.cologneintelligence.fitgoodies.util.DependencyManager;
import java.io.File;
/**
* The file fixture is used to select files via HTML:
* <table border="1" summary="">
* <tr><td>fitgoodies.file.FileFixture</td></tr>
* <tr><td>directory</td><td>/my/dir</td></tr>
* <tr><td>pattern</td><td>.*\.txt</td></tr>
* <tr><td>encoding</td><td>utf-8</td></tr>
* </table>
* <p>
* The fixture sets the values in {@link FileFixtureHelper}.
*
* @see FileFixtureHelper FileFixtureHelper
*/
public class FileFixture extends ActionFixture {
/**
* Sets the filename pattern to {@code pattern}.
*
* @param pattern pattern to use
*/
public void pattern(final String pattern) {
FileFixtureHelper helper = DependencyManager.getOrCreate(FileFixtureHelper.class);
helper.setPattern(pattern);
}
/**
* Calls {@link #pattern(String)}, using the next cell as its parameter.
*
* @throws Exception propagated to fit
*/
public void pattern() throws Exception {
transformAndEnter();
}
/**
* Calls {@link #directory(String)}, using the next cell as its parameter.
*
* @throws Exception propagated to fit
*/
public void directory() throws Exception {
transformAndEnter();
}
/**
* Calls {@link #encoding(String)}, using the next cell as its parameter.
*
* @throws Exception propagated to fit
*/
public void encoding() throws Exception {
transformAndEnter();
}
/**
* Sets the directory to {@code directory}.
*
* @param directory directory to use
*/
public void directory(final String directory) {
FileFixtureHelper helper = DependencyManager.getOrCreate(FileFixtureHelper.class);
helper.setDirectory(new File(directory));
}
/**
* Sets the encoding to {@code encoding}.
*
* @param encoding encoding to use
*/
public void encoding(final String encoding) {
FileFixtureHelper helper = DependencyManager.getOrCreate(FileFixtureHelper.class);
helper.setEncoding(encoding);
}
}