if (this.validHeaders == null) this.validHeaders = new String[0];
final List<Header> validHeaders = new ArrayList<Header>(this.validHeaders.length);
for (String validHeader : this.validHeaders)
validHeaders.add(new Header(finder.findResource(validHeader), mergeProperties(), headerSections));
final DocumentFactory documentFactory = new DocumentFactory(basedir, buildMapping(), buildHeaderDefinitions(), encoding, keywords);
int nThreads = (int) (Runtime.getRuntime().availableProcessors() * concurrencyFactor);
ExecutorService executorService = Executors.newFixedThreadPool(nThreads);
CompletionService completionService = new ExecutorCompletionService(executorService);
int count = 0;
debug("Number of execution threads: %s", nThreads);
try {
for (final String file : listSelectedFiles()) {
completionService.submit(new Runnable() {
public void run() {
Document document = documentFactory.createDocuments(file);
debug("Selected file: %s [header style: %s]", document.getFile(), document.getHeaderDefinition());
if (document.isNotSupported()) {
warn("Unknown file extension: %s", document.getFile());
} else if (document.is(h)) {
debug("Skipping header file: %s", document.getFile());