1 package org.sapia.archie.sync; 2 3 import java.util.Iterator ; 4 5 import org.sapia.archie.DuplicateException; 6 import org.sapia.archie.Name; 7 import org.sapia.archie.NameParser; 8 import org.sapia.archie.NamePart; 9 import org.sapia.archie.Node; 10 import org.sapia.archie.ProcessingException; 11 12 20 public class SynchronizedNode implements Node{ 21 22 private Node _node; 23 private Synchronizer _sync = new SynchronizerAdapter(); 24 25 28 public SynchronizedNode(Node node){ 29 _node = node; 30 } 31 32 35 public void setSynchronizer(Synchronizer sync){ 36 _sync = sync; 37 } 38 39 42 public Synchronizer getSynchronizer(){ 43 return _sync; 44 } 45 46 56 public void synchronizePut(NamePart valueName, Object toSync, boolean overwrite){ 57 _node.putValue(valueName, toSync, overwrite); 58 } 59 60 69 public void synchronizeRemove(NamePart valueName){ 70 _node.removeValue(valueName); 71 } 72 73 83 public Object synchronizeGet(NamePart valueName){ 84 return _node.getValue(valueName); 85 } 86 87 90 public Node createChild(NamePart name) throws DuplicateException, 91 ProcessingException { 92 return _node.createChild(name); 93 } 94 97 public Name getAbsolutePath() { 98 return _node.getAbsolutePath(); 99 } 100 103 public Node getChild(NamePart name) { 104 return _node.getChild(name); 105 } 106 109 public Iterator getChildren() { 110 return _node.getChildren(); 111 } 112 115 public int getChildrenCount() { 116 return _node.getChildrenCount(); 117 } 118 121 public Iterator getChildrenNames() { 122 return _node.getChildrenNames(); 123 } 124 127 public Iterator getEntries() { 128 return _node.getEntries(); 129 } 130 133 public NamePart getName() { 134 return _node.getName(); 135 } 136 139 public NameParser getNameParser() { 140 return _node.getNameParser(); 141 } 142 145 public Node getParent() { 146 return _node.getParent(); 147 } 148 151 public Object getValue(NamePart name) { 152 Object toReturn = _node.getValue(name); 153 if(toReturn == null){ 154 toReturn = _sync.onGetValue((Name)getAbsolutePath().clone(), name); 155 } 156 return toReturn; 157 } 158 161 public int getValueCount() { 162 return _node.getValueCount(); 163 } 164 167 public Iterator getValueNames() { 168 return _node.getValueNames(); 169 } 170 173 public boolean putValue(NamePart name, Object value, boolean overwrite) { 174 boolean put = _node.putValue(name, value, overwrite); 175 _sync.onPutValue((Name)getAbsolutePath().clone(), name, value, overwrite); 176 return put; 177 } 178 181 public Node removeChild(NamePart name) { 182 return _node.removeChild(name); 183 } 184 187 public Object removeValue(NamePart name) { 188 Object toReturn = _node.removeValue(name); 189 _sync.onRemoveValue((Name)getAbsolutePath().clone(), name); 190 return toReturn; 191 } 192 195 public void setUp(Node parent, NamePart nodeName) { 196 _node.setUp(parent, nodeName); 197 } 198 } 199 | Popular Tags |