@@ -61,6 +61,7 @@ public class TextSearcher extends Thread {
61
61
62
62
/**
63
63
* Constructor for text searcher thread.
64
+ *
64
65
* @param text search text.
65
66
* @param storage instance of file storage for store already checked file.
66
67
*/
@@ -72,6 +73,7 @@ public TextSearcher(final String text, final FileStorage storage) {
72
73
73
74
/**
74
75
* Return true if something was found.
76
+ *
75
77
* @return true if something was found, otherwise false.
76
78
*/
77
79
public boolean getFounded () {
@@ -98,6 +100,7 @@ public void brake() {
98
100
99
101
/**
100
102
* Return list of found files.
103
+ *
101
104
* @return list of found files.
102
105
*/
103
106
public List <String > getFileList () {
@@ -112,12 +115,13 @@ public List<String> getFileList() {
112
115
*/
113
116
private void searchFromDisk () {
114
117
for (File disk : disks ) {
115
- search (disk .getAbsolutePath ());
118
+ search (disk .getAbsolutePath ());
116
119
}
117
120
}
118
121
119
122
/**
120
123
* Recursive search from directory to file.
124
+ *
121
125
* @param disk start of search.
122
126
* @return true if text is find, otherwise false.
123
127
*/
@@ -128,7 +132,7 @@ private boolean search(String disk) {
128
132
if (file .isDirectory ()) {
129
133
search (file .getAbsolutePath ());
130
134
} else if (isCorrectFile (file ) && !this .isInterrupted ()) {
131
- processingFile (file , this .searchText );
135
+ processFile (file , this .searchText );
132
136
}
133
137
}
134
138
}
@@ -137,23 +141,28 @@ private boolean search(String disk) {
137
141
138
142
/**
139
143
* Read file and set founded flag.
144
+ *
140
145
* @param file for reading.
141
146
* @param text for searching.
142
147
*/
143
- private void processingFile (File file , String text ) {
148
+ private void processFile (File file , String text ) {
144
149
this .founded = readFile (file .getAbsolutePath (), text );
145
- log .info (String .format ("SEARCH AT: %s" , file .getAbsolutePath ()));
146
- if (this .founded ) {
147
- log .info (String .format ("FOUND AT: %s" , file .getAbsolutePath ()));
148
- synchronized (this .resultFiles ) {
149
- this .resultFiles .add (file .getAbsolutePath ());
150
- }
150
+ if (log .isInfoEnabled ()) {
151
+ log .info ("SEARCH AT: {}" , file .getAbsolutePath ());
152
+ }
153
+ if (this .founded && log .isInfoEnabled ()) {
154
+ log .info ("FOUND AT: {}" , file .getAbsolutePath ());
155
+ }
156
+
157
+ synchronized (this .resultFiles ) {
158
+ this .resultFiles .add (file .getAbsolutePath ());
151
159
}
152
160
this .fileStorage .addCheckedFile (file .getAbsolutePath ());
153
161
}
154
162
155
163
/**
156
164
* Read file.
165
+ *
157
166
* @param file for reading.
158
167
* @param text for searching.
159
168
* @return true if some string in file contains text or
@@ -182,6 +191,7 @@ private boolean readFile(String file, String text) {
182
191
/**
183
192
* Checked that current file correct.
184
193
* Correct means that file not read yet, not hidden and can read.
194
+ *
185
195
* @param file instance of file.
186
196
* @return true if all expression is true, otherwise false.
187
197
*/
0 commit comments