org.jpop.net
Interface ClientInterface

All Superinterfaces:
java.lang.Runnable
All Known Implementing Classes:
PoplogDocClient

public interface ClientInterface
extends java.lang.Runnable

Interface to a client for the poplog doc server a new client should be created in a way such that the &tl;msg type>Received methods are called from whithin the run() or main parsing method of the object, and overriden to provide event handling to the calling classes.

Version:
1.0
Author:
dsm

Method Summary
 void clientConnected()
          Should be called when the client connects to the server
 void clientDisconnected()
          Should be called when the client disconnects from the server
 void close()
          Close connection with server
 void connect(java.lang.String servername, int port)
          Connect to the server
 void docReceived(java.io.BufferedReader doc)
          Should be called when the server sends a document.
 void errorReceived(java.io.BufferedReader err)
          Should be called when the server sends an error.
 void exceptionGenerated(java.lang.Exception e)
          Called when a non-fatal exception is generated
 void getDoc(java.lang.String type, java.lang.String name)
          send a doc request to sever
 void getHelp()
          send a help request to sever
 void getInfo()
          send an info request to sever
 void getLicense()
          send a license request to sever
 void getList(java.lang.String type)
          send a list request to sever
 void getVersion()
          send a version request to sever
 void helpReceived(java.io.BufferedReader hlp)
          Should be called when the server sends its help.
 boolean isConnected()
          Check if the client is connected
 void licenseReceived(java.io.BufferedReader lic)
          Should be called when the server sends a license.
 void listReceived(java.io.BufferedReader list)
          Should be called when the server sends a list.
 void messageReceived(java.io.BufferedReader msg)
          Should be called when the server sends a message.
 void parse(java.lang.String line)
          Parses a line of text into a statement that can be sent to the server
 void println(java.lang.String line)
          Prints a line to the server
 void run()
          Main processing method for the ClientInterface object
 void warningReceived(java.io.BufferedReader warn)
          Should be called when the server sends a warning.
 

Method Detail

println

public void println(java.lang.String line)
Prints a line to the server

Parameters:
line - The line to print

isConnected

public boolean isConnected()
Check if the client is connected

Returns:
true when connected, false otherwise

parse

public void parse(java.lang.String line)
           throws ClientException
Parses a line of text into a statement that can be sent to the server

Parameters:
line - The text to parse
Throws:
ClientException - When something goes wrong

connect

public void connect(java.lang.String servername,
                    int port)
             throws java.net.UnknownHostException,
                    java.io.IOException
Connect to the server

Parameters:
servername - Name of the server
port - The port the server listens to
Throws:
java.net.UnknownHostException - When the host can't be found
java.io.IOException - When IO to the host can't be got

close

public void close()
           throws java.io.IOException
Close connection with server

Throws:
java.io.IOException

listReceived

public void listReceived(java.io.BufferedReader list)
Should be called when the server sends a list. The BufferedReader is the actual list

Parameters:
list - The list received from the server as a BufferedReader.

clientConnected

public void clientConnected()
Should be called when the client connects to the server


clientDisconnected

public void clientDisconnected()
Should be called when the client disconnects from the server


docReceived

public void docReceived(java.io.BufferedReader doc)
Should be called when the server sends a document. The BufferedReader is the actual document

Parameters:
doc - The document received from the server as a BufferedReader.

messageReceived

public void messageReceived(java.io.BufferedReader msg)
Should be called when the server sends a message. The BufferedReader is the actual message

Parameters:
msg - The message received from the server as a BufferedReader.

warningReceived

public void warningReceived(java.io.BufferedReader warn)
Should be called when the server sends a warning. The BufferedReader is the actual warning

Parameters:
warn - The warning received from the server as a BufferedReader.

errorReceived

public void errorReceived(java.io.BufferedReader err)
Should be called when the server sends an error. The BufferedReader is the actual error

Parameters:
err - The error received from the server as a BufferedReader.

helpReceived

public void helpReceived(java.io.BufferedReader hlp)
Should be called when the server sends its help. The BufferedReader is the actual help

Parameters:
hlp - The help received from the server as a BufferedReader.

licenseReceived

public void licenseReceived(java.io.BufferedReader lic)
Should be called when the server sends a license. The BufferedReader is the actual license

Parameters:
lic - The license received from the server as a BufferedReader.

run

public void run()
Main processing method for the ClientInterface object

Specified by:
run in interface java.lang.Runnable

getDoc

public void getDoc(java.lang.String type,
                   java.lang.String name)
            throws ClientException
send a doc request to sever

Parameters:
type -
name -
Throws:
ClientException

getList

public void getList(java.lang.String type)
send a list request to sever

Parameters:
type -

getHelp

public void getHelp()
send a help request to sever


getInfo

public void getInfo()
send an info request to sever


getVersion

public void getVersion()
send a version request to sever


getLicense

public void getLicense()
send a license request to sever


exceptionGenerated

public void exceptionGenerated(java.lang.Exception e)
Called when a non-fatal exception is generated