# HG changeset patch # User František Kučera # Date 1416244633 -3600 # Node ID f517bafcf8124bf1f75a7a458ef2fe7fb8d2c47c # Parent a5a723467a3937140e3d6c774ba7177bfc6b0276 stateful RecursiveImageResizer diff -r a5a723467a39 -r f517bafcf812 java/copy-image-resizer/src/cz/frantovo/copyImageResizer/RecursiveImageResizer.java --- a/java/copy-image-resizer/src/cz/frantovo/copyImageResizer/RecursiveImageResizer.java Mon Nov 17 18:13:59 2014 +0100 +++ b/java/copy-image-resizer/src/cz/frantovo/copyImageResizer/RecursiveImageResizer.java Mon Nov 17 18:17:13 2014 +0100 @@ -40,11 +40,17 @@ private final SingleImageResizer resizer = new SingleImageResizer(); - public void resize(RecursiveOptions options) throws RecursiveException, ResizeException { - resizeDirectory(options.getInput(), options); + private final RecursiveOptions options; + + public RecursiveImageResizer(RecursiveOptions options) { + this.options = options; } - private void resizeFile(File inputFile, RecursiveOptions options) throws ResizeException { + public void resize() throws RecursiveException, ResizeException { + resizeDirectory(options.getInput()); + } + + private void resizeFile(File inputFile) throws ResizeException { File inputFileRelative = relativize(options.getInput(), inputFile); log.log(Level.FINER, "Resizing file: {0}", inputFileRelative); @@ -112,7 +118,7 @@ } - private void resizeDirectory(File directory, RecursiveOptions options) throws ResizeException { + private void resizeDirectory(File directory) throws ResizeException { log.log(Level.FINE, "Resizing directory: {0}", directory); @@ -125,9 +131,9 @@ for (File entry : directory.listFiles()) { if (entry.isDirectory()) { - resizeDirectory(entry, options); + resizeDirectory(entry); } else { - resizeFile(entry, options); + resizeFile(entry); } } diff -r a5a723467a39 -r f517bafcf812 java/copy-image-resizer/src/cz/frantovo/copyImageResizer/cli/CLIStarter.java --- a/java/copy-image-resizer/src/cz/frantovo/copyImageResizer/cli/CLIStarter.java Mon Nov 17 18:13:59 2014 +0100 +++ b/java/copy-image-resizer/src/cz/frantovo/copyImageResizer/cli/CLIStarter.java Mon Nov 17 18:17:13 2014 +0100 @@ -37,8 +37,8 @@ try { CLIParser parser = new CLIParser(); RecursiveOptions options = parser.parseOptions(args); - RecursiveImageResizer resizer = new RecursiveImageResizer(); - resizer.resize(options); + RecursiveImageResizer resizer = new RecursiveImageResizer(options); + resizer.resize(); } catch (CLIParserException e) { log.log(Level.SEVERE, "Unable to parse CLI options", e); } catch (RecursiveException e) {