Package javax.tools

Class 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 Detail

      • uri

        protected final URI uri
        A URI for this file object.
    • Constructor Detail

      • 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 Detail

      • getLastModified

        public long getLastModified()
        This implementation returns 0L. Subclasses can change this behavior as long as the contract of FileObject is obeyed.
        Specified by:
        getLastModified in interface FileObject
        Returns:
        0L
      • delete

        public boolean delete()
        This implementation does nothing. Subclasses can change this behavior as long as the contract of FileObject is obeyed.
        Specified by:
        delete in interface FileObject
        Returns:
        false
      • isNameCompatible

        public boolean isNameCompatible​(String simpleName,
                                        JavaFileObject.Kind kind)
        This implementation compares the path of its URI to the given simple name. This method returns true if the given kind is equal to the kind of this object, and if the path is equal to simpleName + kind.extension or if it ends with "/" + simpleName + kind.extension.

        This method calls getKind() and FileObject.toUri() and does not access the fields uri and kind directly.

        Subclasses can change this behavior as long as the contract of JavaFileObject is obeyed.

        Specified by:
        isNameCompatible in interface JavaFileObject
        Parameters:
        simpleName - a simple name of a class
        kind - a kind
        Returns:
        true if this file object is compatible; false otherwise
      • getNestingKind

        public NestingKind getNestingKind()
        This implementation returns null. Subclasses can change this behavior as long as the contract of JavaFileObject is obeyed.
        Specified by:
        getNestingKind in interface JavaFileObject
        Returns:
        the nesting kind, or null if the nesting kind is not known
      • getAccessLevel

        public Modifier getAccessLevel()
        This implementation returns null. Subclasses can change this behavior as long as the contract of JavaFileObject is obeyed.
        Specified by:
        getAccessLevel in interface JavaFileObject
        Returns:
        the access level

微信小程序

微信扫一扫体验

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部