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

pack-priv final Class ProgramFileObject

extends SimpleJavaFileObject
Class Inheritance
Imports
com.sun.tools.javac.resources.LauncherProperties.Errors, javax.lang.model.SourceVersion, javax.tools.JavaFileObject, .SimpleJavaFileObject, java.io.BufferedInputStream, .BufferedReader, .IOException, .InputStreamReader, java.nio.charset.Charset, java.nio.file.Files, .Path

The program to launch as Java file 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.

Field Summary

Modifier and TypeField and Description
private final CharSequence
private final Path
private final boolean
Inherited from javax.tools.SimpleJavaFileObject:
kinduri

Constructor Summary

AccessConstructor and Description
pack-priv
ProgramFileObject(Path file, CharSequence chars, boolean ignoreFirstLine)

Method Summary

Modifier and TypeMethod and Description
public CharSequence
getCharContent(boolean ignoreEncodingErrors)

Overrides javax.tools.SimpleJavaFileObject.getCharContent.

Implements javax.tools.FileObject.getCharContent.

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

public Path
public String
getName()

Overrides javax.tools.SimpleJavaFileObject.getName.

Implements javax.tools.FileObject.getName.

Returns a user-friendly name for this file object.

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

Overrides javax.tools.SimpleJavaFileObject.isNameCompatible.

Implements javax.tools.JavaFileObject.isNameCompatible.

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

pack-priv static ProgramFileObject

Returns:

a file object containing the content of the file
of
(Path
the file
file
)

Reads a source file, ignoring the first line if it is not a Java source file and it begins with #!

public String
toString()

Overrides javax.tools.SimpleJavaFileObject.toString.

Returns a string representation of the object.

Inherited from javax.tools.SimpleJavaFileObject:
deleteforSourcegetAccessLevelgetKindgetLastModifiedgetNestingKindopenInputStreamopenOutputStreamopenReaderopenWritertoUri

Field Detail

charsback to summary
private final CharSequence chars
fileback to summary
private final Path file
ignoreFirstLineback to summary
private final boolean ignoreFirstLine

Constructor Detail

ProgramFileObjectback to summary
pack-priv ProgramFileObject(Path file, CharSequence chars, boolean ignoreFirstLine)

Method Detail

getCharContentback to summary
public CharSequence getCharContent(boolean ignoreEncodingErrors)

Overrides javax.tools.SimpleJavaFileObject.getCharContent.

Implements javax.tools.FileObject.getCharContent.

Doc from javax.tools.SimpleJavaFileObject.getCharContent.

Returns the character content of this file object, if available. Any byte that cannot be decoded will be replaced by the default translation character. In addition, a diagnostic may be reported unless ignoreEncodingErrors is true.

Annotations
@Override
getFileback to summary
public Path getFile()
getNameback to summary
public String getName()

Overrides javax.tools.SimpleJavaFileObject.getName.

Implements javax.tools.FileObject.getName.

Doc from javax.tools.FileObject.getName.

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.

Annotations
@Override
isFirstLineIgnoredback to summary
public boolean isFirstLineIgnored()
isNameCompatibleback to summary
public boolean isNameCompatible(String simpleName, JavaFileObject.Kind kind)

Overrides javax.tools.SimpleJavaFileObject.isNameCompatible.

Implements javax.tools.JavaFileObject.isNameCompatible.

Doc from javax.tools.SimpleJavaFileObject.isNameCompatible.

Checks if this file object is compatible with the specified simple name and kind. A simple name is a single identifier (not qualified) as defined in The Java Language Specification, section 6.2.

Annotations
@Override
ofback to summary
pack-priv static ProgramFileObject of(Path file) throws Fault

Reads a source file, ignoring the first line if it is not a Java source file and it begins with #!.

If it is not a Java source file, and if the first two bytes are #!, indicating a "magic number" of an executable text file, the rest of the first line up to but not including the newline is ignored. All characters after the first two are read in the Charset#defaultCharset() default platform encoding}.

Parameters
file:Path

the file

Returns:ProgramFileObject

a file object containing the content of the file

Exceptions
Fault:
if an error occurs while reading the file
toStringback to summary
public String toString()

Overrides javax.tools.SimpleJavaFileObject.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override