polyglot.frontend
Class SourceLoader

java.lang.Object
  extended bypolyglot.frontend.SourceLoader

public class SourceLoader
extends java.lang.Object

A SourceLoader is responsible for loading source files.


Field Summary
protected static java.io.File current_dir
          The current user directory.
protected  java.util.Map directoryContentsCache
          This is a map from Files (of directories) to Set[String]s, which records the first level of contents of the directory.
protected  ExtensionInfo sourceExt
           
protected  java.util.Collection sourcePath
           
 
Constructor Summary
SourceLoader(ExtensionInfo sourceExt, java.util.Collection sourcePath)
           
 
Method Summary
 FileSource classSource(java.lang.String className)
          Load the source file for the given class name using the source path.
 FileSource fileSource(java.lang.String fileName)
          Load a source from a specific file.
 boolean packageExists(java.lang.String name)
          Check if a directory for a package exists.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sourceExt

protected ExtensionInfo sourceExt

sourcePath

protected java.util.Collection sourcePath

directoryContentsCache

protected java.util.Map directoryContentsCache
This is a map from Files (of directories) to Set[String]s, which records the first level of contents of the directory. This cache is used to avoid a number of File.exists() calls.


current_dir

protected static java.io.File current_dir
The current user directory. We make it static so we don't need to keep on making copies of it.

Constructor Detail

SourceLoader

public SourceLoader(ExtensionInfo sourceExt,
                    java.util.Collection sourcePath)
Method Detail

fileSource

public FileSource fileSource(java.lang.String fileName)
                      throws java.io.IOException
Load a source from a specific file.

Throws:
java.io.IOException

packageExists

public boolean packageExists(java.lang.String name)
Check if a directory for a package exists.


classSource

public FileSource classSource(java.lang.String className)
Load the source file for the given class name using the source path.