<commit_before>package Data;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import authoring.WorldData;

public class DataManager {
	private static DataManager instance = null;
	private Map<String, WorldData> myWorldDatas;
	private FileStorer myFileStorer;
	
	private DataManager() {
		myWorldDatas = new HashMap<String, WorldData>();
		myFileStorer = new FileStorer();
		init();
	}
	
	public static DataManager getInstance() {
		if (instance == null) {
			instance = new DataManager();
		}
		return instance;
	}
	
	private void init() {
		List<String> gameList = myFileStorer.getSavedGameList();
		for (String gameName : gameList) {
			try {
				WorldData worldData = myFileStorer.getWorldData(gameName);
				myWorldDatas.put(gameName, worldData);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
	public WorldData getWorldData(String worldDataName) {
		return myWorldDatas.get(worldDataName);
	}
	
	public void setWorldData(String worldDataName, WorldData worldData) {
		myWorldDatas.put(worldDataName, worldData);
	}
	
	public void saveWorldDataToFile(String worldDataName) {
		myFileStorer.storeWorldData(worldDataName, myWorldDatas.get(worldDataName));
	}
	
	public WorldData loadWorldDataFromFile(String worldDataName) {
		try {
			WorldData worldData = myFileStorer.getWorldData(worldDataName);
			myWorldDatas.put(worldDataName, worldData);
			return worldData;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;<commit_msg>Made Data Manager class cleaner<commit_after>package Data;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import authoring.WorldData;



/** 
 * Manages WorldData objects. Keeps a map of WorldData objects associated with
 * each WorldData file.
 */

public class DataManager {
	private static DataManager instance = null;
	private Map<String, WorldData> myWorldDatas;
	private FileStorer myFileStorer;
	
	private DataManager() {
		myWorldDatas = new HashMap<String, WorldData>();
		myFileStorer = new FileStorer();
		init();
	}
	
	public static DataManager getInstance() {
		if (instance == null) {
			instance = new DataManager();
		}
		return instance;
	}
	
	private void init() {
		List<String> gameList = myFileStorer.getSavedGameList();
		for (String gameName : gameList) {
			try {
				WorldData worldData = myFileStorer.getWorldData(gameName);
				myWorldDatas.put(gameName, worldData);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
	/**
	 * Method used to retrieve a WorldData object from map. If object is not
	 * in map, it tries to retrieve from the file. If the file isn't found, it
	 * returns null.
	 * @param worldDataName
	 * @return WorldData
	 */
	public WorldData getWorldData(String worldDataName) {
		WorldData worldData = null;
		if (myWorldDatas.containsKey(worldDataName)) {
			worldData = myWorldDatas.get(worldDataName);
		}
		else {
			worldData = loadWorldDataFromFile(worldDataName);
		}
		return worldData;
	}
	

	/**
	 * Method used to add WorldData object to map.
	 * @param worldDataName
	 * @param worldData
	 */
	public void setWorldData(String worldDataName, WorldData worldData) {
		myWorldDatas.put(worldDataName, worldData);
	}
	
	/**
	 * Method used to save WorldData to file.
	 * @param worldDataName
	 */
	public void saveWorldDataToFile(String worldDataName) {
		myFileStorer.storeWorldData(worldDataName, myWorldDatas.get(worldDataName));
	}
	
	/**
	 * Method used to load worldData from file. It also updates the map.
	 * @param worldDataName
	 * @return WorldData
	 */
	public WorldData loadWorldDataFromFile(String worldDataName) {
		try {
			WorldData worldData = myFileStorer.getWorldData(worldDataName);
			myWorldDatas.put(worldDataName, worldData);
			return worldData;
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return null;
{'fraction_non_alphanumeric': 0.0955209106656768, 'fraction_numerical': 0.0, 'mean_word_length': 4.182051282051282, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5254537', 'n_tokens_mistral': 1380, 'n_tokens_neox': 1228, 'n_words': 328}