<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
- <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_6" inherit-compiler-output="false">
+ <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8" inherit-compiler-output="false">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
- <source>1.6</source>
- <target>1.6</target>
+ <source>1.8</source>
+ <target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
import java.util.ArrayList;
-public class Main {
+class Main {
- public static ArrayList<Module> modules;
+ private static ArrayList<Module> modules;
- public static String[] getRemainingOptions(final String[] options) {
+ private static String[] getRemainingOptions(final String[] options) {
final String[] remainingOptions = new String[options.length - 1];
System.arraycopy(options, 1, remainingOptions, 0, options.length - 1);
return remainingOptions;
}
- public static void initModules() {
- modules = new ArrayList<Module>();
+ private static void initModules() {
+ modules = new ArrayList<>();
modules.add(new Encoder());
modules.add(new eu.svjatoslav.meviz.htmlindexer.Main());
}
- public static void showHelp() {
+ private static void showHelp() {
final StringBuilder buffer = new StringBuilder();
buffer.append("Commandline options: \n"
public class BomStrippingOptions {
- public ArrayList<String> inputPatterns = new ArrayList<String>();
+ public final ArrayList<String> inputPatterns = new ArrayList<>();
public boolean recursive = false;
import java.io.File;
-public class CommandlineHandler {
+class CommandlineHandler {
- Parser parser = new Parser();
+ final Parser parser = new Parser();
- NullParameter recursiveParameter = parser.add(
+ private final NullParameter recursiveParameter = parser.add(
new NullParameter("Enable recursive mode.")).addAliases("-r",
"--recursive");
- StringParameters inputPatternParameter = parser.add(
+ private final StringParameters inputPatternParameter = parser.add(
new StringParameters("File input pattern.")).addAliases("-i",
"--input-pattern");
- DirectoryParameter workingDirectoryParameter = parser
+ private final DirectoryParameter workingDirectoryParameter = parser
.add(new DirectoryParameter("Working directory."))
.addAliases("-w", "--working-directory").mustExist();
public class Main implements Module {
- byte[] bomHeader = new byte[]{(byte) 0xef, (byte) 0xbb, (byte) 0xbf};
+ private final byte[] bomHeader = new byte[]{(byte) 0xef, (byte) 0xbb, (byte) 0xbf};
- CommandlineHandler commandlineHandler = new CommandlineHandler();
+ private final CommandlineHandler commandlineHandler = new CommandlineHandler();
- BomStrippingOptions options;
+ private BomStrippingOptions options;
- public boolean contains(final byte[] header, final byte[] patternToSeek) {
+ private boolean contains(final byte[] header, final byte[] patternToSeek) {
for (int i = 0; i < patternToSeek.length; i++)
if (header[i] != patternToSeek[i])
return true;
}
- public boolean fileContainsHeader(final File file)
+ private boolean fileContainsHeader(final File file)
throws IOException {
final FileInputStream fileInputStream = new FileInputStream(file);
return contains(currentFileHeader, bomHeader);
}
- public boolean fileMatchesInputPattern(final File file) {
+ private boolean fileMatchesInputPattern(final File file) {
final String fileName = file.getName().toLowerCase();
for (final String inputPattern : options.inputPatterns)
return "stripbom";
}
- public void processDirectory(final File directory) {
+ private void processDirectory(final File directory) {
for (final File subFile : directory.listFiles())
if (subFile.isDirectory()) {
}
- public void processFile(final File file) throws IOException {
+ private void processFile(final File file) throws IOException {
if (file.length() < bomHeader.length)
return;
commandlineHandler.parser.showHelp();
}
- public void stripFileFromHeader(final File file)
+ private void stripFileFromHeader(final File file)
throws IOException {
// read entire file
final byte[] fileContents = IOHelper.getFileContents(file);
import eu.svjatoslav.commons.commandline.parameterparser.parameter.NullParameter;
import eu.svjatoslav.commons.commandline.parameterparser.parameter.StringParameters;
-public class CommandlineHandler {
+class CommandlineHandler {
- Parser parser = new Parser();
+ final Parser parser = new Parser();
- StringParameters outputFormatParameter = parser.add(new StringParameters("Encoding output format."))
+ private final StringParameters outputFormatParameter = parser.add(new StringParameters("Encoding output format."))
.addAliases("-o", "--output-format").setMandatory();
- IntegerParameter targetFramerate = parser
+ private final IntegerParameter targetFramerate = parser
.add(new IntegerParameter("Target framerate.").addAliases("-f", "--target-framerate"));
- NullParameter deinterlaceParameter = parser.add(new NullParameter("Deinterlace video.")).addAliases("-d",
+ private final NullParameter deinterlaceParameter = parser.add(new NullParameter("Deinterlace video.")).addAliases("-d",
"--deinterlace");
- NullParameter testParameter = parser.add(new NullParameter("Simulate file encoding.")).addAliases("-t", "--test");
+ private final NullParameter testParameter = parser.add(new NullParameter("Simulate file encoding.")).addAliases("-t", "--test");
- NullParameter recursiveParameter = parser.add(new NullParameter("Enable recursive mode.")).addAliases("-r",
+ private final NullParameter recursiveParameter = parser.add(new NullParameter("Enable recursive mode.")).addAliases("-r",
"--recursive");
- NullParameter forPortableParameter = parser.add(new NullParameter("Encode for portable player.")).addAliases("-p",
+ private final NullParameter forPortableParameter = parser.add(new NullParameter("Encode for portable player.")).addAliases("-p",
"--portable");
- StringParameters inputPatternParameter = parser.add(new StringParameters("File input pattern."))
+ private final StringParameters inputPatternParameter = parser.add(new StringParameters("File input pattern."))
.addAliases("-i", "--input-pattern").setMandatory();
- DirectoryParameter workingDirectoryParameter = parser.add(new DirectoryParameter("Working directory."))
+ private final DirectoryParameter workingDirectoryParameter = parser.add(new DirectoryParameter("Working directory."))
.addAliases("-w", "--working-directory").mustExist();
- BitrateParameter videoBitrateParameter = parser.add(new BitrateParameter("Video bitrate")).addAliases("-v",
+ private final BitrateParameter videoBitrateParameter = parser.add(new BitrateParameter("Video bitrate")).addAliases("-v",
"--video-bitrate");
- BitrateParameter audioBitrateParameter = parser.add(new BitrateParameter("Audio bitrate")).addAliases("-a",
+ private final BitrateParameter audioBitrateParameter = parser.add(new BitrateParameter("Audio bitrate")).addAliases("-a",
"--audio-bitrate");
/**
public class Encoder implements Module {
- public FormatsRegistry encoderRegistry = new FormatsRegistry();
-
- public EncodingOptions encodingOptions;
-
- public EncodingPlan encodingPlan;
-
- CommandlineHandler commandlineHandler = new CommandlineHandler();
+ private final FormatsRegistry encoderRegistry = new FormatsRegistry();
+ private final CommandlineHandler commandlineHandler = new CommandlineHandler();
+ private EncodingOptions encodingOptions;
+ private EncodingPlan encodingPlan;
/**
* Generate encoding plan
*
* @param sourceFile Source directory of file
*/
- public void compileEncodingPlan(final File sourceFile) {
+ private void compileEncodingPlan(final File sourceFile) {
if (!sourceFile.exists()) {
System.out.println("Error: file \"" + sourceFile.getAbsolutePath()
+ "\" does not exist.");
* @param file single file candidate to potentially be encoded
* @return <code>true</code> if file shall be encoded.
*/
- public boolean fileMatchesInputPattern(final File file) {
+ private boolean fileMatchesInputPattern(final File file) {
final String fileName = file.getName().toLowerCase();
for (final String inputPattern : encodingOptions.getInputPatterns())
private File workingDirectory = new File(System.getProperty("user.dir"));
- private List<String> outputFormats = new ArrayList<String>();
+ private List<String> outputFormats = new ArrayList<>();
- private List<String> inputPatterns = new ArrayList<String>();
+ private List<String> inputPatterns = new ArrayList<>();
public BitrateParameter.bitrate getAudioBitrate() {
return audioBitrate;
package eu.svjatoslav.meviz.encoder;
-import java.io.IOException;
import java.util.ArrayList;
public class EncodingPlan {
- public ArrayList<EncodingTask> encodingTasks = new ArrayList<EncodingTask>();
+ private final ArrayList<EncodingTask> encodingTasks = new ArrayList<>();
- public void execute(final EncodingOptions encodingOptions)
- throws IOException {
+ public void execute(final EncodingOptions encodingOptions) {
for (final EncodingTask task : encodingTasks)
task.execute(encodingOptions);
/**
* @return the useTerminal
*/
- public boolean doUseTerminal() {
+ private boolean doUseTerminal() {
return useTerminal;
}
- public String encodeApostrophes(final String input) {
+ private String encodeApostrophes(final String input) {
final StringBuilder result = new StringBuilder();
for (final char c : input.toCharArray()) {
}
- public String getCommand(final EncodingOptions encodingOptions) {
+ private String getCommand(final EncodingOptions encodingOptions) {
return converter.getCommand(source, target, encodingOptions, targetFormat);
}
public class FormatsRegistry {
- public ArrayList<AbstractConverter> encoders = new ArrayList<AbstractConverter>();
+ private final ArrayList<AbstractConverter> encoders = new ArrayList<>();
public FormatsRegistry() {
// video conversion
final String sourceFormatLowerCase = sourceFormat.toLowerCase();
final String targetFormatLowerCase = targetFormat.toLowerCase();
- final ArrayList<AbstractConverter> encoders = new ArrayList<AbstractConverter>();
+ final ArrayList<AbstractConverter> encoders = new ArrayList<>();
for (final AbstractConverter encoder : this.encoders)
if (encoder.supportsSource(sourceFormatLowerCase))
return encoders;
}
- public void registerEncoder(final AbstractConverter encoder) {
+ private void registerEncoder(final AbstractConverter encoder) {
encoders.add(encoder);
}
public abstract String getCommand(File inputFile, File targetFile,
EncodingOptions options, String targetFormat);
- public abstract List<String> getSourceFileExtensions();
+ protected abstract List<String> getSourceFileExtensions();
- public abstract List<String> getTargetFileExtensions();
+ protected abstract List<String> getTargetFileExtensions();
/**
* For some reasons some encoders require terminal to run. Until this is
return getTargetFileExtensions().contains(format);
}
- public List<String> toList(final String... strings) {
- final ArrayList<String> result = new ArrayList<String>();
+ List<String> toList(final String... strings) {
+ final ArrayList<String> result = new ArrayList<>();
Collections.addAll(result, strings);
return "Convenience helper to retrieve contents of inserted memory card.";
}
- public File[] getDiskVideos(final File file) {
+ private File[] getDiskVideos(final File file) {
final String videosPath = file.getAbsolutePath() + "/AVCHD/BDMV/STREAM/";
final File videosDirectory = new File(videosPath);
return videosDirectory.listFiles();
}
- public String getDoubleDigit(final int value) {
+ private String getDoubleDigit(final int value) {
String valueString = Integer.toString(value);
if (valueString.length() == 1)
valueString = "0" + valueString;
}
@SuppressWarnings("deprecation")
- public File getTargetDirectory() {
+ private File getTargetDirectory() {
final Date now = new Date();
final GregorianCalendar calendar = new GregorianCalendar();
targetFilePath.append("/");
targetFilePath.append(FilePathParser.getFileNameWithoutExtension(sourceFile));
targetFilePath.append(".mp4");
- final File targetFile = new File(targetFilePath.toString());
- return targetFile;
+ return new File(targetFilePath.toString());
}
@Override
return fileExtension.equalsIgnoreCase("ogv");
}
- public static boolean shallFileBeIndexed(final File file) {
+ static boolean shallFileBeIndexed(final File file) {
if (file.getName().startsWith("."))
return false;
return true;
}
- public void compileHtml(final Layout layout,
- final DirectoryMetadata directory)
+ void compileHtml(final Layout layout,
+ final DirectoryMetadata directory)
throws UnsupportedEncodingException {
for (final AbstractFile file : directory.getFiles())
import java.io.File;
-public class CommandlineHandler {
+class CommandlineHandler {
- Parser parser = new Parser();
-
- StringParameter galleryNameParameter = parser.add(
+ final Parser parser = new Parser();
+ final NullParameter removeIndex = parser.add(
+ new NullParameter("Remove generated index")).addAliases("-r",
+ "--remove");
+ private final StringParameter galleryNameParameter = parser.add(
new StringParameter("Gallery title. (default is: "
+ Constants.DEFAULT_GALLERY_TITLE + ").")).addAliases("-t",
"--gallery-title");
-
- DirectoryParameter workingDirectoryParameter = parser
+ private final DirectoryParameter workingDirectoryParameter = parser
.add(new DirectoryParameter("Working directory."))
.addAliases("-w", "--working-directory").mustExist();
- NullParameter removeIndex = parser.add(
- new NullParameter("Remove generated index")).addAliases("-r",
- "--remove");
-
public String getGalleryTitle() {
if (galleryNameParameter.isParameterSpecified())
return galleryNameParameter.getValue();
import java.io.File;
import java.io.IOException;
-public class FilesystemIndexRemover {
+class FilesystemIndexRemover {
private final CommandlineHandler commandlineHandler;
removeIndex(commandlineHandler.getWorkingDirectory());
}
- public void removeIndex(final File workingDirectory) throws IOException {
+ private void removeIndex(final File workingDirectory) throws IOException {
// remove thumbnails directory from current directory
final File thumbnailsDirectory = Utils
public class FilesystemIndexer extends AbstractIndexer {
- public static final Logger logger = Logger
+ private static final Logger logger = Logger
.getLogger(FilesystemIndexer.class);
- private final HashSet<String> validMetadataFiles = new HashSet<String>();
+ private final HashSet<String> validMetadataFiles = new HashSet<>();
private final File directoryToIndex;
private final List<String> pathElements;
}
- public boolean canWriteIndexFile(final File indexFile)
+ private boolean canWriteIndexFile(final File indexFile)
throws IOException {
return !indexFile.exists() || Utils.isMevizGeneratedIndexFile(indexFile);
}
- public void generateHtmlFromMetadata(final HashSet<Layout> layouts) {
+ private void generateHtmlFromMetadata(final HashSet<Layout> layouts) {
// Generate HTML from metadata
for (final Layout layout : layouts)
try {
}
}
- public List<String> getChildPath(final File file) {
+ private List<String> getChildPath(final File file) {
- final List<String> result = new ArrayList<String>();
+ final List<String> result = new ArrayList<>();
result.addAll(pathElements);
result.add(file.getName());
+ Utils.urlEncode(thumbnailFileName);
}
- public void initializeLayouts() {
+ private void initializeLayouts() {
layouts = Utils.getLayouts();
"", "."));
}
- public void initializeThumbnailsDirectory() {
+ private void initializeThumbnailsDirectory() {
final File thumbnailsDirectory = Utils
.getThumbnailsDirectory(directoryToIndex);
thumbnailsDirectory.mkdirs();
}
- public void loadOrCreateMetadata() {
+ private void loadOrCreateMetadata() {
metadataFile = new File(
Utils.getThumbnailsDirectoryPath(directoryToIndex)
}
- public void updateMetadata() throws Exception {
+ private void updateMetadata() throws Exception {
for (final File file : directoryToIndex.listFiles())
if (shallFileBeIndexed(file)) {
package eu.svjatoslav.meviz.htmlindexer;
-public class ImageFormatError extends Exception {
+class ImageFormatError extends Exception {
private static final long serialVersionUID = 4037233564457071385L;
public List<String> getLocalPathComponents() {
- final List<String> result = new ArrayList<String>();
+ final List<String> result = new ArrayList<>();
final String[] strings = localUrl.split("/");
*/
void enlistOgv(AbstractFile file,
DirectoryMetadata parentDirectoryMetadata)
- throws UnsupportedEncodingException;
+ ;
/**
* Return layout specific suffix that will be appended between
*/
String getHtml(final boolean showTitle,
final boolean doHtmlHeaderAndFooter, DirectoryMetadata metadata)
- throws IOException;
+ ;
/**
* Initialize layout for particular directory.
public class Main implements Module {
- CommandlineHandler commandlineHandler = new CommandlineHandler();
+ private final CommandlineHandler commandlineHandler = new CommandlineHandler();
/**
* {@inheritDoc}
new FilesystemIndexRemover(commandlineHandler);
else
new FilesystemIndexer(commandlineHandler.getWorkingDirectory(),
- commandlineHandler, new ArrayList<String>());
+ commandlineHandler, new ArrayList<>());
}
}
public static HashSet<Layout> getLayouts() {
- final HashSet<Layout> layouts = new HashSet<Layout>();
+ final HashSet<Layout> layouts = new HashSet<>();
layouts.add(new MixedLayout());
return layouts;
}
crc.update(b);
// note use crc.value, not crc.getValue()
- final String hex = Integer.toHexString((int) crc.getValue())
- .toUpperCase();
-
- // System.out.println("Input string: " + input);
- // System.out.println("Result: " + hex);
- return hex;
+ return Integer.toHexString((int) crc.getValue())
+ .toUpperCase();
}
public static File getThumbnailsDirectory(final File directoryToIndex) {
return layout.getHtml(false, false, directory);
}
- public DirectoryMetadata getMetadataForPath(final String requestPath)
+ private DirectoryMetadata getMetadataForPath(final String requestPath)
throws ClassNotFoundException, IOException {
final String urlString = globalPrefix +
import org.apache.log4j.Logger;
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
import java.util.List;
public class MixedLayout implements Layout {
public static final String encoding = "UTF-8";
- Logger logger = Logger.getLogger(MixedLayout.class);
+ private final Logger logger = Logger.getLogger(MixedLayout.class);
- StringBuffer dirHtml = new StringBuffer();
+ private StringBuffer dirHtml = new StringBuffer();
- StringBuffer filesHtml = new StringBuffer();
+ private StringBuffer filesHtml = new StringBuffer();
- String galleryTitle;
+ private String galleryTitle;
- List<String> path;
+ private List<String> path;
private AbstractIndexer indexer;
*/
@Override
public void enlistOgv(final AbstractFile abstractFile,
- final DirectoryMetadata parentDirectoryMetadata)
- throws UnsupportedEncodingException {
+ final DirectoryMetadata parentDirectoryMetadata) {
final GeneralFile file = (GeneralFile) abstractFile;
public int width;
public int height;
- public Dimension() {
+ private Dimension() {
width = 0;
height = 0;
}
import eu.svjatoslav.commons.file.FilePathParser;
import eu.svjatoslav.meviz.htmlindexer.AbstractIndexer;
import eu.svjatoslav.meviz.htmlindexer.FileSortComparator;
-import eu.svjatoslav.meviz.htmlindexer.ImageFormatError;
import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.*;
import java.io.File;
-import java.io.IOException;
import java.io.Serializable;
import java.util.*;
private static final long serialVersionUID = 3526489102725366334L;
- private final HashMap<String, AbstractFile> fileNameToFileMap = new HashMap<String, AbstractFile>();
+ private final HashMap<String, AbstractFile> fileNameToFileMap = new HashMap<>();
public transient boolean changed;
return new GeneralFile(parentDirectory, fileName);
}
- public AbstractFile getFile(final String fileName) {
+ private AbstractFile getFile(final String fileName) {
return fileNameToFileMap.get(fileName);
}
public Collection<AbstractFile> getFiles() {
- final ArrayList<AbstractFile> files = new ArrayList<AbstractFile>(
+ final ArrayList<AbstractFile> files = new ArrayList<>(
fileNameToFileMap.values());
Collections.sort(files, new FileSortComparator());
return mevizSpecialFile.getFileContent();
}
- public Dimension getImageDimensions(final String fileName)
- throws IOException, ImageFormatError {
+ public Dimension getImageDimensions(final String fileName) {
return ((Picture) getFile(fileName)).getDimensions();
}
- public AbstractFile registerFile(final File parentDirectory, final File file)
+ private AbstractFile registerFile(final File parentDirectory, final File file)
throws Exception {
final String fileName = file.getName();
public void removeUnusedMetadataEntries() {
- for (final String key : new HashSet<String>(fileNameToFileMap.keySet()))
- if (!fileNameToFileMap.get(key).isMetaInfoVerified()) {
- fileNameToFileMap.remove(key);
- changed = true;
- }
+ new HashSet<>(fileNameToFileMap.keySet()).stream().filter(key -> !fileNameToFileMap.get(key).isMetaInfoVerified()).forEach(key -> {
+ fileNameToFileMap.remove(key);
+ changed = true;
+ });
}
}
public class MetadadaHelper {
- public static final Logger logger = Logger.getLogger(MetadadaHelper.class);
+ private static final Logger logger = Logger.getLogger(MetadadaHelper.class);
/**
* Load previously generated or initialize new directory metadata.
import eu.svjatoslav.commons.file.FilePathParser;
import java.io.File;
-import java.io.IOException;
import java.io.Serializable;
public abstract class AbstractFile implements Serializable {
private transient boolean metaInfoVerified;
- public AbstractFile(final File parentDirectory, final String fileName)
+ AbstractFile(final File parentDirectory, final String fileName)
throws Exception {
this.fileName = fileName;
ensureFileMetainfoIsUpToDate(parentDirectory);
return getFile(parentDirectory).exists();
}
- public File getFile(final File parentDirectory) {
+ File getFile(final File parentDirectory) {
return new File(parentDirectory.getAbsolutePath(), fileName);
}
return fileLength;
}
- private boolean isMetainfoUpToDate(final java.io.File parentDirectory)
- throws IOException {
+ private boolean isMetainfoUpToDate(final java.io.File parentDirectory) {
if (metaInfoVerified)
return true;
* exceeding provided thumbnail width and height, and preserving aspect
* ratio of original image.
*/
- public static java.awt.Dimension getTargetThumbnailDimension(
+ private static java.awt.Dimension getTargetThumbnailDimension(
final java.awt.Dimension originalImageDimension,
final java.awt.Dimension desiredTargetDimension) {
* Propose list of thumbnail dimensions.
*/
public static List<Dimension> getThumbnailDimensions(Dimension current) {
- final ArrayList<Dimension> result = new ArrayList<Dimension>();
+ final ArrayList<Dimension> result = new ArrayList<>();
result.add(current);
while (current.getArea() > 1000000) {
/**
* @return new image scaled to desired dimensions
*/
- public static Image scaleImage(final Image srcImage, final int width,
- final int height) {
+ private static Image scaleImage(final Image srcImage, final int width,
+ final int height) {
final ImageFilter filter = new java.awt.image.AreaAveragingScaleFilter(
width, height);
import java.io.File;
-public class CommandlineHandler {
+class CommandlineHandler {
- Parser parser = new Parser();
+ final Parser parser = new Parser();
- NullParameter recursiveParameter = parser.add(
+ private final NullParameter recursiveParameter = parser.add(
new NullParameter("Enable recursive mode.")).addAliases("-r",
"--recursive");
- NullParameter testParameter = parser.add(
+ private final NullParameter testParameter = parser.add(
new NullParameter(
"Simulate renaming (no changes will be actually done)."))
.addAliases("-t", "--test");
- StringParameter outputPatternParameter = parser.add(
+ private final StringParameter outputPatternParameter = parser.add(
new StringParameter("Output pattern.")).addAliases("-o",
"--output-pattern");
- StringParameters inputPatternParameter = parser.add(
+ private final StringParameters inputPatternParameter = parser.add(
new StringParameters("File input pattern.")).addAliases("-i",
"--input-pattern");
- DirectoryParameter workingDirectoryParameter = parser
+ private final DirectoryParameter workingDirectoryParameter = parser
.add(new DirectoryParameter("Working directory."))
.addAliases("-w", "--working-directory").mustExist();
public class Main implements Module {
- public int processedFilesCount;
- CommandlineHandler commandlineHandler = new CommandlineHandler();
- RenamingOptions options;
+ private final CommandlineHandler commandlineHandler = new CommandlineHandler();
+ private int processedFilesCount;
+ private RenamingOptions options;
/**
* Verify that program has enough information to start executing
*
* @return true if all is ok, false if errors were found
*/
- public boolean checkThatThereIsEnoughDataToProceed() {
+ private boolean checkThatThereIsEnoughDataToProceed() {
if (options.inputPatterns.size() == 0) {
System.out.println("Error: no input patterns given.");
return false;
return true;
}
- public boolean fileMatchesInputPattern(final File file) {
+ private boolean fileMatchesInputPattern(final File file) {
final String fileName = file.getName();
for (final String inputPattern : options.inputPatterns)
}
}
- public void processFileOrDirectory(final File file) {
+ private void processFileOrDirectory(final File file) {
if (!file.exists()) {
System.out.println("Error: file \"" + file.getAbsolutePath()
+ "\" does not exist.");
}
- public void rename() {
+ private void rename() {
processFileOrDirectory(options.targetDirectory);
}
public class RenamingOptions {
- public ArrayList<String> inputPatterns = new ArrayList<String>();
+ public final ArrayList<String> inputPatterns = new ArrayList<>();
public boolean recursive = false;
import java.io.File;
-public class CommandlineHandler {
+class CommandlineHandler {
- Parser parser = new Parser();
+ final Parser parser = new Parser();
- NullParameter recursiveParameter = parser.add(
+ private final NullParameter recursiveParameter = parser.add(
new NullParameter("Enable recursive mode.")).addAliases("-r",
"--recursive");
- StringParameter searchForPattern = parser
+ private final StringParameter searchForPattern = parser
.add(new StringParameter("String to search for"))
.addAliases("-s", "--search-pattern").setMandatory();
- StringParameter replaceWithPattern = parser.add(
+ private final StringParameter replaceWithPattern = parser.add(
new StringParameter("String to place instead")).addAliases("-p",
"--replace-pattern");
- DirectoryParameter directoryParameter = parser
+ private final DirectoryParameter directoryParameter = parser
.add(new DirectoryParameter("Working directory."))
.addAliases("-w", "--working-directory").mustExist();
public class Main implements Module {
- CommandlineHandler commandlineHandler = new CommandlineHandler();
+ private final CommandlineHandler commandlineHandler = new CommandlineHandler();
- CommandlineOptions options;
+ private CommandlineOptions options;
@Override
public String getDescription() {
return "replace";
}
- public void processDirectory(final File directory) {
+ private void processDirectory(final File directory) {
for (final File file : directory.listFiles())
if (file.isDirectory()) {
}
- public void processFile(final File file) throws IOException {
+ private void processFile(final File file) throws IOException {
final FileReader fileReader = new FileReader(file);
final BufferedReader bufferedReader = new BufferedReader(fileReader);
import java.io.File;
-public class CommandlineHandler {
+class CommandlineHandler {
- Parser parser = new Parser();
+ final Parser parser = new Parser();
- NullParameter recursiveParameter = parser.add(
+ private final NullParameter recursiveParameter = parser.add(
new NullParameter("Enable recursive mode.")).addAliases("-r",
"--recursive");
- StringParameters fileInputPatternsParameter = parser.add(
+ private final StringParameters fileInputPatternsParameter = parser.add(
new StringParameters("File input pattern.").addAliases("-i",
"--input-pattern")).setMandatory();
- StringParameters splitPatternsParameter = parser
+ private final StringParameters splitPatternsParameter = parser
.add(new StringParameters("File split regular expression."))
.addAliases("-s", "--split-pattern").setMandatory();
- DirectoryParameter workingDirectoryParameter = parser.add(
+ private final DirectoryParameter workingDirectoryParameter = parser.add(
new DirectoryParameter("Working directory.")).addAliases("-w",
"--working-directory");
public class Main implements Module {
- CommandlineHandler commandlineHandler = new CommandlineHandler();
+ private final CommandlineHandler commandlineHandler = new CommandlineHandler();
- TextSplittingOptions options;
+ private TextSplittingOptions options;
- public boolean fileMatchesInputPattern(final File file) {
+ private boolean fileMatchesInputPattern(final File file) {
final String fileName = file.getName().toLowerCase();
for (final String inputPattern : options.fileInputPatterns)
return new File(targetFilePath.toString());
}
- public void processDirectory(final File directory) {
+ private void processDirectory(final File directory) {
for (final File subFile : directory.listFiles())
if (subFile.isDirectory()) {
}
- public void processFile(final File file) throws IOException {
+ private void processFile(final File file) throws IOException {
final File targetFile = getTargetFile(file);
final BufferedReader bufferedReader = new BufferedReader(
public class TextSplittingOptions {
- public ArrayList<String> fileInputPatterns = new ArrayList<String>();
+ public final ArrayList<String> fileInputPatterns = new ArrayList<>();
- public ArrayList<String> textSplitPatterns = new ArrayList<String>();
+ public final ArrayList<String> textSplitPatterns = new ArrayList<>();
public boolean recursive = false;
import java.io.File;
-public class CommandlineHandler {
+class CommandlineHandler {
- Parser parser = new Parser();
+ final Parser parser = new Parser();
- NullParameter recursiveParameter = parser.add(
+ private final NullParameter recursiveParameter = parser.add(
new NullParameter("Enable recursive mode.")).addAliases("-r",
"--recursive");
- StringParameters inputPatternParameter = parser.add(
+ private final StringParameters inputPatternParameter = parser.add(
new StringParameters("File input pattern.")).addAliases("-i",
"--input-pattern");
- DirectoryParameter workingDirectoryParameter = parser.add(
+ private final DirectoryParameter workingDirectoryParameter = parser.add(
new DirectoryParameter("Working directory.")).addAliases("-w",
"--working-directory");
public class Main implements Module {
- public static final int targetLineLength = 200;
+ private static final int targetLineLength = 200;
- public static final int maxSplittedLines = 3;
+ private static final int maxSplittedLines = 3;
- public static final String splitLinePrefix = " ";
+ private static final String splitLinePrefix = " ";
- CommandlineHandler commandlineHandler = new CommandlineHandler();
+ private final CommandlineHandler commandlineHandler = new CommandlineHandler();
- TextTruncatingOptions options;
+ private TextTruncatingOptions options;
- public boolean fileMatchesInputPattern(final File file) {
+ private boolean fileMatchesInputPattern(final File file) {
final String fileName = file.getName().toLowerCase();
for (final String inputPattern : options.inputPatterns)
return new File(targetFilePath.toString());
}
- public void processDirectory(final File directory) {
+ private void processDirectory(final File directory) {
for (final File subFile : directory.listFiles())
if (subFile.isDirectory()) {
}
- public void processFile(final File file) throws IOException {
+ private void processFile(final File file) throws IOException {
final File targetFile = getTargetFile(file);
final BufferedReader bufferedReader = new BufferedReader(
public class TextTruncatingOptions {
- public ArrayList<String> inputPatterns = new ArrayList<String>();
+ public final ArrayList<String> inputPatterns = new ArrayList<>();
public boolean recursive = false;