From 891ecca562e87bb5d0ab1e49eea566c15fe91c6d Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Tue, 12 Jul 2016 16:11:20 +0300 Subject: [PATCH] Moved to Java 8. Code cleanup. --- meviz.iml | 2 +- pom.xml | 4 ++-- src/main/java/eu/svjatoslav/meviz/Main.java | 12 +++++----- .../meviz/bomremove/BomStrippingOptions.java | 2 +- .../meviz/bomremove/CommandlineHandler.java | 10 ++++---- .../eu/svjatoslav/meviz/bomremove/Main.java | 18 +++++++------- .../meviz/encoder/CommandlineHandler.java | 24 +++++++++---------- .../eu/svjatoslav/meviz/encoder/Encoder.java | 15 +++++------- .../meviz/encoder/EncodingOptions.java | 4 ++-- .../meviz/encoder/EncodingPlan.java | 6 ++--- .../meviz/encoder/EncodingTask.java | 6 ++--- .../meviz/encoder/FormatsRegistry.java | 6 ++--- .../encoder/converters/AbstractConverter.java | 8 +++---- .../eu/svjatoslav/meviz/grabmemcard/Main.java | 9 ++++--- .../meviz/htmlindexer/AbstractIndexer.java | 6 ++--- .../meviz/htmlindexer/CommandlineHandler.java | 17 ++++++------- .../htmlindexer/FilesystemIndexRemover.java | 4 ++-- .../meviz/htmlindexer/FilesystemIndexer.java | 20 ++++++++-------- .../meviz/htmlindexer/ImageFormatError.java | 2 +- .../meviz/htmlindexer/IndexingContext.java | 2 +- .../svjatoslav/meviz/htmlindexer/Layout.java | 4 ++-- .../eu/svjatoslav/meviz/htmlindexer/Main.java | 4 ++-- .../svjatoslav/meviz/htmlindexer/Utils.java | 10 +++----- .../meviz/htmlindexer/WebIndexer.java | 2 +- .../htmlindexer/layouts/MixedLayout.java | 14 +++++------ .../meviz/htmlindexer/metadata/Dimension.java | 2 +- .../metadata/DirectoryMetadata.java | 22 +++++++---------- .../htmlindexer/metadata/MetadadaHelper.java | 2 +- .../metadata/fileTypes/AbstractFile.java | 8 +++---- .../metadata/fileTypes/Picture.java | 8 +++---- .../meviz/renamer/CommandlineHandler.java | 14 +++++------ .../eu/svjatoslav/meviz/renamer/Main.java | 14 +++++------ .../meviz/renamer/RenamingOptions.java | 2 +- .../meviz/replace/CommandlineHandler.java | 12 +++++----- .../eu/svjatoslav/meviz/replace/Main.java | 8 +++---- .../textsplitter/CommandlineHandler.java | 12 +++++----- .../svjatoslav/meviz/textsplitter/Main.java | 10 ++++---- .../textsplitter/TextSplittingOptions.java | 4 ++-- .../texttruncate/CommandlineHandler.java | 10 ++++---- .../svjatoslav/meviz/texttruncate/Main.java | 16 ++++++------- .../texttruncate/TextTruncatingOptions.java | 2 +- 41 files changed, 168 insertions(+), 189 deletions(-) diff --git a/meviz.iml b/meviz.iml index 8cdc9f9..4ca17be 100644 --- a/meviz.iml +++ b/meviz.iml @@ -1,6 +1,6 @@ - + diff --git a/pom.xml b/pom.xml index 7b104ea..9e07573 100644 --- a/pom.xml +++ b/pom.xml @@ -71,8 +71,8 @@ maven-compiler-plugin 2.3.2 - 1.6 - 1.6 + 1.8 + 1.8 UTF-8 diff --git a/src/main/java/eu/svjatoslav/meviz/Main.java b/src/main/java/eu/svjatoslav/meviz/Main.java index 9fc8f98..d1b9d51 100755 --- a/src/main/java/eu/svjatoslav/meviz/Main.java +++ b/src/main/java/eu/svjatoslav/meviz/Main.java @@ -13,11 +13,11 @@ import eu.svjatoslav.meviz.encoder.Encoder; import java.util.ArrayList; -public class Main { +class Main { - public static ArrayList modules; + private static ArrayList 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); @@ -25,8 +25,8 @@ public class Main { return remainingOptions; } - public static void initModules() { - modules = new ArrayList(); + private static void initModules() { + modules = new ArrayList<>(); modules.add(new Encoder()); modules.add(new eu.svjatoslav.meviz.htmlindexer.Main()); @@ -75,7 +75,7 @@ public class Main { } - public static void showHelp() { + private static void showHelp() { final StringBuilder buffer = new StringBuilder(); buffer.append("Commandline options: \n" diff --git a/src/main/java/eu/svjatoslav/meviz/bomremove/BomStrippingOptions.java b/src/main/java/eu/svjatoslav/meviz/bomremove/BomStrippingOptions.java index 491f64f..364131c 100755 --- a/src/main/java/eu/svjatoslav/meviz/bomremove/BomStrippingOptions.java +++ b/src/main/java/eu/svjatoslav/meviz/bomremove/BomStrippingOptions.java @@ -14,7 +14,7 @@ import java.util.ArrayList; public class BomStrippingOptions { - public ArrayList inputPatterns = new ArrayList(); + public final ArrayList inputPatterns = new ArrayList<>(); public boolean recursive = false; diff --git a/src/main/java/eu/svjatoslav/meviz/bomremove/CommandlineHandler.java b/src/main/java/eu/svjatoslav/meviz/bomremove/CommandlineHandler.java index 367a7f2..627dbf8 100755 --- a/src/main/java/eu/svjatoslav/meviz/bomremove/CommandlineHandler.java +++ b/src/main/java/eu/svjatoslav/meviz/bomremove/CommandlineHandler.java @@ -16,19 +16,19 @@ import eu.svjatoslav.commons.commandline.parameterparser.parameter.StringParamet 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(); diff --git a/src/main/java/eu/svjatoslav/meviz/bomremove/Main.java b/src/main/java/eu/svjatoslav/meviz/bomremove/Main.java index d792bb6..65c99da 100755 --- a/src/main/java/eu/svjatoslav/meviz/bomremove/Main.java +++ b/src/main/java/eu/svjatoslav/meviz/bomremove/Main.java @@ -20,13 +20,13 @@ import java.util.Arrays; 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]) @@ -35,7 +35,7 @@ public class Main implements Module { return true; } - public boolean fileContainsHeader(final File file) + private boolean fileContainsHeader(final File file) throws IOException { final FileInputStream fileInputStream = new FileInputStream(file); @@ -47,7 +47,7 @@ public class Main implements Module { 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) @@ -67,7 +67,7 @@ public class Main implements Module { return "stripbom"; } - public void processDirectory(final File directory) { + private void processDirectory(final File directory) { for (final File subFile : directory.listFiles()) if (subFile.isDirectory()) { @@ -85,7 +85,7 @@ public class Main implements Module { } - public void processFile(final File file) throws IOException { + private void processFile(final File file) throws IOException { if (file.length() < bomHeader.length) return; @@ -116,7 +116,7 @@ public class Main implements Module { 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); diff --git a/src/main/java/eu/svjatoslav/meviz/encoder/CommandlineHandler.java b/src/main/java/eu/svjatoslav/meviz/encoder/CommandlineHandler.java index dc1601d..367742e 100755 --- a/src/main/java/eu/svjatoslav/meviz/encoder/CommandlineHandler.java +++ b/src/main/java/eu/svjatoslav/meviz/encoder/CommandlineHandler.java @@ -15,37 +15,37 @@ import eu.svjatoslav.commons.commandline.parameterparser.parameter.IntegerParame 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"); /** diff --git a/src/main/java/eu/svjatoslav/meviz/encoder/Encoder.java b/src/main/java/eu/svjatoslav/meviz/encoder/Encoder.java index fda023e..2c5d088 100755 --- a/src/main/java/eu/svjatoslav/meviz/encoder/Encoder.java +++ b/src/main/java/eu/svjatoslav/meviz/encoder/Encoder.java @@ -19,20 +19,17 @@ import java.util.List; 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."); @@ -106,7 +103,7 @@ public class Encoder implements Module { * @param file single file candidate to potentially be encoded * @return true 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()) diff --git a/src/main/java/eu/svjatoslav/meviz/encoder/EncodingOptions.java b/src/main/java/eu/svjatoslav/meviz/encoder/EncodingOptions.java index b4efb1f..04e86e6 100755 --- a/src/main/java/eu/svjatoslav/meviz/encoder/EncodingOptions.java +++ b/src/main/java/eu/svjatoslav/meviz/encoder/EncodingOptions.java @@ -31,9 +31,9 @@ public class EncodingOptions { private File workingDirectory = new File(System.getProperty("user.dir")); - private List outputFormats = new ArrayList(); + private List outputFormats = new ArrayList<>(); - private List inputPatterns = new ArrayList(); + private List inputPatterns = new ArrayList<>(); public BitrateParameter.bitrate getAudioBitrate() { return audioBitrate; diff --git a/src/main/java/eu/svjatoslav/meviz/encoder/EncodingPlan.java b/src/main/java/eu/svjatoslav/meviz/encoder/EncodingPlan.java index 0838d1a..49c52cc 100755 --- a/src/main/java/eu/svjatoslav/meviz/encoder/EncodingPlan.java +++ b/src/main/java/eu/svjatoslav/meviz/encoder/EncodingPlan.java @@ -9,15 +9,13 @@ package eu.svjatoslav.meviz.encoder; -import java.io.IOException; import java.util.ArrayList; public class EncodingPlan { - public ArrayList encodingTasks = new ArrayList(); + private final ArrayList 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); diff --git a/src/main/java/eu/svjatoslav/meviz/encoder/EncodingTask.java b/src/main/java/eu/svjatoslav/meviz/encoder/EncodingTask.java index 896ce15..67beb8c 100755 --- a/src/main/java/eu/svjatoslav/meviz/encoder/EncodingTask.java +++ b/src/main/java/eu/svjatoslav/meviz/encoder/EncodingTask.java @@ -41,11 +41,11 @@ public class EncodingTask { /** * @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()) { @@ -80,7 +80,7 @@ public class EncodingTask { } - public String getCommand(final EncodingOptions encodingOptions) { + private String getCommand(final EncodingOptions encodingOptions) { return converter.getCommand(source, target, encodingOptions, targetFormat); } diff --git a/src/main/java/eu/svjatoslav/meviz/encoder/FormatsRegistry.java b/src/main/java/eu/svjatoslav/meviz/encoder/FormatsRegistry.java index 7395c31..9870ced 100755 --- a/src/main/java/eu/svjatoslav/meviz/encoder/FormatsRegistry.java +++ b/src/main/java/eu/svjatoslav/meviz/encoder/FormatsRegistry.java @@ -16,7 +16,7 @@ import java.util.List; public class FormatsRegistry { - public ArrayList encoders = new ArrayList(); + private final ArrayList encoders = new ArrayList<>(); public FormatsRegistry() { // video conversion @@ -42,7 +42,7 @@ public class FormatsRegistry { final String sourceFormatLowerCase = sourceFormat.toLowerCase(); final String targetFormatLowerCase = targetFormat.toLowerCase(); - final ArrayList encoders = new ArrayList(); + final ArrayList encoders = new ArrayList<>(); for (final AbstractConverter encoder : this.encoders) if (encoder.supportsSource(sourceFormatLowerCase)) @@ -54,7 +54,7 @@ public class FormatsRegistry { return encoders; } - public void registerEncoder(final AbstractConverter encoder) { + private void registerEncoder(final AbstractConverter encoder) { encoders.add(encoder); } diff --git a/src/main/java/eu/svjatoslav/meviz/encoder/converters/AbstractConverter.java b/src/main/java/eu/svjatoslav/meviz/encoder/converters/AbstractConverter.java index 322566b..0d935c1 100755 --- a/src/main/java/eu/svjatoslav/meviz/encoder/converters/AbstractConverter.java +++ b/src/main/java/eu/svjatoslav/meviz/encoder/converters/AbstractConverter.java @@ -21,9 +21,9 @@ public abstract class AbstractConverter { public abstract String getCommand(File inputFile, File targetFile, EncodingOptions options, String targetFormat); - public abstract List getSourceFileExtensions(); + protected abstract List getSourceFileExtensions(); - public abstract List getTargetFileExtensions(); + protected abstract List getTargetFileExtensions(); /** * For some reasons some encoders require terminal to run. Until this is @@ -39,8 +39,8 @@ public abstract class AbstractConverter { return getTargetFileExtensions().contains(format); } - public List toList(final String... strings) { - final ArrayList result = new ArrayList(); + List toList(final String... strings) { + final ArrayList result = new ArrayList<>(); Collections.addAll(result, strings); diff --git a/src/main/java/eu/svjatoslav/meviz/grabmemcard/Main.java b/src/main/java/eu/svjatoslav/meviz/grabmemcard/Main.java index 44faebc..ae9f42e 100755 --- a/src/main/java/eu/svjatoslav/meviz/grabmemcard/Main.java +++ b/src/main/java/eu/svjatoslav/meviz/grabmemcard/Main.java @@ -31,7 +31,7 @@ public class Main implements Module { 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); @@ -41,7 +41,7 @@ public class Main implements Module { 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; @@ -61,7 +61,7 @@ public class Main implements Module { } @SuppressWarnings("deprecation") - public File getTargetDirectory() { + private File getTargetDirectory() { final Date now = new Date(); final GregorianCalendar calendar = new GregorianCalendar(); @@ -85,8 +85,7 @@ public class Main implements Module { 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 diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/AbstractIndexer.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/AbstractIndexer.java index 2394ece..5036721 100644 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/AbstractIndexer.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/AbstractIndexer.java @@ -23,7 +23,7 @@ public abstract class AbstractIndexer { return fileExtension.equalsIgnoreCase("ogv"); } - public static boolean shallFileBeIndexed(final File file) { + static boolean shallFileBeIndexed(final File file) { if (file.getName().startsWith(".")) return false; @@ -34,8 +34,8 @@ public abstract class AbstractIndexer { 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()) diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/CommandlineHandler.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/CommandlineHandler.java index d45bc84..497b5b3 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/CommandlineHandler.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/CommandlineHandler.java @@ -17,23 +17,20 @@ import eu.svjatoslav.meviz.encoder.EncodingOptions; 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(); diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexRemover.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexRemover.java index 0b3b816..30f1099 100644 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexRemover.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexRemover.java @@ -5,7 +5,7 @@ import eu.svjatoslav.commons.file.IOHelper; import java.io.File; import java.io.IOException; -public class FilesystemIndexRemover { +class FilesystemIndexRemover { private final CommandlineHandler commandlineHandler; @@ -16,7 +16,7 @@ public class FilesystemIndexRemover { 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 diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexer.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexer.java index 86ad818..6aa927c 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexer.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/FilesystemIndexer.java @@ -29,10 +29,10 @@ import java.util.List; public class FilesystemIndexer extends AbstractIndexer { - public static final Logger logger = Logger + private static final Logger logger = Logger .getLogger(FilesystemIndexer.class); - private final HashSet validMetadataFiles = new HashSet(); + private final HashSet validMetadataFiles = new HashSet<>(); private final File directoryToIndex; private final List pathElements; @@ -73,14 +73,14 @@ public class FilesystemIndexer extends AbstractIndexer { } - 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 layouts) { + private void generateHtmlFromMetadata(final HashSet layouts) { // Generate HTML from metadata for (final Layout layout : layouts) try { @@ -99,9 +99,9 @@ public class FilesystemIndexer extends AbstractIndexer { } } - public List getChildPath(final File file) { + private List getChildPath(final File file) { - final List result = new ArrayList(); + final List result = new ArrayList<>(); result.addAll(pathElements); result.add(file.getName()); @@ -149,7 +149,7 @@ public class FilesystemIndexer extends AbstractIndexer { + Utils.urlEncode(thumbnailFileName); } - public void initializeLayouts() { + private void initializeLayouts() { layouts = Utils.getLayouts(); @@ -160,7 +160,7 @@ public class FilesystemIndexer extends AbstractIndexer { "", ".")); } - public void initializeThumbnailsDirectory() { + private void initializeThumbnailsDirectory() { final File thumbnailsDirectory = Utils .getThumbnailsDirectory(directoryToIndex); @@ -168,7 +168,7 @@ public class FilesystemIndexer extends AbstractIndexer { thumbnailsDirectory.mkdirs(); } - public void loadOrCreateMetadata() { + private void loadOrCreateMetadata() { metadataFile = new File( Utils.getThumbnailsDirectoryPath(directoryToIndex) @@ -186,7 +186,7 @@ public class FilesystemIndexer extends AbstractIndexer { } - public void updateMetadata() throws Exception { + private void updateMetadata() throws Exception { for (final File file : directoryToIndex.listFiles()) if (shallFileBeIndexed(file)) { diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/ImageFormatError.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/ImageFormatError.java index 7d40bf4..c2089a1 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/ImageFormatError.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/ImageFormatError.java @@ -9,7 +9,7 @@ package eu.svjatoslav.meviz.htmlindexer; -public class ImageFormatError extends Exception { +class ImageFormatError extends Exception { private static final long serialVersionUID = 4037233564457071385L; diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/IndexingContext.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/IndexingContext.java index 2ec1bed..585f934 100644 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/IndexingContext.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/IndexingContext.java @@ -19,7 +19,7 @@ public class IndexingContext { public List getLocalPathComponents() { - final List result = new ArrayList(); + final List result = new ArrayList<>(); final String[] strings = localUrl.split("/"); diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/Layout.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/Layout.java index f9e0982..f434f92 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/Layout.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/Layout.java @@ -51,7 +51,7 @@ public interface Layout { */ void enlistOgv(AbstractFile file, DirectoryMetadata parentDirectoryMetadata) - throws UnsupportedEncodingException; + ; /** * Return layout specific suffix that will be appended between @@ -68,7 +68,7 @@ public interface Layout { */ String getHtml(final boolean showTitle, final boolean doHtmlHeaderAndFooter, DirectoryMetadata metadata) - throws IOException; + ; /** * Initialize layout for particular directory. diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/Main.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/Main.java index 77eb377..f524490 100644 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/Main.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/Main.java @@ -6,7 +6,7 @@ import java.util.ArrayList; public class Main implements Module { - CommandlineHandler commandlineHandler = new CommandlineHandler(); + private final CommandlineHandler commandlineHandler = new CommandlineHandler(); /** * {@inheritDoc} @@ -35,7 +35,7 @@ public class Main implements Module { new FilesystemIndexRemover(commandlineHandler); else new FilesystemIndexer(commandlineHandler.getWorkingDirectory(), - commandlineHandler, new ArrayList()); + commandlineHandler, new ArrayList<>()); } diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java index 028995b..69c1c43 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/Utils.java @@ -60,7 +60,7 @@ public class Utils { } public static HashSet getLayouts() { - final HashSet layouts = new HashSet(); + final HashSet layouts = new HashSet<>(); layouts.add(new MixedLayout()); return layouts; } @@ -76,13 +76,9 @@ public class Utils { 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) { diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/WebIndexer.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/WebIndexer.java index dd52973..beaea50 100644 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/WebIndexer.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/WebIndexer.java @@ -65,7 +65,7 @@ public class WebIndexer extends AbstractIndexer { 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 + diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/layouts/MixedLayout.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/layouts/MixedLayout.java index ebc5ca2..aae1a19 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/layouts/MixedLayout.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/layouts/MixedLayout.java @@ -19,22 +19,21 @@ import eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes.Picture; 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 path; + private List path; private AbstractIndexer indexer; @@ -132,8 +131,7 @@ public class MixedLayout implements Layout { */ @Override public void enlistOgv(final AbstractFile abstractFile, - final DirectoryMetadata parentDirectoryMetadata) - throws UnsupportedEncodingException { + final DirectoryMetadata parentDirectoryMetadata) { final GeneralFile file = (GeneralFile) abstractFile; diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/Dimension.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/Dimension.java index db51f50..5c144f4 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/Dimension.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/Dimension.java @@ -22,7 +22,7 @@ public class Dimension implements Serializable, Comparable { public int width; public int height; - public Dimension() { + private Dimension() { width = 0; height = 0; } diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/DirectoryMetadata.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/DirectoryMetadata.java index 0dcdf12..600d65c 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/DirectoryMetadata.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/DirectoryMetadata.java @@ -12,11 +12,9 @@ package eu.svjatoslav.meviz.htmlindexer.metadata; 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.*; @@ -27,7 +25,7 @@ public class DirectoryMetadata implements Serializable { private static final long serialVersionUID = 3526489102725366334L; - private final HashMap fileNameToFileMap = new HashMap(); + private final HashMap fileNameToFileMap = new HashMap<>(); public transient boolean changed; @@ -89,13 +87,13 @@ public class DirectoryMetadata implements Serializable { return new GeneralFile(parentDirectory, fileName); } - public AbstractFile getFile(final String fileName) { + private AbstractFile getFile(final String fileName) { return fileNameToFileMap.get(fileName); } public Collection getFiles() { - final ArrayList files = new ArrayList( + final ArrayList files = new ArrayList<>( fileNameToFileMap.values()); Collections.sort(files, new FileSortComparator()); @@ -112,13 +110,12 @@ public class DirectoryMetadata implements Serializable { 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(); @@ -135,11 +132,10 @@ public class DirectoryMetadata implements Serializable { public void removeUnusedMetadataEntries() { - for (final String key : new HashSet(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; + }); } } diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/MetadadaHelper.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/MetadadaHelper.java index 0013d1c..3e75939 100644 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/MetadadaHelper.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/MetadadaHelper.java @@ -16,7 +16,7 @@ import java.io.*; 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. diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/fileTypes/AbstractFile.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/fileTypes/AbstractFile.java index 9c35a32..7662093 100644 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/fileTypes/AbstractFile.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/fileTypes/AbstractFile.java @@ -3,7 +3,6 @@ package eu.svjatoslav.meviz.htmlindexer.metadata.fileTypes; import eu.svjatoslav.commons.file.FilePathParser; import java.io.File; -import java.io.IOException; import java.io.Serializable; public abstract class AbstractFile implements Serializable { @@ -22,7 +21,7 @@ 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); @@ -46,7 +45,7 @@ public abstract class AbstractFile implements Serializable { return getFile(parentDirectory).exists(); } - public File getFile(final File parentDirectory) { + File getFile(final File parentDirectory) { return new File(parentDirectory.getAbsolutePath(), fileName); } @@ -58,8 +57,7 @@ public abstract class AbstractFile implements Serializable { return fileLength; } - private boolean isMetainfoUpToDate(final java.io.File parentDirectory) - throws IOException { + private boolean isMetainfoUpToDate(final java.io.File parentDirectory) { if (metaInfoVerified) return true; diff --git a/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/fileTypes/Picture.java b/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/fileTypes/Picture.java index 7ed4d09..4c3aee7 100755 --- a/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/fileTypes/Picture.java +++ b/src/main/java/eu/svjatoslav/meviz/htmlindexer/metadata/fileTypes/Picture.java @@ -53,7 +53,7 @@ public class Picture extends AbstractFile { * 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) { @@ -87,7 +87,7 @@ public class Picture extends AbstractFile { * Propose list of thumbnail dimensions. */ public static List getThumbnailDimensions(Dimension current) { - final ArrayList result = new ArrayList(); + final ArrayList result = new ArrayList<>(); result.add(current); while (current.getArea() > 1000000) { @@ -138,8 +138,8 @@ public class Picture extends AbstractFile { /** * @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); diff --git a/src/main/java/eu/svjatoslav/meviz/renamer/CommandlineHandler.java b/src/main/java/eu/svjatoslav/meviz/renamer/CommandlineHandler.java index 708cf16..ec49573 100755 --- a/src/main/java/eu/svjatoslav/meviz/renamer/CommandlineHandler.java +++ b/src/main/java/eu/svjatoslav/meviz/renamer/CommandlineHandler.java @@ -18,28 +18,28 @@ import eu.svjatoslav.meviz.encoder.EncodingOptions; 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(); diff --git a/src/main/java/eu/svjatoslav/meviz/renamer/Main.java b/src/main/java/eu/svjatoslav/meviz/renamer/Main.java index 6495e0f..073898e 100755 --- a/src/main/java/eu/svjatoslav/meviz/renamer/Main.java +++ b/src/main/java/eu/svjatoslav/meviz/renamer/Main.java @@ -17,16 +17,16 @@ import java.util.Arrays; 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; @@ -40,7 +40,7 @@ public class Main implements Module { 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) @@ -119,7 +119,7 @@ public class Main implements Module { } } - 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."); @@ -134,7 +134,7 @@ public class Main implements Module { } - public void rename() { + private void rename() { processFileOrDirectory(options.targetDirectory); } diff --git a/src/main/java/eu/svjatoslav/meviz/renamer/RenamingOptions.java b/src/main/java/eu/svjatoslav/meviz/renamer/RenamingOptions.java index a9a1c04..5670c8e 100755 --- a/src/main/java/eu/svjatoslav/meviz/renamer/RenamingOptions.java +++ b/src/main/java/eu/svjatoslav/meviz/renamer/RenamingOptions.java @@ -14,7 +14,7 @@ import java.util.ArrayList; public class RenamingOptions { - public ArrayList inputPatterns = new ArrayList(); + public final ArrayList inputPatterns = new ArrayList<>(); public boolean recursive = false; diff --git a/src/main/java/eu/svjatoslav/meviz/replace/CommandlineHandler.java b/src/main/java/eu/svjatoslav/meviz/replace/CommandlineHandler.java index d8147a1..5c6d44b 100755 --- a/src/main/java/eu/svjatoslav/meviz/replace/CommandlineHandler.java +++ b/src/main/java/eu/svjatoslav/meviz/replace/CommandlineHandler.java @@ -16,23 +16,23 @@ import eu.svjatoslav.commons.commandline.parameterparser.parameter.StringParamet 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(); diff --git a/src/main/java/eu/svjatoslav/meviz/replace/Main.java b/src/main/java/eu/svjatoslav/meviz/replace/Main.java index 3f42a9a..64c47d7 100755 --- a/src/main/java/eu/svjatoslav/meviz/replace/Main.java +++ b/src/main/java/eu/svjatoslav/meviz/replace/Main.java @@ -15,9 +15,9 @@ import java.io.*; public class Main implements Module { - CommandlineHandler commandlineHandler = new CommandlineHandler(); + private final CommandlineHandler commandlineHandler = new CommandlineHandler(); - CommandlineOptions options; + private CommandlineOptions options; @Override public String getDescription() { @@ -29,7 +29,7 @@ public class Main implements Module { return "replace"; } - public void processDirectory(final File directory) { + private void processDirectory(final File directory) { for (final File file : directory.listFiles()) if (file.isDirectory()) { @@ -47,7 +47,7 @@ public class Main implements Module { } - 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); diff --git a/src/main/java/eu/svjatoslav/meviz/textsplitter/CommandlineHandler.java b/src/main/java/eu/svjatoslav/meviz/textsplitter/CommandlineHandler.java index 322d56c..a07d10c 100755 --- a/src/main/java/eu/svjatoslav/meviz/textsplitter/CommandlineHandler.java +++ b/src/main/java/eu/svjatoslav/meviz/textsplitter/CommandlineHandler.java @@ -16,23 +16,23 @@ import eu.svjatoslav.commons.commandline.parameterparser.parameter.StringParamet 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"); diff --git a/src/main/java/eu/svjatoslav/meviz/textsplitter/Main.java b/src/main/java/eu/svjatoslav/meviz/textsplitter/Main.java index aaaecde..cad3b05 100755 --- a/src/main/java/eu/svjatoslav/meviz/textsplitter/Main.java +++ b/src/main/java/eu/svjatoslav/meviz/textsplitter/Main.java @@ -18,11 +18,11 @@ import java.io.*; 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) @@ -62,7 +62,7 @@ public class Main implements Module { 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()) { @@ -80,7 +80,7 @@ public class Main implements Module { } - 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( diff --git a/src/main/java/eu/svjatoslav/meviz/textsplitter/TextSplittingOptions.java b/src/main/java/eu/svjatoslav/meviz/textsplitter/TextSplittingOptions.java index 0f0cd42..33365bc 100755 --- a/src/main/java/eu/svjatoslav/meviz/textsplitter/TextSplittingOptions.java +++ b/src/main/java/eu/svjatoslav/meviz/textsplitter/TextSplittingOptions.java @@ -14,9 +14,9 @@ import java.util.ArrayList; public class TextSplittingOptions { - public ArrayList fileInputPatterns = new ArrayList(); + public final ArrayList fileInputPatterns = new ArrayList<>(); - public ArrayList textSplitPatterns = new ArrayList(); + public final ArrayList textSplitPatterns = new ArrayList<>(); public boolean recursive = false; diff --git a/src/main/java/eu/svjatoslav/meviz/texttruncate/CommandlineHandler.java b/src/main/java/eu/svjatoslav/meviz/texttruncate/CommandlineHandler.java index dc294d6..5d657e5 100755 --- a/src/main/java/eu/svjatoslav/meviz/texttruncate/CommandlineHandler.java +++ b/src/main/java/eu/svjatoslav/meviz/texttruncate/CommandlineHandler.java @@ -16,19 +16,19 @@ import eu.svjatoslav.commons.commandline.parameterparser.parameter.StringParamet 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"); diff --git a/src/main/java/eu/svjatoslav/meviz/texttruncate/Main.java b/src/main/java/eu/svjatoslav/meviz/texttruncate/Main.java index 4dfd1af..63d0ad0 100755 --- a/src/main/java/eu/svjatoslav/meviz/texttruncate/Main.java +++ b/src/main/java/eu/svjatoslav/meviz/texttruncate/Main.java @@ -18,17 +18,17 @@ import java.io.*; 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) @@ -68,7 +68,7 @@ public class Main implements Module { 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()) { @@ -86,7 +86,7 @@ public class Main implements Module { } - 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( diff --git a/src/main/java/eu/svjatoslav/meviz/texttruncate/TextTruncatingOptions.java b/src/main/java/eu/svjatoslav/meviz/texttruncate/TextTruncatingOptions.java index 229443c..563754e 100755 --- a/src/main/java/eu/svjatoslav/meviz/texttruncate/TextTruncatingOptions.java +++ b/src/main/java/eu/svjatoslav/meviz/texttruncate/TextTruncatingOptions.java @@ -14,7 +14,7 @@ import java.util.ArrayList; public class TextTruncatingOptions { - public ArrayList inputPatterns = new ArrayList(); + public final ArrayList inputPatterns = new ArrayList<>(); public boolean recursive = false; -- 2.20.1