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

📄 cookie.java

📁 开发框架。 一.说明: 此框架的意图是解决手机软件开发中常遇到
💻 JAVA
字号:
package org.gggeye.easymf.net;

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

/**
 * a cookie stored on the mobile device, cookie is used to maintain the states between client and server
 * @author mingjava
 * @version 0.1 05/06/2006
 */
public class Cookie {
    
    private String path = "";
    private String name = "";
    private String value = "";
    private long expire = 1000000000;
    /** Creates a new instance of Cookie */
    public Cookie() {
    }
    
    public String getPath() {
        return path;
    }
    
    public void setPath(String path) {
        this.path = path;
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public String getValue() {
        return value;
    }
    
    public void setValue(String value) {
        this.value = value;
    }
    
    public void serialize(DataOutputStream dos) throws IOException{
        dos.writeUTF(name);
        dos.writeUTF(value);
        dos.writeUTF(path);
        dos.writeLong(expire);
    }
    
    public static Cookie deserialize(DataInputStream dis) throws IOException{
        Cookie cookie = new Cookie();
        cookie.name = dis.readUTF();
        cookie.value = dis.readUTF();
        cookie.path = dis.readUTF();
        cookie.expire = dis.readLong();
        return cookie;
    }

    public long getExpire() {
        return expire;
    }

    public void setExpire(long expire) {
        this.expire = expire;
    }
    //for debug
    public String toString(){
        return name+"="+value+";expires="+new Date(expire).toString()+";path="+path;
    }
    
    public boolean isExpired(long now){
        return expire-now<0;
    }
    
    public boolean isExpired(){
        return expire-(new Date().getTime())<0;
    }
}

⌨️ 快捷键说明

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