The Protocol object is multithread safe.
| Modifier and Type | Field and Description |
|---|---|
| private static final byte[] | |
| private final List | |
| protected String | |
| private volatile ResponseInputStream | |
| private String | |
| protected MailLogger | |
| private volatile DataOutputStream | |
| protected String | |
| protected Properties | |
| protected boolean | |
| private Socket | |
| private int | |
| pack-priv static final AtomicInteger | |
| private final String | |
| private volatile long | |
| private TraceInputStream | |
| protected MailLogger | |
| private TraceOutputStream |
| Access | Constructor and Description |
|---|---|
| public | Protocol(String
host to connect to host, int portnumber to connect to port, Properties Properties object used by this protocol props, String Prefix to prepend to property keys prefix, boolean use SSL? isSSL, MailLogger log messages here logger)Constructor. |
| public | Protocol(InputStream
the InputStream to read from in, PrintStream the PrintStream to write to out, Properties Properties object used by this protocol props, boolean true to enable debugging output debug)Constructor for debugging. |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public synchronized Response[] | |
| private void | |
| private void | |
| private String | computePrefix(Properties props, String prefix)
Compute the tag prefix to be used for this connection. |
| protected synchronized void | |
| protected void | |
| public SocketChannel | Returns: the SocketChannelReturn the SocketChannel associated with this connection, if any. |
| public InetAddress | Returns: the InetAddress the socket is connected toReturn the address the socket connected to. |
| protected ResponseInputStream | |
| protected synchronized String | |
| protected OutputStream | |
| protected ByteArray | |
| public long | |
| public void | handleResult(Response
the response response)Convenience routine to handle OK, NO, BAD and BYE responses. |
| public boolean | Returns: true if another response is in the bufferIs another response available in our buffer? |
| private void | |
| public boolean | |
| protected boolean | |
| public void | |
| protected void | |
| public Response | |
| public void | |
| protected void | |
| public void | simpleCommand(String
the command cmd, Argument the arguments args)Convenience routine to handle simple IAP commands that do not have responses specific to that command. |
| public synchronized void | |
| public synchronized void | |
| protected synchronized boolean | Returns: true if the server supports non-synchronizing literalsReturns whether this Protocol supports non-synchronizing literals Default is false. |
| public boolean | |
| protected void | suspendTracing()
Temporarily turn off protocol tracing, e.g., to prevent tracing the authentication sequence, including the password. |
| public String |
| CRLF | back to summary |
|---|---|
| private static final byte[] CRLF | |
| handlers | back to summary |
|---|---|
| private final List<ResponseHandler> handlers | |
| host | back to summary |
|---|---|
| protected String host | |
| input | back to summary |
|---|---|
| private volatile ResponseInputStream input | |
| localHostName | back to summary |
|---|---|
| private String localHostName | |
| logger | back to summary |
|---|---|
| protected MailLogger logger | |
| output | back to summary |
|---|---|
| private volatile DataOutputStream output | |
| prefix | back to summary |
|---|---|
| protected String prefix | |
| props | back to summary |
|---|---|
| protected Properties props | |
| quote | back to summary |
|---|---|
| protected boolean quote | |
| socket | back to summary |
|---|---|
| private Socket socket | |
| tagCounter | back to summary |
|---|---|
| private int tagCounter | |
| tagNum | back to summary |
|---|---|
| pack-priv static final AtomicInteger tagNum | |
| tagPrefix | back to summary |
|---|---|
| private final String tagPrefix | |
| timestamp | back to summary |
|---|---|
| private volatile long timestamp | |
| traceInput | back to summary |
|---|---|
| private TraceInputStream traceInput | |
| traceLogger | back to summary |
|---|---|
| protected MailLogger traceLogger | |
| traceOutput | back to summary |
|---|---|
| private TraceOutputStream traceOutput | |
| Protocol | back to summary |
|---|---|
| public Protocol(String host, int port, Properties props, String prefix, boolean isSSL, MailLogger logger) throws IOException, ProtocolException Constructor. Opens a connection to the given host at given port.
| |
| Protocol | back to summary |
|---|---|
| public Protocol(InputStream in, PrintStream out, Properties props, boolean debug) throws IOException Constructor for debugging.
| |
| addResponseHandler | back to summary |
|---|---|
| public void addResponseHandler(ResponseHandler h) Adds a response handler.
| |
| command | back to summary |
|---|---|
| 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. | |
| commandEnd | back to summary |
|---|---|
| private void commandEnd() | |
| commandStart | back to summary |
|---|---|
| private void commandStart(String command) | |
| computePrefix | back to summary |
|---|---|
| private String computePrefix(Properties props, String prefix) Compute the tag prefix to be used for this connection. Start with "A" - "Z", then "AA" - "ZZ", and finally "AAA" - "ZZZ". Wrap around after that. | |
| disconnect | back to summary |
|---|---|
| protected synchronized void disconnect() Disconnect. | |
| finalize | back to summary |
|---|---|
| protected void finalize() throws Throwable Overrides java. Finalizer.
| |
| getChannel | back to summary |
|---|---|
| public SocketChannel getChannel() Return the SocketChannel associated with this connection, if any.
| |
| getInetAddress | back to summary |
|---|---|
| public InetAddress getInetAddress() Return the address the socket connected to.
| |
| getInputStream | back to summary |
|---|---|
| protected ResponseInputStream getInputStream() Return the Protocol's InputStream.
| |
| getLocalHost | back to summary |
|---|---|
| protected synchronized String getLocalHost() Get the name of the local host. The property <prefix>.localhost overrides <prefix>.localaddress, which overrides what InetAddress would tell us.
| |
| getOutputStream | back to summary |
|---|---|
| protected OutputStream getOutputStream() Return the Protocol's OutputStream
| |
| getResponseBuffer | back to summary |
|---|---|
| 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 | back to summary |
|---|---|
| public long getTimestamp() Returns the timestamp.
| |
| handleResult | back to summary |
|---|---|
| public void handleResult(Response response) throws ProtocolException Convenience routine to handle OK, NO, BAD and BYE responses.
| |
| hasResponse | back to summary |
|---|---|
| public boolean hasResponse() Is another response available in our buffer?
| |
| initStreams | back to summary |
|---|---|
| private void initStreams() throws IOException | |
| isSSL | back to summary |
|---|---|
| public boolean isSSL() Is this connection using an SSL socket?
| |
| isTracing | back to summary |
|---|---|
| protected boolean isTracing() Is protocol tracing enabled?
| |
| notifyResponseHandlers | back to summary |
|---|---|
| public void notifyResponseHandlers(Response[] responses) Notify response handlers
| |
| processGreeting | back to summary |
|---|---|
| protected void processGreeting(Response r) throws ProtocolException | |
| readResponse | back to summary |
|---|---|
| public Response readResponse() throws IOException, ProtocolException | |
| removeResponseHandler | back to summary |
|---|---|
| public void removeResponseHandler(ResponseHandler h) Removed the specified response handler.
| |
| resumeTracing | back to summary |
|---|---|
| protected void resumeTracing() Resume protocol tracing, if it was enabled to begin with. | |
| simpleCommand | back to summary |
|---|---|
| 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.
| |
| startCompression | back to summary |
|---|---|
| public synchronized void startCompression(String cmd) throws IOException, ProtocolException Start compression on the current connection.
| |
| startTLS | back to summary |
|---|---|
| public synchronized void startTLS(String cmd) throws IOException, ProtocolException Start TLS on the current connection.
| |
| supportsNonSyncLiterals | back to summary |
|---|---|
| protected synchronized boolean supportsNonSyncLiterals() Returns whether this Protocol supports non-synchronizing literals Default is false. Subclasses should override this if required
| |
| supportsUtf8 | back to summary |
|---|---|
| public boolean supportsUtf8() Does the server support UTF-8? This implementation returns false. Subclasses should override as appropriate.
| |
| suspendTracing | back to summary |
|---|---|
| protected void suspendTracing() Temporarily turn off protocol tracing, e.g., to prevent tracing the authentication sequence, including the password. | |
| writeCommand | back to summary |
|---|---|
| public String writeCommand(String command, Argument args) throws IOException, ProtocolException | |