SourcePathCachepublic final class SourcePathCache extends Object
Fields Summary |
---|
private final File[] | m_sourcepath | private final Map | m_packageCache | private static final FileExtensionFilter | FILE_EXTENSION_FILTER |
Constructors Summary |
---|
public SourcePathCache(String[] sourcepath, boolean removeNonExistent)
if (sourcepath == null) throw new IllegalArgumentException ("null input: sourcepath");
final List _sourcepath = new ArrayList (sourcepath.length);
for (int i = 0; i < sourcepath.length; ++ i)
{
final File dir = new File (sourcepath [i]);
if (! removeNonExistent || (dir.isDirectory () && dir.exists ()))
_sourcepath.add (dir);
}
m_sourcepath = new File [_sourcepath.size ()];
_sourcepath.toArray (m_sourcepath);
m_packageCache = new HashMap ();
| public SourcePathCache(File[] sourcepath, boolean removeNonExistent)
if (sourcepath == null) throw new IllegalArgumentException ("null input: sourcepath");
final List _sourcepath = new ArrayList (sourcepath.length);
for (int i = 0; i < sourcepath.length; ++ i)
{
final File dir = sourcepath [i];
if (! removeNonExistent || (dir.isDirectory () && dir.exists ()))
_sourcepath.add (dir);
}
m_sourcepath = new File [_sourcepath.size ()];
_sourcepath.toArray (m_sourcepath);
m_packageCache = new HashMap ();
|
Methods Summary |
---|
private java.util.Set | faultListing(java.io.File dir, java.lang.String packageVMName)
if ($assert.ENABLED) $assert.ASSERT (dir != null, "dir = null");
if ($assert.ENABLED) $assert.ASSERT (packageVMName != null, "packageVMName = null");
final File packageFile = new File (dir, packageVMName.replace ('/", File.separatorChar));
final File [] listing = packageFile.listFiles (FILE_EXTENSION_FILTER);
if ((listing == null) || (listing.length == 0))
return Collections.EMPTY_SET;
else
{
final Set result = new HashSet (listing.length);
for (int f = 0; f < listing.length; ++ f)
{
result.add (listing [f].getName ());
}
return result;
}
| public synchronized java.io.File | find(java.lang.String packageVMName, java.lang.String name)
if (packageVMName == null) throw new IllegalArgumentException ("null input: packageVMName");
if (name == null) throw new IllegalArgumentException ("null input: name");
if (m_sourcepath.length == 0) return null;
CacheEntry entry = (CacheEntry) m_packageCache.get (packageVMName);
if (entry == null)
{
entry = new CacheEntry (m_sourcepath.length);
m_packageCache.put (packageVMName, entry);
}
final Set [] listings = entry.m_listings;
for (int p = 0; p < listings.length; ++ p)
{
Set listing = listings [p];
if (listing == null)
{
listing = faultListing (m_sourcepath [p], packageVMName);
listings [p] = listing;
}
// TODO: this is case-sensitive at this point
if (listing.contains (name))
{
final File relativeFile = new File (packageVMName.replace ('/", File.separatorChar), name);
return new File (m_sourcepath [p], relativeFile.getPath ()).getAbsoluteFile ();
}
}
return null;
|
|