<commit_before>package org.openlca.ilcd.io;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;

import org.openlca.ilcd.commons.IDataSet;
import org.openlca.ilcd.sources.Source;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ZipStore implements DataStore {

	private Logger log = LoggerFactory.getLogger(getClass());
	private FileSystem zip;
	private HashMap<String, List<Path>> entries;
	private XmlBinder binder = new XmlBinder();

	public ZipStore(File zipFile) throws IOException {
		log.trace("Create zip store {}", zipFile);
		String uriStr = zipFile.toURI().toASCIIString();
		URI uri = URI.create("jar:" + uriStr);
		Map<String, String> options = new HashMap<>();
		if (!zipFile.exists())
			options.put("create", "true");
		zip = FileSystems.newFileSystem(uri, options);
		initEntries();
	}

	private void initEntries() throws IOException {
		entries = new HashMap<>();
		for (Path root : zip.getRootDirectories()) {
			Files.walkFileTree(root, new FileVisitor(f -> {
				String dir = f.getParent().getFileName().toString()
						.toLowerCase();
				List<Path> list = getEntries(dir);
				list.add(f);
			}));
		}
	}

	/** Get the entries of the given directory. */
	public List<Path> getEntries(String dir) {
		List<Path> list = entries.get(dir);
		if (list == null) {
			list = new ArrayList<>();
			entries.put(dir, list);
		}
		return list;
	}<commit_msg>ilcd: fixed null-pointer exception in ZipStore <commit_after>package org.openlca.ilcd.io;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;

import org.openlca.ilcd.commons.IDataSet;
import org.openlca.ilcd.sources.Source;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ZipStore implements DataStore {

	private Logger log = LoggerFactory.getLogger(getClass());
	private FileSystem zip;
	private HashMap<String, List<Path>> entries;
	private XmlBinder binder = new XmlBinder();

	public ZipStore(File zipFile) throws IOException {
		log.trace("Create zip store {}", zipFile);
		String uriStr = zipFile.toURI().toASCIIString();
		URI uri = URI.create("jar:" + uriStr);
		Map<String, String> options = new HashMap<>();
		if (!zipFile.exists())
			options.put("create", "true");
		zip = FileSystems.newFileSystem(uri, options);
		initEntries();
	}

	private void initEntries() throws IOException {
		entries = new HashMap<>();
		for (Path root : zip.getRootDirectories()) {
			Files.walkFileTree(root, new FileVisitor(f -> {
				Path p = f.getParent();
				if (p == null)
					return;
				Path dirPath = p.getFileName();
				if (dirPath == null)
					return;
				String dir = dirPath.toString().toLowerCase();
				List<Path> list = getEntries(dir);
				list.add(f);
			}));
		}
	}

	/** Get the entries of the given directory. */
	public List<Path> getEntries(String dir) {
		List<Path> list = entries.get(dir);
		if (list == null) {
			list = new ArrayList<>();
			entries.put(dir, list);
		}
		return list;
	}
{'fraction_non_alphanumeric': 0.13537227375282027, 'fraction_numerical': 0.001002757583354224, 'mean_word_length': 4.533980582524272, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2011281', 'n_tokens_mistral': 1379, 'n_tokens_neox': 1275, 'n_words': 309}