1 package org.hibernate; 3 4 import java.io.Serializable ; 5 import java.sql.ResultSet ; 6 import java.util.HashMap ; 7 import java.util.Map ; 8 9 17 public final class ScrollMode implements Serializable { 18 private final int resultSetType; 19 private final String name; 20 private static final Map INSTANCES = new HashMap (); 21 22 private ScrollMode(int level, String name) { 23 this.resultSetType=level; 24 this.name=name; 25 } 26 27 public String toString() { 28 return name; 29 } 30 31 34 public int toResultSetType() { 35 return resultSetType; 36 } 37 38 41 public static final ScrollMode FORWARD_ONLY = new ScrollMode(ResultSet.TYPE_FORWARD_ONLY, "FORWARD_ONLY"); 42 45 public static final ScrollMode SCROLL_SENSITIVE = new ScrollMode(ResultSet.TYPE_SCROLL_SENSITIVE, "SCROLL_SENSITIVE"); 46 52 public static final ScrollMode SCROLL_INSENSITIVE = new ScrollMode(ResultSet.TYPE_SCROLL_INSENSITIVE, "SCROLL_INSENSITIVE"); 53 54 public boolean lessThan(ScrollMode other) { 55 return this.resultSetType<other.resultSetType; 56 } 57 58 static { 59 INSTANCES.put( FORWARD_ONLY.name, FORWARD_ONLY ); 60 INSTANCES.put( SCROLL_INSENSITIVE.name, SCROLL_INSENSITIVE ); 61 INSTANCES.put( SCROLL_SENSITIVE.name, SCROLL_SENSITIVE ); 62 } 63 64 private Object readResolve() { 65 return INSTANCES.get(name); 66 } 67 68 } 69 70 71 72 73 74 75 | Popular Tags |