1
我正在将Java(JDK 1.5)“枚举”转换为Java ME(JDK 1.4)。Java ME:将基本JDK 1.5“枚举”对象转换为Java ME CLDC-1.1/IMP-NG(JDK 1.4)
很多人都建议使用retroweaver将JDK 1.5库解析为JDK 1.4,但使用它时遇到了很多问题,并且由于硬件限制,我真的想完全控制我的项目。
什么是翻译它或找到等价物的最佳方法?
/**
Authentication enumerates the authentication levels.
*/
public enum Authentication
{
/**
No authentication is used.
*/
NONE,
/**
Low authentication is used.
*/
LOW,
/**
High authentication is used.
*/
HIGH,
/*
* High authentication is used. Password is hashed with MD5.
*/
HIGH_MD5,
/*
* High authentication is used. Password is hashed with SHA1.
*/
HIGH_SHA1,
/*
* High authentication is used. Password is hashed with GMAC.
*/
HIGH_GMAC;
/*
* Get integer value for enum.
*/
public int getValue()
{
return this.ordinal();
}
/*
* Convert integer for enum value.
*/
public static Authentication forValue(int value)
{
return values()[value];
}
}
这实际上取决于您在代码中依赖枚举的独特功能的程度。如果没有任何东西想要序列化或做任何事情,你可以用类来模拟枚举并实现你正在使用的特定功能。如果你不需要类型安全,你甚至可以决定用普通常量替换枚举。 – RealSkeptic
我用普通常量替换所有东西可能会起作用。我会试着看看它是否有效。 TNX –