1 24 25 package org.objectweb.perseus; 26 27 import org.objectweb.perseus.persistence.api.StateManager; 28 import org.objectweb.perseus.persistence.api.State; 29 import org.objectweb.perseus.cache.api.CacheEntry; 30 import org.objectweb.perseus.cache.api.CacheEvent; 31 32 public class StateManagerTestImpl implements StateManager { 33 34 public StateManagerTestImpl() { 35 36 } 37 38 public State createState(CacheEntry ce) { 39 if (ce.getCeObject() instanceof PString) 40 return new PStringState(ce); 41 if (ce.getCeObject() instanceof PInteger) 42 return new PIntegerState(ce); 43 return null; 44 } 45 46 public State createState(State s) { 47 if (s instanceof PStringState) 48 return new PStringState(s); 49 if (s instanceof PIntegerState) 50 return new PIntegerState(s); 51 return null; 52 } 53 54 public State getReferenceState(CacheEntry ce) { 55 return ((StatefullReplacebleCacheEntry) ce).getRefState(); 56 } 57 58 public void setReferenceState(CacheEntry ce, State state) { 59 ((StatefullReplacebleCacheEntry) ce).setRefState(state); 60 } 61 62 public void destroyState(State state) { 63 } 64 65 public void makeUnexported(State state) { 66 ((StatusOwner) state).setStatus((byte) 67 (((StatusOwner) state).getStatus() | Status.STATUS_UNEXPORTED)); 68 } 69 70 public boolean isUnexported(State state) { 71 return (((StatusOwner) state).getStatus() & Status.STATUS_UNEXPORTED) > 0; 72 } 73 74 public void makeExported(State state) { 75 ((StatusOwner) state).setStatus((byte) 76 (((StatusOwner) state).getStatus() | Status.STATUS_EXPORTED)); 77 } 78 79 public boolean isExported(State state) { 80 return (((StatusOwner) state).getStatus() & Status.STATUS_EXPORTED) > 0; 81 } 82 83 public void makeDirty(State state) { 84 byte status = ((StatusOwner) state).getStatus(); 85 status = (byte) (status | Status.STATUS_DIRTY); 86 ((StatusOwner) state).setStatus(status); 88 } 89 90 public boolean isDirty(State state) { 91 return (((StatusOwner) state).getStatus() & Status.STATUS_DIRTY) > 0; 92 } 93 94 public void makeClean(State state) { 95 ((StatusOwner) state).setStatus(Status.STATUS_CLEAN); 96 } 97 98 public void makeFlushed(State state) { 99 ((StatusOwner) state).setStatus((byte) 100 (((StatusOwner) state).getStatus() | Status.STATUS_FLUSHED)); 101 } 102 103 public boolean isFlushed(State state) { 104 return (((StatusOwner) state).getStatus() & Status.STATUS_FLUSHED) > 0; 105 } 106 107 public void makeUnbound(CacheEntry ce) { 108 } 110 111 public boolean isBound(CacheEntry ce) { 112 return true; 113 } 115 116 public void entryBound(CacheEvent event) { 117 } 119 120 public void entryUnbound(CacheEvent event) { 121 } 123 } 124 | Popular Tags |