1 24 package org.objectweb.jalisto.se.impl.lock; 25 26 import org.objectweb.jalisto.se.api.internal.DataWrapper; 27 28 public class ObjectTransactionnalState { 29 30 public ObjectTransactionnalState(int currentAction, DataWrapper currentValue, short update) { 31 this.currentAction = currentAction; 32 this.currentValue = currentValue; 33 this.update = update; 34 } 35 36 37 public int getCurrentAction() { 38 return currentAction; 39 } 40 41 public boolean isReadAction() { 42 return (currentAction == READ_ACTION); 43 } 44 45 public boolean isCreateAction() { 46 return (currentAction == CREATE_ACTION); 47 } 48 49 50 public DataWrapper getCurrentValue() { 51 return currentValue; 52 } 53 54 public void setValue(int action, DataWrapper currentValue) { 55 if ((action != READ_ACTION) || (currentAction == READ_ACTION)) { 56 this.currentValue = currentValue; 57 currentAction = action; 58 } 59 } 60 61 62 public void update() { 63 update++; 64 } 65 66 public short getUpdate() { 67 return update; 68 } 69 70 public void setUpdate(short update) { 71 if (update != (short) -1) { 72 this.update = update; 73 } 74 } 75 76 77 public String toString() { 78 StringBuffer sb = new StringBuffer (); 79 sb.append("ITImage : ").append(getActionAsString(currentAction)).append(", "); 80 sb.append(currentValue).append(", update=").append(update); 81 return sb.toString(); 82 } 83 84 private String getActionAsString(int action) { 85 if (action == NO_ACTION) { 86 return "no_action"; 87 } else if (action == NEW_OID_ACTION) { 88 return "new_action"; 89 } else if (action == CREATE_ACTION) { 90 return "create_action"; 91 } else if (action == UPDATE_ACTION) { 92 return "update_action"; 93 } else if (action == DELETE_ACTION) { 94 return "delete_action"; 95 } else { 96 return "read_action"; 97 } 98 } 99 100 101 private DataWrapper currentValue; 102 private int currentAction; 103 private short update; 104 105 106 public static final int NO_ACTION = 0; 107 public static final int NEW_OID_ACTION = 1; 108 public static final int CREATE_ACTION = 2; 109 public static final int UPDATE_ACTION = 3; 110 public static final int DELETE_ACTION = 4; 111 public static final int READ_ACTION = 5; 112 } 113 | Popular Tags |