J2ME编的手机助手 文件下载解压缩以后,是一个NetBeans的工程文件,如果有NB的朋友,可以直接打开编辑 源文件在src目录下面,可执行文件在dist目录下 功能如下 1

源代码在线查看: note.java

软件大小: 413 K
上传用户: lhf123290507
关键词: NetBeans J2ME dist src
下载地址: 免注册下载 普通下载 VIP

相关代码

				/*
				 * Note.java
				 *
				 * Created on 2007年3月15日, 上午10:37
				 *
				 * To change this template, choose Tools | Template Manager
				 * and open the template in the editor.
				 */
				
				package net.bccn.account.model;
				
				import java.io.ByteArrayInputStream;
				import java.io.ByteArrayOutputStream;
				import java.io.DataInputStream;
				import java.io.DataOutputStream;
				import java.io.IOException;
				import java.util.Calendar;
				import java.util.Date;
				import javax.microedition.rms.RecordComparator;
				import net.bccn.account.util.Record;
				import net.bccn.account.util.Util;
				
				/**
				 *
				 * @author hadeslee
				 */
				public class Note implements Record{
				    private int id;
				    private String content;
				    private Date date;
				    private Date from;//起始日期
				    public static final String NAME="Note";
				    /** Creates a new instance of Note */
				    public Note() {
				        
				    }
				    
				    public void fromBytes(byte[] data) throws IOException {
				        ByteArrayInputStream bin=new ByteArrayInputStream(data);
				        DataInputStream din=new DataInputStream(bin);
				        String name=din.readUTF();
				        if(!name.equals(Note.NAME)){
				            return;
				        }
				        this.content=din.readUTF();
				        date=new Date();
				        date.setTime(din.readLong());
				        din.close();
				    }
				    public void setFromDate(Date date){
				        from=date;
				    }
				    public Date getFromDate(){
				        return from;
				    }
				    public byte[] toBytes() throws IOException {
				        ByteArrayOutputStream bout=new ByteArrayOutputStream();
				        DataOutputStream dout=new DataOutputStream(bout);
				        dout.writeUTF(Note.NAME);
				        dout.writeUTF(content);
				        dout.writeLong(date.getTime());
				        dout.flush();
				        return bout.toByteArray();
				    }
				    
				    public int getID() {
				        return id;
				    }
				    
				    public void setID(int id) {
				        this.id=id;
				    }
				    
				    public Record getEmptyRecord() {
				        return new Note();
				    }
				    
				    public boolean matches(byte[] b) {
				        Note demo=new Note();
				        try{
				            demo.fromBytes(b);
				            if(demo.content==null){
				                return false;
				            }else{
				                if(this.date!=null){
				                    if(this.from!=null){
				                        long demoLong=(demo.getDate().getTime()+Util.OFF_SET)/86400000;
				                        long fromLong=(from.getTime()+Util.OFF_SET)/86400000;
				                        long toLong=(date.getTime()+Util.OFF_SET)/86400000;
				                        if(demoLong>=fromLong&&demoLong				                        else
				                            return false;
				                    }else{
				                        if((this.getDate().getTime()+Util.OFF_SET)/86400000==
				                                (demo.getDate().getTime()+Util.OFF_SET)/86400000){
				                        } else{
				                            return false;
				                        }
				                        
				                    }
				                }
				                return (this.content!=null?demo.content.indexOf(this.content)!=-1:true);
				                
				            }
				        } catch(Exception exe){
				            return false;
				        }
				    }
				    public int compare(byte[] b, byte[] b0) {
				        Note n1=new Note();
				        Note n2=new Note();
				        try{
				            n1.fromBytes(b);
				            n2.fromBytes(b0);
				            if(n1.date.getTime()>n2.date.getTime()){
				                return RecordComparator.FOLLOWS;
				            }else if(n1.date.getTime()				                return RecordComparator.PRECEDES;
				            }else
				                return RecordComparator.EQUIVALENT;
				        } catch(Exception exe){
				            return RecordComparator.EQUIVALENT;
				        }
				    }
				    
				    public String getContent() {
				        return content;
				    }
				    
				    public void setContent(String content) {
				        this.content = content;
				    }
				    
				    public Date getDate() {
				        return date;
				    }
				    
				    public void setDate(Date date) {
				        this.date = date;
				    }
				    private String getDateString(){
				        Calendar cal=Calendar.getInstance();
				        cal.setTime(date);
				        return ""+cal.get(Calendar.YEAR)+"-"+(cal.get(Calendar.MONTH)+1)+
				                "-"+cal.get(Calendar.DATE);
				    }
				    public String toString(){
				        return getDateString()+":"+content;
				    }
				}
							

相关资源