Method from com.sun.tools.javac.nio.JavacPathFileManager Detail: |
public void close() throws IOException {
for (FileSystem fs: fileSystems.values())
fs.close();
}
|
public void flush() throws IOException {
contentCache.clear();
}
|
public ClassLoader getClassLoader(Location location) {
nullCheck(location);
Iterable< ? extends Path > path = getLocation(location);
if (path == null)
return null;
ListBuffer< URL > lb = new ListBuffer< URL >();
for (Path p: path) {
try {
lb.append(p.toUri().toURL());
} catch (MalformedURLException e) {
throw new AssertionError(e);
}
}
return getClassLoader(lb.toArray(new URL[lb.size()]));
}
|
public FileSystem getDefaultFileSystem() {
if (defaultFileSystem == null)
defaultFileSystem = FileSystems.getDefault();
return defaultFileSystem;
}
|
public FileObject getFileForInput(Location location,
String packageName,
String relativeName) throws IOException {
return getFileForInput(location, getRelativePath(packageName, relativeName));
}
|
public FileObject getFileForOutput(Location location,
String packageName,
String relativeName,
FileObject sibling) throws IOException {
return getFileForOutput(location, getRelativePath(packageName, relativeName), sibling);
}
|
public JavaFileObject getJavaFileForInput(Location location,
String className,
Kind kind) throws IOException {
return getFileForInput(location, getRelativePath(className, kind));
}
|
public JavaFileObject getJavaFileForOutput(Location location,
String className,
Kind kind,
FileObject sibling) throws IOException {
return getFileForOutput(location, getRelativePath(className, kind), sibling);
}
|
public Iterable<JavaFileObject> getJavaFileObjects(Path paths) {
return getJavaFileObjectsFromPaths(Arrays.asList(nullCheck(paths)));
}
|
public Iterable<JavaFileObject> getJavaFileObjectsFromPaths(Iterable<Path> paths) {
ArrayList< PathFileObject > result;
if (paths instanceof Collection< ? >)
result = new ArrayList< PathFileObject >(((Collection< ? >)paths).size());
else
result = new ArrayList< PathFileObject >();
for (Path p: paths)
result.add(PathFileObject.createSimplePathFileObject(this, nullCheck(p)));
return result;
}
|
public Iterable<Path> getLocation(Location location) {
nullCheck(location);
lazyInitSearchPaths();
PathsForLocation path = pathsForLocation.get(location);
if (path == null && !pathsForLocation.containsKey(location)) {
setDefaultForLocation(location);
path = pathsForLocation.get(location);
}
return path;
}
|
public Path getPath(FileObject fo) {
nullCheck(fo);
if (!(fo instanceof PathFileObject))
throw new IllegalArgumentException();
return ((PathFileObject) fo).getPath();
}
|
public boolean hasLocation(Location location) {
return (getLocation(location) != null);
}
|
public String inferBinaryName(Location location,
JavaFileObject fo) {
nullCheck(fo);
// Need to match the path semantics of list(location, ...)
Iterable< ? extends Path > paths = getLocation(location);
if (paths == null) {
return null;
}
if (!(fo instanceof PathFileObject))
throw new IllegalArgumentException(fo.getClass().getName());
return ((PathFileObject) fo).inferBinaryName(paths);
}
|
public boolean isDefaultBootClassPath() {
return searchPaths.isDefaultBootClassPath();
}
|
public boolean isSameFile(FileObject a,
FileObject b) {
nullCheck(a);
nullCheck(b);
if (!(a instanceof PathFileObject))
throw new IllegalArgumentException("Not supported: " + a);
if (!(b instanceof PathFileObject))
throw new IllegalArgumentException("Not supported: " + b);
return ((PathFileObject) a).isSameFile((PathFileObject) b);
}
|
public Iterable<JavaFileObject> list(Location location,
String packageName,
Set<Kind> kinds,
boolean recurse) throws IOException {
// validatePackageName(packageName);
nullCheck(packageName);
nullCheck(kinds);
Iterable< ? extends Path > paths = getLocation(location);
if (paths == null)
return List.nil();
ListBuffer< JavaFileObject > results = new ListBuffer< JavaFileObject >();
for (Path path : paths)
list(path, packageName, kinds, recurse, results);
return results.toList();
}
|
protected void setContext(Context context) {
super.setContext(context);
searchPaths = Paths.instance(context);
}
Set the context for JavacPathFileManager. |
public void setDefaultFileSystem(FileSystem fs) {
defaultFileSystem = fs;
}
|
public void setLocation(Location location,
Iterable<Path> searchPath) throws IOException {
nullCheck(location);
lazyInitSearchPaths();
if (searchPath == null) {
setDefaultForLocation(location);
} else {
if (location.isOutputLocation())
checkOutputPath(searchPath);
PathsForLocation pl = new PathsForLocation();
for (Path p: searchPath)
pl.add(p); // TODO -Xlint:path warn if path not found
pathsForLocation.put(location, pl);
}
}
|