com.sun.cdc.io
Class GeneralBase

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by java.io.DataOutputStream
              extended by com.sun.cdc.io.GeneralBase
All Implemented Interfaces:
DataInput, DataOutput
Direct Known Subclasses:
ConnectionBase

public abstract class GeneralBase
extends DataOutputStream
implements DataInput, DataOutput

Base class for objects that implement the DataInput and DataOutput interfaces. It also behaves like a DataOutputStream so it can be used for UniversalOutputStream


Field Summary
 
Fields inherited from class java.io.DataOutputStream
written
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
GeneralBase()
           
 
Method Summary
 void close()
          Close the stream.
 void flush()
          Flush the stream.
 int read()
          Reads the next byte of data from the input stream.
 boolean readBoolean()
          See the general contract of the readBoolean method of DataInput.
 byte readByte()
          See the general contract of the readByte method of DataInput.
 char readChar()
          See the general contract of the readChar method of DataInput.
 double readDouble()
          Unsupported function
 float readFloat()
          Unsupported function
 void readFully(byte[] b)
          See the general contract of the readFully method of DataInput.
 void readFully(byte[] b, int off, int len)
          See the general contract of the readFully method of DataInput.
 int readInt()
          See the general contract of the readInt method of DataInput.
 String readLine()
          Unsupported function
 long readLong()
          See the general contract of the readLong method of DataInput.
 short readShort()
          See the general contract of the readShort method of DataInput.
 int readUnsignedByte()
          See the general contract of the readUnsignedByte method of DataInput.
 int readUnsignedShort()
          See the general contract of the readUnsignedShort method of DataInput.
 String readUTF()
          See the general contract of the readUTF method of DataInput.
 long skip(long n)
          Skips over and discards n bytes of data from this input stream.
 int skipBytes(int n)
          See the general contract of the skipBytes method of DataInput.
 void write(byte[] b, int off, int len)
          Writes len bytes from the specified byte array starting at offset off to the underlying output stream.
 void write(int b)
          Writes the specified byte (the low eight bits of the argument b) to the underlying output stream.
 
Methods inherited from class java.io.DataOutputStream
size, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
 
Methods inherited from class java.io.FilterOutputStream
write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.io.DataOutput
write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF
 

Constructor Detail

GeneralBase

public GeneralBase()
Method Detail

write

public void write(int b)
           throws IOException
Writes the specified byte (the low eight bits of the argument b) to the underlying output stream. If no exception is thrown, the counter written is incremented by 1.

Implements the write method of OutputStream.

Specified by:
write in interface DataOutput
Overrides:
write in class DataOutputStream
Parameters:
b - the byte to be written.
Throws:
IOException - if an I/O error occurs.
See Also:
FilterOutputStream.out

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Writes len bytes from the specified byte array starting at offset off to the underlying output stream. If no exception is thrown, the counter written is incremented by len.

Specified by:
write in interface DataOutput
Overrides:
write in class DataOutputStream
Parameters:
b - the data.
off - the start offset in the data.
len - the number of bytes to write.
Throws:
IOException - if an I/O error occurs.
See Also:
FilterOutputStream.out

flush

public void flush()
           throws IOException
Flush the stream.

Overrides:
flush in class DataOutputStream
Throws:
IOException - if an I/O error occurs.
See Also:
FilterOutputStream.out, OutputStream.flush()

close

public void close()
           throws IOException
Close the stream.

Overrides:
close in class FilterOutputStream
Throws:
IOException - if an I/O error occurs.
See Also:
FilterOutputStream.flush(), FilterOutputStream.out

read

public int read()
         throws IOException
Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

A subclass must provide an implementation of this method.

Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws:
IOException - if an I/O error occurs.

skip

public long skip(long n)
          throws IOException
Skips over and discards n bytes of data from this input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. This may result from any of a number of conditions; reaching end of file before n bytes have been skipped is only one possibility. The actual number of bytes skipped is returned. If n is negative, no bytes are skipped.

The skip method of InputStream creates a byte array and then repeatedly reads into it until n bytes have been read or the end of the stream has been reached. Subclasses are encouraged to provide a more efficient implementation of this method.

Parameters:
n - the number of bytes to be skipped.
Returns:
the actual number of bytes skipped.
Throws:
IOException - if an I/O error occurs.

readFully

public void readFully(byte[] b)
               throws IOException
See the general contract of the readFully method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readFully in interface DataInput
Parameters:
b - the buffer into which the data is read.
Throws:
EOFException - if this input stream reaches the end before reading all the bytes.
IOException - if an I/O error occurs.

readFully

public void readFully(byte[] b,
                      int off,
                      int len)
               throws IOException
See the general contract of the readFully method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readFully in interface DataInput
Parameters:
b - the buffer into which the data is read.
off - the start offset of the data.
len - the number of bytes to read.
Throws:
EOFException - if this input stream reaches the end before reading all the bytes.
IOException - if an I/O error occurs.

skipBytes

public int skipBytes(int n)
              throws IOException
See the general contract of the skipBytes method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
skipBytes in interface DataInput
Parameters:
n - the number of bytes to be skipped.
Returns:
the actual number of bytes skipped.
Throws:
IOException - if an I/O error occurs.

readBoolean

public boolean readBoolean()
                    throws IOException
See the general contract of the readBoolean method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readBoolean in interface DataInput
Returns:
the boolean value read.
Throws:
EOFException - if this input stream has reached the end.
IOException - if an I/O error occurs.

readByte

public byte readByte()
              throws IOException
See the general contract of the readByte method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readByte in interface DataInput
Returns:
the next byte of this input stream as a signed 8-bit byte.
Throws:
EOFException - if this input stream has reached the end.
IOException - if an I/O error occurs.

readUnsignedByte

public int readUnsignedByte()
                     throws IOException
See the general contract of the readUnsignedByte method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readUnsignedByte in interface DataInput
Returns:
the next byte of this input stream, interpreted as an unsigned 8-bit number.
Throws:
EOFException - if this input stream has reached the end.
IOException - if an I/O error occurs.

readShort

public short readShort()
                throws IOException
See the general contract of the readShort method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readShort in interface DataInput
Returns:
the next two bytes of this input stream, interpreted as a signed 16-bit number.
Throws:
EOFException - if this input stream reaches the end before reading two bytes.
IOException - if an I/O error occurs.

readUnsignedShort

public int readUnsignedShort()
                      throws IOException
See the general contract of the readUnsignedShort method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readUnsignedShort in interface DataInput
Returns:
the next two bytes of this input stream, interpreted as an unsigned 16-bit integer.
Throws:
EOFException - if this input stream reaches the end before reading two bytes.
IOException - if an I/O error occurs.

readChar

public char readChar()
              throws IOException
See the general contract of the readChar method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readChar in interface DataInput
Returns:
the next two bytes of this input stream as a Unicode character.
Throws:
EOFException - if this input stream reaches the end before reading two bytes.
IOException - if an I/O error occurs.

readInt

public int readInt()
            throws IOException
See the general contract of the readInt method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readInt in interface DataInput
Returns:
the next four bytes of this input stream, interpreted as an int.
Throws:
EOFException - if this input stream reaches the end before reading four bytes.
IOException - if an I/O error occurs.

readLong

public long readLong()
              throws IOException
See the general contract of the readLong method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readLong in interface DataInput
Returns:
the next eight bytes of this input stream, interpreted as a long.
Throws:
EOFException - if this input stream reaches the end before reading eight bytes.
IOException - if an I/O error occurs.

readUTF

public String readUTF()
               throws IOException
See the general contract of the readUTF method of DataInput.

Bytes for this operation are read from the contained input stream.

Specified by:
readUTF in interface DataInput
Returns:
a Unicode string.
Throws:
EOFException - if this input stream reaches the end before reading all the bytes.
IOException - if an I/O error occurs.
See Also:
DataInputStream.readUTF(java.io.DataInput)

readFloat

public float readFloat()
                throws IOException
Unsupported function

Specified by:
readFloat in interface DataInput
Returns:
the float value read.
Throws:
EOFException - if this stream reaches the end before reading all the bytes.
IOException - if an I/O error occurs.

readDouble

public double readDouble()
                  throws IOException
Unsupported function

Specified by:
readDouble in interface DataInput
Returns:
the double value read.
Throws:
EOFException - if this stream reaches the end before reading all the bytes.
IOException - if an I/O error occurs.

readLine

public String readLine()
                throws IOException
Unsupported function

Specified by:
readLine in interface DataInput
Returns:
the next line of text from the input stream, or null if the end of file is encountered before a byte can be read.
Throws:
IOException - if an I/O error occurs.