com.ohrasys.cad.gds
Class GDSReader

java.lang.Object
  extended by java.io.Reader
      extended by java.io.InputStreamReader
          extended by com.ohrasys.cad.gds.GDSReader
All Implemented Interfaces:
java.io.Closeable, java.lang.Readable

public class GDSReader
extends java.io.InputStreamReader

A basic GDS file reader

Since:
1.5

Field Summary
 
Fields inherited from class java.io.Reader
lock
 
Constructor Summary
GDSReader(java.io.File file)
          Creates a new GDSReader object.
GDSReader(java.io.File file, boolean validating)
          Creates a new GDSReader object.
GDSReader(java.io.FileDescriptor fd)
          Creates a new GDSReader object.
GDSReader(java.io.FileDescriptor fd, boolean validating)
          Creates a new GDSReader object.
GDSReader(GDSInputStream in, boolean validating)
          Creates a new GDSReader object.
GDSReader(java.lang.String fileName)
          Creates a new GDSReader object.
GDSReader(java.lang.String fileName, boolean validating)
          Creates a new GDSReader object.
 
Method Summary
 int getRead()
          A method to determine the number of bytes read from the file.
 int getRemaining()
          A method to determine the number of bytes remaining to be read
 int getSize()
          A method to determine the size of the GDS file.
 void mark(int readAheadLimit)
          Marks the current position in the file.
 boolean markSupported()
          Determines if marks are supported by this reader.
 int read()
          Reads the next value from the stream.
 int read(char[] cbuf)
          A blocking read into a character buffer.
 int read(char[] buf, int offset, int length)
          Reads a string of characters into a buffer.
 java.lang.Object readRecord()
          Reads a single GDSRecord from the filestream.
 void reset()
          Resets the stream and mark pointer.
 long skip(long num)
          Skips a finite number of bytes in the stream
 java.lang.String toString()
          Returns a string representation of this class
 
Methods inherited from class java.io.InputStreamReader
close, getEncoding, ready
 
Methods inherited from class java.io.Reader
read
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GDSReader

public GDSReader(java.io.File file)
          throws java.io.FileNotFoundException
Creates a new GDSReader object.

Parameters:
file - The file to read from.
Throws:
java.io.FileNotFoundException - If the file doesn't exist or is not readable.

GDSReader

public GDSReader(java.io.FileDescriptor fd)
          throws java.io.FileNotFoundException
Creates a new GDSReader object.

Parameters:
fd - The file descriptor to read from.
Throws:
java.io.FileNotFoundException - If the file doesn't exist or is not readable.

GDSReader

public GDSReader(java.lang.String fileName)
          throws java.io.FileNotFoundException
Creates a new GDSReader object.

Parameters:
fileName - The file to read from.
Throws:
java.io.FileNotFoundException - If the file doesn't exist or is not readable.

GDSReader

public GDSReader(GDSInputStream in,
                 boolean validating)
          throws java.io.FileNotFoundException
Creates a new GDSReader object.

Parameters:
in - The input stream to read from
validating - Set to true if on the fly validating is to be performed.
Throws:
java.io.FileNotFoundException - If the input file doesn't exist or is not readable.

GDSReader

public GDSReader(java.io.FileDescriptor fd,
                 boolean validating)
          throws java.io.FileNotFoundException
Creates a new GDSReader object.

Parameters:
fd - The file descriptor to read from
validating - Set to true if on the fly validating is to be performed.
Throws:
java.io.FileNotFoundException - If the file doesn't exist or is not readable.

GDSReader

public GDSReader(java.lang.String fileName,
                 boolean validating)
          throws java.io.FileNotFoundException
Creates a new GDSReader object.

Parameters:
fileName - The file to read from.
validating - Set to true if on the fly validating is to be performed.
Throws:
java.io.FileNotFoundException - If the file doesn't exist or is not readable.

GDSReader

public GDSReader(java.io.File file,
                 boolean validating)
          throws java.io.FileNotFoundException
Creates a new GDSReader object.

Parameters:
file - The file to read from.
validating - Set to true if on the fly validating is to be performed.
Throws:
java.io.FileNotFoundException - If the file doesn't exist or is not readable.
Method Detail

getRead

public int getRead()
            throws GDSReaderException
A method to determine the number of bytes read from the file.

Returns:
The number of bytes read.
Throws:
GDSReaderException - If an error in processing occurs.

getRemaining

public int getRemaining()
                 throws GDSReaderException
A method to determine the number of bytes remaining to be read

Returns:
The number of bytes remaining to be read.
Throws:
GDSReaderException - If an error in processing occurs.

getSize

public int getSize()
            throws GDSReaderException
A method to determine the size of the GDS file.

Returns:
The size of the file in bytes.
Throws:
GDSReaderException - If an error in processing occurs.

mark

public void mark(int readAheadLimit)
          throws java.io.IOException
Marks the current position in the file. This is an unsupported method of the Reader interface.

Overrides:
mark in class java.io.Reader
Parameters:
readAheadLimit - The maximum read ahead limit.
Throws:
java.io.IOException - Always thrown. This method is not supported.

markSupported

public boolean markSupported()
Determines if marks are supported by this reader. This method always returns false since the GDSReader doesn't support marks.

Overrides:
markSupported in class java.io.Reader
Returns:
false.

read

public int read()
         throws java.io.IOException
Reads the next value from the stream.

Overrides:
read in class java.io.InputStreamReader
Returns:
The value read.
Throws:
java.io.IOException - If an IO exception occurs.

read

public int read(char[] cbuf)
         throws java.io.IOException
A blocking read into a character buffer.

Overrides:
read in class java.io.Reader
Parameters:
cbuf - The buffer to read into to
Returns:
The number of characters read or -1 if the end of the file is reached.
Throws:
java.io.IOException - If an IO exception occurs.

read

public int read(char[] buf,
                int offset,
                int length)
         throws java.io.IOException
Reads a string of characters into a buffer.

Overrides:
read in class java.io.InputStreamReader
Parameters:
buf - The destination for the read.
offset - The starting offset from the beginning of the destination buffer.
length - The number of characters to read.
Returns:
The number of characters read or -1 if the end of file is reached.
Throws:
java.io.IOException - If an IO exception occurs.

readRecord

public java.lang.Object readRecord()
                            throws GDSReaderException
Reads a single GDSRecord from the filestream.

Returns:
The next available GDSII record.
Throws:
GDSReaderException - If an error in processing occurs.

reset

public void reset()
           throws java.io.IOException
Resets the stream and mark pointer. This is an unsupported method of the reader interface.

Overrides:
reset in class java.io.Reader
Throws:
java.io.IOException - Always thrown as reset is not supported by GDSReader.

skip

public long skip(long num)
          throws java.io.IOException
Skips a finite number of bytes in the stream

Overrides:
skip in class java.io.Reader
Parameters:
num - The number of bytes to skip
Returns:
The actual number of bytes skipped
Throws:
java.io.IOException - If an IO exception occurs

toString

public java.lang.String toString()
Returns a string representation of this class

Overrides:
toString in class java.lang.Object
Returns:
The physical address of this instance