1 19 20 package org.netbeans.modules.java.project; 21 22 import java.net.URI ; 23 import java.net.URL ; 24 import java.util.Arrays ; 25 import org.netbeans.api.java.queries.JavadocForBinaryQuery; 26 import org.netbeans.api.project.FileOwnerQuery; 27 import org.netbeans.api.project.Project; 28 import org.netbeans.spi.java.queries.JavadocForBinaryQueryImplementation; 29 import org.openide.ErrorManager; 30 31 35 public class JavadocForBinaryQueryImpl implements JavadocForBinaryQueryImplementation { 36 37 private static final ErrorManager ERR = ErrorManager.getDefault().getInstance(JavadocForBinaryQueryImpl.class.getName()); 38 39 40 public JavadocForBinaryQueryImpl() { 41 } 42 43 public JavadocForBinaryQuery.Result findJavadoc(URL binary) { 44 boolean log = ERR.isLoggable(ErrorManager.INFORMATIONAL); 45 Project project = FileOwnerQuery.getOwner(URI.create(binary.toString())); 46 if (project != null) { 47 JavadocForBinaryQueryImplementation jfbqi = project.getLookup().lookup(JavadocForBinaryQueryImplementation.class); 48 if (jfbqi != null) { 49 JavadocForBinaryQuery.Result result = jfbqi.findJavadoc(binary); 50 if (log) ERR.log("Project " + project + " reported for " + binary + ": " + (result != null ? Arrays.asList(result.getRoots()) : null)); 51 return result; 52 } else { 53 if (log) ERR.log("Project " + project + " did not have any JavadocForBinaryQueryImplementation"); 54 } 55 } else { 56 if (log) ERR.log("No project found for " + binary + "; cannot find Javadoc"); 57 } 58 return null; 59 } 60 61 } 62 | Popular Tags |