⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 imapconnection.java

📁 linux下建立JAVA虚拟机的源码KAFFE
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                long uid = Long.parseLong((String) code.get(i + 2));                uidplus.appenduid(uidvalidity, uid);              }            else if ("COPYUID".equals(item) && i < len - 3)              {                long uidvalidity =                  Long.parseLong((String) code.get(i + 1));                MessageSetTokenizer oldUIDs =                  new MessageSetTokenizer((String) code.get(i + 2));                MessageSetTokenizer newUIDs =                  new MessageSetTokenizer((String) code.get(i + 3));                while (oldUIDs.hasNext())                  {                    long oldUID = ((Long) oldUIDs.next()).longValue();                    long newUID = ((Long) newUIDs.next()).longValue();                    uidplus.copyuid(uidvalidity, oldUID, newUID);                  }              }          }        else          {            processUIDPlus((List) item, uidplus);          }      }  }    /**   * Request a checkpoint of the currently selected mailbox.   */  public void check()    throws IOException  {    invokeSimpleCommand(CHECK);  }    /**   * Permanently remove all messages that have the \Deleted flags set,   * and close the mailbox.   * @return true if successful, false if no mailbox was selected   */  public boolean close()    throws IOException  {    return invokeSimpleCommand(CLOSE);  }    /**   * Permanently removes all messages that have the \Delete flag set.   * @return the numbers of the messages expunged   */  public int[] expunge()    throws IOException  {    String tag = newTag();    sendCommand(tag, EXPUNGE);    List numbers = new ArrayList();    while (true)      {        IMAPResponse response = readResponse();        String id = response.getID();        if (response.isUntagged())          {            if (id == EXPUNGE)              {                numbers.add(new Integer(response.getCount()));              }            else              {                asyncResponses.add(response);              }          }        else if (tag.equals(response.getTag()))          {            processAlerts(response);            if (id == OK)              {                int len = numbers.size();                int[] mn = new int[len];                for (int i = 0; i < len; i++)                  {                    mn[i] = ((Integer) numbers.get(i)).intValue();                  }                return mn;              }            else              {                throw new IMAPException(id, response.getText());              }          }        else          {            throw new IMAPException(id, response.getText());          }      }  }    /**   * Searches the currently selected mailbox for messages matching the   * specified criteria.   */  public int[] search(String charset, String[] criteria)    throws IOException  {    String tag = newTag();    StringBuffer buffer = new StringBuffer(SEARCH);    buffer.append(' ');    if (charset != null)      {        buffer.append(charset);        buffer.append(' ');      }    for (int i = 0; i < criteria.length; i++)      {        if (i > 0)          {            buffer.append(' ');          }        buffer.append(criteria[i]);      }    sendCommand(tag, buffer.toString());    List list = new ArrayList();    while (true)      {        IMAPResponse response = readResponse();        String id = response.getID();        if (response.isUntagged())          {            if (id == SEARCH)              {                String text = response.getText();                if (text == null)                  {                    continue;                  }                try                  {                    int si = text.indexOf(' ');                    while (si != -1)                      {                        list.add(new Integer(text.substring(0, si)));                        text = text.substring(si + 1);                        si = text.indexOf(' ');                      }                    list.add(new Integer(text));                  }                catch (NumberFormatException e)                  {                    throw new IMAPException(id, "Expecting number: " + text);                  }              }            else              {                asyncResponses.add(response);              }          }        else if (tag.equals(response.getTag()))          {            processAlerts(response);            if (id == OK)              {                int len = list.size();                int[] mn = new int[len];                for (int i = 0; i < len; i++)                  {                    mn[i] = ((Integer) list.get(i)).intValue();                  }                return mn;              }            else              {                throw new IMAPException(id, response.getText());              }          }        else          {            throw new IMAPException(id, response.getText());          }      }  }    /**   * Retrieves data associated with the specified message in the mailbox.   * @param message the message number   * @param fetchCommands the fetch commands, e.g. FLAGS   */  public MessageStatus fetch(int message, String[] fetchCommands)    throws IOException  {    String ids = (message == -1) ? "*" : Integer.toString(message);    return fetchImpl(FETCH, ids, fetchCommands)[0];  }  /**   * Retrieves data associated with the specified range of messages in   * the mailbox.   * @param start the message number of the first message   * @param end the message number of the last message   * @param fetchCommands the fetch commands, e.g. FLAGS   */  public MessageStatus[] fetch(int start, int end, String[] fetchCommands)    throws IOException  {    StringBuffer ids = new StringBuffer();    ids.append((start == -1) ? '*' : start);    ids.append(':');    ids.append((end == -1) ? '*' : end);    return fetchImpl(FETCH, ids.toString(), fetchCommands);  }  /**   * Retrieves data associated with messages in the mailbox.   * @param messages the message numbers   * @param fetchCommands the fetch commands, e.g. FLAGS   */  public MessageStatus[] fetch(int[] messages, String[] fetchCommands)    throws IOException  {    StringBuffer ids = new StringBuffer();    for (int i = 0; i < messages.length; i++)      {        if (i > 0)          {            ids.append(',');          }        ids.append(messages[i]);      }    return fetchImpl(FETCH, ids.toString(), fetchCommands);  }  /**   * Retrieves data associated with the specified message in the mailbox.   * @param uid the message UID   * @param fetchCommands the fetch commands, e.g. FLAGS   */  public MessageStatus uidFetch(long uid, String[] fetchCommands)    throws IOException  {    String ids = (uid == -1L) ? "*" : Long.toString(uid);    return fetchImpl(UID + ' ' + FETCH, ids, fetchCommands)[0];  }    /**   * Retrieves data associated with the specified range of messages in   * the mailbox.   * @param start the message number of the first message   * @param end the message number of the last message   * @param fetchCommands the fetch commands, e.g. FLAGS   */  public MessageStatus[] uidFetch(long start, long end,                                   String[] fetchCommands)    throws IOException  {    StringBuffer ids = new StringBuffer();    ids.append((start == -1L) ? '*' : start);    ids.append(':');    ids.append((end == -1L) ? '*' : end);    return fetchImpl(UID + ' ' + FETCH, ids.toString(), fetchCommands);  }    /**   * Retrieves data associated with messages in the mailbox.   * @param uids the message UIDs   * @param fetchCommands the fetch commands, e.g. FLAGS   */  public MessageStatus[] uidFetch(long[] uids, String[] fetchCommands)    throws IOException  {    StringBuffer ids = new StringBuffer();    for (int i = 0; i < uids.length; i++)      {        if (i > 0)          {            ids.append(',');          }        ids.append(uids[i]);      }    return fetchImpl(UID + ' ' + FETCH, ids.toString(), fetchCommands);  }    private MessageStatus[] fetchImpl(String cmd, String ids,                                    String[] fetchCommands)    throws IOException  {    String tag = newTag();    StringBuffer buffer = new StringBuffer(cmd);    buffer.append(' ');    buffer.append(ids);    buffer.append(' ');    buffer.append('(');    for (int i = 0; i < fetchCommands.length; i++)      {        if (i > 0)          {            buffer.append(' ');          }        buffer.append(fetchCommands[i]);      }    buffer.append(')');    sendCommand(tag, buffer.toString());    List list = new ArrayList();    while (true)      {        IMAPResponse response = readResponse();        String id = response.getID();        if (response.isUntagged())          {            if (id == FETCH)              {                int msgnum = response.getCount();                List code = response.getResponseCode();                MessageStatus status = new MessageStatus(msgnum, code);                list.add(status);              }            else              {                asyncResponses.add(response);              }          }        else if (tag.equals(response.getTag()))          {            processAlerts(response);            if (id == OK)              {                MessageStatus[] statuses = new MessageStatus[list.size()];                list.toArray(statuses);                return statuses;              }            else              {                throw new IMAPException(id, response.getText());              }          }        else          {            throw new IMAPException(id, response.getText());          }      }  }  /**   * Alters data associated with the specified message in the mailbox.   * @param message the message number   * @param flagCommand FLAGS, +FLAGS, -FLAGS(or .SILENT versions)   * @param flags message flags to set   * @return the message status   */  public MessageStatus store(int message, String flagCommand,                             String[] flags)    throws IOException  {    String ids = (message == -1) ? "*" : Integer.toString(message);    return storeImpl(STORE, ids, flagCommand, flags)[0];  }  /**   * Alters data associated with the specified range of messages in the   * mailbox.   * @param start the message number of the first message   * @param end the message number of the last message   * @param flagCommand FLAGS, +FLAGS, -FLAGS(or .SILENT versions)   * @param flags message flags to set   * @return a list of message-number to current flags   */  public MessageStatus[] store(int start, int end, String flagCommand,                               String[] flags)    throws IOException  {    StringBuffer ids = new StringBuffer();    ids.append((start == -1) ? '*' : start);    ids.append(':');    ids.append((end == -1) ? '*' : end);    return storeImpl(STORE, ids.toString(), flagCommand, flags);  }  /**   * Alters data associated with messages in the mailbox.   * @param messages the message numbers   * @param flagCommand FLAGS, +FLAGS, -FLAGS(or .SILENT versions)   * @param flags message flags to set   * @return a list of message-number to current flags   */  public MessageStatus[] store(int[] messages, String flagCommand,                               String[] flags)    throws IOException  {    StringBuffer ids = new StringBuffer();    for (int i = 0; i < messages.length; i++)      {        if (i > 0)          {            ids.append(',');          }        ids.append(messages[i]);      }    return storeImpl(STORE, ids.toString(), flagCommand, flags);  }    /**   * Alters data associated with the specified message in the mailbox.   * @param uid the message UID   * @param flagCommand FLAGS, +FLAGS, -FLAGS(or .SILENT versions)   * @param flags message flags to set   * @return the message status   */  public MessageStatus uidStore(long uid, String flagCommand,                                String[] flags)    throws IOException  {    String ids = (uid == -1L) ? "*" : Long.toString(uid);    return storeImpl(UID + ' ' + STORE, ids, flagCommand, flags)[0];  }  /**   * Alters data associated with the specified range of messages in the   * mailbox.   * @param start the UID of the first message   * @param end the UID of the last message   * @param flagCommand FLAGS, +FLAGS, -FLAGS(or .SILENT versions)   * @param flags message flags to set   * @return a list of message-number to current flags   */  public MessageStatus[] uidStore(long start, long end, String flagCommand,                                  String[] flags)    throws IOException  {    StringBuffer ids = new StringBuffer();    ids.append((start == -1L) ? '*' : start);    ids.append(':');    ids.append((end == -1L) ? '*' : end);    return storeImpl(UID + ' ' + STORE, ids.toString(), flagCommand, flags);  }  /**   * Alters data associated with messages in the mailbox.   * @param uids the message UIDs   * @param flagCommand FLAGS, +FLAGS, -FLAGS(or .SILENT versions)   * @param flags message flags to set   * @return a list of message-number to current flags   */  public MessageStatus[] uidStore(long[] uids, String flagCommand,                                  String[] flags)    throws IOException  {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -