1 28 29 package org.objectweb.util.ref.lib; 30 31 import org.objectweb.util.ref.api.Referencable; 32 import org.objectweb.util.ref.api.Reference; 33 34 40 public class ReferenceBase 41 implements Reference 42 { 43 49 50 private Referencable owner_; 51 52 53 private Referencable target_; 54 55 61 62 public ReferenceBase() { 63 owner_ = null; 65 target_ = null; 66 } 67 68 73 public ReferenceBase(Referencable owner) { 74 owner_ = owner; 76 target_ = null; 77 } 78 79 85 public ReferenceBase(Referencable owner, Referencable target) { 86 owner_ = owner; 88 target_ = null; 89 setTarget(target); 90 } 91 92 98 104 109 public Referencable getOwner() { 110 return owner_; 111 } 112 113 118 public void setOwner(Referencable ref) { 119 owner_ = ref; 120 } 121 122 127 public Referencable getTarget() { 128 return target_; 129 } 130 131 136 public void setTarget(Referencable ref) { 137 if (ref == target_) return; 139 140 cutIt(); 142 143 target_ = ref; 145 target_.addReferencedBy(owner_); 146 } 147 148 151 public void cutIt() { 152 if (target_ != null) { 153 target_.removeReferencedBy(owner_); 155 target_ = null; 156 } 157 } 158 } 159 | Popular Tags |