org.altlinux.jabbix
Class JabbixReader

java.lang.Object
  extended by org.altlinux.jabbix.JabbixReader

public class JabbixReader
extends Object

A stream reader implementing the base Jabbix protocol.

Author:
Paul Wolneykien

Constructor Summary
JabbixReader(InputStream in)
          Creates a reader for the given input stream.
 
Method Summary
 String readAll()
          Reads the whole available data to the end of the stream.
 String readMessage()
          Reads a message from the input stream.
 String readMessage(boolean untilEOF)
          Reads a message from the input stream.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JabbixReader

public JabbixReader(InputStream in)
Creates a reader for the given input stream.

Parameters:
in - the stream to read from
Method Detail

readMessage

public String readMessage(boolean untilEOF)
                   throws IOException,
                          JabbixProtocolException
Reads a message from the input stream. If the Zabbix protocol is used in the request being read, then the message length is determined from the header. Otherwise, the assumption is made that the end of message is indicated by a separator character (see JabbixProtocol.isSeparator(char)). If the untilEOF flag is passed, then the whole data to the end of the stream is read and returned as one message.

Parameters:
untilEOF - the flag telling to read to whole available data
Returns:
a message
Throws:
IOException - if an I/O exception occurred during the read operation
JabbixProtocolException - if the protocol was violated (i.e. an unexpected value was received)
See Also:
JabbixProtocol.HEADER

readMessage

public String readMessage()
                   throws IOException,
                          JabbixProtocolException
Reads a message from the input stream. The length of message is either explicitly set in the request header or determined by a separator character (see JabbixProtocol.isSeparator(char)).

Returns:
a message
Throws:
IOException - if an I/O exception occurred during the read operation
JabbixProtocolException - if the protocol was violated (i.e. an unexpected value was received)
See Also:
readMessage(boolean)

readAll

public String readAll()
               throws IOException,
                      JabbixProtocolException
Reads the whole available data to the end of the stream.

Returns:
a message containing the all read data
Throws:
IOException - if an I/O exception occurred during the read operation
JabbixProtocolException - if the protocol was violated (i.e. an unexpected value was received)
See Also:
readMessage(boolean)