//get a HashMap that maps days to an ArrayList of ips
//there are some bugs here. To be fixed
/*when you write a method that is probably used by other methods,
you should wirte it with local variable to avoid some mistakes.
*/
//the two methods use the same instance variables <uiqueIp>
public HashMap<String, ArrayList<String>> iPsForDays(){
ArrayList<String> days = new ArrayList<String>();
readFile();
for(LogEntry a: records){
String date = a.getAccessTime().toString();
String time = date.substring(4, 10);
uniqueIp = uniqueIpVisitsOnDay2(time);
//If we want to make best use of uniqueIp, the right side should be
// an ArrayList of ips on different days.
IpsOnDays.put(time, uniqueIp);
System.out.println(IpsOnDays);
}
return IpsOnDays;
}
public ArrayList<String> uniqueIpVisitsOnDay2(String someday){
for(LogEntry a: records){
String date = a.getAccessTime().toString();
String time = date.substring(4,10);
if(time.equals(someday)){
uniqueIp.add(a.getIpAddress());
}
}
return uniqueIp;
}