1 2 12 package com.versant.core.jdo; 13 14 import com.versant.core.common.Utils; 15 16 import java.util.EventObject ; 17 18 24 public class LifecycleEvent extends EventObject { 25 26 public static final int CREATE = 0; 27 public static final int LOAD = 1; 28 public static final int PRESTORE = 2; 29 public static final int POSTSTORE = 3; 30 public static final int CLEAR = 4; 31 public static final int DELETE = 5; 32 public static final int DIRTY = 6; 33 public static final int DETACH = 7; 34 public static final int ATTACH = 8; 35 36 private int type; 37 private Object target; 38 39 public LifecycleEvent(Object source, int type) { 40 super(source); 41 this.type = type; 42 } 43 44 public LifecycleEvent(Object source, int type, Object target) { 45 this(source, type); 46 this.target = target; 47 } 48 49 52 public int getEventType() { 53 return type; 54 } 55 56 61 public Object getTarget() { 62 return target; 63 } 64 65 public static String toTypeString(int type) { 66 switch (type) { 67 case CREATE: return "CREATE"; 68 case LOAD: return "LOAD"; 69 case PRESTORE: return "PRESTORE"; 70 case POSTSTORE: return "POSTSTORE"; 71 case CLEAR: return "CLEAR"; 72 case DELETE: return "DELETE"; 73 case DIRTY: return "DIRTY"; 74 case DETACH: return "DETACH"; 75 case ATTACH: return "ATTACH"; 76 } 77 return "UNKNOWN(" + type + ")"; 78 } 79 80 public String toString() { 81 return "LifecycleEvent[source=" + Utils.toString(source) + 82 ", " + toTypeString(type) + ", target=" + 83 Utils.toString(target) + "]"; 84 } 85 86 } 87 88 | Popular Tags |