Mobile 诺基亚:错误预验证java/langnoclassdeffounderror:java/lang/Compariable for java me平台

Mobile 诺基亚:错误预验证java/langnoclassdeffounderror:java/lang/Compariable for java me平台,mobile,java-me,compiler-errors,nokia,preverify,Mobile,Java Me,Compiler Errors,Nokia,Preverify,获取错误预验证类java/langnoclassdeffounderror:java/lang/Compariable for java me平台 我已将J2SE代码迁移到J2ME代码。我知道一些J2SE函数在J2ME平台上不起作用。因此,我已经对可比较的类进行了交叉检查。它包含在JavaME库中 现在,我无法解决错误。请帮帮我 请参考以下代码: import java.io.Serializable; import aiproject.CompareToBuilder; import aip

获取错误预验证类java/langnoclassdeffounderror:java/lang/Compariable for java me平台

我已将J2SE代码迁移到J2ME代码。我知道一些J2SE函数在J2ME平台上不起作用。因此,我已经对可比较的类进行了交叉检查。它包含在JavaME库中

现在,我无法解决错误。请帮帮我

请参考以下代码:

import java.io.Serializable;

import aiproject.CompareToBuilder;
import aiproject.EqualsBuilder;
import aiproject.HashCodeBuilder;
import aiproject.ToStringBuilder;


public class WordProbability implements Comparable, Serializable {


    private static final int UNDEFINED = -1;

    private String word = "";
    private String category = ICategorisedCategorizer.DEFAULT_CATEGORY;

    private long matchingCount = UNDEFINED;
    private long nonMatchingCount = UNDEFINED;

    private double probability = ICategorizer.NEUTRAL_PROBABILITY;

    public WordProbability() {
        setMatchingCount(0);
        setNonMatchingCount(0);
    }

    public WordProbability(String w) {
        setWord(w);
        setMatchingCount(0);
        setNonMatchingCount(0);
    }

    public WordProbability(String c, String w) {
        setCategory(c);
        setWord(w);
        setMatchingCount(0);
        setNonMatchingCount(0);
    }

    public WordProbability(String w, double probability) {
        setWord(w);
        setProbability(probability);
    }

    public WordProbability(String w, long matchingCount, long nonMatchingCount) {
        setWord(w);
        setMatchingCount(matchingCount);
        setNonMatchingCount(nonMatchingCount);
    }

    public void setWord(String w) {
        this.word = w;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public void setProbability(double probability) {
        this.probability = probability;
        this.matchingCount = UNDEFINED;
        this.nonMatchingCount = UNDEFINED;
    }

    public void setMatchingCount(long matchingCount) {
        if (matchingCount < 0) {
            throw new IllegalArgumentException("matchingCount must be greater than 0");
        }
        this.matchingCount = matchingCount;
        calculateProbability();
    }

    public void setNonMatchingCount(long nonMatchingCount) {
        if (nonMatchingCount < 0) {
            throw new IllegalArgumentException("nonMatchingCount must be greater than 0");
        }
        this.nonMatchingCount = nonMatchingCount;
        calculateProbability();
    }

    public void registerMatch() {
        if (matchingCount == Long.MAX_VALUE) {
            throw new UnsupportedOperationException("Long.MAX_VALUE reached, can't register more matches");
        }
        matchingCount++;
        calculateProbability();
    }

    public void registerNonMatch() {
        if (nonMatchingCount == Long.MAX_VALUE) {
            throw new UnsupportedOperationException("Long.MAX_VALUE reached, can't register more matches");
        }
        nonMatchingCount++;
        calculateProbability();
    }

    private void calculateProbability() {
       String method = "calculateProbability() ";
        double result = ICategorizer.NEUTRAL_PROBABILITY;
        if (matchingCount == 0) {
            if (nonMatchingCount == 0) {
                result = ICategorizer.NEUTRAL_PROBABILITY;
            } else {
                result = ICategorizer.LOWER_BOUND;
            }
        } else {
            result = BayesianCategorizer.normaliseSignificance((double) matchingCount / (double) (matchingCount + nonMatchingCount));
        }

        probability = result;
    }

    /**
     * output
     */
    public double getProbability() {
        return probability;
    }

    public long getMatchingCount() {

        if (matchingCount == UNDEFINED) {
            throw new UnsupportedOperationException("MatchingCount has not been defined");
        }

        return matchingCount;
    }

    public long getNonMatchingCount() {

        if (nonMatchingCount == UNDEFINED) {
            throw new UnsupportedOperationException("nonMatchingCount has not been defined");
        }

        return nonMatchingCount;
    }

    public String getWord() {
        return word;
    }

    public String getCategory() {
        return category;
    }

    public boolean equals(Object o) {
        if (!(o instanceof WordProbability)) {
            return false;
        }
        WordProbability rhs = (WordProbability) o;
        return new EqualsBuilder().append(getWord(), rhs.getWord()).append(getCategory(), rhs.getCategory()).isEquals();
    }

    public int compareTo(java.lang.Object o) {
        if (!(o instanceof WordProbability)) {
            throw new ClassCastException(o.getClass() + " is not a " + this.getClass());
        }
        WordProbability rhs = (WordProbability) o;
        return new CompareToBuilder().append(this.getCategory(), rhs.getCategory()).append(this.getWord(), rhs.getWord()).toComparison();
    }

    public String toString() {
        return new ToStringBuilder(this).append("word", word).append("category", category).append("probability", probability).append("matchingCount", matchingCount).append("nonMatchingCount", nonMatchingCount).toString();
    }

    public int hashCode() {
        return new HashCodeBuilder(17, 37).append(word).append(category).toHashCode();
    }

}
import java.io.Serializable;
导入aiproject.CompareToBuilder;
导入aiproject.EqualsBuilder;
导入aiproject.HashCodeBuilder;
导入aiproject.ToStringBuilder;
公共类WordProbability实现了可比较的、可序列化的{
私有静态final int UNDEFINED=-1;
私有字符串单词=”;
私有字符串类别=ICategorisedCategorizer.DEFAULT_类别;
私有长匹配计数=未定义;
私有长非匹配计数=未定义;
私人双重概率=ICategorizer.NEUTRAL_概率;
公共词汇概率(){
设置匹配计数(0);
设置非匹配计数(0);
}
公共字概率(字符串w){
设定字(w);
设置匹配计数(0);
设置非匹配计数(0);
}
公共字概率(字符串c、字符串w){
(c)类;
设定字(w);
设置匹配计数(0);
设置非匹配计数(0);
}
公共字概率(字符串w,双概率){
设定字(w);
概率(概率);
}
公共字概率(字符串w、长匹配计数、长非匹配计数){
设定字(w);
设置匹配计数(匹配计数);
设置非匹配计数(非匹配计数);
}
公共无效设置字(字符串w){
this.word=w;
}
公共无效集合类别(字符串类别){
this.category=类别;
}
公共概率(双重概率){
这个概率=概率;
this.matchingCount=未定义;
this.nonMatchingCount=未定义;
}
公共无效设置匹配计数(长匹配计数){
如果(匹配计数<0){
抛出新的IllegalArgumentException(“matchingCount必须大于0”);
}
this.matchingCount=matchingCount;
计算可能性();
}
公共无效集合非匹配计数(长非匹配计数){
if(非匹配计数<0){
抛出新的IllegalArgumentException(“非匹配计数必须大于0”);
}
this.nonMatchingCount=nonMatchingCount;
计算可能性();
}
公共无效注册表匹配(){
if(matchingCount==Long.MAX_值){
抛出新的UnsupportedOperationException(“已达到Long.MAX_值,无法注册更多匹配项”);
}
matchingCount++;
计算可能性();
}
public void registerNonMatch(){
if(nonMatchingCount==Long.MAX_值){
抛出新的UnsupportedOperationException(“已达到Long.MAX_值,无法注册更多匹配项”);
}
非匹配计数++;
计算可能性();
}
私有无效计算概率(){
String method=“calculateProbability()”;
双重结果=Igategorizer.NEUTRAL_概率;
如果(匹配计数==0){
如果(非匹配计数==0){
结果=ICategorizer.NEUTRAL_概率;
}否则{
结果=ICategorizer.下限;
}
}否则{
结果=BayesianCategorizer.normalise显著性((双)匹配计数/(双)(匹配计数+非匹配计数));
}
概率=结果;
}
/**
*输出
*/
公共双概率{
返回概率;
}
公共长getMatchingCount(){
if(matchingCount==未定义){
抛出新的UnsupportedOperationException(“未定义匹配计数”);
}
返回匹配计数;
}
公共长getNonMatchingCount(){
if(nonMatchingCount==未定义){
抛出新的UnsupportedOperationException(“未定义非匹配计数”);
}
返回非匹配计数;
}
公共字符串getWord(){
返回词;
}
公共字符串getCategory(){
退货类别;
}
公共布尔等于(对象o){
if(!(o单词概率的实例)){
返回false;
}
字概率rhs=(字概率)o;
返回新的equalBuilder().append(getWord(),rhs.getWord()).append(getCategory(),rhs.getCategory()).isEquals();
}
public int compareTo(java.lang.Object o){
if(!(o单词概率的实例)){
抛出新的ClassCastException(o.getClass()+”不是“+this.getClass());
}
字概率rhs=(字概率)o;
返回新的CompareToBuilder().append(this.getCategory(),rhs.getCategory()).append(this.getWord(),rhs.getWord()).toComparison();
}
公共字符串toString(){
返回新的ToStringBuilder(this).append(“word”,word).append(“category”,category).append(“probability”,probability).append(“matchingCount”,matchingCount).append(“nonMatchingCount”,nonMatchingCount).toString();
}
公共int hashCode(){
返回新的HashCodeBuilder(17,37).append(word).append(category).toHashCode();
}
}

在JavaME的javadocs中,我看不到可比性。 所以我认为它不存在

你在哪里找到的? 可能是某个Lib或JSR包含了它。然后您需要将其包括在项目设置中

如果您只需要这个接口,您可以自己定义它