public class Protocol
extends java.lang.Object
The Protocol object is multithread safe.
Modifier and Type | Field and Description |
---|---|
protected boolean |
debug |
protected java.lang.String |
host |
protected java.io.PrintStream |
out |
protected java.lang.String |
prefix |
protected java.util.Properties |
props |
protected boolean |
quote |
Constructor and Description |
---|
Protocol(java.io.InputStream in,
java.io.OutputStream out,
boolean debug)
Constructor for debugging.
|
Protocol(java.lang.String host,
int port,
boolean debug,
java.io.PrintStream out,
java.util.Properties props,
java.lang.String prefix,
boolean isSSL)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addResponseHandler(ResponseHandler h)
Adds a response handler.
|
Response[] |
command(java.lang.String command,
Argument args)
Send a command to the server.
|
protected void |
disconnect()
Disconnect.
|
protected void |
finalize()
Finalizer.
|
protected ResponseInputStream |
getInputStream()
Return the Protocol's InputStream.
|
protected java.lang.String |
getLocalHost()
Get the name of the local host.
|
protected java.io.OutputStream |
getOutputStream()
Return the Protocol's OutputStream
|
protected ByteArray |
getResponseBuffer()
Return a buffer to be used to read a response.
|
long |
getTimestamp()
Returns the timestamp.
|
void |
handleResult(Response response)
Convenience routine to handle OK, NO, BAD and BYE responses.
|
void |
notifyResponseHandlers(Response[] responses)
Notify response handlers
|
protected void |
processGreeting(Response r) |
Response |
readResponse() |
void |
removeResponseHandler(ResponseHandler h)
Removed the specified response handler.
|
void |
simpleCommand(java.lang.String cmd,
Argument args)
Convenience routine to handle simple IAP commands
that do not have responses specific to that command.
|
void |
startTLS(java.lang.String cmd)
Start TLS on the current connection.
|
protected boolean |
supportsNonSyncLiterals()
Returns whether this Protocol supports non-synchronizing literals
Default is false.
|
java.lang.String |
writeCommand(java.lang.String command,
Argument args) |
protected java.lang.String host
protected boolean debug
protected boolean quote
protected java.io.PrintStream out
protected java.util.Properties props
protected java.lang.String prefix
public Protocol(java.lang.String host, int port, boolean debug, java.io.PrintStream out, java.util.Properties props, java.lang.String prefix, boolean isSSL) throws java.io.IOException, ProtocolException
Opens a connection to the given host at given port.
host
- host to connect toport
- portnumber to connect todebug
- debug modeout
- debug output streamprops
- Properties object used by this protocolprefix
- Prefix to prepend to property keysjava.io.IOException
ProtocolException
public Protocol(java.io.InputStream in, java.io.OutputStream out, boolean debug) throws java.io.IOException
java.io.IOException
public long getTimestamp()
public void addResponseHandler(ResponseHandler h)
public void removeResponseHandler(ResponseHandler h)
public void notifyResponseHandlers(Response[] responses)
protected void processGreeting(Response r) throws ProtocolException
ProtocolException
protected ResponseInputStream getInputStream()
protected java.io.OutputStream getOutputStream()
protected boolean supportsNonSyncLiterals()
public Response readResponse() throws java.io.IOException, ProtocolException
java.io.IOException
ProtocolException
protected ByteArray getResponseBuffer()
public java.lang.String writeCommand(java.lang.String command, Argument args) throws java.io.IOException, ProtocolException
java.io.IOException
ProtocolException
public Response[] command(java.lang.String command, Argument args)
command
- the commandargs
- the argumentspublic void handleResult(Response response) throws ProtocolException
ProtocolException
public void simpleCommand(java.lang.String cmd, Argument args) throws ProtocolException
ProtocolException
public void startTLS(java.lang.String cmd) throws java.io.IOException, ProtocolException
cmd
is the command to issue to start TLS negotiation.
If the command succeeds, we begin TLS negotiation.java.io.IOException
ProtocolException
protected void disconnect()
protected java.lang.String getLocalHost()
protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
Copyright © 2012 Sun Microsystems, Inc.. All Rights Reserved.