Package javax.tools

Class SimpleJavaFileObject

java.lang.Object
javax.tools.SimpleJavaFileObject
All Implemented Interfaces:
FileObject, JavaFileObject

public class SimpleJavaFileObject extends Object implements JavaFileObject
Provides simple implementations for most methods in JavaFileObject. This class is designed to be subclassed and used as a basis for JavaFileObject implementations. Subclasses can override the implementation and specification of any method of this class as long as the general contract of JavaFileObject is obeyed.
Since:
1.6
  • Field Details

    • uri

      protected final URI uri
      A URI for this file object.
    • kind

      protected final JavaFileObject.Kind kind
      The kind of this file object.
  • Constructor Details

    • SimpleJavaFileObject

      protected SimpleJavaFileObject(URI uri, JavaFileObject.Kind kind)
      Construct a SimpleJavaFileObject of the given kind and with the given URI.
      Parameters:
      uri - the URI for this file object
      kind - the kind of this file object
  • Method Details

    • toUri

      public URI toUri()
      Description copied from interface: FileObject
      Returns a URI identifying this file object.
      Specified by:
      toUri in interface FileObject
      Returns:
      a URI
    • getName

      public String getName()
      Description copied from interface: FileObject
      Returns a user-friendly name for this file object. The exact value returned is not specified but implementations should take care to preserve names as given by the user. For example, if the user writes the filename "BobsApp\Test.java" on the command line, this method should return "BobsApp\Test.java" whereas the toUri method might return file:///C:/Documents%20and%20Settings/UncleBob/BobsApp/Test.java.
      Specified by:
      getName in interface FileObject
      Returns:
      a user-friendly name
    • openInputStream

      public InputStream openInputStream() throws IOException
      This implementation always throws UnsupportedOperationException. Subclasses can change this behavior as long as the contract of FileObject is obeyed.
      Specified by:
      openInputStream in interface FileObject
      Returns:
      an InputStream
      Throws:
      IOException - if an I/O error occurred
    • openOutputStream

      public OutputStream openOutputStream() throws IOException
      This implementation always throws UnsupportedOperationException. Subclasses can change this behavior as long as the contract of FileObject is obeyed.
      Specified by:
      openOutputStream in interface FileObject
      Returns:
      an OutputStream
      Throws:
      IOException - if an I/O error occurred
    • openReader

      public Reader openReader(boolean ignoreEncodingErrors) throws IOException
      Wraps the result of getCharContent(boolean) in a Reader. Subclasses can change this behavior as long as the contract of FileObject is obeyed.
      Specified by:
      openReader in interface FileObject
      Parameters:
      ignoreEncodingErrors - ignore encoding errors if true
      Returns:
      a Reader wrapping the result of getCharContent
      Throws:
      IllegalStateException - if this file object was opened for writing and does not support reading
      UnsupportedOperationException - if this kind of file object does not support character access
      IOException - if an I/O error occurred
    • getCharContent

      public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException
      This implementation always throws UnsupportedOperationException. Subclasses can change this behavior as long as the contract of