Package com.onpositive.gae.profiler

Source Code of com.onpositive.gae.profiler.DictionaryManager

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;
  }
}
TOP

Related Classes of com.onpositive.gae.profiler.DictionaryManager

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.