<commit_before>package fi.csc.microarray.client.serverfiles;

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;

import javax.swing.filechooser.FileSystemView;

/**
 * This class provides a view into a generic directory service.
 */
public class ServerFileSystemView extends FileSystemView {

	private ServerFile rootFile;
	
	public ServerFileSystemView(ServerFile rootFile) {
		this.rootFile = rootFile;
	}

	public static ServerFileSystemView parseFromPaths(URL[] urls) throws MalformedURLException {
		
		HashMap<String, ServerFile> dirs = new HashMap<String, ServerFile>();
		ServerFile root = null;
		
		for (URL url : urls) {
			ServerFile file = new ServerFile(url);
			String p = url.getPath();
			ServerFile parent = dirs.get(p.substring(0, p.substring(0, p.length() - 1).lastIndexOf("/") + 1));
			if (parent == null) {
				root = file; // this was root
			} else {
				parent.addChild(file);
			}
			if (file.isDirectory()) {
				dirs.put(url.getPath(), file);
			}
		}
//		
//		ServerFile root = new ServerFile(new URL(prefix + paths[0]));
//		ServerFile home = new ServerFile(new URL(prefix + paths[1]));
//		root.addChild(home);
//		ServerFile bam1 = new ServerFile(new URL(prefix + paths[2]));
//		ServerFile bam2 = new ServerFile(new URL(prefix + paths[3]));
//		home.addChild(bam1);
//		home.addChild(bam2);
		
		if (root == null) {
			throw new IllegalArgumentException("paths were missing root");
		}
		
		return new ServerFileSystemView(root);
	}
	
	
	@Override
	public File createNewFolder(File aContainingDir) throws IOException {
		throw new UnsupportedOperationException();
	}

	@Override
	public File[] getRoots() {
		return new File[] { rootFile };
	}

	public File getRoot() {
		return rootFile;
	}

	@Override
	public boolean isHiddenFile(File f) {
		return false;
	}<commit_msg>pathlist parsing implemented<commit_after>package fi.csc.microarray.client.serverfiles;

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;

import javax.swing.filechooser.FileSystemView;

/**
 * This class provides a view into a generic directory service.
 */
public class ServerFileSystemView extends FileSystemView {

	private ServerFile rootFile;
	
	public ServerFileSystemView(ServerFile rootFile) {
		this.rootFile = rootFile;
	}

	public static ServerFileSystemView parseFromPaths(URL[] urls) throws MalformedURLException {
		
		HashMap<String, ServerFile> dirs = new HashMap<String, ServerFile>();
		ServerFile root = null;
		
		for (URL url : urls) {
			ServerFile file = new ServerFile(url);
			String p = url.getPath();
			ServerFile parent = dirs.get(p.substring(0, p.substring(0, p.length() - 1).lastIndexOf("/") + 1));
			if (parent == null) {
				root = file; // this was root
			} else {
				parent.addChild(file);
			}
			if (file.isDirectory()) {
				dirs.put(url.getPath(), file);
			}
		}
		
		if (root == null) {
			throw new IllegalArgumentException("paths were missing root path");
		}
		
		return new ServerFileSystemView(root);
	}
	
	
	@Override
	public File createNewFolder(File aContainingDir) throws IOException {
		throw new UnsupportedOperationException();
	}

	@Override
	public File[] getRoots() {
		return new File[] { rootFile };
	}

	public File getRoot() {
		return rootFile;
	}

	@Override
	public boolean isHiddenFile(File f) {
		return false;
	}
{'fraction_non_alphanumeric': 0.11965317919075144, 'fraction_numerical': 0.004624277456647399, 'mean_word_length': 3.994227994227994, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '142102', 'n_tokens_mistral': 1211, 'n_tokens_neox': 1083, 'n_words': 284}