/** * * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.tuscany.sdo.impl; import java.io.ObjectStreamException; import java.math.BigDecimal; import java.math.BigInteger; import java.util.Date; import java.util.List; import org.apache.tuscany.sdo.SDOPackage; import org.apache.tuscany.sdo.impl.ChangeSummaryImpl.SDOChangeRecorder; import org.apache.tuscany.sdo.util.DataObjectUtil; import org.eclipse.emf.common.notify.Notification; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.URI; import org.eclipse.emf.ecore.EAttribute; import org.eclipse.emf.ecore.EClass; import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.emf.ecore.InternalEObject; import org.eclipse.emf.ecore.EStructuralFeature.Internal.DynamicValueHolder; import org.eclipse.emf.ecore.impl.BasicEObjectImpl; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.ecore.util.BasicExtendedMetaData; import org.eclipse.emf.ecore.util.EContentsEList; import org.eclipse.emf.ecore.util.ECrossReferenceEList; import commonj.sdo.ChangeSummary; import commonj.sdo.DataGraph; import commonj.sdo.DataObject; import commonj.sdo.Property; import commonj.sdo.Sequence; import commonj.sdo.Type; /** * * Base implementation of the SDO DataObject interface. This implementation allocates the minimum storage * overhead needed for SDO. It provides a complete implementation of the API, but does not, however, allocate * any storage for the actual properties of the data object. It instead requires subclasses for this purpose. * The subclass, DynamicDataObjectImpl serves as a concrete implementation class for dynamic data objects. * Static data object storage is provided by generated classes, which also directly or indirectly derive from * this class. * *

*

* * @generated */ public abstract class DataObjectImpl extends BasicEObjectImpl implements DataObject { protected InternalEObject eContainer; protected int eContainerFeatureID; protected SDOChangeRecorder changeRecorder; protected Object location; // Resource.Internal (if object is directly contained in a resource) or URI (if it is a proxy) /** * * * @generated */ protected DataObjectImpl() { super(); } /** * * * @generated NOT */ public Object get(int propertyIndex) { return eGet(propertyIndex, true, false); } /** * * * @generated NOT */ public void set(int propertyIndex, Object value) { eSet(propertyIndex, value); } /** * * * @generated NOT */ public boolean isSet(int propertyIndex) { return eIsSet(propertyIndex); } /** * * * @generated NOT */ public void unset(int propertyIndex) { eUnset(propertyIndex); } /** * * * @generated NOT */ public Object get(Property property) { return eGet((EStructuralFeature)property, true, false); } /** * * * @generated NOT */ public void set(Property property, Object value) { eSet((EStructuralFeature)property, value); } /** * * * @generated NOT */ public boolean isSet(Property property) { return eIsSet((EStructuralFeature)property); } /** * * * @generated NOT */ public void unset(Property property) { eUnset((EStructuralFeature)property); } /** * * * @generated NOT */ public DataObject getContainer() { return (DataObject)eContainer(); } /** * * * @generated NOT */ public Property getContainmentProperty() { return (Property)eContainmentFeature(); } /** * * * @generated NOT */ public Type getType() { return (Type)eClass(); } // Remaining DataObject methods are (will be) implemented as straight delegation to DataObjectUtil /** * * * @generated NOT */ public Object writeReplace() throws ObjectStreamException { return DataObjectUtil.writeReplace(this); } /** * * * @generated NOT */ public Object get(String path) { return DataObjectUtil.get(this, path); } /** * * * @generated NOT */ public void set(String path, Object value) { DataObjectUtil.set(this, path, value); } /** * * * @generated NOT */ public boolean isSet(String path) { return DataObjectUtil.isSet(this, path); } /** * * * @generated NOT */ public void unset(String path) { DataObjectUtil.unset(this, path); } /** * * * @generated NOT */ public DataGraph getDataGraph() { return DataObjectUtil.getDataGraph(this); } /** * * * @generated NOT */ public BigDecimal getBigDecimal(String path) { return DataObjectUtil.getBigDecimal(get(path)); } /** * * * @generated NOT */ public BigInteger getBigInteger(String path) { return DataObjectUtil.getBigInteger(get(path)); } /** * * * @generated NOT */ public boolean getBoolean(String path) { return DataObjectUtil.getBoolean(get(path)); } /** * * * @generated NOT */ public byte getByte(String path) { return DataObjectUtil.getByte(get(path)); } /** * * * @generated NOT */ public byte[] getBytes(String path) { return DataObjectUtil.getBytes(get(path)); } /** * * * @generated NOT */ public char getChar(String path) { return DataObjectUtil.getChar(get(path)); } /** * * * @generated NOT */ public DataObject getDataObject(String path) { return (DataObject)get(path); } /** * * * @generated NOT */ public Date getDate(String path) { return DataObjectUtil.getDate(get(path)); } /** * * * @generated NOT */ public double getDouble(String path) { return DataObjectUtil.getDouble(get(path)); } /** * * * @generated NOT */ public float getFloat(String path) { return DataObjectUtil.getFloat(get(path)); } /** * * * @generated NOT */ public int getInt(String path) { return DataObjectUtil.getInt(get(path)); } /** * * * @generated NOT */ public List getList(String path) { return (List)get(path); } /** * * * @generated NOT */ public long getLong(String path) { return DataObjectUtil.getLong(get(path)); } /** * * * @generated NOT */ public Sequence getSequence(String path) { return (Sequence)get(path); } /** * * * @generated NOT */ public short getShort(String path) { return DataObjectUtil.getShort(get(path)); } /** * * * @generated NOT */ public String getString(String path) { return DataObjectUtil.getString(get(path)); } /** * * * @generated NOT */ public void setBigDecimal(String path, BigDecimal value) { DataObjectUtil.setBigDecimal(this, path, value); } /** * * * @generated NOT */ public void setBigInteger(String path, BigInteger value) { DataObjectUtil.setBigInteger(this, path, value); } /** * * * @generated NOT */ public void setBoolean(String path, boolean value) { DataObjectUtil.setBoolean(this, path, value); } /** * * * @generated NOT */ public void setByte(String path, byte value) { DataObjectUtil.setByte(this, path, value); } /** * * * @generated NOT */ public void setBytes(String path, byte[] value) { DataObjectUtil.setBytes(this, path, value); } /** * * * @generated NOT */ public void setChar(String path, char value) { DataObjectUtil.setChar(this, path, value); } /** * * * @generated NOT */ public void setDataObject(String path, DataObject value) { DataObjectUtil.set(this, path, value); } /** * * * @generated NOT */ public void setDate(String path, Date value) { DataObjectUtil.setDate(this,path,value); } /** * * * @generated NOT */ public void setDouble(String path, double value) { DataObjectUtil.setDouble(this, path, value); } /** * * * @generated NOT */ public void setFloat(String path, float value) { DataObjectUtil.setFloat(this, path, value); } /** * * * @generated NOT */ public void setInt(String path, int value) { DataObjectUtil.setInt(this, path, value); } /** * * * @generated NOT */ public void setList(String path, List value) { DataObjectUtil.set(this, path, value); } /** * * * @generated NOT */ public void setLong(String path, long value) { DataObjectUtil.setLong(this, path, value); } /** * * * @generated NOT */ public void setShort(String path, short value) { DataObjectUtil.setShort(this, path, value); } /** * * * @generated NOT */ public void setString(String path, String value) { DataObjectUtil.setString(this, path, value); } /** * * * @generated NOT */ public BigDecimal getBigDecimal(int propertyIndex) { return DataObjectUtil.getBigDecimal(this, propertyIndex); } /** * * * @generated NOT */ public BigInteger getBigInteger(int propertyIndex) { return DataObjectUtil.getBigInteger(this,propertyIndex); } /** * * * @generated NOT */ public boolean getBoolean(int propertyIndex) { return DataObjectUtil.getBoolean(this, propertyIndex); } /** * * * @generated NOT */ public byte getByte(int propertyIndex) { return DataObjectUtil.getByte(this, propertyIndex); } /** * * * @generated NOT */ public byte[] getBytes(int propertyIndex) { return DataObjectUtil.getBytes(this, propertyIndex); } /** * * * @generated NOT */ public char getChar(int propertyIndex) { return DataObjectUtil.getChar(this, propertyIndex); } /** * * * @generated NOT */ public DataObject getDataObject(int propertyIndex) { return DataObjectUtil.getDataObject(this, propertyIndex); } /** * * * @generated NOT */ public Date getDate(int propertyIndex) { return DataObjectUtil.getDate(this,propertyIndex); } /** * * * @generated NOT */ public double getDouble(int propertyIndex) { return DataObjectUtil.getDouble(this, propertyIndex); } /** * * * @generated NOT */ public float getFloat(int propertyIndex) { return DataObjectUtil.getFloat(this,propertyIndex); } /** * * * @generated NOT */ public int getInt(int propertyIndex) { return DataObjectUtil.getInt(this,propertyIndex); } /** * * * @generated NOT */ public List getList(int propertyIndex) { return DataObjectUtil.getList(this, propertyIndex); } /** * * * @generated NOT */ public long getLong(int propertyIndex) { return DataObjectUtil.getLong(this,propertyIndex); } /** * * * @generated NOT */ public Sequence getSequence(int propertyIndex) { return DataObjectUtil.getSequence(this, propertyIndex); } /** * * * @generated NOT */ public short getShort(int propertyIndex) { return DataObjectUtil.getShort(this,propertyIndex); } /** * * * @generated NOT */ public String getString(int propertyIndex) { return DataObjectUtil.getString(this,propertyIndex); } /** * * * @generated NOT */ public void setBigDecimal(int propertyIndex, BigDecimal value) { DataObjectUtil.setBigDecimal(this, propertyIndex, value); } /** * * * @generated NOT */ public void setBigInteger(int propertyIndex, BigInteger value) { DataObjectUtil.setBigInteger(this, propertyIndex, value); } /** * * * @generated NOT */ public void setBoolean(int propertyIndex, boolean value) { DataObjectUtil.setBoolean(this, propertyIndex, value); } /** * * * @generated NOT */ public void setByte(int propertyIndex, byte value) { DataObjectUtil.setByte(this, propertyIndex, value); } /** * * * @generated NOT */ public void setBytes(int propertyIndex, byte[] value) { DataObjectUtil.setBytes(this, propertyIndex, value); } /** * * * @generated NOT */ public void setChar(int propertyIndex, char value) { DataObjectUtil.setChar(this, propertyIndex, value); } /** * * * @generated NOT */ public void setDataObject(int propertyIndex, DataObject value) { DataObjectUtil.setDataObject(this, propertyIndex, value); } /** * * * @generated NOT */ public void setDate(int propertyIndex, Date value) { DataObjectUtil.setDate(this, propertyIndex, value); } /** * * * @generated NOT */ public void setDouble(int propertyIndex, double value) { DataObjectUtil.setDouble(this, propertyIndex, value); } /** * * * @generated NOT */ public void setFloat(int propertyIndex, float value) { DataObjectUtil.setFloat(this, propertyIndex, value); } /** * * * @generated NOT */ public void setInt(int propertyIndex, int value) { DataObjectUtil.setInt(this, propertyIndex, value); } /** * * * @generated NOT */ public void setList(int propertyIndex, List value) { DataObjectUtil.setList(this, propertyIndex, value); } /** * * * @generated NOT */ public void setLong(int propertyIndex, long value) { DataObjectUtil.setLong(this, propertyIndex, value); } /** * * * @generated NOT */ public void setShort(int propertyIndex, short value) { DataObjectUtil.setShort(this, propertyIndex, value); } /** * * * @generated NOT */ public void setString(int propertyIndex, String value) { DataObjectUtil.setString(this, propertyIndex, value); } /** * * * @generated NOT */ public BigDecimal getBigDecimal(Property property) { return DataObjectUtil.getBigDecimal(this, property); } /** * * * @generated NOT */ public BigInteger getBigInteger(Property property) { return DataObjectUtil.getBigInteger(this, property); } /** * * * @generated NOT */ public boolean getBoolean(Property property) { return DataObjectUtil.getBoolean(this, property); } /** * * * @generated NOT */ public byte getByte(Property property) { return DataObjectUtil.getByte(this, property); } /** * * * @generated NOT */ public byte[] getBytes(Property property) { return DataObjectUtil.getBytes(this, property); } /** * * * @generated NOT */ public char getChar(Property property) { return DataObjectUtil.getChar(this, property); } /** * * * @generated NOT */ public DataObject getDataObject(Property property) { return (DataObject)DataObjectUtil.getDataObject(this,property); } /** * * * @generated NOT */ public Date getDate(Property property) { return DataObjectUtil.getDate(this, property); } /** * * * @generated NOT */ public double getDouble(Property property) { return DataObjectUtil.getDouble(this, property); } /** * * * @generated NOT */ public float getFloat(Property property) { return DataObjectUtil.getFloat(this, property); } /** * * * @generated NOT */ public int getInt(Property property) { return DataObjectUtil.getInt(this, property); } /** * * * @generated NOT */ public List getList(Property property) { return (List)DataObjectUtil.getList(this, property); } /** * * * @generated NOT */ public long getLong(Property property) { return DataObjectUtil.getLong(this, property); } /** * * * @generated NOT */ public Sequence getSequence(Property property) { return (Sequence)DataObjectUtil.getSequence(this, property); } /** * * * @generated NOT */ public short getShort(Property property) { return DataObjectUtil.getShort(this, property); } /** * * * @generated NOT */ public String getString(Property property) { return DataObjectUtil.getString(this, property); } /** * * * @generated NOT */ public void setBigDecimal(Property property, BigDecimal value) { DataObjectUtil.setBigDecimal(this,property, value); } /** * * * @generated NOT */ public void setBigInteger(Property property, BigInteger value) { DataObjectUtil.setBigInteger(this,property, value); } /** * * * @generated NOT */ public void setBoolean(Property property, boolean value) { DataObjectUtil.setBoolean(this,property, value); } /** * * * @generated NOT */ public void setByte(Property property, byte value) { DataObjectUtil.setByte(this,property, value); } /** * * * @generated NOT */ public void setBytes(Property property, byte[] value) { DataObjectUtil.setBytes(this,property, value); } /** * * * @generated NOT */ public void setChar(Property property, char value) { DataObjectUtil.setChar(this,property, value); } /** * * * @generated NOT */ public void setDataObject(Property property, DataObject value) { DataObjectUtil.setDataObject(this,property, value); } /** * * * @generated NOT */ public void setDate(Property property, Date value) { DataObjectUtil.setDate(this,property, value); } /** * * * @generated NOT */ public void setDouble(Property property, double value) { DataObjectUtil.setDouble(this,property, value); } /** * * * @generated NOT */ public void setFloat(Property property, float value) { DataObjectUtil.setFloat(this,property, value); } /** * * * @generated NOT */ public void setInt(Property property, int value) { DataObjectUtil.setInt(this,property, value); } /** * * * @generated NOT */ public void setList(Property property, List value) { DataObjectUtil.setList(this,property, value); } /** * * * @generated NOT */ public void setLong(Property property, long value) { DataObjectUtil.setLong(this,property, value); } /** * * * @generated NOT */ public void setShort(Property property, short value) { DataObjectUtil.setShort(this,property, value); } /** * * * @generated NOT */ public void setString(Property property, String value) { DataObjectUtil.setString(this,property, value); } /** * * * @generated NOT */ public DataObject createDataObject(String propertyName) { return DataObjectUtil.createDataObject(this, propertyName); } /** * * * @generated NOT */ public DataObject createDataObject(int propertyIndex) { return DataObjectUtil.createDataObject(this, propertyIndex); } /** * * * @generated NOT */ public DataObject createDataObject(Property property) { return DataObjectUtil.createDataObject(this,property); } /** * * * @generated NOT */ public DataObject createDataObject(String propertyName, String namespaceURI, String typeName) { return DataObjectUtil.createDataObject(this, propertyName, namespaceURI, typeName); } /** * * * @generated NOT */ public DataObject createDataObject(int propertyIndex, String namespaceURI, String typeName) { return DataObjectUtil.createDataObject(this, propertyIndex, namespaceURI, typeName); } /** * * * @generated NOT */ public DataObject createDataObject(Property property, Type type) { return DataObjectUtil.createDataObject(this, property, type); } /** * * * @generated NOT */ public void delete() { DataObjectUtil.delete(this); } /** * * * @generated NOT */ public Sequence getSequence() { EAttribute mixedFeature = BasicExtendedMetaData.INSTANCE.getMixedFeature(eClass()); return mixedFeature != null ? (Sequence)eGet(mixedFeature, true, false) : null; } /** * * * @generated NOT */ public List getInstanceProperties() { return DataObjectUtil.getInstanceProperties(this); } /** * * * @generated NOT */ public Property getProperty(String propertyName) { return DataObjectUtil.getProperty(this, propertyName); } /** * * * @generated NOT */ public DataObject getRootObject() { return DataObjectUtil.getRootObject(this); } /** * * * @generated NOT */ public ChangeSummary getChangeSummary() { return DataObjectUtil.getChangeSummary(this); } /** * * * @generated NOT */ public void detach() { DataObjectUtil.detach(this); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Following methods customize BasicEObjectImpl, optimized for SDO //////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * * * @generated */ protected EClass eStaticClass() { return SDOPackage.eINSTANCE.getDataObject(); } public boolean eNotificationRequired() { return changeRecorder != null; } public void eNotify(Notification notification) { changeRecorder.notifyChanged(notification); } public void setChangeRecorder(SDOChangeRecorder changeRecorder) { if (this.changeRecorder != null) { this.changeRecorder.unsetTarget(this); } if (changeRecorder != null) { changeRecorder.setTarget(this); } this.changeRecorder = changeRecorder; } public InternalEObject eInternalContainer() { return eContainer; } public int eContainerFeatureID() { return eContainerFeatureID; } protected void eBasicSetContainer(InternalEObject newContainer, int newContainerFeatureID) { eContainer = newContainer; eContainerFeatureID = newContainerFeatureID; } public EClass eClass() { return eStaticClass(); } public EList eContents() { return new EContentsEList(this); } public EList eCrossReferences() { return new ECrossReferenceEList(this); } public Resource.Internal eDirectResource() { return location instanceof Resource.Internal ? (Resource.Internal)location : null; } protected EClass eDynamicClass() { return null; } protected boolean eHasSettings() { return false; } public boolean eIsProxy() { return location instanceof URI; } public URI eProxyURI() { return location instanceof URI ? (URI)location : null; } public void eSetClass(EClass eClass) { throw new UnsupportedOperationException(); } protected void eSetDirectResource(Resource.Internal resource) { location = resource; } public void eSetProxyURI(URI uri) { location = uri; } protected DynamicValueHolder eSettings() { return null; } public Object eGet(int featureID, boolean resolve, boolean coreType) { return eDynamicGet(featureID, resolve, coreType); } public void eSet(int featureID, Object newValue) { eDynamicSet(featureID, newValue); } public void eUnset(int featureID) { eDynamicUnset(featureID); } public boolean eIsSet(int featureID) { return eDynamicIsSet(featureID); } public Object eDynamicGet(int featureID, boolean resolve, boolean coreType) { return eOpenGet(DataObjectUtil.getOpenFeature(this, featureID), resolve); } public void eDynamicSet(int featureID, Object newValue) { eOpenSet(DataObjectUtil.getOpenFeature(this, featureID), newValue); } public void eDynamicUnset(int featureID) { eOpenUnset(DataObjectUtil.getOpenFeature(this, featureID)); } public boolean eDynamicIsSet(int featureID) { return eOpenIsSet(DataObjectUtil.getOpenFeature(this, featureID)); } /* public int eDerivedStructuralFeatureID(EStructuralFeature eStructuralFeature) { Class containerClass = eStructuralFeature.getContainerClass(); return containerClass == null ? eClass().getFeatureID(eStructuralFeature) : containerClass.isInstance(this) ? eDerivedStructuralFeatureID(eStructuralFeature.getFeatureID(), containerClass) : -1; } public void eOpenSet(EStructuralFeature eFeature, Object newValue) { EStructuralFeature openFeature = ExtendedMetaData.INSTANCE.getAffiliation(eClass(), eFeature); if (openFeature == null) { openFeature = (EStructuralFeature)eClass().getEStructuralFeature("any"); } if (openFeature != null) { if (!FeatureMapUtil.isFeatureMap(openFeature)) { openFeature = ExtendedMetaData.INSTANCE.getGroup(openFeature); } FeatureMap featureMap = (FeatureMap)eGet(openFeature); ((FeatureMap.Internal)featureMap).set(eFeature, newValue); } else { throw new IllegalArgumentException("The feature '" + eFeature.getName() + "' is not a valid changeable feature"); } } */ } //DataObjectImpl