stateful RecursiveImageResizer
authorFrantišek Kučera <franta-hg@frantovo.cz>
Mon, 17 Nov 2014 18:17:13 +0100
changeset 11f517bafcf812
parent 10 a5a723467a39
child 12 27e41d7f5e8d
stateful RecursiveImageResizer
java/copy-image-resizer/src/cz/frantovo/copyImageResizer/RecursiveImageResizer.java
java/copy-image-resizer/src/cz/frantovo/copyImageResizer/cli/CLIStarter.java
     1.1 --- a/java/copy-image-resizer/src/cz/frantovo/copyImageResizer/RecursiveImageResizer.java	Mon Nov 17 18:13:59 2014 +0100
     1.2 +++ b/java/copy-image-resizer/src/cz/frantovo/copyImageResizer/RecursiveImageResizer.java	Mon Nov 17 18:17:13 2014 +0100
     1.3 @@ -40,11 +40,17 @@
     1.4  
     1.5  	private final SingleImageResizer resizer = new SingleImageResizer();
     1.6  
     1.7 -	public void resize(RecursiveOptions options) throws RecursiveException, ResizeException {
     1.8 -		resizeDirectory(options.getInput(), options);
     1.9 +	private final RecursiveOptions options;
    1.10 +
    1.11 +	public RecursiveImageResizer(RecursiveOptions options) {
    1.12 +		this.options = options;
    1.13  	}
    1.14  
    1.15 -	private void resizeFile(File inputFile, RecursiveOptions options) throws ResizeException {
    1.16 +	public void resize() throws RecursiveException, ResizeException {
    1.17 +		resizeDirectory(options.getInput());
    1.18 +	}
    1.19 +
    1.20 +	private void resizeFile(File inputFile) throws ResizeException {
    1.21  		File inputFileRelative = relativize(options.getInput(), inputFile);
    1.22  		log.log(Level.FINER, "Resizing file: {0}", inputFileRelative);
    1.23  
    1.24 @@ -112,7 +118,7 @@
    1.25  
    1.26  	}
    1.27  
    1.28 -	private void resizeDirectory(File directory, RecursiveOptions options) throws ResizeException {
    1.29 +	private void resizeDirectory(File directory) throws ResizeException {
    1.30  
    1.31  		log.log(Level.FINE, "Resizing directory: {0}", directory);
    1.32  
    1.33 @@ -125,9 +131,9 @@
    1.34  
    1.35  		for (File entry : directory.listFiles()) {
    1.36  			if (entry.isDirectory()) {
    1.37 -				resizeDirectory(entry, options);
    1.38 +				resizeDirectory(entry);
    1.39  			} else {
    1.40 -				resizeFile(entry, options);
    1.41 +				resizeFile(entry);
    1.42  			}
    1.43  		}
    1.44  
     2.1 --- a/java/copy-image-resizer/src/cz/frantovo/copyImageResizer/cli/CLIStarter.java	Mon Nov 17 18:13:59 2014 +0100
     2.2 +++ b/java/copy-image-resizer/src/cz/frantovo/copyImageResizer/cli/CLIStarter.java	Mon Nov 17 18:17:13 2014 +0100
     2.3 @@ -37,8 +37,8 @@
     2.4  		try {
     2.5  			CLIParser parser = new CLIParser();
     2.6  			RecursiveOptions options = parser.parseOptions(args);
     2.7 -			RecursiveImageResizer resizer = new RecursiveImageResizer();
     2.8 -			resizer.resize(options);
     2.9 +			RecursiveImageResizer resizer = new RecursiveImageResizer(options);
    2.10 +			resizer.resize();
    2.11  		} catch (CLIParserException e) {
    2.12  			log.log(Level.SEVERE, "Unable to parse CLI options", e);
    2.13  		} catch (RecursiveException e) {