1 17 package org.eclipse.emf.ecore.sdo.impl; 18 19 20 import org.eclipse.emf.common.notify.Adapter; 21 import org.eclipse.emf.common.notify.Notification; 22 import org.eclipse.emf.common.notify.NotificationChain; 23 import org.eclipse.emf.common.notify.Notifier; 24 import org.eclipse.emf.ecore.EClass; 25 import org.eclipse.emf.ecore.EReference; 26 import org.eclipse.emf.ecore.EStructuralFeature; 27 import org.eclipse.emf.ecore.impl.ENotificationImpl; 28 import org.eclipse.emf.ecore.impl.EObjectImpl; 29 import org.eclipse.emf.ecore.sdo.EProperty; 30 import org.eclipse.emf.ecore.sdo.SDOPackage; 31 import org.eclipse.emf.ecore.sdo.util.SDOUtil; 32 import org.eclipse.emf.ecore.util.EcoreUtil; 33 34 import commonj.sdo.Type; 35 36 37 57 public class EPropertyImpl extends EObjectImpl implements EProperty, Adapter 58 { 59 67 protected static final String NAME_EDEFAULT = null; 68 69 77 protected static final boolean MANY_EDEFAULT = false; 78 79 87 protected static final boolean CONTAINMENT_EDEFAULT = false; 88 89 97 protected static final Object DEFAULT_EDEFAULT = null; 98 99 107 protected EStructuralFeature eStructuralFeature = null; 108 109 114 protected EPropertyImpl() 115 { 116 super(); 117 } 118 119 124 protected EClass eStaticClass() 125 { 126 return SDOPackage.eINSTANCE.getEProperty(); 127 } 128 129 134 public String getName() 135 { 136 return eStructuralFeature.getName(); 137 } 138 139 144 public boolean isMany() 145 { 146 return eStructuralFeature.isMany(); 147 } 148 149 154 public boolean isContainment() 155 { 156 return eStructuralFeature instanceof EReference && ((EReference)eStructuralFeature).isContainment(); 157 } 158 159 164 public Object getDefault() 165 { 166 return eStructuralFeature.getDefaultValue(); 167 } 168 169 174 public Type getType() 175 { 176 return SDOUtil.adaptType(eStructuralFeature.getEType()); 177 } 178 179 184 public Type getContainingType() 185 { 186 return SDOUtil.adaptType(eStructuralFeature.getEContainingClass()); 187 } 188 189 194 public EStructuralFeature getEStructuralFeature() 195 { 196 return eStructuralFeature; 197 } 198 199 204 public void setEStructuralFeature(EStructuralFeature newEStructuralFeature) 205 { 206 EStructuralFeature oldEStructuralFeature = eStructuralFeature; 207 eStructuralFeature = newEStructuralFeature; 208 if (eNotificationRequired()) 209 eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.EPROPERTY__ESTRUCTURAL_FEATURE, oldEStructuralFeature, eStructuralFeature)); 210 } 211 212 public boolean isAdapterForType(Object type) 213 { 214 return type == EProperty.class; 215 } 216 217 public void notifyChanged(Notification msg) 218 { 219 } 220 221 public Notifier getTarget() 222 { 223 return getEStructuralFeature(); 224 } 225 226 public void setTarget(Notifier newTarget) 227 { 228 setEStructuralFeature((EStructuralFeature)newTarget); 229 } 230 231 public boolean isReadOnly() 232 { 233 return "true".equals(EcoreUtil.getAnnotation(eStructuralFeature, "commonj.sdo", "readOnly")); 234 } 235 236 public void setReadOnly(boolean readOnly) 237 { 238 EcoreUtil.setAnnotation(eStructuralFeature, "commonj.sdo", "readOnly", readOnly ? "true" : "false"); 239 } 240 241 246 public NotificationChain eBasicRemoveFromContainer(NotificationChain msgs) 247 { 248 if (eContainerFeatureID >= 0) 249 { 250 switch (eContainerFeatureID) 251 { 252 case SDOPackage.EPROPERTY__CONTAINING_TYPE: 253 return eContainer.eInverseRemove(this, SDOPackage.TYPE__PROPERTIES, Type.class, msgs); 254 default: 255 return eDynamicBasicRemoveFromContainer(msgs); 256 } 257 } 258 return eContainer.eInverseRemove(this, EOPPOSITE_FEATURE_BASE - eContainerFeatureID, null, msgs); 259 } 260 261 266 public Object eGet(EStructuralFeature eFeature, boolean resolve) 267 { 268 switch (eDerivedStructuralFeatureID(eFeature)) 269 { 270 case SDOPackage.EPROPERTY__NAME: 271 return getName(); 272 case SDOPackage.EPROPERTY__MANY: 273 return isMany() ? Boolean.TRUE : Boolean.FALSE; 274 case SDOPackage.EPROPERTY__CONTAINMENT: 275 return isContainment() ? Boolean.TRUE : Boolean.FALSE; 276 case SDOPackage.EPROPERTY__DEFAULT: 277 return getDefault(); 278 case SDOPackage.EPROPERTY__TYPE: 279 return getType(); 280 case SDOPackage.EPROPERTY__CONTAINING_TYPE: 281 return getContainingType(); 282 case SDOPackage.EPROPERTY__ESTRUCTURAL_FEATURE: 283 return getEStructuralFeature(); 284 } 285 return eDynamicGet(eFeature, resolve); 286 } 287 288 293 public void eSet(EStructuralFeature eFeature, Object newValue) 294 { 295 switch (eDerivedStructuralFeatureID(eFeature)) 296 { 297 case SDOPackage.EPROPERTY__ESTRUCTURAL_FEATURE: 298 setEStructuralFeature((EStructuralFeature)newValue); 299 return; 300 } 301 eDynamicSet(eFeature, newValue); 302 } 303 304 309 public void eUnset(EStructuralFeature eFeature) 310 { 311 switch (eDerivedStructuralFeatureID(eFeature)) 312 { 313 case SDOPackage.EPROPERTY__ESTRUCTURAL_FEATURE: 314 setEStructuralFeature((EStructuralFeature)null); 315 return; 316 } 317 eDynamicUnset(eFeature); 318 } 319 320 325 public boolean eIsSet(EStructuralFeature eFeature) 326 { 327 switch (eDerivedStructuralFeatureID(eFeature)) 328 { 329 case SDOPackage.EPROPERTY__NAME: 330 return NAME_EDEFAULT == null ? getName() != null : !NAME_EDEFAULT.equals(getName()); 331 case SDOPackage.EPROPERTY__MANY: 332 return isMany() != MANY_EDEFAULT; 333 case SDOPackage.EPROPERTY__CONTAINMENT: 334 return isContainment() != CONTAINMENT_EDEFAULT; 335 case SDOPackage.EPROPERTY__DEFAULT: 336 return DEFAULT_EDEFAULT == null ? getDefault() != null : !DEFAULT_EDEFAULT.equals(getDefault()); 337 case SDOPackage.EPROPERTY__TYPE: 338 return getType() != null; 339 case SDOPackage.EPROPERTY__CONTAINING_TYPE: 340 return getContainingType() != null; 341 case SDOPackage.EPROPERTY__ESTRUCTURAL_FEATURE: 342 return eStructuralFeature != null; 343 } 344 return eDynamicIsSet(eFeature); 345 } 346 347 } | Popular Tags |