Author: rdonkin
Date: Sun Dec 8 21:34:10 2013
New Revision: 1549307
URL: http://svn.apache.org/r1549307
Log:
Format Code.
Modified:
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/walker/DirectoryWalker.java
Modified:
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/walker/DirectoryWalker.java
URL:
http://svn.apache.org/viewvc/creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/walker/DirectoryWalker.java?rev=1549307&r1=1549306&r2=1549307&view=diff
==============================================================================
---
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/walker/DirectoryWalker.java
(original)
+++
creadur/rat/branches/gsoc/apache-rat-core/src/main/java/org/apache/rat/walker/DirectoryWalker.java
Sun Dec 8 21:34:10 2013
@@ -35,116 +35,136 @@ import java.util.regex.Pattern;
*/
public class DirectoryWalker extends Walker implements IReportable {
- protected static final FileNameComparator COMPARATOR = new
FileNameComparator();
+ protected static final FileNameComparator COMPARATOR = new
FileNameComparator();
- public DirectoryWalker(File file) {
- this(file, (FilenameFilter) null);
- }
-
- /**
- * Constructs a walker.
- * @param file not null
- * @param filter filters input files (optional),
- * or null when no filtering should be performed
- */
- public DirectoryWalker(File file, final FilenameFilter filter) {
- super(file.getPath(), file, filter);
- }
-
- public DirectoryWalker(File file, final Pattern ignoreNameRegex) {
- super(file.getPath(), file, regexFilter(ignoreNameRegex));
- }
-
- public boolean isRestricted() {
- return false;
- }
-
- /**
- * Process a directory, restricted directories will be ignored.
- *
- * @param report The report to process the directory with
- * @param file the directory to process
- * @throws RatException
- */
- private void processDirectory(RatReport report, final File file) throws
RatException {
- if (!isRestricted(file)) {
- process(report, file);
- }
- }
-
- /**
- * Run a report over all files and directories in this DirectoryWalker,
- * ignoring any files/directories set to be ignored.
- *
- * @param report the defined RatReport to run on this Directory walker.
- *
- */
- public void run(final RatReport report) throws RatException {
- process(report, file);
- }
-
- /**
- * Process a directory, ignoring any files/directories set to be ignored.
- *
- * @param report the report to use in processing
- * @param file the run the report against
- * @throws RatException
- */
- private void process(final RatReport report, final File file) throws
RatException {
- final File[] files = file.listFiles();
- Arrays.sort(files, COMPARATOR);
- if (files != null) {
- // breadth first traversal
- processNonDirectories(report, files);
- processDirectories(report, files);
- }
- }
-
- /**
- * Process all directories in a set of file objects, ignoring any
directories set to be ignored.
- *
- * @param report the report to use in processing
- * @param files the files to process (only directories will be processed)
- * @throws RatException
- */
- private void processDirectories(final RatReport report, final File[]
files) throws RatException {
- for (final File file : files) {
- if (!ignored(file)) {
- if (file.isDirectory()) {
- processDirectory(report, file);
- }
- }
- }
- }
-
- /**
- * Process all files in a set of file objects, ignoring any files set to
be ignored.
- *
- * @param report the report to use in processing
- * @param files the files to process (only files will be processed)
- * @throws RatException
- */
- private void processNonDirectories(final RatReport report, final File[]
files) throws RatException {
- for (final File file : files) {
- if (!ignored(file)) {
- if (!file.isDirectory()) {
- report(report, file);
- }
- }
- }
- }
-
- /**
- * Report on the given file.
- *
- * @param report the report to process the file with
- * @param file the file to be reported on
- * @throws RatException
- */
- private void report(final RatReport report, File file) throws RatException
{
+ public DirectoryWalker(File file) {
+ this(file, (FilenameFilter) null);
+ }
+
+ /**
+ * Constructs a walker.
+ *
+ * @param file
+ * not null
+ * @param filter
+ * filters input files (optional), or null when no filtering
+ * should be performed
+ */
+ public DirectoryWalker(File file, final FilenameFilter filter) {
+ super(file.getPath(), file, filter);
+ }
+
+ public DirectoryWalker(File file, final Pattern ignoreNameRegex) {
+ super(file.getPath(), file, regexFilter(ignoreNameRegex));
+ }
+
+ public boolean isRestricted() {
+ return false;
+ }
+
+ /**
+ * Process a directory, restricted directories will be ignored.
+ *
+ * @param report
+ * The report to process the directory with
+ * @param file
+ * the directory to process
+ * @throws RatException
+ */
+ private void processDirectory(RatReport report, final File file)
+ throws RatException {
+ if (!isRestricted(file)) {
+ process(report, file);
+ }
+ }
+
+ /**
+ * Run a report over all files and directories in this DirectoryWalker,
+ * ignoring any files/directories set to be ignored.
+ *
+ * @param report
+ * the defined RatReport to run on this Directory walker.
+ *
+ */
+ public void run(final RatReport report) throws RatException {
+ process(report, file);
+ }
+
+ /**
+ * Process a directory, ignoring any files/directories set to be
ignored.
+ *
+ * @param report
+ * the report to use in processing
+ * @param file
+ * the run the report against
+ * @throws RatException
+ */
+ private void process(final RatReport report, final File file)
+ throws RatException {
+ final File[] files = file.listFiles();
+ Arrays.sort(files, COMPARATOR);
+ if (files != null) {
+ // breadth first traversal
+ processNonDirectories(report, files);
+ processDirectories(report, files);
+ }
+ }
+
+ /**
+ * Process all directories in a set of file objects, ignoring any
+ * directories set to be ignored.
+ *
+ * @param report
+ * the report to use in processing
+ * @param files
+ * the files to process (only directories will be processed)
+ * @throws RatException
+ */
+ private void processDirectories(final RatReport report, final File[]
files)
+ throws RatException {
+ for (final File file : files) {
+ if (!ignored(file)) {
+ if (file.isDirectory()) {
+ processDirectory(report, file);
+ }
+ }
+ }
+ }
+
+ /**
+ * Process all files in a set of file objects, ignoring any files set
to be
+ * ignored.
+ *
+ * @param report
+ * the report to use in processing
+ * @param files
+ * the files to process (only files will be processed)
+ * @throws RatException
+ */
+ private void processNonDirectories(final RatReport report,
+ final File[] files) throws RatException {
+ for (final File file : files) {
+ if (!ignored(file)) {
+ if (!file.isDirectory()) {
+ report(report, file);
+ }
+ }
+ }
+ }
+
+ /**
+ * Report on the given file.
+ *
+ * @param report
+ * the report to process the file with
+ * @param file
+ * the file to be reported on
+ * @throws RatException
+ */
+ private void report(final RatReport report, File file) throws
RatException {
- Document document = new FileDocument(file);
- report.report(document);
+ Document document = new FileDocument(file);
+ report.report(document);
- }
+ }
}