javax.tools.ForwardingFileObject Java Examples

The following examples show how to use javax.tools.ForwardingFileObject. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RecordingJavaFileManager.java    From takari-lifecycle with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public FileObject getFileForOutput(Location location, String packageName, String relativeName, final FileObject sibling) throws IOException {
  FileObject fileObject = super.getFileForOutput(location, packageName, relativeName, sibling);
  return new ForwardingFileObject<FileObject>(fileObject) {
    @Override
    public OutputStream openOutputStream() throws IOException {
      record(sibling != null ? FileObjects.toFile(sibling) : null, FileObjects.toFile(fileObject));
      return new IncrementalFileOutputStream(FileObjects.toFile(this));
    }

    @Override
    public Writer openWriter() throws IOException {
      return encoding != null ? new OutputStreamWriter(openOutputStream(), encoding) : new OutputStreamWriter(openOutputStream());
    }
  };
}