byucc.jhdl
Class JHDLPrintWriter

java.lang.Object
  extended byjava.io.Writer
      extended byjava.io.PrintWriter
          extended bybyucc.jhdl.JHDLPrintWriter

public class JHDLPrintWriter
extends java.io.PrintWriter

This class extends PrintWriter. It is designed for use as an error message handling mechanism. The class JHDLOutput instantiates this class, and it also determines what the OutputStream will be.

Version:
1.0
Author:
Michael Halcrow

Field Summary
 
Fields inherited from class java.io.PrintWriter
out
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
JHDLPrintWriter()
          Creates a disabled JHDLPrintWriter.
JHDLPrintWriter(java.io.File file)
           
JHDLPrintWriter(JHDLPrintWriter pw)
           
JHDLPrintWriter(JHDLPrintWriter pw, boolean autoFlush)
           
JHDLPrintWriter(java.io.OutputStream outputStream)
          Initializes the PrintWriter's OutputStream to outputStream.
JHDLPrintWriter(java.io.OutputStream outputStream, boolean autoFlush)
          Creates a PrintWriter to the given stream
JHDLPrintWriter(java.lang.String filename)
          Creates a JHDLPrintWriter that targets a particular filename.
JHDLPrintWriter(java.io.Writer outputWriter)
          Initializes the PrintWriter's OutputStream to outputStream.
JHDLPrintWriter(java.io.Writer outputWriter, boolean autoFlush)
          Creates a PrintWriter to the given stream
 
Method Summary
 boolean disable()
          Disables this JHDLPrintWriter object
 boolean enable()
          Enables this JHDLPrintWriter object
 void finalize()
          Finalizer.
static java.io.BufferedWriter getBufferedWriter(java.lang.String fileName)
           
 boolean getEnabled()
          Returns the enabled state of this JHDLPrintWriter
 java.io.Writer getWriter()
           
 boolean isEnabled()
          Returns the value of isEnabled.
 void print(boolean arg)
          Override of print() method to handle the case when the instance is not enabled.
 void print(char arg)
          Override of print() method to handle the case when the instance is not enabled.
 void print(char[] s)
          The lone print() that does not call write(String) in the inherited version.
 void println()
          Override of println() method to handle the case when the instance is not enabled.
 void println(boolean arg)
          Override of println() method to handle the case when the instance is not enabled.
 void println(char arg)
          Override of println() method to handle the case when the instance is not enabled.
 void println(char[] arg)
          Override of println() method to handle the case when the instance is not enabled.
 void println(double arg)
          Override of println() method to handle the case when the instance is not enabled.
 void println(float arg)
          Override of println() method to handle the case when the instance is not enabled.
 void println(int arg)
          Override of println() method to handle the case when the instance is not enabled.
 void println(long arg)
          Override of println() method to handle the case when the instance is not enabled.
 void println(java.lang.Object arg)
          Override of println() method to handle the case when the instance is not enabled.
 void println(java.lang.String arg)
          Provides correct prefix and printing behavior, based on whether this instance is enabled.
 boolean setEnabled(boolean setTo)
          Sets the enabled status of this JHDLPrintWriter object.
 java.lang.String toString()
          Returns a string describing where this print writer is currently directed.
 void write(java.lang.String str)
          In order to make the passed text compatible with all operating systems (theoretically), this replaces all '\n' characters with a call to println().
 
Methods inherited from class java.io.PrintWriter
checkError, close, flush, print, print, print, print, print, print, setError, write, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JHDLPrintWriter

public JHDLPrintWriter(JHDLPrintWriter pw,
                       boolean autoFlush)

JHDLPrintWriter

public JHDLPrintWriter(JHDLPrintWriter pw)

JHDLPrintWriter

public JHDLPrintWriter(java.io.OutputStream outputStream,
                       boolean autoFlush)
Creates a PrintWriter to the given stream

Parameters:
outputStream - The target output stream (may be null, in which case this is disabled)
autoFlush - sets the autoFlush flag on the PrintWriter object

JHDLPrintWriter

public JHDLPrintWriter(java.io.OutputStream outputStream)
Initializes the PrintWriter's OutputStream to outputStream.

Parameters:
outputStream - The target OutputStream.

JHDLPrintWriter

public JHDLPrintWriter(java.io.Writer outputWriter,
                       boolean autoFlush)
Creates a PrintWriter to the given stream

Parameters:
autoFlush - sets the autoFlush flag on the PrintWriter object

JHDLPrintWriter

public JHDLPrintWriter(java.io.Writer outputWriter)
Initializes the PrintWriter's OutputStream to outputStream.


JHDLPrintWriter

public JHDLPrintWriter()
Creates a disabled JHDLPrintWriter.


JHDLPrintWriter

public JHDLPrintWriter(java.lang.String filename)
                throws java.io.IOException
Creates a JHDLPrintWriter that targets a particular filename. If the filename is null, then output is disabled.

Parameters:
filename - the file to direct output to (may be null)
Throws:
java.io.IOException - if there is a problem creating the stream

JHDLPrintWriter

public JHDLPrintWriter(java.io.File file)
                throws java.io.IOException
Method Detail

getBufferedWriter

public static java.io.BufferedWriter getBufferedWriter(java.lang.String fileName)

isEnabled

public boolean isEnabled()
Returns the value of isEnabled. If false, then the print(char[]) methods of this class do nothing.

Returns:
true if this printWriter is directed to some output stream.

print

public void print(char[] s)
The lone print() that does not call write(String) in the inherited version.

Parameters:
s - the array of chars to print
See Also:
write(String)

getWriter

public java.io.Writer getWriter()

write

public void write(java.lang.String str)
In order to make the passed text compatible with all operating systems (theoretically), this replaces all '\n' characters with a call to println(). According to the source code of PrintWriter, all of the print() methods not explicitly overloaded in this class eventually call this method. If isEnabled() returns false, then this method does nothing.

Parameters:
str - the string to print

print

public void print(boolean arg)
Override of print() method to handle the case when the instance is not enabled.

Parameters:
arg - the data to print

print

public void print(char arg)
Override of print() method to handle the case when the instance is not enabled.

Parameters:
arg - the data to print

println

public void println(java.lang.String arg)
Provides correct prefix and printing behavior, based on whether this instance is enabled.

Parameters:
arg - the string to print

println

public void println(boolean arg)
Override of println() method to handle the case when the instance is not enabled.

Parameters:
arg - the data to print

println

public void println(char arg)
Override of println() method to handle the case when the instance is not enabled.

Parameters:
arg - the data to print

println

public void println(char[] arg)
Override of println() method to handle the case when the instance is not enabled.

Parameters:
arg - the data to print

println

public void println(double arg)
Override of println() method to handle the case when the instance is not enabled.

Parameters:
arg - the data to print

println

public void println(float arg)
Override of println() method to handle the case when the instance is not enabled.

Parameters:
arg - the data to print

println

public void println(int arg)
Override of println() method to handle the case when the instance is not enabled.

Parameters:
arg - the data to print

println

public void println(long arg)
Override of println() method to handle the case when the instance is not enabled.

Parameters:
arg - the data to print

println

public void println(java.lang.Object arg)
Override of println() method to handle the case when the instance is not enabled.

Parameters:
arg - the data to print

println

public void println()
Override of println() method to handle the case when the instance is not enabled.


toString

public java.lang.String toString()
Returns a string describing where this print writer is currently directed.

Returns:
Information about this print writer

disable

public boolean disable()
Disables this JHDLPrintWriter object


enable

public boolean enable()
Enables this JHDLPrintWriter object


setEnabled

public boolean setEnabled(boolean setTo)
Sets the enabled status of this JHDLPrintWriter object. If this was created with null as the target, provides no functionality.

Parameters:
setTo - the new boolean setting of isEnabled for this object

getEnabled

public boolean getEnabled()
Returns the enabled state of this JHDLPrintWriter

Returns:
True if this is enabled; false otherwise

finalize

public void finalize()
Finalizer. Will not close any stream whose name starts with "System".



Copyright ? 2006 Brigham Young University, Configurable Computing Laboratory. All Rights Reserved.