Java ME: transform basic JDK 1.5 "enum" object into Java ME CLDC-1.1/IMP-NG (JDK 1.4) -


i'm translating java (jdk 1.5) "enum" java me (jdk 1.4).

many people have suggested retroweaver parse jdk 1.5 libraries jdk 1.4 i've got lot of problems using , want full control of project due hw limitations.

what's best way translate or find equivalent?

/**   authentication enumerates authentication levels. */ public enum authentication {     /**       no authentication used.     */     none,     /**       low authentication used.     */     low,     /**       high authentication used.     */     high,     /*      * high authentication used. password hashed md5.      */     high_md5,     /*      * high authentication used. password hashed sha1.      */     high_sha1,     /*      * high authentication used. password hashed gmac.      */     high_gmac;      /*      * integer value enum.      */     public int getvalue()     {         return this.ordinal();     }      /*      * convert integer enum value.      */     public static authentication forvalue(int value)     {         return values()[value];     } } 

this 1997 article shows how create enumerated constands in java.

the idea have final class private constructor , public constants. example used is:

public final class color {    private string id;   public final int ord;   private static int upperbound = 0;    private color(string anid) {     this.id = anid;     this.ord = upperbound++;   }    public string tostring() {return this.id; }   public static int size() { return upperbound; }    public static final color red = new color("red");   public static final color green = new color("green");   public static final color blue = new color("blue"); } 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -