@Override
        public Page next() {
            if(!fileIterator.hasNext()) {
                return null;
            }
            Path filePath = fileIterator.next();
            try {
                if (dataFormat.equals(DataFormat.CBOR)) {
                    TargetModelCbor object = readFile(filePath);
                    return new Page(object);
                } else if (dataFormat.equals(DataFormat.JSON)) {
                    TargetModelJson object = readFile(filePath);
                    return new Page(object);
                } else if (dataFormat.equals(DataFormat.HTML)) {
                    URL url;
                    if(hashFilename) {
                        url = new URL("http://"+filePath);
                    } else {
                        url = new URL(URLDecoder.decode(filePath.toString(), "UTF-8"));
                    }
                    String object = readFile(filePath);
                    return new Page(url, object);
                } else {
                    throw new IllegalStateException("Unsuported data format: "+dataFormat);
                }
            } catch (Exception e) {
                String f = filePath == null ? null : filePath.toString();
                throw new IllegalStateException("Failed to read file: "+f, e);
            }
        }
A target repository that stores pages in the file system. Files are organized per domain,
one folder for each domain. Supports serialization of data different formats:
- Plain HTML (may lose some data, about headers)
- JSON
- CBOR

@author aeciosantos
ache/src/main/java/achecrawler/target/repository/FileSystemTargetRepository.java