1 19 package org.netbeans.modules.java.debug; 20 21 import java.net.MalformedURLException ; 22 import java.net.URL ; 23 import java.util.logging.Level ; 24 import java.util.logging.Logger ; 25 import javax.swing.event.ChangeListener ; 26 import org.netbeans.api.java.queries.SourceForBinaryQuery.Result; 27 import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation; 28 import org.openide.filesystems.FileObject; 29 import org.openide.filesystems.URLMapper; 30 31 35 public class SourceForBinaryQueryImpl implements SourceForBinaryQueryImplementation { 36 37 public SourceForBinaryQueryImpl() { 38 } 39 40 public synchronized Result findSourceRoots(URL binaryRoot) { 41 try { 42 String binaryRootS = binaryRoot.toExternalForm(); 43 URL result = null; 44 if (binaryRootS.startsWith("jar:file:")) { if (binaryRootS.endsWith("/java/external/javac-api.jar!/")) { result = new URL (binaryRootS.substring("jar:".length(), binaryRootS.length() - "/java/external/javac-api.jar!/".length()) + "/retouche/Jsr199/src"); } else if (binaryRootS.endsWith("/java/external/javac-impl.jar!/")) { result = new URL (binaryRootS.substring("jar:".length(), binaryRootS.length() - "/java/external/javac-impl.jar!/".length()) + "/retouche/Jsr199/src"); } 50 final FileObject resultFO = result != null ? URLMapper.findFileObject(result) : null; 51 if (resultFO != null) { 52 return new Result() { 53 public FileObject[] getRoots() { 54 return new FileObject[] {resultFO}; 55 } 56 public void addChangeListener(ChangeListener l) {} 57 public void removeChangeListener(ChangeListener l) {} 58 }; 59 } 60 } 61 } catch (MalformedURLException e) { 62 Logger.getLogger("global").log(Level.INFO, null, e); } 64 return null; 65 } 66 67 } 68 | Popular Tags |