APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.tools.javac.file

public abstract Class PathFileObject

extends Object
implements JavaFileObject
Class Inheritance
All Implemented Interfaces
javax.tools.JavaFileObject, javax.tools.FileObject
Known Direct Subclasses
com.sun.tools.javac.file.PathFileObject.DirectoryFileObject, com.sun.tools.javac.file.PathFileObject.JarFileObject, com.sun.tools.javac.file.PathFileObject.JRTFileObject, com.sun.tools.javac.file.PathFileObject.SimpleFileObject
Imports
java.io.IOException, .InputStream, .InputStreamReader, .OutputStream, .OutputStreamWriter, .Reader, .Writer, java.net.URI, .URISyntaxException, java.nio.ByteBuffer, .CharBuffer, java.nio.charset.CharsetDecoder, java.nio.file.FileSystem, .FileSystems, .Files, .LinkOption, .Path, java.text.Normalizer, java.util.Objects, javax.lang.model.element.Modifier, .NestingKind, javax.tools.FileObject, .JavaFileObject, com.sun.tools.javac.file.RelativePath.RelativeFile, com.sun.tools.javac.util.DefinedBy, .DefinedBy.Api

Implementation of JavaFileObject using java.nio.file API.

PathFileObjects are, for the most part, straightforward wrappers around immutable absolute Path objects. Different subtypes are used to provide specialized implementations of "inferBinaryName" and "getName" that capture additional information available at the time the object is created.

In general, JavaFileManager#isSameFile should be used to determine whether two file objects refer to the same file on disk. PathFileObject also supports the standard equals and hashCode methods, primarily for convenience when working with collections. All of these operations delegate to the equivalent operations on the underlying Path object.

This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
PathFileObject.CannotCreateUriError

Used when URLSyntaxException is thrown unexpectedly during implementations of FileObject.toURI().

private static class
private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
private static final FileSystem
protected final BaseFileManager
private boolean
private static final boolean
protected final Path

Constructor Summary

AccessConstructor and Description
protected
PathFileObject(BaseFileManager
the file manager creating this file object
fileManager
,
Path
the path contained in this file object.
path
)

Create a PathFileObject, for a specified path, in the context of a given file manager.

Method Summary

Modifier and TypeMethod and Description
public boolean
delete()

Implements javax.tools.FileObject.delete.

Deletes this file object.

private void
public boolean
equals(Object other)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

pack-priv static PathFileObject
forDirectoryPath(BaseFileManager
the file manager creating this file object
fileManager
,
Path
the absolute path referred to by this file object
path
,
Path
the path of the directory containing the root of the package hierarchy
userPackageRootDir
,
RelativePath
the path of this file relative to userPackageRootDir
relativePath
)

Create a PathFileObject for a file within a directory, such that the binary name can be inferred from the relationship to an enclosing directory.

public static PathFileObject

Returns:

the file object
forJarPath
(BaseFileManager
the file manager creating this file object
fileManager
,
Path
the path referred to by this file object
path
,
Path
the path of the jar file containing the file system.
userJarPath
)

Create a PathFileObject for a file in a file system such as a jar file, such that the binary name can be inferred from its position within the file system.

public static PathFileObject

Returns:

the file object
forJRTPath
(BaseFileManager
the file manager creating this file object
fileManager
,
final Path
the path referred to by this file object
path
)

Create a PathFileObject for a file in a modular file system, such as jrt:, such that the binary name can be inferred from its position within the filesystem.

pack-priv static PathFileObject
forSimplePath(BaseFileManager
the file manager creating this file object
fileManager
,
Path
the path referred to by this file object
path
,
Path
the "user-friendly" name for this path.
userPath
)

Create a PathFileObject for a file whose binary name must be inferred from its position on a search path.

public Modifier
getAccessLevel()

Implements javax.tools.JavaFileObject.getAccessLevel.

Provides a hint about the access level of the class represented by this file object.

public CharSequence
getCharContent(boolean ignoreEncodingErrors)

Implements javax.tools.FileObject.getCharContent.

Returns the character content of this file object, if available.

public JavaFileObject.Kind
getKind()

Implements javax.tools.JavaFileObject.getKind.

Returns the kind of this file object.

public long
getLastModified()

Implements javax.tools.FileObject.getLastModified.

Returns the time this file object was last modified.

public NestingKind
getNestingKind()

Implements javax.tools.JavaFileObject.getNestingKind.

Provides a hint about the nesting level of the class represented by this file object.

public Path

Returns:

the Path for this object.
getPath
()

Return the Path for this object.

public String

Returns:

the last component of the path
getShortName
()

The short name is used when generating raw diagnostics.

pack-priv abstract PathFileObject
getSibling(String basename)

Return the file object for a sibling file with a given file name.

public static String

Returns:

the simple name of the file object
getSimpleName
(FileObject
the file object
fo
)

Return the last component of a presumed hierarchical URI.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

pack-priv abstract String
pack-priv boolean
isJarFile()

Returns whether this file object represents a file in a JAR archive.

public boolean
isNameCompatible(String simpleName, JavaFileObject.Kind kind)

Implements javax.tools.JavaFileObject.isNameCompatible.

Checks if this file object is compatible with the specified simple name and kind.

protected boolean
pack-priv boolean
public InputStream
openInputStream()

Implements javax.tools.FileObject.openInputStream.

Returns an InputStream for this file object.

public OutputStream
openOutputStream()

Implements javax.tools.FileObject.openOutputStream.

Returns an OutputStream for this file object.

public Reader
openReader(boolean ignoreEncodingErrors)

Implements javax.tools.FileObject.openReader.

Returns a reader for this object.

public Writer
openWriter()

Implements javax.tools.FileObject.openWriter.

Returns a Writer for this file object.

private static String
protected static String
toBinaryName(RelativePath relativePath)

protected static String
toBinaryName(Path relativePath)

private static String
toBinaryName(String relativePath, String sep)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

public URI
toUri()

Implements javax.tools.FileObject.toUri.

Returns a URI identifying this file object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait