equal
deleted
inserted
replaced
46 */ |
46 */ |
47 protected SimpleFileVisitor() { |
47 protected SimpleFileVisitor() { |
48 } |
48 } |
49 |
49 |
50 /** |
50 /** |
|
51 * Throws NullPointerException if obj is null. |
|
52 */ |
|
53 private static void checkNotNull(Object obj) { |
|
54 if (obj == null) |
|
55 throw new NullPointerException(); |
|
56 } |
|
57 |
|
58 /** |
51 * Invoked for a directory before entries in the directory are visited. |
59 * Invoked for a directory before entries in the directory are visited. |
52 * |
60 * |
53 * <p> Unless overridden, this method returns {@link FileVisitResult#CONTINUE |
61 * <p> Unless overridden, this method returns {@link FileVisitResult#CONTINUE |
54 * CONTINUE}. |
62 * CONTINUE}. |
55 */ |
63 */ |
56 @Override |
64 @Override |
57 public FileVisitResult preVisitDirectory(T dir) { |
65 public FileVisitResult preVisitDirectory(T dir) { |
|
66 checkNotNull(dir); |
58 return FileVisitResult.CONTINUE; |
67 return FileVisitResult.CONTINUE; |
59 } |
68 } |
60 |
69 |
61 /** |
70 /** |
62 * Invoked for a directory that could not be opened. |
71 * Invoked for a directory that could not be opened. |
68 * with the I/O exception thrown when the attempt to open the |
77 * with the I/O exception thrown when the attempt to open the |
69 * directory failed |
78 * directory failed |
70 */ |
79 */ |
71 @Override |
80 @Override |
72 public FileVisitResult preVisitDirectoryFailed(T dir, IOException exc) { |
81 public FileVisitResult preVisitDirectoryFailed(T dir, IOException exc) { |
|
82 checkNotNull(dir); |
|
83 checkNotNull(exc); |
73 throw new IOError(exc); |
84 throw new IOError(exc); |
74 } |
85 } |
75 |
86 |
76 /** |
87 /** |
77 * Invoked for a file in a directory. |
88 * Invoked for a file in a directory. |
79 * <p> Unless overridden, this method returns {@link FileVisitResult#CONTINUE |
90 * <p> Unless overridden, this method returns {@link FileVisitResult#CONTINUE |
80 * CONTINUE}. |
91 * CONTINUE}. |
81 */ |
92 */ |
82 @Override |
93 @Override |
83 public FileVisitResult visitFile(T file, BasicFileAttributes attrs) { |
94 public FileVisitResult visitFile(T file, BasicFileAttributes attrs) { |
|
95 checkNotNull(file); |
|
96 checkNotNull(attrs); |
84 return FileVisitResult.CONTINUE; |
97 return FileVisitResult.CONTINUE; |
85 } |
98 } |
86 |
99 |
87 /** |
100 /** |
88 * Invoked for a file when its basic file attributes could not be read. |
101 * Invoked for a file when its basic file attributes could not be read. |
94 * with the I/O exception thrown when the attempt to read the file |
107 * with the I/O exception thrown when the attempt to read the file |
95 * attributes failed |
108 * attributes failed |
96 */ |
109 */ |
97 @Override |
110 @Override |
98 public FileVisitResult visitFileFailed(T file, IOException exc) { |
111 public FileVisitResult visitFileFailed(T file, IOException exc) { |
|
112 checkNotNull(file); |
|
113 checkNotNull(exc); |
99 throw new IOError(exc); |
114 throw new IOError(exc); |
100 } |
115 } |
101 |
116 |
102 /** |
117 /** |
103 * Invoked for a directory after entries in the directory, and all of their |
118 * Invoked for a directory after entries in the directory, and all of their |
112 * if iteration of the directory completed prematurely due to an |
127 * if iteration of the directory completed prematurely due to an |
113 * I/O error |
128 * I/O error |
114 */ |
129 */ |
115 @Override |
130 @Override |
116 public FileVisitResult postVisitDirectory(T dir, IOException exc) { |
131 public FileVisitResult postVisitDirectory(T dir, IOException exc) { |
|
132 checkNotNull(dir); |
117 if (exc != null) |
133 if (exc != null) |
118 throw new IOError(exc); |
134 throw new IOError(exc); |
119 return FileVisitResult.CONTINUE; |
135 return FileVisitResult.CONTINUE; |
120 } |
136 } |
121 } |
137 } |