1 20 package org.enhydra.barracuda.plankton.data; 21 22 import java.io.*; 23 import java.util.*; 24 25 28 public abstract class AbstractPData implements PData { 29 30 protected PData parent = null; 31 protected boolean inheritParents = true; 32 protected DefaultStateMap state = null; 33 34 35 42 public void setParent(PData p) { 43 if (p==this) return; 47 parent = p; 48 } 49 50 55 public PData getParent() { 56 return parent; 57 } 58 59 65 public PData getRootParent() { 66 if ((parent!=null) || (parent instanceof PData)) return parent.getRootParent(); 67 else return this; 68 } 69 70 80 public void setInheritParents(boolean val) { 81 inheritParents = val; 82 } 83 84 89 public boolean isInheritParents() { 90 return inheritParents; 91 } 92 93 94 101 public void putState(Object key, Object val) { 102 if (state==null) state = new DefaultStateMap(); 103 state.putState(key, val); 104 } 105 106 112 public Object getState(Object key) { 113 if (state==null) return null; 114 else return state.getState(key); 115 } 116 117 123 public Object removeState(Object key) { 124 if (state==null) return null; 125 else return state.removeState(key); 126 } 127 128 134 public List getStateKeys() { 135 if (state==null) return null; 136 else return state.getStateKeys(); 137 } 138 139 145 public Map getStateValues() { 146 if (state==null) state = new DefaultStateMap(); 147 return state.getStateValues(); 148 } 149 150 154 public void clearState() { 155 if (state!=null) state.clearState(); 156 } 157 158 159 160 } 161 | Popular Tags |