moka.io
Class IOStream

java.lang.Object
  extended bymoka.lang.Object
      extended bymoka.io.IOStream
Direct Known Subclasses:
File, Socket

public abstract class IOStream
extends Object

This class represents an Input/Output data stream.

Since:
MDK1.0a

Field Summary
 boolean error
          Is the stream in error ? Should be only read.
 boolean opened
          Is the stream opened ? Should be only read.
 
Constructor Summary
IOStream()
          Creates an IOStream.
 
Method Summary
abstract  void close()
          Closes the stream.
 void finalize()
          Frees the memory of system ressources used by this IOStream object.
abstract  void open()
          Opens the stream.
 boolean readBoolean()
          Reads a boolean.
abstract  char readByte()
          Reads an 8 bit byte.
abstract  void readBytes(moka.io.char_p buffer, short len)
          Copies to a buffer of bytes up to the specified length bytes read from the stream.
 char readChar()
          Reads a char.
 moka.io.char_p readChars(short len)
          Reads an ANSI string.
 double readDouble()
          Reads a double.
 int readInt()
          Reads an int.
 long readLong()
          Reads a long.
 Object readObject()
          Reads a Object.
 short readShort()
          Reads a short.
 java.lang.String readString()
          Reads a String object.
 void writeBoolean(boolean val)
          Writes a boolean.
abstract  void writeByte(char val)
          Writes an 8 bit byte.
abstract  void writeBytes(moka.io.char_p buffer, short len)
          Writes a buffer of bytes up to the specified length.
 void writeChar(char val)
          Writes a char.
 void writeChars(moka.io.char_p val)
          Writes an ANSI string.
 void writeDouble(double val)
          Writes a double.
 void writeInt(int val)
          Writes an int.
 void writeLong(long val)
          Writes a long.
 void writeObject(Object val)
          Writes an Object.
 void writeShort(short val)
          Writes an short.
 void writeString(java.lang.String val)
          Writes a String object.
 
Methods inherited from class moka.lang.Object
equals, getClassName, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

opened

public boolean opened
Is the stream opened ? Should be only read.


error

public boolean error
Is the stream in error ? Should be only read.

Constructor Detail

IOStream

public IOStream()
Creates an IOStream.

Method Detail

open

public abstract void open()
Opens the stream. Since this method is an abstract one, subclasses of IOStream must overwrite this method.


close

public abstract void close()
Closes the stream. Since this method is an abstract one, subclasses of IOStream must overwrite this method.


writeByte

public abstract void writeByte(char val)
Writes an 8 bit byte. Since this method is an abstract one, subclasses of IOStream must overwrite this method.

Parameters:
val - the byte value to be written

writeBytes

public abstract void writeBytes(moka.io.char_p buffer,
                                short len)
Writes a buffer of bytes up to the specified length. Since this method is an abstract one, subclasses of IOStream must overwrite this method.

Parameters:
buffer - the buffer of bytes to be written
len - the specified length

readByte

public abstract char readByte()
Reads an 8 bit byte. Since this method is an abstract one, subclasses of IOStream must overwrite this method.

Returns:
the byte value read

readBytes

public abstract void readBytes(moka.io.char_p buffer,
                               short len)
Copies to a buffer of bytes up to the specified length bytes read from the stream. Since this method is an abstract one, subclasses of IOStream must overwrite this method.

Parameters:
buffer - the buffer of bytes where the bytes will be copied
len - the specified length

finalize

public void finalize()
Frees the memory of system ressources used by this IOStream object. If the stream is opened, it will be closed first.

Overrides:
finalize in class Object

writeBoolean

public void writeBoolean(boolean val)
Writes a boolean.

Parameters:
val - the boolean value to be written

writeChar

public void writeChar(char val)
Writes a char.

Parameters:
val - the char value to be written

writeDouble

public void writeDouble(double val)
Writes a double.

Parameters:
val - the double value to be written

writeShort

public void writeShort(short val)
Writes an short.

Parameters:
val - the short value to be written

writeInt

public void writeInt(int val)
Writes an int.

Parameters:
val - the int value to be written

writeLong

public void writeLong(long val)
Writes a long.

Parameters:
val - the long value to be written

writeString

public void writeString(java.lang.String val)
Writes a String object. The specified string is finalized before the method returns.

Parameters:
val - the String object to be written

writeChars

public void writeChars(moka.io.char_p val)
Writes an ANSI string.

Parameters:
val - the ANSI string to be written

writeObject

public void writeObject(Object val)
Writes an Object. This object must be a subclass of serializable.

Parameters:
val - the Object to be written

readBoolean

public boolean readBoolean()
Reads a boolean.

Returns:
the boolean value read

readChar

public char readChar()
Reads a char.

Returns:
the char value read

readDouble

public double readDouble()
Reads a double.

Returns:
the double value read

readShort

public short readShort()
Reads a short.

Returns:
the short value read

readInt

public int readInt()
Reads an int.

Returns:
val the int value read

readLong

public long readLong()
Reads a long.

Returns:
the long value read

readString

public java.lang.String readString()
Reads a String object.

Returns:
the String object read

readChars

public moka.io.char_p readChars(short len)
Reads an ANSI string.

Parameters:
len - the length of the ANSI string
Returns:
the ANSI string read

readObject

public Object readObject()
Reads a Object.

Returns:
the Object read