This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


com.sun.mail.iap
class Protocol

com.sun.mail.iap.Protocol
Direct Known Subclasses:
IMAPProtocol

public class Protocol
extends Object

General protocol handling code for IMAP-like protocols.

The Protocol object is multithread safe.


Field Summary
protected boolean debug
          
protected String host
          
protected PrintStream out
          
protected String prefix
          
protected Properties props
          
protected boolean quote
          
 
Constructor Summary
Protocol(InputStream in, OutputStream out, boolean debug)

          Constructor for debugging.
Protocol(String host, int port, boolean debug, PrintStream out, Properties props, String prefix, boolean isSSL)

          Constructor.
 
Method Summary
 void

          Adds a response handler.
 Response[]
command(String command, Argument args)

          Send a command to the server.
protected void

          Disconnect.
protected void

          Finalizer.
protected ResponseInputStream

          Return the Protocol's InputStream.
protected OutputStream

          Return the Protocol's OutputStream
protected ByteArray

          Return a buffer to be used to read a response.
 long

          Returns the timestamp.
 void

          Convenience routine to handle OK, NO, BAD and BYE responses.
 void

          Notify response handlers
protected void

          
 Response

          
 void

          Removed the specified response handler.
 void

          Convenience routine to handle simple IAP commands that do not have responses specific to that command.
 void

          Start TLS on the current connection.
protected boolean

          Returns whether this Protocol supports non-synchronizing literals Default is false.
 String
writeCommand(String command, Argument args)

          
 

Field Detail

debug

protected boolean debug

host

protected String host

out

protected PrintStream out

prefix

protected String prefix

props

protected Properties props

quote

protected boolean quote
Constructor Detail

Protocol

public Protocol(InputStream in,
                OutputStream out,
                boolean debug)
         throws IOException
Constructor for debugging.

Parameters:
in
out
debug
Throws:
IOException

Protocol

public Protocol(String host,
                int port,
                boolean debug,
                PrintStream out,
                Properties props,
                String prefix,
                boolean isSSL)
         throws IOException,
                ProtocolException
Constructor.

Opens a connection to the given host at given port.

Parameters:
host - host to connect to
port - portnumber to connect to
debug - debug mode
out - debug output stream
props - Properties object used by this protocol
prefix - Prefix to prepend to property keys
isSSL
Throws:
IOException
ProtocolException
Method Detail

addResponseHandler

public synchronized void addResponseHandler(ResponseHandler h)
Adds a response handler.

Parameters:
h

command

public synchronized Response[] command(String command,
                                       Argument args)
Send a command to the server. Collect all responses until either the corresponding command completion response or a BYE response (indicating server failure). Return all the collected responses.

Parameters:
command - the command
args - the arguments
Returns:
array of Response objects returned by the server

disconnect

protected synchronized void disconnect()
Disconnect.


finalize

protected void finalize()
                 throws Throwable
Finalizer.

Overrides:
finalize in class Object
Throws:
Throwable

getInputStream

protected ResponseInputStream getInputStream()
Return the Protocol's InputStream.


getOutputStream

protected OutputStream getOutputStream()
Return the Protocol's OutputStream


getResponseBuffer

protected ByteArray getResponseBuffer()
Return a buffer to be used to read a response. The default implementation returns null, which causes a new buffer to be allocated for every response.


getTimestamp

public long getTimestamp()
Returns the timestamp.


handleResult

public void handleResult(Response response)
                  throws ProtocolException
Convenience routine to handle OK, NO, BAD and BYE responses.

Parameters:
response
Throws:
ProtocolException

notifyResponseHandlers

public void notifyResponseHandlers(Response[] responses)
Notify response handlers

Parameters:
responses

processGreeting

protected void processGreeting(Response r)
                        throws ProtocolException
Parameters:
r
Throws:
ProtocolException

readResponse

public Response readResponse()
                      throws IOException,
                             ProtocolException
Throws:
IOException
ProtocolException

removeResponseHandler

public synchronized void removeResponseHandler(ResponseHandler h)
Removed the specified response handler.

Parameters:
h

simpleCommand

public void simpleCommand(String cmd,
                          Argument args)
                   throws ProtocolException
Convenience routine to handle simple IAP commands that do not have responses specific to that command.

Parameters:
cmd
args
Throws:
ProtocolException

startTLS

public synchronized void startTLS(String cmd)
                           throws IOException,
                                  ProtocolException
Start TLS on the current connection. cmd is the command to issue to start TLS negotiation. If the command succeeds, we begin TLS negotiation.

Parameters:
cmd
Throws:
IOException
ProtocolException

supportsNonSyncLiterals

protected synchronized boolean supportsNonSyncLiterals()
Returns whether this Protocol supports non-synchronizing literals Default is false. Subclasses should override this if required


writeCommand

public String writeCommand(String command,
                           Argument args)
                    throws IOException,
                           ProtocolException
Parameters:
command
args
Throws:
IOException
ProtocolException


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention. The official Sun™ documentation can be found here at http://java.sun.com/products/javamail/javadocs/index.html.