"

2013 FRC Java API

"

com.sun.squawk.util
Class StructuredFileInputStream

java.lang.Object
  extended by com.sun.squawk.util.StructuredFileInputStream

public abstract class StructuredFileInputStream
extends Object

An instance of StructuredInputStream is used to read a file that must conform to some given format such as a class file or a suite file.


Constructor Summary
StructuredFileInputStream(InputStream in, String filePath, String traceFeature)
          Creates a StructuredFileInputStream that reads class components from a given input stream.
 
Method Summary
 void close()
          Closes this reader and releases any system resources associated with the underlying input stream.
abstract  Error formatError(String msg)
          Throw a LinkageError to indicate there was an IO error or the file did not conform to the structure expected by the client of this class.
 int getBytesRead()
          Gets the number of bytes that have been read so far.
 String getFileName()
          Gets the name of the file from which this reader is reading.
 int readByte(String prefix)
          Reads a signed byte from the file.
 double readDouble(String prefix)
          Reads a double value from the file.
 void readEOF()
          Ensures that the input stream is at the end of the file.
 float readFloat(String prefix)
          Reads a float value from the file.
 void readFully(byte[] b, String prefix)
          Reads some bytes from the class file and stores them into the buffer array b.
 int readInt(String prefix)
          Reads an integer from the class file.
 long readLong(String prefix)
          Reads a long value from the file.
 int readShort(String prefix)
          Reads a signed short from the file.
 int readUnsignedByte(String prefix)
          Reads an unsigned byte from the file.
 int readUnsignedShort(String prefix)
          Reads an unsigned short from the class file.
 String readUTF(String prefix)
          Reads a UTF-8 encoded string from the file.
 void skip(int n, String prefix)
          Skips over and discards n bytes of data from the file.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StructuredFileInputStream

public StructuredFileInputStream(InputStream in,
                                 String filePath,
                                 String traceFeature)
Creates a StructuredFileInputStream that reads class components from a given input stream.

Parameters:
in - the input stream
filePath - the file from which in was created
traceFeature - the tracing feature that must be enabled if tracing is to be enabled
Method Detail

getFileName

public final String getFileName()
Gets the name of the file from which this reader is reading.

Returns:
the name of the file from which this reader is reading

formatError

public abstract Error formatError(String msg)
Throw a LinkageError to indicate there was an IO error or the file did not conform to the structure expected by the client of this class.

Parameters:
msg - the cause of the error
Returns:
the LinkageError raised

getBytesRead

public final int getBytesRead()
Gets the number of bytes that have been read so far. This only accounts for whole units that have been successfully read. For example, if a call to readInt(java.lang.String) failed with an IOException, any bytes read during the call will not be included in the total.

Returns:
int

readFully

public final void readFully(byte[] b,
                            String prefix)
Reads some bytes from the class file and stores them into the buffer array b. The number of bytes read is equal to the length of b.

Parameters:
b - the buffer to fill
prefix - the optional prefix used when tracing this read

readInt

public final int readInt(String prefix)
Reads an integer from the class file.

Parameters:
prefix - the optional prefix used when tracing this read
Returns:
the value read
See Also:
DataInputStream.readInt()

readUnsignedShort

public final int readUnsignedShort(String prefix)
Reads an unsigned short from the class file.

Parameters:
prefix - the optional prefix used when tracing this read
Returns:
the value read
See Also:
DataInputStream.readUnsignedShort()

readUnsignedByte

public final int readUnsignedByte(String prefix)
Reads an unsigned byte from the file.

Parameters:
prefix - the optional prefix used when tracing this read
Returns:
the value read
See Also:
DataInputStream.readUnsignedByte()

readShort

public final int readShort(String prefix)
Reads a signed short from the file.

Parameters:
prefix - the optional prefix used when tracing this read
Returns:
the value read
See Also:
DataInputStream.readShort()

readByte

public final int readByte(String prefix)
Reads a signed byte from the file.

Parameters:
prefix - the optional prefix used when tracing this read
Returns:
the value read
See Also:
DataInputStream.readByte()

readLong

public final long readLong(String prefix)
Reads a long value from the file.

Parameters:
prefix - the optional prefix used when tracing this read
Returns:
the value read
See Also:
DataInputStream.readLong()

readFloat

public final float readFloat(String prefix)
Reads a float value from the file.

Parameters:
prefix - the optional prefix used when tracing this read
Returns:
the value read
See Also:
DataInputStream.readFloat()

readDouble

public final double readDouble(String prefix)
Reads a double value from the file.

Parameters:
prefix - the optional prefix used when tracing this read
Returns:
the value read
See Also:
DataInputStream.readDouble()

readUTF

public final String readUTF(String prefix)
Reads a UTF-8 encoded string from the file.

Parameters:
prefix - the optional prefix used when tracing this read
Returns:
the value read
See Also:
DataInputStream.readUTF()

skip

public final void skip(int n,
                       String prefix)
Skips over and discards n bytes of data from the file.

Parameters:
n - the number of bytes to be skipped.
prefix - the optional prefix used when tracing this read

readEOF

public void readEOF()
Ensures that the input stream is at the end of the file.

Throws:
a - LinkageError if the input stream is not at the end of the file

close

public final void close()
Closes this reader and releases any system resources associated with the underlying input stream.


"

2013 FRC Java API

"

"
For updated information see the Java FRC site
"