org.apache.myfaces.buildtools.maven2.plugin.javascript.uixtools
Class FileProcessor

java.lang.Object
  extended by org.apache.myfaces.buildtools.maven2.plugin.javascript.uixtools.FileProcessor
Direct Known Subclasses:
JavascriptCompiler, Obfuscator, Reducer

public abstract class FileProcessor
extends Object

This utility class can be used to perform some processing on input files, and write the results to corresponding output files. It supports recursing into subdirectories.

Version:
$Name: $ ($Revision: 606225 $) $Date: 2007-12-21 16:55:00 +0100 (Fri, 21 Dec 2007) $

Field Summary
protected  boolean isVerbose
          If this is true, verbose output will be generated.
 
Constructor Summary
FileProcessor(FilenameFilter filter, boolean verbosity)
          Creates a Fileprocessor that overwrites all output files, and does not fail fast.
FileProcessor(FilenameFilter filter, boolean failFast, boolean overwrite, boolean verbose)
           
FileProcessor(String extension, boolean verbosity)
          Creates a Fileprocessor that overwrites all output files, and does not fail fast.
 
Method Summary
static FilenameFilter getExtensionFilter(String filenameExt)
           
 boolean process(File in, File out)
           
protected abstract  void processFile(File in, File out)
          Called to process a single file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

isVerbose

protected final boolean isVerbose
If this is true, verbose output will be generated.

Constructor Detail

FileProcessor

public FileProcessor(FilenameFilter filter,
                     boolean failFast,
                     boolean overwrite,
                     boolean verbose)
Parameters:
filter - used to select files and/or subdirectories.
failFast - if true, terminates at the first error (otherwise, continues with the next file).
overwrite - if false, will not overwrite existing output files (That particular input and output file will be skipped).
verbose - if true, generates verbose output.

FileProcessor

public FileProcessor(FilenameFilter filter,
                     boolean verbosity)
Creates a Fileprocessor that overwrites all output files, and does not fail fast.

Parameters:
filter - used to select files and/or subdirectories.

FileProcessor

public FileProcessor(String extension,
                     boolean verbosity)
Creates a Fileprocessor that overwrites all output files, and does not fail fast.

Parameters:
extension - the file extension to filter for. if this is null, all files and subdirectories in a directory will be processed recursively.
See Also:
getExtensionFilter(String extension)
Method Detail

getExtensionFilter

public static FilenameFilter getExtensionFilter(String filenameExt)
Parameters:
filenameExt - the filename extension to accept. If null, all files are accepted.
Returns:
a filter that only accepts files with names that end with the specified extension. However, the filter accepts all subdirectories.

process

public boolean process(File in,
                       File out)
Parameters:
in - the input file or directory
out - if the input is a directory, then this must be the output directory. Otherwise, this is the output file.
Returns:
true if there were no errors. false otherwise.

processFile

protected abstract void processFile(File in,
                                    File out)
                             throws Exception
Called to process a single file.

Parameters:
in - the input file. This is never a directory.
out - the output file. If this file exists and overwriting is not permitted, then this method is never called.
Throws:
Exception - if this class is set to fail fast then any exception thrown will cause all execution to halt. If this class does not fail fast, then the exception will be reported and execution will continue with the next file.


Copyright © 2001-2013 The Apache Software Foundation. All Rights Reserved.