Class OutputFile


  • public class OutputFile
    extends java.lang.Object
    This class handles the creation and maintenance of the boiler-plate classes, such as Token.java, JavaCharStream.java etc. It is responsible for:
    • Writing the JavaCC header lines to the file.
    • Writing the checksum line.
    • Using the checksum to determine if an existing file has been changed by the user (and so should be left alone).
    • Checking any existing file's version (if the file can not be overwritten).
    • Checking any existing file's creation options (if the file can not be overwritten).
    Author:
    Paul Cager
    • Field Summary

      Fields 
      Modifier and Type Field Description
      boolean needToWrite  
    • Constructor Summary

      Constructors 
      Constructor Description
      OutputFile​(java.io.File file)  
      OutputFile​(java.io.File file, java.lang.String compatibleVersion, java.lang.String[] options)
      Create a new OutputFile.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Close the OutputFile, writing any necessary trailer information (such as a checksum).
      java.lang.String getPath()  
      java.io.PrintWriter getPrintWriter()
      Return a PrintWriter object that may be used to write to this file.
      java.lang.String getToolName()  
      void setToolName​(java.lang.String toolName)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • needToWrite

        public boolean needToWrite
    • Constructor Detail

      • OutputFile

        public OutputFile​(java.io.File file,
                          java.lang.String compatibleVersion,
                          java.lang.String[] options)
                   throws java.io.IOException
        Create a new OutputFile.
        Parameters:
        file - the file to write to.
        compatibleVersion - the minimum compatible JavaCC version.
        options - if the file already exists, and cannot be overwritten, this is a list of options (such s STATIC=false) to check for changes.
        Throws:
        java.io.IOException
      • OutputFile

        public OutputFile​(java.io.File file)
                   throws java.io.IOException
        Throws:
        java.io.IOException
    • Method Detail

      • getPrintWriter

        public java.io.PrintWriter getPrintWriter()
                                           throws java.io.IOException
        Return a PrintWriter object that may be used to write to this file. Any necessary header information is written by this method.
        Returns:
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Close the OutputFile, writing any necessary trailer information (such as a checksum).
        Throws:
        java.io.IOException
      • getToolName

        public java.lang.String getToolName()
        Returns:
        the toolName
      • setToolName

        public void setToolName​(java.lang.String toolName)
        Parameters:
        toolName - the toolName to set
      • getPath

        public java.lang.String getPath()