1 7 package org.jboss.cache.optimistic; 8 9 import org.jboss.cache.Fqn; 10 11 import java.util.Map ; 12 import java.util.SortedMap ; 13 import java.util.TreeMap ; 14 import java.util.concurrent.ConcurrentHashMap ; 15 16 23 public class TransactionWorkspaceImpl implements TransactionWorkspace 24 { 25 26 private Map <Fqn, WorkspaceNode> nodes; 27 private boolean versioningImplicit = true; 28 29 public TransactionWorkspaceImpl() 30 { 31 nodes = new ConcurrentHashMap <Fqn, WorkspaceNode>(); 32 } 33 34 37 public Map <Fqn, WorkspaceNode> getNodes() 38 { 39 return nodes; 40 } 41 42 45 public void setNodes(Map <Fqn, WorkspaceNode> nodes) 46 { 47 this.nodes = nodes; 48 } 49 50 public WorkspaceNode getNode(Fqn fqn) 51 { 52 return nodes.get(fqn); 53 } 54 55 public void addNode(WorkspaceNode node) 56 { 57 nodes.put(node.getFqn(), node); 58 } 59 60 public Object removeNode(Fqn fqn) 61 { 62 return nodes.remove(fqn); 63 } 64 65 public SortedMap <Fqn, WorkspaceNode> getNodesAfter(Fqn fqn) 66 { 67 SortedMap <Fqn, WorkspaceNode> sm = new TreeMap <Fqn, WorkspaceNode>(); 68 sm.putAll(nodes); 69 return sm.tailMap(fqn); 70 } 71 72 public boolean isVersioningImplicit() 73 { 74 return versioningImplicit; 75 } 76 77 public void setVersioningImplicit(boolean versioningImplicit) 78 { 79 this.versioningImplicit = versioningImplicit; 80 } 81 82 public boolean hasNode(Fqn fqn) 83 { 84 return nodes.containsKey(fqn); 85 } 86 87 90 public String toString() 91 { 92 return "Workspace nodes=" + nodes; 93 } 94 } 95 | Popular Tags |