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

📄 jwmafolderlist.java

📁 java windows mda and reveus
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*** * jwma Java WebMail * Copyright (c) 2000-2003 jwma team * * jwma is free software; you can distribute and use this source * under the terms of the BSD-style license received along with * the distribution. ***/package dtw.webmail.model;import dtw.webmail.util.StringUtil;import org.apache.log4j.Logger;import javax.mail.Folder;import javax.mail.MessagingException;import java.util.*;/** * Class implementing a list for <tt>JwmaFolder</tt> * instances. * It has caching functionality, which reduces the need to * reconstruct the list after moving and deleting folders. * * @author Dieter Wimberger * @version 0.9.7 07/02/2003 */class JwmaFolderList {  //logging  private static Logger log = Logger.getLogger(JwmaFolderList.class);  //class attributes  public static boolean c_SubscribedOnly = true;  //instance attributes  private Folder m_Folder;  private List m_Folders;  private boolean m_Recursive;  private boolean m_SubscribedOnly = c_SubscribedOnly;  private String m_Pattern;  /**   * Constructs a new <tt>JwmaFolderList</tt> instance.   *   * @param f the folder to be listed as <tt>javax.mail.Folder</tt>.   * @param recurse flags if the list should be build recursive.   */  private JwmaFolderList(Folder f, boolean recurse) {    m_Recursive = recurse;    if (recurse) {      m_Pattern = "*";    } else {      m_Pattern = "%";    }    m_Folder = f;  }//JwmaFolderList  /**   * Tests if this <tt>JwmaFolderList</tt> will work   * only with subscribed folders.   *   * @return true if subscribed only, false otherwise.   */  public boolean isSubscribedOnly() {    return m_SubscribedOnly;  }//isSubscribedOnly  /**   * Sets or resets the flag for working only with   * subscribed folders.   */  public void setSubscribedOnly(boolean subscribedOnly) {    m_SubscribedOnly = subscribedOnly;  }//setSubscribedOnly  /**   * Sets the pattern used for listing folders.   *   * @return the pattern as <tt>String</tt>.   */  public String getPattern() {    return m_Pattern;  }//getPattern  /**   * Returns the pattern for listing folders.   *   * @param pattern the pattern as <tt>String</tt>.   */  public void setPattern(String pattern) {    m_Pattern = pattern;  }//setPattern  /**   * Returns an Iterator over the <tt>JwmaFolder</tt> instances   * contained within this list.   *   * @return the <tt>Iterator</tt> over the items in this list.   */  public Iterator iterator() {    return m_Folders.listIterator();  }//iterator  /**   * Returns the size of this list.   *   * @return the size of this list.   */  public int size() {    return m_Folders.size();  }//getSize  /**   * Returns a sublist of this list, that contains only   * the folders of the given type.   *   * @param type the requested folder type as <tt>int</tt>.   *   * @return the list containing all folders of the given type as   *         <tt>List</tt>.   */  public List sublist(int type) {    if (type == JwmaFolder.TYPE_ALL) {      return m_Folders;    } else {      List folders = new ArrayList();      for (Iterator iter = m_Folders.listIterator(); iter.hasNext();) {        JwmaFolderImpl f = (JwmaFolderImpl) iter.next();        switch (type) {          case JwmaFolder.TYPE_MESSAGE_CONTAINER:            if (f.isType(JwmaFolder.TYPE_MAILBOX)                || f.isType(JwmaFolder.TYPE_MIXED)) {              folders.add(f);            }            break;          case JwmaFolder.TYPE_FOLDER_CONTAINER:            if (f.isType(JwmaFolder.TYPE_FOLDER)                || f.isType(JwmaFolder.TYPE_MIXED)) {              folders.add(f);            }            break;          default:            if (f.isType(type)) {              folders.add(f);            }        }      }      //force sort      Collections.sort(folders, LEXOGRAPHICAL);      return folders;    }  }//sublist  /**   * Returns a sublist of this list, that contains only   * the folders of the given type.   *   * @param type the requested folder type as <tt>int</tt>.   *   * @return the list containing all folders of the given type as   *         <tt>List</tt>.   */  public List sublist(int type, boolean subscribed) {    if (type == JwmaFolder.TYPE_ALL) {      return m_Folders;    } else {      List folders = new ArrayList();      for (Iterator iter = m_Folders.listIterator(); iter.hasNext();) {        JwmaFolderImpl f = (JwmaFolderImpl) iter.next();        switch (type) {          case JwmaFolder.TYPE_MESSAGE_CONTAINER:            if (f.isType(JwmaFolder.TYPE_MAILBOX)                || f.isType(JwmaFolder.TYPE_MIXED)) {              if (subscribed) {                if (f.isSubscribed()) {                  folders.add(f);                }              } else {                folders.add(f);              }            }            break;          case JwmaFolder.TYPE_FOLDER_CONTAINER:            if (f.isType(JwmaFolder.TYPE_FOLDER)                || f.isType(JwmaFolder.TYPE_MIXED)) {              if (subscribed) {                if (f.isSubscribed()) {                  folders.add(f);                }              } else {                folders.add(f);              }            }            break;          default:            if (f.isType(type)) {              if (subscribed) {                if (f.isSubscribed()) {                  folders.add(f);                }              } else {                folders.add(f);              }            }        }      }      //force sort      Collections.sort(folders, LEXOGRAPHICAL);      return folders;    }  }//sublist  /**   * Returns a sublist of this list, that contains only   * the folders of the given type, filtering the given   * folder.   * This method can be used to obtain targets for moving   * messages or other folders.   *   * @param type the requested folder type as <tt>int</tt>.   * @param folder the <tt>JwmaFolderImpl</tt> instance to be filtered   *        from the list.   *   * @return the list containing all folders of the given type as   *         <tt>List</tt>.   */  public List sublist(int type, JwmaFolderImpl folder) {    List folders = new ArrayList();    for (Iterator iter = m_Folders.listIterator(); iter.hasNext();) {      JwmaFolderImpl f = (JwmaFolderImpl) iter.next();      if (f.equals(folder)) {        //filter this one        continue;      }      switch (type) {        case JwmaFolder.TYPE_ALL:          folders.add(f);          break;        case JwmaFolder.TYPE_MESSAGE_CONTAINER:          if (f.isType(JwmaFolder.TYPE_MAILBOX)              || f.isType(JwmaFolder.TYPE_MIXED)) {            folders.add(f);          }          break;        case JwmaFolder.TYPE_FOLDER_CONTAINER:          if (f.isType(JwmaFolder.TYPE_FOLDER)              || f.isType(JwmaFolder.TYPE_MIXED)) {            folders.add(f);          }          break;        default:          if (f.isType(type)) {            folders.add(f);          }      }    }    //force sort    Collections.sort(folders, LEXOGRAPHICAL);    return folders;  }//sublist  /**   * Returns a sublist of this list, that contains only   * the folders of the given type, filtering the given   * folder.   * This method can be used to obtain targets for moving   * messages or other folders.   *   * @param type the requested folder type as <tt>int</tt>.   * @param folder the <tt>JwmaFolderImpl</tt> instance to be filtered   *        from the list.   *   * @return the list containing all folders of the given type as   *         <tt>List</tt>.   */  public List sublist(int type, JwmaFolderImpl folder, boolean subscribed) {    List folders = new ArrayList();    for (Iterator iter = m_Folders.listIterator(); iter.hasNext();) {      JwmaFolderImpl f = (JwmaFolderImpl) iter.next();      if (f.equals(folder)) {        //filter this one        continue;      }      switch (type) {        case JwmaFolder.TYPE_ALL:          if (subscribed) {            if (f.isSubscribed()) {              folders.add(f);            }          } else {

⌨️ 快捷键说明

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