|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jpop.net.PoplogDocClient
Creates a Doc Client that sends requests to the server and gets responses from it in the form of messages
Field Summary | |
static java.lang.String |
ERROR_MESG
Prepended to the response string to indicate the nature of the message. |
static java.lang.String |
SERVER_MESG
Prepended to the response string to indicate the nature of the message. |
static java.lang.String |
TEXT_MESG
Prepended to the response string to indicate the nature of the message. |
static java.lang.String |
WARNING_MESG
Prepended to the response string to indicate the nature of the message. |
Constructor Summary | |
PoplogDocClient()
Default constructor. |
|
PoplogDocClient(java.lang.String serverName,
int port)
Better constructor. |
Method Summary | |
abstract void |
clientConnected()
Fired whenever the client connects to a server |
abstract void |
clientDisconnected()
Fired whenever the client closes the conection to the server |
void |
close()
Closes the connection to the server, disowns any lists that were got from it and sends out the client disconnected event. |
void |
connect(java.lang.String servername,
int port)
Connect to the server. |
abstract void |
docReceived(java.io.BufferedReader doc)
Fired whenever a document from the server is received. |
abstract void |
errorReceived(java.io.BufferedReader err)
Fired whenever an error from the server is received. |
abstract void |
exceptionGenerated(java.lang.Exception e)
Fired whenever an exception is generated and for some reason the program should not be halted whilst alerting the user anyway |
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 |
int |
getPort()
Get the port of the server we are connected to |
java.lang.String |
getServerName()
Get the name of the server we are connected to |
void |
getVersion()
send a version request to sever |
void |
help()
Help for the client |
abstract void |
helpReceived(java.io.BufferedReader hlp)
Fired whenever a help document from the server is received. |
void |
info()
info for the client |
boolean |
isConnected()
Check if the client is connected |
void |
license()
license for the client |
abstract void |
licenseReceived(java.io.BufferedReader lic)
Fired whenever a license document from the server is received. |
abstract void |
listReceived(java.io.BufferedReader list)
Fired whenever a list from the server is received. |
static void |
main(java.lang.String[] args)
Main method. |
abstract void |
messageReceived(java.io.BufferedReader msg)
Fired whenever a message from the server is received. |
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 |
java.lang.String |
resolveDocName(java.lang.String type,
java.lang.String name)
Check whether the doc name we have actually exists, and return a modified version in the correct case-sensitive syntax. |
void |
run()
Runs a service loop continually receiving messages from the server and sending out the appropriate messages. |
void |
version()
version of the client |
abstract void |
warningReceived(java.io.BufferedReader warn)
Fired whenever a warning from the server is received. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String WARNING_MESG
public static final java.lang.String ERROR_MESG
public static final java.lang.String TEXT_MESG
public static final java.lang.String SERVER_MESG
Constructor Detail |
public PoplogDocClient()
public PoplogDocClient(java.lang.String serverName, int port) throws java.net.UnknownHostException, java.io.IOException
serverName
- The name of the server where an instance of the
PoplogDocServer is runningport
- The port the server is listening to
java.net.UnknownHostException
java.io.IOException
java.net.UnknownHostException
- When the server can't be reached
java.io.IOException
- If the connection can't be madeMethod Detail |
public static void main(java.lang.String[] args)
args
- The commands line argumentspublic java.lang.String getServerName()
public int getPort()
public boolean isConnected()
isConnected
in interface ClientInterface
public void getDoc(java.lang.String type, java.lang.String name) throws ClientException
getDoc
in interface ClientInterface
type
- The type of the request (REF, HELP, DOC, or TEACH)name
- The name of the document to fetch ("filename" or "")
ClientException
public void getHelp()
getHelp
in interface ClientInterface
public void getInfo()
getInfo
in interface ClientInterface
public void getLicense()
getLicense
in interface ClientInterface
public void getList(java.lang.String type)
getList
in interface ClientInterface
type
- public void getVersion()
getVersion
in interface ClientInterface
public void connect(java.lang.String servername, int port) throws java.net.UnknownHostException, java.io.IOException
connect
in interface ClientInterface
port
- The port the server is listening toservername
-
java.net.UnknownHostException
- When the server can't be reached
java.io.IOException
- If the connection can't be madepublic void close() throws java.io.IOException
close
in interface ClientInterface
java.io.IOException
- When the client cannot disconnectpublic void run()
run
in interface ClientInterface
public void parse(java.lang.String line) throws ClientException
parse
in interface ClientInterface
line
- The text to parse
ClientException
- When something goes wrongpublic void help()
public void version()
public void info()
public void license()
public void println(java.lang.String line)
println
in interface ClientInterface
line
- The line to printpublic java.lang.String resolveDocName(java.lang.String type, java.lang.String name)
type
- The type of document we wantname
- The tentative name of the document
public abstract void docReceived(java.io.BufferedReader doc)
docReceived
in interface ClientInterface
doc
- A Reader pointing top the beginning of the documentpublic abstract void errorReceived(java.io.BufferedReader err)
errorReceived
in interface ClientInterface
err
- A Reader pointing top the beginning of the errorpublic abstract void exceptionGenerated(java.lang.Exception e)
exceptionGenerated
in interface ClientInterface
e
- The exceptionpublic abstract void helpReceived(java.io.BufferedReader hlp)
helpReceived
in interface ClientInterface
hlp
- A Reader pointing top the beginning of the documentpublic abstract void licenseReceived(java.io.BufferedReader lic)
licenseReceived
in interface ClientInterface
lic
- A Reader pointing top the beginning of the documentpublic abstract void listReceived(java.io.BufferedReader list)
listReceived
in interface ClientInterface
list
- A Reader pointing top the beginning of the listpublic abstract void messageReceived(java.io.BufferedReader msg)
messageReceived
in interface ClientInterface
msg
- A Reader pointing top the beginning of the documentpublic abstract void warningReceived(java.io.BufferedReader warn)
warningReceived
in interface ClientInterface
warn
- A Reader pointing top the beginning of the warningpublic abstract void clientConnected()
clientConnected
in interface ClientInterface
public abstract void clientDisconnected()
clientDisconnected
in interface ClientInterface
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |