org.hebe.mps
Class InputStream

java.lang.Object
  |
  +--org.hebe.mps.InputStream

public class InputStream
extends java.lang.Object

Structures the bitstream coming from an MPS server into usable MPS primitive types (mapped onto Java types, of course). Uses a Connection object to talk to the other end.

Author:
Tony Garnock-Jones
See Also:
Connection, OutputStream

Field Summary
private  Connection connection
           
private  java.io.InputStream input
           
 
Constructor Summary
InputStream(Connection c)
          Construct an InputStream which decodes the bits coming from a Connection object.
InputStream(java.io.InputStream i)
          Construct an InputStream which decodes bits from an arbitrary inputstream.
 
Method Summary
private  void open()
          Causes the connection to the server to open, if it isn't already open.
private  int read()
          Reads a single byte from the server.
 boolean readbool()
          Reads a single boolean from the server.
 char readchar()
          Reads a single char from the server.
 float readfloat()
          Reads a single float from the server.
 int readint()
          Reads a single int from the server.
 long readlong()
          Reads a single 64-bit long from the server.
 java.lang.String readReference()
          Reads the canonical (bound) name of an MPS object from the remote end of the link.
 java.lang.String readstring()
          Reads a single java.lang.String from the server.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

connection

private Connection connection

input

private java.io.InputStream input
Constructor Detail

InputStream

public InputStream(Connection c)
Construct an InputStream which decodes the bits coming from a Connection object.
Parameters:
c - the raw connection to filter

InputStream

public InputStream(java.io.InputStream i)
Construct an InputStream which decodes bits from an arbitrary inputstream.
Parameters:
i - the raw inputstream to filter
Method Detail

read

private int read()
          throws java.io.IOException,
                 MPSException
Reads a single byte from the server.
Returns:
the byte read
Throws:
java.io.IOException - if there's an error reading our input
MPSConnectionClosedException - if the connection closes unexpectedly

open

private void open()
           throws MPSException
Causes the connection to the server to open, if it isn't already open.
Throws:
MPSException - from connection.getInputStream() if there's a problem
See Also:
Connection.getInputStream()

readint

public int readint()
            throws MPSException
Reads a single int from the server.
Returns:
the 32-bit signed value read from our input
Throws:
MPSException - if there's a problem reading

readstring

public java.lang.String readstring()
                            throws MPSException
Reads a single java.lang.String from the server.
Returns:
the string read
Throws:
MPSException - if there's a problem reading
See Also:
String

readbool

public boolean readbool()
                 throws MPSException
Reads a single boolean from the server.
Returns:
the boolean read
Throws:
MPSException - if there's a problem reading

readlong

public long readlong()
              throws MPSException
Reads a single 64-bit long from the server.
Returns:
the long read
Throws:
MPSException - if there's a problem reading

readchar

public char readchar()
              throws MPSException
Reads a single char from the server.
Returns:
the char read
Throws:
MPSException - if there's a problem reading

readReference

public java.lang.String readReference()
                               throws MPSException
Reads the canonical (bound) name of an MPS object from the remote end of the link.
Returns:
the canonical name of the object read from the server
Throws:
MPSException - if there's a problem reading
See Also:
OutputStream.writeReference(java.lang.Object)

readfloat

public float readfloat()
                throws MPSException
Reads a single float from the server.
Returns:
the float read
Throws:
MPSException - if there's a problem reading