1 22 package org.jboss.tm.remoting.interfaces; 23 24 import java.io.ObjectStreamException ; 25 import java.io.Serializable ; 26 27 34 public class Vote implements Serializable 35 { 36 static final long serialVersionUID = -6997498750766547785L; 37 38 43 private static final int MAX_TYPE_ID = 2; 44 45 46 private static final Vote[] values = new Vote[MAX_TYPE_ID + 1]; 47 48 public static final Vote COMMIT = new Vote("COMMIT", 0); 49 public static final Vote ROLLBACK = new Vote("ROLLBACK", 1); 50 public static final Vote READONLY = new Vote("READONLY", 2); 51 52 private final transient String name; 53 54 private final int ordinal; 56 57 private Vote(String name, int ordinal) 58 { 59 this.name = name; 60 this.ordinal = ordinal; 61 values[ordinal] = this; 62 } 63 64 public String toString() 65 { 66 return name; 67 } 68 69 Object readResolve() throws ObjectStreamException 70 { 71 return values[ordinal]; 72 } 73 74 } 75 | Popular Tags |