<commit_before>package udo.storage;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;

//import org.json.simple.*;



//import com.google.gson.Gson;

import java.io.*;


public class Storage {
	
	public static final String EOL = System.getProperty("line.separator");
    //private static File storageFile;
    private static ArrayList<Task> taskList;
    public enum TASK_TYPE{ EVENT, DEADLINE, TODO};
    
	public static void main(String[] args) throws IOException{

	    Storage st = new Storage();
		
	    //testing purposes:
	    
	    /*boolean function = st.add("event", "meeting", new GregorianCalendar(2005,01,01), new GregorianCalendar(2005,01,03),
    			0, new GregorianCalendar(2005,01,02), "work", true);
		boolean function2 = st.add("deadline", "fighting", null, new GregorianCalendar(2010,01,03),
    			0, new GregorianCalendar(2011,01,02), "personal", false);
		boolean function3 = st.add("todo", "reading books", null, null,
    			120, null, "leisure", false);
    	if (function&&function2&&function3) System.out.println("Adding successfully");
    	
    	ArrayList<Task> test = new ArrayList<Task>();
    	test = st.query();
    	printTest(test);
    	//test = st.query("leisure");
    	//printTest(test);
    	test = st.query(new GregorianCalendar(2010,01,03));
    	printTest(test);
    	//test = st.query(TASK_TYPE.DEADLINE);
    	//printTest(test);
    	//test = st.search("read");
    	//printTest(test);
    	test = st.query(true);
    	printTest(test);
    	boolean done;
    	done = st.changeStatus(2);
    	test = st.query(true);
    	printTest(test);
    	done = st.delete(1);
    	test = st.query();
    	printTest(test);
    	*/
    	
	    st.exit();
	}

   
	public static void printTest(ArrayList<Task> test){
		for (int i =0; i < test.size(); i++)
			System.out.println(test.get(i));
		System.out.println("");
	}
	
	//read from json file
	public Storage(){
    	taskList = new ArrayList<Task>();
    	
    	//buggy:
    	
    	/*
    	try{
    		FileReader fr = new FileReader("tasks.json");
    		BufferedReader br = new BufferedReader(fr);
    		Gson gson = new Gson();
    		Task newT = gson.fromJson(br, Task.class);
    		while (newT != null){
    			taskList.add(newT);
    			newT = gson.fromJson(br, Task.class);
    		}
    		br.close();
    	} catch (IOException e){
    		storageFile = new File("tasks.json");
    	}*/
    }
    
	//add functions
    public boolean add(String taskType, String content, GregorianCalendar start, GregorianCalendar end,
    		int duration, GregorianCalendar reminder, String label, boolean priority){
    	Task newTask = new Task(taskType, content, start, end, duration, reminder, label, priority);
    	taskList.add(newTask);
    	return true;
    }

    //delete function
    public boolean delete(int index){
    	taskList.remove(index);
    	return true;
    }

    //modify function (still working)
    public boolean modify(int index, String taskType, String content, GregorianCalendar start, GregorianCalendar end,
    		int duration, GregorianCalendar reminder, String label, boolean priority){
    	
    	return true;
    }
    
    //query
    public ArrayList<Task> query(){
    	return taskList;
    }
    
    public ArrayList<Task> query(String label){
    	ArrayList<Task> returnList = new ArrayList<Task>();
    	for(int i=0; i<taskList.size();i++){
    		if (taskList.get(i).getLabel().equals(label)){
    			returnList.add(taskList.get(i));
    		}<commit_msg>add "modify" method<commit_after>package udo.storage;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;

//import org.json.simple.*;



//import com.google.gson.Gson;

import java.io.*;


public class Storage {
	
	public static final String EOL = System.getProperty("line.separator");
    //private static File storageFile;
    private static ArrayList<Task> taskList;
    public enum TASK_TYPE{ EVENT, DEADLINE, TODO};
    
	public static void main(String[] args) throws IOException{

	    Storage st = new Storage();
		
	    //testing purposes:
	    
	    /*boolean function = st.add("event", "meeting", new GregorianCalendar(2005,01,01), new GregorianCalendar(2005,01,03),
    			0, new GregorianCalendar(2005,01,02), "work", true);
		boolean function2 = st.add("deadline", "fighting", null, new GregorianCalendar(2010,01,03),
    			0, new GregorianCalendar(2011,01,02), "personal", false);
		boolean function3 = st.add("todo", "reading books", null, null,
    			120, null, "leisure", false);
    	if (function&&function2&&function3) System.out.println("Adding successfully");
    	
    	ArrayList<Task> test = new ArrayList<Task>();
    	test = st.query();
    	printTest(test);
    	//test = st.query("leisure");
    	//printTest(test);
    	//test = st.query(new GregorianCalendar(2010,01,03));
    	//printTest(test);
    	//test = st.query(TASK_TYPE.DEADLINE);
    	//printTest(test);
    	//test = st.search("read");
    	//printTest(test);
    	//test = st.query(true);
    	//printTest(test);
    	boolean done;
    	//done = st.changeStatus(2);
    	//test = st.query(true);
    	//printTest(test);
    	//done = st.delete(1);
    	//test = st.query();
    	//printTest(test);
    	done = st.modify(2, "deadline", null, null, new GregorianCalendar(2006,01,05),0, new GregorianCalendar(2006,01,02), null);
    	done = st.modify(1, "event", "hanging out", new GregorianCalendar(2013,05,04), new GregorianCalendar(2013,05,05), -1, new GregorianCalendar(2013,05,03), "leisure");
	    done = st.modify(0, "todo", null,null, null, 3, null, null);
    	test = st.query();
	    printTest(test);*/
	    
	    st.exit();
	}

   
	/*public static void printTest(ArrayList<Task> test){
		for (int i =0; i < test.size(); i++)
			System.out.println(test.get(i));
		System.out.println("");
	}*/
	
	//read from json file
	public Storage(){
    	taskList = new ArrayList<Task>();
    	
    	//buggy:
    	
    	/*
    	try{
    		FileReader fr = new FileReader("tasks.json");
    		BufferedReader br = new BufferedReader(fr);
    		Gson gson = new Gson();
    		Task newT = gson.fromJson(br, Task.class);
    		while (newT != null){
    			taskList.add(newT);
    			newT = gson.fromJson(br, Task.class);
    		}
    		br.close();
    	} catch (IOException e){
    		storageFile = new File("tasks.json");
    	}*/
    }
    
	//add functions
    public boolean add(String taskType, String content, GregorianCalendar start, GregorianCalendar end,
    		int duration, GregorianCalendar reminder, String label, boolean priority){
    	Task newTask = new Task(taskType, content, start, end, duration, reminder, label, priority);
    	taskList.add(newTask);
    	return true;
    }

    //delete function
    public boolean delete(int index){
    	taskList.remove(index);
    	return true;
    }

    //modify function (still working)
    public boolean modify(int index, String taskType, String content, GregorianCalendar start, GregorianCalendar end,
    		int duration, GregorianCalendar reminder, String label){
    	Task modifiedTask = taskList.get(index);
    	if (content != null){
    		modifiedTask.setContent(content);
    	}
    	if (duration != -1){
    		modifiedTask.setDuration(duration);
    	}
    	if (reminder != null){
    		modifiedTask.setReminder(reminder);
    	}
    	if (label != null){
    		modifiedTask.setLabel(label);
    	}
    	if (taskType != null){
    		modifiedTask.setTaskType(taskType);
    		if (taskType.equals("event")){
    			modifiedTask.setStart(start);
    			
    			if (end != null){
    				modifiedTask.setEnd(end);
    			}
    		}
    		else if (taskType.equals("deadline")){
    			modifiedTask.setStart(null);
    			
    			if (end != null){
    				modifiedTask.setEnd(end);
    			}
    		}
    		
    		else {
    			modifiedTask.setStart(null);
    			modifiedTask.setEnd(null);
    		}
    	}
    	else {
    		if (start != null){
    			modifiedTask.setStart(start);
    		}
    		if (end != null){
    			modifiedTask.setEnd(end);
    		}
    	}
    	return true;
    }
    
    //query
    public ArrayList<Task> query(){
    	return taskList;
    }
    
    public ArrayList<Task> query(String label){
    	ArrayList<Task> returnList = new ArrayList<Task>();
    	for(int i=0; i<taskList.size();i++){
    		if (taskList.get(i).getLabel().equals(label)){
    			returnList.add(taskList.get(i));
    		}
{'fraction_non_alphanumeric': 0.14246575342465753, 'fraction_numerical': 0.020131030375223347, 'mean_word_length': 2.818099135970896, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 21, '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': '96107', 'n_tokens_mistral': 2999, 'n_tokens_neox': 2786, 'n_words': 624}