com.sun.electric.tool.io.input
Class Input

java.lang.Object
  extended by com.sun.electric.tool.io.input.Input
Direct Known Subclasses:
CIF, DXF, EDIF, GDS, LEFDEF, LibraryFiles, Simulate, Sue, VerilogReader

public class Input
extends java.lang.Object

This class manages reading files in different formats. The class is subclassed by the different file readers.


Field Summary
protected  long byteCount
          the number of bytes of data read so far
protected  java.io.DataInputStream dataInputStream
          The input stream.
static ErrorLogger errorLogger
          Log errors.
protected  long fileLength
          The length of the file.
protected  java.lang.String filePath
          Name of the file being input.
protected  java.io.InputStream inputStream
          The raw input stream.
protected  java.io.LineNumberReader lineReader
          The line number reader (text only).
protected static int READ_BUFFER_SIZE
           
 
Constructor Summary
Input()
           
 
Method Summary
static boolean changesQuiet(boolean quiet)
          Method to set the subsequent changes to be "quiet".
protected  void closeInput()
           
protected  boolean eofDuring(java.lang.String when)
          Method to display an error message because end-of-file was reached.
protected  java.lang.String getAKeyword()
           
protected  java.lang.String getLine()
          Method to read the next line of text from a file.
protected  java.lang.String getLineFromBinary()
          Method to read a line of text, when the file has been opened in binary mode.
protected static java.lang.String getProgressNote()
           
protected  java.lang.String getRestOfLine()
          Method to allow getAKeyword() to read next line next time is invocated.
protected  Library importALibrary(Library lib)
          Method to import a library from disk.
static Library importLibrary(java.net.URL fileURL, FileType type)
          Method to import a Library from disk.
static Library importToCurrentLibrary(java.net.URL fileURL, FileType type)
           
protected  void initKeywordParsing()
           
protected  boolean isBreakCharacter(char chr)
          Helper method for keyword processing which decides whether a character is its own keyword.
static boolean isChangeQuiet()
          Method to tell whether changes are being made quietly.
static boolean isNewLibraryCreated()
          Method to tell if a new library was created for this import operation.
protected  boolean openBinaryInput(java.net.URL fileURL)
           
protected  boolean openStringsInput(java.lang.String[] lines)
           
protected  boolean openTextInput(java.net.URL fileURL)
           
protected  java.lang.String preprocessLine(java.lang.String line)
          Helper method for keyword processing which removes comments.
protected  java.lang.String readWholeLine()
           
protected static void setProgressNote(java.lang.String msg)
           
protected static void setProgressValue(int value)
           
protected static void startProgressDialog(java.lang.String type, java.lang.String filePath)
           
protected static void stopProgressDialog()
           
protected  void updateProgressDialog(int bytesRead)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

READ_BUFFER_SIZE

protected static final int READ_BUFFER_SIZE
See Also:
Constant Field Values

errorLogger

public static ErrorLogger errorLogger
Log errors. Static because shared between many readers


filePath

protected java.lang.String filePath
Name of the file being input.


inputStream

protected java.io.InputStream inputStream
The raw input stream.


lineReader

protected java.io.LineNumberReader lineReader
The line number reader (text only).


dataInputStream

protected java.io.DataInputStream dataInputStream
The input stream.


fileLength

protected long fileLength
The length of the file.


byteCount

protected long byteCount
the number of bytes of data read so far

Constructor Detail

Input

public Input()
Method Detail

isNewLibraryCreated

public static boolean isNewLibraryCreated()
Method to tell if a new library was created for this import operation.

Returns:
true if a new library was created.

importLibrary

public static Library importLibrary(java.net.URL fileURL,
                                    FileType type)
Method to import a Library from disk. This method is for reading external file formats such as CIF, GDS, etc.

Parameters:
fileURL - the URL to the disk file.
type - the type of library file (CIF, GDS, etc.)
Returns:
the read Library, or null if an error occurred.

importToCurrentLibrary

public static Library importToCurrentLibrary(java.net.URL fileURL,
                                             FileType type)

importALibrary

protected Library importALibrary(Library lib)
Method to import a library from disk. This method must be overridden by the various import modules.

Parameters:
lib - the library to fill
Returns:
the created library (null on error).

openBinaryInput

protected boolean openBinaryInput(java.net.URL fileURL)

openStringsInput

protected boolean openStringsInput(java.lang.String[] lines)

openTextInput

protected boolean openTextInput(java.net.URL fileURL)

setProgressNote

protected static void setProgressNote(java.lang.String msg)

getProgressNote

protected static java.lang.String getProgressNote()

startProgressDialog

protected static void startProgressDialog(java.lang.String type,
                                          java.lang.String filePath)

stopProgressDialog

protected static void stopProgressDialog()

setProgressValue

protected static void setProgressValue(int value)

updateProgressDialog

protected void updateProgressDialog(int bytesRead)

closeInput

protected void closeInput()

getLine

protected java.lang.String getLine()
                            throws java.io.IOException
Method to read the next line of text from a file.

Returns:
the line (null on EOF).
Throws:
java.io.IOException

getLineFromBinary

protected java.lang.String getLineFromBinary()
                                      throws java.io.IOException
Method to read a line of text, when the file has been opened in binary mode.

Returns:
the line (null on EOF).
Throws:
java.io.IOException

initKeywordParsing

protected void initKeywordParsing()

getRestOfLine

protected java.lang.String getRestOfLine()
                                  throws java.io.IOException
Method to allow getAKeyword() to read next line next time is invocated.

Throws:
java.io.IOException

readWholeLine

protected java.lang.String readWholeLine()
                                  throws java.io.IOException
Throws:
java.io.IOException

getAKeyword

protected java.lang.String getAKeyword()
                                throws java.io.IOException
Throws:
java.io.IOException

isBreakCharacter

protected boolean isBreakCharacter(char chr)
Helper method for keyword processing which decides whether a character is its own keyword.

Parameters:
chr - the character in question.
Returns:
true if this character should be its own keyword.

preprocessLine

protected java.lang.String preprocessLine(java.lang.String line)
Helper method for keyword processing which removes comments.

Parameters:
line - a line of text just read.
Returns:
the line after comments have been removed.

isChangeQuiet

public static boolean isChangeQuiet()
Method to tell whether changes are being made quietly. Quiet changes are not passed to constraint satisfaction.

Returns:
true if changes are being made quietly.

changesQuiet

public static boolean changesQuiet(boolean quiet)
Method to set the subsequent changes to be "quiet". Quiet changes are not passed to constraint satisfaction.

Returns:
the previous value of the "quiet" state.

eofDuring

protected boolean eofDuring(java.lang.String when)
Method to display an error message because end-of-file was reached.

Parameters:
when - the statement being read when EOF was reached.
Returns:
false (and prints an error message).