@Override public JavaFileObject getJavaFileForInput(Location l, String className, Kind kind) { if (kind == JavaFileObject.Kind.CLASS) { int dot = className.lastIndexOf('.'); String dir = dot == -1 ? "" : FileObjects.convertPackage2Folder(className.substring(0, dot)); javax.tools.FileObject fo = tx.readFileObject(l, dir, className.substring(dot + 1)); if (fo != null) { return (JavaFileObject)fo; } } return super.getJavaFileForInput(l, className, kind); }
@Override public javax.tools.FileObject getFileForInput(Location l, String pkgName, String relativeName) { final String[] names = FileObjects.getFolderAndBaseName( FileObjects.resolveRelativePath(pkgName, relativeName), FileObjects.NBFS_SEPARATOR_CHAR); javax.tools.FileObject fo = tx.readFileObject(l, names[0], names[1]); if (fo != null) { return fo; } return super.getFileForInput(l, pkgName, relativeName); }
@Override public FileObject getFileForInput(Location location, String packageName, String relativeName) throws IOException { if (!hasLocation(location)) { throw new IllegalArgumentException(String.valueOf(location)); } final File root = new File(outputRoot); final String path = FileObjects.resolveRelativePath(packageName, relativeName); final String[] names = FileObjects.getFolderAndBaseName(path, FileObjects.NBFS_SEPARATOR_CHAR); final javax.tools.FileObject jfo = tx.readFileObject(location, names[0], names[1]); if (jfo != null) { return (JavaFileObject) jfo; } final Archive archive = provider.getArchive(BaseUtilities.toURI(root).toURL(), false); return archive != null ? archive.getFile(path) : null; }
@Override public JavaFileObject getJavaFileForInput(Location location, String className, JavaFileObject.Kind kind) throws IOException { if (!hasLocation(location)) { throw new IllegalArgumentException(String.valueOf(location)); } final String [] names = FileObjects.getParentRelativePathAndName(className); if (kind == JavaFileObject.Kind.CLASS) { javax.tools.FileObject fo = tx.readFileObject(location, names[0], names[1]); if (fo != null) { return (JavaFileObject)fo; } } names[1] = names[1] + kind.extension; try { final File root = new File (outputRoot); Archive archive = provider.getArchive (BaseUtilities.toURI(root).toURL(), false); if (archive != null) { Iterable<JavaFileObject> files = archive.getFiles(names[0], null, null, null); for (JavaFileObject e : files) { if (names[1].equals(e.getName())) { return e; } } } } catch (IOException e) { Exceptions.printStackTrace(e); } return null; }