1 16 package org.apache.cocoon.portal.profile.impl; 17 18 import java.util.HashMap ; 19 import java.util.Iterator ; 20 import java.util.Map ; 21 22 import org.apache.cocoon.portal.coplet.CopletData; 23 import org.apache.cocoon.portal.util.DeltaApplicableReferencesAdjustable; 24 25 32 public class CopletDataManager 33 implements DeltaApplicableReferencesAdjustable { 34 35 38 private Map copletData = new HashMap (); 39 40 43 private boolean deltaApplied = false; 44 45 48 public Map getCopletData() { 49 return this.copletData; 50 } 51 52 55 public CopletData getCopletData(String name) { 56 return (CopletData)this.copletData.get(name); 57 } 58 59 62 public void putCopletData(CopletData data) { 63 this.copletData.put(data.getId(), data); 64 } 65 66 70 public boolean applyDelta(Object object) { 71 CopletDataManager manager = (CopletDataManager)object; 72 73 this.deltaApplied = true; 74 75 Iterator iterator = manager.getCopletData().values().iterator(); 76 CopletData data, delta; 77 while (iterator.hasNext()) { 78 delta = (CopletData)iterator.next(); 79 data = this.getCopletData(delta.getId()); 80 if (data == null) { 81 this.putCopletData(delta); 82 } else { 83 data.applyDelta(delta); 84 } 85 } 86 87 return true; 88 } 89 90 93 public boolean deltaApplied() { 94 return this.deltaApplied; 95 } 96 97 102 public void adjustReferences(Object object) { 103 CopletDataManager manager = (CopletDataManager)object; 104 105 Iterator iterator = this.copletData.values().iterator(); 106 CopletData data, other; 107 while (iterator.hasNext()) { 108 data = (CopletData)iterator.next(); 109 if (!data.deltaApplied()) { 110 other = manager.getCopletData(data.getId()); 111 if (other != null) { 112 this.putCopletData(other); 113 } 114 } 115 } 116 } 117 } 118 | Popular Tags |