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

📄 folderinfo.java

📁 The Funambol J2ME Mail Client aims to be a light, easy to use, free email client for J2ME devices.
💻 JAVA
字号:
/*
 * Copyright (C) 2006-2007 Funambol
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package com.funambol.mailclient.mm;

import com.funambol.mail.Message;
import com.funambol.mail.Folder;
import com.funambol.mail.Store;

import com.funambol.mail.MailException;
import com.funambol.mail.StoreFactory;
import com.funambol.storage.Serializable;

import com.funambol.util.Log;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

/**
 * Folder information, used by the UI as a cache of the stored folders.
 */
public class FolderInfo implements Serializable {
    
    /** Visible name */
    private String name;
    
    /** Message Store */
    private Store store;
    
    /**
     * Default contructor
     */
    public FolderInfo(){
        name = new String();
        store = StoreFactory.getStore();
    }
    
    
    /**
     * Initialize a FolderInfo instance with full references
     * @param name is the name of the folder
     * @param store is this FolderInfo related store
     */
    public FolderInfo(String name, Store store){
        this.name = name;
        this.store = store;
    }
    
    /**
     * Accessor method. Get the Complete Folder related to this 
     * FolderInfo instance
     * @return Folder (complete object) represented by this MessageInfo instance
     * @throws MailException if errors occur retrieving the folder ralated to 
     * the given name
     */
    public Folder getFolder() throws MailException {
        return store.getFolder(name);
    }
    
    /**
     * Get the basic informations for the messages contained in
     * this Folder
     * @return MessageInfo[] related to this folder's messages
     * @throws MailException if errors occur retrieving the folder ralated to 
     * the given name
     * @throws MailException if theare are problem creating MessageInfo array
     */
    public MessageInfo[] getMsgList() throws MailException {
        Folder f = store.getFolder(name);
        Message[] list = f.getMsgHeaders();
        int len = (list != null) ? list.length : 0 ;
        MessageInfo[] ret = new MessageInfo[len];
        
        for(int i=0; i<len; i++) {
            ret[i] = new MessageInfo(list[i], this);
        }
        
        return ret;
    }
    
    /**
     * To Be Implemented for Folder Children implementation
     * @return the basic information for the children of this folder
     */
    public FolderInfo[] getChildren() {
        return null;
    }
    
    /**
     * TO BE IMPLEMENTED
     * Set the listener for this FolderInfo instance related Folder 
     * @param fl is the listener to be added to this FolderInfo related Folder
     
    public void setListener(FolderListener fl) {
    }*/
    
    /**
     * TO BE IMPLEMENTED
     * Removes the listener for this FolderInfo instance related Folder 
     * @param fl is the listener to be removed from this FolderInfo 
     * related Folder
     
    public boolean removeListener(FolderListener fl) {
        return false;
    }*/
    
    /**
     * Accessor method to get the FolderInfo name
     * @return the name of this FolderInfo instance' related Folder
     */
    public String getName() {
        return name;
    }
    
    /**
     * Serializes the folderinfo and writes it to the given outputstream
     * @param out the DataOutputStream to write
     * @throw IOException if an error occurs during serialization
     */
    public void serialize(DataOutputStream out) throws IOException {
        out.writeUTF(name);
    }
    
    /**
     * Deserializes the messageinfo objects reading the given input stream
     * @param in the DataInputStream to read
     * @throw IOException if an error occurs during deserialization
     */
    public void deserialize(DataInputStream in) throws IOException {
        //Deserialize object from input stream 
        this.name = in.readUTF();
        //Set the object reference to the current instance of Store. 
        this.store = StoreFactory.getStore();
    }
 }

⌨️ 快捷键说明

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