/*
* Meviz - Various tools collection to work with multimedia.
- * Copyright (C) 2012, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
+ * Copyright (C) 2012 -- 2019, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
*
* This program is free software; you can redistribute it and/or
- * modify it under the terms of version 2 of the GNU General Public License
- * as published by the Free Software Foundation.
- */
+ * modify it under the terms of version 3 of the GNU Lesser General Public License
+ * or later as published by the Free Software Foundation.
+*/
package eu.svjatoslav.meviz.bomremove;
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);