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

📄 serializablecontact.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.cm.rms;

import com.funambol.mailclient.cm.Contact;
import com.funambol.mailclient.cm.ContactManagerException;
import com.funambol.storage.ComplexSerializer;
import com.funambol.storage.Serializable;
import com.funambol.util.Log;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

public class SerializableContact extends Contact implements Serializable{
    
    //-------------------------------------------------------------- Contructors
    public SerializableContact() {
        super();
    }
    
    public SerializableContact(
            String newNickName,
            String newFirstName,
            String newLastName,
            String newEmail_1,
            String newEmail_2,
            String newEmail_3,
            String newHomePhone,
            String newJobPhone,
            String newMobilePhone) throws ContactManagerException {
        super(  newNickName, 
                newFirstName, 
                newLastName,
                newEmail_1,
                newEmail_2,
                newEmail_3,
                newHomePhone,
                newJobPhone,
                newMobilePhone
                );
    }
    
    /**
     * Write object fields to the output stream.
     * Write the components for the first record
     * @param out Output stream
     * @throws IOException
     */
    public void serialize(DataOutputStream out) throws IOException {
        ComplexSerializer.writeField(out, this.getNickName());
        ComplexSerializer.writeField(out, this.getFirstName());
        ComplexSerializer.writeField(out, this.getLastName());
        ComplexSerializer.writeField(out, this.getDefaultEmail());
        ComplexSerializer.writeField(out, this.getEmail_2());
        ComplexSerializer.writeField(out, this.getEmail_3());
        ComplexSerializer.writeField(out, this.getHomePhone());
        ComplexSerializer.writeField(out, this.getJobPhone());
        ComplexSerializer.writeField(out, this.getMobilePhone());
    }
    
    /**
     * Read object field from the input stream.
     * @param in Input stream
     * @throws IOException
     */
    public void deserialize(DataInputStream in) throws IOException {
        this.setNickName(ComplexSerializer.readField(in));
        this.setFirstName(ComplexSerializer.readField(in));
        this.setLastName(ComplexSerializer.readField(in));
        try {
            this.setDefaultEmail(ComplexSerializer.readField(in));
        } catch (ContactManagerException ex) {
            Log.error("contact.deserialize: " + ex.toString());
            ex.printStackTrace();
        }
        this.setEmail_2(ComplexSerializer.readField(in));
        this.setEmail_3(ComplexSerializer.readField(in));
        this.setHomePhone(ComplexSerializer.readField(in));
        this.setJobPhone(ComplexSerializer.readField(in));
        this.setMobilePhone(ComplexSerializer.readField(in));
    }
}

⌨️ 快捷键说明

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