edu.byu.ece.edif.core
Class EdifPrintWriter

java.lang.Object
  extended by java.io.Writer
      extended by java.io.PrintWriter
          extended by edu.byu.ece.edif.core.EdifPrintWriter
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.lang.Appendable

public class EdifPrintWriter
extends java.io.PrintWriter

Used for generating valid Edif text output. This class extends PrintWriter but also contains a number of convenience methods for properly formatting Edif output.

This class keeps track of the indentation during formatted printing. An integer value (_indenture) keeps track of the indentation level and the _indentString is used as the String printed for each level of indentation.

To Do:

Version:
$Id:EdifPrintWriter.java 198 2008-04-16 21:14:21Z jamesfcarroll $

Field Summary
private static java.lang.String _endOfLineChar
          Contains the endOfLineChar.
private static java.lang.String _indentString
          Contains the indent String.
private  int _indenture
          Contains the amount of indenture.
 
Fields inherited from class java.io.PrintWriter
out
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
EdifPrintWriter(java.io.OutputStream out)
          Construct an EdifPrintWriter Object using the passed-in OutputStream as its output.
EdifPrintWriter(java.lang.String outputFilename)
          Construct an EdifPrintWriter Object that will write to the passed in String filename.
 
Method Summary
 void decrIndent()
          Decrement the amount of indenture.
 void incrIndent()
          Increment the amount of indenture.
static void printEdifEnvironment(java.lang.String filename, EdifCell cell)
          This method will create a new Edif file for a given EdifCell object, and print it to the passed-in filename.
 void printIndent(java.lang.String str)
          Print the passed-in String object with the right amount of preceding indentation.
 void println()
          Print the end of line character to the PrintWriter.
 void println(java.lang.String str)
          Print out the passed-in string followed by the end of line character.
 void printlnIndent(java.lang.String str)
          Print the passed-in String object with the right amount of preceding indentation, followed by the newline character.
 void printQuote(java.lang.String str)
          Print quotes around the passed in String object.
 
Methods inherited from class java.io.PrintWriter
append, append, append, checkError, close, flush, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, setError, write, write, write, write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_endOfLineChar

private static final java.lang.String _endOfLineChar
Contains the endOfLineChar.

See Also:
Constant Field Values

_indentString

private static final java.lang.String _indentString
Contains the indent String.

See Also:
Constant Field Values

_indenture

private int _indenture
Contains the amount of indenture.

Constructor Detail

EdifPrintWriter

public EdifPrintWriter(java.io.OutputStream out)
Construct an EdifPrintWriter Object using the passed-in OutputStream as its output.

Parameters:
out - The OutputStream Object that this EdifPrintWriter Object will write to

EdifPrintWriter

public EdifPrintWriter(java.lang.String outputFilename)
                throws java.io.IOException
Construct an EdifPrintWriter Object that will write to the passed in String filename.

Parameters:
outputFilename - The file that this EdifPrintWriter Object will write to
Throws:
java.io.IOException
Method Detail

decrIndent

public void decrIndent()
Decrement the amount of indenture.


incrIndent

public void incrIndent()
Increment the amount of indenture.


printEdifEnvironment

public static void printEdifEnvironment(java.lang.String filename,
                                        EdifCell cell)
                                 throws java.io.IOException
This method will create a new Edif file for a given EdifCell object, and print it to the passed-in filename.

Parameters:
filename - The name of the file to generate
cell - The EdifCell object that is to be put into the top-level of the generated Edif file.
subFile - The EdifEnvironment object that owns the cell.
Throws:
java.io.IOException

printIndent

public void printIndent(java.lang.String str)
Print the passed-in String object with the right amount of preceding indentation.

Parameters:
str - The String object that will be printed preceded by indentation

println

public void println()
Print the end of line character to the PrintWriter.

Overrides:
println in class java.io.PrintWriter

println

public void println(java.lang.String str)
Print out the passed-in string followed by the end of line character.

Overrides:
println in class java.io.PrintWriter
Parameters:
str - The String that will be written to the PrintWriter followed by the end of line character

printlnIndent

public void printlnIndent(java.lang.String str)
Print the passed-in String object with the right amount of preceding indentation, followed by the newline character.

Parameters:
str - The String object that will be printed preceded by indentation, and followed by the end of line character

printQuote

public void printQuote(java.lang.String str)
Print quotes around the passed in String object.

Parameters:
str - The String object that will have quotes printed around it