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

📄 usersorter.java

📁 J2ME MIDP 2.0 无线设备编程的一些源码
💻 JAVA
字号:
//UserSorter.java
import javax.microedition.rms.*;

public class UserSorter implements RecordComparator
{
    public static final int SORTBYNAME=0;
    public static final int SORTBYEMAIL=1;
    protected int sortType;
    protected RecordData rData;
    public UserSorter(int sType)
    {
        sortType= sType;
        rData = new RecordData();
    }
    //实现记录之间的比较
    public int compare(byte[] rec1, byte[] rec2)
    {
        String temp1="",temp2="";
        if( SORTBYNAME == sortType)
        {
            rData.ReadByte(rec1);
            temp1 = rData.name;
            rData.ReadByte(rec2);
            temp2 = rData.name;
        }
        if( SORTBYEMAIL == sortType)
        {
            rData.ReadByte(rec1);
            temp1 = rData.email;
            rData.ReadByte(rec2);
            temp2 = rData.email;
        }
        System.out.println("trace name1="+ temp1);
        System.out.println("trace name2="+ temp2);

        int compare = temp1.compareTo(temp2);
        if(compare <0)
            return FOLLOWS;
        if(compare>0) 
            return PRECEDES;
        return EQUIVALENT;
    }
}

⌨️ 快捷键说明

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