/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.tod;
import com.sun.jdi.Method;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.filesystems.URLMapper;
import org.openide.modules.InstalledFileLocator;
/**
* A collection of utility functions for TOD.
*
* @author jeff
*/
public class TODUtils {
/**
* Whether or not TOD should be used in place of the standard interpreted
* omniscient debugger in Sodbeans.
*/
private static final boolean ENABLE_TOD = true;
public static boolean isTODEnabled() {
return ENABLE_TOD;
}
/**
* The location of TOD's libraries.
* @return the library path
*/
public static String getTODLibraryPath() {
//String userDir;
//String os = System.getProperty("os.name");
/*
if (os.compareTo("Mac OS X") == 0) {
userDir = System.getProperty("user.dir") + "/TOD/release/modules/lib/";
}
else if (os.compareTo("Linux") == 0) {
userDir = System.getProperty("user.dir") + "/TOD/release/modules/lib/";
}
else {
userDir = System.getProperty("user.dir") + "\\TOD\\release\\modules\\lib\\";
}
return userDir;*/
URL url;
try {
InstalledFileLocator locator = InstalledFileLocator.getDefault();
File directory = locator.locate("modules/lib", "org.tod", false);
return directory.getAbsolutePath() + File.separator;
} catch (Exception ex) {
Logger.getLogger(TODUtils.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
/**
* The location of TOD's JAR files.
* @return the library path
*/
public static String getTODJARPath() {
try {
InstalledFileLocator locator = InstalledFileLocator.getDefault();
File directory = locator.locate("modules/ext", "org.tod", false);
return directory.getAbsolutePath() + File.separator;
} catch (Exception ex) {
Logger.getLogger(TODUtils.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
/**
* Compute the JNI-style signature for the given JVM method.
*
* @param method
* @return the JNI-style signature. for example, "public void Main()"
* becomes "Main()V".
*/
public static String computeMethodSignature(Method method) {
return method.name() + method.signature();
}
}