com.sun.mail.imap.protocol
类 IMAPProtocol

java.lang.Object
  继承者 com.sun.mail.iap.Protocol
      继承者 com.sun.mail.imap.protocol.IMAPProtocol

public class IMAPProtocol
extends Protocol

This class extends the iap.Protocol object and implements IMAP semantics. In general, there is a method corresponding to each IMAP protocol command. The typical implementation issues the appropriate protocol command, collects all responses, processes those responses that are specific to this command and then dispatches the rest (the unsolicited ones) to the dispatcher using the notifyResponseHandlers(r).

版本:
1.64, 07/05/04
作者:
John Mani, Bill Shannon

字段摘要
 
从类 com.sun.mail.iap.Protocol 继承的字段
debug, host, out, prefix, props, quote
 
构造方法摘要
IMAPProtocol(String name, String host, int port, boolean debug, PrintStream out, Properties props, boolean isSSL)
          Constructor.
 
方法摘要
 void append(String mbox, Flags f, Date d, Literal data)
          APPEND Command.
 AppendUID appenduid(String mbox, Flags f, Date d, Literal data)
          APPEND Command, return uid from APPENDUID response code.
 AppendUID appenduid(String mbox, Flags f, Date d, Literal data, boolean uid)
           
 void authlogin(String u, String p)
          The AUTHENTICATE command with AUTH=LOGIN authenticate scheme
 void authplain(String authzid, String u, String p)
          The AUTHENTICATE command with AUTH=PLAIN authentication scheme.
 void capability()
          CAPABILITY command.
 void check()
          CHECK Command.
 void close()
          CLOSE Command.
 void copy(int start, int end, String mbox)
           
 void copy(MessageSet[] msgsets, String mbox)
          COPY command.
 void create(String mbox)
          CREATE Command.
 void delete(String mbox)
          DELETE Command.
 void deleteACL(String mbox, String user)
          DELETEACL Command.
 void disconnect()
          Close socket connection.
 MailboxInfo examine(String mbox)
          EXAMINE Command.
 void expunge()
          EXPUNGE Command.
 Response[] fetch(int start, int end, String what)
           
 Response[] fetch(int msg, String what)
           
 Response[] fetch(MessageSet[] msgsets, String what)
           
 BODY fetchBody(int msgno, String section)
          Fetch given BODY section.
protected  BODY fetchBody(int msgno, String section, boolean peek)
           
 BODY fetchBody(int msgno, String section, int start, int size)
          Partial FETCH of given BODY section.
protected  BODY fetchBody(int msgno, String section, int start, int size, boolean peek, ByteArray ba)
           
 BODY fetchBody(int msgno, String section, int start, int size, ByteArray ba)
          Partial FETCH of given BODY section.
 BODYSTRUCTURE fetchBodyStructure(int msgno)
          Fetch the BODYSTRUCTURE of the specified message.
 Flags fetchFlags(int msgno)
          Fetch the FLAGS for the given message.
 RFC822DATA fetchRFC822(int msgno, String what)
          Fetch the specified RFC822 Data item.
 UID fetchSequenceNumber(long uid)
          Get the sequence number for the given UID.
 UID[] fetchSequenceNumbers(long[] uids)
          Get the sequence numbers for UIDs ranging from start till end.
 UID[] fetchSequenceNumbers(long start, long end)
          Get the sequence numbers for UIDs ranging from start till end.
 UID fetchUID(int msgno)
          Fetch the IMAP UID for the given message.
 ACL[] getACL(String mbox)
          GETACL Command.
 Map getCapabilities()
          Return the map of capabilities returned by the server.
 Quota[] getQuota(String root)
          GETQUOTA Command.
 Quota[] getQuotaRoot(String mbox)
          GETQUOTAROOT Command.
protected  ByteArray getResponseBuffer()
          Return a buffer to read a response into.
 boolean hasCapability(String c)
          Check whether the given capability is supported by this server.
 void idleAbort()
          Abort an IDLE command.
 void idleStart()
          IDLE Command.
 boolean isAuthenticated()
          Returns true if the connection has been authenticated, either due to a successful login, or due to a PREAUTH greeting response.
 boolean isREV1()
          Returns true if this is a IMAP4rev1 server
 ListInfo[] list(String ref, String pattern)
          LIST Command.
 Rights[] listRights(String mbox, String user)
          LISTRIGHTS Command.
 void login(String u, String p)
          LOGIN Command.
 void logout()
          LOGOUT Command.
 ListInfo[] lsub(String ref, String pattern)
          LSUB Command.
 Rights myRights(String mbox)
          MYRIGHTS Command.
 Namespaces namespace()
          NAMESPACE Command.
 void noop()
          The NOOP command.
protected  void parseCapabilities(Response r)
          Parse the capabilities from a CAPABILITY response or from a CAPABILITY response code attached to (e.g.) an OK response.
 BODY peekBody(int msgno, String section)
          Fetch given BODY section, without marking the message as SEEN.
 BODY peekBody(int msgno, String section, int start, int size)
          Partial FETCH of given BODY section, without setting SEEN flag.
 BODY peekBody(int msgno, String section, int start, int size, ByteArray ba)
          Partial FETCH of given BODY section, without setting SEEN flag.
protected  void processGreeting(Response r)
          Check the greeting when first connecting; look for PREAUTH response.
 boolean processIdleResponse(Response r)
          Process a response returned by readIdleResponse().
 void proxyauth(String u)
          PROXYAUTH Command.
 Response readIdleResponse()
          While an IDLE command is in progress, read a response sent from the server.
 Response readResponse()
          Read a response from the server.
 void rename(String o, String n)
          RENAME Command.
 void sasllogin(String[] allowed, String realm, String authzid, String u, String p)
          SASL-based login.
 int[] search(MessageSet[] msgsets, SearchTerm term)
          Issue the given search criterion on the specified message sets.
 int[] search(SearchTerm term)
          Issue the given search criterion on all messages in this folder.
 MailboxInfo select(String mbox)
          SELECT Command.
 void setACL(String mbox, char modifier, ACL acl)
          SETACL Command.
protected  void setCapabilities(Response r)
          If the response contains a CAPABILITY response code, extract it and save the capabilities.
 void setQuota(Quota quota)
          SETQUOTA Command.
 void startTLS()
          STARTTLS Command.
 Status status(String mbox, String[] items)
          STATUS Command.
 void storeFlags(int msg, Flags flags, boolean set)
          Set the specified flags on this message.
 void storeFlags(int start, int end, Flags flags, boolean set)
           
 void storeFlags(MessageSet[] msgsets, Flags flags, boolean set)
           
 void subscribe(String mbox)
          SUBSCRIBE Command.
protected  boolean supportsNonSyncLiterals()
          Returns whether this Protocol supports non-synchronizing literals.
 void uidexpunge(UIDSet[] set)
          UID EXPUNGE Command.
 void unsubscribe(String mbox)
          UNSUBSCRIBE Command.
 
从类 com.sun.mail.iap.Protocol 继承的方法
addResponseHandler, command, finalize, getInputStream, getOutputStream, getTimestamp, handleResult, notifyResponseHandlers, removeResponseHandler, simpleCommand, startTLS, writeCommand
 
从类 java.lang.Object 继承的方法
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

IMAPProtocol

public IMAPProtocol(String name,
                    String host,
                    int port,
                    boolean debug,
                    PrintStream out,
                    Properties props,
                    boolean isSSL)
             throws IOException,
                    ProtocolException
Constructor. Opens a connection to the given host at given port.

参数:
host - host to connect to
port - portnumber to connect to
debug - debug mode
props - Properties object used by this protocol
抛出:
IOException
ProtocolException
方法详细信息

capability

public void capability()
                throws ProtocolException
CAPABILITY command.

抛出:
ProtocolException
另请参见:
"RFC2060, section 6.1.1"

setCapabilities

protected void setCapabilities(Response r)
If the response contains a CAPABILITY response code, extract it and save the capabilities.


parseCapabilities

protected void parseCapabilities(Response r)
Parse the capabilities from a CAPABILITY response or from a CAPABILITY response code attached to (e.g.) an OK response.


processGreeting

protected void processGreeting(Response r)
                        throws ProtocolException
Check the greeting when first connecting; look for PREAUTH response.

覆盖:
Protocol 中的 processGreeting
抛出:
ProtocolException

isAuthenticated

public boolean isAuthenticated()
Returns true if the connection has been authenticated, either due to a successful login, or due to a PREAUTH greeting response.


isREV1

public boolean isREV1()
Returns true if this is a IMAP4rev1 server


supportsNonSyncLiterals

protected boolean supportsNonSyncLiterals()
Returns whether this Protocol supports non-synchronizing literals.

覆盖:
Protocol 中的 supportsNonSyncLiterals

readResponse

public Response readResponse()
                      throws IOException,
                             ProtocolException
Read a response from the server.

覆盖:
Protocol 中的 readResponse
抛出:
IOException
ProtocolException

hasCapability

public boolean hasCapability(String c)
Check whether the given capability is supported by this server. Returns true if so, otherwise returns false.


getCapabilities

public Map getCapabilities()
Return the map of capabilities returned by the server.

从以下版本开始:
JavaMail 1.4.1

disconnect

public void disconnect()
Close socket connection. This method just makes the Protocol.disconnect() method public.

覆盖:
Protocol 中的 disconnect

noop

public void noop()
          throws ProtocolException
The NOOP command.

抛出:
ProtocolException
另请参见:
"RFC2060, section 6.1.2"

logout

public void logout()
            throws ProtocolException
LOGOUT Command.

抛出:
ProtocolException
另请参见:
"RFC2060, section 6.1.3"

login

public void login(String u,
                  String p)
           throws ProtocolException
LOGIN Command.

抛出:
ProtocolException
另请参见:
"RFC2060, section 6.2.2"

authlogin

public void authlogin(String u,
                      String p)
               throws ProtocolException
The AUTHENTICATE command with AUTH=LOGIN authenticate scheme

抛出:
ProtocolException
另请参见:
"RFC2060, section 6.2.1"

authplain

public void authplain(String authzid,
                      String u,
                      String p)
               throws ProtocolException
The AUTHENTICATE command with AUTH=PLAIN authentication scheme. This is based heavly on the authlogin(java.lang.String, java.lang.String) method.

参数:
authzid - the authorization id
u - the username
p - the password
抛出:
ProtocolException - as thrown by Protocol.handleResult(com.sun.mail.iap.Response).
从以下版本开始:
JavaMail 1.3.2
另请参见:
"RFC3501, section 6.2.2", "RFC2595, section 6"

sasllogin

public void sasllogin(String[] allowed,
                      String realm,
                      String authzid,
                      String u,
                      String p)
               throws ProtocolException
SASL-based login.

抛出:
ProtocolException

proxyauth

public void proxyauth(String u)
               throws ProtocolException
PROXYAUTH Command.

抛出:
ProtocolException
另请参见:
"Netscape/iPlanet/SunONE Messaging Server extension"

startTLS

public void startTLS()
              throws ProtocolException
STARTTLS Command.

抛出:
ProtocolException
另请参见:
"RFC3501, section 6.2.1"

select

public MailboxInfo select(String mbox)
                   throws ProtocolException
SELECT Command.

抛出:
ProtocolException
另请参见:
"RFC2060, section 6.3.1"

examine

public MailboxInfo examine(String mbox)
                    throws ProtocolException
EXAMINE Command.

抛出:
ProtocolException
另请参见:
"RFC2060, section 6.3.2"

status

public Status status(String mbox,
                     String[] items)
              throws ProtocolException
STATUS Command.

抛出:
ProtocolException
另请参见:
"RFC2060, section 6.3.10"

create

public void create(String mbox)
            throws ProtocolException
CREATE Command.

抛出:
ProtocolException
另请参见:
"RFC2060, section 6.3.3"

delete

public void delete(String mbox)
            throws ProtocolException
DELETE Command.

抛出:
ProtocolException
另请参见:
"RFC2060, section 6.3.4"

rename

public void rename(String o,
                   String n)
            throws ProtocolException
RENAME Command.

抛出:
ProtocolException
另请参见:
"RFC2060, section 6.3.5"

subscribe

public void subscribe(String mbox)
               throws ProtocolException
SUBSCRIBE Command.

抛出:
ProtocolException
另请参见:
"RFC2060, section 6.3.6"

unsubscribe

public void unsubscribe(String mbox)
                 throws ProtocolException
UNSUBSCRIBE Command.

抛出:
ProtocolException
另请参见:
"RFC2060, section 6.3.7"

list

public ListInfo[] list(String ref,
                       String pattern)
                throws ProtocolException
LIST Command.

抛出:
ProtocolException
另请参见:
"RFC2060, section 6.3.8"

lsub

public ListInfo[] lsub(String ref,
                       String pattern)
                throws ProtocolException
LSUB Command.

抛出:
ProtocolException
另请参见:
"RFC2060, section 6.3.9"

append

public void append(String mbox,
                   Flags f,
                   Date d,
                   Literal data)
            throws ProtocolException
APPEND Command.

抛出:
ProtocolException
另请参见:
"RFC2060, section 6.3.11"

appenduid

public AppendUID appenduid(String mbox,
                           Flags f,
                           Date d,
                           Literal data)
                    throws ProtocolException
APPEND Command, return uid from APPENDUID response code.

抛出:
ProtocolException
另请参见:
"RFC2060, section 6.3.11"

appenduid

public AppendUID appenduid(String mbox,
                           Flags f,
                           Date d,
                           Literal data,
                           boolean uid)
                    throws ProtocolException
抛出:
ProtocolException

check

public void check()
           throws ProtocolException
CHECK Command.

抛出:
ProtocolException
另请参见:
"RFC2060, section 6.4.1"

close

public void close()
           throws ProtocolException
CLOSE Command.

抛出:
ProtocolException
另请参见:
"RFC2060, section 6.4.2"

expunge

public void expunge()
             throws ProtocolException
EXPUNGE Command.

抛出:
ProtocolException
另请参见:
"RFC2060, section 6.4.3"

uidexpunge

public void uidexpunge(UIDSet[] set)
                throws ProtocolException
UID EXPUNGE Command.

抛出:
ProtocolException
另请参见:
"RFC2359, section 4.1"

fetchBodyStructure

public BODYSTRUCTURE fetchBodyStructure(int msgno)
                                 throws ProtocolException
Fetch the BODYSTRUCTURE of the specified message.

抛出:
ProtocolException

peekBody

public BODY peekBody(int msgno,
                     String section)
              throws ProtocolException
Fetch given BODY section, without marking the message as SEEN.

抛出:
ProtocolException

fetchBody

public BODY fetchBody(int msgno,
                      String section)
               throws ProtocolException
Fetch given BODY section.

抛出:
ProtocolException

fetchBody

protected BODY fetchBody(int msgno,
                         String section,
                         boolean peek)
                  throws ProtocolException
抛出:
ProtocolException

peekBody

public BODY peekBody(int msgno,
                     String section,
                     int start,
                     int size)
              throws ProtocolException
Partial FETCH of given BODY section, without setting SEEN flag.

抛出:
ProtocolException

fetchBody

public BODY fetchBody(int msgno,
                      String section,
                      int start,
                      int size)
               throws ProtocolException
Partial FETCH of given BODY section.

抛出:
ProtocolException

peekBody

public BODY peekBody(int msgno,
                     String section,
                     int start,
                     int size,
                     ByteArray ba)
              throws ProtocolException
Partial FETCH of given BODY section, without setting SEEN flag.

抛出:
ProtocolException

fetchBody

public BODY fetchBody(int msgno,
                      String section,
                      int start,
                      int size,
                      ByteArray ba)
               throws ProtocolException
Partial FETCH of given BODY section.

抛出:
ProtocolException

fetchBody

protected BODY fetchBody(int msgno,
                         String section,
                         int start,
                         int size,
                         boolean peek,
                         ByteArray ba)
                  throws ProtocolException
抛出:
ProtocolException

getResponseBuffer

protected ByteArray getResponseBuffer()
Return a buffer to read a response into. The buffer is provided by fetchBody and is used only once.

覆盖:
Protocol 中的 getResponseBuffer

fetchRFC822

public RFC822DATA fetchRFC822(int msgno,
                              String what)
                       throws ProtocolException
Fetch the specified RFC822 Data item. 'what' names the item to be fetched. 'what' can be null to fetch the whole message.

抛出:
ProtocolException

fetchFlags

public Flags fetchFlags(int msgno)
                 throws ProtocolException
Fetch the FLAGS for the given message.

抛出:
ProtocolException

fetchUID

public UID fetchUID(int msgno)
             throws ProtocolException
Fetch the IMAP UID for the given message.

抛出:
ProtocolException

fetchSequenceNumber

public UID fetchSequenceNumber(long uid)
                        throws ProtocolException
Get the sequence number for the given UID. A UID object containing the sequence number is returned. If the given UID is invalid, null is returned.

抛出:
ProtocolException

fetchSequenceNumbers

public UID[] fetchSequenceNumbers(long start,
                                  long end)
                           throws ProtocolException
Get the sequence numbers for UIDs ranging from start till end. UID objects that contain the sequence numbers are returned. If no UIDs in the given range are found, an empty array is returned.

抛出:
ProtocolException

fetchSequenceNumbers

public UID[] fetchSequenceNumbers(long[] uids)
                           throws ProtocolException
Get the sequence numbers for UIDs ranging from start till end. UID objects that contain the sequence numbers are returned. If no UIDs in the given range are found, an empty array is returned.

抛出:
ProtocolException

fetch

public Response[] fetch(MessageSet[] msgsets,
                        String what)
                 throws ProtocolException
抛出:
ProtocolException

fetch

public Response[] fetch(int start,
                        int end,
                        String what)
                 throws ProtocolException
抛出:
ProtocolException

fetch

public Response[] fetch(int msg,
                        String what)
                 throws ProtocolException
抛出:
ProtocolException

copy

public void copy(MessageSet[] msgsets,
                 String mbox)
          throws ProtocolException
COPY command.

抛出:
ProtocolException

copy

public void copy(int start,
                 int end,
                 String mbox)
          throws ProtocolException
抛出:
ProtocolException

storeFlags

public void storeFlags(MessageSet[] msgsets,
                       Flags flags,
                       boolean set)
                throws ProtocolException
抛出:
ProtocolException

storeFlags

public void storeFlags(int start,
                       int end,
                       Flags flags,
                       boolean set)
                throws ProtocolException
抛出:
ProtocolException

storeFlags

public void storeFlags(int msg,
                       Flags flags,
                       boolean set)
                throws ProtocolException
Set the specified flags on this message.

抛出:
ProtocolException

search

public int[] search(MessageSet[] msgsets,
                    SearchTerm term)
             throws ProtocolException,
                    SearchException
Issue the given search criterion on the specified message sets. Returns array of matching sequence numbers. An empty array is returned if no matches are found.

参数:
msgsets - array of MessageSets
term - SearchTerm
返回:
array of matching sequence numbers.
抛出:
ProtocolException
SearchException

search

public int[] search(SearchTerm term)
             throws ProtocolException,
                    SearchException
Issue the given search criterion on all messages in this folder. Returns array of matching sequence numbers. An empty array is returned if no matches are found.

参数:
term - SearchTerm
返回:
array of matching sequence numbers.
抛出:
ProtocolException
SearchException

namespace

public Namespaces namespace()
                     throws ProtocolException
NAMESPACE Command.

抛出:
ProtocolException
另请参见:
"RFC2342"

getQuotaRoot

public Quota[] getQuotaRoot(String mbox)
                     throws ProtocolException
GETQUOTAROOT Command. Returns an array of Quota objects, representing the quotas for this mailbox and, indirectly, the quotaroots for this mailbox.

抛出:
ProtocolException
另请参见:
"RFC2087"

getQuota

public Quota[] getQuota(String root)
                 throws ProtocolException
GETQUOTA Command. Returns an array of Quota objects, representing the quotas for this quotaroot.

抛出:
ProtocolException
另请参见:
"RFC2087"

setQuota

public void setQuota(Quota quota)
              throws ProtocolException
SETQUOTA Command. Set the indicated quota on the corresponding quotaroot.

抛出:
ProtocolException
另请参见:
"RFC2087"

setACL

public void setACL(String mbox,
                   char modifier,
                   ACL acl)
            throws ProtocolException
SETACL Command.

抛出:
ProtocolException
另请参见:
"RFC2086"

deleteACL

public void deleteACL(String mbox,
                      String user)
               throws ProtocolException
DELETEACL Command.

抛出:
ProtocolException
另请参见:
"RFC2086"

getACL

public ACL[] getACL(String mbox)
             throws ProtocolException
GETACL Command.

抛出:
ProtocolException
另请参见:
"RFC2086"

listRights

public Rights[] listRights(String mbox,
                           String user)
                    throws ProtocolException
LISTRIGHTS Command.

抛出:
ProtocolException
另请参见:
"RFC2086"

myRights

public Rights myRights(String mbox)
                throws ProtocolException
MYRIGHTS Command.

抛出:
ProtocolException
另请参见:
"RFC2086"

idleStart

public void idleStart()
               throws ProtocolException
IDLE Command.

If the server supports the IDLE command extension, the IDLE command is issued and this method blocks until a response has been received. Once the first response has been received, the IDLE command is terminated and all responses are collected and handled and this method returns.

Note that while this method is blocked waiting for a response, no other threads may issue any commands to the server that would use this same connection.

抛出:
ProtocolException
从以下版本开始:
JavaMail 1.4.1
另请参见:
"RFC2177"

readIdleResponse

public Response readIdleResponse()
While an IDLE command is in progress, read a response sent from the server. The response is read with no locks held so that when the read blocks waiting for the response from the server it's not holding locks that would prevent other threads from interrupting the IDLE command.

从以下版本开始:
JavaMail 1.4.1

processIdleResponse

public boolean processIdleResponse(Response r)
                            throws ProtocolException
Process a response returned by readIdleResponse(). This method will be called with appropriate locks held so that the processing of the response is safe.

抛出:
ProtocolException
从以下版本开始:
JavaMail 1.4.1

idleAbort

public void idleAbort()
               throws ProtocolException
Abort an IDLE command. While one thread is blocked in readIdleResponse(), another thread will use this method to abort the IDLE command, which will cause the server to send the closing tag for the IDLE command, which readIdleResponse() and processIdleResponse() will see and terminate the IDLE state.

抛出:
ProtocolException
从以下版本开始:
JavaMail 1.4.1


Copyright © 2013. All Rights Reserved.