byucc.jhdl.netlisters
Class NetlistWriter

java.lang.Object
  extended byjava.io.Writer
      extended byjava.io.PrintWriter
          extended bybyucc.jhdl.netlisters.NetlistWriter

public class NetlistWriter
extends java.io.PrintWriter

This extends PrintWriter to offer filtering - whenever the character '\n' is encountered in a string to be printed, the string is tokenized and PrintWriter.println() is called after each token. In this manner, the writer has correct system-independent line separation, and the netlists can cache multi-line strings to print using regular Java Strings or StringBuffers.

To have the original behavior of '\n' being the ASCII line-feed character, instead of a system-independent line break, use one of the write(java.lang.String) methods, or print the actual char or char[].

This class can only throw (runtime) exceptions during the constructor, if a file cannot be opened. All other operations have suppressed messages, but one can check if an error has occurred by calling the cumulative status flag #getError().

Author:
Eric Blake

Field Summary
 
Fields inherited from class java.io.PrintWriter
out
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
NetlistWriter(java.io.File file)
          Opens a print writer that targets the given file.
NetlistWriter(java.io.OutputStream output)
          Opens a print writer that targets the given OutputStream.
NetlistWriter(java.io.OutputStream output, boolean autoflush)
          Opens a print writer that targets the given OutputStream.
NetlistWriter(java.lang.String filename)
          Opens a print writer that targets the given filename.
NetlistWriter(java.io.Writer output)
          Opens a print writer that targets the given Writer.
NetlistWriter(java.io.Writer output, boolean autoflush)
          Opens a print writer that targets the given Writer.
 
Method Summary
 void write(java.lang.String data)
          Overrides the write() method (called by all the print() methods) to have system-independent line breaks on '\n'
 
Methods inherited from class java.io.PrintWriter
checkError, close, flush, print, print, print, print, print, print, print, print, print, println, println, println, println, println, println, println, println, println, println, setError, write, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NetlistWriter

public NetlistWriter(java.lang.String filename)
Opens a print writer that targets the given filename.

Parameters:
filename - the file to write to
Throws:
NetlistException - if the file cannot be opened

NetlistWriter

public NetlistWriter(java.io.File file)
Opens a print writer that targets the given file.

Parameters:
file - the file to write to
Throws:
NetlistException - if the file cannot be opened

NetlistWriter

public NetlistWriter(java.io.OutputStream output)
Opens a print writer that targets the given OutputStream.

Parameters:
output - the target output

NetlistWriter

public NetlistWriter(java.io.OutputStream output,
                     boolean autoflush)
Opens a print writer that targets the given OutputStream.

Parameters:
output - the target output
autoflush - whether to autoflush

NetlistWriter

public NetlistWriter(java.io.Writer output)
Opens a print writer that targets the given Writer.

Parameters:
output - the target output

NetlistWriter

public NetlistWriter(java.io.Writer output,
                     boolean autoflush)
Opens a print writer that targets the given Writer.

Parameters:
output - the target output
autoflush - whether to autoflush
Method Detail

write

public void write(java.lang.String data)
Overrides the write() method (called by all the print() methods) to have system-independent line breaks on '\n'

Parameters:
data - the String to print to the file


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