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

public Class DiagnosticSource

extends Object
Class Inheritance
Imports
java.io.IOException, java.lang.ref.SoftReference, java.nio.CharBuffer, javax.tools.JavaFileObject, com.sun.tools.javac.file.JavacFileManager

A simple abstraction of a source file, as needed for use in a diagnostic message. Provides access to the line and position in a line for any given character offset.

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
protected char[]
buf

A temporary hard reference to the content of the file object.

protected int
bufLen

The length of the content.

protected JavaFileObject
fileObject

The underlying file object.

protected int
line

The line number of a line found by findLine.

protected int
lineStart

The start of a line found by findLine.

protected AbstractLog
log

A log for reporting errors, such as errors accessing the content.

public static final DiagnosticSource
protected SoftReference<char[]>
refBuf

A soft reference to the content of the file object.

Constructor Summary

AccessConstructor and Description
public
private

Method Summary

Modifier and TypeMethod and Description
protected boolean
findLine(int
Character offset into the buffer
pos
)

Find the line in the buffer that contains the current position

public int
getColumnNumber(int pos, boolean expandTabs)

Return the one-based column number associated with a given pos for the current source file.

public JavaFileObject
getFile()

Return the underlying file object handled by this DiagnosticSource object.

public String
getLine(int pos)

Return the content of the line containing a given pos.

public int
getLineNumber(int pos)

Return the one-based line number associated with a given pos for the current source file.

protected char[]
initBuf(JavaFileObject fileObject)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufback to summary
protected char[] buf

A temporary hard reference to the content of the file object.

bufLenback to summary
protected int bufLen

The length of the content.

fileObjectback to summary
protected JavaFileObject fileObject

The underlying file object.

lineback to summary
protected int line

The line number of a line found by findLine.

lineStartback to summary
protected int lineStart

The start of a line found by findLine.

logback to summary
protected AbstractLog log

A log for reporting errors, such as errors accessing the content.

NO_SOURCEback to summary
public static final DiagnosticSource NO_SOURCE
refBufback to summary
protected SoftReference<char[]> refBuf

A soft reference to the content of the file object.

Constructor Detail

DiagnosticSourceback to summary
public DiagnosticSource(JavaFileObject fo, AbstractLog log)
DiagnosticSourceback to summary
private DiagnosticSource()

Method Detail

findLineback to summary
protected boolean findLine(int pos)

Find the line in the buffer that contains the current position

Parameters
pos:int

Character offset into the buffer

getColumnNumberback to summary
public int getColumnNumber(int pos, boolean expandTabs)

Return the one-based column number associated with a given pos for the current source file. Zero is returned if no column exists for the given position.

getFileback to summary
public JavaFileObject getFile()

Return the underlying file object handled by this DiagnosticSource object.

getLineback to summary
public String getLine(int pos)

Return the content of the line containing a given pos.

getLineNumberback to summary
public int getLineNumber(int pos)

Return the one-based line number associated with a given pos for the current source file. Zero is returned if no line exists for the given position.

initBufback to summary
protected char[] initBuf(JavaFileObject fileObject) throws IOException