com.sun.tools.javac.util
Class JCDiagnostic

java.lang.Object
  extended by com.sun.tools.javac.util.JCDiagnostic
All Implemented Interfaces:
Diagnostic<JavaFileObject>
Direct Known Subclasses:
JCDiagnostic.MultilineDiagnostic

public class JCDiagnostic
extends java.lang.Object
implements Diagnostic<JavaFileObject>

An abstraction of a diagnostic message generated by the compiler.

This is NOT part of any API supported by Sun Microsystems. 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 Class Summary
static interface JCDiagnostic.DiagnosticPosition
          A DiagnosticPosition provides information about the positions in a file that gave rise to a diagnostic.
static class JCDiagnostic.DiagnosticType
          A DiagnosticType defines the type of the diagnostic.
static class JCDiagnostic.Factory
          A factory for creating diagnostic objects.
static class JCDiagnostic.MultilineDiagnostic
           
static class JCDiagnostic.SimpleDiagnosticPosition
          A DiagnosticPosition that simply identifies a position, but no related tree node, as the location for a diagnostic.
 
Nested classes/interfaces inherited from interface javax.tools.Diagnostic
Diagnostic.Kind
 
Field Summary
protected  java.lang.Object[] args
           
private  int column
           
private  DiagnosticFormatter<JCDiagnostic> defaultFormatter
           
private static DiagnosticFormatter<JCDiagnostic> fragmentFormatter
          Deprecated. 
private  java.lang.String key
           
private  int line
           
private  boolean mandatory
           
private  JCDiagnostic.DiagnosticPosition position
           
private  DiagnosticSource source
           
private  JCDiagnostic.DiagnosticType type
           
 
Fields inherited from interface javax.tools.Diagnostic
NOPOS
 
Constructor Summary
protected JCDiagnostic(DiagnosticFormatter<JCDiagnostic> formatter, JCDiagnostic.DiagnosticType dt, boolean mandatory, DiagnosticSource source, JCDiagnostic.DiagnosticPosition pos, java.lang.String key, java.lang.Object... args)
          Create a diagnostic object.
 
Method Summary
static JCDiagnostic fragment(java.lang.String key, java.lang.Object... args)
          Deprecated. 
 java.lang.Object[] getArgs()
          Get the arguments to be included in the text of the diagnostic.
 java.lang.String getCode()
          Gets a diagnostic code indicating the type of diagnostic.
 long getColumnNumber()
          Get the column number within the line of source referred to by this diagnostic.
 DiagnosticSource getDiagnosticSource()
          Get the source referred to by this diagnostic.
 long getEndPosition()
          Gets the character offset from the beginning of the file associated with this diagnostic that indicates the end of the problem.
static DiagnosticFormatter<JCDiagnostic> getFragmentFormatter()
          Deprecated. 
protected  int getIntEndPosition()
           
protected  int getIntPosition()
           
protected  int getIntStartPosition()
           
 Diagnostic.Kind getKind()
          Gets the kind of this diagnostic, for example, error or warning.
 long getLineNumber()
          Get the line number within the source referred to by this diagnostic.
 java.lang.String getMessage(java.util.Locale locale)
          Gets a localized message for the given locale.
 long getPosition()
          Gets a character offset from the beginning of the source object associated with this diagnostic that indicates the location of the problem.
 java.lang.String getPrefix()
          Get the prefix string associated with this type of diagnostic.
 java.lang.String getPrefix(JCDiagnostic.DiagnosticType dt)
          Get the prefix string associated with a particular type of diagnostic.
 JavaFileObject getSource()
          Get the name of the source file referred to by this diagnostic.
 java.lang.String getSourceName()
          Get the name of the source file referred to by this diagnostic.
 long getStartPosition()
          Gets the character offset from the beginning of the file associated with this diagnostic that indicates the start of the problem.
 List<JCDiagnostic> getSubdiagnostics()
          Get the subdiagnostic list
 JCDiagnostic.DiagnosticType getType()
          Get the type of this diagnostic.
 boolean isMandatory()
          Check whether or not this diagnostic is required to be shown.
 boolean isMultiline()
           
 java.lang.String toString()
          Return the standard presentation of this diagnostic.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

type

private final JCDiagnostic.DiagnosticType type

source

private final DiagnosticSource source

position

private final JCDiagnostic.DiagnosticPosition position

line

private final int line

column

private final int column

key

private final java.lang.String key

args

protected java.lang.Object[] args

mandatory

private boolean mandatory

defaultFormatter

private DiagnosticFormatter<JCDiagnostic> defaultFormatter

fragmentFormatter

@Deprecated
private static DiagnosticFormatter<JCDiagnostic> fragmentFormatter
Deprecated. 
Constructor Detail

JCDiagnostic

protected JCDiagnostic(DiagnosticFormatter<JCDiagnostic> formatter,
                       JCDiagnostic.DiagnosticType dt,
                       boolean mandatory,
                       DiagnosticSource source,
                       JCDiagnostic.DiagnosticPosition pos,
                       java.lang.String key,
                       java.lang.Object... args)
Create a diagnostic object.

Parameters:
messages - the resource for localized messages
dt - the type of diagnostic
name - the name of the source file, or null if none.
pos - the character offset within the source file, if given.
key - a resource key to identify the text of the diagnostic
args - arguments to be included in the text of the diagnostic
Method Detail

fragment

@Deprecated
public static JCDiagnostic fragment(java.lang.String key,
                                               java.lang.Object... args)
Deprecated. 

Create a fragment diagnostic, for use as an argument in other diagnostics

Parameters:
key - The key for the localized error message.
args - Fields of the error message.

getFragmentFormatter

@Deprecated
public static DiagnosticFormatter<JCDiagnostic> getFragmentFormatter()
Deprecated. 


getType

public JCDiagnostic.DiagnosticType getType()
Get the type of this diagnostic.

Returns:
the type of this diagnostic

getSubdiagnostics

public List<JCDiagnostic> getSubdiagnostics()
Get the subdiagnostic list

Returns:
subdiagnostic list

isMultiline

public boolean isMultiline()

isMandatory

public boolean isMandatory()
Check whether or not this diagnostic is required to be shown.

Returns:
true if this diagnostic is required to be shown.

getSource

public JavaFileObject getSource()
Get the name of the source file referred to by this diagnostic.

Specified by:
getSource in interface Diagnostic<JavaFileObject>
Returns:
the name of the source referred to with this diagnostic, or null if none

getSourceName

public java.lang.String getSourceName()
Get the name of the source file referred to by this diagnostic.

Returns:
the name of the source referred to with this diagnostic, or null if none

getDiagnosticSource

public DiagnosticSource getDiagnosticSource()
Get the source referred to by this diagnostic.

Returns:
the source referred to with this diagnostic, or null if none

getIntStartPosition

protected int getIntStartPosition()

getIntPosition

protected int getIntPosition()

getIntEndPosition

protected int getIntEndPosition()

getStartPosition

public long getStartPosition()
Description copied from interface: Diagnostic
Gets the character offset from the beginning of the file associated with this diagnostic that indicates the start of the problem.

Specified by:
getStartPosition in interface Diagnostic<JavaFileObject>
Returns:
offset from beginning of file; Diagnostic.NOPOS if and only if Diagnostic.getPosition() returns Diagnostic.NOPOS

getPosition

public long getPosition()
Description copied from interface: Diagnostic
Gets a character offset from the beginning of the source object associated with this diagnostic that indicates the location of the problem. In addition, the following must be true:

getStartPostion() <= getPosition()

getPosition() <= getEndPosition()

Specified by:
getPosition in interface Diagnostic<JavaFileObject>
Returns:
character offset from beginning of source; Diagnostic.NOPOS if Diagnostic.getSource() would return null or if no location is suitable

getEndPosition

public long getEndPosition()
Description copied from interface: Diagnostic
Gets the character offset from the beginning of the file associated with this diagnostic that indicates the end of the problem.

Specified by:
getEndPosition in interface Diagnostic<JavaFileObject>
Returns:
offset from beginning of file; Diagnostic.NOPOS if and only if Diagnostic.getPosition() returns Diagnostic.NOPOS

getLineNumber

public long getLineNumber()
Get the line number within the source referred to by this diagnostic.

Specified by:
getLineNumber in interface Diagnostic<JavaFileObject>
Returns:
the line number within the source referred to by this diagnostic

getColumnNumber

public long getColumnNumber()
Get the column number within the line of source referred to by this diagnostic.

Specified by:
getColumnNumber in interface Diagnostic<JavaFileObject>
Returns:
the column number within the line of source referred to by this diagnostic

getArgs

public java.lang.Object[] getArgs()
Get the arguments to be included in the text of the diagnostic.

Returns:
the arguments to be included in the text of the diagnostic

getPrefix

public java.lang.String getPrefix()
Get the prefix string associated with this type of diagnostic.

Returns:
the prefix string associated with this type of diagnostic

getPrefix

public java.lang.String getPrefix(JCDiagnostic.DiagnosticType dt)
Get the prefix string associated with a particular type of diagnostic.

Returns:
the prefix string associated with a particular type of diagnostic

toString

public java.lang.String toString()
Return the standard presentation of this diagnostic.

Overrides:
toString in class java.lang.Object

getKind

public Diagnostic.Kind getKind()
Description copied from interface: Diagnostic
Gets the kind of this diagnostic, for example, error or warning.

Specified by:
getKind in interface Diagnostic<JavaFileObject>
Returns:
the kind of this diagnostic

getCode

public java.lang.String getCode()
Description copied from interface: Diagnostic
Gets a diagnostic code indicating the type of diagnostic. The code is implementation-dependent and might be null.

Specified by:
getCode in interface Diagnostic<JavaFileObject>
Returns:
a diagnostic code

getMessage

public java.lang.String getMessage(java.util.Locale locale)
Description copied from interface: Diagnostic
Gets a localized message for the given locale. The actual message is implementation-dependent. If the locale is null use the default locale.

Specified by:
getMessage in interface Diagnostic<JavaFileObject>
Parameters:
locale - a locale; might be null
Returns:
a localized message