From 0efd9007f763a2e4db0861e17be5c5e99101005c Mon Sep 17 00:00:00 2001 From: Jochen Staerk Date: Thu, 22 Oct 2015 15:06:54 +0200 Subject: [PATCH] version 0.0.6 --- mustang/toecount/pom.xml | 4 ++-- .../src/main/java/toecount/FileChecker.java | 11 +++-------- .../src/main/java/toecount/FileTraverser.java | 11 +---------- .../toecount/src/main/java/toecount/StatRun.java | 8 ++++++++ .../src/main/java/toecount/Toecount.java | 16 ++++++---------- 5 files changed, 20 insertions(+), 30 deletions(-) mode change 100644 => 100755 mustang/toecount/pom.xml mode change 100644 => 100755 mustang/toecount/src/main/java/toecount/FileChecker.java mode change 100644 => 100755 mustang/toecount/src/main/java/toecount/FileTraverser.java mode change 100644 => 100755 mustang/toecount/src/main/java/toecount/StatRun.java mode change 100644 => 100755 mustang/toecount/src/main/java/toecount/Toecount.java diff --git a/mustang/toecount/pom.xml b/mustang/toecount/pom.xml old mode 100644 new mode 100755 index 24eda5cb..01a276b5 --- a/mustang/toecount/pom.xml +++ b/mustang/toecount/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.mustangproject.ZUGFeRD toecount - 0.0.5-SNAPSHOT + 0.0.6-SNAPSHOT ZUGFeRD PDF checker Shows statistics on how many PDFs in a directory are ZUGFeRD-Compliant @@ -27,7 +27,7 @@ org.mustangproject.ZUGFeRD mustang - 1.2.0 + 1.2.1-SNAPSHOT org.apache.pdfbox diff --git a/mustang/toecount/src/main/java/toecount/FileChecker.java b/mustang/toecount/src/main/java/toecount/FileChecker.java old mode 100644 new mode 100755 index ef955335..c1ad9d64 --- a/mustang/toecount/src/main/java/toecount/FileChecker.java +++ b/mustang/toecount/src/main/java/toecount/FileChecker.java @@ -6,14 +6,13 @@ public class FileChecker { String filename; StatRun thisRun; boolean isPDF=false; - boolean checkFileExt=true; public FileChecker(String filename, StatRun statistics) { this.filename=filename; thisRun=statistics; thisRun.incFileCount(); String extension = ""; - if (checkFileExt) { + if (!thisRun.shallIgnoreFileExt()) { int extIndex = filename.lastIndexOf("."); if (extIndex >= 0) { extension = filename.substring(extIndex).toLowerCase(); @@ -27,9 +26,9 @@ public class FileChecker { } public boolean checkForZUGFeRD() { - if ((!isPDF)&&(checkFileExt)) { + if ((!isPDF)&&(!thisRun.shallIgnoreFileExt())) { return false; - } + } ZUGFeRDImporter zi=new ZUGFeRDImporter(); zi.extract(filename); if (zi.canParse()) { @@ -47,9 +46,5 @@ public class FileChecker { public String getOutputLine() { return thisRun.getOutputLine(); } - - public void ignoreFileExtension() { - checkFileExt=false; - } } diff --git a/mustang/toecount/src/main/java/toecount/FileTraverser.java b/mustang/toecount/src/main/java/toecount/FileTraverser.java old mode 100644 new mode 100755 index 461d254e..660b785f --- a/mustang/toecount/src/main/java/toecount/FileTraverser.java +++ b/mustang/toecount/src/main/java/toecount/FileTraverser.java @@ -12,7 +12,6 @@ public class FileTraverser extends SimpleFileVisitor { private StatRun thisRun; - private boolean checkFileExt=true; public FileTraverser(StatRun statistics) { this.thisRun=statistics; } @@ -27,15 +26,10 @@ public class FileTraverser extends SimpleFileVisitor { } else if (attr.isRegularFile()) { String filename = file.toString(); FileChecker fc = new FileChecker(filename, thisRun); - if (!checkFileExt) { - fc.ignoreFileExtension(); - } fc.checkForZUGFeRD(); System.out.print(fc.getOutputLine()); - } else { - // Not yet handled - } + } return CONTINUE; } @@ -59,7 +53,4 @@ public class FileTraverser extends SimpleFileVisitor { return CONTINUE; } - public void ignoreFileExtension() { - checkFileExt=false; - } } diff --git a/mustang/toecount/src/main/java/toecount/StatRun.java b/mustang/toecount/src/main/java/toecount/StatRun.java old mode 100644 new mode 100755 index cdfffecd..6473ca71 --- a/mustang/toecount/src/main/java/toecount/StatRun.java +++ b/mustang/toecount/src/main/java/toecount/StatRun.java @@ -5,7 +5,15 @@ public class StatRun { private int horseCount = 0; private int fileCount = 0; private int dirCount = 0; + private boolean checkFileExt=true; + public void ignoreFileExtension() { + checkFileExt=false; + } + + public boolean shallIgnoreFileExt() { + return !checkFileExt; + } public void incFileCount(){ fileCount++; } diff --git a/mustang/toecount/src/main/java/toecount/Toecount.java b/mustang/toecount/src/main/java/toecount/Toecount.java old mode 100644 new mode 100755 index be6d9c78..6c0c412e --- a/mustang/toecount/src/main/java/toecount/Toecount.java +++ b/mustang/toecount/src/main/java/toecount/Toecount.java @@ -22,7 +22,7 @@ public class Toecount { } private static void printHelp() { System.out - .println("Mustangproject.org's Toecount 0.0.5 \r\n" + .println("Mustangproject.org's Toecount 0.0.6 \r\n" + "A Apache Public License command line tool for statistics on PDF invoices with\r\n" + "ZUGFeRD Metadata (http://www.zugferd.de)\r\n" + "\r\n" @@ -75,23 +75,21 @@ public class Toecount { } StatRun sr=new StatRun(); + if (ignoreFileExt) { + sr.ignoreFileExtension(); + } if (directoryName != null) { Path startingDir = Paths.get(directoryName); if (Files.isRegularFile(startingDir)) { String filename = startingDir.toString(); FileChecker fc = new FileChecker(filename, sr); - if (ignoreFileExt) { - fc.ignoreFileExtension(); - } + fc.checkForZUGFeRD(); System.out.print(fc.getOutputLine()); } else if (Files.isDirectory(startingDir)) { FileTraverser pf = new FileTraverser(sr); - if (ignoreFileExt) { - pf.ignoreFileExtension(); - } try { Files.walkFileTree(startingDir, pf); } catch (IOException e) { @@ -109,9 +107,7 @@ public class Toecount { try { while ((s = in.readLine()) != null && s.length() != 0) { FileChecker fc = new FileChecker(s, sr); - if (ignoreFileExt) { - fc.ignoreFileExtension(); - } + fc.checkForZUGFeRD(); System.out.print(fc.getOutputLine());