package com.onpositive.gae.profiler;
import java.io.File;
import java.io.IOException;
import java.util.WeakHashMap;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import com.onpositive.instrumentation.tasks.CallDictionary;
public class DictionaryManager {
static WeakHashMap<File, CallDictionary> cashedDictionaries = new WeakHashMap<File, CallDictionary>();
public static CallDictionary getCallDictionary(IProject project)
throws IOException {
IPath workingLocation = project.getWorkingLocation(Activator.PLUGIN_ID);
File fl = workingLocation.toFile();
File dictionaryFile = new File(fl, "profiler.dict");
CallDictionary callDictionary = cashedDictionaries.get(dictionaryFile);
if (callDictionary == null) {
callDictionary = new StoredCallDictionary(project,dictionaryFile);
cashedDictionaries.put(dictionaryFile, callDictionary);
}
return callDictionary;
}
public static boolean deleteCallDictinary(IProject project) {
IPath workingLocation = project.getWorkingLocation(Activator.PLUGIN_ID);
File fl = workingLocation.toFile();
File dictionaryFile = new File(fl, "profiler.dict");
cashedDictionaries.remove(dictionaryFile);
if (dictionaryFile.exists()){
return dictionaryFile.delete();
}
return true;
}
}