tribble.io
Class DiagnosticOutputDfl

java.lang.Object
  extended by java.io.Writer
      extended by java.io.PrintWriter
          extended by tribble.io.SuspendablePrintWriter
              extended by tribble.io.DiagnosticOutputDfl
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable, DiagnosticOutputI, SuspendableWriterI

public class DiagnosticOutputDfl
extends SuspendablePrintWriter
implements DiagnosticOutputI

Diagnostic message (informational, warning, and error messages) output stream.

This is a default implementation of a diagnostic message output stream (see DiagnosticOutputI) that is capable of writing diagnostic messages as lines of text to an underlying output stream. Such a stream is used to display informational, warning, and error diagnostic messages by such classes as lexical analyzers (lexers) and parsers. See the printMessage(java.lang.String, int, java.lang.String) method.

Since:
2001-05-18
Version:
$Revision: 1.4 $ $Date: 2003/02/26 04:08:35 $
Author:
David R. Tribble, david@tribble.com.
Copyright 2001-2003 by David R. Tribble all rights reserved.
Permission is granted to freely use and distribute this source code provided that the original copyright and authorship notices remain intact.
See Also:
DiagnosticOutputI

Field Summary
protected  java.lang.StringBuffer m_buf
          Output message buffer.
(package private) static java.lang.String REV
          Revision information.
 
Fields inherited from class tribble.io.SuspendablePrintWriter
m_err, m_sus
 
Fields inherited from class java.io.PrintWriter
out
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
DiagnosticOutputDfl(java.io.OutputStream out)
          Constructor.
DiagnosticOutputDfl(java.io.Writer out)
          Constructor.
 
Method Summary
protected  void finalize()
          Finalization.
 void printMessage(java.lang.String fname, int line, java.lang.String msg)
          Writes a diagnostic message to the output stream.
 
Methods inherited from class tribble.io.SuspendablePrintWriter
checkError, clearError, close, flush, getOutput, isSuspended, print, print, print, print, print, print, print, print, print, println, println, println, println, println, println, println, println, println, println, resume, setOutput, suspend, write, write, write, write, write
 
Methods inherited from class java.io.PrintWriter
append, append, append, format, format, printf, printf, setError
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REV

static final java.lang.String REV
Revision information.

See Also:
Constant Field Values

m_buf

protected java.lang.StringBuffer m_buf
Output message buffer.

Constructor Detail

DiagnosticOutputDfl

public DiagnosticOutputDfl(java.io.Writer out)
Constructor.

Parameters:
out - An output stream to which diagnostic messages (warning and error messages) are written. This should not be null.
Since:
1.1, 2001-07-20

DiagnosticOutputDfl

public DiagnosticOutputDfl(java.io.OutputStream out)
Constructor.

Parameters:
out - An output stream to which diagnostic messages (warning and error messages) are written. This should not be null.
Since:
1.1, 2001-07-20
Method Detail

printMessage

public void printMessage(java.lang.String fname,
                         int line,
                         java.lang.String msg)
Writes a diagnostic message to the output stream.

Specified by:
printMessage in interface DiagnosticOutputI
Parameters:
fname - An optional source filename for the diagnostic message. If it is not null and not empty, it and a colon (":") immediately following it are written.
line - An optional source line number for the diagnostic message. If it is not zero, it and a colon (":") immediately following it are written.
msg - The message text. This typically contains a prefix indicating the severity of the message, such as "warning:" or "error:". Note that the message should not contain a terminating linefeed.
Since:
1.1, 2001-05-18

finalize

protected void finalize()
                 throws java.lang.Throwable
Finalization. Flushes the underlying output stream, if any, but does not close it.

Overrides:
finalize in class SuspendablePrintWriter
Throws:
java.lang.Throwable - Thrown if an error occurs.
Since:
1.1, 2001-05-18