1 package org.hibernate; 3 4 import java.util.Map ; 5 import java.util.HashMap ; 6 import java.io.Serializable ; 7 8 13 public class EntityMode implements Serializable { 14 15 private static final Map INSTANCES = new HashMap (); 16 17 public static final EntityMode POJO = new EntityMode( "pojo" ); 18 public static final EntityMode DOM4J = new EntityMode( "dom4j" ); 19 public static final EntityMode MAP = new EntityMode( "dynamic-map" ); 20 21 static { 22 INSTANCES.put( POJO.name, POJO ); 23 INSTANCES.put( DOM4J.name, DOM4J ); 24 INSTANCES.put( MAP.name, MAP ); 25 } 26 27 private final String name; 28 29 public EntityMode(String name) { 30 this.name = name; 31 } 32 33 public String toString() { 34 return name; 35 } 36 37 private Object readResolve() { 38 return INSTANCES.get( name ); 39 } 40 41 public static EntityMode parse(String name) { 42 EntityMode rtn = ( EntityMode ) INSTANCES.get( name ); 43 if ( rtn == null ) { 44 rtn = POJO; 46 } 47 return rtn; 48 } 49 } 50 | Popular Tags |