diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-10 19:19:55 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2009-11-10 19:19:55 +0000 |
commit | 2a444004802173fa97afbc389fc4a6600b6d3f88 (patch) | |
tree | b175a25dd02206218987ab4bc730ad8e77b7756a /sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl | |
parent | c993ba575bdd1530b7bbc0c6a19c32e66fce4b89 (diff) |
moving SDO branches
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@834614 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl')
21 files changed, 12194 insertions, 0 deletions
diff --git a/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/AnyTypeDataObjectImpl.java b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/AnyTypeDataObjectImpl.java new file mode 100644 index 0000000000..b7d22c3be0 --- /dev/null +++ b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/AnyTypeDataObjectImpl.java @@ -0,0 +1,299 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.apache.tuscany.sdo.AnyTypeDataObject; +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.util.BasicSequence; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.util.BasicFeatureMap; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.ecore.util.InternalEList; +import org.eclipse.emf.ecore.xml.type.AnyType; +import org.eclipse.emf.ecore.xml.type.XMLTypePackage; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>EData Object Any Type</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.sdo.impl.AnyTypeDataObjectImpl#getMixed <em>Mixed</em>}</li> + * <li>{@link org.apache.tuscany.sdo.impl.AnyTypeDataObjectImpl#getAny <em>Any</em>}</li> + * <li>{@link org.apache.tuscany.sdo.impl.AnyTypeDataObjectImpl#getAnyAttribute <em>Any Attribute</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class AnyTypeDataObjectImpl extends DataObjectImpl implements AnyTypeDataObject +{ + /** + * The cached value of the '{@link #getMixed() <em>Mixed</em>}' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getMixed() + * @generated + * @ordered + */ + protected FeatureMap mixed = null; + + /** + * The cached value of the '{@link #getAnyAttribute() <em>Any Attribute</em>}' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getAnyAttribute() + * @generated + * @ordered + */ + protected FeatureMap anyAttribute = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected AnyTypeDataObjectImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getAnyTypeDataObject(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public FeatureMap getMixed() + { + if (mixed == null) + { + //mixed = new BasicFeatureMap(this, SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED); + mixed = new BasicSequence(new BasicFeatureMap(this, SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED)).featureMap(); + } + return mixed; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public FeatureMap getAny() + { + //return (FeatureMap)((FeatureMap)getMixed()).list(XMLTypePackage.eINSTANCE.getAnyType_Any()); + return new BasicSequence((FeatureMap.Internal)((FeatureMap)getMixed()).list(XMLTypePackage.eINSTANCE.getAnyType_Any())).featureMap(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public FeatureMap getAnyAttribute() + { + if (anyAttribute == null) + { + //anyAttribute = new BasicFeatureMap(this, SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE); + anyAttribute = new BasicSequence(new BasicFeatureMap(this, SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE)).featureMap(); + } + return anyAttribute; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) + { + if (featureID >= 0) + { + switch (eDerivedStructuralFeatureID(featureID, baseClass)) + { + case SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED: + return ((InternalEList)getMixed()).basicRemove(otherEnd, msgs); + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY: + return ((InternalEList)getAny()).basicRemove(otherEnd, msgs); + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + return ((InternalEList)getAnyAttribute()).basicRemove(otherEnd, msgs); + default: + return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs); + } + } + return eBasicSetContainer(null, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED: + if (coreType) return getMixed(); + return ((FeatureMap.Internal)getMixed()).getWrapper(); + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY: + if (coreType) return getAny(); + return ((FeatureMap.Internal)getAny()).getWrapper(); + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + if (coreType) return getAnyAttribute(); + return ((FeatureMap.Internal)getAnyAttribute()).getWrapper(); + } + return eDynamicGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED: + ((FeatureMap.Internal)getMixed()).set(newValue); + return; + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY: + ((FeatureMap.Internal)getAny()).set(newValue); + return; + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + ((FeatureMap.Internal)getAnyAttribute()).set(newValue); + return; + } + eDynamicSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED: + getMixed().clear(); + return; + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY: + getAny().clear(); + return; + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + getAnyAttribute().clear(); + return; + } + eDynamicUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED: + return mixed != null && !mixed.isEmpty(); + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY: + return !getAny().isEmpty(); + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + return anyAttribute != null && !anyAttribute.isEmpty(); + } + return eDynamicIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public int eBaseStructuralFeatureID(int derivedFeatureID, Class baseClass) + { + if (baseClass == AnyType.class) + { + switch (derivedFeatureID) + { + case SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED: return XMLTypePackage.ANY_TYPE__MIXED; + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY: return XMLTypePackage.ANY_TYPE__ANY; + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: return XMLTypePackage.ANY_TYPE__ANY_ATTRIBUTE; + default: return -1; + } + } + return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) + { + if (baseClass == AnyType.class) + { + switch (baseFeatureID) + { + case XMLTypePackage.ANY_TYPE__MIXED: return SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED; + case XMLTypePackage.ANY_TYPE__ANY: return SDOPackage.ANY_TYPE_DATA_OBJECT__ANY; + case XMLTypePackage.ANY_TYPE__ANY_ATTRIBUTE: return SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE; + default: return -1; + } + } + return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (mixed: "); + result.append(mixed); + result.append(", anyAttribute: "); + result.append(anyAttribute); + result.append(')'); + return result.toString(); + } + +} //EDataObjectAnyTypeImpl diff --git a/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/AttributeImpl.java b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/AttributeImpl.java new file mode 100644 index 0000000000..e02977e0e8 --- /dev/null +++ b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/AttributeImpl.java @@ -0,0 +1,836 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.util.List; + +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.model.ModelFactory; +import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl; +import org.apache.tuscany.sdo.model.internal.InternalFactory; +import org.apache.tuscany.sdo.model.internal.impl.InternalFactoryImpl; +import org.apache.tuscany.sdo.util.BasicSequence; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.apache.tuscany.sdo.util.SDOUtil; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.EAttributeImpl; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.ExtendedMetaData; +import org.eclipse.emf.ecore.util.FeatureMap; + +import commonj.sdo.Property; +import commonj.sdo.Sequence; +import commonj.sdo.Type; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Attribute</b></em>'. + * <!-- end-user-doc --> + * <p> + * </p> + * + * @generated + */ +public class AttributeImpl extends EAttributeImpl implements Property, org.apache.tuscany.sdo.model.Property/*, DataObject*/ +{ + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected AttributeImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getAttribute(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Object getDefault() + { + return getDefaultValue(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isReadOnly() + { + //return "true".equals(EcoreUtil.getAnnotation(this, "commonj.sdo", "readOnly")); + return !isChangeable(); //TODO semantics don't exactly match? + } + + /** + * Single-valued SDO properties behave as EMF unsettable, multi-valued properties as EMF !unsettable + */ + public boolean isUnsettable() + { + return !isMany(); + } + + public boolean isUnique() + { + return false; + } + + protected List aliasNames = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getAliasNames() + { + if (aliasNames == null) + { + aliasNames = DataObjectUtil.getAliasNames(this); + } + return aliasNames; + } + + public static Type INTERNAL_BASE64_BYTES = ((InternalFactoryImpl)InternalFactory.INSTANCE).getBase64Bytes(); + public static Type INTERNAL_QNAME = ((InternalFactoryImpl)InternalFactory.INSTANCE).getQName(); + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Type getType() + { + EClassifier eType = getEType(); + if (eType == INTERNAL_BASE64_BYTES) + return ((ModelFactoryImpl)ModelFactory.INSTANCE).getBytes(); + else if (eType == INTERNAL_QNAME) + return ((ModelFactoryImpl)ModelFactory.INSTANCE).getURI(); + return (Type)eType; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Type getContainingType() + { + return (Type)getEContainingClass(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Property getOpposite() + { + return null; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isContainment() + { + return false; + } + + protected EStructuralFeature.Internal.SettingDelegate createFeatureMapSettingDelegate() + { + return new InternalSettingDelegateSequence(this); + } + + public static class InternalSettingDelegateSequence extends InternalSettingDelegateMany + { + InternalSettingDelegateSequence(EStructuralFeature feature) + { + super(InternalSettingDelegateMany.FEATURE_MAP, feature); + } + + protected EStructuralFeature.Setting createDynamicSetting(InternalEObject owner) + { + FeatureMap.Internal featureMap = (FeatureMap.Internal)super.createDynamicSetting(owner); + new BasicSequence(featureMap); + return featureMap; + } + } + + public boolean isNullable() + { + String isNillable = EcoreUtil.getAnnotation(this, ExtendedMetaData.ANNOTATION_URI, "nillable"); + return isNillable != null && "true".equals(isNillable); + } + + public boolean isOpenContent() + { + return SDOUtil.isDocumentRoot(getContainingType()); + } + + public List getInstanceProperties() { + return DataObjectUtil.getMetaObjectInstanceProperties(this); + } + + public Object get(Property property) { + return DataObjectUtil.getMetaObjectInstanceProperty(this, property); + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // org.apache.tuscany.sdo.model.Property methods + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + + public List getAliasName() { + return this.getAliasNames(); + } + + public Sequence getAny() { + throw new UnsupportedOperationException(); + } + + public void unsetContainment() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetContainment() { + return false; + } + + public void setMany(boolean value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void unsetMany() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetMany() { + return isMany(); + } + + public void setReadOnly(boolean value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void unsetReadOnly() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetReadOnly() { + return isReadOnly(); + } + + public org.apache.tuscany.sdo.model.Type getType_() { + return (org.apache.tuscany.sdo.model.Type)getType(); + } + + public void setType(org.apache.tuscany.sdo.model.Type value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public Sequence getAnyAttribute() { + throw new UnsupportedOperationException(); + } + + public String getDefault_() { + return (String) this.getDefault(); + } + + public void setDefault_(String value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public org.apache.tuscany.sdo.model.Property getOpposite_() { + return (org.apache.tuscany.sdo.model.Property) getOpposite(); + } + + public void setOpposite_(org.apache.tuscany.sdo.model.Property value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void setContainment(boolean value) { + throw new UnsupportedOperationException(); + } + + public void setNullable(boolean value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void unsetNullable() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetNullable() { + return isUnsettable(); + } + + public void unsetName() + { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetName() + { + return true; + } + + public void unsetOpposite() + { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetOpposite() + { + return getOpposite() != null; + } + + public void unsetType() + { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetType() + { + return true; + } + + public void unsetDefault() + { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetDefault() + { + return getDefault() != null; + } + + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // DataObject method implementations + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + /* + public Object get(int propertyIndex) { + return DataObjectUtil.get(this, propertyIndex); + } + + public void set(int propertyIndex, Object value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSet(int propertyIndex) { + return DataObjectUtil.isSet(this, propertyIndex); + } + + public void unset(int propertyIndex) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public Object get(Property property) { + return DataObjectUtil.get(this, ((EStructuralFeature)property).getFeatureID()); + } + + public void set(Property property, Object value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSet(Property property) { + return DataObjectUtil.isSet(this, ((EStructuralFeature)property).getFeatureID()); + } + + public void unset(Property property) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject getContainer() { + return (DataObject)eContainer(); + } + + public Property getContainmentProperty() { + return (Property)eContainmentFeature(); + } + + // Remaining DataObject methods are (will be) implemented as straight delegation to DataObjectUtil + + public Object get(String path) { + return DataObjectUtil.get(this, path); + } + + public void set(String path, Object value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSet(String path) { + return DataObjectUtil.isSet(this, path); + } + + public void unset(String path) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean getBoolean(String path) { + return DataObjectUtil.getBoolean(get(path)); + } + + public byte getByte(String path) { + return DataObjectUtil.getByte(get(path)); + } + + public char getChar(String path) { + return DataObjectUtil.getChar(get(path)); + } + + public double getDouble(String path) { + return DataObjectUtil.getDouble(get(path)); + } + + public float getFloat(String path) { + return DataObjectUtil.getFloat(get(path)); + } + + public int getInt(String path) { + return DataObjectUtil.getInt(get(path)); + } + + public long getLong(String path) { + return DataObjectUtil.getLong(get(path)); + } + + public short getShort(String path) { + return DataObjectUtil.getShort(get(path)); + } + + public byte[] getBytes(String path) { + return DataObjectUtil.getBytes(get(path)); + } + + public BigDecimal getBigDecimal(String path) { + return DataObjectUtil.getBigDecimal(get(path)); + } + + public BigInteger getBigInteger(String path) { + return DataObjectUtil.getBigInteger(get(path)); + } + + public DataObject getDataObject(String path) { + return (DataObject)get(path); + } + + public Date getDate(String path) { + return DataObjectUtil.getDate(get(path)); + } + + public String getString(String path) { + return DataObjectUtil.getString(get(path)); + } + + public List getList(String path) { + return (List)get(path); + } + + public Sequence getSequence(String path) { + return (Sequence)get(path); + } + + public void setBoolean(String path, boolean value) { + set(path, new Boolean(value)); + } + + public void setByte(String path, byte value) { + set(path, new Byte(value)); + } + + public void setChar(String path, char value) { + set(path, new Character(value)); + } + + public void setDouble(String path, double value) { + set(path, new Double(value)); + } + + public void setFloat(String path, float value) { + set(path, new Float(value)); + } + + public void setInt(String path, int value) { + set(path, new Integer(value)); + } + + public void setLong(String path, long value) { + set(path, new Long(value)); + } + + public void setShort(String path, short value) { + set(path, new Short(value)); + } + + public void setBytes(String path, byte[] value) { + set(path, value); + } + + public void setBigDecimal(String path, BigDecimal value) { + set(path, value); + } + + public void setBigInteger(String path, BigInteger value) { + set(path, value); + } + + public void setDataObject(String path, DataObject value) { + set(path, value); + } + + public void setDate(String path, Date value) { + set(path, value); + } + + public void setString(String path, String value) { + set(path, value); + } + + public void setList(String path, List value) { + set(path, value); + } + + public boolean getBoolean(int propertyIndex) { + return DataObjectUtil.getBoolean(this, propertyIndex); + } + + public byte getByte(int propertyIndex) { + return DataObjectUtil.getByte(this, propertyIndex); + } + + public char getChar(int propertyIndex) { + return DataObjectUtil.getChar(this, propertyIndex); + } + + public double getDouble(int propertyIndex) { + return DataObjectUtil.getDouble(this, propertyIndex); + } + + public float getFloat(int propertyIndex) { + return DataObjectUtil.getFloat(this, propertyIndex); + } + + public int getInt(int propertyIndex) { + return DataObjectUtil.getInt(this, propertyIndex); + } + + public long getLong(int propertyIndex) { + return DataObjectUtil.getLong(this, propertyIndex); + } + + public short getShort(int propertyIndex) { + return DataObjectUtil.getShort(this, propertyIndex); + } + + public byte[] getBytes(int propertyIndex) { + return DataObjectUtil.getBytes(this, propertyIndex); + } + + public BigDecimal getBigDecimal(int propertyIndex) { + return DataObjectUtil.getBigDecimal(this, propertyIndex); + } + + public BigInteger getBigInteger(int propertyIndex) { + return DataObjectUtil.getBigInteger(this, propertyIndex); + } + + public DataObject getDataObject(int propertyIndex) { + return DataObjectUtil.getDataObject(this, propertyIndex); + } + + public Date getDate(int propertyIndex) { + return DataObjectUtil.getDate(this, propertyIndex); + } + + public String getString(int propertyIndex) { + return DataObjectUtil.getString(this, propertyIndex); + } + + public List getList(int propertyIndex) { + return DataObjectUtil.getList(this, propertyIndex); + } + + public Sequence getSequence(int propertyIndex) { + return DataObjectUtil.getSequence(this, propertyIndex); + } + + public void setBoolean(int propertyIndex, boolean value) { + set(propertyIndex, new Boolean(value)); + } + + public void setByte(int propertyIndex, byte value) { + set(propertyIndex, new Byte(value)); + } + + public void setChar(int propertyIndex, char value) { + set(propertyIndex, new Character(value)); + } + + public void setDouble(int propertyIndex, double value) { + set(propertyIndex, new Double(value)); + } + + public void setFloat(int propertyIndex, float value) { + set(propertyIndex, new Float(value)); + } + + public void setInt(int propertyIndex, int value) { + set(propertyIndex, new Integer(value)); + } + + public void setLong(int propertyIndex, long value) { + set(propertyIndex, new Long(value)); + } + + public void setShort(int propertyIndex, short value) { + set(propertyIndex, new Short(value)); + } + + public void setBytes(int propertyIndex, byte[] value) { + set(propertyIndex, value); + } + + public void setBigDecimal(int propertyIndex, BigDecimal value) { + set(propertyIndex, value); + } + + public void setBigInteger(int propertyIndex, BigInteger value) { + set(propertyIndex, value); + } + + public void setDataObject(int propertyIndex, DataObject value) { + set(propertyIndex, value); + } + + public void setDate(int propertyIndex, Date value) { + set(propertyIndex, value); + } + + public void setString(int propertyIndex, String value) { + set(propertyIndex, value); + } + + public void setList(int propertyIndex, List value) { + set(propertyIndex, value); + } + + public boolean getBoolean(Property property) { + return DataObjectUtil.getBoolean(this, property); + } + + public byte getByte(Property property) { + return DataObjectUtil.getByte(this, property); + } + + public char getChar(Property property) { + return DataObjectUtil.getChar(this, property); + } + + public double getDouble(Property property) { + return DataObjectUtil.getDouble(this, property); + } + + public float getFloat(Property property) { + return DataObjectUtil.getFloat(this, property); + } + + public int getInt(Property property) { + return DataObjectUtil.getInt(this, property); + } + + public long getLong(Property property) { + return DataObjectUtil.getLong(this, property); + } + + public short getShort(Property property) { + return DataObjectUtil.getShort(this, property); + } + + public byte[] getBytes(Property property) { + return DataObjectUtil.getBytes(this, property); + } + + public BigDecimal getBigDecimal(Property property) { + return DataObjectUtil.getBigDecimal(this, property); + } + + public BigInteger getBigInteger(Property property) { + return DataObjectUtil.getBigInteger(this, property); + } + + public DataObject getDataObject(Property property) { + return DataObjectUtil.getDataObject(this, property); + } + + public Date getDate(Property property) { + return DataObjectUtil.getDate(this, property); + } + + public String getString(Property property) { + return DataObjectUtil.getString(this, property); + } + + public List getList(Property property) { + return DataObjectUtil.getList(this, property); + } + + public Sequence getSequence(Property property) { + return DataObjectUtil.getSequence(this, property); + } + + public void setBoolean(Property property, boolean value) { + set(property, new Boolean(value)); + } + + public void setByte(Property property, byte value) { + set(property, new Byte(value)); + } + + public void setChar(Property property, char value) { + set(property, new Character(value)); + } + + public void setDouble(Property property, double value) { + set(property, new Double(value)); + } + + public void setFloat(Property property, float value) { + set(property, new Float(value)); + } + + public void setInt(Property property, int value) { + set(property, new Integer(value)); + } + + public void setLong(Property property, long value) { + set(property, new Long(value)); + } + + public void setShort(Property property, short value) { + set(property, new Short(value)); + } + + public void setBytes(Property property, byte[] value) { + set(property, value); + } + + public void setBigDecimal(Property property, BigDecimal value) { + set(property, value); + } + + public void setBigInteger(Property property, BigInteger value) { + set(property, value); + } + + public void setDataObject(Property property, DataObject value) { + set(property, value); + } + + public void setDate(Property property, Date value) { + set(property, value); + } + + public void setString(Property property, String value) { + set(property, value); + } + + public void setList(Property property, List value) { + set(property, value); + } + + public DataObject createDataObject(String propertyName) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(String propertyName, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property, Type type) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void delete() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataGraph getDataGraph() { + return DataObjectUtil.getDataGraph(this); + } + + public Sequence getSequence() { + EAttribute mixedFeature = BasicExtendedMetaData.INSTANCE.getMixedFeature(eClass()); + return mixedFeature != null ? (Sequence)eGet(mixedFeature, true, false) : null; + } + + public List getInstanceProperties() { + return DataObjectUtil.getInstanceProperties(this); + } + + public DataObject getRootObject() { + return DataObjectUtil.getRootObject(this); + } + + public ChangeSummary getChangeSummary() { + // TODO: implement this method + throw new UnsupportedOperationException(); + } + + public void detach() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + //DataObjectUtil.detach(this); + } + + public Property getProperty(String propertyName) { + return DataObjectUtil.getProperty(this, propertyName); + } + */ + +} //AttributeImpl diff --git a/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummaryImpl.java b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummaryImpl.java new file mode 100644 index 0000000000..55f3d5449d --- /dev/null +++ b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummaryImpl.java @@ -0,0 +1,876 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.util.BasicSequence; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.UniqueEList; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.change.ChangeDescription; +import org.eclipse.emf.ecore.change.FeatureChange; +import org.eclipse.emf.ecore.change.impl.ChangeDescriptionImpl; +import org.eclipse.emf.ecore.change.util.ChangeRecorder; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.util.BasicExtendedMetaData; +import org.eclipse.emf.ecore.util.DelegatingFeatureMap; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.ecore.util.FeatureMapUtil; +import org.eclipse.emf.ecore.util.InternalEList; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Sequence; + + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>EChange Summary</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.sdo.impl.ChangeSummaryImpl#getEDataGraph <em>EData Graph</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class ChangeSummaryImpl extends ChangeDescriptionImpl implements ChangeSummary +{ + /** + * The cached value of the '{@link #getEDataGraph() <em>EData Graph</em>}' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getEDataGraph() + * @generated + * @ordered + */ + protected DataGraph eDataGraph = null; + + protected DataObject dataObject = null; + protected SDOChangeRecorder changeRecorder = null; + + protected Set cachedDeletedObjects = null; + protected List cachedCreatedObjects = null; + protected Map cachedSDOObjectChanges = null; + protected boolean isStale = false; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected ChangeSummaryImpl() + { + super(); + cachedSDOObjectChanges = createThreadSafeMap(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getChangeSummary(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isLogging() + { + return changeRecorder != null; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public DataGraph getEDataGraph() + { + return eDataGraph; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain basicSetEDataGraph(DataGraph newEDataGraph, NotificationChain msgs) + { + DataGraph oldEDataGraph = eDataGraph; + eDataGraph = newEDataGraph; + if (eNotificationRequired()) + { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH, oldEDataGraph, newEDataGraph); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setEDataGraph(DataGraph newEDataGraph) + { + if (newEDataGraph != eDataGraph) + { + NotificationChain msgs = null; + if (eDataGraph != null) + msgs = ((InternalEObject)eDataGraph).eInverseRemove(this, SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY, DataGraph.class, msgs); + if (newEDataGraph != null) + msgs = ((InternalEObject)newEDataGraph).eInverseAdd(this, SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY, DataGraph.class, msgs); + msgs = basicSetEDataGraph(newEDataGraph, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH, newEDataGraph, newEDataGraph)); + } + + public DataObject getDataObject() + { + return dataObject; + } + + public void setDataObject(DataObject newDataObject) + { + dataObject = newDataObject; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void beginLogging() + { + if (isLogging()) + { + throw new IllegalStateException("Already logging"); + } + + getObjectsToAttach().clear(); + getObjectChanges().clear(); + getResourceChanges().clear(); + oldContainmentInformation = null; + + beginRecording(); +// if (eNotificationRequired()) +// eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.ECHANGE_SUMMARY__LOGGING, false, true)); + } + + /** + * + */ + private void beginRecording() { + changeRecorder = new SDOChangeRecorder(); + if (eDataGraph != null) + { + changeRecorder.beginRecording(Collections.singleton(((DataGraphImpl)eDataGraph).getRootResource())); + } + else if (dataObject != null) + { + changeRecorder.beginRecording(Collections.singleton(dataObject)); + } + else + { + throw new IllegalStateException("ChangeSummary not attached to any data objects"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void resumeLogging() + { + if (isLogging()) + { + throw new IllegalStateException("Already logging"); + } + + oldContainmentInformation = null; + + beginRecording(); +// if (eNotificationRequired()) +// eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.ECHANGE_SUMMARY__LOGGING, false, true)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) + { + if (featureID >= 0) + { + switch (eDerivedStructuralFeatureID(featureID, baseClass)) + { + case SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH: + if (eDataGraph != null) + msgs = ((InternalEObject)eDataGraph).eInverseRemove(this, SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY, DataGraph.class, msgs); + return basicSetEDataGraph((DataGraph)otherEnd, msgs); + default: + return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs); + } + } + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + return eBasicSetContainer(otherEnd, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) + { + if (featureID >= 0) + { + switch (eDerivedStructuralFeatureID(featureID, baseClass)) + { + case SDOPackage.CHANGE_SUMMARY__OBJECT_CHANGES: + return ((InternalEList)getObjectChanges()).basicRemove(otherEnd, msgs); + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_ATTACH: + return ((InternalEList)getObjectsToAttach()).basicRemove(otherEnd, msgs); + case SDOPackage.CHANGE_SUMMARY__RESOURCE_CHANGES: + return ((InternalEList)getResourceChanges()).basicRemove(otherEnd, msgs); + case SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH: + return basicSetEDataGraph(null, msgs); + default: + return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs); + } + } + return eBasicSetContainer(null, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case SDOPackage.CHANGE_SUMMARY__OBJECT_CHANGES: + if (coreType) return getObjectChanges(); + else return getObjectChanges().map(); + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_DETACH: + return getObjectsToDetach(); + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_ATTACH: + return getObjectsToAttach(); + case SDOPackage.CHANGE_SUMMARY__RESOURCE_CHANGES: + return getResourceChanges(); + case SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH: + return getEDataGraph(); +// case SDOPackage.CHANGE_SUMMARY__EDATA_OBJECT: +// return getEDataObject(); + } + return eDynamicGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case SDOPackage.CHANGE_SUMMARY__OBJECT_CHANGES: + ((EStructuralFeature.Setting)getObjectChanges()).set(newValue); + return; + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_DETACH: + getObjectsToDetach().clear(); + getObjectsToDetach().addAll((Collection)newValue); + return; + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_ATTACH: + getObjectsToAttach().clear(); + getObjectsToAttach().addAll((Collection)newValue); + return; + case SDOPackage.CHANGE_SUMMARY__RESOURCE_CHANGES: + getResourceChanges().clear(); + getResourceChanges().addAll((Collection)newValue); + return; + case SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH: + setEDataGraph((DataGraph)newValue); + return; + } + eDynamicSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case SDOPackage.CHANGE_SUMMARY__OBJECT_CHANGES: + getObjectChanges().clear(); + return; + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_DETACH: + getObjectsToDetach().clear(); + return; + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_ATTACH: + getObjectsToAttach().clear(); + return; + case SDOPackage.CHANGE_SUMMARY__RESOURCE_CHANGES: + getResourceChanges().clear(); + return; + case SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH: + setEDataGraph((DataGraph)null); + return; + } + eDynamicUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case SDOPackage.CHANGE_SUMMARY__OBJECT_CHANGES: + return objectChanges != null && !objectChanges.isEmpty(); + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_DETACH: + return objectsToDetach != null && !objectsToDetach.isEmpty(); + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_ATTACH: + return objectsToAttach != null && !objectsToAttach.isEmpty(); + case SDOPackage.CHANGE_SUMMARY__RESOURCE_CHANGES: + return resourceChanges != null && !resourceChanges.isEmpty(); + case SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH: + return eDataGraph != null; + } + return eDynamicIsSet(featureID); + } + + protected void uncache() + { + cachedDeletedObjects = null; + cachedCreatedObjects = null; + cachedSDOObjectChanges.clear(); + } + + protected class SDOChangeRecorder extends ChangeRecorder + { + public SDOChangeRecorder() + { + super(); + } + + public void beginRecording(ChangeDescription changeDescription, Collection rootObjects) + { + uncache(); + super.beginRecording(changeDescription, rootObjects); + } + + protected ChangeDescription createChangeDescription() + { + return ChangeSummaryImpl.this; + } + + protected FeatureChange createFeatureChange(EObject eObject, EStructuralFeature eStructuralFeature, Object value, boolean isSet) + { + Property property = (Property)eStructuralFeature; + if (property.isReadOnly()) + { + if (((DataObject)eObject).getDataGraph() != null) + { + throw + new IllegalStateException + ("The property '" + property.getName() + "' of type '" + + property.getContainingType().getName() + "' is read only"); + } + } + return (FeatureChange)SDOFactory.eINSTANCE.createChangeSummarySetting(eStructuralFeature, value, isSet); + } + + protected void consolidateChanges() + { + uncache(); + isStale = false; + + // TODO remove this fixup when https://bugs.eclipse.org/bugs/show_bug.cgi?id=177235 is + // available to us (i.e. we update to EMF 2.3) -- see Tuscany-1164 + boolean isUncontainedRoot = dataObject != null + && ((EObject)dataObject).eContainer() == null + && ((EObject)dataObject).eResource() == null; + + super.consolidateChanges(); + + if(isUncontainedRoot && changeDescription.getObjectsToAttach().contains(dataObject)) { + changeDescription.getObjectsToAttach().remove(dataObject); + } + + } + + protected void addAdapter(Notifier notifier) + { + if (!loadingTargets) return; // Optimize ChangeSummary to not record changes in newly created DOs + + if (notifier instanceof DataObjectImpl) + ((DataObjectImpl)notifier).setChangeRecorder(this); + else + super.addAdapter(notifier); + } + + protected void removeAdapter(Notifier notifier) + { + if (notifier instanceof DataObjectImpl) + ((DataObjectImpl)notifier).setChangeRecorder(null); + else + super.removeAdapter(notifier); + } + + public void notifyChanged(Notification notification) + { + super.notifyChanged(notification); + + Object notifier = notification.getNotifier(); + if (notifier instanceof EObject) + { + cachedSDOObjectChanges.remove(notifier); + Object feature = notification.getFeature(); + if (feature instanceof Property && ((Property)feature).isContainment()) + { + cachedCreatedObjects = null; + cachedDeletedObjects = null; + oldContainmentInformation = null; + } + isStale = true; + } + } + + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void endLogging() + { + if (!isLogging()) + { + throw new IllegalStateException("Not currently logging"); + } + + changeRecorder.endRecording(); + changeRecorder.dispose(); + changeRecorder = null; +// if (eNotificationRequired()) +// eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.ECHANGE_SUMMARY__LOGGING, true, false)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isCreated(DataObject dataObject) + { + return getCachedCreatedObjects().contains(dataObject); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isDeleted(DataObject dataObject) + { + return getCachedDeletedObjects().contains(dataObject); + } + + protected Set getCachedDeletedObjects() + { + if (cachedDeletedObjects == null) + { + if (isStale()) changeRecorder.consolidateChanges(); + cachedDeletedObjects = new HashSet(); + for (Iterator i = EcoreUtil.getAllContents(getObjectsToAttach()); i.hasNext(); ) + { + cachedDeletedObjects.add(i.next()); + } + } + return cachedDeletedObjects; + } + + protected List getCachedCreatedObjects() + { + if (cachedCreatedObjects == null) + { + if (isStale()) changeRecorder.consolidateChanges(); + cachedCreatedObjects = super.getObjectsToDetach(); + } + return cachedCreatedObjects; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getChangedDataObjects() + { + EList result = new UniqueEList.FastCompare(getCachedDeletedObjects()); + result.addAll(getCachedCreatedObjects()); + for (Iterator i = getObjectChanges().iterator(); i.hasNext(); ) + { + Map.Entry entry = (Map.Entry)i.next(); + result.add(entry.getKey()); + } + return result; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getOldValues(DataObject dataObject) + { + List sdoSettings = (List)cachedSDOObjectChanges.get(dataObject); + if (sdoSettings != null) + { + return sdoSettings; + } + + if (isStale()) changeRecorder.consolidateChanges(); + List settings = (List)getObjectChanges().get(dataObject); + if (settings == null) + { + settings = Collections.EMPTY_LIST; + } + else + { + for (int i = 0; i < settings.size(); i++) + { + FeatureChange change = (FeatureChange)settings.get(i); + EStructuralFeature feature = change.getFeature(); + if (FeatureMapUtil.isFeatureMap(feature)) + { + final List values = (List)change.getValue(); + if (sdoSettings == null) + { + sdoSettings = new BasicEList(settings); + } + DelegatingFeatureMap featureMap = new DelegatingFeatureMap(((InternalEObject)dataObject), feature) + { + protected final List theList = values; + + protected List delegateList() + { + return theList; + } + }; + + // create new settings and replace the setting for mixed feature + sdoSettings.set(i, SDOFactory.eINSTANCE.createChangeSummarySetting(feature, new BasicSequence(featureMap), change.isSet())); + // add all derived features + for (int k = 0; k < featureMap.size(); k++) + { + EStructuralFeature f = featureMap.getEStructuralFeature(k); + sdoSettings.add(SDOFactory.eINSTANCE.createChangeSummarySetting(f, featureMap.get(f, false), true)); + } + } + } + } + sdoSettings = (sdoSettings != null) ? sdoSettings : settings; + cachedSDOObjectChanges.put(dataObject, sdoSettings); + return sdoSettings; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isModified(DataObject dataObject) + { + return getObjectChanges().containsKey(dataObject) && !isDeleted(dataObject) && !isCreated(dataObject); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void summarize() + { + if (!isLogging()) + { + throw new IllegalStateException("Not currently logging"); + } + + changeRecorder.summarize(); + } + + public Setting getOldValue(DataObject dataObject, Property property) + { + for (Iterator i = getOldValues(dataObject).iterator(); i.hasNext(); ) + { + Setting setting = (Setting)i.next(); + if (setting.getProperty() == property) + { + return setting; + } + } + + return null; + } + + public DataObject getOldContainer(DataObject dataObject) + { + return (DataObject)getOldContainer((EObject)dataObject); + } + + public Property getOldContainmentProperty(DataObject dataObject) + { + return (Property)getOldContainmentFeature((EObject)dataObject); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Sequence getOldSequence(DataObject dataObject) + { + EAttribute mixedFeature = BasicExtendedMetaData.INSTANCE.getMixedFeature((EClass)dataObject.getType()); + if (mixedFeature != null) + { + return (Sequence)getOldValue(dataObject, (Property)mixedFeature).getValue(); + } + return null; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void undoChanges() + { + if (isLogging()) + { + changeRecorder.summarize(); + } + else + { + uncache(); + } + apply(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataGraph getDataGraph() + { + return getEDataGraph(); + } + + protected Map getOldContainmentInformation() + { + if (oldContainmentInformation == null) + { + if (isStale()) changeRecorder.consolidateChanges(); + super.getOldContainmentInformation(); + } + return oldContainmentInformation; + } + + protected boolean isStale() + { + return isLogging() && isStale; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject getRootObject() + { + if (eDataGraph != null) + { + return eDataGraph.getRootObject(); + } + if (dataObject != null) + { + return dataObject; + } + return null; + } + + static protected boolean isContainmentReference(Object feature) + { + return feature instanceof EReference && ((EReference) feature).isContainment(); + } + + public DataObject getOldDataObject(DataObject dataObject) + { + //TODO: Fix this method. Currently, it has the side effect of undoing the unset of contained children references + // of root deleted objects - i.e., when featureChange.apply(oldDataObject) is called. + // + List changes = (List) getObjectChanges().get(dataObject); + if (changes == null) + return dataObject; + EObject oldDataObject = EcoreUtil.copy((EObject)dataObject); + for (Iterator fIter = changes.iterator(); fIter.hasNext(); ) + { + FeatureChange featureChange = (FeatureChange)fIter.next(); + featureChange.apply(oldDataObject); + EStructuralFeature feature = featureChange.getFeature(); + if (FeatureMapUtil.isFeatureMap(feature)) + { + FeatureMap featureMap = (FeatureMap) oldDataObject.eGet(feature); + for (int index = featureMap.size(); index != 0;) + if (isContainmentReference(featureMap.getEStructuralFeature(--index))) + featureMap.setValue(index, getOldDataObject((DataObject) featureMap.getValue(index))); + } + else if (isContainmentReference(feature)) + { + Object value = oldDataObject.eGet(feature); + if (feature.isMany()) + { + changes = (List) value; + for (int index = changes.size(); index != 0;) + changes.set(--index, getOldDataObject((DataObject) changes.get(index))); // Java pushes stack from left to right + } + else + oldDataObject.eSet(feature, getOldDataObject((DataObject) value)); + } + } + + return (DataObject)oldDataObject; + } + + private static Class concurrentHashMapClazz = null; + private static boolean isThreadSafeMapClazzIdentified = false; + + private Map createThreadSafeMap() + { + if (!isThreadSafeMapClazzIdentified) + { + concurrentHashMapClazz = loadConcurrentHashMapClazz(); + isThreadSafeMapClazzIdentified = true; + } + Map threadSafeMap = null; + if (concurrentHashMapClazz == null) + { + threadSafeMap = Collections.synchronizedMap(new HashMap()); + } + else + { + try + { + threadSafeMap = (Map)concurrentHashMapClazz.newInstance(); + } + catch (InstantiationException e) + { + throw new RuntimeException(e); + } + catch (IllegalAccessException e) + { + throw new RuntimeException(e); + } + } + return threadSafeMap; + } + + private static String[] concurrentHashMapClazzNames = new String[] { + "java.util.concurrent.ConcurrentHashMap", + "edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap"}; + + private static Class loadConcurrentHashMapClazz() + { + Class mapClazz = null; + for (int i = 0; i < concurrentHashMapClazzNames.length; i++) + { + String concurrentHashMapClazzName = concurrentHashMapClazzNames[i]; + try + { + mapClazz = Class.forName(concurrentHashMapClazzName, true, Thread.currentThread().getContextClassLoader()); + } + catch (Exception ignored) {} + if (mapClazz != null) + { + break; + } + try + { + mapClazz = Class.forName(concurrentHashMapClazzName); + } + catch (Exception ignored) {} + if (mapClazz != null) + { + break; + } + } + return mapClazz; + } + +} //ChangeSummaryImpl diff --git a/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummarySettingImpl.java b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummarySettingImpl.java new file mode 100644 index 0000000000..d1cd1d3e05 --- /dev/null +++ b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummarySettingImpl.java @@ -0,0 +1,113 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.util.Map; + +import org.apache.tuscany.sdo.SDOPackage; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.change.impl.FeatureChangeImpl; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.Property; +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>EChange Summary Setting</b></em>'. + * <!-- end-user-doc --> + * <p> + * </p> + * + * @generated + */ +public class ChangeSummarySettingImpl extends FeatureChangeImpl implements ChangeSummary.Setting +{ + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected ChangeSummarySettingImpl() + { + super(); + } + + protected ChangeSummarySettingImpl(EStructuralFeature feature, Object value, boolean isSet) + { + super(feature, value, isSet); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getChangeSummarySetting(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Object getValue() + { + EStructuralFeature feature = getFeature(); + if (feature.isMany()) + { + if (value == null) + { + EObject eObject = (EObject)((Map.Entry)eContainer()).getKey(); + value = getListValue((EList)eObject.eGet(feature)); + } + return value; + } + else + { + return super.getValue(); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Property getProperty() + { + return (Property)getFeature(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isSet() + { + return super.isSet(); + } + +} //EChangeSummarySettingImpl diff --git a/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/ClassImpl.java b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/ClassImpl.java new file mode 100644 index 0000000000..cd37620f4c --- /dev/null +++ b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/ClassImpl.java @@ -0,0 +1,1127 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.model.ModelFactory; +import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl; +import org.apache.tuscany.sdo.util.BasicSequence; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.UniqueEList; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.impl.EClassImpl; +import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; +import org.eclipse.emf.ecore.util.ExtendedMetaData; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.ecore.util.FeatureMapUtil; + +import commonj.sdo.Property; +import commonj.sdo.Sequence; +import commonj.sdo.Type; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Class</b></em>'. + * <!-- end-user-doc --> + * <p> + * </p> + * + * @generated + */ +public class ClassImpl extends EClassImpl implements Type, org.apache.tuscany.sdo.model.Type/*, DataObject*/ +{ + private static final long serialVersionUID = 1L; + + private static final Property UNINITIALIZED_PROPERTY = SDOFactory.eINSTANCE.createAttribute(); + + private Property changeSummaryPropertyCache = UNINITIALIZED_PROPERTY; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected ClassImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getClass_(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String getURI() + { + return getEPackage().getNsURI(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isDataType() + { + return false; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isOpen() + { + final List properties = getExtendedProperties(); + if (properties != Collections.EMPTY_LIST) + { + for (int i = 0, count = properties.size(); i < count; ++i) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)properties.get(i); + if (isOpenFeatureMap(eStructuralFeature)) + return true; + } + } + + for (final Iterator iterator = getBaseTypes().iterator() ; iterator.hasNext(); ) + { + Type baseType = (Type)iterator.next(); + if (baseType.isOpen()) + return true; + } + + return false; + } + + private static final EStructuralFeature UNINITIALIZED_SEQUENCE_FEATURE = (EAttribute)SDOFactory.eINSTANCE.createAttribute(); + protected static final EStructuralFeature VIRTUAL_SEQUENCE_FEATURE = (EAttribute)SDOFactory.eINSTANCE.createAttribute(); + + private EStructuralFeature sequenceFeature = UNINITIALIZED_SEQUENCE_FEATURE; + + public EStructuralFeature getSequenceFeature() + { + if (sequenceFeature == UNINITIALIZED_SEQUENCE_FEATURE) + { + EStructuralFeature sequenceFeatureCandidate = null; + boolean hasNonDerivedFeatures = false; + + for (Iterator iterator = getEAllStructuralFeatures().iterator(); iterator.hasNext(); ) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)iterator.next(); + if (!eStructuralFeature.isDerived()) { + if (sequenceFeatureCandidate == null && isSequenceFeatureMap(eStructuralFeature)) + sequenceFeatureCandidate = eStructuralFeature; + else if (isElementFeature(eStructuralFeature) && !DataObjectUtil.isInternalProperty(eStructuralFeature)) + hasNonDerivedFeatures = true; + } + } + + sequenceFeature = + sequenceFeatureCandidate != null && hasNonDerivedFeatures ? + VIRTUAL_SEQUENCE_FEATURE : + sequenceFeatureCandidate; + } + + return sequenceFeature; + } + + protected boolean isSequenceFeatureMap(EStructuralFeature eStructuralFeature) + { + switch (ExtendedMetaData.INSTANCE.getFeatureKind(eStructuralFeature)) + { + case ExtendedMetaData.ELEMENT_WILDCARD_FEATURE: + return eStructuralFeature.getUpperBound() != 1; + case ExtendedMetaData.GROUP_FEATURE: + return true; + } + return false; + } + + protected boolean isElementFeature(EStructuralFeature eStructuralFeature) + { + switch (ExtendedMetaData.INSTANCE.getFeatureKind(eStructuralFeature)) + { + case ExtendedMetaData.ATTRIBUTE_FEATURE: + case ExtendedMetaData.ATTRIBUTE_WILDCARD_FEATURE: + return false; + } + return true; + } + + public List getVirtualSequenceProperties() + { + List result = new ArrayList(); + for (Iterator iterator = getEAllStructuralFeatures().iterator(); iterator.hasNext(); ) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)iterator.next(); + if (!eStructuralFeature.isDerived() && isElementFeature(eStructuralFeature)) + result.add(eStructuralFeature); + } + return result; + } + + public void setSequenceFeature(EAttribute sequenceFeature) + { + getEStructuralFeatures().add(sequenceFeature); + this.sequenceFeature = sequenceFeature; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isSequenced() + { + return getSequenceFeature() != null; + } + + protected List aliasNames = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getAliasNames() + { + if (aliasNames == null) + { + aliasNames = DataObjectUtil.getAliasNames(this); + } + return aliasNames; + } + + protected List declaredProperties = null; + + public List getDeclaredProperties() + { + if (declaredProperties == null) { + initPropertyLists(); + } + return declaredProperties; + } + + protected List extendedProperties = null; + + public List getExtendedProperties() + { + if (extendedProperties == null) { + initPropertyLists(); + } + return extendedProperties; + } + + protected List getTypeFeatures() + { + return getEStructuralFeatures(); + } + + protected void initPropertyLists() + { + List declaredProperties = new ArrayList(); + List extendedProperties = Collections.EMPTY_LIST; + + for (Iterator i = getTypeFeatures().iterator(); i.hasNext(); ) { + EStructuralFeature eStructuralFeature = (EStructuralFeature)i.next(); + boolean isExtendedProperty = DataObjectUtil.isInternalProperty(eStructuralFeature); + if (isExtendedProperty) { + if (extendedProperties == Collections.EMPTY_LIST) + extendedProperties = new ArrayList(); + extendedProperties.add(eStructuralFeature); + } + else + declaredProperties.add(eStructuralFeature); + } + this.declaredProperties = declaredProperties; + this.extendedProperties = extendedProperties; + } + + public EList getEStructuralFeatures() + { + if (eStructuralFeatures == null) + { + eStructuralFeatures = + new EObjectContainmentWithInverseEList(EStructuralFeature.class, this, EcorePackage.ECLASS__ESTRUCTURAL_FEATURES, EcorePackage.ESTRUCTURAL_FEATURE__ECONTAINING_CLASS) + { + protected void didChange() + { + declaredProperties = extendedProperties = null; + } + }; + } + return eStructuralFeatures; + } + + protected List allProperties = null; + protected List allExtendedProperties = null; + protected EList allFeaturesCache = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getProperties() + { + final EList allFeatures = getEAllStructuralFeatures(); + if (allFeatures != allFeaturesCache) + { + allFeaturesCache = allFeatures; + allProperties = allExtendedProperties = null; + } + if (allProperties == null) + { + List allProperties = new UniqueEList(); + for (final Iterator iterator = getBaseTypes().iterator(); iterator.hasNext(); ) + { + Type baseType = (Type)iterator.next(); + allProperties.addAll(baseType.getProperties()); + } + allProperties.addAll(getDeclaredProperties()); + this.allProperties = allProperties; + } + return allProperties; + } + + public List getAllExtendedProperties() + { + final EList allFeatures = getEAllStructuralFeatures(); + if (allFeatures != allFeaturesCache) + { + allFeaturesCache = allFeatures; + allProperties = allExtendedProperties = null; + } + if (allExtendedProperties == null) + { + List allExtendedProperties = new UniqueEList(); + for (final Iterator iterator = getBaseTypes().iterator(); iterator.hasNext(); ) + { + Type baseType = (Type)iterator.next(); + allExtendedProperties.addAll(((ClassImpl)baseType).getAllExtendedProperties()); + } + allExtendedProperties.addAll(getExtendedProperties()); + this.allExtendedProperties = allExtendedProperties; + } + return allExtendedProperties; + } + + protected boolean isOpenFeatureMap(EStructuralFeature eStructuralFeature) + { + switch (ExtendedMetaData.INSTANCE.getFeatureKind(eStructuralFeature)) + { + case ExtendedMetaData.ELEMENT_WILDCARD_FEATURE: + return eStructuralFeature != ExtendedMetaData.INSTANCE.getMixedFeature(this); + case ExtendedMetaData.ATTRIBUTE_WILDCARD_FEATURE: + //FB I think this is wrong ... case ExtendedMetaData.GROUP_FEATURE: + return true; + } + return false; + } + + public void addOpenProperties(EObject dataObject, Collection propertyList) + { + for (final Iterator iterator = getBaseTypes().iterator(); iterator.hasNext(); ) + { + ClassImpl baseType = (ClassImpl)iterator.next(); + baseType.addOpenProperties(dataObject, propertyList); + } + + for (final Iterator iter = getExtendedProperties().iterator(); iter.hasNext(); ) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)iter.next(); + if (isOpenFeatureMap(eStructuralFeature)) + { + List features = (List)dataObject.eGet(eStructuralFeature); + for (int j = 0, size = features.size(); j < size; ++j) + { + FeatureMap.Entry entry = (FeatureMap.Entry)features.get(j); + EStructuralFeature entryFeature = entry.getEStructuralFeature(); + Property property = BasicSequence.getFeatureProperty(entryFeature); + if (property != null) propertyList.add(entryFeature); + } + } + } + } + + public Property getOpenProperty(EObject dataObject, String featureName) + { + for (final Iterator iterator = getBaseTypes().iterator(); iterator.hasNext(); ) + { + ClassImpl baseType = (ClassImpl)iterator.next(); + Property result = baseType.getOpenProperty(dataObject, featureName); + if (result != null) return result; + } + + Set openFeatureSet = new HashSet(); + for (final Iterator iter = getExtendedProperties().iterator(); iter.hasNext(); ) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)iter.next(); + //if (isOpenFeatureMap(eStructuralFeature)) + //FB The above check excludes subsitition groups - i.e., doesn't support dObj.get("element.substitution") + if (FeatureMapUtil.isFeatureMap(eStructuralFeature)) + { + List features = (List)dataObject.eGet(eStructuralFeature); + for (int j = 0, size = features.size(); j < size; ++j) + { + FeatureMap.Entry entry = (FeatureMap.Entry)features.get(j); + EStructuralFeature entryFeature = entry.getEStructuralFeature(); + if (openFeatureSet.add(entryFeature)) + { + Property property = BasicSequence.getFeatureProperty(entryFeature); + if (property != null) + { + if (property.getName().equals(featureName)) return (Property)entryFeature; + List aliasNames = property.getAliasNames(); + for (int aliasCount = aliasNames.size(); aliasCount > 0; ) + { + if (aliasNames.get(--aliasCount).equals(featureName)) return (Property)entryFeature; + } + } + } + } + } + } + + return null; + } + + /* + public Property getOpenProperty(DataObject dataObject, String featureName) + { + EObject eObject = (EObject)dataObject; + EClass eClass = eObject.eClass(); + Set openFeatureSet = new HashSet(); + for (int i = 0, count = eClass.getEAllStructuralFeatures().size(); i < count; ++i) + { + EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature(i); + if (FeatureMapUtil.isFeatureMap(eStructuralFeature)) + { + List features = (List)eObject.eGet(eStructuralFeature); + for (int j = 0, size = features.size(); j < size; ++j) + { + FeatureMap.Entry entry = (FeatureMap.Entry)features.get(j); + EStructuralFeature entryFeature = entry.getEStructuralFeature(); + if (openFeatureSet.add(entryFeature)) + { + Property property = (Property)entryFeature; + if (property.getName().equals(featureName)) return (Property)entryFeature; + + List aliasNames = property.getAliasNames(); + for (int aliasCount = aliasNames.size(); aliasCount > 0; ) + { + if (aliasNames.get(--aliasCount).equals(featureName)) return (Property)entryFeature; + } + } + } + } + } + return null; + } + */ + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getBaseTypes() + { + return getESuperTypes(); + } + + private void initAliasNames() { + Map result = new HashMap(); + for (Iterator i = getProperties().iterator(); i.hasNext();) + { + Property property = (Property)i.next(); + result.put(property.getName(), property); + + List aliasNames = property.getAliasNames(); + for (int count = aliasNames.size(); count > 0;) + { + result.put(aliasNames.get(--count), property); + } + } + propertyNameToPropertyMap = result; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Property getProperty(String propertyName) + { + if (propertyNameToPropertyMap == null) initAliasNames(); + Property property = (Property)propertyNameToPropertyMap.get(propertyName); + if (property == null && !isOpen()) { + initAliasNames(); + property = (Property)propertyNameToPropertyMap.get(propertyName); + } + return property; + } + + protected Map propertyNameToPropertyMap; + + public List getInstanceProperties() { + return DataObjectUtil.getMetaObjectInstanceProperties(this); + } + + public Object get(Property property) { + return DataObjectUtil.getMetaObjectInstanceProperty(this, property); + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // org.apache.tuscany.sdo.model.Type method implementations + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + + public List getBaseType() { + return this.getBaseTypes(); + } + + public List getProperty() { + return this.getProperties(); + } + + public List getAliasName() { + return this.getAliasNames(); + } + + public void unsetAbstract() { + eUnset(EcorePackage.eINSTANCE.getEClass_Abstract()); + } + + public boolean isSetAbstract() { + return eIsSet(EcorePackage.eINSTANCE.getEClass_Abstract()); + } + + public Sequence getAny() { + throw new UnsupportedOperationException(); + } + + public Sequence getAnyAttribute() { + throw new UnsupportedOperationException(); + } + + public void setDataType(boolean value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void unsetDataType() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetDataType() { + return false; + } + + public void setOpen(boolean value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void unsetOpen() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetOpen() { + return isOpen(); + } + + public void setSequenced(boolean value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void unsetSequenced() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetSequenced() { + return isSequenced(); + } + + public void unsetName() + { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetName() + { + return true; + } + + public void unsetUri() + { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetUri() + { + return true; + } + + public void setUri(String value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public String getUri() { + return getURI(); + } + + public Property getChangeSummaryProperty() { + if (changeSummaryPropertyCache == UNINITIALIZED_PROPERTY) { + changeSummaryPropertyCache = null; + + // Find property of type ChangeSummaryType, if one exists + Type csType = ((ModelFactoryImpl)ModelFactory.INSTANCE).getChangeSummaryType(); + for (Iterator props = getProperties().iterator(); props.hasNext(); ) { + Property p = (Property)props.next(); + if(csType == p.getType()) { + changeSummaryPropertyCache = p; + break; + } + } + } + + return changeSummaryPropertyCache; + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // DataObject method implementations + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + /* + public Object get(int propertyIndex) { + return DataObjectUtil.get(this, propertyIndex); + } + + public void set(int propertyIndex, Object value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSet(int propertyIndex) { + return DataObjectUtil.isSet(this, propertyIndex); + } + + public void unset(int propertyIndex) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public Object get(Property property) { + return DataObjectUtil.get(this, ((EStructuralFeature)property).getFeatureID()); + } + + public void set(Property property, Object value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSet(Property property) { + return DataObjectUtil.isSet(this, ((EStructuralFeature)property).getFeatureID()); + } + + public void unset(Property property) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject getContainer() { + return (DataObject)eContainer(); + } + + public Property getContainmentProperty() { + return (Property)eContainmentFeature(); + } + + public Type getType() { + return (Type)ModelPackageImpl.eINSTANCE.getType(); + } + + // Remaining DataObject methods are (will be) implemented as straight delegation to DataObjectUtil + + public Object get(String path) { + return DataObjectUtil.get(this, path); + } + + public void set(String path, Object value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSet(String path) { + return DataObjectUtil.isSet(this, path); + } + + public void unset(String path) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean getBoolean(String path) { + return DataObjectUtil.getBoolean(get(path)); + } + + public byte getByte(String path) { + return DataObjectUtil.getByte(get(path)); + } + + public char getChar(String path) { + return DataObjectUtil.getChar(get(path)); + } + + public double getDouble(String path) { + return DataObjectUtil.getDouble(get(path)); + } + + public float getFloat(String path) { + return DataObjectUtil.getFloat(get(path)); + } + + public int getInt(String path) { + return DataObjectUtil.getInt(get(path)); + } + + public long getLong(String path) { + return DataObjectUtil.getLong(get(path)); + } + + public short getShort(String path) { + return DataObjectUtil.getShort(get(path)); + } + + public byte[] getBytes(String path) { + return DataObjectUtil.getBytes(get(path)); + } + + public BigDecimal getBigDecimal(String path) { + return DataObjectUtil.getBigDecimal(get(path)); + } + + public BigInteger getBigInteger(String path) { + return DataObjectUtil.getBigInteger(get(path)); + } + + public DataObject getDataObject(String path) { + return (DataObject)get(path); + } + + public Date getDate(String path) { + return DataObjectUtil.getDate(get(path)); + } + + public String getString(String path) { + return DataObjectUtil.getString(get(path)); + } + + public List getList(String path) { + return (List)get(path); + } + + public Sequence getSequence(String path) { + return (Sequence)get(path); + } + + public void setBoolean(String path, boolean value) { + set(path, new Boolean(value)); + } + + public void setByte(String path, byte value) { + set(path, new Byte(value)); + } + + public void setChar(String path, char value) { + set(path, new Character(value)); + } + + public void setDouble(String path, double value) { + set(path, new Double(value)); + } + + public void setFloat(String path, float value) { + set(path, new Float(value)); + } + + public void setInt(String path, int value) { + set(path, new Integer(value)); + } + + public void setLong(String path, long value) { + set(path, new Long(value)); + } + + public void setShort(String path, short value) { + set(path, new Short(value)); + } + + public void setBytes(String path, byte[] value) { + set(path, value); + } + + public void setBigDecimal(String path, BigDecimal value) { + set(path, value); + } + + public void setBigInteger(String path, BigInteger value) { + set(path, value); + } + + public void setDataObject(String path, DataObject value) { + set(path, value); + } + + public void setDate(String path, Date value) { + set(path, value); + } + + public void setString(String path, String value) { + set(path, value); + } + + public void setList(String path, List value) { + set(path, value); + } + + public boolean getBoolean(int propertyIndex) { + return DataObjectUtil.getBoolean(this, propertyIndex); + } + + public byte getByte(int propertyIndex) { + return DataObjectUtil.getByte(this, propertyIndex); + } + + public char getChar(int propertyIndex) { + return DataObjectUtil.getChar(this, propertyIndex); + } + + public double getDouble(int propertyIndex) { + return DataObjectUtil.getDouble(this, propertyIndex); + } + + public float getFloat(int propertyIndex) { + return DataObjectUtil.getFloat(this, propertyIndex); + } + + public int getInt(int propertyIndex) { + return DataObjectUtil.getInt(this, propertyIndex); + } + + public long getLong(int propertyIndex) { + return DataObjectUtil.getLong(this, propertyIndex); + } + + public short getShort(int propertyIndex) { + return DataObjectUtil.getShort(this, propertyIndex); + } + + public byte[] getBytes(int propertyIndex) { + return DataObjectUtil.getBytes(this, propertyIndex); + } + + public BigDecimal getBigDecimal(int propertyIndex) { + return DataObjectUtil.getBigDecimal(this, propertyIndex); + } + + public BigInteger getBigInteger(int propertyIndex) { + return DataObjectUtil.getBigInteger(this, propertyIndex); + } + + public DataObject getDataObject(int propertyIndex) { + return DataObjectUtil.getDataObject(this, propertyIndex); + } + + public Date getDate(int propertyIndex) { + return DataObjectUtil.getDate(this, propertyIndex); + } + + public String getString(int propertyIndex) { + return DataObjectUtil.getString(this, propertyIndex); + } + + public List getList(int propertyIndex) { + return DataObjectUtil.getList(this, propertyIndex); + } + + public Sequence getSequence(int propertyIndex) { + return DataObjectUtil.getSequence(this, propertyIndex); + } + + public void setBoolean(int propertyIndex, boolean value) { + set(propertyIndex, new Boolean(value)); + } + + public void setByte(int propertyIndex, byte value) { + set(propertyIndex, new Byte(value)); + } + + public void setChar(int propertyIndex, char value) { + set(propertyIndex, new Character(value)); + } + + public void setDouble(int propertyIndex, double value) { + set(propertyIndex, new Double(value)); + } + + public void setFloat(int propertyIndex, float value) { + set(propertyIndex, new Float(value)); + } + + public void setInt(int propertyIndex, int value) { + set(propertyIndex, new Integer(value)); + } + + public void setLong(int propertyIndex, long value) { + set(propertyIndex, new Long(value)); + } + + public void setShort(int propertyIndex, short value) { + set(propertyIndex, new Short(value)); + } + + public void setBytes(int propertyIndex, byte[] value) { + set(propertyIndex, value); + } + + public void setBigDecimal(int propertyIndex, BigDecimal value) { + set(propertyIndex, value); + } + + public void setBigInteger(int propertyIndex, BigInteger value) { + set(propertyIndex, value); + } + + public void setDataObject(int propertyIndex, DataObject value) { + set(propertyIndex, value); + } + + public void setDate(int propertyIndex, Date value) { + set(propertyIndex, value); + } + + public void setString(int propertyIndex, String value) { + set(propertyIndex, value); + } + + public void setList(int propertyIndex, List value) { + set(propertyIndex, value); + } + + public boolean getBoolean(Property property) { + return DataObjectUtil.getBoolean(this, property); + } + + public byte getByte(Property property) { + return DataObjectUtil.getByte(this, property); + } + + public char getChar(Property property) { + return DataObjectUtil.getChar(this, property); + } + + public double getDouble(Property property) { + return DataObjectUtil.getDouble(this, property); + } + + public float getFloat(Property property) { + return DataObjectUtil.getFloat(this, property); + } + + public int getInt(Property property) { + return DataObjectUtil.getInt(this, property); + } + + public long getLong(Property property) { + return DataObjectUtil.getLong(this, property); + } + + public short getShort(Property property) { + return DataObjectUtil.getShort(this, property); + } + + public byte[] getBytes(Property property) { + return DataObjectUtil.getBytes(this, property); + } + + public BigDecimal getBigDecimal(Property property) { + return DataObjectUtil.getBigDecimal(this, property); + } + + public BigInteger getBigInteger(Property property) { + return DataObjectUtil.getBigInteger(this, property); + } + + public DataObject getDataObject(Property property) { + return DataObjectUtil.getDataObject(this, property); + } + + public Date getDate(Property property) { + return DataObjectUtil.getDate(this, property); + } + + public String getString(Property property) { + return DataObjectUtil.getString(this, property); + } + + public List getList(Property property) { + return DataObjectUtil.getList(this, property); + } + + public Sequence getSequence(Property property) { + return DataObjectUtil.getSequence(this, property); + } + + public void setBoolean(Property property, boolean value) { + set(property, new Boolean(value)); + } + + public void setByte(Property property, byte value) { + set(property, new Byte(value)); + } + + public void setChar(Property property, char value) { + set(property, new Character(value)); + } + + public void setDouble(Property property, double value) { + set(property, new Double(value)); + } + + public void setFloat(Property property, float value) { + set(property, new Float(value)); + } + + public void setInt(Property property, int value) { + set(property, new Integer(value)); + } + + public void setLong(Property property, long value) { + set(property, new Long(value)); + } + + public void setShort(Property property, short value) { + set(property, new Short(value)); + } + + public void setBytes(Property property, byte[] value) { + set(property, value); + } + + public void setBigDecimal(Property property, BigDecimal value) { + set(property, value); + } + + public void setBigInteger(Property property, BigInteger value) { + set(property, value); + } + + public void setDataObject(Property property, DataObject value) { + set(property, value); + } + + public void setDate(Property property, Date value) { + set(property, value); + } + + public void setString(Property property, String value) { + set(property, value); + } + + public void setList(Property property, List value) { + set(property, value); + } + + public DataObject createDataObject(String propertyName) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(String propertyName, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property, Type type) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void delete() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataGraph getDataGraph() { + return DataObjectUtil.getDataGraph(this); + } + + public Sequence getSequence() { + EAttribute mixedFeature = BasicExtendedMetaData.INSTANCE.getMixedFeature(eClass()); + return mixedFeature != null ? (Sequence)eGet(mixedFeature, true, false) : null; + } + + public List getInstanceProperties() { + return DataObjectUtil.getInstanceProperties(this); + } + + public DataObject getRootObject() { + return DataObjectUtil.getRootObject(this); + } + + public ChangeSummary getChangeSummary() { + // TODO: implement this method + throw new UnsupportedOperationException(); + } + + public void detach() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + //DataObjectUtil.detach(this); + } + */ + +} //ClassTypeImpl diff --git a/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/DataGraphImpl.java b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/DataGraphImpl.java new file mode 100644 index 0000000000..d61b7fd05e --- /dev/null +++ b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/DataGraphImpl.java @@ -0,0 +1,852 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.helper.TypeHelperImpl; +import org.apache.tuscany.sdo.lib.SDOObjectInputStream; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.EObjectImpl; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.util.BasicExtendedMetaData; +import org.eclipse.emf.ecore.util.ExtendedMetaData; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.TypeHelper; + + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>EData Graph</b></em>'. + * @extends DataGraph, Adapter, Serializable + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.sdo.impl.DataGraphImpl#getResourceSet <em>Resource Set</em>}</li> + * <li>{@link org.apache.tuscany.sdo.impl.DataGraphImpl#getRootResource <em>Root Resource</em>}</li> + * <li>{@link org.apache.tuscany.sdo.impl.DataGraphImpl#getEChangeSummary <em>EChange Summary</em>}</li> + * <li>{@link org.apache.tuscany.sdo.impl.DataGraphImpl#getERootObject <em>ERoot Object</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class DataGraphImpl extends EObjectImpl implements DataGraph, Adapter, Serializable +{ + /** + * The default value of the '{@link #getResourceSet() <em>Resource Set</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getResourceSet() + * @generated + * @ordered + */ + protected static final ResourceSet RESOURCE_SET_EDEFAULT = null; + + /** + * The cached value of the '{@link #getResourceSet() <em>Resource Set</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getResourceSet() + * @generated + * @ordered + */ + protected ResourceSet resourceSet = RESOURCE_SET_EDEFAULT; + + /** + * The default value of the '{@link #getRootResource() <em>Root Resource</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getRootResource() + * @generated + * @ordered + */ + protected static final Resource ROOT_RESOURCE_EDEFAULT = null; + + /** + * The cached value of the '{@link #getEChangeSummary() <em>EChange Summary</em>}' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getEChangeSummary() + * @generated + * @ordered + */ + protected ChangeSummary eChangeSummary = null; + + /** + * The cached value of the '{@link #getERootObject() <em>ERoot Object</em>}' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getERootObject() + * @generated + * @ordered + */ + protected EObject eRootObject = null; + + /** + * The cached extended metadata to wrap the resource set's package registry. + */ + protected ExtendedMetaData extendedMetaData; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected DataGraphImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getDataGraph(); + } + + public boolean isAdapterForType(Object type) + { + return type == DataGraph.class; + } + + public void notifyChanged(Notification msg) + { + } + + public Notifier getTarget() + { + return getResourceSet(); + } + + public void setTarget(Notifier newTarget) + { + } + + protected ExtendedMetaData getExtendedMetaData() + { + if (extendedMetaData == null) + { + getResourceSet(); + } + return extendedMetaData; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public ResourceSet getResourceSet() + { + if (resourceSet == null) + { + if (eResource() != null) + { + resourceSet = eResource().getResourceSet(); + } + if (resourceSet == null) + { + resourceSet = createResourceSet(); + } + initializeResourceSet(resourceSet); + } + return resourceSet; + } + + protected ResourceSet createResourceSet() + { + return DataObjectUtil.createResourceSet(); + } + + protected Resource createRootResource() + { + Resource result = resourceSet.createResource(URI.createURI("root.xml")); + result.getContents().clear(); + return result; + } + + protected Resource createChangeSummaryResource() + { + Resource result = resourceSet.createResource(URI.createURI("change-summary.xml")); + result.getContents().clear(); + return result; + } + + protected void initializeResourceSet(ResourceSet resourceSet) + { + if (resourceSet == null) + { + extendedMetaData = null; + } + else + { + extendedMetaData = new BasicExtendedMetaData(resourceSet.getPackageRegistry()); + resourceSet.eAdapters().add(this); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setResourceSetGen(ResourceSet newResourceSet) + { + ResourceSet oldResourceSet = resourceSet; + resourceSet = newResourceSet; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.DATA_GRAPH__RESOURCE_SET, oldResourceSet, resourceSet)); + } + + public void setResourceSet(ResourceSet newResourceSet) + { + if (resourceSet != null) + { + resourceSet.eAdapters().remove(this); + } + setResourceSetGen(newResourceSet); + initializeResourceSet(newResourceSet); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Resource getRootResource() + { + if (eRootObject == null) + { + Resource result = getResourceSet().getResource(URI.createURI("root.xml"), false); + if (result == null) + { + result = createRootResource(); + } + + return result; + } + else + { + return eRootObject.eResource(); + } + } + + public Resource getDataGraphResource() + { + Resource result = eResource(); + if (result == null) + { + result = getResourceSet().createResource(URI.createURI("all.datagraph")); + result.getContents().add(this); + } + return result; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ChangeSummary getEChangeSummary() + { + return eChangeSummary; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain basicSetEChangeSummary(ChangeSummary newEChangeSummary, NotificationChain msgs) + { + ChangeSummary oldEChangeSummary = eChangeSummary; + eChangeSummary = newEChangeSummary; + if (eNotificationRequired()) + { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY, oldEChangeSummary, newEChangeSummary); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setEChangeSummary(ChangeSummary newEChangeSummary) + { + if (newEChangeSummary != eChangeSummary) + { + NotificationChain msgs = null; + if (eChangeSummary != null) + msgs = ((InternalEObject)eChangeSummary).eInverseRemove(this, SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH, ChangeSummary.class, msgs); + if (newEChangeSummary != null) + msgs = ((InternalEObject)newEChangeSummary).eInverseAdd(this, SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH, ChangeSummary.class, msgs); + msgs = basicSetEChangeSummary(newEChangeSummary, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY, newEChangeSummary, newEChangeSummary)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EObject getERootObject() + { + return eRootObject; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setERootObjectGen(EObject newERootObject) + { + EObject oldERootObject = eRootObject; + eRootObject = newERootObject; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.DATA_GRAPH__EROOT_OBJECT, oldERootObject, eRootObject)); + } + + public void setERootObject(EObject newERootObject) + { + // If there is a resource set already... + // + if (resourceSet != null) + { + // Get the root resource and if there's a root object in it already, clear it. + // Then set the root object and add it to the root resource. + // + List contents = getRootResource().getContents(); + if (eRootObject != null) + { + contents.clear(); + } + setERootObjectGen(newERootObject); + if (newERootObject != null) + { + contents.add(newERootObject); + } + } + else + { + // Set the root object and see if it has a resource we can reuse. + // + setERootObjectGen(newERootObject); + Resource rootResource = newERootObject.eResource(); + if (rootResource != null) + { + // If there is no resource set + // + if (rootResource.getResourceSet() == null) + { + // Demand create one and add this resource to it. + // + getResourceSet().getResources().add(rootResource); + } + else + { + // Reuse the existing resource set. + // + setResourceSet(rootResource.getResourceSet()); + } + } + else + { + // Demand create the resource set and the root resource, and add to it's contents. + // + getResourceSet(); + createRootResource().getContents().add(newERootObject); + } + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public EClassifier getEClassifier(String namespaceURI, String typeName) + { + ExtendedMetaData extendedMetaData = getExtendedMetaData(); + EPackage ePackage = extendedMetaData.getPackage(namespaceURI); + if (ePackage != null) + { + EClassifier eClassifier = ePackage.getEClassifier(typeName); + if (eClassifier == null) + { + eClassifier = extendedMetaData.getType(ePackage, typeName); + } + return eClassifier; + } + else + { + return null; + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Type getType(String namespaceURI, String typeName) + { + return TypeHelper.INSTANCE.getType(namespaceURI, typeName); + //EClassifier eClassifier = getEClassifier(namespaceURI, typeName); + //return eClassifier == null ? null : SDOUtil.getType(eClassifier); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) + { + if (featureID >= 0) + { + switch (eDerivedStructuralFeatureID(featureID, baseClass)) + { + case SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY: + if (eChangeSummary != null) + msgs = ((InternalEObject)eChangeSummary).eInverseRemove(this, SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH, ChangeSummary.class, msgs); + return basicSetEChangeSummary((ChangeSummary)otherEnd, msgs); + default: + return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs); + } + } + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + return eBasicSetContainer(otherEnd, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) + { + if (featureID >= 0) + { + switch (eDerivedStructuralFeatureID(featureID, baseClass)) + { + case SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY: + return basicSetEChangeSummary(null, msgs); + default: + return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs); + } + } + return eBasicSetContainer(null, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case SDOPackage.DATA_GRAPH__RESOURCE_SET: + return getResourceSet(); + case SDOPackage.DATA_GRAPH__ROOT_RESOURCE: + return getRootResource(); + case SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY: + return getEChangeSummary(); + case SDOPackage.DATA_GRAPH__EROOT_OBJECT: + return getERootObject(); + } + return eDynamicGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case SDOPackage.DATA_GRAPH__RESOURCE_SET: + setResourceSet((ResourceSet)newValue); + return; + case SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY: + setEChangeSummary((ChangeSummary)newValue); + return; + case SDOPackage.DATA_GRAPH__EROOT_OBJECT: + setERootObject((EObject)newValue); + return; + } + eDynamicSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case SDOPackage.DATA_GRAPH__RESOURCE_SET: + setResourceSet(RESOURCE_SET_EDEFAULT); + return; + case SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY: + setEChangeSummary((ChangeSummary)null); + return; + case SDOPackage.DATA_GRAPH__EROOT_OBJECT: + setERootObject((EObject)null); + return; + } + eDynamicUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case SDOPackage.DATA_GRAPH__RESOURCE_SET: + return RESOURCE_SET_EDEFAULT == null ? resourceSet != null : !RESOURCE_SET_EDEFAULT.equals(resourceSet); + case SDOPackage.DATA_GRAPH__ROOT_RESOURCE: + return ROOT_RESOURCE_EDEFAULT == null ? getRootResource() != null : !ROOT_RESOURCE_EDEFAULT.equals(getRootResource()); + case SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY: + return eChangeSummary != null; + case SDOPackage.DATA_GRAPH__EROOT_OBJECT: + return eRootObject != null; + } + return eDynamicIsSet(featureID); + } + + public DataObject createEDataObject(Type type) + { + return DataObjectUtil.create(type); + } + + public DataObject getRootObject() + { + return (DataObject)getERootObject(); + } + + public DataObject createRootObject(String namespaceURI, String typeName) + { + Type type = getType(namespaceURI, typeName); + if (type == null) { + throw new IllegalArgumentException( + "createRootObject given invalid parameters: getType("+ + namespaceURI+", "+typeName+") returned null type"); + } + if (getERootObject() != null) { + throw new IllegalStateException( + "createRootObject was called when a root object already exists"); + } + DataObject dataObject = DataObjectUtil.create(type); + setERootObject((EObject)dataObject); + return dataObject; + } + + public DataObject createRootObject(Type type) + { + if (type == null) { + throw new IllegalArgumentException( + "createRootObject must be provided a non-null type"); + } + if (getERootObject() != null) { + throw new IllegalStateException( + "createRootObject was called when a root object already exists"); + } + DataObject dataObject = DataObjectUtil.create(type); + setERootObject((EObject)dataObject); + return dataObject; + } + + public ChangeSummary getChangeSummary() + { + //FB is this the right place to create the resources? + ChangeSummary changeSummary = getEChangeSummary(); + if (changeSummary == null) + { + getRootResource(); + changeSummary = createEChangeSummary(); + setEChangeSummary(changeSummary); + } + + if (((ChangeSummaryImpl)changeSummary).eResource() == null) + { + Resource changeSummaryResource = createChangeSummaryResource(); + changeSummaryResource.getContents().add(changeSummary); + } + + return changeSummary; + } + + protected ChangeSummaryImpl createEChangeSummary() + { + return (ChangeSummaryImpl)SDOFactory.eINSTANCE.createChangeSummary(); + } + + public static class EDataGraphExternalizable implements Externalizable + { + protected DataGraphImpl eDataGraph; + //protected Map writeReplacements = new HashMap(); + + public EDataGraphExternalizable() + { + } + + public EDataGraphExternalizable(DataGraphImpl eDataGraph) + { + this.eDataGraph = eDataGraph; + } + + public void writeExternal(ObjectOutput objectOutput) throws IOException + { + ByteArrayOutputStream byteArrayOutputStream = + new ByteArrayOutputStream() + { + public byte [] toByteArray() + { + return super.toByteArray(); + } + }; + + eDataGraph.getDataGraphResource().save(byteArrayOutputStream, null); + objectOutput.writeInt(byteArrayOutputStream.toByteArray().length); + objectOutput.write(byteArrayOutputStream.toByteArray()); + } + + public void readExternal(ObjectInput objectInput) throws IOException + { + int length = objectInput.readInt(); + byte [] bytes = new byte [length]; + objectInput.readFully(bytes); + + ResourceSet resourceSet = createResourceSet(); + Resource resource = resourceSet.createResource(URI.createURI("all.datagraph")); + + HashMap map = null; + if(objectInput instanceof SDOObjectInputStream) + { + TypeHelperImpl th = (TypeHelperImpl)((SDOObjectInputStream)objectInput).getHelperContext().getTypeHelper(); + map = new HashMap(); + map.put("EXTENDED_META_DATA", th.getExtendedMetaData()); + } + resource.load(new ByteArrayInputStream(bytes), map); + eDataGraph = (DataGraphImpl)resource.getContents().get(0); + } + + protected ResourceSet createResourceSet() + { + return DataObjectUtil.createResourceSet(); + } + + /* + public Object getWriteReplacement(EObject eObject) + { + Object result = writeReplacements.get(eObject); + if (result == null) + { + result = new EDataObjectExternalizable(eDataGraph, eObject); + writeReplacements.put(eObject, result); + } + return result; + } + */ + + protected Object readResolve() + { + return eDataGraph; + } + } + + /* + public static class EDataObjectExternalizable implements Externalizable + { + protected EObject eObject; + protected DataGraphImpl eDataGraph; + + public EDataObjectExternalizable() + { + } + + public EDataObjectExternalizable(DataGraphImpl eDataGraph, EObject eObject) + { + this.eDataGraph = eDataGraph; + this.eObject = eObject; + } + + public void writeExternal(ObjectOutput objectOutput) throws IOException + { + // Write the data object reference too. + String uri = eObject.eResource().getURIFragment(eObject); + objectOutput.writeUTF(uri); + objectOutput.writeObject(eDataGraph.getWriteReplacement()); + } + + public void readExternal(ObjectInput objectInput) throws IOException, ClassNotFoundException + { + String uri = objectInput.readUTF(); + eDataGraph = (DataGraphImpl)objectInput.readObject(); + eObject = eDataGraph.getRootResource().getEObject(uri); + } + + protected Object readResolve() + { + return eObject; + } + } + */ + + protected EDataGraphExternalizable eDataGraphExternalizable; + //protected Adapter modificationTracker; + + public Object getWriteReplacement() + { + if (eDataGraphExternalizable == null) + { + eDataGraphExternalizable = createEDataGraphExternalizable(); + /* + getRootResource().setTrackingModification(true); + modificationTracker = + new AdapterImpl() + { + public void notifyChanged(Notification notification) + { + if (notification.getFeatureID(Resource.class) == Resource.RESOURCE__IS_MODIFIED && notification.getNewBooleanValue()) + { + eDataGraphExternalizable = null; + modificationTracker = null; + ((Resource)target).eAdapters().remove(this); + } + } + }; + getRootResource().eAdapters().add(modificationTracker); + */ + } + return eDataGraphExternalizable; + } + + protected EDataGraphExternalizable createEDataGraphExternalizable() + { + return new EDataGraphExternalizable(this); + } + + /* + public Object getWriteReplacement(EObject eObject) + { + return ((EDataGraphExternalizable)getWriteReplacement()).getWriteReplacement(eObject); + } + */ + + public Object writeReplace() + { + return getWriteReplacement(); + } + + public EObject eObjectForURIFragmentSegment(String uriFragmentSegment) + { + if (uriFragmentSegment.startsWith("@models.")) + { + if (resourceSet != null) + { + int count = Integer.parseInt(uriFragmentSegment.substring(8)); + for (Iterator i = resourceSet.getResources().iterator(); i.hasNext(); ) + { + Resource ePackageResource = (Resource)i.next(); + List resourceContents = ePackageResource.getContents(); + if (resourceContents.size() == 1 && resourceContents.get(0) instanceof EPackage && count-- == 0) + { + return (EObject)resourceContents.get(0); + } + } + } + + return null; + } + else + { + return super.eObjectForURIFragmentSegment(uriFragmentSegment); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (resourceSet: "); + result.append(resourceSet); + result.append(')'); + return result.toString(); + } + +} //EDataGraphImpl diff --git a/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectBase.java b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectBase.java new file mode 100644 index 0000000000..34216bc1e2 --- /dev/null +++ b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectBase.java @@ -0,0 +1,536 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.util.List; + +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.helper.HelperContextImpl; +import org.apache.tuscany.sdo.util.BasicSequence; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.EStructuralFeature.Setting; +import org.eclipse.emf.ecore.EStructuralFeature.Internal.SettingDelegate; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.util.BasicFeatureMap; +import org.eclipse.emf.ecore.util.EDataTypeEList; +import org.eclipse.emf.ecore.util.EDataTypeUniqueEList; +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; +import org.eclipse.emf.ecore.util.EObjectEList; +import org.eclipse.emf.ecore.util.EObjectResolvingEList; +import org.eclipse.emf.ecore.util.EObjectWithInverseEList; +import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.ecore.util.InternalEList; + +import commonj.sdo.Property; +import commonj.sdo.Sequence; +import commonj.sdo.Type; + + +/** + * Base implementation of the SDO DataObject interface. Used as base class for generated (static) SDO classes + */ +public abstract class DataObjectBase extends ExtensibleDataObjectImpl +{ + + protected int OPPOSITE_FEATURE_BASE = EOPPOSITE_FEATURE_BASE; + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Following methods should be proposed SPI for generated subclasses to use + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + protected boolean isNotifying() + { + return changeRecorder != null; + } + + protected interface ChangeKind + { + int SET = Notification.SET; + int UNSET = Notification.UNSET; + int RESOLVE = Notification.RESOLVE; + } + + /** + * notify methods for types: boolean, byte, char, double, float, int, long, short, and Object + */ + + protected void notify(int changeKind, int property, boolean oldBooleanValue, boolean newBooleanValue) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldBooleanValue, newBooleanValue)); + } + + protected void notify(int changeKind, int property, boolean oldBooleanValue, boolean newBooleanValue, boolean isSetChange) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldBooleanValue, newBooleanValue, isSetChange)); + } + + protected void notify(int changeKind, int property, byte oldByteValue, byte newByteValue) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldByteValue, newByteValue)); + } + + protected void notify(int changeKind, int property, byte oldByteValue, byte newByteValue, boolean isSetChange) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldByteValue, newByteValue, isSetChange)); + } + + protected void notify(int changeKind, int property, char oldCharValue, char newCharValue) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldCharValue, newCharValue)); + } + + protected void notify(int changeKind, int property, char oldCharValue, char newCharValue, boolean isSetChange) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldCharValue, newCharValue, isSetChange)); + } + + protected void notify(int changeKind, int property, double oldDoubleValue, double newDoubleValue) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldDoubleValue, newDoubleValue)); + } + + protected void notify(int changeKind, int property, double oldDoubleValue, double newDoubleValue, boolean isSetChange) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldDoubleValue, newDoubleValue, isSetChange)); + } + + protected void notify(int changeKind, int property, float oldFloatValue, float newFloatValue) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldFloatValue, newFloatValue)); + } + + protected void notify(int changeKind, int property, float oldFloatValue, float newFloatValue, boolean isSetChange) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldFloatValue, newFloatValue, isSetChange)); + } + + protected void notify(int changeKind, int property, int oldIntValue, int newIntValue) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldIntValue, newIntValue)); + } + + protected void notify(int changeKind, int property, int oldIntValue, int newIntValue, boolean isSetChange) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldIntValue, newIntValue, isSetChange)); + } + + protected void notify(int changeKind, int property, long oldLongValue, long newLongValue) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldLongValue, newLongValue)); + } + + protected void notify(int changeKind, int property, long oldLongValue, long newLongValue, boolean isSetChange) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldLongValue, newLongValue, isSetChange)); + } + + protected void notify(int changeKind, int property, short oldShortValue, short newShortValue) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldShortValue, newShortValue)); + } + + protected void notify(int changeKind, int property, short oldShortValue, short newShortValue, boolean isSetChange) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldShortValue, newShortValue, isSetChange)); + } + + protected void notify(int changeKind, int property, Object oldValue, Object newValue) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldValue, newValue)); + } + + protected void notify(int changeKind, int property, Object oldValue, Object newValue, boolean isSetChange) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldValue, newValue, isSetChange)); + } + + public interface ListKind + { + int CONTAINMENT = 0; + int CONTAINMENT_UNSETTABLE = 1; + int CONTAINMENT_RESOLVING = 2; + int CONTAINMENT_RESOLVING_UNSETTABLE = 3; + int CONTAINMENT_INVERSE = 4; + int CONTAINMENT_INVERSE_UNSETTABLE = 5; + int CONTAINMENT_INVERSE_RESOLVING = 6; + int CONTAINMENT_INVERSE_RESOLVING_UNSETTABLE = 7; + + int NONCONTAINMENT = 8; + int NONCONTAINMENT_UNSETTABLE = 9; + int NONCONTAINMENT_RESOLVING = 10; + int NONCONTAINMENT_RESOLVING_UNSETTABLE = 11; + int NONCONTAINMENT_INVERSE = 12; + int NONCONTAINMENT_INVERSE_UNSETTABLE = 13; + int NONCONTAINMENT_MANYINVERSE = 14; + int NONCONTAINMENT_MANYINVERSE_UNSETTABLE = 15; + int NONCONTAINMENT_INVERSE_RESOLVING = 16; + int NONCONTAINMENT_INVERSE_RESOLVING_UNSETTABLE = 17; + int NONCONTAINMENT_MANYINVERSE_RESOLVING = 18; + int NONCONTAINMENT_MANYINVERSE_RESOLVING_UNSETTABLE = 19; + + int DATATYPE = 20; + int DATATYPE_UNSETTABLE = 21; + int DATATYPE_UNIQUE = 22; + int DATATYPE_UNIQUE_UNSETTABLE = 23; + + int BASIC = 24; + } + + /** + * @deprecated + */ + protected List createPropertyList(int listKind, Class dataClass, int property) + { + return createPropertyList(listKind, dataClass, property, 0); + } + + protected List createPropertyList(int listKind, Class dataClass, int property, int reverseProperty) + { + switch (listKind) + { + case ListKind.CONTAINMENT: + return new EObjectContainmentEList(dataClass, this, property); + case ListKind.CONTAINMENT_INVERSE_RESOLVING_UNSETTABLE: + return new EObjectContainmentWithInverseEList.Unsettable.Resolving(dataClass, this, property, reverseProperty); + case ListKind.CONTAINMENT_INVERSE_RESOLVING: + return new EObjectContainmentWithInverseEList.Resolving(dataClass, this, property, reverseProperty); + case ListKind.CONTAINMENT_INVERSE_UNSETTABLE: + return new EObjectContainmentWithInverseEList.Unsettable(dataClass, this, property, reverseProperty); + case ListKind.CONTAINMENT_INVERSE: + return new EObjectContainmentWithInverseEList(dataClass, this, property, reverseProperty); + case ListKind.CONTAINMENT_RESOLVING_UNSETTABLE: + return new EObjectContainmentEList.Unsettable.Resolving(dataClass, this, property); + case ListKind.CONTAINMENT_RESOLVING: + return new EObjectContainmentEList.Resolving(dataClass, this, property); + case ListKind.CONTAINMENT_UNSETTABLE: + return new EObjectContainmentEList.Unsettable(dataClass, this, property); + case ListKind.NONCONTAINMENT_MANYINVERSE_RESOLVING_UNSETTABLE: + return new EObjectWithInverseResolvingEList.Unsettable.ManyInverse(dataClass, this, property, reverseProperty); + case ListKind.NONCONTAINMENT_MANYINVERSE_RESOLVING: + return new EObjectWithInverseResolvingEList.ManyInverse(dataClass, this, property, reverseProperty); + case ListKind.NONCONTAINMENT_INVERSE_RESOLVING_UNSETTABLE: + return new EObjectWithInverseResolvingEList.Unsettable(dataClass, this, property, reverseProperty); + case ListKind.NONCONTAINMENT_INVERSE_RESOLVING: + return new EObjectWithInverseResolvingEList(dataClass, this, property, reverseProperty); + case ListKind.NONCONTAINMENT_MANYINVERSE_UNSETTABLE: + return new EObjectWithInverseEList.Unsettable.ManyInverse(dataClass, this, property, reverseProperty); + case ListKind.NONCONTAINMENT_MANYINVERSE: + return new EObjectWithInverseEList.ManyInverse(dataClass, this, property, reverseProperty); + case ListKind.NONCONTAINMENT_INVERSE_UNSETTABLE: + return new EObjectWithInverseEList.Unsettable(dataClass, this, property, reverseProperty); + case ListKind.NONCONTAINMENT_INVERSE: + return new EObjectWithInverseEList(dataClass, this, property, reverseProperty); + case ListKind.NONCONTAINMENT_RESOLVING_UNSETTABLE: + return new EObjectResolvingEList.Unsettable(dataClass, this, property); + case ListKind.NONCONTAINMENT_RESOLVING: + return new EObjectResolvingEList(dataClass, this, property); + case ListKind.NONCONTAINMENT_UNSETTABLE: + return new EObjectEList.Unsettable(dataClass, this, property); + case ListKind.NONCONTAINMENT: + return new EObjectEList(dataClass, this, property); + case ListKind.DATATYPE_UNIQUE_UNSETTABLE: + return new EDataTypeUniqueEList.Unsettable(dataClass, this, property); + case ListKind.DATATYPE_UNIQUE: + return new EDataTypeUniqueEList(dataClass, this, property); + case ListKind.DATATYPE_UNSETTABLE: + return new EDataTypeEList.Unsettable(dataClass, this, property); + case ListKind.DATATYPE: + return new EDataTypeEList(dataClass, this, property); + } + return null; + } + + protected BasicSequence createSequence(int property) { + return new BasicSequence(new BasicFeatureMap(this, property)); + } + + protected Sequence createSequence(Sequence sequence, Type type, int propertyIndex) { + return new BasicSequence((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)sequence).featureMap().list(((EClass)type).getEStructuralFeature(propertyIndex))); + } + + protected void createChangeSummary(int property) { + ChangeSummaryImpl changeSummary = (ChangeSummaryImpl)SDOFactory.eINSTANCE.createChangeSummary(); + set(property, changeSummary); + changeSummary.setDataObject(this); + } + + /* + * get the value of the type's property at propertyIndex via the sequence + * @param seq + * @param type + * @param propertyIndex + * @return + */ + protected Object get(Sequence seq, Type type, int propertyIndex) { + return ((FeatureMap.Internal.Wrapper)seq).featureMap().get(((EClass)type).getEStructuralFeature(propertyIndex), true); + } + + protected List getList(Sequence seq, Type type, int propertyIndex) { + return ((FeatureMap.Internal.Wrapper)seq).featureMap().list(((EClass)type).getEStructuralFeature(propertyIndex)); + } + + protected void set(Sequence seq, Type type, int propertyIndex, Object newValue) { + ((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)seq).featureMap()).set(((EClass)type).getEStructuralFeature(propertyIndex), newValue); + } + + protected void unset(Sequence seq, Type type, int propertyIndex) { + ((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)seq).featureMap()).clear(((EClass)type).getEStructuralFeature(propertyIndex)); + + } + protected boolean isSet(Sequence seq, Type type, int propertyIndex) { + return !((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)seq).featureMap()).isEmpty(((EClass)type).getEStructuralFeature(propertyIndex)); + } + + protected boolean isSequenceEmpty(Sequence sequence) { + return ((FeatureMap.Internal.Wrapper)sequence).featureMap().isEmpty(); + } + + protected void setSequence(Sequence seq, Object newValue) { + ((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)seq).featureMap()).set(newValue); + } + + protected void unsetSequence(Sequence seq) { + ((FeatureMap.Internal.Wrapper)seq).featureMap().clear(); + } + + protected ChangeContext basicAdd(Sequence seq, Type type, int propertyIndex, Object newValue, ChangeContext changeContext) { + ChangeContextImpl changeContextImpl = (ChangeContextImpl)changeContext; + changeContextImpl.notificationChain = ((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)seq).featureMap()).basicAdd(((EClass)type).getEStructuralFeature(propertyIndex), newValue, changeContextImpl.notificationChain); + return changeContextImpl; + } + + private ChangeContextImpl initializeChangeContext(ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl; + if (changeContext == null) + { + changeContextImpl = new ChangeContextImpl(null); + } else + { + changeContextImpl = (ChangeContextImpl)changeContext; + } + return changeContextImpl; + } + + protected interface ChangeContext {} + + + protected ChangeContext inverseRemove(Object otherEnd, int propertyIndex, ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + changeContextImpl.notificationChain = super.eInverseRemove((InternalEObject)otherEnd, propertyIndex, changeContextImpl.notificationChain); + return changeContextImpl; + } + + protected ChangeContext inverseAdd(Object otherEnd, int propertyIndex, ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + changeContextImpl.notificationChain = super.eInverseAdd((InternalEObject)otherEnd, propertyIndex, changeContextImpl.notificationChain); + return changeContextImpl; + } + + protected ChangeContext inverseRemove(Object thisEnd, Object otherEnd, int propertyIndex, Class baseClass, ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + changeContextImpl.notificationChain = ((InternalEObject)thisEnd).eInverseRemove((InternalEObject)otherEnd, propertyIndex, baseClass, changeContextImpl.notificationChain); + return changeContextImpl; + } + + protected ChangeContext inverseAdd(Object thisEnd, Object otherEnd, int propertyIndex, Class baseClass, ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + changeContextImpl.notificationChain = ((InternalEObject)thisEnd).eInverseAdd((InternalEObject)otherEnd, propertyIndex, baseClass, changeContextImpl.notificationChain); + return changeContextImpl; + } + + protected ChangeContext addNotification(Object notifier, int eventType, int featureID, Object oldValue, Object newValue, boolean isSetChanged, ChangeContext changeContext) + { + ENotificationImpl notification = new ENotificationImpl((InternalEObject)notifier, eventType, featureID, oldValue, newValue, isSetChanged ); + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + if (changeContextImpl.notificationChain == null) changeContextImpl.notificationChain = notification; else changeContextImpl.notificationChain.add(notification); + return changeContextImpl; + } + + protected ChangeContext addNotification(Object notifier, int eventType, int featureID, Object oldValue, Object newValue, ChangeContext changeContext) + { + ENotificationImpl notification = new ENotificationImpl((InternalEObject)notifier, eventType, featureID, oldValue, newValue); + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + if (changeContextImpl.notificationChain == null) changeContextImpl.notificationChain = notification; else changeContextImpl.notificationChain.add(notification); + return changeContextImpl; + } + + protected ChangeContext removeFromList(List propertyList, Object objectToRemove, ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + changeContextImpl.notificationChain = ((InternalEList)propertyList).basicRemove(objectToRemove, changeContextImpl.notificationChain); + return changeContextImpl; + } + + protected ChangeContext removeFromSequence(Sequence sequence, Object otherEnd, ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + changeContextImpl.notificationChain = ((InternalEList)((FeatureMap.Internal.Wrapper)sequence).featureMap()).basicRemove(otherEnd, changeContextImpl.notificationChain); + return changeContextImpl; + } + + protected void dispatch(ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + if (changeContextImpl.notificationChain != null) + { + changeContextImpl.notificationChain.dispatch(); + } + } + + protected boolean isProxy() // FB TODO : regen models and then remove this method + { + return eIsProxy(); + } + + protected boolean isProxy(Object object) + { + return ((EObject)object).eIsProxy(); + } + + protected Object resolveProxy(Object proxy) + { + Resource resource = this.eResource(); + ResourceSet resourceSet = resource != null ? resource.getResourceSet() : null; + if (resourceSet != null) return EcoreUtil.resolve((EObject)proxy, resourceSet); + + URI proxyURI = ((InternalEObject)proxy).eProxyURI(); + if (proxyURI != null) + { + EPackage ePackage = HelperContextImpl.getBuiltInModelRegistry().getEPackage(proxyURI.trimFragment().toString()); + if (ePackage != null) + { + resource = ePackage.eResource(); + if (resource != null) + { + return resource.getEObject(proxyURI.fragment().toString()); + } + } + } + return null; + } + + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Following methods override EMF methods to work with pure SDO generated subclasses + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + public EClass eStaticClass() + { + return (EClass)getStaticType(); + } + + public Type getStaticType() // must be overridden in subclasses + { + throw new UnsupportedOperationException(); + } + + public int eStaticFeatureCount() + { + return getStaticPropertyCount(); + } + + public int getStaticPropertyCount() // must be overridden in subclasses + { + throw new UnsupportedOperationException(); + } + + protected int internalConvertIndex(int internalIndex) + { + return internalIndex; + } + + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + Object result = get(internalConvertIndex(featureID), resolve); + if (coreType) + { + if (result instanceof FeatureMap.Internal.Wrapper) result = ((FeatureMap.Internal.Wrapper)result).featureMap(); + } + return result; + } + + public void eSet(int featureID, Object newValue) + { + set(internalConvertIndex(featureID), newValue); + } + + public void eUnset(int featureID) + { + unset(internalConvertIndex(featureID)); + } + + public boolean eIsSet(int featureID) + { + return isSet(internalConvertIndex(featureID)); + } + + private class ChangeContextImpl implements ChangeContext + { + protected NotificationChain notificationChain; + public ChangeContextImpl(NotificationChain notificationChain) { + this.notificationChain = notificationChain; + } + } + + //FB TODO ... review this? ... what about eInverseAdd? + public NotificationChain eInverseRemove(InternalEObject otherEnd, int internalIndex, NotificationChain msgs) + { + return ((ChangeContextImpl)inverseRemove(otherEnd, internalConvertIndex(internalIndex), new ChangeContextImpl(msgs))).notificationChain; + } + + public String toString() + { + StringBuffer result = new StringBuffer(getClass().getName()); + result.append('@'); + result.append(Integer.toHexString(hashCode())); + if (eIsProxy()) + { + result.append(" (proxyURI: "); + result.append(eProxyURI()); + result.append(')'); + } + return result.toString(); + } + +} //DataObjectBase + + + + + + + diff --git a/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectImpl.java b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectImpl.java new file mode 100644 index 0000000000..d97f677d34 --- /dev/null +++ b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectImpl.java @@ -0,0 +1,1562 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.Collections; +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.lib.UnknownPropertyList; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.apache.tuscany.sdo.util.VirtualSequence; +import org.apache.tuscany.sdo.util.DataObjectUtil.Accessor; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +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.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; +import commonj.sdo.impl.ExternalizableDelegator; + + +/** + * <!-- begin-user-doc --> + * 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. + * <!-- end-user-doc --> + * <p> + * </p> + * + * @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) + protected BasicEList eAdapters; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected DataObjectImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Object get(int propertyIndex) + { + return get(DataObjectUtil.getProperty(this, propertyIndex)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void set(int propertyIndex, Object value) + { + set(DataObjectUtil.getProperty(this, propertyIndex), value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isSet(int propertyIndex) + { + return isSet(DataObjectUtil.getProperty(this, propertyIndex)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void unset(int propertyIndex) + { + unset(DataObjectUtil.getProperty(this, propertyIndex)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Object get(Property property) + { + return eGet((EStructuralFeature)property, true, false); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void set(Property property, Object value) + { + eSet((EStructuralFeature)property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isSet(Property property) + { + return eIsSet((EStructuralFeature)property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void unset(Property property) + { + eUnset((EStructuralFeature)property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject getContainer() + { + return (DataObject)eContainer(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Property getContainmentProperty() + { + return (Property)eContainmentFeature(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Type getType() + { + return (Type)eClass(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Object writeReplace() throws ObjectStreamException + { + return new ExternalizableDelegator(this); + } + + + // Remaining DataObject methods are implemented as straight delegation to DataObjectUtil + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Object get(String path) + { + return DataObjectUtil.get(this, path); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void set(String path, Object value) + { + DataObjectUtil.set(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isSet(String path) + { + return DataObjectUtil.isSet(this, path); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void unset(String path) + { + DataObjectUtil.unset(this, path); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataGraph getDataGraph() + { + return DataObjectUtil.getDataGraph(this); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public BigDecimal getBigDecimal(String path) + { + return DataObjectUtil.getBigDecimal(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public BigInteger getBigInteger(String path) + { + return DataObjectUtil.getBigInteger(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean getBoolean(String path) + { + return DataObjectUtil.getBoolean(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public byte getByte(String path) + { + return DataObjectUtil.getByte(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public byte[] getBytes(String path) + { + return DataObjectUtil.getBytes(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public char getChar(String path) + { + return DataObjectUtil.getChar(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject getDataObject(String path) + { + return (DataObject)get(path); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Date getDate(String path) + { + return DataObjectUtil.getDate(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public double getDouble(String path) + { + return DataObjectUtil.getDouble(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public float getFloat(String path) + { + return DataObjectUtil.getFloat(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public int getInt(String path) + { + return DataObjectUtil.getInt(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getList(String path) + { + List result = (List)get(path); + if (result == null) { + result = new UnknownPropertyList(this, path); + } + + return result; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public long getLong(String path) + { + return DataObjectUtil.getLong(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Sequence getSequence(String path) + { + return (Sequence)get(path); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public short getShort(String path) + { + return DataObjectUtil.getShort(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String getString(String path) + { + return DataObjectUtil.getString(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBigDecimal(String path, BigDecimal value) + { + DataObjectUtil.setBigDecimal(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBigInteger(String path, BigInteger value) + { + DataObjectUtil.setBigInteger(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBoolean(String path, boolean value) + { + DataObjectUtil.setBoolean(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setByte(String path, byte value) + { + DataObjectUtil.setByte(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBytes(String path, byte[] value) + { + DataObjectUtil.setBytes(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setChar(String path, char value) + { + DataObjectUtil.setChar(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setDataObject(String path, DataObject value) + { + DataObjectUtil.set(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setDate(String path, Date value) + { + DataObjectUtil.setDate(this,path,value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setDouble(String path, double value) + { + DataObjectUtil.setDouble(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setFloat(String path, float value) + { + DataObjectUtil.setFloat(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setInt(String path, int value) + { + DataObjectUtil.setInt(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setList(String path, List value) + { + DataObjectUtil.set(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setLong(String path, long value) + { + DataObjectUtil.setLong(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setShort(String path, short value) + { + DataObjectUtil.setShort(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setString(String path, String value) + { + DataObjectUtil.setString(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public BigDecimal getBigDecimal(int propertyIndex) + { + return DataObjectUtil.getBigDecimal(this, propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public BigInteger getBigInteger(int propertyIndex) + { + return DataObjectUtil.getBigInteger(this,propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean getBoolean(int propertyIndex) + { + return DataObjectUtil.getBoolean(this, propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public byte getByte(int propertyIndex) + { + return DataObjectUtil.getByte(this, propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public byte[] getBytes(int propertyIndex) + { + return DataObjectUtil.getBytes(this, propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public char getChar(int propertyIndex) + { + return DataObjectUtil.getChar(this, propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject getDataObject(int propertyIndex) + { + return DataObjectUtil.getDataObject(this, propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Date getDate(int propertyIndex) + { + return DataObjectUtil.getDate(this,propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public double getDouble(int propertyIndex) + { + return DataObjectUtil.getDouble(this, propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public float getFloat(int propertyIndex) + { + return DataObjectUtil.getFloat(this,propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public int getInt(int propertyIndex) + { + return DataObjectUtil.getInt(this,propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getList(int propertyIndex) + { + return DataObjectUtil.getList(this, propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public long getLong(int propertyIndex) + { + return DataObjectUtil.getLong(this,propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Sequence getSequence(int propertyIndex) + { + return DataObjectUtil.getSequence(this, propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public short getShort(int propertyIndex) + { + return DataObjectUtil.getShort(this,propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String getString(int propertyIndex) + { + return DataObjectUtil.getString(this,propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBigDecimal(int propertyIndex, BigDecimal value) + { + DataObjectUtil.setBigDecimal(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBigInteger(int propertyIndex, BigInteger value) + { + DataObjectUtil.setBigInteger(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBoolean(int propertyIndex, boolean value) + { + DataObjectUtil.setBoolean(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setByte(int propertyIndex, byte value) + { + DataObjectUtil.setByte(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBytes(int propertyIndex, byte[] value) + { + DataObjectUtil.setBytes(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setChar(int propertyIndex, char value) + { + DataObjectUtil.setChar(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setDataObject(int propertyIndex, DataObject value) + { + DataObjectUtil.setDataObject(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setDate(int propertyIndex, Date value) + { + DataObjectUtil.setDate(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setDouble(int propertyIndex, double value) + { + DataObjectUtil.setDouble(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setFloat(int propertyIndex, float value) + { + DataObjectUtil.setFloat(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setInt(int propertyIndex, int value) + { + DataObjectUtil.setInt(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setList(int propertyIndex, List value) + { + DataObjectUtil.setList(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setLong(int propertyIndex, long value) + { + DataObjectUtil.setLong(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setShort(int propertyIndex, short value) + { + DataObjectUtil.setShort(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setString(int propertyIndex, String value) + { + DataObjectUtil.setString(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public BigDecimal getBigDecimal(Property property) + { + return DataObjectUtil.getBigDecimal(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public BigInteger getBigInteger(Property property) + { + return DataObjectUtil.getBigInteger(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean getBoolean(Property property) + { + return DataObjectUtil.getBoolean(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public byte getByte(Property property) + { + return DataObjectUtil.getByte(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public byte[] getBytes(Property property) + { + return DataObjectUtil.getBytes(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public char getChar(Property property) + { + return DataObjectUtil.getChar(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject getDataObject(Property property) + { + return (DataObject)DataObjectUtil.getDataObject(this,property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Date getDate(Property property) + { + return DataObjectUtil.getDate(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public double getDouble(Property property) + { + return DataObjectUtil.getDouble(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public float getFloat(Property property) + { + return DataObjectUtil.getFloat(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public int getInt(Property property) + { + return DataObjectUtil.getInt(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getList(Property property) + { + return (List)DataObjectUtil.getList(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public long getLong(Property property) + { + return DataObjectUtil.getLong(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Sequence getSequence(Property property) + { + return (Sequence)DataObjectUtil.getSequence(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public short getShort(Property property) + { + return DataObjectUtil.getShort(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String getString(Property property) + { + return DataObjectUtil.getString(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBigDecimal(Property property, BigDecimal value) + { + DataObjectUtil.setBigDecimal(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBigInteger(Property property, BigInteger value) + { + DataObjectUtil.setBigInteger(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBoolean(Property property, boolean value) + { + DataObjectUtil.setBoolean(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setByte(Property property, byte value) + { + DataObjectUtil.setByte(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBytes(Property property, byte[] value) + { + DataObjectUtil.setBytes(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setChar(Property property, char value) + { + DataObjectUtil.setChar(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setDataObject(Property property, DataObject value) + { + DataObjectUtil.setDataObject(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setDate(Property property, Date value) + { + DataObjectUtil.setDate(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setDouble(Property property, double value) + { + DataObjectUtil.setDouble(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setFloat(Property property, float value) + { + DataObjectUtil.setFloat(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setInt(Property property, int value) + { + DataObjectUtil.setInt(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setList(Property property, List value) + { + DataObjectUtil.setList(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setLong(Property property, long value) + { + DataObjectUtil.setLong(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setShort(Property property, short value) + { + DataObjectUtil.setShort(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setString(Property property, String value) + { + DataObjectUtil.setString(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject createDataObject(String propertyName) + { + return DataObjectUtil.createDataObject(this, propertyName); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject createDataObject(int propertyIndex) + { + return DataObjectUtil.createDataObject(this, propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject createDataObject(Property property) + { + return DataObjectUtil.createDataObject(this,property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject createDataObject(String propertyName, String namespaceURI, String typeName) + { + return DataObjectUtil.createDataObject(this, propertyName, namespaceURI, typeName); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject createDataObject(int propertyIndex, String namespaceURI, String typeName) + { + return DataObjectUtil.createDataObject(this, propertyIndex, namespaceURI, typeName); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject createDataObject(Property property, Type type) + { + return DataObjectUtil.createDataObject(this, property, type); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void delete() + { + DataObjectUtil.delete(this); + } + + protected Sequence sequence = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Sequence getSequence() + { + if (sequence == null) + { + EStructuralFeature sequenceFeature = ((ClassImpl)eClass()).getSequenceFeature(); + if (sequenceFeature == null) return null; + if (sequenceFeature == ClassImpl.VIRTUAL_SEQUENCE_FEATURE) + sequence = new VirtualSequence(this); + else + sequence = (Sequence)eGet(sequenceFeature, true, false); + } + return sequence; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getInstanceProperties() + { + return DataObjectUtil.getInstanceProperties(this); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Property getInstanceProperty(String propertyName) + { + return DataObjectUtil.getInstanceProperty(this, propertyName); + } + + /** + * @deprecated + */ + public Property getProperty(String propertyName) + { + return DataObjectUtil.getInstanceProperty(this, propertyName); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject getRootObject() + { + return DataObjectUtil.getRootObject(this); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public ChangeSummary getChangeSummary() + { + return DataObjectUtil.getChangeSummary(this); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void detach() + { + DataObjectUtil.detach(this); + } + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Following methods customize BasicEObjectImpl, optimized for SDO + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getDataObject(); + } + + public boolean eNotificationRequired() + { + return changeRecorder != null || super.eNotificationRequired(); + } + + public boolean eDeliver() + { + return true; + } + + public void eNotify(Notification notification) + { + if(changeRecorder != null) changeRecorder.notifyChanged(notification); + super.eNotify(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 EList eAdapters() + { + if (eAdapters == null) + { + eAdapters = new EAdapterList(this); + } + return eAdapters; + } + + public BasicEList eBasicAdapters() + { + return eAdapters; + } + + + /* + 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 + + + diff --git a/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/DataTypeImpl.java b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/DataTypeImpl.java new file mode 100644 index 0000000000..dee124429f --- /dev/null +++ b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/DataTypeImpl.java @@ -0,0 +1,781 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.util.Collections; +import java.util.List; + +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.impl.EDataTypeImpl; +import org.eclipse.emf.ecore.util.ExtendedMetaData; + +import commonj.sdo.Property; +import commonj.sdo.Sequence; +import commonj.sdo.Type; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Data Type</b></em>'. + * <!-- end-user-doc --> + * <p> + * </p> + * + * @generated + */ +public class DataTypeImpl extends EDataTypeImpl implements Type, org.apache.tuscany.sdo.model.Type/*, DataObject*/ +{ + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected DataTypeImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getDataType(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String getURI() + { + return getEPackage().getNsURI(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isDataType() + { + return true; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isOpen() + { + return false; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isSequenced() + { + return false; + } + + protected List aliasNames = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getAliasNames() + { + if (aliasNames == null) + { + aliasNames = DataObjectUtil.getAliasNames(this); + } + return aliasNames; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getDeclaredProperties() + { + return Collections.EMPTY_LIST; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getProperties() + { + return Collections.EMPTY_LIST; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getBaseTypes() + { + EDataType dataType = ExtendedMetaData.INSTANCE.getBaseType(this); + if (dataType == null) + { + return Collections.EMPTY_LIST; + } + else + { + return Collections.singletonList(dataType); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Property getProperty(String propertyName) + { + return null; + } + + public List getInstanceProperties() { + return DataObjectUtil.getMetaObjectInstanceProperties(this); + } + + public Object get(Property property) { + return DataObjectUtil.getMetaObjectInstanceProperty(this, property); + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // org.apache.tuscany.sdo.model.Type method implementations + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + + public List getBaseType() { + return this.getBaseTypes(); + } + + public List getProperty() { + return this.getProperties(); + } + + public List getAliasName() { + return this.getAliasNames(); + } + + public Sequence getAny() { + throw new UnsupportedOperationException(); + } + + public Sequence getAnyAttribute() { + throw new UnsupportedOperationException(); + } + + public boolean isAbstract() + { + return false; + } + + public void setAbstract(boolean value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetAbstract() { + return false; + } + + public void unsetAbstract() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void setDataType(boolean value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void unsetDataType() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetDataType() { + return true; + } + + public void setOpen(boolean value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void unsetOpen() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetOpen() { + return false; + } + + public void setSequenced(boolean value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void unsetSequenced() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetSequenced() { + return false; + } + + public void unsetName() + { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetName() + { + return true; + } + + public void unsetUri() + { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetUri() + { + return true; + } + + public void setUri(String value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public String getUri() { + return getURI(); + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // DataObject method implementations + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + /* + public Object get(int propertyIndex) { + Object ret = DataObjectUtil.get(this, propertyIndex); + return (ret != null) ? + ret : eGet(propertyIndex, true, false); + } + + public void set(int propertyIndex, Object value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSet(int propertyIndex) { + return eIsSet(propertyIndex); + } + + public void unset(int propertyIndex) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public Object get(Property property) { + Object ret = DataObjectUtil.get(this, ((EStructuralFeature)property).getFeatureID()); + return (ret != null) ? + ret : eGet((EStructuralFeature)property, true, false); + } + + public void set(Property property, Object value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSet(Property property) { + return eIsSet((EStructuralFeature)property); + } + + public void unset(Property property) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject getContainer() { + return (DataObject)eContainer(); + } + + public Property getContainmentProperty() { + return (Property)eContainmentFeature(); + } + + public Type getType() { + return (Type)ModelPackageImpl.eINSTANCE.getType(); + } + + // Remaining DataObject methods are (will be) implemented as straight delegation to DataObjectUtil + + public Object get(String path) { + return DataObjectUtil.get(this, path); + } + + public void set(String path, Object value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSet(String path) { + return DataObjectUtil.isSet(this, path); + } + + public void unset(String path) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean getBoolean(String path) { + return DataObjectUtil.getBoolean(get(path)); + } + + public byte getByte(String path) { + return DataObjectUtil.getByte(get(path)); + } + + public char getChar(String path) { + return DataObjectUtil.getChar(get(path)); + } + + public double getDouble(String path) { + return DataObjectUtil.getDouble(get(path)); + } + + public float getFloat(String path) { + return DataObjectUtil.getFloat(get(path)); + } + + public int getInt(String path) { + return DataObjectUtil.getInt(get(path)); + } + + public long getLong(String path) { + return DataObjectUtil.getLong(get(path)); + } + + public short getShort(String path) { + return DataObjectUtil.getShort(get(path)); + } + + public byte[] getBytes(String path) { + return DataObjectUtil.getBytes(get(path)); + } + + public BigDecimal getBigDecimal(String path) { + return DataObjectUtil.getBigDecimal(get(path)); + } + + public BigInteger getBigInteger(String path) { + return DataObjectUtil.getBigInteger(get(path)); + } + + public DataObject getDataObject(String path) { + return (DataObject)get(path); + } + + public Date getDate(String path) { + return DataObjectUtil.getDate(get(path)); + } + + public String getString(String path) { + return DataObjectUtil.getString(get(path)); + } + + public List getList(String path) { + return (List)get(path); + } + + public Sequence getSequence(String path) { + return (Sequence)get(path); + } + + public void setBoolean(String path, boolean value) { + set(path, new Boolean(value)); + } + + public void setByte(String path, byte value) { + set(path, new Byte(value)); + } + + public void setChar(String path, char value) { + set(path, new Character(value)); + } + + public void setDouble(String path, double value) { + set(path, new Double(value)); + } + + public void setFloat(String path, float value) { + set(path, new Float(value)); + } + + public void setInt(String path, int value) { + set(path, new Integer(value)); + } + + public void setLong(String path, long value) { + set(path, new Long(value)); + } + + public void setShort(String path, short value) { + set(path, new Short(value)); + } + + public void setBytes(String path, byte[] value) { + set(path, value); + } + + public void setBigDecimal(String path, BigDecimal value) { + set(path, value); + } + + public void setBigInteger(String path, BigInteger value) { + set(path, value); + } + + public void setDataObject(String path, DataObject value) { + set(path, value); + } + + public void setDate(String path, Date value) { + set(path, value); + } + + public void setString(String path, String value) { + set(path, value); + } + + public void setList(String path, List value) { + set(path, value); + } + + public boolean getBoolean(int propertyIndex) { + return DataObjectUtil.getBoolean(this, propertyIndex); + } + + public byte getByte(int propertyIndex) { + return DataObjectUtil.getByte(this, propertyIndex); + } + + public char getChar(int propertyIndex) { + return DataObjectUtil.getChar(this, propertyIndex); + } + + public double getDouble(int propertyIndex) { + return DataObjectUtil.getDouble(this, propertyIndex); + } + + public float getFloat(int propertyIndex) { + return DataObjectUtil.getFloat(this, propertyIndex); + } + + public int getInt(int propertyIndex) { + return DataObjectUtil.getInt(this, propertyIndex); + } + + public long getLong(int propertyIndex) { + return DataObjectUtil.getLong(this, propertyIndex); + } + + public short getShort(int propertyIndex) { + return DataObjectUtil.getShort(this, propertyIndex); + } + + public byte[] getBytes(int propertyIndex) { + return DataObjectUtil.getBytes(this, propertyIndex); + } + + public BigDecimal getBigDecimal(int propertyIndex) { + return DataObjectUtil.getBigDecimal(this, propertyIndex); + } + + public BigInteger getBigInteger(int propertyIndex) { + return DataObjectUtil.getBigInteger(this, propertyIndex); + } + + public DataObject getDataObject(int propertyIndex) { + return DataObjectUtil.getDataObject(this, propertyIndex); + } + + public Date getDate(int propertyIndex) { + return DataObjectUtil.getDate(this, propertyIndex); + } + + public String getString(int propertyIndex) { + return DataObjectUtil.getString(this, propertyIndex); + } + + public List getList(int propertyIndex) { + return DataObjectUtil.getList(this, propertyIndex); + } + + public Sequence getSequence(int propertyIndex) { + return DataObjectUtil.getSequence(this, propertyIndex); + } + + public void setBoolean(int propertyIndex, boolean value) { + set(propertyIndex, new Boolean(value)); + } + + public void setByte(int propertyIndex, byte value) { + set(propertyIndex, new Byte(value)); + } + + public void setChar(int propertyIndex, char value) { + set(propertyIndex, new Character(value)); + } + + public void setDouble(int propertyIndex, double value) { + set(propertyIndex, new Double(value)); + } + + public void setFloat(int propertyIndex, float value) { + set(propertyIndex, new Float(value)); + } + + public void setInt(int propertyIndex, int value) { + set(propertyIndex, new Integer(value)); + } + + public void setLong(int propertyIndex, long value) { + set(propertyIndex, new Long(value)); + } + + public void setShort(int propertyIndex, short value) { + set(propertyIndex, new Short(value)); + } + + public void setBytes(int propertyIndex, byte[] value) { + set(propertyIndex, value); + } + + public void setBigDecimal(int propertyIndex, BigDecimal value) { + set(propertyIndex, value); + } + + public void setBigInteger(int propertyIndex, BigInteger value) { + set(propertyIndex, value); + } + + public void setDataObject(int propertyIndex, DataObject value) { + set(propertyIndex, value); + } + + public void setDate(int propertyIndex, Date value) { + set(propertyIndex, value); + } + + public void setString(int propertyIndex, String value) { + set(propertyIndex, value); + } + + public void setList(int propertyIndex, List value) { + set(propertyIndex, value); + } + + public boolean getBoolean(Property property) { + return DataObjectUtil.getBoolean(this, property); + } + + public byte getByte(Property property) { + return DataObjectUtil.getByte(this, property); + } + + public char getChar(Property property) { + return DataObjectUtil.getChar(this, property); + } + + public double getDouble(Property property) { + return DataObjectUtil.getDouble(this, property); + } + + public float getFloat(Property property) { + return DataObjectUtil.getFloat(this, property); + } + + public int getInt(Property property) { + return DataObjectUtil.getInt(this, property); + } + + public long getLong(Property property) { + return DataObjectUtil.getLong(this, property); + } + + public short getShort(Property property) { + return DataObjectUtil.getShort(this, property); + } + + public byte[] getBytes(Property property) { + return DataObjectUtil.getBytes(this, property); + } + + public BigDecimal getBigDecimal(Property property) { + return DataObjectUtil.getBigDecimal(this, property); + } + + public BigInteger getBigInteger(Property property) { + return DataObjectUtil.getBigInteger(this, property); + } + + public DataObject getDataObject(Property property) { + return DataObjectUtil.getDataObject(this, property); + } + + public Date getDate(Property property) { + return DataObjectUtil.getDate(this, property); + } + + public String getString(Property property) { + return DataObjectUtil.getString(this, property); + } + + public List getList(Property property) { + return DataObjectUtil.getList(this, property); + } + + public Sequence getSequence(Property property) { + return DataObjectUtil.getSequence(this, property); + } + + public void setBoolean(Property property, boolean value) { + set(property, new Boolean(value)); + } + + public void setByte(Property property, byte value) { + set(property, new Byte(value)); + } + + public void setChar(Property property, char value) { + set(property, new Character(value)); + } + + public void setDouble(Property property, double value) { + set(property, new Double(value)); + } + + public void setFloat(Property property, float value) { + set(property, new Float(value)); + } + + public void setInt(Property property, int value) { + set(property, new Integer(value)); + } + + public void setLong(Property property, long value) { + set(property, new Long(value)); + } + + public void setShort(Property property, short value) { + set(property, new Short(value)); + } + + public void setBytes(Property property, byte[] value) { + set(property, value); + } + + public void setBigDecimal(Property property, BigDecimal value) { + set(property, value); + } + + public void setBigInteger(Property property, BigInteger value) { + set(property, value); + } + + public void setDataObject(Property property, DataObject value) { + set(property, value); + } + + public void setDate(Property property, Date value) { + set(property, value); + } + + public void setString(Property property, String value) { + set(property, value); + } + + public void setList(Property property, List value) { + set(property, value); + } + + public DataObject createDataObject(String propertyName) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(String propertyName, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property, Type type) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void delete() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataGraph getDataGraph() { + return DataObjectUtil.getDataGraph(this); + } + + public Sequence getSequence() { + EAttribute mixedFeature = BasicExtendedMetaData.INSTANCE.getMixedFeature(eClass()); + return mixedFeature != null ? (Sequence)eGet(mixedFeature, true, false) : null; + } + + public List getInstanceProperties() { + return DataObjectUtil.getInstanceProperties(this); + } + + public DataObject getRootObject() { + return DataObjectUtil.getRootObject(this); + } + + public ChangeSummary getChangeSummary() { + // TODO: implement this method + throw new UnsupportedOperationException(); + } + + public void detach() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + */ + +} //DataTypeImpl diff --git a/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicDataObjectImpl.java b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicDataObjectImpl.java new file mode 100644 index 0000000000..153ef18444 --- /dev/null +++ b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicDataObjectImpl.java @@ -0,0 +1,216 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.SDOPackage; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Dynamic Data Object</b></em>'. + * @extends EStructuralFeature.Internal.DynamicValueHolder + * <!-- end-user-doc --> + * <p> + * </p> + * + * @generated + */ +public class DynamicDataObjectImpl extends DataObjectImpl implements DataObject, EStructuralFeature.Internal.DynamicValueHolder +{ + protected EClass eClass; + protected Object [] eSettings; + + protected static final Object [] ENO_SETTINGS = new Object [0]; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected DynamicDataObjectImpl() + { + super(); + } + + /** + * Creates a dynamic DataObject. + */ + public DynamicDataObjectImpl(EClass eClass) + { + super(); + eSetClass(eClass); + Property csp = ((ClassImpl)eClass).getChangeSummaryProperty(); + if (csp != null) + { + ChangeSummaryImpl changeSummary = (ChangeSummaryImpl)SDOFactory.eINSTANCE.createChangeSummary(); + set(csp, changeSummary); + changeSummary.setDataObject(this); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getDynamicDataObject(); + } + + protected int eStaticFeatureCount() + { + return 0; + } + + public int eDerivedStructuralFeatureID(EStructuralFeature eStructuralFeature) + { + return eClass().getFeatureID(eStructuralFeature); + } + + protected boolean eHasSettings() + { + return eSettings != null; + } + + protected EStructuralFeature.Internal.DynamicValueHolder eSettings() + { + if (eSettings == null) + { + int size = eClass().getFeatureCount() - eStaticFeatureCount(); + eSettings = size == 0 ? ENO_SETTINGS : new Object [size]; + } + + return this; + } + + protected EClass eDynamicClass() + { + return eClass; + } + + public EClass eClass() + { + return eClass; + } + + public void eSetClass(EClass eClass) + { + this.eClass = eClass; + } + + public Object dynamicGet(int dynamicFeatureID) + { + return eSettings[dynamicFeatureID]; + } + + public void dynamicSet(int dynamicFeatureID, Object value) + { + eSettings[dynamicFeatureID] = value; + } + + public void dynamicUnset(int dynamicFeatureID) + { + eSettings[dynamicFeatureID] = null; + } + + public Object eDynamicGet(int featureID, boolean resolve, boolean coreType) + { + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + return eSettingDelegate(eFeature).dynamicGet(this, eSettings(), featureID, resolve, coreType); + } + else + { + return super.eDynamicGet(featureID, resolve, coreType); + } + } + + public void eDynamicSet(int featureID, Object newValue) + { + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + try { + eDynamicSet(featureID, eFeature, newValue); + } catch (IllegalArgumentException e) { + throw new UnsupportedOperationException(e.getMessage()); + } + } + else + { + super.eDynamicSet(featureID, newValue); + } + } + + public void eDynamicUnset(int featureID) + { + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + try { + eDynamicUnset(featureID, eFeature); + } catch (IllegalArgumentException e) { + throw new UnsupportedOperationException(e.getMessage()); + } + } + else + { + super.eDynamicUnset(featureID); + } + } + + public boolean eDynamicIsSet(int featureID) + { + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + return eSettingDelegate(eFeature).dynamicIsSet(this, eSettings(), featureID); + } + else + { + return super.eDynamicIsSet(featureID); + } + } + + /** + * An EFactoryImpl that creates DynamicEDataObjectImpl instances. + */ + public static class FactoryImpl extends EFactoryImpl + { + public FactoryImpl() + { + } + + public EObject basicCreate(EClass eClass) + { + return new DynamicDataObjectImpl(eClass); + } + } + +} //DynamicDataObjectImpl diff --git a/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicStoreDataObjectImpl.java b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicStoreDataObjectImpl.java new file mode 100644 index 0000000000..d9d39bad49 --- /dev/null +++ b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicStoreDataObjectImpl.java @@ -0,0 +1,91 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.apache.tuscany.sdo.SDOPackage; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import commonj.sdo.DataObject; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Dynamic Store Data Object</b></em>'. + * <!-- end-user-doc --> + * <p> + * </p> + * + * @generated + */ +public class DynamicStoreDataObjectImpl extends StoreDataObjectImpl implements DataObject +{ + protected EClass eClass; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected DynamicStoreDataObjectImpl() + { + super(); + } + + public DynamicStoreDataObjectImpl(InternalEObject.EStore eStore) + { + super(eStore); + } + + public DynamicStoreDataObjectImpl(EClass eClass) + { + super(eClass); + } + + public DynamicStoreDataObjectImpl(EClass eClass, InternalEObject.EStore eStore) + { + super(eClass, eStore); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getDynamicStoreDataObject(); + } + + protected EClass eDynamicClass() + { + return eClass; + } + + public EClass eClass() + { + return eClass; + } + + public void eSetClass(EClass eClass) + { + this.eClass = eClass; + } + +} //DynamicStoreDataObjectImpl diff --git a/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/EnumImpl.java b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/EnumImpl.java new file mode 100644 index 0000000000..54f642d8cf --- /dev/null +++ b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/EnumImpl.java @@ -0,0 +1,183 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.util.Collections; +import java.util.List; + +//import org.apache.tuscany.sdo.SDOPackage; + +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.impl.EEnumImpl; + +import commonj.sdo.Property; +import commonj.sdo.Type; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Enum</b></em>'. + * <!-- end-user-doc --> + * <p> + * </p> + * + * @generated + * @deprecated SDO doesn't support Enum types + */ +public class EnumImpl extends EEnumImpl implements Type +{ + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EnumImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + protected EClass eStaticClass() + { + return EcorePackage.eINSTANCE.getEEnum(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String getURI() + { + return getEPackage().getNsURI(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isDataType() + { + return true; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isOpen() + { + return false; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isSequenced() + { + return false; + } + + protected List aliasNames = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getAliasNames() + { + if (aliasNames == null) + { + aliasNames = DataObjectUtil.getAliasNames(this); + } + return aliasNames; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getDeclaredProperties() + { + return Collections.EMPTY_LIST; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getProperties() + { + return Collections.EMPTY_LIST; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getBaseTypes() + { + return Collections.EMPTY_LIST; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Property getProperty(String propertyName) + { + return null; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isAbstract() + { + return false; + } + + public List getInstanceProperties() + { + throw new UnsupportedOperationException(); + } + + public Object get(Property property) + { + throw new UnsupportedOperationException(); + } + +} //EnumTypeImpl diff --git a/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/EventImpl.java b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/EventImpl.java new file mode 100644 index 0000000000..206a3c1fbf --- /dev/null +++ b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/EventImpl.java @@ -0,0 +1,78 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.apache.tuscany.sdo.api.Event; +import org.eclipse.emf.common.notify.Notification; + +import commonj.sdo.Property; + + +public class EventImpl implements Event { + + protected Notification emfEvent; + protected Object notifier; + + public EventImpl(Notification notification) + { + this.emfEvent = notification; + } + + public Object getNotifier() + { + return notifier == null ? emfEvent.getNotifier() : notifier; + } + + public int getEventType() + { + return emfEvent.getEventType(); + } + + + public Property getProperty() + { + return (Property)emfEvent.getFeature(); + } + + public Object getOldValue() + { + return emfEvent.getOldValue(); + } + + public Object getNewValue() + { + return emfEvent.getNewValue(); + } + + public boolean wasSet() + { + return emfEvent.wasSet(); + } + + public boolean isTouch() + { + return emfEvent.isTouch(); + } + + public int getPosition() + { + return emfEvent.getPosition(); + } +} diff --git a/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/ExtensibleDataObjectImpl.java b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/ExtensibleDataObjectImpl.java new file mode 100644 index 0000000000..93825f7873 --- /dev/null +++ b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/ExtensibleDataObjectImpl.java @@ -0,0 +1,267 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.SDOPackage; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Extensible Data Object</b></em>'. + * @extends EStructuralFeature.Internal.DynamicValueHolder + * <!-- end-user-doc --> + * <p> + * </p> + * + * @generated + */ +public class ExtensibleDataObjectImpl extends DataObjectImpl implements DataObject, EStructuralFeature.Internal.DynamicValueHolder +{ + protected EClass eClass; + protected Object [] eSettings; + + protected static final Object [] ENO_SETTINGS = new Object [0]; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected ExtensibleDataObjectImpl() + { + super(); + } + + /** + * Creates an extensible DataObject. + */ + public ExtensibleDataObjectImpl(EClass eClass) + { + super(); + eSetClass(eClass); + Property csp = ((ClassImpl)eClass).getChangeSummaryProperty(); + if (csp != null) + { + ChangeSummaryImpl changeSummary = (ChangeSummaryImpl)SDOFactory.eINSTANCE.createChangeSummary(); + set(csp, changeSummary); + changeSummary.setDataObject(this); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getExtensibleDataObject(); + } + + public int eDerivedStructuralFeatureID(EStructuralFeature eStructuralFeature) + { + return eClass().getFeatureID(eStructuralFeature); + } + + protected boolean eHasSettings() + { + return eSettings != null; + } + + protected EStructuralFeature.Internal.DynamicValueHolder eSettings() + { + if (eSettings == null) + { + int size = eClass().getFeatureCount() - eStaticFeatureCount(); + eSettings = size == 0 ? ENO_SETTINGS : new Object [size]; + } + + return this; + } + + protected EClass eDynamicClass() + { + return eClass; + } + + protected boolean isDynamic() + { + return (eClass != null); + } + + public Object get(int featureID, boolean resolve) + { + return get(featureID, resolve, true); + } + + public Object get(int featureID, boolean resolve, boolean coreType) + { + Object result = null; + if (isDynamic() || featureID >= eStaticFeatureCount()) + { + result = super.eGet(featureID, resolve, coreType); + } + else + { + result = super.get(featureID); + } + return result; + } + + public void set(int featureID, Object newValue) + { + if (isDynamic() || featureID >= eStaticFeatureCount()) + { + super.eSet(featureID, newValue); + } + else + { + super.set(featureID, newValue); + } + } + + public void unset(int featureID) + { + if (isDynamic() || featureID >= eStaticFeatureCount()) + { + super.eUnset(featureID); + } + else + { + super.unset(featureID); + } + } + + public boolean isSet(int featureID) + { + if (isDynamic() || featureID >= eStaticFeatureCount()) + { + return super.eIsSet(featureID); + } + else + { + return super.isSet(featureID); + } + } + + public EClass eClass() + { + return isDynamic() ? eClass : eStaticClass(); + } + + public void eSetClass(EClass eClass) + { + this.eClass = eClass; + } + + public Object dynamicGet(int dynamicFeatureID) + { + return eSettings[dynamicFeatureID]; + } + + public void dynamicSet(int dynamicFeatureID, Object value) + { + eSettings[dynamicFeatureID] = value; + } + + public void dynamicUnset(int dynamicFeatureID) + { + eSettings[dynamicFeatureID] = null; + } + + public Object eDynamicGet(int featureID, boolean resolve, boolean coreType) + { + int dynamicFeatureID = featureID - eStaticFeatureCount(); + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + return eSettingDelegate(eFeature).dynamicGet(this, eSettings(), dynamicFeatureID, resolve, coreType); + } + else + { + return super.eDynamicGet(dynamicFeatureID, resolve, coreType); + } + } + + public void eDynamicSet(int featureID, Object newValue) + { + int dynamicFeatureID = featureID - eStaticFeatureCount(); + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + eDynamicSet(dynamicFeatureID, eFeature, newValue); + } + else + { + super.eDynamicSet(dynamicFeatureID, newValue); + } + } + + public void eDynamicUnset(int featureID) + { + int dynamicFeatureID = featureID - eStaticFeatureCount(); + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + eDynamicUnset(dynamicFeatureID, eFeature); + } + else + { + super.eDynamicUnset(dynamicFeatureID); + } + } + + public boolean eDynamicIsSet(int featureID) + { + int dynamicFeatureID = featureID - eStaticFeatureCount(); + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + return eSettingDelegate(eFeature).dynamicIsSet(this, eSettings(), dynamicFeatureID); + } + else + { + return super.eDynamicIsSet(dynamicFeatureID); + } + } + + /** + * An EFactoryImpl that creates ExtensibleDataObjectImpl instances. + */ + public static class FactoryImpl extends EFactoryImpl + { + public FactoryImpl() + { + } + + public EObject basicCreate(EClass eClass) + { + return new ExtensibleDataObjectImpl(eClass); + } + } + +} //ExtensibleDataObjectImpl diff --git a/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/FactoryBase.java b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/FactoryBase.java new file mode 100644 index 0000000000..e344a6ffde --- /dev/null +++ b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/FactoryBase.java @@ -0,0 +1,368 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.impl.SDOFactoryImpl.SDOEcoreFactory; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.ENamedElement; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.impl.EClassImpl; +import org.eclipse.emf.ecore.impl.EPackageImpl; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; + +/** + * Base class for generated (static) SDO factories + */ +public class FactoryBase extends EPackageImpl +{ + + public static final boolean IS_ATTRIBUTE = true; + + protected FactoryBase(String namespaceURI, String namespacePrefix) + { + super(new SDOEFactoryImpl()); + ecoreFactory = new SDOEcoreFactory(); + + int index = namespacePrefix.lastIndexOf("."); + setName(index != -1 ? namespacePrefix.substring(index + 1) : namespacePrefix); + setNsPrefix(namespacePrefix); + + createResource(namespaceURI); + setNsURI(namespaceURI); + + ((SDOEFactoryImpl)getEFactoryInstance()).sdoFactory = this; + } + + protected FactoryBase(String namespaceURI, String namespacePrefix, String interfacePackage) + { + super(new SDOEFactoryImpl()); + ecoreFactory = new SDOEcoreFactory(); + + int index = interfacePackage.lastIndexOf("."); + setName(index != -1 ? interfacePackage.substring(index + 1) : interfacePackage); + setNsPrefix(namespacePrefix); + + createResource(namespaceURI); + setNsURI(namespaceURI); + + ((SDOEFactoryImpl)getEFactoryInstance()).sdoFactory = this; + } + + + + public DataObject create(int typeNumber) + { + return null; + } + + public Object createFromString(int typeNumber, String stringValue) + { + return ((SDOEFactoryImpl)getEFactoryInstance()).createFromString(typeNumber, stringValue); + } + + public String convertToString(int typeNumber, Object objectValue) + { + return ((SDOEFactoryImpl)getEFactoryInstance()).convertToString(typeNumber, objectValue); + } + + protected Type createType(boolean isDataType, int typeNumber) + { + if (isDataType) + return (Type)createEDataType(typeNumber); + else + return (Type)createEClass(typeNumber); + } + + protected void createProperty(boolean isDataType, Type containingType, int internalPropertyNumber) + { + if (isDataType) + createEAttribute((EClass)containingType, internalPropertyNumber); + else + createEReference((EClass)containingType, internalPropertyNumber); + } + + /** + * @deprecated - use getLocalProperty instead, since getProperty causes + * caching of structural features. + */ + protected Property getProperty(Type type, int internalPropertyNumber) + { + return (Property)((EClass)type).getEAllStructuralFeatures().get(internalPropertyNumber); + } + + protected Property getLocalProperty(Type type, int localPropertyIndex) + { + return (Property)((EClass)type).getEStructuralFeatures().get(localPropertyIndex); + } + + + protected void initializeType(Type type, Class instanceClass, String name) + { + initEClass((EClass)type, instanceClass, name, !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + } + + protected void initializeType(Type type, Class instanceClass, String name, boolean isAbstract) + { + initEClass((EClass)type, instanceClass, name, isAbstract, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + } + + protected void initializeType(Type type, Class instanceClass, String name, boolean isSerializable, boolean isGenerated) + { + initEDataType((EDataType)type, instanceClass, name, isSerializable, isGenerated); + } + + protected void initializeProperty(Property property, Type type, String name, String defaultValue, int lower, int upper, Class containerClass, boolean isReadonly, boolean isUnsettable, boolean isDerived) + { + initEAttribute((EAttribute)property, type != sequence ? (EClassifier)type : ecorePackage.getEFeatureMapEntry(), name, defaultValue, lower, upper, containerClass, isDerived, isDerived, !isReadonly, isUnsettable, !IS_ID, !IS_UNIQUE, isDerived, IS_ORDERED); + } + + protected void initializeProperty(Property property, Type type, String name, String defaultValue, int lower, int upper, Class containerClass, boolean isReadonly, boolean isUnsettable, boolean isDerived, boolean isComposite, Property oppositeProperty) + { + initEReference((EReference)property, (EClassifier)type, (EReference)oppositeProperty, name, defaultValue, lower, upper, containerClass, isDerived, isDerived, !isReadonly, isComposite, !isComposite /*resolve*/, isUnsettable, IS_UNIQUE, isDerived, IS_ORDERED); + } + + protected void initXSD() + { + createDocumentRoot(); + } + + protected void addXSDMapping(String[] xsdMappings, String annotationSource) + { + addAnnotation((ENamedElement)this, annotationSource, xsdMappings); + } + + protected void addXSDMapping(Type type, String[] xsdMappings) + { + addAnnotation((ENamedElement)type, ANNOTATION_SOURCE, xsdMappings); + } + + protected void addXSDMapping(Property property, String[] xsdMappings) + { + addAnnotation((ENamedElement)property, ANNOTATION_SOURCE, xsdMappings); + } + + protected void setInstanceProperty(Type type, String namespaceURI, String propertyName, String propertyValue) + { + setInstanceProperty((ENamedElement)type, namespaceURI, propertyName, propertyValue); + } + + protected void setInstanceProperty(Property property, String namespaceURI, String propertyName, String propertyValue) + { + setInstanceProperty((ENamedElement)property, namespaceURI, propertyName, propertyValue); + } + + private void setInstanceProperty(ENamedElement eNamedElement, String namespaceURI, String propertyName, String propertyValue) + { + EAnnotation annotation = eNamedElement.getEAnnotation(namespaceURI); + if (annotation == null) + { + addAnnotation(eNamedElement, namespaceURI, new String[]{propertyName, propertyValue}); + } else + { + annotation.getDetails().put(propertyName, propertyValue); + } + } + + protected Property createGlobalProperty(String name, Type type, String[] xsdMappings) + { + return createGlobalProperty(name, type, xsdMappings, false); + } + + protected Property createGlobalProperty(String name, Type type, String[] xsdMappings, boolean asAttribute) + { + return createGlobalProperty(name, type, xsdMappings, asAttribute, ANNOTATION_SOURCE); + } + + protected Property createGlobalProperty(String name, Type type, String[] xsdMappings, boolean asAttribute, String annotationSource) + { + int propertyNumber = documentRootEClass.getEStructuralFeatures().size(); + + EStructuralFeature globalProperty; + if(asAttribute) { + createEAttribute(documentRootEClass, propertyNumber); + EAttribute gatt = (EAttribute)documentRootEClass.getEStructuralFeatures().get(propertyNumber); + initEAttribute(gatt, (EDataType)type, name, null, 0, -2, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, IS_DERIVED, IS_ORDERED); + globalProperty = gatt; + } else { + createEReference(documentRootEClass, propertyNumber); + EReference gref = (EReference)documentRootEClass.getEStructuralFeatures().get(propertyNumber); + initEReference(gref, (EClass)type, null, name, null, 0, -2, null, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + globalProperty = gref; + } + addAnnotation((ENamedElement)globalProperty, annotationSource, xsdMappings); + return (Property) globalProperty; + } + + private static final Type sequence = SDOFactory.eINSTANCE.createDataType(); // dummy type + + protected Type getSequence() + { + return sequence; + } + + protected void addSuperType(Type subType, Type superType) + { + ((EClass)subType).getESuperTypes().add((EClass)superType); + } + + /*** + * @param namespaceURI + * @return Static factory (from the global scope) for the provided URI + * + * @deprecated - Use of the global scope is no longer encouraged. This method uses the + * global scope for retrieving the URI's factory. Instead, it is now possible to simply + * access SomeFactoryInterface.INSTANCE object directly. + * + */ + public static Object getStaticFactory(String namespaceURI) + { + EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(namespaceURI); + //return (FactoryBase)ePackage; + return ePackage instanceof FactoryBase ? (Object)ePackage : (Object)ePackage.getEFactoryInstance(); + } + + // private EMF-specific methods + + private static class SDOEFactoryImpl extends DynamicDataObjectImpl.FactoryImpl + { + protected FactoryBase sdoFactory; + + public SDOEFactoryImpl() + { + super(); + } + + public EObject create(EClass eClass) + { + DataObject result = sdoFactory.create(eClass.getClassifierID()); + if (result == null) { + if (eClass.isAbstract()) { + Class instanceClass = eClass.getInstanceClass(); + try { + Class concreteInstanceClass = DataObjectUtil.getImplementationClass(instanceClass, true); + return (EObject)concreteInstanceClass.newInstance(); + } + catch (Exception e) + { + //System.out.println("Error: " + e); + } + } + return super.create(eClass); + } + return (EObject)result; + } + + public Object createFromString(EDataType eDataType, String stringValue) + { + return sdoFactory.createFromString(eDataType.getClassifierID(), stringValue); + } + + public String convertToString(EDataType eDataType, Object objectValue) + { + return sdoFactory.convertToString(eDataType.getClassifierID(), objectValue); + } + + protected Object createFromString(int typeNumber, String stringValue) + { + return super.createFromString((EDataType)sdoFactory.getEClassifiers().get(typeNumber), stringValue); + } + + protected String convertToString(int typeNumber, Object objectValue) + { + return super.convertToString((EDataType)sdoFactory.getEClassifiers().get(typeNumber), objectValue); + } + } + + private static final int DOCUMENT_ROOT = 0; + private static final int DOCUMENT_ROOT__MIXED = 0; + private static final int DOCUMENT_ROOT__XMLNS_PREFIX_MAP = 1; + private static final int DOCUMENT_ROOT__XSI_SCHEMA_LOCATION = 2; + private static final String ANNOTATION_SOURCE = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData"; + private EClass documentRootEClass = null; + + private void createDocumentRoot() + { + documentRootEClass = ecoreFactory.createEClass(); + ((EClassImpl)documentRootEClass).setClassifierID(DOCUMENT_ROOT); + getEClassifiers().add(DOCUMENT_ROOT, documentRootEClass); + + createEAttribute(documentRootEClass, DOCUMENT_ROOT__MIXED); + createEReference(documentRootEClass, DOCUMENT_ROOT__XMLNS_PREFIX_MAP); + createEReference(documentRootEClass, DOCUMENT_ROOT__XSI_SCHEMA_LOCATION); + + initEClass(documentRootEClass, null, "DocumentRoot", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + initEAttribute((EAttribute)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__MIXED), ecorePackage.getEFeatureMapEntry(), "mixed", null, 0, -1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference((EReference)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__XMLNS_PREFIX_MAP), ecorePackage.getEStringToStringMapEntry(), null, "xMLNSPrefixMap", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference((EReference)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__XSI_SCHEMA_LOCATION), ecorePackage.getEStringToStringMapEntry(), null, "xSISchemaLocation", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + addAnnotation + (documentRootEClass, + ANNOTATION_SOURCE, + new String[] + { + "name", "", + "kind", "mixed" + }); + addAnnotation + ((EAttribute)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__MIXED), + ANNOTATION_SOURCE, + new String[] + { + "kind", "elementWildcard", + "name", ":mixed" + }); + addAnnotation + ((EReference)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__XMLNS_PREFIX_MAP), + ANNOTATION_SOURCE, + new String[] + { + "kind", "attribute", + "name", "xmlns:prefix" + }); + addAnnotation + ((EReference)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__XSI_SCHEMA_LOCATION), + ANNOTATION_SOURCE, + new String[] + { + "kind", "attribute", + "name", "xsi:schemaLocation" + }); + } + + /** + * Initialize SDO runtime. + */ + static + { + DataObjectUtil.initRuntime(); + } +} diff --git a/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/ListenerBase.java b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/ListenerBase.java new file mode 100644 index 0000000000..986628bbc9 --- /dev/null +++ b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/ListenerBase.java @@ -0,0 +1,33 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.apache.tuscany.sdo.api.Event; +import org.apache.tuscany.sdo.api.EventListener; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.impl.AdapterImpl; + +public abstract class ListenerBase extends AdapterImpl implements EventListener { + + public void notifyChanged(Notification msg) { + Event e = new EventImpl(msg); + eventNotification(e); + } +} diff --git a/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/ReferenceImpl.java b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/ReferenceImpl.java new file mode 100644 index 0000000000..19fb89bbd3 --- /dev/null +++ b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/ReferenceImpl.java @@ -0,0 +1,785 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.util.List; + +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.apache.tuscany.sdo.util.SDOUtil; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.impl.EReferenceImpl; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.ExtendedMetaData; + +import commonj.sdo.Property; +import commonj.sdo.Sequence; +import commonj.sdo.Type; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Reference</b></em>'. + * <!-- end-user-doc --> + * <p> + * </p> + * + * @generated + */ +public class ReferenceImpl extends EReferenceImpl implements Property,/* DataObject,*/ org.apache.tuscany.sdo.model.Property +{ + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected ReferenceImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getReference(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Object getDefault() + { + return getDefaultValue(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isReadOnly() + { + //return "true".equals(EcoreUtil.getAnnotation(this, "commonj.sdo", "readOnly")); + return !isChangeable(); //TODO semantics don't exactly match? + } + + /** + * Single-valued SDO properties behave as EMF unsettable, multi-valued properties as EMF !unsettable + */ + public boolean isUnsettable() + { + return !isMany(); + } + + protected List aliasNames = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getAliasNames() + { + if (aliasNames == null) + { + aliasNames = DataObjectUtil.getAliasNames(this); + } + return aliasNames; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Type getType() + { + return (Type)getEType(); + /* + EClassifier eType = getEType(); + //FB More temporary hacks + return eType instanceof Type ? (Type)getEType() : null; + */ + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Type getContainingType() + { + return (Type)getEContainingClass(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Property getOpposite() + { + return (Property)getEOpposite(); + } + + public boolean isNullable() + { + String isNillable = EcoreUtil.getAnnotation(this, ExtendedMetaData.ANNOTATION_URI, "nillable"); + return isNillable != null && "true".equals(isNillable); + } + + public boolean isOpenContent() + { + return SDOUtil.isDocumentRoot(getContainingType()); + } + + public List getInstanceProperties() { + return DataObjectUtil.getMetaObjectInstanceProperties(this); + } + + public Object get(Property property) { + return DataObjectUtil.getMetaObjectInstanceProperty(this, property); + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // org.apache.tuscany.sdo.model.Property methods + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + + public List getAliasName() { + return this.getAliasNames(); + } + + public Sequence getAny() { + throw new UnsupportedOperationException(); + } + + public void setMany(boolean value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void unsetMany() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetMany() { + return isMany(); + } + + public void setReadOnly(boolean value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void unsetReadOnly() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetReadOnly() { + return isReadOnly(); + } + + public org.apache.tuscany.sdo.model.Type getType_() { + return (org.apache.tuscany.sdo.model.Type)getType(); + } + + public void setType(org.apache.tuscany.sdo.model.Type value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public Sequence getAnyAttribute() { + throw new UnsupportedOperationException(); + } + + public String getDefault_() { + return (String) this.getDefault(); + } + + public void setDefault_(String value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public org.apache.tuscany.sdo.model.Property getOpposite_() { + return (org.apache.tuscany.sdo.model.Property) getOpposite(); + } + + public void setOpposite_(org.apache.tuscany.sdo.model.Property value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void unsetContainment() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetContainment() { + return isContainment(); + } + + public void setNullable(boolean value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void unsetNullable() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetNullable() { + return isNullable(); + } + + public void unsetName() + { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetName() + { + return true; + } + + public void unsetOpposite() + { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetOpposite() + { + return getOpposite() != null; + } + + public void unsetType() + { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetType() + { + return true; + } + + public void unsetDefault() + { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetDefault() + { + return getDefault() != null; + } + + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // DataObject method implementations + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + /* + public Object get(int propertyIndex) { + return DataObjectUtil.get(this, propertyIndex); + } + + public void set(int propertyIndex, Object value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSet(int propertyIndex) { + return DataObjectUtil.isSet(this, propertyIndex); + } + + public void unset(int propertyIndex) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public Object get(Property property) { + return DataObjectUtil.get(this, ((EStructuralFeature)property).getFeatureID()); + } + + public void set(Property property, Object value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSet(Property property) { + return DataObjectUtil.isSet(this, ((EStructuralFeature)property).getFeatureID()); + } + + public void unset(Property property) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject getContainer() { + return (DataObject)eContainer(); + } + + public Property getContainmentProperty() { + return (Property)eContainmentFeature(); + } + + // Remaining DataObject methods are (will be) implemented as straight delegation to DataObjectUtil + + public Object get(String path) { + return DataObjectUtil.get(this, path); + } + + public void set(String path, Object value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSet(String path) { + return DataObjectUtil.isSet(this, path); + } + + public void unset(String path) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean getBoolean(String path) { + return DataObjectUtil.getBoolean(get(path)); + } + + public byte getByte(String path) { + return DataObjectUtil.getByte(get(path)); + } + + public char getChar(String path) { + return DataObjectUtil.getChar(get(path)); + } + + public double getDouble(String path) { + return DataObjectUtil.getDouble(get(path)); + } + + public float getFloat(String path) { + return DataObjectUtil.getFloat(get(path)); + } + + public int getInt(String path) { + return DataObjectUtil.getInt(get(path)); + } + + public long getLong(String path) { + return DataObjectUtil.getLong(get(path)); + } + + public short getShort(String path) { + return DataObjectUtil.getShort(get(path)); + } + + public byte[] getBytes(String path) { + return DataObjectUtil.getBytes(get(path)); + } + + public BigDecimal getBigDecimal(String path) { + return DataObjectUtil.getBigDecimal(get(path)); + } + + public BigInteger getBigInteger(String path) { + return DataObjectUtil.getBigInteger(get(path)); + } + + public DataObject getDataObject(String path) { + return (DataObject)get(path); + } + + public Date getDate(String path) { + return DataObjectUtil.getDate(get(path)); + } + + public String getString(String path) { + return DataObjectUtil.getString(get(path)); + } + + public List getList(String path) { + return (List)get(path); + } + + public Sequence getSequence(String path) { + return (Sequence)get(path); + } + + public void setBoolean(String path, boolean value) { + set(path, new Boolean(value)); + } + + public void setByte(String path, byte value) { + set(path, new Byte(value)); + } + + public void setChar(String path, char value) { + set(path, new Character(value)); + } + + public void setDouble(String path, double value) { + set(path, new Double(value)); + } + + public void setFloat(String path, float value) { + set(path, new Float(value)); + } + + public void setInt(String path, int value) { + set(path, new Integer(value)); + } + + public void setLong(String path, long value) { + set(path, new Long(value)); + } + + public void setShort(String path, short value) { + set(path, new Short(value)); + } + + public void setBytes(String path, byte[] value) { + set(path, value); + } + + public void setBigDecimal(String path, BigDecimal value) { + set(path, value); + } + + public void setBigInteger(String path, BigInteger value) { + set(path, value); + } + + public void setDataObject(String path, DataObject value) { + set(path, value); + } + + public void setDate(String path, Date value) { + set(path, value); + } + + public void setString(String path, String value) { + set(path, value); + } + + public void setList(String path, List value) { + set(path, value); + } + + public boolean getBoolean(int propertyIndex) { + return DataObjectUtil.getBoolean(this, propertyIndex); + } + + public byte getByte(int propertyIndex) { + return DataObjectUtil.getByte(this, propertyIndex); + } + + public char getChar(int propertyIndex) { + return DataObjectUtil.getChar(this, propertyIndex); + } + + public double getDouble(int propertyIndex) { + return DataObjectUtil.getDouble(this, propertyIndex); + } + + public float getFloat(int propertyIndex) { + return DataObjectUtil.getFloat(this, propertyIndex); + } + + public int getInt(int propertyIndex) { + return DataObjectUtil.getInt(this, propertyIndex); + } + + public long getLong(int propertyIndex) { + return DataObjectUtil.getLong(this, propertyIndex); + } + + public short getShort(int propertyIndex) { + return DataObjectUtil.getShort(this, propertyIndex); + } + + public byte[] getBytes(int propertyIndex) { + return DataObjectUtil.getBytes(this, propertyIndex); + } + + public BigDecimal getBigDecimal(int propertyIndex) { + return DataObjectUtil.getBigDecimal(this, propertyIndex); + } + + public BigInteger getBigInteger(int propertyIndex) { + return DataObjectUtil.getBigInteger(this, propertyIndex); + } + + public DataObject getDataObject(int propertyIndex) { + return DataObjectUtil.getDataObject(this, propertyIndex); + } + + public Date getDate(int propertyIndex) { + return DataObjectUtil.getDate(this, propertyIndex); + } + + public String getString(int propertyIndex) { + return DataObjectUtil.getString(this, propertyIndex); + } + + public List getList(int propertyIndex) { + return DataObjectUtil.getList(this, propertyIndex); + } + + public Sequence getSequence(int propertyIndex) { + return DataObjectUtil.getSequence(this, propertyIndex); + } + + public void setBoolean(int propertyIndex, boolean value) { + set(propertyIndex, new Boolean(value)); + } + + public void setByte(int propertyIndex, byte value) { + set(propertyIndex, new Byte(value)); + } + + public void setChar(int propertyIndex, char value) { + set(propertyIndex, new Character(value)); + } + + public void setDouble(int propertyIndex, double value) { + set(propertyIndex, new Double(value)); + } + + public void setFloat(int propertyIndex, float value) { + set(propertyIndex, new Float(value)); + } + + public void setInt(int propertyIndex, int value) { + set(propertyIndex, new Integer(value)); + } + + public void setLong(int propertyIndex, long value) { + set(propertyIndex, new Long(value)); + } + + public void setShort(int propertyIndex, short value) { + set(propertyIndex, new Short(value)); + } + + public void setBytes(int propertyIndex, byte[] value) { + set(propertyIndex, value); + } + + public void setBigDecimal(int propertyIndex, BigDecimal value) { + set(propertyIndex, value); + } + + public void setBigInteger(int propertyIndex, BigInteger value) { + set(propertyIndex, value); + } + + public void setDataObject(int propertyIndex, DataObject value) { + set(propertyIndex, value); + } + + public void setDate(int propertyIndex, Date value) { + set(propertyIndex, value); + } + + public void setString(int propertyIndex, String value) { + set(propertyIndex, value); + } + + public void setList(int propertyIndex, List value) { + set(propertyIndex, value); + } + + public boolean getBoolean(Property property) { + return DataObjectUtil.getBoolean(this, property); + } + + public byte getByte(Property property) { + return DataObjectUtil.getByte(this, property); + } + + public char getChar(Property property) { + return DataObjectUtil.getChar(this, property); + } + + public double getDouble(Property property) { + return DataObjectUtil.getDouble(this, property); + } + + public float getFloat(Property property) { + return DataObjectUtil.getFloat(this, property); + } + + public int getInt(Property property) { + return DataObjectUtil.getInt(this, property); + } + + public long getLong(Property property) { + return DataObjectUtil.getLong(this, property); + } + + public short getShort(Property property) { + return DataObjectUtil.getShort(this, property); + } + + public byte[] getBytes(Property property) { + return DataObjectUtil.getBytes(this, property); + } + + public BigDecimal getBigDecimal(Property property) { + return DataObjectUtil.getBigDecimal(this, property); + } + + public BigInteger getBigInteger(Property property) { + return DataObjectUtil.getBigInteger(this, property); + } + + public DataObject getDataObject(Property property) { + return DataObjectUtil.getDataObject(this, property); + } + + public Date getDate(Property property) { + return DataObjectUtil.getDate(this, property); + } + + public String getString(Property property) { + return DataObjectUtil.getString(this, property); + } + + public List getList(Property property) { + return DataObjectUtil.getList(this, property); + } + + public Sequence getSequence(Property property) { + return DataObjectUtil.getSequence(this, property); + } + + public void setBoolean(Property property, boolean value) { + set(property, new Boolean(value)); + } + + public void setByte(Property property, byte value) { + set(property, new Byte(value)); + } + + public void setChar(Property property, char value) { + set(property, new Character(value)); + } + + public void setDouble(Property property, double value) { + set(property, new Double(value)); + } + + public void setFloat(Property property, float value) { + set(property, new Float(value)); + } + + public void setInt(Property property, int value) { + set(property, new Integer(value)); + } + + public void setLong(Property property, long value) { + set(property, new Long(value)); + } + + public void setShort(Property property, short value) { + set(property, new Short(value)); + } + + public void setBytes(Property property, byte[] value) { + set(property, value); + } + + public void setBigDecimal(Property property, BigDecimal value) { + set(property, value); + } + + public void setBigInteger(Property property, BigInteger value) { + set(property, value); + } + + public void setDataObject(Property property, DataObject value) { + set(property, value); + } + + public void setDate(Property property, Date value) { + set(property, value); + } + + public void setString(Property property, String value) { + set(property, value); + } + + public void setList(Property property, List value) { + set(property, value); + } + + public DataObject createDataObject(String propertyName) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(String propertyName, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property, Type type) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void delete() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataGraph getDataGraph() { + return DataObjectUtil.getDataGraph(this); + } + + public Sequence getSequence() { + EAttribute mixedFeature = BasicExtendedMetaData.INSTANCE.getMixedFeature(eClass()); + return mixedFeature != null ? (Sequence)eGet(mixedFeature, true, false) : null; + } + + public List getInstanceProperties() { + return DataObjectUtil.getInstanceProperties(this); + } + + public DataObject getRootObject() { + return DataObjectUtil.getRootObject(this); + } + + public ChangeSummary getChangeSummary() { + // TODO: implement this method + throw new UnsupportedOperationException(); + } + + public void detach() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + //DataObjectUtil.detach(this); + } + + public Property getProperty(String propertyName) { + return DataObjectUtil.getProperty(this, propertyName); + } + */ + +} //ReferenceImpl diff --git a/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOFactoryImpl.java b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOFactoryImpl.java new file mode 100644 index 0000000000..bb0f5ccd2a --- /dev/null +++ b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOFactoryImpl.java @@ -0,0 +1,337 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.apache.tuscany.sdo.AnyTypeDataObject; +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.SimpleAnyTypeDataObject; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.impl.EFactoryImpl; +import org.eclipse.emf.ecore.impl.EcoreFactoryImpl; +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; + +/** + * <!-- begin-user-doc --> + * An implementation of the model <b>Factory</b>. + * <!-- end-user-doc --> + * @generated + */ +public class SDOFactoryImpl extends EFactoryImpl implements SDOFactory +{ + /** + * Creates the default factory implementation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public static SDOFactory init() + { + try + { + SDOFactory theSDOFactory = (SDOFactory)EPackage.Registry.INSTANCE.getEFactory(SDOPackage.eNS_URI); + if (theSDOFactory != null) + { + return theSDOFactory; + } + } + catch (Exception exception) + { + EcorePlugin.INSTANCE.log(exception); + } + return new SDOFactoryImpl(); + } + + public static class SDOEcoreFactory extends EcoreFactoryImpl + { + public EClass createEClass() { return new ClassImpl(); } + public EDataType createEDataType() { return new DataTypeImpl(); } + //public EEnum createEEnum() { return new EnumImpl(); } + public EAttribute createEAttribute() { return new AttributeImpl(); } + public EReference createEReference() { return new ReferenceImpl(); } + +// public EFactory createEFactory() +// { +// EFactoryImpl eFactory = new EFactoryImpl() { OVERRIDE basicCreate(); } // TODO think about doing this +// return eFactory; +// } + } + + /** + * Creates an instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public SDOFactoryImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EObject create(EClass eClass) + { + switch (eClass.getClassifierID()) + { + case SDOPackage.CHANGE_SUMMARY: return (EObject)createChangeSummary(); + case SDOPackage.CHANGE_SUMMARY_SETTING: return (EObject)createChangeSummarySetting(); + case SDOPackage.DATA_GRAPH: return (EObject)createDataGraph(); + case SDOPackage.ANY_TYPE_DATA_OBJECT: return createAnyTypeDataObject(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT: return createSimpleAnyTypeDataObject(); + case SDOPackage.CLASS: return (EObject)createClass(); + case SDOPackage.DATA_TYPE: return (EObject)createDataType(); + case SDOPackage.ATTRIBUTE: return (EObject)createAttribute(); + case SDOPackage.REFERENCE: return (EObject)createReference(); + case SDOPackage.ENUM: return (EObject)createEnum(); + case SDOPackage.DYNAMIC_DATA_OBJECT: return (EObject)createDynamicDataObject(); + case SDOPackage.STORE_DATA_OBJECT: return (EObject)createStoreDataObject(); + case SDOPackage.DYNAMIC_STORE_DATA_OBJECT: return (EObject)createDynamicStoreDataObject(); + case SDOPackage.EXTENSIBLE_DATA_OBJECT: return (EObject)createExtensibleDataObject(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object createFromString(EDataType eDataType, String initialValue) + { + switch (eDataType.getClassifierID()) + { + default: + throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String convertToString(EDataType eDataType, Object instanceValue) + { + switch (eDataType.getClassifierID()) + { + default: + throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ChangeSummary createChangeSummary() + { + ChangeSummaryImpl changeSummary = new ChangeSummaryImpl(); + return changeSummary; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ChangeSummary.Setting createChangeSummarySetting() + { + ChangeSummarySettingImpl changeSummarySetting = new ChangeSummarySettingImpl(); + return changeSummarySetting; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public DataGraph createDataGraph() + { + DataGraphImpl dataGraph = new DataGraphImpl(); + return dataGraph; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public AnyTypeDataObject createAnyTypeDataObject() + { + AnyTypeDataObjectImpl anyTypeDataObject = new AnyTypeDataObjectImpl(); + return anyTypeDataObject; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public SimpleAnyTypeDataObject createSimpleAnyTypeDataObject() + { + SimpleAnyTypeDataObjectImpl simpleAnyTypeDataObject = new SimpleAnyTypeDataObjectImpl(); + return simpleAnyTypeDataObject; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Type createClass() + { + ClassImpl class_ = new ClassImpl(); + return class_; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Type createDataType() + { + DataTypeImpl dataType = new DataTypeImpl(); + return dataType; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Property createAttribute() + { + AttributeImpl attribute = new AttributeImpl(); + return attribute; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Property createReference() + { + ReferenceImpl reference = new ReferenceImpl(); + return reference; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Type createEnum() + { + EnumImpl enum_ = new EnumImpl(); + return enum_; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public DataObject createDynamicDataObject() + { + DynamicDataObjectImpl dynamicDataObject = new DynamicDataObjectImpl(); + return dynamicDataObject; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public DataObject createStoreDataObject() + { + StoreDataObjectImpl storeDataObject = new StoreDataObjectImpl(); + return storeDataObject; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public DataObject createDynamicStoreDataObject() + { + DynamicStoreDataObjectImpl dynamicStoreDataObject = new DynamicStoreDataObjectImpl(); + return dynamicStoreDataObject; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public DataObject createExtensibleDataObject() + { + ExtensibleDataObjectImpl extensibleDataObject = new ExtensibleDataObjectImpl(); + return extensibleDataObject; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public SDOPackage getSDOPackage() + { + return (SDOPackage)getEPackage(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @deprecated + * @generated + */ + public static SDOPackage getPackage() + { + return SDOPackage.eINSTANCE; + } + + public ChangeSummary.Setting createChangeSummarySetting(EStructuralFeature eStructuralFeature, Object value, boolean isSet) + { + ChangeSummarySettingImpl eChangeSummarySetting = new ChangeSummarySettingImpl(eStructuralFeature, value, isSet); + return eChangeSummarySetting; + } + +} //SDOFactoryImpl diff --git a/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOPackageImpl.java b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOPackageImpl.java new file mode 100644 index 0000000000..25bdab16fe --- /dev/null +++ b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOPackageImpl.java @@ -0,0 +1,2207 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.util.Collections; +import java.util.List; + +import org.apache.tuscany.sdo.AnyTypeDataObject; +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.SimpleAnyTypeDataObject; +import org.apache.tuscany.sdo.impl.SDOFactoryImpl.SDOEcoreFactory; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EOperation; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.change.ChangePackage; +import org.eclipse.emf.ecore.change.impl.ChangePackageImpl; +import org.eclipse.emf.ecore.impl.EClassImpl; +import org.eclipse.emf.ecore.impl.EPackageImpl; +import org.eclipse.emf.ecore.impl.EcorePackageImpl; +import org.eclipse.emf.ecore.xml.type.XMLTypePackage; +import org.eclipse.emf.ecore.xml.type.impl.XMLTypePackageImpl; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Sequence; +import commonj.sdo.Type; + +/** + * <!-- begin-user-doc --> + * An implementation of the model <b>Package</b>. + * <!-- end-user-doc --> + * @generated + */ +public class SDOPackageImpl extends EPackageImpl implements SDOPackage +{ + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass changeSummaryEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass changeSummarySettingEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass dataGraphEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass dataObjectEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass propertyEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass sequenceEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass typeEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass anyTypeDataObjectEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass simpleAnyTypeDataObjectEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass classEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass dataTypeEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass attributeEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass referenceEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass enumEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass dynamicDataObjectEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass storeDataObjectEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass dynamicStoreDataObjectEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass extensibleDataObjectEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType eJavaListEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType eObjectStreamExceptionEDataType = null; + + /** + * Creates an instance of the model <b>Package</b>, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + * <p>Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see org.apache.tuscany.sdo.SDOPackage#eNS_URI + * @see #init() + * @generated NOT + */ + private SDOPackageImpl() + { + super(eNS_URI, SDOFactory.eINSTANCE); + ecoreFactory = new SDOEcoreFactory(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the <b>Package</b> for this + * model, and for any others upon which it depends. Simple + * dependencies are satisfied by calling this method on all + * dependent packages before doing anything else. This method drives + * initialization for interdependent packages directly, in parallel + * with this package, itself. + * <p>Of this package and its interdependencies, all packages which + * have not yet been registered by their URI values are first created + * and registered. The packages are then initialized in two steps: + * meta-model objects for all of the packages are created before any + * are initialized, since one package's meta-model objects may refer to + * those of another. + * <p>Invocation of this method will not affect any packages that have + * already been initialized. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static SDOPackage init() + { + if (isInited) return (SDOPackage)EPackage.Registry.INSTANCE.getEPackage(SDOPackage.eNS_URI); + + // Obtain or create and register package + SDOPackageImpl theSDOPackage = (SDOPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof SDOPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new SDOPackageImpl()); + + isInited = true; + + // Initialize simple dependencies + EcorePackageImpl.init(); + XMLTypePackageImpl.init(); + ChangePackageImpl.init(); + + // Create package meta-data objects + theSDOPackage.createPackageContents(); + + // Initialize created meta-data + theSDOPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theSDOPackage.freeze(); + + return theSDOPackage; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getChangeSummary() + { + return changeSummaryEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EReference getChangeSummary_EDataGraph() + { + return (EReference)changeSummaryEClass.getEStructuralFeatures().get(0); + } + +// /** +// * <!-- begin-user-doc --> +// * <!-- end-user-doc --> +// * <hand coded but could be generated> +// */ +// public EReference getChangeSummary_EDataObject() +// { +// return (EReference)changeSummaryEClass.getEStructuralFeatures().get(1); +// } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getChangeSummarySetting() + { + return changeSummarySettingEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getDataGraph() + { + return dataGraphEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EAttribute getDataGraph_ResourceSet() + { + return (EAttribute)dataGraphEClass.getEStructuralFeatures().get(0); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EAttribute getDataGraph_RootResource() + { + return (EAttribute)dataGraphEClass.getEStructuralFeatures().get(1); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EReference getDataGraph_EChangeSummary() + { + return (EReference)dataGraphEClass.getEStructuralFeatures().get(2); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EReference getDataGraph_ERootObject() + { + return (EReference)dataGraphEClass.getEStructuralFeatures().get(3); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getDataObject() + { + return dataObjectEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getProperty() + { + return propertyEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getSequence() + { + return sequenceEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getType() + { + return typeEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getAnyTypeDataObject() + { + return anyTypeDataObjectEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getSimpleAnyTypeDataObject() + { + return simpleAnyTypeDataObjectEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getClass_() + { + return classEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getDataType() + { + return dataTypeEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getAttribute() + { + return attributeEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getReference() + { + return referenceEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getEnum() + { + return enumEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getDynamicDataObject() + { + return dynamicDataObjectEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getStoreDataObject() + { + return storeDataObjectEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getDynamicStoreDataObject() + { + return dynamicStoreDataObjectEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getExtensibleDataObject() + { + return extensibleDataObjectEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EDataType getEJavaList() + { + return eJavaListEDataType; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EDataType getEObjectStreamException() + { + return eObjectStreamExceptionEDataType; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public SDOFactory getSDOFactory() + { + return (SDOFactory)getEFactoryInstance(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void createPackageContents() + { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + changeSummaryEClass = createEClass(CHANGE_SUMMARY); + createEReference(changeSummaryEClass, CHANGE_SUMMARY__EDATA_GRAPH); + + changeSummarySettingEClass = createEClass(CHANGE_SUMMARY_SETTING); + + dataGraphEClass = createEClass(DATA_GRAPH); + createEAttribute(dataGraphEClass, DATA_GRAPH__RESOURCE_SET); + createEAttribute(dataGraphEClass, DATA_GRAPH__ROOT_RESOURCE); + createEReference(dataGraphEClass, DATA_GRAPH__ECHANGE_SUMMARY); + createEReference(dataGraphEClass, DATA_GRAPH__EROOT_OBJECT); + + dataObjectEClass = createEClass(DATA_OBJECT); + + propertyEClass = createEClass(PROPERTY); + + sequenceEClass = createEClass(SEQUENCE); + + typeEClass = createEClass(TYPE); + + anyTypeDataObjectEClass = createEClass(ANY_TYPE_DATA_OBJECT); + + simpleAnyTypeDataObjectEClass = createEClass(SIMPLE_ANY_TYPE_DATA_OBJECT); + + classEClass = createEClass(CLASS); + + dataTypeEClass = createEClass(DATA_TYPE); + + attributeEClass = createEClass(ATTRIBUTE); + + referenceEClass = createEClass(REFERENCE); + + enumEClass = createEClass(ENUM); + + dynamicDataObjectEClass = createEClass(DYNAMIC_DATA_OBJECT); + + storeDataObjectEClass = createEClass(STORE_DATA_OBJECT); + + dynamicStoreDataObjectEClass = createEClass(DYNAMIC_STORE_DATA_OBJECT); + + extensibleDataObjectEClass = createEClass(EXTENSIBLE_DATA_OBJECT); + + // Create data types + eJavaListEDataType = createEDataType(EJAVA_LIST); + eObjectStreamExceptionEDataType = createEDataType(EOBJECT_STREAM_EXCEPTION); + } + + protected EClass createEClass(int id) + { + EClassImpl c; + switch(id) { + case ANY_TYPE_DATA_OBJECT: + c = new ClassImpl() { + List baseTypes = null; + public List getBaseTypes() { + if (baseTypes == null) + baseTypes = Collections.singletonList(getDataObject()); + return baseTypes; + } + public List getTypeFeatures() { + return getEAllStructuralFeatures(); + } + }; + break; + case SIMPLE_ANY_TYPE_DATA_OBJECT: + c = new ClassImpl() { + List baseTypes = null; + public List getBaseTypes() { + if (baseTypes == null) + baseTypes = Collections.singletonList(getAnyTypeDataObject()); + return baseTypes; + } + }; + break; + default: + c = (EClassImpl)ecoreFactory.createEClass(); + } + c.setClassifierID(id); + getEClassifiers().add(c); + return c; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void initializePackageContents() + { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Obtain other dependent packages + ChangePackageImpl theChangePackage = (ChangePackageImpl)EPackage.Registry.INSTANCE.getEPackage(ChangePackage.eNS_URI); + EcorePackageImpl theEcorePackage = (EcorePackageImpl)EPackage.Registry.INSTANCE.getEPackage(EcorePackage.eNS_URI); + XMLTypePackageImpl theXMLTypePackage = (XMLTypePackageImpl)EPackage.Registry.INSTANCE.getEPackage(XMLTypePackage.eNS_URI); + + // Add supertypes to classes + changeSummaryEClass.getESuperTypes().add(theChangePackage.getChangeDescription()); + changeSummarySettingEClass.getESuperTypes().add(theChangePackage.getFeatureChange()); + dataGraphEClass.getESuperTypes().add(theEcorePackage.getEObject()); + anyTypeDataObjectEClass.getESuperTypes().add(this.getDataObject()); + anyTypeDataObjectEClass.getESuperTypes().add(theXMLTypePackage.getAnyType()); + simpleAnyTypeDataObjectEClass.getESuperTypes().add(this.getAnyTypeDataObject()); + simpleAnyTypeDataObjectEClass.getESuperTypes().add(theXMLTypePackage.getSimpleAnyType()); + classEClass.getESuperTypes().add(theEcorePackage.getEClass()); + classEClass.getESuperTypes().add(this.getType()); + dataTypeEClass.getESuperTypes().add(theEcorePackage.getEDataType()); + dataTypeEClass.getESuperTypes().add(this.getType()); + attributeEClass.getESuperTypes().add(theEcorePackage.getEAttribute()); + attributeEClass.getESuperTypes().add(this.getProperty()); + referenceEClass.getESuperTypes().add(theEcorePackage.getEReference()); + referenceEClass.getESuperTypes().add(this.getProperty()); + enumEClass.getESuperTypes().add(theEcorePackage.getEEnum()); + enumEClass.getESuperTypes().add(this.getType()); + dynamicDataObjectEClass.getESuperTypes().add(this.getDataObject()); + storeDataObjectEClass.getESuperTypes().add(this.getDataObject()); + dynamicStoreDataObjectEClass.getESuperTypes().add(this.getStoreDataObject()); + extensibleDataObjectEClass.getESuperTypes().add(this.getDataObject()); + + // Initialize classes and features; add operations and parameters + initEClass(changeSummaryEClass, ChangeSummary.class, "ChangeSummary", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + initEReference(getChangeSummary_EDataGraph(), this.getDataGraph(), this.getDataGraph_EChangeSummary(), "eDataGraph", null, 1, 1, ChangeSummary.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + addEOperation(changeSummaryEClass, null, "beginLogging"); + + addEOperation(changeSummaryEClass, null, "endLogging"); + + EOperation op = addEOperation(changeSummaryEClass, ecorePackage.getEBoolean(), "isCreated"); + addEParameter(op, this.getDataObject(), "dataObject"); + + op = addEOperation(changeSummaryEClass, ecorePackage.getEBoolean(), "isDeleted"); + addEParameter(op, this.getDataObject(), "dataObject"); + + op = addEOperation(changeSummaryEClass, this.getEJavaList(), "getOldValues"); + addEParameter(op, this.getDataObject(), "dataObject"); + + op = addEOperation(changeSummaryEClass, ecorePackage.getEBoolean(), "isModified"); + addEParameter(op, this.getDataObject(), "dataObject"); + + op = addEOperation(changeSummaryEClass, this.getChangeSummarySetting(), "getOldValue"); + addEParameter(op, this.getDataObject(), "dataObject"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(changeSummaryEClass, this.getDataObject(), "getOldContainer"); + addEParameter(op, this.getDataObject(), "dataObject"); + + op = addEOperation(changeSummaryEClass, this.getProperty(), "getOldContainmentProperty"); + addEParameter(op, this.getDataObject(), "dataObject"); + + op = addEOperation(changeSummaryEClass, this.getSequence(), "getOldSequence"); + addEParameter(op, this.getDataObject(), "dataObject"); + + addEOperation(changeSummaryEClass, null, "undoChanges"); + + addEOperation(changeSummaryEClass, ecorePackage.getEBoolean(), "isLogging"); + + addEOperation(changeSummaryEClass, this.getDataGraph(), "getDataGraph"); + + addEOperation(changeSummaryEClass, this.getEJavaList(), "getChangedObjects"); + + addEOperation(changeSummaryEClass, this.getDataObject(), "getRootObject"); + + initEClass(changeSummarySettingEClass, ChangeSummary.Setting.class, "ChangeSummarySetting", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + addEOperation(changeSummarySettingEClass, ecorePackage.getEBoolean(), "isSet"); + + addEOperation(changeSummarySettingEClass, theEcorePackage.getEJavaObject(), "getValue"); + + addEOperation(changeSummarySettingEClass, this.getProperty(), "getProperty"); + + initEClass(dataGraphEClass, DataGraph.class, "DataGraph", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getDataGraph_ResourceSet(), theEcorePackage.getEResourceSet(), "resourceSet", null, 0, 1, DataGraph.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getDataGraph_RootResource(), theEcorePackage.getEResource(), "rootResource", null, 0, 1, DataGraph.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + initEReference(getDataGraph_EChangeSummary(), this.getChangeSummary(), this.getChangeSummary_EDataGraph(), "eChangeSummary", null, 1, 1, DataGraph.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getDataGraph_ERootObject(), theEcorePackage.getEObject(), null, "eRootObject", null, 1, 1, DataGraph.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + op = addEOperation(dataGraphEClass, this.getDataObject(), "createRootObject"); + addEParameter(op, ecorePackage.getEString(), "namespaceURI"); + addEParameter(op, ecorePackage.getEString(), "typeName"); + + op = addEOperation(dataGraphEClass, this.getDataObject(), "createRootObject"); + addEParameter(op, this.getType(), "type"); + + op = addEOperation(dataGraphEClass, this.getType(), "getType"); + addEParameter(op, ecorePackage.getEString(), "namespaceURI"); + addEParameter(op, ecorePackage.getEString(), "typeName"); + + addEOperation(dataGraphEClass, this.getDataObject(), "getRootObject"); + + addEOperation(dataGraphEClass, this.getChangeSummary(), "getChangeSummary"); + + initEClass(dataObjectEClass, DataObject.class, "DataObject", IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEJavaObject(), "get"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, null, "set"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, theEcorePackage.getEJavaObject(), "value"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEBoolean(), "isSet"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, null, "unset"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEJavaObject(), "get"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, null, "set"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, theEcorePackage.getEJavaObject(), "value"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEBoolean(), "isSet"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, null, "unset"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEJavaObject(), "get"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, null, "set"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, theEcorePackage.getEJavaObject(), "value"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEBoolean(), "isSet"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, null, "unset"); + addEParameter(op, this.getProperty(), "property"); + + addEOperation(dataObjectEClass, this.getDataObject(), "getContainer"); + + addEOperation(dataObjectEClass, this.getProperty(), "getContainmentProperty"); + + addEOperation(dataObjectEClass, this.getDataGraph(), "getDataGraph"); + + addEOperation(dataObjectEClass, this.getType(), "getType"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEBigDecimal(), "getBigDecimal"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEBigInteger(), "getBigInteger"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEBoolean(), "getBoolean"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEByte(), "getByte"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEByteArray(), "getBytes"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEChar(), "getChar"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, this.getDataObject(), "getDataObject"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEDate(), "getDate"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEDouble(), "getDouble"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEFloat(), "getFloat"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEInt(), "getInt"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, this.getEJavaList(), "getList"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, ecorePackage.getELong(), "getLong"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, this.getSequence(), "getSequence"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEShort(), "getShort"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEString(), "getString"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, null, "setBigDecimal"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, theEcorePackage.getEBigDecimal(), "value"); + + op = addEOperation(dataObjectEClass, null, "setBigInteger"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, theEcorePackage.getEBigInteger(), "value"); + + op = addEOperation(dataObjectEClass, null, "setBoolean"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, ecorePackage.getEBoolean(), "value"); + + op = addEOperation(dataObjectEClass, null, "setByte"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, ecorePackage.getEByte(), "value"); + + op = addEOperation(dataObjectEClass, null, "setBytes"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, theEcorePackage.getEByteArray(), "value"); + + op = addEOperation(dataObjectEClass, null, "setChar"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, ecorePackage.getEChar(), "value"); + + op = addEOperation(dataObjectEClass, null, "setDataObject"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, this.getDataObject(), "value"); + + op = addEOperation(dataObjectEClass, null, "setDate"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, theEcorePackage.getEDate(), "value"); + + op = addEOperation(dataObjectEClass, null, "setDouble"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, ecorePackage.getEDouble(), "value"); + + op = addEOperation(dataObjectEClass, null, "setFloat"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, ecorePackage.getEFloat(), "value"); + + op = addEOperation(dataObjectEClass, null, "setInt"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, ecorePackage.getEInt(), "value"); + + op = addEOperation(dataObjectEClass, null, "setList"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, this.getEJavaList(), "value"); + + op = addEOperation(dataObjectEClass, null, "setLong"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, ecorePackage.getELong(), "value"); + + op = addEOperation(dataObjectEClass, null, "setShort"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, ecorePackage.getEShort(), "value"); + + op = addEOperation(dataObjectEClass, null, "setString"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, ecorePackage.getEString(), "value"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEBigDecimal(), "getBigDecimal"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEBigInteger(), "getBigInteger"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEBoolean(), "getBoolean"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEByte(), "getByte"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEByteArray(), "getBytes"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEChar(), "getChar"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, this.getDataObject(), "getDataObject"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEDate(), "getDate"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEDouble(), "getDouble"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEFloat(), "getFloat"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEInt(), "getInt"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, this.getEJavaList(), "getList"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, ecorePackage.getELong(), "getLong"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, this.getSequence(), "getSequence"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEShort(), "getShort"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEString(), "getString"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, null, "setBigDecimal"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, theEcorePackage.getEBigDecimal(), "value"); + + op = addEOperation(dataObjectEClass, null, "setBigInteger"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, theEcorePackage.getEBigInteger(), "value"); + + op = addEOperation(dataObjectEClass, null, "setBoolean"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, ecorePackage.getEBoolean(), "value"); + + op = addEOperation(dataObjectEClass, null, "setByte"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, ecorePackage.getEByte(), "value"); + + op = addEOperation(dataObjectEClass, null, "setBytes"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, theEcorePackage.getEByteArray(), "value"); + + op = addEOperation(dataObjectEClass, null, "setChar"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, ecorePackage.getEChar(), "value"); + + op = addEOperation(dataObjectEClass, null, "setDataObject"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, this.getDataObject(), "value"); + + op = addEOperation(dataObjectEClass, null, "setDate"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, theEcorePackage.getEDate(), "value"); + + op = addEOperation(dataObjectEClass, null, "setDouble"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, ecorePackage.getEDouble(), "value"); + + op = addEOperation(dataObjectEClass, null, "setFloat"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, ecorePackage.getEFloat(), "value"); + + op = addEOperation(dataObjectEClass, null, "setInt"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, ecorePackage.getEInt(), "value"); + + op = addEOperation(dataObjectEClass, null, "setList"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, this.getEJavaList(), "value"); + + op = addEOperation(dataObjectEClass, null, "setLong"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, ecorePackage.getELong(), "value"); + + op = addEOperation(dataObjectEClass, null, "setShort"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, ecorePackage.getEShort(), "value"); + + op = addEOperation(dataObjectEClass, null, "setString"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, ecorePackage.getEString(), "value"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEBigDecimal(), "getBigDecimal"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEBigInteger(), "getBigInteger"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEBoolean(), "getBoolean"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEByte(), "getByte"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEByteArray(), "getBytes"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEChar(), "getChar"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, this.getDataObject(), "getDataObject"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEDate(), "getDate"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEDouble(), "getDouble"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEFloat(), "getFloat"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEInt(), "getInt"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, this.getEJavaList(), "getList"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, ecorePackage.getELong(), "getLong"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, this.getSequence(), "getSequence"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEShort(), "getShort"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEString(), "getString"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, null, "setBigDecimal"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, theEcorePackage.getEBigDecimal(), "value"); + + op = addEOperation(dataObjectEClass, null, "setBigInteger"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, theEcorePackage.getEBigInteger(), "value"); + + op = addEOperation(dataObjectEClass, null, "setBoolean"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, ecorePackage.getEBoolean(), "value"); + + op = addEOperation(dataObjectEClass, null, "setByte"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, ecorePackage.getEByte(), "value"); + + op = addEOperation(dataObjectEClass, null, "setBytes"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, theEcorePackage.getEByteArray(), "value"); + + op = addEOperation(dataObjectEClass, null, "setChar"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, ecorePackage.getEChar(), "value"); + + op = addEOperation(dataObjectEClass, null, "setDataObject"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, this.getDataObject(), "value"); + + op = addEOperation(dataObjectEClass, null, "setDate"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, theEcorePackage.getEDate(), "value"); + + op = addEOperation(dataObjectEClass, null, "setDouble"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, ecorePackage.getEDouble(), "value"); + + op = addEOperation(dataObjectEClass, null, "setFloat"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, ecorePackage.getEFloat(), "value"); + + op = addEOperation(dataObjectEClass, null, "setInt"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, ecorePackage.getEInt(), "value"); + + op = addEOperation(dataObjectEClass, null, "setList"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, this.getEJavaList(), "value"); + + op = addEOperation(dataObjectEClass, null, "setLong"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, ecorePackage.getELong(), "value"); + + op = addEOperation(dataObjectEClass, null, "setShort"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, ecorePackage.getEShort(), "value"); + + op = addEOperation(dataObjectEClass, null, "setString"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, ecorePackage.getEString(), "value"); + + op = addEOperation(dataObjectEClass, this.getDataObject(), "createDataObject"); + addEParameter(op, ecorePackage.getEString(), "propertyName"); + + op = addEOperation(dataObjectEClass, this.getDataObject(), "createDataObject"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, this.getDataObject(), "createDataObject"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, this.getDataObject(), "createDataObject"); + addEParameter(op, ecorePackage.getEString(), "propertyName"); + addEParameter(op, ecorePackage.getEString(), "namespaceURI"); + addEParameter(op, ecorePackage.getEString(), "typeName"); + + op = addEOperation(dataObjectEClass, this.getDataObject(), "createDataObject"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, ecorePackage.getEString(), "namespaceURI"); + addEParameter(op, ecorePackage.getEString(), "typeName"); + + op = addEOperation(dataObjectEClass, this.getDataObject(), "createDataObject"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, this.getType(), "type"); + + addEOperation(dataObjectEClass, null, "delete"); + + addEOperation(dataObjectEClass, this.getSequence(), "getSequence"); + + addEOperation(dataObjectEClass, this.getEJavaList(), "getInstanceProperties"); + + op = addEOperation(dataObjectEClass, this.getProperty(), "getProperty"); + addEParameter(op, ecorePackage.getEString(), "propertyName"); + + addEOperation(dataObjectEClass, this.getDataObject(), "getRootObject"); + + addEOperation(dataObjectEClass, this.getChangeSummary(), "getChangeSummary"); + + addEOperation(dataObjectEClass, null, "detach"); + + initEClass(propertyEClass, Property.class, "Property", IS_ABSTRACT, IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + addEOperation(propertyEClass, ecorePackage.getEString(), "getName"); + + addEOperation(propertyEClass, this.getType(), "getType"); + + addEOperation(propertyEClass, ecorePackage.getEBoolean(), "isMany"); + + addEOperation(propertyEClass, ecorePackage.getEBoolean(), "isContainment"); + + addEOperation(propertyEClass, ecorePackage.getEBoolean(), "isReadOnly"); + + addEOperation(propertyEClass, this.getType(), "getContainingType"); + + addEOperation(propertyEClass, this.getEJavaList(), "getAliasNames"); + + addEOperation(propertyEClass, this.getProperty(), "getOpposite"); + + addEOperation(propertyEClass, theEcorePackage.getEJavaObject(), "getDefault"); + + initEClass(sequenceEClass, Sequence.class, "Sequence", IS_ABSTRACT, IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + addEOperation(sequenceEClass, ecorePackage.getEInt(), "size"); + + op = addEOperation(sequenceEClass, this.getProperty(), "getProperty"); + addEParameter(op, ecorePackage.getEInt(), "index"); + + op = addEOperation(sequenceEClass, theEcorePackage.getEJavaObject(), "getValue"); + addEParameter(op, ecorePackage.getEInt(), "index"); + + op = addEOperation(sequenceEClass, theEcorePackage.getEJavaObject(), "setValue"); + addEParameter(op, ecorePackage.getEInt(), "index"); + addEParameter(op, theEcorePackage.getEJavaObject(), "value"); + + op = addEOperation(sequenceEClass, ecorePackage.getEBoolean(), "add"); + addEParameter(op, ecorePackage.getEString(), "propertyName"); + addEParameter(op, theEcorePackage.getEJavaObject(), "value"); + + op = addEOperation(sequenceEClass, ecorePackage.getEBoolean(), "add"); + addEParameter(op, ecorePackage.getEInt(), "propertIndex"); + addEParameter(op, theEcorePackage.getEJavaObject(), "value"); + + op = addEOperation(sequenceEClass, ecorePackage.getEBoolean(), "add"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, theEcorePackage.getEJavaObject(), "value"); + + op = addEOperation(sequenceEClass, null, "add"); + addEParameter(op, ecorePackage.getEInt(), "index"); + addEParameter(op, ecorePackage.getEString(), "propertyName"); + addEParameter(op, theEcorePackage.getEJavaObject(), "value"); + + op = addEOperation(sequenceEClass, null, "add"); + addEParameter(op, ecorePackage.getEInt(), "index"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, theEcorePackage.getEJavaObject(), "value"); + + op = addEOperation(sequenceEClass, null, "add"); + addEParameter(op, ecorePackage.getEInt(), "index"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, theEcorePackage.getEJavaObject(), "value"); + + op = addEOperation(sequenceEClass, null, "add"); + addEParameter(op, ecorePackage.getEString(), "text"); + + op = addEOperation(sequenceEClass, null, "add"); + addEParameter(op, ecorePackage.getEInt(), "index"); + addEParameter(op, ecorePackage.getEString(), "text"); + + initEClass(typeEClass, Type.class, "Type", IS_ABSTRACT, IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + addEOperation(typeEClass, ecorePackage.getEString(), "getName"); + + addEOperation(typeEClass, ecorePackage.getEString(), "getURI"); + + addEOperation(typeEClass, theEcorePackage.getEJavaClass(), "getInstanceClass"); + + op = addEOperation(typeEClass, ecorePackage.getEBoolean(), "isInstance"); + addEParameter(op, theEcorePackage.getEJavaObject(), "object"); + + addEOperation(typeEClass, ecorePackage.getEBoolean(), "isDataType"); + + addEOperation(typeEClass, ecorePackage.getEBoolean(), "isSequenced"); + + addEOperation(typeEClass, ecorePackage.getEBoolean(), "isOpen"); + + addEOperation(typeEClass, ecorePackage.getEBoolean(), "isAbstract"); + + addEOperation(typeEClass, this.getEJavaList(), "getBaseTypes"); + + addEOperation(typeEClass, this.getEJavaList(), "getAliasNames"); + + addEOperation(typeEClass, this.getEJavaList(), "getProperties"); + + addEOperation(typeEClass, this.getEJavaList(), "getDeclaredProperties"); + + op = addEOperation(typeEClass, this.getProperty(), "getProperty"); + addEParameter(op, ecorePackage.getEString(), "propertyName"); + + initEClass(anyTypeDataObjectEClass, AnyTypeDataObject.class, "AnyTypeDataObject", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + + initEClass(simpleAnyTypeDataObjectEClass, SimpleAnyTypeDataObject.class, "SimpleAnyTypeDataObject", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + + initEClass(classEClass, Type.class, "Class", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + initEClass(dataTypeEClass, Type.class, "DataType", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + initEClass(attributeEClass, Property.class, "Attribute", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + initEClass(referenceEClass, Property.class, "Reference", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + initEClass(enumEClass, Type.class, "Enum", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + initEClass(dynamicDataObjectEClass, DataObject.class, "DynamicDataObject", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + initEClass(storeDataObjectEClass, DataObject.class, "StoreDataObject", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + initEClass(dynamicStoreDataObjectEClass, DataObject.class, "DynamicStoreDataObject", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + initEClass(extensibleDataObjectEClass, DataObject.class, "ExtensibleDataObject", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + // Initialize data types + initEDataType(eJavaListEDataType, List.class, "EJavaList", !IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(eObjectStreamExceptionEDataType, ObjectStreamException.class, "EObjectStreamException", !IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + + // Create resource + createResource(eNS_URI); + + // Create annotations + // http://www.eclipse.org/emf/2002/GenModel + createGenModelAnnotations(); + // http:///org/eclipse/emf/ecore/util/ExtendedMetaData + createExtendedMetaDataAnnotations(); + } + + /** + * Initializes the annotations for <b>http://www.eclipse.org/emf/2002/GenModel</b>. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected void createGenModelAnnotations() + { + String source = "http://www.eclipse.org/emf/2002/GenModel"; + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(0), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.get(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(1), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.set(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(2), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.isSet(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(3), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.unset(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(4), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.get(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(5), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.set(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(6), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.isSet(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(7), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.unset(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(8), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.get(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(9), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.set(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(10), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.isSet(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(11), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.unset(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(12), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getContainer(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(13), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getContainmentProperty(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(14), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDataGraph(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(15), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getType(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(16), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBigDecimal(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(17), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBigInteger(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(18), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBoolean(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(19), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getByte(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(20), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBytes(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(21), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getChar(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(22), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDataObject(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(23), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDate(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(24), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDouble(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(25), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getFloat(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(26), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getInt(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(27), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getList(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(28), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getLong(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(29), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getSequence(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(30), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getShort(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(31), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getString(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(32), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBigDecimal(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(33), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBigInteger(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(34), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBoolean(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(35), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setByte(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(36), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBytes(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(37), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setChar(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(38), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDataObject(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(39), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDate(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(40), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDouble(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(41), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setFloat(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(42), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setInt(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(43), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setList(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(44), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setLong(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(45), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setShort(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(46), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setString(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(47), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBigDecimal(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(48), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBigInteger(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(49), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBoolean(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(50), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getByte(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(51), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBytes(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(52), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getChar(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(53), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDataObject(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(54), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDate(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(55), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDouble(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(56), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getFloat(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(57), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getInt(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(58), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getList(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(59), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getLong(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(60), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getSequence(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(61), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getShort(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(62), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getString(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(63), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBigDecimal(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(64), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBigInteger(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(65), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBoolean(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(66), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setByte(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(67), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBytes(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(68), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setChar(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(69), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDataObject(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(70), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDate(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(71), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDouble(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(72), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setFloat(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(73), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setInt(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(74), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setList(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(75), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setLong(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(76), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setShort(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(77), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setString(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(78), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBigDecimal(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(79), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBigInteger(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(80), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBoolean(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(81), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getByte(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(82), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBytes(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(83), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getChar(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(84), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDataObject(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(85), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDate(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(86), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDouble(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(87), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getFloat(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(88), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getInt(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(89), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getList(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(90), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getLong(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(91), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getSequence(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(92), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getShort(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(93), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getString(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(94), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBigDecimal(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(95), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBigInteger(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(96), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBoolean(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(97), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setByte(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(98), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBytes(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(99), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setChar(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(100), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDataObject(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(101), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDate(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(102), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDouble(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(103), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setFloat(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(104), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setInt(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(105), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setList(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(106), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setLong(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(107), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setShort(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(108), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setString(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(109), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, propertyName);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(110), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(111), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(112), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, propertyName, namespaceURI, typeName);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(113), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, propertyIndex, namespaceURI, typeName);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(114), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, property, type);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(115), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.delete(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(116), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getSequence(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(117), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getInstanceProperties(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(118), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getProperty(this, propertyName);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(119), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getRootObject(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(120), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getChangeSummary(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(121), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.detach(this);" + }); + } + + /** + * Initializes the annotations for <b>http:///org/eclipse/emf/ecore/util/ExtendedMetaData</b>. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected void createExtendedMetaDataAnnotations() + { + String source = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData"; + addAnnotation + (anyTypeDataObjectEClass, + source, + new String[] + { + "kind", "mixed" + }); + addAnnotation + (simpleAnyTypeDataObjectEClass, + source, + new String[] + { + "kind", "simple" + }); + } + +} //SDOPackageImpl diff --git a/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/SimpleAnyTypeDataObjectImpl.java b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/SimpleAnyTypeDataObjectImpl.java new file mode 100644 index 0000000000..e257e30d27 --- /dev/null +++ b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/SimpleAnyTypeDataObjectImpl.java @@ -0,0 +1,333 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.util.Iterator; + +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.SimpleAnyTypeDataObject; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.ecore.xml.type.SimpleAnyType; +import org.eclipse.emf.ecore.xml.type.XMLTypePackage; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>EData Object Simple Any Type</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.sdo.impl.SimpleAnyTypeDataObjectImpl#getRawValue <em>Raw Value</em>}</li> + * <li>{@link org.apache.tuscany.sdo.impl.SimpleAnyTypeDataObjectImpl#getValue <em>Value</em>}</li> + * <li>{@link org.apache.tuscany.sdo.impl.SimpleAnyTypeDataObjectImpl#getInstanceType <em>Instance Type</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class SimpleAnyTypeDataObjectImpl extends AnyTypeDataObjectImpl implements SimpleAnyTypeDataObject +{ + /** + * The default value of the '{@link #getRawValue() <em>Raw Value</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getRawValue() + * @generated + * @ordered + */ + protected static final String RAW_VALUE_EDEFAULT = null; + + /** + * The default value of the '{@link #getValue() <em>Value</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getValue() + * @generated + * @ordered + */ + protected static final Object VALUE_EDEFAULT = null; + + /** + * The cached value of the '{@link #getInstanceType() <em>Instance Type</em>}' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getInstanceType() + * @generated + * @ordered + */ + protected EDataType instanceType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected SimpleAnyTypeDataObjectImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getSimpleAnyTypeDataObject(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String getRawValue() + { + StringBuffer value = new StringBuffer(); + for (Iterator i = getMixed().iterator(); i.hasNext(); ) + { + FeatureMap.Entry entry = (FeatureMap.Entry)i.next(); + if (entry.getEStructuralFeature() == XMLTypePackage.eINSTANCE.getXMLTypeDocumentRoot_Text()) + { + value.append(entry.getValue()); + } + } + return value.toString(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setRawValue(String newRawValue) + { + getMixed().clear(); + if (newRawValue != null) + { + getMixed().add(XMLTypePackage.eINSTANCE.getXMLTypeDocumentRoot_Text(), newRawValue); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Object getValue() + { + return EcoreUtil.createFromString(instanceType, getRawValue()); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setValue(Object newValue) + { + setRawValue(EcoreUtil.convertToString(instanceType, newValue)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EDataType getInstanceType() + { + return instanceType; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setInstanceType(EDataType newInstanceType) + { + EDataType oldInstanceType = instanceType; + instanceType = newInstanceType; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE, oldInstanceType, instanceType)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__MIXED: + if (coreType) return getMixed(); + return ((FeatureMap.Internal)getMixed()).getWrapper(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY: + if (coreType) return getAny(); + return ((FeatureMap.Internal)getAny()).getWrapper(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + if (coreType) return getAnyAttribute(); + return ((FeatureMap.Internal)getAnyAttribute()).getWrapper(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__RAW_VALUE: + return getRawValue(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__VALUE: + return getValue(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE: + return getInstanceType(); + } + return eDynamicGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__MIXED: + ((FeatureMap.Internal)getMixed()).set(newValue); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY: + ((FeatureMap.Internal)getAny()).set(newValue); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + ((FeatureMap.Internal)getAnyAttribute()).set(newValue); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__RAW_VALUE: + setRawValue((String)newValue); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__VALUE: + setValue((Object)newValue); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE: + setInstanceType((EDataType)newValue); + return; + } + eDynamicSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__MIXED: + getMixed().clear(); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY: + getAny().clear(); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + getAnyAttribute().clear(); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__RAW_VALUE: + setRawValue(RAW_VALUE_EDEFAULT); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__VALUE: + setValue(VALUE_EDEFAULT); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE: + setInstanceType((EDataType)null); + return; + } + eDynamicUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__MIXED: + return mixed != null && !mixed.isEmpty(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY: + return !getAny().isEmpty(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + return anyAttribute != null && !anyAttribute.isEmpty(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__RAW_VALUE: + return RAW_VALUE_EDEFAULT == null ? getRawValue() != null : !RAW_VALUE_EDEFAULT.equals(getRawValue()); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__VALUE: + return VALUE_EDEFAULT == null ? getValue() != null : !VALUE_EDEFAULT.equals(getValue()); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE: + return instanceType != null; + } + return eDynamicIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public int eBaseStructuralFeatureID(int derivedFeatureID, Class baseClass) + { + if (baseClass == SimpleAnyType.class) + { + switch (derivedFeatureID) + { + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__RAW_VALUE: return XMLTypePackage.SIMPLE_ANY_TYPE__RAW_VALUE; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__VALUE: return XMLTypePackage.SIMPLE_ANY_TYPE__VALUE; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE: return XMLTypePackage.SIMPLE_ANY_TYPE__INSTANCE_TYPE; + default: return -1; + } + } + return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) + { + if (baseClass == SimpleAnyType.class) + { + switch (baseFeatureID) + { + case XMLTypePackage.SIMPLE_ANY_TYPE__RAW_VALUE: return SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__RAW_VALUE; + case XMLTypePackage.SIMPLE_ANY_TYPE__VALUE: return SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__VALUE; + case XMLTypePackage.SIMPLE_ANY_TYPE__INSTANCE_TYPE: return SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE; + default: return -1; + } + } + return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); + } + +} //EDataObjectSimpleAnyTypeImpl diff --git a/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/StoreDataObjectImpl.java b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/StoreDataObjectImpl.java new file mode 100644 index 0000000000..0cf7f3586c --- /dev/null +++ b/sdo-java/branches/sdo-1.1-incubating/impl/src/main/java/org/apache/tuscany/sdo/impl/StoreDataObjectImpl.java @@ -0,0 +1,314 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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 org.apache.tuscany.sdo.SDOPackage; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.EStoreEObjectImpl.EStoreEList; +import org.eclipse.emf.ecore.impl.EStoreEObjectImpl.EStoreFeatureMap; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.ecore.util.FeatureMapUtil; + +import commonj.sdo.DataObject; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Store Data Object</b></em>'. + * @extends EStructuralFeature.Internal.DynamicValueHolder + * <!-- end-user-doc --> + * <p> + * </p> + * + * @generated + */ +public class StoreDataObjectImpl extends DataObjectImpl implements DataObject, EStructuralFeature.Internal.DynamicValueHolder +{ + //TODO consider factoring the eSettings code into a new base class that this and DynamicDataObjectImpl could extend + + protected static final Object [] ENO_SETTINGS = new Object [0]; + protected static final InternalEObject EUNINITIALIZED_CONTAINER = new DynamicDataObjectImpl(); + + protected Object [] eSettings; + protected InternalEObject.EStore eStore; + + /** + * Creates a store-based DataObject. + */ + public StoreDataObjectImpl() + { + super(); + eContainer = EUNINITIALIZED_CONTAINER; + } + + /** + * Creates a store-based DataObject. + */ + public StoreDataObjectImpl(InternalEObject.EStore eStore) + { + super(); + eSetStore(eStore); + eContainer = EUNINITIALIZED_CONTAINER; + } + + /** + * Creates a store-based DataObject. + */ + public StoreDataObjectImpl(EClass eClass) + { + super(); + eSetClass(eClass); + eContainer = EUNINITIALIZED_CONTAINER; + } + + /** + * Creates a store-based DataObject. + */ + public StoreDataObjectImpl(EClass eClass, InternalEObject.EStore eStore) + { + super(); + eSetClass(eClass); + eSetStore(eStore); + eContainer = EUNINITIALIZED_CONTAINER; + } + + protected boolean eIsCaching() + { + return true; + } + + public Object dynamicGet(int dynamicFeatureID) + { + Object result = eSettings[dynamicFeatureID]; + if (result == null) + { + EStructuralFeature eStructuralFeature = eDynamicFeature(dynamicFeatureID); + if (!eStructuralFeature.isTransient()) + { + if (FeatureMapUtil.isFeatureMap(eStructuralFeature)) + { + eSettings[dynamicFeatureID] = result = createFeatureMap(eStructuralFeature); + } + else if (eStructuralFeature.isMany()) + { + eSettings[dynamicFeatureID] = result = createList(eStructuralFeature); + } + else + { + result = eStore().get(this, eStructuralFeature, InternalEObject.EStore.NO_INDEX); + if (eIsCaching()) + { + eSettings[dynamicFeatureID] = result; + } + } + } + } + return result; + } + + public void dynamicSet(int dynamicFeatureID, Object value) + { + EStructuralFeature eStructuralFeature = eDynamicFeature(dynamicFeatureID); + if (eStructuralFeature.isTransient()) + { + eSettings[dynamicFeatureID] = value; + } + else + { + eStore().set(this, eStructuralFeature, InternalEObject.EStore.NO_INDEX, value == NIL ? null : value); + if (eIsCaching()) + { + eSettings[dynamicFeatureID] = value; + } + } + } + + public void dynamicUnset(int dynamicFeatureID) + { + eStore().unset(this, eDynamicFeature(dynamicFeatureID)); + eSettings[dynamicFeatureID] = null; + } + + public Object eDynamicGet(int featureID, boolean resolve, boolean coreType) + { + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + return eSettingDelegate(eFeature).dynamicGet(this, eSettings(), featureID, resolve, coreType); + } + else + { + return super.eDynamicGet(featureID, resolve, coreType); + } + } + + public void eDynamicSet(int featureID, Object newValue) + { + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + eDynamicSet(featureID, eFeature, newValue); + } + else + { + super.eDynamicSet(featureID, newValue); + } + } + + public void eDynamicUnset(int featureID) + { + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + eDynamicUnset(featureID, eFeature); + } + else + { + super.eDynamicUnset(featureID); + } + } + + public boolean eDynamicIsSet(int featureID) + { + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + return eFeature.isTransient() ? + eSettingDelegate(eFeature).dynamicIsSet(this, eSettings(), featureID) : + eStore().isSet(this, eFeature); + } + else + { + return super.eDynamicIsSet(featureID); + } + } + + /* + public boolean eDynamicIsSet(EStructuralFeature eStructuralFeature) + { + return + eStructuralFeature.isTransient() ? + super.eDynamicIsSet(eStructuralFeature) : + eStore().isSet(this, eStructuralFeature); + } + */ + + protected EList createList(EStructuralFeature eStructuralFeature) + { + return new EStoreEList(this, eStructuralFeature, eStore()); + } + + protected FeatureMap createFeatureMap(EStructuralFeature eStructuralFeature) + { + return new EStoreFeatureMap(this, eStructuralFeature, eStore()); + } + + public EObject eContainer() + { + if (eContainer == EUNINITIALIZED_CONTAINER) + { + eInitializeContainer(); + } + + return eContainer; + } + + public int eContainerFeatureID() + { + if (eContainer == EUNINITIALIZED_CONTAINER) + { + eInitializeContainer(); + } + + return eContainerFeatureID; + } + + protected void eInitializeContainer() + { + eContainer = eStore().getContainer(this); + if (eContainer != null) + { + EStructuralFeature eContainingFeature = eStore().getContainingFeature(this); + if (eContainingFeature instanceof EReference) + { + EReference eContainingReference = (EReference)eContainingFeature; + EReference eOpposite = eContainingReference.getEOpposite(); + if (eOpposite != null) + { + eContainerFeatureID = eClass().getFeatureID(eOpposite); + return; + } + } + + eContainerFeatureID = EOPPOSITE_FEATURE_BASE - eContainer.eClass().getFeatureID(eContainingFeature); + } + } + + public InternalEObject.EStore eStore() + { + return eStore; + } + + public void eSetStore(InternalEObject.EStore store) + { + this.eStore = store; + } + + protected int eStaticFeatureCount() + { + return 0; + } + + public int eDerivedStructuralFeatureID(EStructuralFeature eStructuralFeature) + { + return eClass().getFeatureID(eStructuralFeature); + } + + protected boolean eHasSettings() + { + return eSettings != null; + } + + protected EStructuralFeature.Internal.DynamicValueHolder eSettings() + { + if (eSettings == null) + { + int size = eClass().getFeatureCount() - eStaticFeatureCount(); + eSettings = size == 0 ? ENO_SETTINGS : new Object [size]; + } + + return this; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getStoreDataObject(); + } + +} //StoreDataObjectImpl |