Top Description Fields Constructors Methods
com.sun.mail.pop3

public Class POP3Store

extends Store
Class Inheritance
Known Direct Subclasses
com.sun.mail.pop3.POP3SSLStore
Imports
java.util.Properties, .Collections, .Map, java.util.logging.Level, java.lang.reflect.*, javax.mail.*, javax.mail.internet.*, java.io.File, .PrintStream, .IOException, .EOFException, com.sun.mail.util.PropUtil, .MailLogger, .SocketConnectException, .MailConnectException

A POP3 Message Store. Contains only one folder, "INBOX". See the com.sun.mail.pop3 package documentation for further information on the POP3 protocol provider.

Authors
Bill Shannon, John Mani

Field Summary

Modifier and TypeField and Description
pack-priv volatile boolean
private Map<String, String>
private int
pack-priv volatile boolean
pack-priv volatile File
pack-priv volatile boolean
pack-priv volatile boolean
private String
private boolean
pack-priv volatile boolean
private MailLogger
pack-priv volatile Constructor<?>
private String
private String
private Protocol
private int
private POP3Folder
private boolean
pack-priv volatile boolean
pack-priv volatile boolean
pack-priv volatile boolean
private String
private boolean
private boolean

Constructor Summary

AccessConstructor and Description
public
POP3Store(Session session, URLName url)

public
POP3Store(Session session, URLName url, String name, boolean isSSL)

Method Summary

Modifier and TypeMethod and Description
public Map<String, String>

Returns:

Map of capabilities
capabilities
()

Return a Map of the capabilities the server provided, as per RFC 2449.

private void
private static IOException
public synchronized void
close()

Overrides javax.mail.Service.close.

Implements java.lang.AutoCloseable.close.

Close this service and terminate its connection.
pack-priv synchronized void
close(boolean force)

pack-priv synchronized void
protected void
finalize()

Overrides javax.mail.Service.finalize.

Stop the event dispatcher thread so the queue can be garbage collected.
private final synchronized boolean
getBoolProp(String prop)

Get the value of a boolean property.

public Folder
getDefaultFolder()

Implements abstract javax.mail.Store.getDefaultFolder.

Returns a Folder object that represents the 'root' of the default namespace presented to the user by the Store.
public Folder
getFolder(String
The name of the Folder. In some Stores, name can be an absolute path if it starts with the hierarchy delimiter. Else it is interpreted relative to the 'root' of this namespace.
name
)

Implements abstract javax.mail.Store.getFolder.

Only the name "INBOX" is supported.
public Folder
getFolder(URLName
URLName that denotes a folder
url
)

Implements abstract javax.mail.Store.getFolder.

Return a closed Folder object, corresponding to the given URLName.
pack-priv synchronized Protocol
pack-priv synchronized Session
getSession()

Hides javax.mail.Service.getSession.

Get a reference to the session.
public synchronized boolean
isConnected()

Overrides javax.mail.Service.isConnected.

Check whether this store is connected.
private static boolean
public synchronized boolean

Returns:

true if using SSL
isSSL
()

Is this POP3Store using SSL to connect to the server?

protected synchronized boolean
protocolConnect(String
the name of the host to connect to
host
,
int
the port to use (-1 means use default port)
portNum
,
String
the name of the user to login as
user
,
String
the user's password
passwd
)

Overrides javax.mail.Service.protocolConnect.

The service implementation should override this method to perform the actual protocol-specific connection attempt.
Inherited from javax.mail.Store:
addFolderListeneraddStoreListenergetPersonalNamespacesgetSharedNamespacesgetUserNamespacesnotifyFolderListenersnotifyFolderRenamedListenersnotifyStoreListenersremoveFolderListenerremoveStoreListener

Field Detail

cacheWriteToback to summary
pack-priv volatile boolean cacheWriteTo
capabilitiesback to summary
private Map<String, String> capabilities
defaultPortback to summary
private int defaultPort
disableTopback to summary
pack-priv volatile boolean disableTop
fileCacheDirback to summary
pack-priv volatile File fileCacheDir
finalizeCleanCloseback to summary
pack-priv volatile boolean finalizeCleanClose
forgetTopHeadersback to summary
pack-priv volatile boolean forgetTopHeaders
hostback to summary
private String host
isSSLback to summary
private boolean isSSL
keepMessageContentback to summary
pack-priv volatile boolean keepMessageContent
loggerback to summary
private MailLogger logger
messageConstructorback to summary
pack-priv volatile Constructor<?> messageConstructor
nameback to summary
private String name
passwdback to summary
private String passwd
portback to summary
private Protocol port
portNumback to summary
private int portNum
portOwnerback to summary
private POP3Folder portOwner
requireStartTLSback to summary
private boolean requireStartTLS
rsetBeforeQuitback to summary
pack-priv volatile boolean rsetBeforeQuit
supportsUidlback to summary
pack-priv volatile boolean supportsUidl
useFileCacheback to summary
pack-priv volatile boolean useFileCache
userback to summary
private String user
useStartTLSback to summary
private boolean useStartTLS
usingSSLback to summary
private boolean usingSSL

Constructor Detail

POP3Storeback to summary
public POP3Store(Session session, URLName url)
POP3Storeback to summary
public POP3Store(Session session, URLName url, String name, boolean isSSL)

Method Detail

capabilitiesback to summary
public Map<String, String> capabilities() throws MessagingException

Return a Map of the capabilities the server provided, as per RFC 2449. If the server doesn't support RFC 2449, an emtpy Map is returned. The returned Map can not be modified. The key to the Map is the upper case capability name as a String. The value of the entry is the entire String capability line returned by the server.

For example, to check if the server supports the STLS capability, use: if (store.capabilities().containsKey("STLS")) ...

Returns:Map<String, String>

Map of capabilities

Exceptions
MessagingException:
for failures
Since
JavaMail 1.4.3
checkConnectedback to summary
private void checkConnected() throws MessagingException
cleanupAndThrowback to summary
private static IOException cleanupAndThrow(Protocol p, IOException ife)
closeback to summary
public synchronized void close() throws MessagingException

Overrides javax.mail.Service.close.

Implements java.lang.AutoCloseable.close.

Doc from javax.mail.Service.close.

Close this service and terminate its connection. A close ConnectionEvent is delivered to any ConnectionListeners. Any Messaging components (Folders, Messages, etc.) belonging to this service are invalid after this service is closed. Note that the service is closed even if this method terminates abnormally by throwing a MessagingException.

This implementation uses setConnected(false) to set this service's connected state to false. It will then send a close ConnectionEvent to any registered ConnectionListeners. Subclasses overriding this method to do implementation specific cleanup should call this method as a last step to insure event notification, probably by including a call to super.close() in a finally clause.

Annotations
@Override
Exceptions
MessagingException:
for errors while closing
closeback to summary
pack-priv synchronized void close(boolean force) throws MessagingException
closePortback to summary
pack-priv synchronized void closePort(POP3Folder owner)
finalizeback to summary
protected void finalize() throws Throwable

Overrides javax.mail.Service.finalize.

Doc from javax.mail.Service.finalize.

Stop the event dispatcher thread so the queue can be garbage collected.

Annotations
@Override
Exceptions
Throwable:

Doc from java.lang.Object.finalize.

the Exception raised by this method

getBoolPropback to summary
private final synchronized boolean getBoolProp(String prop)

Get the value of a boolean property. Print out the value if logging is enabled.

getDefaultFolderback to summary
public Folder getDefaultFolder() throws MessagingException

Implements abstract javax.mail.Store.getDefaultFolder.

Doc from javax.mail.Store.getDefaultFolder.

Returns a Folder object that represents the 'root' of the default namespace presented to the user by the Store.

Returns:Folder

the root Folder

Annotations
@Override
Exceptions
MessagingException:
for other failures
getFolderback to summary
public Folder getFolder(String name) throws MessagingException

Implements abstract javax.mail.Store.getFolder.

Only the name "INBOX" is supported.

Parameters
name:String

Doc from javax.mail.Store.getFolder.

The name of the Folder. In some Stores, name can be an absolute path if it starts with the hierarchy delimiter. Else it is interpreted relative to the 'root' of this namespace.

Returns:Folder

Doc from javax.mail.Store.getFolder.

Folder object

Annotations
@Override
Exceptions
MessagingException:

Doc from javax.mail.Store.getFolder.

for other failures

getFolderback to summary
public Folder getFolder(URLName url) throws MessagingException

Implements abstract javax.mail.Store.getFolder.

Doc from javax.mail.Store.getFolder.

Return a closed Folder object, corresponding to the given URLName. The store specified in the given URLName should refer to this Store object.

Implementations of this method may obtain the name of the actual folder using the getFile() method on URLName, and use that name to create the folder.

Parameters
url:URLName

URLName that denotes a folder

Returns:Folder

Folder object

Annotations
@Override
Exceptions
MessagingException:
for other failures
getPortback to summary
pack-priv synchronized Protocol getPort(POP3Folder owner) throws IOException
getSessionback to summary
pack-priv synchronized Session getSession()

Hides javax.mail.Service.getSession.

Get a reference to the session.

isConnectedback to summary
public synchronized boolean isConnected()

Overrides javax.mail.Service.isConnected.

Check whether this store is connected. Override superclass method, to actually ping our server connection.

Returns:boolean

Doc from javax.mail.Service.isConnected.

true if the service is connected, false if it is not connected

Annotations
@Override
isRecoverableback to summary
private static boolean isRecoverable(Throwable t)
isSSLback to summary
public synchronized boolean isSSL()

Is this POP3Store using SSL to connect to the server?

Returns:boolean

true if using SSL

Since
JavaMail 1.4.6
protocolConnectback to summary
protected synchronized boolean protocolConnect(String host, int portNum, String user, String passwd) throws MessagingException

Overrides javax.mail.Service.protocolConnect.

Doc from javax.mail.Service.protocolConnect.

The service implementation should override this method to perform the actual protocol-specific connection attempt. The default implementation of the connect method calls this method as needed.

The protocolConnect method should return false if a user name or password is required for authentication but the corresponding parameter is null; the connect method will prompt the user when needed to supply missing information. This method may also return false if authentication fails for the supplied user name or password. Alternatively, this method may throw an AuthenticationFailedException when authentication fails. This exception may include a String message with more detail about the failure.

The protocolConnect method should throw an exception to report failures not related to authentication, such as an invalid host name or port number, loss of a connection during the authentication process, unavailability of the server, etc.

Parameters
host:String

the name of the host to connect to

portNum:int

the port to use (-1 means use default port)

user:String

the name of the user to login as

passwd:String

the user's password

Returns:boolean

true if connection successful, false if authentication failed

Annotations
@Override
Exceptions
MessagingException:
for non-authentication failures