1 56 package org.objectstyle.cayenne.graph; 57 58 import java.util.ArrayList ; 59 import java.util.Collections ; 60 import java.util.List ; 61 62 70 public class OperationRecorder implements GraphChangeHandler { 71 72 protected List diffs; 73 74 public OperationRecorder() { 75 this.diffs = new ArrayList (); 76 } 77 78 81 public GraphDiff getDiffs() { 82 return new CompoundDiff(Collections.unmodifiableList(diffs)); 83 } 84 85 public void clear() { 86 this.diffs = new ArrayList (); 87 } 88 89 public int size() { 90 return diffs.size(); 91 } 92 93 public boolean isEmpty() { 94 return diffs.isEmpty(); 95 } 96 97 public void nodeCreated(Object nodeId) { 98 diffs.add(new NodeCreateOperation(nodeId)); 99 } 100 101 public void nodeIdChanged(Object nodeId, Object newId) { 102 diffs.add(new NodeIdChangeOperation(nodeId, newId)); 103 } 104 105 public void nodeRemoved(Object nodeId) { 106 diffs.add(new NodeDeleteOperation(nodeId)); 107 } 108 109 public void nodePropertyChanged( 110 Object nodeId, 111 String property, 112 Object oldValue, 113 Object newValue) { 114 diffs.add(new NodePropertyChangeOperation(nodeId, property, oldValue, newValue)); 115 } 116 117 public void arcCreated(Object nodeId, Object targetNodeId, Object arcId) { 118 diffs.add(new ArcCreateOperation(nodeId, targetNodeId, arcId)); 119 } 120 121 public void arcDeleted(Object nodeId, Object targetNodeId, Object arcId) { 122 diffs.add(new ArcDeleteOperation(nodeId, targetNodeId, arcId)); 123 } 124 } 125 | Popular Tags |