/* (non-Javadoc) * @see javax.tools.JavaFileManager#getJavaFileForInput(javax.tools.JavaFileManager.Location, java.lang.String, javax.tools.JavaFileObject.Kind) */ @Override public JavaFileObject getJavaFileForInput(Location location, String className, Kind kind) throws IOException { if (kind != Kind.CLASS && kind != Kind.SOURCE) { throw new IllegalArgumentException("Invalid kind : " + kind); // $NON-NLS-1$ } Iterable<? extends File> files = getLocation(location); if (files == null) { throw new IllegalArgumentException("Unknown location : " + location); // $NON-NLS-1$ } String normalizedFileName = normalized(className); normalizedFileName += kind.extension; for (File file : files) { if (file.isDirectory()) { // handle directory File f = new File(file, normalizedFileName); if (f.exists()) { return new EclipseFileObject(className, f.toURI(), kind, this.charset); } else { continue; // go to next entry in the location } } else if (isArchive(file)) { // handle archive file Archive archive = getArchive(file); if (archive != Archive.UNKNOWN_ARCHIVE) { if (archive.contains(normalizedFileName)) { return archive.getArchiveFileObject(normalizedFileName, this.charset); } } } } return null; }
/* (non-Javadoc) * @see javax.tools.JavaFileManager#getFileForInput(javax.tools.JavaFileManager.Location, java.lang.String, java.lang.String) */ @Override public FileObject getFileForInput(Location location, String packageName, String relativeName) throws IOException { Iterable<? extends File> files = getLocation(location); if (files == null) { throw new IllegalArgumentException("Unknown location : " + location); // $NON-NLS-1$ } String normalizedFileName = normalized(packageName) + '/' + relativeName.replace('\\', '/'); for (File file : files) { if (file.isDirectory()) { // handle directory File f = new File(file, normalizedFileName); if (f.exists()) { return new EclipseFileObject( packageName + File.separator + relativeName, f.toURI(), getKind(f), this.charset); } else { continue; // go to next entry in the location } } else if (isArchive(file)) { // handle archive file Archive archive = getArchive(file); if (archive != Archive.UNKNOWN_ARCHIVE) { if (archive.contains(normalizedFileName)) { return archive.getArchiveFileObject(normalizedFileName, this.charset); } } } } return null; }
@Override public boolean contains(File item) { for (Archive<File> archive : archives) { if (archive.contains(item)) { return true; } } return false; }