站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 5.0.0

SourceForBinaryQueryImplementation (NetBeans Java Support APIs) - NetBeans API Javadoc 5.0.0

 

org.netbeans.spi.java.queries
Interface SourceForBinaryQueryImplementation


public interface SourceForBinaryQueryImplementation

Information about where Java sources corresponding to binaries (classfiles) can be found.

A default implementation is registered by the org.netbeans.modules.java.project module which looks up the project corresponding to the file (if any; jar-protocol URLs actually check the owner of the JAR file itself) and checks whether that project has an implementation of this interface in its lookup. If so, it delegates to that implementation. Therefore it is not generally necessary for a project type provider to register its own global implementation of this query, if it depends on the Java Project module and uses this style.

Note that if you supply a SourceForBinaryQueryImplementation corresponding to an entry in a ClassPathProvider for some source files, there needs to be a ClassPathProvider for the sources used as dependencies as well. Otherwise code completion will not work well; the current parser database creation strategy uses the following search order when deciding what to parse for a binary classpath element:

  1. The sources returned by SourceForBinaryQueryImplementation, if these have at least a bootclasspath specified as well by some ClassPathProvider.
  2. Compiled classes mixed into the "source" directory, if there are any.
  3. Compiled classes in the binary classpath element.

Since:
org.netbeans.api.java/1 1.4
See Also:
SourceForBinaryQuery, FileOwnerQuery, Project

Method Summary
 SourceForBinaryQuery.Result findSourceRoots(URL binaryRoot)
          Returns the source root(s) for a given binary root.
 

Method Detail

findSourceRoots

public SourceForBinaryQuery.Result findSourceRoots(URL binaryRoot)
Returns the source root(s) for a given binary root.

The returned SourceForBinaryQuery.Result must be a singleton. It means that for repeated calling of this method with the same recognized root the method has to return the same instance of SourceForBinaryQuery.Result.
The typical implemantation of the findSourceRoots contains 3 steps:

  1. Look into the cache if there is already a result for the root, if so return it
  2. Check if the binaryRoot is recognized, if not return null
  3. Create a new SourceForBinaryQuery.Result for the binaryRoot, put it into the cache and return it.

Any absolute URL may be used but typically it will use the file protocol for directory entries and jar protocol for JAR entries (e.g. jar:file:/tmp/foo.jar!/).

Parameters:
binaryRoot - the class path root of Java class files
Returns:
a result object encapsulating the answer or null if the binaryRoot is not recognized

 

Built on May 3 2007.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.