|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--de.trantor.mail.Connection
Is the abstract base class for socket connections used inside the SMTP, POP3 and IMAP protocols of the mail package. The rationale for using this class is the difference in how networking is handled in J2ME and J2SE: While J2SE has java.net.Socket, J2ME uses the Generic Connection Framework with its javax.io.Connector class as a central means to open sockets or HTTP connection. Unfortunately, both methods are totally incompatible with each other, so a common abstraction has to be found to make the mail package work in both environments.
The Connection class is such an abstraction. It provides abstract versions of methods that open and close sockets, read from them and write to them. It also provides a static factory method that is able to instantiate one of several sub-classes of Connection that match the different run-time environments. These sub-classes are all called ConnectionImpl, and they are loaded "by name" from the j2me, j2se, or http packages, respectively. This is the only way to get rid of compile-time dependencies on these classes.
| Constructor Summary | |
Connection()
|
|
| Method Summary | |
abstract void |
close()
Closes a connection. |
abstract boolean |
connected()
Queries the current status of the connection. |
boolean |
getDebug()
Queries the current value of the debugging flag. |
static Connection |
getInstance()
Creates a new, concrete connection object for either J2SE or J2SE, depending on the current run-time environment. |
abstract void |
open(java.lang.String host,
int port,
boolean ssl)
Opens a connection. |
protected abstract int |
read(byte[] buffer,
int offset,
int count)
Reads from the socket. |
java.lang.String |
receive()
Receives a string from the server. |
void |
send(java.lang.String s)
Sends a string to the server. |
void |
setDebug(boolean debug)
Controls the output of debugging information to standard output. |
protected abstract void |
write(byte[] buffer,
int offset,
int count)
Writes to the socket. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Connection()
| Method Detail |
public abstract void open(java.lang.String host,
int port,
boolean ssl)
throws java.io.IOException
java.io.IOException
public abstract void close()
throws java.io.IOException
java.io.IOException
protected abstract void write(byte[] buffer,
int offset,
int count)
throws java.io.IOException
java.io.IOException
protected abstract int read(byte[] buffer,
int offset,
int count)
throws java.io.IOException
java.io.IOExceptionpublic abstract boolean connected()
public static Connection getInstance()
public void send(java.lang.String s)
throws java.io.IOException
java.io.IOExceptionreceive()
public java.lang.String receive()
throws java.io.IOException
java.io.IOExceptionsend(java.lang.String)public void setDebug(boolean debug)
getDebug()public boolean getDebug()
setDebug(boolean)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||