From bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a Mon Sep 17 00:00:00 2001 From: dims Date: Tue, 17 Jun 2008 00:23:01 +0000 Subject: Move Tuscany from Incubator to top level. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tuscany/sdo/AnyTypeDataObject.java | 34 + .../java/org/apache/tuscany/sdo/SDOFactory.java | 173 ++ .../java/org/apache/tuscany/sdo/SDOPackage.java | 1599 +++++++++++++++ .../org/apache/tuscany/sdo/SDOTypeVisitor.java | 46 + .../tuscany/sdo/SimpleAnyTypeDataObject.java | 32 + .../sdo/codegen/BytecodeInterfaceGenerator.java | 93 + .../tuscany/sdo/codegen/GenerationException.java | 39 + .../sdo/codegen/JavaInterfaceGenerator.java | 104 + .../sdo/codegen/NoJavaImplementationException.java | 58 + .../apache/tuscany/sdo/helper/CopyHelperImpl.java | 51 + .../apache/tuscany/sdo/helper/DataFactoryImpl.java | 58 + .../apache/tuscany/sdo/helper/DataHelperImpl.java | 303 +++ .../tuscany/sdo/helper/EqualityHelperImpl.java | 67 + .../tuscany/sdo/helper/HelperProviderImpl.java | 110 + .../apache/tuscany/sdo/helper/TypeHelperImpl.java | 94 + .../apache/tuscany/sdo/helper/XMLDocumentImpl.java | 349 ++++ .../apache/tuscany/sdo/helper/XMLHelperImpl.java | 116 ++ .../apache/tuscany/sdo/helper/XSDHelperImpl.java | 273 +++ .../tuscany/sdo/impl/AnyTypeDataObjectImpl.java | 296 +++ .../org/apache/tuscany/sdo/impl/AttributeImpl.java | 163 ++ .../apache/tuscany/sdo/impl/ChangeSummaryImpl.java | 692 +++++++ .../tuscany/sdo/impl/ChangeSummarySettingImpl.java | 110 + .../org/apache/tuscany/sdo/impl/ClassImpl.java | 192 ++ .../org/apache/tuscany/sdo/impl/DataGraphImpl.java | 816 ++++++++ .../apache/tuscany/sdo/impl/DataObjectImpl.java | 1705 ++++++++++++++++ .../org/apache/tuscany/sdo/impl/DataTypeImpl.java | 177 ++ .../tuscany/sdo/impl/DynamicDataObjectImpl.java | 196 ++ .../sdo/impl/DynamicStoreDataObjectImpl.java | 88 + .../java/org/apache/tuscany/sdo/impl/EnumImpl.java | 169 ++ .../org/apache/tuscany/sdo/impl/ReferenceImpl.java | 129 ++ .../apache/tuscany/sdo/impl/SDOFactoryImpl.java | 325 +++ .../apache/tuscany/sdo/impl/SDOPackageImpl.java | 2133 ++++++++++++++++++++ .../sdo/impl/SimpleAnyTypeDataObjectImpl.java | 330 +++ .../tuscany/sdo/impl/StoreDataObjectImpl.java | 311 +++ .../org/apache/tuscany/sdo/util/BasicSequence.java | 134 ++ .../sdo/util/DataGraphResourceFactoryImpl.java | 644 ++++++ .../apache/tuscany/sdo/util/DataObjectUtil.java | 1727 ++++++++++++++++ .../java/org/apache/tuscany/sdo/util/SDOUtil.java | 221 ++ .../impl/src/main/resources/META-INF/MANIFEST.MF | 19 + .../services/commonj.sdo.impl.HelperProvider | 1 + .../java/org/apache/tuscany/sdo/codegen/Bar1.java | 23 + .../java/org/apache/tuscany/sdo/codegen/Bar2.java | 23 + .../BytecodeInterfaceGeneratorTestCase.java | 164 ++ .../java/org/apache/tuscany/sdo/codegen/Foo.java | 23 + .../codegen/JavaInterfaceGeneratorTestCase.java | 126 ++ .../apache/tuscany/sdo/codegen/MockProperty.java | 75 + .../org/apache/tuscany/sdo/codegen/MockType.java | 93 + .../tuscany/sdo/test/ChangeSummaryTestCase.java | 90 + .../tuscany/sdo/test/DataTypeBaseTypeTestCase.java | 65 + .../apache/tuscany/sdo/test/MixedTypeTestCase.java | 86 + .../apache/tuscany/sdo/test/OpenTypeTestCase.java | 82 + .../tuscany/sdo/test/SimpleCopyTestCase.java | 68 + .../tuscany/sdo/test/SimpleDynamicTestCase.java | 81 + .../tuscany/sdo/test/SimpleEqualityTestCase.java | 60 + .../java/org/apache/tuscany/sdo/test/TestUtil.java | 168 ++ .../apache/tuscany/sdo/test/XSDHelperTestCase.java | 57 + .../sdo/impl/src/test/resources/datatype.xsd | 16 + .../sdo/impl/src/test/resources/mixed.xml | 9 + .../sdo/impl/src/test/resources/mixed.xsd | 23 + .../sdo/impl/src/test/resources/open.xml | 8 + .../sdo/impl/src/test/resources/open.xsd | 26 + .../sdo/impl/src/test/resources/quote.xml | 14 + .../sdo/impl/src/test/resources/shallowquote.xml | 11 + .../sdo/impl/src/test/resources/simple.xsd | 23 + .../src/test/resources/simplechangesummary.xml | 35 + 65 files changed, 15626 insertions(+) create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/AnyTypeDataObject.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOFactory.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOPackage.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOTypeVisitor.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/SimpleAnyTypeDataObject.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGenerator.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/GenerationException.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGenerator.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/NoJavaImplementationException.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/CopyHelperImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DataFactoryImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DataHelperImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/EqualityHelperImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/HelperProviderImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLDocumentImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLHelperImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XSDHelperImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/AnyTypeDataObjectImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/AttributeImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummaryImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummarySettingImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ClassImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataGraphImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataTypeImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicDataObjectImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicStoreDataObjectImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/EnumImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ReferenceImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOFactoryImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOPackageImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/SimpleAnyTypeDataObjectImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/StoreDataObjectImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/BasicSequence.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataGraphResourceFactoryImpl.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/SDOUtil.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/resources/META-INF/MANIFEST.MF create mode 100644 tags/java-stable-20060304/sdo/impl/src/main/resources/META-INF/services/commonj.sdo.impl.HelperProvider create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/resources/datatype.xsd create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/resources/mixed.xml create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/resources/mixed.xsd create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/resources/open.xml create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/resources/open.xsd create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/resources/quote.xml create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/resources/shallowquote.xml create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/resources/simple.xsd create mode 100644 tags/java-stable-20060304/sdo/impl/src/test/resources/simplechangesummary.xml (limited to 'tags/java-stable-20060304/sdo/impl/src') diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/AnyTypeDataObject.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/AnyTypeDataObject.java new file mode 100644 index 0000000000..5eea403613 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/AnyTypeDataObject.java @@ -0,0 +1,34 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo; + +import commonj.sdo.DataObject; + +import org.eclipse.emf.ecore.xml.type.AnyType; + +/** + * + * A representation of the model object 'Any Type Data Object'. + * + * + * + * @see org.apache.tuscany.sdo.SDOPackage#getAnyTypeDataObject() + * @model extendedMetaData="kind='mixed'" + * @generated + */ +public interface AnyTypeDataObject extends DataObject, AnyType { +} // AnyTypeDataObject diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOFactory.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOFactory.java new file mode 100644 index 0000000000..5b066bb6e3 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOFactory.java @@ -0,0 +1,173 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import org.eclipse.emf.ecore.EFactory; +import org.eclipse.emf.ecore.EStructuralFeature; + +import commonj.sdo.Property; +import commonj.sdo.Type; + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @see org.apache.tuscany.sdo.SDOPackage + * @generated + */ +public interface SDOFactory extends EFactory{ + /** + * The singleton instance of the factory. + * + * + * @generated + */ + SDOFactory eINSTANCE = org.apache.tuscany.sdo.impl.SDOFactoryImpl.init(); + + /** + * Returns a new object of class 'Change Summary'. + * + * + * @return a new object of class 'Change Summary'. + * @generated + */ + ChangeSummary createChangeSummary(); + + /** + * Returns a new object of class 'Change Summary Setting'. + * + * + * @return a new object of class 'Change Summary Setting'. + * @generated + */ + ChangeSummary.Setting createChangeSummarySetting(); + + /** + * Returns a new object of class 'Data Graph'. + * + * + * @return a new object of class 'Data Graph'. + * @generated + */ + DataGraph createDataGraph(); + + /** + * Returns a new object of class 'Any Type Data Object'. + * + * + * @return a new object of class 'Any Type Data Object'. + * @generated + */ + AnyTypeDataObject createAnyTypeDataObject(); + + /** + * Returns a new object of class 'Simple Any Type Data Object'. + * + * + * @return a new object of class 'Simple Any Type Data Object'. + * @generated + */ + SimpleAnyTypeDataObject createSimpleAnyTypeDataObject(); + + /** + * Returns a new object of class 'Class'. + * + * + * @return a new object of class 'Class'. + * @generated + */ + Type createClass(); + + /** + * Returns a new object of class 'Data Type'. + * + * + * @return a new object of class 'Data Type'. + * @generated + */ + Type createDataType(); + + /** + * Returns a new object of class 'Attribute'. + * + * + * @return a new object of class 'Attribute'. + * @generated + */ + Property createAttribute(); + + /** + * Returns a new object of class 'Reference'. + * + * + * @return a new object of class 'Reference'. + * @generated + */ + Property createReference(); + + /** + * Returns a new object of class 'Enum'. + * + * + * @return a new object of class 'Enum'. + * @generated + */ + Type createEnum(); + + /** + * Returns a new object of class 'Dynamic Data Object'. + * + * + * @return a new object of class 'Dynamic Data Object'. + * @generated + */ + DataObject createDynamicDataObject(); + + /** + * Returns a new object of class 'Store Data Object'. + * + * + * @return a new object of class 'Store Data Object'. + * @generated + */ + DataObject createStoreDataObject(); + + /** + * Returns a new object of class 'Dynamic Store Data Object'. + * + * + * @return a new object of class 'Dynamic Store Data Object'. + * @generated + */ + DataObject createDynamicStoreDataObject(); + + /** + * Returns the package supported by this factory. + * + * + * @return the package supported by this factory. + * @generated + */ + SDOPackage getSDOPackage(); + + ChangeSummary.Setting createChangeSummarySetting(EStructuralFeature eStructuralFeature, Object value, boolean isSet); + +} //SDOFactory diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOPackage.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOPackage.java new file mode 100644 index 0000000000..caa154baf5 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOPackage.java @@ -0,0 +1,1599 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +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; + +/** + * + * The Package for the model. + * It contains accessors for the meta objects to represent + * + * + * @see org.apache.tuscany.sdo.SDOFactory + * @model kind="package" + * @generated + */ +public interface SDOPackage extends EPackage{ + /** + * The package name. + * + * + * @generated + */ + String eNAME = "sdo"; + + /** + * The package namespace URI. + * + * + * @generated + */ + String eNS_URI = "http://www.apache.org/tuscany/2005/SDO"; + + /** + * The package namespace name. + * + * + * @generated + */ + String eNS_PREFIX = "sdo"; + + /** + * The singleton instance of the package. + * + * + * @generated + */ + SDOPackage eINSTANCE = org.apache.tuscany.sdo.impl.SDOPackageImpl.init(); + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.DataGraphImpl Data Graph}' class. + * + * + * @see org.apache.tuscany.sdo.impl.DataGraphImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getDataGraph() + * @generated + */ + int DATA_GRAPH = 2; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.ChangeSummaryImpl Change Summary}' class. + * + * + * @see org.apache.tuscany.sdo.impl.ChangeSummaryImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getChangeSummary() + * @generated + */ + int CHANGE_SUMMARY = 0; + + /** + * The feature id for the 'Object Changes' map. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY__OBJECT_CHANGES = ChangePackage.CHANGE_DESCRIPTION__OBJECT_CHANGES; + + /** + * The feature id for the 'Objects To Detach' reference list. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY__OBJECTS_TO_DETACH = ChangePackage.CHANGE_DESCRIPTION__OBJECTS_TO_DETACH; + + /** + * The feature id for the 'Objects To Attach' containment reference list. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY__OBJECTS_TO_ATTACH = ChangePackage.CHANGE_DESCRIPTION__OBJECTS_TO_ATTACH; + + /** + * The feature id for the 'Resource Changes' containment reference list. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY__RESOURCE_CHANGES = ChangePackage.CHANGE_DESCRIPTION__RESOURCE_CHANGES; + + /** + * The feature id for the 'EData Graph' reference. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY__EDATA_GRAPH = ChangePackage.CHANGE_DESCRIPTION_FEATURE_COUNT + 0; + + /** + * The number of structural features of the 'Change Summary' class. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY_FEATURE_COUNT = ChangePackage.CHANGE_DESCRIPTION_FEATURE_COUNT + 1; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.ChangeSummarySettingImpl Change Summary Setting}' class. + * + * + * @see org.apache.tuscany.sdo.impl.ChangeSummarySettingImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getChangeSummarySetting() + * @generated + */ + int CHANGE_SUMMARY_SETTING = 1; + + /** + * The feature id for the 'Feature Name' attribute. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING__FEATURE_NAME = ChangePackage.FEATURE_CHANGE__FEATURE_NAME; + + /** + * The feature id for the 'Data Value' attribute. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING__DATA_VALUE = ChangePackage.FEATURE_CHANGE__DATA_VALUE; + + /** + * The feature id for the 'Set' attribute. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING__SET = ChangePackage.FEATURE_CHANGE__SET; + + /** + * The feature id for the 'Value' attribute. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING__VALUE = ChangePackage.FEATURE_CHANGE__VALUE; + + /** + * The feature id for the 'Feature' reference. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING__FEATURE = ChangePackage.FEATURE_CHANGE__FEATURE; + + /** + * The feature id for the 'Reference Value' reference. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING__REFERENCE_VALUE = ChangePackage.FEATURE_CHANGE__REFERENCE_VALUE; + + /** + * The feature id for the 'List Changes' containment reference list. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING__LIST_CHANGES = ChangePackage.FEATURE_CHANGE__LIST_CHANGES; + + /** + * The number of structural features of the 'Change Summary Setting' class. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING_FEATURE_COUNT = ChangePackage.FEATURE_CHANGE_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Resource Set' attribute. + * + * + * @generated + * @ordered + */ + int DATA_GRAPH__RESOURCE_SET = EcorePackage.EOBJECT_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Root Resource' attribute. + * + * + * @generated + * @ordered + */ + int DATA_GRAPH__ROOT_RESOURCE = EcorePackage.EOBJECT_FEATURE_COUNT + 1; + + /** + * The feature id for the 'EChange Summary' reference. + * + * + * @generated + * @ordered + */ + int DATA_GRAPH__ECHANGE_SUMMARY = EcorePackage.EOBJECT_FEATURE_COUNT + 2; + + /** + * The feature id for the 'ERoot Object' reference. + * + * + * @generated + * @ordered + */ + int DATA_GRAPH__EROOT_OBJECT = EcorePackage.EOBJECT_FEATURE_COUNT + 3; + + /** + * The number of structural features of the 'Data Graph' class. + * + * + * @generated + * @ordered + */ + int DATA_GRAPH_FEATURE_COUNT = EcorePackage.EOBJECT_FEATURE_COUNT + 4; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.DataObjectImpl Data Object}' class. + * + * + * @see org.apache.tuscany.sdo.impl.DataObjectImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getDataObject() + * @generated + */ + int DATA_OBJECT = 3; + + /** + * The meta object id for the '{@link commonj.sdo.Property Property}' class. + * + * + * @see commonj.sdo.Property + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getProperty() + * @generated + */ + int PROPERTY = 4; + + /** + * The meta object id for the '{@link commonj.sdo.Sequence Sequence}' class. + * + * + * @see commonj.sdo.Sequence + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getSequence() + * @generated + */ + int SEQUENCE = 5; + + /** + * The meta object id for the '{@link commonj.sdo.Type Type}' class. + * + * + * @see commonj.sdo.Type + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getType() + * @generated + */ + int TYPE = 6; + + /** + * The number of structural features of the 'Data Object' class. + * + * + * @generated + * @ordered + */ + int DATA_OBJECT_FEATURE_COUNT = 0; + + /** + * The number of structural features of the 'Property' class. + * + * + * @generated + * @ordered + */ + int PROPERTY_FEATURE_COUNT = 0; + + /** + * The number of structural features of the 'Sequence' class. + * + * + * @generated + * @ordered + */ + int SEQUENCE_FEATURE_COUNT = 0; + + /** + * The number of structural features of the 'Type' class. + * + * + * @generated + * @ordered + */ + int TYPE_FEATURE_COUNT = 0; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.AnyTypeDataObjectImpl Any Type Data Object}' class. + * + * + * @see org.apache.tuscany.sdo.impl.AnyTypeDataObjectImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getAnyTypeDataObject() + * @generated + */ + int ANY_TYPE_DATA_OBJECT = 7; + + /** + * The feature id for the 'Mixed' attribute list. + * + * + * @generated + * @ordered + */ + int ANY_TYPE_DATA_OBJECT__MIXED = DATA_OBJECT_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Any' attribute list. + * + * + * @generated + * @ordered + */ + int ANY_TYPE_DATA_OBJECT__ANY = DATA_OBJECT_FEATURE_COUNT + 1; + + /** + * The feature id for the 'Any Attribute' attribute list. + * + * + * @generated + * @ordered + */ + int ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE = DATA_OBJECT_FEATURE_COUNT + 2; + + /** + * The number of structural features of the 'Any Type Data Object' class. + * + * + * @generated + * @ordered + */ + int ANY_TYPE_DATA_OBJECT_FEATURE_COUNT = DATA_OBJECT_FEATURE_COUNT + 3; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.SimpleAnyTypeDataObjectImpl Simple Any Type Data Object}' class. + * + * + * @see org.apache.tuscany.sdo.impl.SimpleAnyTypeDataObjectImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getSimpleAnyTypeDataObject() + * @generated + */ + int SIMPLE_ANY_TYPE_DATA_OBJECT = 8; + + /** + * The feature id for the 'Mixed' attribute list. + * + * + * @generated + * @ordered + */ + int SIMPLE_ANY_TYPE_DATA_OBJECT__MIXED = ANY_TYPE_DATA_OBJECT__MIXED; + + /** + * The feature id for the 'Any' attribute list. + * + * + * @generated + * @ordered + */ + int SIMPLE_ANY_TYPE_DATA_OBJECT__ANY = ANY_TYPE_DATA_OBJECT__ANY; + + /** + * The feature id for the 'Any Attribute' attribute list. + * + * + * @generated + * @ordered + */ + int SIMPLE_ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE = ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE; + + /** + * The feature id for the 'Raw Value' attribute. + * + * + * @generated + * @ordered + */ + int SIMPLE_ANY_TYPE_DATA_OBJECT__RAW_VALUE = ANY_TYPE_DATA_OBJECT_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Value' attribute. + * + * + * @generated + * @ordered + */ + int SIMPLE_ANY_TYPE_DATA_OBJECT__VALUE = ANY_TYPE_DATA_OBJECT_FEATURE_COUNT + 1; + + /** + * The feature id for the 'Instance Type' reference. + * + * + * @generated + * @ordered + */ + int SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE = ANY_TYPE_DATA_OBJECT_FEATURE_COUNT + 2; + + /** + * The number of structural features of the 'Simple Any Type Data Object' class. + * + * + * @generated + * @ordered + */ + int SIMPLE_ANY_TYPE_DATA_OBJECT_FEATURE_COUNT = ANY_TYPE_DATA_OBJECT_FEATURE_COUNT + 3; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.ClassImpl Class}' class. + * + * + * @see org.apache.tuscany.sdo.impl.ClassImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getClass_() + * @generated + */ + int CLASS = 9; + + /** + * The feature id for the 'EAnnotations' containment reference list. + * + * + * @generated + * @ordered + */ + int CLASS__EANNOTATIONS = EcorePackage.ECLASS__EANNOTATIONS; + + /** + * The feature id for the 'Name' attribute. + * + * + * @generated + * @ordered + */ + int CLASS__NAME = EcorePackage.ECLASS__NAME; + + /** + * The feature id for the 'Instance Class Name' attribute. + * + * + * @generated + * @ordered + */ + int CLASS__INSTANCE_CLASS_NAME = EcorePackage.ECLASS__INSTANCE_CLASS_NAME; + + /** + * The feature id for the 'Instance Class' attribute. + * + * + * @generated + * @ordered + */ + int CLASS__INSTANCE_CLASS = EcorePackage.ECLASS__INSTANCE_CLASS; + + /** + * The feature id for the 'Default Value' attribute. + * + * + * @generated + * @ordered + */ + int CLASS__DEFAULT_VALUE = EcorePackage.ECLASS__DEFAULT_VALUE; + + /** + * The feature id for the 'EPackage' container reference. + * + * + * @generated + * @ordered + */ + int CLASS__EPACKAGE = EcorePackage.ECLASS__EPACKAGE; + + /** + * The feature id for the 'Abstract' attribute. + * + * + * @generated + * @ordered + */ + int CLASS__ABSTRACT = EcorePackage.ECLASS__ABSTRACT; + + /** + * The feature id for the 'Interface' attribute. + * + * + * @generated + * @ordered + */ + int CLASS__INTERFACE = EcorePackage.ECLASS__INTERFACE; + + /** + * The feature id for the 'ESuper Types' reference list. + * + * + * @generated + * @ordered + */ + int CLASS__ESUPER_TYPES = EcorePackage.ECLASS__ESUPER_TYPES; + + /** + * The feature id for the 'EOperations' containment reference list. + * + * + * @generated + * @ordered + */ + int CLASS__EOPERATIONS = EcorePackage.ECLASS__EOPERATIONS; + + /** + * The feature id for the 'EAll Attributes' reference list. + * + * + * @generated + * @ordered + */ + int CLASS__EALL_ATTRIBUTES = EcorePackage.ECLASS__EALL_ATTRIBUTES; + + /** + * The feature id for the 'EAll References' reference list. + * + * + * @generated + * @ordered + */ + int CLASS__EALL_REFERENCES = EcorePackage.ECLASS__EALL_REFERENCES; + + /** + * The feature id for the 'EReferences' reference list. + * + * + * @generated + * @ordered + */ + int CLASS__EREFERENCES = EcorePackage.ECLASS__EREFERENCES; + + /** + * The feature id for the 'EAttributes' reference list. + * + * + * @generated + * @ordered + */ + int CLASS__EATTRIBUTES = EcorePackage.ECLASS__EATTRIBUTES; + + /** + * The feature id for the 'EAll Containments' reference list. + * + * + * @generated + * @ordered + */ + int CLASS__EALL_CONTAINMENTS = EcorePackage.ECLASS__EALL_CONTAINMENTS; + + /** + * The feature id for the 'EAll Operations' reference list. + * + * + * @generated + * @ordered + */ + int CLASS__EALL_OPERATIONS = EcorePackage.ECLASS__EALL_OPERATIONS; + + /** + * The feature id for the 'EAll Structural Features' reference list. + * + * + * @generated + * @ordered + */ + int CLASS__EALL_STRUCTURAL_FEATURES = EcorePackage.ECLASS__EALL_STRUCTURAL_FEATURES; + + /** + * The feature id for the 'EAll Super Types' reference list. + * + * + * @generated + * @ordered + */ + int CLASS__EALL_SUPER_TYPES = EcorePackage.ECLASS__EALL_SUPER_TYPES; + + /** + * The feature id for the 'EID Attribute' reference. + * + * + * @generated + * @ordered + */ + int CLASS__EID_ATTRIBUTE = EcorePackage.ECLASS__EID_ATTRIBUTE; + + /** + * The feature id for the 'EStructural Features' containment reference list. + * + * + * @generated + * @ordered + */ + int CLASS__ESTRUCTURAL_FEATURES = EcorePackage.ECLASS__ESTRUCTURAL_FEATURES; + + /** + * The number of structural features of the 'Class' class. + * + * + * @generated + * @ordered + */ + int CLASS_FEATURE_COUNT = EcorePackage.ECLASS_FEATURE_COUNT + 0; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.DataTypeImpl Data Type}' class. + * + * + * @see org.apache.tuscany.sdo.impl.DataTypeImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getDataType() + * @generated + */ + int DATA_TYPE = 10; + + /** + * The feature id for the 'EAnnotations' containment reference list. + * + * + * @generated + * @ordered + */ + int DATA_TYPE__EANNOTATIONS = EcorePackage.EDATA_TYPE__EANNOTATIONS; + + /** + * The feature id for the 'Name' attribute. + * + * + * @generated + * @ordered + */ + int DATA_TYPE__NAME = EcorePackage.EDATA_TYPE__NAME; + + /** + * The feature id for the 'Instance Class Name' attribute. + * + * + * @generated + * @ordered + */ + int DATA_TYPE__INSTANCE_CLASS_NAME = EcorePackage.EDATA_TYPE__INSTANCE_CLASS_NAME; + + /** + * The feature id for the 'Instance Class' attribute. + * + * + * @generated + * @ordered + */ + int DATA_TYPE__INSTANCE_CLASS = EcorePackage.EDATA_TYPE__INSTANCE_CLASS; + + /** + * The feature id for the 'Default Value' attribute. + * + * + * @generated + * @ordered + */ + int DATA_TYPE__DEFAULT_VALUE = EcorePackage.EDATA_TYPE__DEFAULT_VALUE; + + /** + * The feature id for the 'EPackage' container reference. + * + * + * @generated + * @ordered + */ + int DATA_TYPE__EPACKAGE = EcorePackage.EDATA_TYPE__EPACKAGE; + + /** + * The feature id for the 'Serializable' attribute. + * + * + * @generated + * @ordered + */ + int DATA_TYPE__SERIALIZABLE = EcorePackage.EDATA_TYPE__SERIALIZABLE; + + /** + * The number of structural features of the 'Data Type' class. + * + * + * @generated + * @ordered + */ + int DATA_TYPE_FEATURE_COUNT = EcorePackage.EDATA_TYPE_FEATURE_COUNT + 0; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.AttributeImpl Attribute}' class. + * + * + * @see org.apache.tuscany.sdo.impl.AttributeImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getAttribute() + * @generated + */ + int ATTRIBUTE = 11; + + /** + * The feature id for the 'EAnnotations' containment reference list. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__EANNOTATIONS = EcorePackage.EATTRIBUTE__EANNOTATIONS; + + /** + * The feature id for the 'Name' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__NAME = EcorePackage.EATTRIBUTE__NAME; + + /** + * The feature id for the 'Ordered' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__ORDERED = EcorePackage.EATTRIBUTE__ORDERED; + + /** + * The feature id for the 'Unique' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__UNIQUE = EcorePackage.EATTRIBUTE__UNIQUE; + + /** + * The feature id for the 'Lower Bound' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__LOWER_BOUND = EcorePackage.EATTRIBUTE__LOWER_BOUND; + + /** + * The feature id for the 'Upper Bound' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__UPPER_BOUND = EcorePackage.EATTRIBUTE__UPPER_BOUND; + + /** + * The feature id for the 'Many' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__MANY = EcorePackage.EATTRIBUTE__MANY; + + /** + * The feature id for the 'Required' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__REQUIRED = EcorePackage.EATTRIBUTE__REQUIRED; + + /** + * The feature id for the 'EType' reference. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__ETYPE = EcorePackage.EATTRIBUTE__ETYPE; + + /** + * The feature id for the 'Changeable' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__CHANGEABLE = EcorePackage.EATTRIBUTE__CHANGEABLE; + + /** + * The feature id for the 'Volatile' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__VOLATILE = EcorePackage.EATTRIBUTE__VOLATILE; + + /** + * The feature id for the 'Transient' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__TRANSIENT = EcorePackage.EATTRIBUTE__TRANSIENT; + + /** + * The feature id for the 'Default Value Literal' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__DEFAULT_VALUE_LITERAL = EcorePackage.EATTRIBUTE__DEFAULT_VALUE_LITERAL; + + /** + * The feature id for the 'Default Value' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__DEFAULT_VALUE = EcorePackage.EATTRIBUTE__DEFAULT_VALUE; + + /** + * The feature id for the 'Unsettable' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__UNSETTABLE = EcorePackage.EATTRIBUTE__UNSETTABLE; + + /** + * The feature id for the 'Derived' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__DERIVED = EcorePackage.EATTRIBUTE__DERIVED; + + /** + * The feature id for the 'EContaining Class' container reference. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__ECONTAINING_CLASS = EcorePackage.EATTRIBUTE__ECONTAINING_CLASS; + + /** + * The feature id for the 'ID' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__ID = EcorePackage.EATTRIBUTE__ID; + + /** + * The feature id for the 'EAttribute Type' reference. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__EATTRIBUTE_TYPE = EcorePackage.EATTRIBUTE__EATTRIBUTE_TYPE; + + /** + * The number of structural features of the 'Attribute' class. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE_FEATURE_COUNT = EcorePackage.EATTRIBUTE_FEATURE_COUNT + 0; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.ReferenceImpl Reference}' class. + * + * + * @see org.apache.tuscany.sdo.impl.ReferenceImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getReference() + * @generated + */ + int REFERENCE = 12; + + /** + * The feature id for the 'EAnnotations' containment reference list. + * + * + * @generated + * @ordered + */ + int REFERENCE__EANNOTATIONS = EcorePackage.EREFERENCE__EANNOTATIONS; + + /** + * The feature id for the 'Name' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__NAME = EcorePackage.EREFERENCE__NAME; + + /** + * The feature id for the 'Ordered' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__ORDERED = EcorePackage.EREFERENCE__ORDERED; + + /** + * The feature id for the 'Unique' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__UNIQUE = EcorePackage.EREFERENCE__UNIQUE; + + /** + * The feature id for the 'Lower Bound' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__LOWER_BOUND = EcorePackage.EREFERENCE__LOWER_BOUND; + + /** + * The feature id for the 'Upper Bound' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__UPPER_BOUND = EcorePackage.EREFERENCE__UPPER_BOUND; + + /** + * The feature id for the 'Many' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__MANY = EcorePackage.EREFERENCE__MANY; + + /** + * The feature id for the 'Required' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__REQUIRED = EcorePackage.EREFERENCE__REQUIRED; + + /** + * The feature id for the 'EType' reference. + * + * + * @generated + * @ordered + */ + int REFERENCE__ETYPE = EcorePackage.EREFERENCE__ETYPE; + + /** + * The feature id for the 'Changeable' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__CHANGEABLE = EcorePackage.EREFERENCE__CHANGEABLE; + + /** + * The feature id for the 'Volatile' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__VOLATILE = EcorePackage.EREFERENCE__VOLATILE; + + /** + * The feature id for the 'Transient' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__TRANSIENT = EcorePackage.EREFERENCE__TRANSIENT; + + /** + * The feature id for the 'Default Value Literal' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__DEFAULT_VALUE_LITERAL = EcorePackage.EREFERENCE__DEFAULT_VALUE_LITERAL; + + /** + * The feature id for the 'Default Value' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__DEFAULT_VALUE = EcorePackage.EREFERENCE__DEFAULT_VALUE; + + /** + * The feature id for the 'Unsettable' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__UNSETTABLE = EcorePackage.EREFERENCE__UNSETTABLE; + + /** + * The feature id for the 'Derived' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__DERIVED = EcorePackage.EREFERENCE__DERIVED; + + /** + * The feature id for the 'EContaining Class' container reference. + * + * + * @generated + * @ordered + */ + int REFERENCE__ECONTAINING_CLASS = EcorePackage.EREFERENCE__ECONTAINING_CLASS; + + /** + * The feature id for the 'Containment' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__CONTAINMENT = EcorePackage.EREFERENCE__CONTAINMENT; + + /** + * The feature id for the 'Container' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__CONTAINER = EcorePackage.EREFERENCE__CONTAINER; + + /** + * The feature id for the 'Resolve Proxies' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__RESOLVE_PROXIES = EcorePackage.EREFERENCE__RESOLVE_PROXIES; + + /** + * The feature id for the 'EOpposite' reference. + * + * + * @generated + * @ordered + */ + int REFERENCE__EOPPOSITE = EcorePackage.EREFERENCE__EOPPOSITE; + + /** + * The feature id for the 'EReference Type' reference. + * + * + * @generated + * @ordered + */ + int REFERENCE__EREFERENCE_TYPE = EcorePackage.EREFERENCE__EREFERENCE_TYPE; + + /** + * The number of structural features of the 'Reference' class. + * + * + * @generated + * @ordered + */ + int REFERENCE_FEATURE_COUNT = EcorePackage.EREFERENCE_FEATURE_COUNT + 0; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.EnumImpl Enum}' class. + * + * + * @see org.apache.tuscany.sdo.impl.EnumImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getEnum() + * @generated + */ + int ENUM = 13; + + /** + * The feature id for the 'EAnnotations' containment reference list. + * + * + * @generated + * @ordered + */ + int ENUM__EANNOTATIONS = EcorePackage.EENUM__EANNOTATIONS; + + /** + * The feature id for the 'Name' attribute. + * + * + * @generated + * @ordered + */ + int ENUM__NAME = EcorePackage.EENUM__NAME; + + /** + * The feature id for the 'Instance Class Name' attribute. + * + * + * @generated + * @ordered + */ + int ENUM__INSTANCE_CLASS_NAME = EcorePackage.EENUM__INSTANCE_CLASS_NAME; + + /** + * The feature id for the 'Instance Class' attribute. + * + * + * @generated + * @ordered + */ + int ENUM__INSTANCE_CLASS = EcorePackage.EENUM__INSTANCE_CLASS; + + /** + * The feature id for the 'Default Value' attribute. + * + * + * @generated + * @ordered + */ + int ENUM__DEFAULT_VALUE = EcorePackage.EENUM__DEFAULT_VALUE; + + /** + * The feature id for the 'EPackage' container reference. + * + * + * @generated + * @ordered + */ + int ENUM__EPACKAGE = EcorePackage.EENUM__EPACKAGE; + + /** + * The feature id for the 'Serializable' attribute. + * + * + * @generated + * @ordered + */ + int ENUM__SERIALIZABLE = EcorePackage.EENUM__SERIALIZABLE; + + /** + * The feature id for the 'ELiterals' containment reference list. + * + * + * @generated + * @ordered + */ + int ENUM__ELITERALS = EcorePackage.EENUM__ELITERALS; + + /** + * The number of structural features of the 'Enum' class. + * + * + * @generated + * @ordered + */ + int ENUM_FEATURE_COUNT = EcorePackage.EENUM_FEATURE_COUNT + 0; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.DynamicDataObjectImpl Dynamic Data Object}' class. + * + * + * @see org.apache.tuscany.sdo.impl.DynamicDataObjectImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getDynamicDataObject() + * @generated + */ + int DYNAMIC_DATA_OBJECT = 14; + + /** + * The number of structural features of the 'Dynamic Data Object' class. + * + * + * @generated + * @ordered + */ + int DYNAMIC_DATA_OBJECT_FEATURE_COUNT = DATA_OBJECT_FEATURE_COUNT + 0; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.StoreDataObjectImpl Store Data Object}' class. + * + * + * @see org.apache.tuscany.sdo.impl.StoreDataObjectImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getStoreDataObject() + * @generated + */ + int STORE_DATA_OBJECT = 15; + + /** + * The number of structural features of the 'Store Data Object' class. + * + * + * @generated + * @ordered + */ + int STORE_DATA_OBJECT_FEATURE_COUNT = DATA_OBJECT_FEATURE_COUNT + 0; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.DynamicStoreDataObjectImpl Dynamic Store Data Object}' class. + * + * + * @see org.apache.tuscany.sdo.impl.DynamicStoreDataObjectImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getDynamicStoreDataObject() + * @generated + */ + int DYNAMIC_STORE_DATA_OBJECT = 16; + + /** + * The number of structural features of the 'Dynamic Store Data Object' class. + * + * + * @generated + * @ordered + */ + int DYNAMIC_STORE_DATA_OBJECT_FEATURE_COUNT = STORE_DATA_OBJECT_FEATURE_COUNT + 0; + + /** + * The meta object id for the 'EJava List' data type. + * + * + * @see java.util.List + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getEJavaList() + * @generated + */ + int EJAVA_LIST = 17; + + /** + * The meta object id for the 'EObject Stream Exception' data type. + * + * + * @see java.io.ObjectStreamException + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getEObjectStreamException() + * @generated + */ + int EOBJECT_STREAM_EXCEPTION = 18; + + + /** + * Returns the meta object for class '{@link commonj.sdo.ChangeSummary Change Summary}'. + * + * + * @return the meta object for class 'Change Summary'. + * @see commonj.sdo.ChangeSummary + * @model instanceClass="commonj.sdo.ChangeSummary" + * @generated + */ + EClass getChangeSummary(); + + /** + * Returns the meta object for the reference '{@link commonj.sdo.ChangeSummary#getEDataGraph EData Graph}'. + * + * + * @return the meta object for the reference 'EData Graph'. + * @see commonj.sdo.ChangeSummary#getEDataGraph() + * @see #getChangeSummary() + * @generated + */ + EReference getChangeSummary_EDataGraph(); + + /** + * Returns the meta object for class '{@link commonj.sdo.ChangeSummary.Setting Change Summary Setting}'. + * + * + * @return the meta object for class 'Change Summary Setting'. + * @see commonj.sdo.ChangeSummary.Setting + * @model instanceClass="commonj.sdo.ChangeSummary$Setting" + * @generated + */ + EClass getChangeSummarySetting(); + + /** + * Returns the meta object for class '{@link commonj.sdo.DataGraph Data Graph}'. + * + * + * @return the meta object for class 'Data Graph'. + * @see commonj.sdo.DataGraph + * @model instanceClass="commonj.sdo.DataGraph" + * @generated + */ + EClass getDataGraph(); + + /** + * Returns the meta object for the attribute '{@link commonj.sdo.DataGraph#getResourceSet Resource Set}'. + * + * + * @return the meta object for the attribute 'Resource Set'. + * @see commonj.sdo.DataGraph#getResourceSet() + * @see #getDataGraph() + * @generated + */ + EAttribute getDataGraph_ResourceSet(); + + /** + * Returns the meta object for the attribute '{@link commonj.sdo.DataGraph#getRootResource Root Resource}'. + * + * + * @return the meta object for the attribute 'Root Resource'. + * @see commonj.sdo.DataGraph#getRootResource() + * @see #getDataGraph() + * @generated + */ + EAttribute getDataGraph_RootResource(); + + /** + * Returns the meta object for the reference '{@link commonj.sdo.DataGraph#getEChangeSummary EChange Summary}'. + * + * + * @return the meta object for the reference 'EChange Summary'. + * @see commonj.sdo.DataGraph#getEChangeSummary() + * @see #getDataGraph() + * @generated + */ + EReference getDataGraph_EChangeSummary(); + + /** + * Returns the meta object for the reference '{@link commonj.sdo.DataGraph#getERootObject ERoot Object}'. + * + * + * @return the meta object for the reference 'ERoot Object'. + * @see commonj.sdo.DataGraph#getERootObject() + * @see #getDataGraph() + * @generated + */ + EReference getDataGraph_ERootObject(); + + /** + * Returns the meta object for class '{@link commonj.sdo.DataObject Data Object}'. + * + * + * @return the meta object for class 'Data Object'. + * @see commonj.sdo.DataObject + * @model instanceClass="commonj.sdo.DataObject" + * @generated + */ + EClass getDataObject(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Property Property}'. + * + * + * @return the meta object for class 'Property'. + * @see commonj.sdo.Property + * @model instanceClass="commonj.sdo.Property" + * @generated + */ + EClass getProperty(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Sequence Sequence}'. + * + * + * @return the meta object for class 'Sequence'. + * @see commonj.sdo.Sequence + * @model instanceClass="commonj.sdo.Sequence" + * @generated + */ + EClass getSequence(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Type Type}'. + * + * + * @return the meta object for class 'Type'. + * @see commonj.sdo.Type + * @model instanceClass="commonj.sdo.Type" + * @generated + */ + EClass getType(); + + /** + * Returns the meta object for class '{@link org.apache.tuscany.sdo.AnyTypeDataObject Any Type Data Object}'. + * + * + * @return the meta object for class 'Any Type Data Object'. + * @see org.apache.tuscany.sdo.AnyTypeDataObject + * @generated + */ + EClass getAnyTypeDataObject(); + + /** + * Returns the meta object for class '{@link org.apache.tuscany.sdo.SimpleAnyTypeDataObject Simple Any Type Data Object}'. + * + * + * @return the meta object for class 'Simple Any Type Data Object'. + * @see org.apache.tuscany.sdo.SimpleAnyTypeDataObject + * @generated + */ + EClass getSimpleAnyTypeDataObject(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Type Class}'. + * + * + * @return the meta object for class 'Class'. + * @see commonj.sdo.Type + * @model instanceClass="commonj.sdo.Type" + * @generated + */ + EClass getClass_(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Type Data Type}'. + * + * + * @return the meta object for class 'Data Type'. + * @see commonj.sdo.Type + * @model instanceClass="commonj.sdo.Type" + * @generated + */ + EClass getDataType(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Property Attribute}'. + * + * + * @return the meta object for class 'Attribute'. + * @see commonj.sdo.Property + * @model instanceClass="commonj.sdo.Property" + * @generated + */ + EClass getAttribute(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Property Reference}'. + * + * + * @return the meta object for class 'Reference'. + * @see commonj.sdo.Property + * @model instanceClass="commonj.sdo.Property" + * @generated + */ + EClass getReference(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Type Enum}'. + * + * + * @return the meta object for class 'Enum'. + * @see commonj.sdo.Type + * @model instanceClass="commonj.sdo.Type" + * @generated + */ + EClass getEnum(); + + /** + * Returns the meta object for class '{@link commonj.sdo.DataObject Dynamic Data Object}'. + * + * + * @return the meta object for class 'Dynamic Data Object'. + * @see commonj.sdo.DataObject + * @model instanceClass="commonj.sdo.DataObject" + * @generated + */ + EClass getDynamicDataObject(); + + /** + * Returns the meta object for class '{@link commonj.sdo.DataObject Store Data Object}'. + * + * + * @return the meta object for class 'Store Data Object'. + * @see commonj.sdo.DataObject + * @model instanceClass="commonj.sdo.DataObject" + * @generated + */ + EClass getStoreDataObject(); + + /** + * Returns the meta object for class '{@link commonj.sdo.DataObject Dynamic Store Data Object}'. + * + * + * @return the meta object for class 'Dynamic Store Data Object'. + * @see commonj.sdo.DataObject + * @model instanceClass="commonj.sdo.DataObject" + * @generated + */ + EClass getDynamicStoreDataObject(); + + /** + * Returns the meta object for data type '{@link java.util.List EJava List}'. + * + * + * @return the meta object for data type 'EJava List'. + * @see java.util.List + * @model instanceClass="java.util.List" serializable="false" + * @generated + */ + EDataType getEJavaList(); + + /** + * Returns the meta object for data type '{@link java.io.ObjectStreamException EObject Stream Exception}'. + * + * + * @return the meta object for data type 'EObject Stream Exception'. + * @see java.io.ObjectStreamException + * @model instanceClass="java.io.ObjectStreamException" serializable="false" + * @generated + */ + EDataType getEObjectStreamException(); + + /** + * Returns the factory that creates the instances of the model. + * + * + * @return the factory that creates the instances of the model. + * @generated + */ + SDOFactory getSDOFactory(); + +} //SDOPackage diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOTypeVisitor.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOTypeVisitor.java new file mode 100644 index 0000000000..ced62cc058 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOTypeVisitor.java @@ -0,0 +1,46 @@ +/** + * + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo; + +import commonj.sdo.Property; +import commonj.sdo.Type; + +/** + * Visitor interface that allows applications to process SDO type metadata. + * + * @version $Rev$ $Date$ + */ +public interface SDOTypeVisitor { + /** + * Visit a type definition. + * + * @param type the type to visit + */ + void visitType(Type type); + + /** + * Visit a property definition. + * + * @param property the property to visit + */ + void visitProperty(Property property); + + /** + * Visit after all properties. + */ + void visitEnd(); +} diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/SimpleAnyTypeDataObject.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/SimpleAnyTypeDataObject.java new file mode 100644 index 0000000000..5fed5829ae --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/SimpleAnyTypeDataObject.java @@ -0,0 +1,32 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo; + +import org.eclipse.emf.ecore.xml.type.SimpleAnyType; + +/** + * + * A representation of the model object 'Simple Any Type Data Object'. + * + * + * + * @see org.apache.tuscany.sdo.SDOPackage#getSimpleAnyTypeDataObject() + * @model extendedMetaData="kind='simple'" + * @generated + */ +public interface SimpleAnyTypeDataObject extends AnyTypeDataObject, SimpleAnyType { +} // SimpleAnyTypeDataObject diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGenerator.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGenerator.java new file mode 100644 index 0000000000..534505a613 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGenerator.java @@ -0,0 +1,93 @@ +/** + * + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.codegen; + +import java.util.List; + +import commonj.sdo.Property; +import commonj.sdo.Type; +import org.objectweb.asm.ClassWriter; +import static org.objectweb.asm.Opcodes.*; + +import org.apache.tuscany.sdo.SDOTypeVisitor; + +/** + * Implementation of a generator that will directly emit bytecode for an interface that + * corresponds to the static properties of a SDO type. + * + * @version $Rev$ $Date$ + */ +public class BytecodeInterfaceGenerator implements SDOTypeVisitor { + private final ClassWriter cw; + + public BytecodeInterfaceGenerator() { + cw = new ClassWriter(false); + } + + public void visitType(Type type) { + String name = type.getName(); + int lastDot = name.lastIndexOf('.'); + if (lastDot != -1) { + name = name.replace('.', '/'); + } else { + name = Character.toUpperCase(name.charAt(0)) + name.substring(1); + } + + List baseTypes = type.getBaseTypes(); + String[] interfaces = new String[baseTypes.size()]; + for (int i = 0; i < baseTypes.size(); i++) { + Type baseType = (Type) baseTypes.get(i); + interfaces[i] = baseType.getInstanceClass().getName().replace('.', '/'); + } + + cw.visit(V1_5, ACC_PUBLIC + ACC_ABSTRACT + ACC_INTERFACE, name, null, "java/lang/Object", interfaces); + } + + public void visitProperty(Property property) { + String name = property.getName(); + String propertyName = Character.toUpperCase(name.charAt(0)) + name.substring(1); + Class javaType = property.getType().getInstanceClass(); + String desc = org.objectweb.asm.Type.getDescriptor(javaType); + + if (property.isMany()) { + cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "get" + propertyName, "()Ljava/util/List;", null, null).visitEnd(); + } else { + if (boolean.class.equals(javaType)) { + cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "is" + propertyName, "()Z", null, null).visitEnd(); + } else { + cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "get" + propertyName, "()" + desc, null, null).visitEnd(); + } + if (!property.isReadOnly()) { + cw.visitMethod(ACC_PUBLIC + ACC_ABSTRACT, "set" + propertyName, '(' + desc + ")V", null, null).visitEnd(); + } + } + } + + public void visitEnd() { + cw.visitEnd(); + } + + /** + * Return the bytecode for the interface class in a form that can be written + * to disk, added to a JAR file, or passed to a ClassLoader. + * + * @return the bytecode for the SDO Type's interface class + */ + public byte[] getClassData() { + return cw.toByteArray(); + } +} diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/GenerationException.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/GenerationException.java new file mode 100644 index 0000000000..15ff8a7502 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/GenerationException.java @@ -0,0 +1,39 @@ +/** + * + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.codegen; + +/** + * Exception indicating there was a problem with code generation. + * + * @version $Rev$ $Date$ + */ +public abstract class GenerationException extends RuntimeException { + public GenerationException() { + } + + public GenerationException(String message) { + super(message); + } + + public GenerationException(String message, Throwable cause) { + super(message, cause); + } + + public GenerationException(Throwable cause) { + super(cause); + } +} diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGenerator.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGenerator.java new file mode 100644 index 0000000000..64fc52d89a --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGenerator.java @@ -0,0 +1,104 @@ +/** + * + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.codegen; + +import java.io.PrintWriter; +import java.util.List; + +import commonj.sdo.Property; +import commonj.sdo.Type; + +import org.apache.tuscany.sdo.SDOTypeVisitor; + +/** + * Implementation of a generator that will output the source code for a Java interface + * that corresponds to the SDO Type's static properties. + * + * @version $Rev$ $Date$ + */ +public class JavaInterfaceGenerator implements SDOTypeVisitor { + private final PrintWriter writer; + + /** + * Constructor providing the Writer to output the source to. + * + * @param writer where the generated source code will be written to + */ + public JavaInterfaceGenerator(PrintWriter writer) { + this.writer = writer; + } + + public void visitType(Type type) { + String name = type.getName(); + int lastDot = name.lastIndexOf('.'); + if (lastDot != -1) { + writer.print("package "); + writer.print(name.substring(0, lastDot)); + writer.println(';'); + writer.println(); + + name = name.substring(lastDot + 1); + } else { + name = Character.toUpperCase(name.charAt(0)) + name.substring(1); + } + + writer.print("public interface "); + writer.print(name); + List baseTypes = type.getBaseTypes(); + for (int i = 0; i < baseTypes.size(); i++) { + Type baseType = (Type) baseTypes.get(i); + if (i == 0) { + writer.print(" extends "); + } else { + writer.print(", "); + } + writer.print(baseType.getInstanceClass().getName()); + } + + writer.println(" {"); + } + + public void visitProperty(Property property) { + String name = property.getName(); + String propertyName = Character.toUpperCase(name.charAt(0)) + name.substring(1); + String javaType = property.getType().getInstanceClass().getCanonicalName(); + + if (!property.isMany()) { + writer.print(" "); + writer.print(javaType); + writer.print("boolean".equals(javaType) ? " is" : " get"); + writer.print(propertyName); + writer.println("();"); + if (!property.isReadOnly()) { + writer.print(" void set"); + writer.print(propertyName); + writer.print('('); + writer.print(javaType); + writer.println(" value);"); + } + } else { + writer.print(" java.util.List get"); + writer.print(propertyName); + writer.println("();"); + } + } + + public void visitEnd() { + writer.println('}'); + writer.flush(); + } +} \ No newline at end of file diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/NoJavaImplementationException.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/NoJavaImplementationException.java new file mode 100644 index 0000000000..5b9b3742d5 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/NoJavaImplementationException.java @@ -0,0 +1,58 @@ +/** + * + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.codegen; + +import commonj.sdo.Type; + +/** + * Exception that indicates there is no Java mapping for an SDO type. + * + * @version $Rev$ $Date$ + */ +public class NoJavaImplementationException extends GenerationException { + private final Type type; + + /** + * Constructor supplying the Type that did not have a Java implementation. + * A default message is provided of the form "${URI}#${Name}" + * + * @param type the type that did not have a Java implementation. + */ + public NoJavaImplementationException(Type type) { + super(type == null ? null : type.getURI() + "#" + type.getName()); + this.type = type; + } + + /** + * Constructor supplying a message and the Type that did not have a Java implementation. + * + * @param message the message + * @param type the type that did not have a Java implementation. + */ + public NoJavaImplementationException(String message, Type type) { + super(message); + this.type = type; + } + + /** + * Return the type that did not have a Java implementation. + * @return the type that did not have a Java implementation + */ + public Type getType() { + return type; + } +} diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/CopyHelperImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/CopyHelperImpl.java new file mode 100644 index 0000000000..060bd381dc --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/CopyHelperImpl.java @@ -0,0 +1,51 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.helper; + + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.EcoreUtil.Copier; + +import commonj.sdo.DataObject; +import commonj.sdo.helper.CopyHelper; + + +/** + * A helper for copying DataObjects. + */ +public class CopyHelperImpl implements CopyHelper +{ + public DataObject copyShallow(DataObject dataObject) + { + Copier copier = new Copier() + { + protected void copyContainment(EReference eReference, EObject eObject, EObject copyEObject) + { + } + }; + EObject result = copier.copy((EObject)dataObject); + copier.copyReferences(); + return (DataObject)result; + } + + public DataObject copy(DataObject dataObject) + { + return (DataObject)EcoreUtil.copy((EObject)dataObject); + } +} diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DataFactoryImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DataFactoryImpl.java new file mode 100644 index 0000000000..5fcf3fa4c1 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DataFactoryImpl.java @@ -0,0 +1,58 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.helper; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.util.EcoreUtil; + +import commonj.sdo.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.TypeHelper; + +/** + * A Factory for creating DataObjects. + * The created DataObjects are not connected to any other DataObjects. + */ +public class DataFactoryImpl implements DataFactory +{ + protected TypeHelper typeHelper; + + public DataFactoryImpl(TypeHelper typeHelper) + { + this.typeHelper = typeHelper; + } + + public DataObject create(String uri, String typeName) + { + Type type = typeHelper.getType(uri, typeName); + return create(type); + } + + public DataObject create(Class interfaceClass) + { + //TODO more efficient implementation ... this is a really bad one! + Type type = typeHelper.getType(interfaceClass); + return create(type); + } + + public DataObject create(Type type) + { + EClass eClass = (EClass)type; + return (DataObject)EcoreUtil.create(eClass); + } +} diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DataHelperImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DataHelperImpl.java new file mode 100644 index 0000000000..3986fa4be7 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DataHelperImpl.java @@ -0,0 +1,303 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.helper; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; + + +import commonj.sdo.helper.DataHelper; + +/** + * Data helper methods. + */ +public class DataHelperImpl implements DataHelper +{ + /** + * @param dateString - Must comply to the pattern of yyyy-MM-dd'T'HH:mm:ss'.'SSS Z + * @return null if dataString couldn't be parsed + */ + public synchronized Date toDate(String dateString) + { + if (dateString == null) + { + return null; + } + + DateFormat [] DATE_PATTERNS = + { + new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSS Z"), + new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSS"), + new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"), + new SimpleDateFormat("yyyy-MM-dd'T'HH:mm"), + new SimpleDateFormat("yyyy-MM-dd") + }; + + for (int i = 0; i < DATE_PATTERNS.length; ++i) + { + try + { + return DATE_PATTERNS[i].parse(dateString); + } + catch (ParseException parseException) + { + } + } + + return null; + } + + public synchronized Calendar toCalendar(String dateString) + { + if (dateString == null) + { + return null; + } + + Date date = toDate(dateString); + if (date == null) + { + return null; + } + + Calendar calendar = new GregorianCalendar(); + calendar.setTime(date); + + return calendar; + } + + public synchronized Calendar toCalendar(String dateString, Locale locale) + { + if (dateString == null || locale == null) + { + return null; + } + + Date date = toDate(dateString); + if (date == null) + { + return null; + } + + Calendar calendar = new GregorianCalendar(locale); + calendar.setTime(date); + return calendar; + } + + public synchronized String toDateTime(Date date) + { + if (date == null) + { + return null; + } + + SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSS zz"); + + return f.format(date); + } + + public synchronized String toDuration(Date date) + { + if (date == null) + { + return null; + } + + SimpleDateFormat f = new SimpleDateFormat("'P'yyyy'Y' MM'M' dd'D' 'T' HH'H' mm'M' ss'S.'SSS"); + + return f.format(date); + } + + public synchronized String toTime(Date date) + { + if (date == null) + { + return null; + } + + SimpleDateFormat f = new SimpleDateFormat("HH:mm:ss'.'SSS zz"); + + return f.format(date); + } + + public synchronized String toDay(Date date) + { + if (date == null) + { + return null; + } + + SimpleDateFormat f = new SimpleDateFormat("---dd zz"); + + return f.format(date); + } + + public synchronized String toMonth(Date date) + { + if (date == null) + { + return null; + } + + SimpleDateFormat f = new SimpleDateFormat("--MM zz"); + + return f.format(date); + } + + public synchronized String toMonthDay(Date date) + { + if (date == null) + { + return null; + } + + SimpleDateFormat f = new SimpleDateFormat("--MM-dd zz"); + + return f.format(date); + } + + public synchronized String toYear(Date date) + { + if (date == null) + { + return null; + } + + SimpleDateFormat f = new SimpleDateFormat("yyyy zz"); + + return f.format(date); + } + + public synchronized String toYearMonth(Date date) + { + if (date == null) + { + return null; + } + + SimpleDateFormat f = new SimpleDateFormat("yyyy-MM zz"); + + return f.format(date); + } + + public synchronized String toYearMonthDay(Date date) + { + if (date == null) + { + return null; + } + + SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd zz"); + + return f.format(date); + } + + public synchronized String toDateTime(Calendar calendar) + { + if (calendar == null) + { + return null; + } + + return toDateTime(calendar.getTime()); + } + + public synchronized String toDuration(Calendar calendar) + { + if (calendar == null) + { + return null; + } + + return toDuration(calendar.getTime()); + } + + public synchronized String toTime(Calendar calendar) + { + if (calendar == null) + { + return null; + } + + return toTime(calendar.getTime()); + } + + public synchronized String toDay(Calendar calendar) + { + if (calendar == null) + { + return null; + } + + return toDay(calendar.getTime()); + } + + public synchronized String toMonth(Calendar calendar) + { + if (calendar == null) + { + return null; + } + + return toMonth(calendar.getTime()); + } + + public synchronized String toMonthDay(Calendar calendar) + { + if (calendar == null) + { + return null; + } + + return toMonthDay(calendar.getTime()); + } + + public synchronized String toYear(Calendar calendar) + { + if (calendar == null) + { + return null; + } + + return toYear(calendar.getTime()); + } + + public synchronized String toYearMonth(Calendar calendar) + { + if (calendar == null) + { + return null; + } + + return toYearMonth(calendar.getTime()); + } + + public synchronized String toYearMonthDay(Calendar calendar) + { + if (calendar == null) + { + return null; + } + + return toYearMonthDay(calendar.getTime()); + } +} diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/EqualityHelperImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/EqualityHelperImpl.java new file mode 100644 index 0000000000..a31066d598 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/EqualityHelperImpl.java @@ -0,0 +1,67 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.helper; + + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.util.EcoreUtil; + +import commonj.sdo.DataObject; +import commonj.sdo.helper.EqualityHelper; + + +/** + * A helper for comparing DataObjects. + */ +public class EqualityHelperImpl implements EqualityHelper +{ + public boolean equalShallow(DataObject dataObject1, DataObject dataObject2) + { + EcoreUtil.EqualityHelper equalityHelper = new EcoreUtil.EqualityHelper() + { + protected boolean haveEqualFeature(EObject eObject1, EObject eObject2, EStructuralFeature feature) + { + if (feature instanceof EAttribute) + { + boolean eIsSet = eObject1.eIsSet(feature); + if (eIsSet != eObject2.eIsSet(feature) || !haveEqualAttribute(eObject1, eObject2, (EAttribute)feature)) + { + return false; + } + } + return true; + } + + protected boolean equalFeatureMapValues(Object value1, Object value2, EStructuralFeature feature) + { + if (feature instanceof EAttribute) + { + return value1 == null ? value2 == null : value1.equals(value2); + } + return true; + } + }; + return equalityHelper.equals((EObject)dataObject1, (EObject)dataObject2); + } + + public boolean equal(DataObject dataObject1, DataObject dataObject2) + { + return EcoreUtil.equals((EObject)dataObject1, (EObject)dataObject2); + } +} diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/HelperProviderImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/HelperProviderImpl.java new file mode 100644 index 0000000000..d0ece134e3 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/HelperProviderImpl.java @@ -0,0 +1,110 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.helper; + + +import org.apache.tuscany.sdo.helper.CopyHelperImpl; +import org.apache.tuscany.sdo.helper.DataHelperImpl; +import org.apache.tuscany.sdo.helper.EqualityHelperImpl; +import org.apache.tuscany.sdo.util.SDOUtil; + +import commonj.sdo.helper.CopyHelper; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.DataHelper; +import commonj.sdo.helper.EqualityHelper; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; +import commonj.sdo.impl.ExternalizableDelegator.Resolvable; +import commonj.sdo.impl.HelperProvider; + + +/** + * Create and manage all the default helper INSTANCEs + */ +public class HelperProviderImpl extends HelperProvider +{ + protected CopyHelper copyHelper; + + protected DataFactory dataFactory; + + protected DataHelper dataHelper; + + protected EqualityHelper equalityHelper; + + protected TypeHelper typeHelper; + + protected XMLHelper xmlHelper; + + protected XSDHelper xsdHelper; + + public HelperProviderImpl() + { + typeHelper = SDOUtil.createTypeHelper(); + dataFactory = SDOUtil.createDataFactory(typeHelper); + xmlHelper = SDOUtil.createXMLHelper(typeHelper); + xsdHelper = SDOUtil.createXSDHelper(typeHelper); + copyHelper = new CopyHelperImpl(); + equalityHelper = new EqualityHelperImpl(); + dataHelper = new DataHelperImpl(); + } + + public CopyHelper copyHelper() + { + return copyHelper; + } + + public DataFactory dataFactory() + { + return dataFactory; + } + + public DataHelper dataHelper() + { + return dataHelper; + } + + public EqualityHelper equalityHelper() + { + return equalityHelper; + } + + public TypeHelper typeHelper() + { + return typeHelper; + } + + public XMLHelper xmlHelper() + { + return xmlHelper; + } + + public XSDHelper xsdHelper() + { + return xsdHelper; + } + + public Resolvable resolvable() + { + throw new UnsupportedOperationException(); //TODO + } + + public Resolvable resolvable(Object target) + { + throw new UnsupportedOperationException(); //TODO + } +} diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java new file mode 100644 index 0000000000..38c4c962e7 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java @@ -0,0 +1,94 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.helper; + + +import java.util.Iterator; +import java.util.List; + +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.util.ExtendedMetaData; + +import commonj.sdo.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.TypeHelper; + + +/** + * Look up a Type given the uri and typeName or interfaceClass. + * SDO Types are available through the + * getType("commonj.sdo", typeName) method. + * Defines Types from DataObjects. + */ +public class TypeHelperImpl implements TypeHelper +{ + protected ExtendedMetaData extendedMetaData; + + public TypeHelperImpl(ExtendedMetaData extendedMetaData) + { + this.extendedMetaData = extendedMetaData; + } + + public Type getType(String uri, String typeName) + { + EPackage ePackage = extendedMetaData.getPackage(uri); + if (ePackage != null) + { + EClassifier eClassifier = ePackage.getEClassifier(typeName); + if (eClassifier == null) + { + eClassifier = extendedMetaData.getType(ePackage, typeName); + } + return (Type)eClassifier; + } + return null; + } + + public Type getType(Class interfaceClass) + { + //TODO more efficient implementation ... this is a really bad one! + for (Iterator iter = EPackage.Registry.INSTANCE.values().iterator(); iter.hasNext(); ) + { + Object value = iter.next(); + if (value instanceof EPackage) + { + EPackage ePackage = (EPackage)value; + for (Iterator iter2 = ePackage.getEClassifiers().iterator(); iter2.hasNext(); ) + { + EClassifier eClassifier = (EClassifier)iter2.next(); + if (eClassifier.getInstanceClass() == interfaceClass) + { + return (Type)eClassifier; + } + } + } + } + return null; + } + + public Type define(DataObject type) + { + throw new UnsupportedOperationException(); //TODO + } + + public List /*Type*/define(List /*DataObject*/types) + { + throw new UnsupportedOperationException(); //TODO + } + +} diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLDocumentImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLDocumentImpl.java new file mode 100644 index 0000000000..2626eb12ff --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLDocumentImpl.java @@ -0,0 +1,349 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.helper; + + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Reader; +import java.io.Writer; +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.eclipse.emf.common.util.URI; +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.resource.ResourceSet; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.ExtendedMetaData; +import org.eclipse.emf.ecore.xmi.XMLOptions; +import org.eclipse.emf.ecore.xmi.XMLParserPool; +import org.eclipse.emf.ecore.xmi.XMLResource; +import org.eclipse.emf.ecore.xmi.impl.XMLOptionsImpl; +import org.eclipse.emf.ecore.xmi.impl.XMLParserPoolImpl; +import org.xml.sax.InputSource; + +import commonj.sdo.DataObject; +import commonj.sdo.helper.XMLDocument; + + +/** + * Represents an XML Document containing a tree of DataObjects. + * + * An example XMLDocument fragment is: + * + * + * + * created from this XML Schema fragment: + * + * + * + * + * Upon loading this XMLDocument: + * DataObject is an instance of Type PurchaseOrderType. + * RootElementURI is null because the XSD has no targetNamespace URI. + * RootElementName is purchaseOrder. + * Encoding is null because the document did not specify an encoding. + * XMLDeclaration is true because the document contained an XML declaration. + * XMLVersion is 1.0 + * SchemaLocation and noNamespaceSchemaLocation are null because they are + * not specified in the document. + * + * When saving the root element, if the type of the root dataObject is not the + * type of global element specified by rootElementURI and rootElementName, + * or if a global element does not exist for rootElementURI and rootElementName, + * then an xsi:type declaration is written to record the root DataObject's Type. + * + * When loading the root element and an xsi:type declaration is found + * it is used as the type of the root DataObject. In this case, + * if validation is not being performed, it is not an error if the + * rootElementName is not a global element. + */ +public class XMLDocumentImpl implements XMLDocument +{ + protected ExtendedMetaData extendedMetaData; + + protected EObject rootObject; + + protected XMLResource resource; + + protected EStructuralFeature rootElement; + + protected EObject documentRoot; + + protected static XMLParserPool globalXMLParserPool = new XMLParserPoolImpl(); + + //TODO clean up the options thing + protected XMLDocumentImpl(ExtendedMetaData extendedMetaData, Object options) + { + this.extendedMetaData = extendedMetaData; + ResourceSet resourceSet = DataObjectUtil.createResourceSet(); + + if (options instanceof Map) + { + Class resourceFactoryClass = (Class)((Map)options).get("GENERATED_LOADER"); + if (resourceFactoryClass != null) + { + try + { + Object resourceFactory = resourceFactoryClass.newInstance(); + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", resourceFactory); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + } + + resource = (XMLResource)resourceSet.createResource(URI.createURI("http:///temp.xml")); + + XMLOptions xmlOptions = new XMLOptionsImpl(); + xmlOptions.setProcessAnyXML(true); + resource.getDefaultLoadOptions().put(XMLResource.OPTION_XML_OPTIONS, xmlOptions); + + resource.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData); + resource.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData); + + resource.getDefaultLoadOptions().put(XMLResource.OPTION_USE_PARSER_POOL, globalXMLParserPool); + + resource.getDefaultLoadOptions().put(XMLResource.OPTION_USE_DEPRECATED_METHODS, Boolean.FALSE); + + resource.getDefaultSaveOptions().put(XMLResource.OPTION_CONFIGURATION_CACHE, Boolean.TRUE); + resource.getDefaultLoadOptions().put(XMLResource.OPTION_CONFIGURATION_CACHE, Boolean.TRUE); + + resource.getDefaultLoadOptions().put(XMLResource.OPTION_ANY_TYPE, SDOPackage.eINSTANCE.getAnyTypeDataObject()); + resource.getDefaultSaveOptions().put(XMLResource.OPTION_ANY_TYPE, SDOPackage.eINSTANCE.getAnyTypeDataObject()); + + resource.getDefaultLoadOptions().put(XMLResource.OPTION_ANY_SIMPLE_TYPE, SDOPackage.eINSTANCE.getSimpleAnyTypeDataObject()); + resource.getDefaultSaveOptions().put(XMLResource.OPTION_ANY_SIMPLE_TYPE, SDOPackage.eINSTANCE.getSimpleAnyTypeDataObject()); + + //resource.getDefaultLoadOptions().put(XMLResource.OPTION_USE_XML_NAME_TO_FEATURE_MAP, globalHashMap); + + //resource.getDefaultSaveOptions().put(XMLResource.OPTION_FORMATTED, Boolean.FALSE); + } + + protected XMLDocumentImpl(ExtendedMetaData extendedMetaData) + { + this(extendedMetaData, null); + } + + protected XMLDocumentImpl(ExtendedMetaData extendedMetaData, DataObject dataObject, String rootElementURI, String rootElementName) + { + this(extendedMetaData); + + rootObject = (EObject)dataObject; + + rootElement = extendedMetaData.getElement(rootElementURI, rootElementName); + if (rootElement == null) + { + rootElement = ExtendedMetaData.INSTANCE.demandFeature(rootElementURI, rootElementName, true); + } + + EClass documentRootClass = rootElement.getEContainingClass(); + documentRoot = EcoreUtil.create(documentRootClass); + resource.getContents().add(documentRoot); + } + + protected void save(OutputStream outputStream, Object options) throws IOException + { + EObject oldContainer = null; + EReference oldContainmentReference = null; + int oldContainmentIndex = -1; + + if (documentRoot != null) + { + //TODO also check if rootObject is directly contained in a resource + oldContainer = rootObject.eContainer(); + if (oldContainer != null) + { + oldContainmentReference = rootObject.eContainmentFeature(); + } + if (oldContainer != documentRoot || oldContainmentReference != rootElement) + { + if (oldContainmentReference != null && oldContainmentReference.isMany()) + { + oldContainmentIndex = ((List)oldContainer.eGet(oldContainmentReference)).indexOf(rootObject); + } + documentRoot.eSet(rootElement, rootObject); + } + } + + resource.save(outputStream, (Map)options); + + if (oldContainer != null) + { + if (oldContainer != documentRoot || oldContainmentReference != rootElement) + { + if (oldContainmentReference.isMany()) + { + ((List)oldContainer.eGet(oldContainmentReference)).add(oldContainmentIndex, rootObject); + } + else + { + oldContainer.eSet(oldContainmentReference, rootObject); + } + } + } + else if (documentRoot != null) + { + documentRoot.eSet(rootElement, null); + } + } + + protected void save(Writer outputWriter, Object options) throws IOException + { + // TODO temporary brute-force implementation ... to be replaced + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + save(outputStream, options); + outputWriter.write(new String(outputStream.toByteArray())); + } + + protected void load(InputStream inputStream, String locationURI, Object options) throws IOException + { + InputSource inputSource = new InputSource(inputStream); + load(inputSource, locationURI, options); + } + + protected void load(Reader inputReader, String locationURI, Object options) throws IOException + { + InputSource inputSource = new InputSource(inputReader); + load(inputSource, locationURI, options); + } + + protected void load(InputSource inputSource, String locationURI, Object options) throws IOException + { + rootObject = null; + rootElement = null; + documentRoot = null; + + if (locationURI != null) + { + inputSource.setSystemId(locationURI); + resource.setURI(URI.createURI(locationURI)); + } + + resource.load(inputSource, (Map)options); + + if (!resource.getContents().isEmpty()) + { + documentRoot = (EObject)resource.getContents().get(0); + EClass documentRootClass = documentRoot.eClass(); + if ("".equals(extendedMetaData.getName(documentRootClass))) //TODO efficient way to check this? Maybe DataObject.getContainer should also check this? + { + if (!documentRoot.eContents().isEmpty()) + { + rootObject = (EObject)documentRoot.eContents().get(0); + rootElement = rootObject.eContainmentFeature(); + documentRoot.eUnset(rootElement); + } + } + else + { + rootObject = documentRoot; + documentRoot = null; + } + } + } + + public DataObject getRootObject() + { + return (DataObject)rootObject; + } + + public String getRootElementURI() + { + if (rootElement != null) + { + return extendedMetaData.getNamespace(rootElement); + } + else if (rootObject != null) + { + return extendedMetaData.getNamespace(rootObject.eClass()); + } + return null; + } + + public String getRootElementName() + { + if (rootElement != null) + { + return extendedMetaData.getName(rootElement); + } + else if (rootObject != null) + { + return extendedMetaData.getName(rootObject.eClass()); + } + return null; + } + + public String getEncoding() + { + return resource.getEncoding(); + } + + public void setEncoding(String encoding) + { + resource.setEncoding(encoding); + } + + public boolean isXMLDeclaration() + { + return Boolean.FALSE.equals(resource.getDefaultSaveOptions().get(XMLResource.OPTION_DECLARE_XML)); + } + + public void setXMLDeclaration(boolean xmlDeclaration) + { + resource.getDefaultSaveOptions().put(XMLResource.OPTION_DECLARE_XML, xmlDeclaration ? Boolean.TRUE : Boolean.FALSE); + } + + public String getXMLVersion() + { + return "1.0"; //TODO + } + + public void setXMLVersion(String xmlVersion) + { + throw new UnsupportedOperationException(); //TODO + } + + public String getSchemaLocation() + { + throw new UnsupportedOperationException(); //TODO + } + + public void setSchemaLocation(String schemaLocation) + { + throw new UnsupportedOperationException(); //TODO + } + + public String getNoNamespaceSchemaLocation() + { + throw new UnsupportedOperationException(); //TODO + } + + public void setNoNamespaceSchemaLocation(String schemaLocation) + { + throw new UnsupportedOperationException(); //TODO + } +} diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLHelperImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLHelperImpl.java new file mode 100644 index 0000000000..653665e1b8 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLHelperImpl.java @@ -0,0 +1,116 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.helper; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.Reader; +import java.io.StringReader; +import java.io.StringWriter; +import java.io.Writer; + +import org.eclipse.emf.ecore.util.ExtendedMetaData; + +import commonj.sdo.DataObject; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XMLDocument; +import commonj.sdo.helper.XMLHelper; + +/** + * A helper to convert XML documents into DataObects and + * DataObjects into XML documnets. + */ +public class XMLHelperImpl implements XMLHelper +{ + ExtendedMetaData extendedMetaData; + + public XMLHelperImpl(ExtendedMetaData extendedMetaData) + { + this.extendedMetaData = extendedMetaData; + } + + public XMLHelperImpl(TypeHelper typeHelper) + { + this.extendedMetaData = ((TypeHelperImpl)typeHelper).extendedMetaData; + } + + public XMLDocument load(String inputString) + { + try + { + return load(new StringReader(inputString), null, null); + } + catch (IOException e) + { + throw new RuntimeException(e); // should never happen + } + } + + public XMLDocument load(InputStream inputStream) throws IOException + { + return load(inputStream, null, null); + } + + public XMLDocument load(InputStream inputStream, String locationURI, Object options) throws IOException + { + XMLDocumentImpl document = new XMLDocumentImpl(extendedMetaData, options); + document.load(inputStream, locationURI, options); + return document; + } + + public XMLDocument load(Reader inputReader, String locationURI, Object options) throws IOException + { + XMLDocumentImpl document = new XMLDocumentImpl(extendedMetaData, options); + document.load(inputReader, locationURI, options); + return document; + } + + public String save(DataObject dataObject, String rootElementURI, String rootElementName) + { + StringWriter stringWriter = new StringWriter(); + try + { + save(createDocument(dataObject, rootElementURI, rootElementName), stringWriter, null); + return stringWriter.toString(); + } + catch (IOException e) + { + throw new RuntimeException(e); // should never happen + } + } + + public void save(DataObject dataObject, String rootElementURI, String rootElementName, OutputStream outputStream) throws IOException + { + save(createDocument(dataObject, rootElementURI, rootElementName), outputStream, null); + } + + public void save(XMLDocument xmlDocument, OutputStream outputStream, Object options) throws IOException + { + ((XMLDocumentImpl)xmlDocument).save(outputStream, options); + } + + public void save(XMLDocument xmlDocument, Writer outputWriter, Object options) throws IOException + { + ((XMLDocumentImpl)xmlDocument).save(outputWriter, options); + } + + public XMLDocument createDocument(DataObject dataObject, String rootElementURI, String rootElementName) + { + return new XMLDocumentImpl(extendedMetaData, dataObject, rootElementURI, rootElementName); + } +} diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XSDHelperImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XSDHelperImpl.java new file mode 100644 index 0000000000..3173601861 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XSDHelperImpl.java @@ -0,0 +1,273 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.helper; + + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.Reader; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.tuscany.sdo.impl.DynamicDataObjectImpl; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EModelElement; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.ExtendedMetaData; +import org.eclipse.xsd.XSDConcreteComponent; +import org.eclipse.xsd.XSDSchema; +import org.eclipse.xsd.XSDTypeDefinition; +import org.eclipse.xsd.ecore.XSDEcoreBuilder; +import org.eclipse.xsd.util.XSDResourceImpl; +import org.w3c.dom.Element; +import org.xml.sax.InputSource; + +import commonj.sdo.Property; +import commonj.sdo.Type; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XSDHelper; + + +/** + * Provides access to additional information when the + * Type or Property is defined by an XML Schema (XSD). + * Methods return null/false otherwise or if the information is unavailable. + * Defines Types from an XSD. + */ +public class XSDHelperImpl implements XSDHelper +{ + private XSDEcoreBuilder ecoreBuilder; + + private ExtendedMetaData extendedMetaData; + + public XSDHelperImpl(ExtendedMetaData extendedMetaData) + { + this.extendedMetaData = extendedMetaData; + ecoreBuilder = new SDOXSDEcoreBuilder(extendedMetaData); + } + + public XSDHelperImpl(TypeHelper typeHelper) + { + this(((TypeHelperImpl)typeHelper).extendedMetaData); + } + + public String getLocalName(Type type) + { + return extendedMetaData.getName((EClassifier)type); + } + + public String getLocalName(Property property) + { + return extendedMetaData.getName((EStructuralFeature)property); + } + + public String getNamespaceURI(Property property) + { + return extendedMetaData.getNamespace((EStructuralFeature)property); + } + + public boolean isAttribute(Property property) + { + return extendedMetaData.getFeatureKind((EStructuralFeature)property) == ExtendedMetaData.ATTRIBUTE_FEATURE; + } + + public boolean isElement(Property property) + { + return extendedMetaData.getFeatureKind((EStructuralFeature)property) == ExtendedMetaData.ELEMENT_FEATURE; + } + + public boolean isMixed(Type type) + { + if (type instanceof EClass) + { + return extendedMetaData.getContentKind((EClass)type) == ExtendedMetaData.MIXED_CONTENT; + } + else + { + return false; + } + } + + public boolean isXSD(Type type) + { + return ((EModelElement)type).getEAnnotation(ExtendedMetaData.ANNOTATION_URI) != null; + } + + public Property getGlobalProperty(String uri, String propertyName, boolean isElement) + { + if (isElement) + { + return (Property)extendedMetaData.getElement(uri, propertyName); + } + else + { + return (Property)extendedMetaData.getAttribute(uri, propertyName); + } + } + + public String getAppinfo(Type type, String source) + { + return getAppinfo((EModelElement)type, source); + } + + public String getAppinfo(Property property, String source) + { + return getAppinfo((EModelElement)property, source); + } + + protected String getAppinfo(EModelElement eModelElement, String source) + { + return (String)eModelElement.getEAnnotation(source).getDetails().get("appinfo"); + } + + public List /*Type*/define(String xsd) + { + InputStream inputStream = new ByteArrayInputStream(xsd.getBytes()); + return define(inputStream, "*.xsd"); + + } + + public List /*Type*/define(Reader xsdReader, String schemaLocation) + { + + InputSource inputSource = new InputSource(xsdReader); + return define(inputSource, schemaLocation); + + } + + public List /*Type*/define(InputStream xsdInputStream, String schemaLocation) + { + InputSource inputSource = new InputSource(xsdInputStream); + return define(inputSource, schemaLocation); + } + + protected List /*Type*/define(InputSource inputSource, String schemaLocation) + { + try + { + ResourceSet resourceSet = DataObjectUtil.createResourceSet(); + Resource model = resourceSet.createResource(URI.createURI(schemaLocation != null ? schemaLocation : "null.xsd")); + ((XSDResourceImpl)model).load(inputSource, null); + XSDSchema schema = (XSDSchema)model.getContents().get(0); + + // If define() is called more than once for the same XMLSchema, return the existing defined types + //FIXME ... need to rethink this design + //if (!ecoreBuilder.getTargetNamespaceToEPackageMap().containsKey(schema.getTargetNamespace())) + // also return generated types registered via SDOUtil.registerStaticTypes() + EPackage ePackage = extendedMetaData.getPackage(schema.getTargetNamespace()); + if (ePackage == null) + { + ecoreBuilder.generate(schema); + Collection newEPackages = ecoreBuilder.getTargetNamespaceToEPackageMap().values(); + + for (Iterator iter = newEPackages.iterator(); iter.hasNext();) + { + EPackage currentPackage = (EPackage)iter.next(); + currentPackage.setEFactoryInstance(new DynamicDataObjectImpl.FactoryImpl()); + EcoreUtil.freeze(currentPackage); + } + } + ePackage = extendedMetaData.getPackage(schema.getTargetNamespace()); + return ePackage.getEClassifiers(); + } + catch (Exception e) + { + throw new IllegalArgumentException(); + } + } + + public String generate(List /*Type*/types) + { + throw new UnsupportedOperationException(); //TODO + } + + public String generate(List /*Type*/types, Map /*String, String*/namespaceToSchemaLocation) + { + throw new UnsupportedOperationException(); //TODO + } + + protected static class SDOXSDEcoreBuilder extends XSDEcoreBuilder + { + public SDOXSDEcoreBuilder(ExtendedMetaData extendedMetaData) + { + super(extendedMetaData); + } + + protected String getEcoreAttribute(Element element, String attribute) + { + String sdoAttribute = null; + + if ("name".equals(attribute)) + sdoAttribute = "name"; + else if ("opposite".equals(attribute)) + sdoAttribute = "oppositeProperty"; + else if ("mixed".equals(attribute)) + sdoAttribute = "sequence"; + + if (sdoAttribute != null) + { + return + element != null && element.hasAttributeNS("commonj.sdo/xml", sdoAttribute) ? + element.getAttributeNS("commonj.sdo/xml", sdoAttribute) : + null; + } + + if ("package".equals(attribute)) + sdoAttribute = "package"; + else if ("instanceClass".equals(attribute)) + sdoAttribute = "instanceClass"; + + if (sdoAttribute != null) + { + return + element != null && element.hasAttributeNS("commonj.sdo/java", sdoAttribute) ? + element.getAttributeNS("commonj.sdo/java", sdoAttribute) : + null; + } + + return super.getEcoreAttribute(element, attribute); + } + + protected XSDTypeDefinition getEcoreTypeQNameAttribute(XSDConcreteComponent xsdConcreteComponent, String attribute) + { + String sdoAttribute = null; + + if ("reference".equals(attribute)) sdoAttribute = "propertyType"; + + if (sdoAttribute != null) + { + Element element = xsdConcreteComponent.getElement(); + return element == null ? null : getEcoreTypeQNameAttribute(xsdConcreteComponent, element, "commonj.sdo/xml", sdoAttribute); + } + + return super.getEcoreTypeQNameAttribute(xsdConcreteComponent, attribute); + } + + } + +} diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/AnyTypeDataObjectImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/AnyTypeDataObjectImpl.java new file mode 100644 index 0000000000..a1bb922d69 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/AnyTypeDataObjectImpl.java @@ -0,0 +1,296 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.impl; + +import 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; + +/** + * + * An implementation of the model object 'EData Object Any Type'. + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.apache.tuscany.sdo.impl.AnyTypeDataObjectImpl#getMixed Mixed}
  • + *
  • {@link org.apache.tuscany.sdo.impl.AnyTypeDataObjectImpl#getAny Any}
  • + *
  • {@link org.apache.tuscany.sdo.impl.AnyTypeDataObjectImpl#getAnyAttribute Any Attribute}
  • + *
+ *

+ * + * @generated + */ +public class AnyTypeDataObjectImpl extends DataObjectImpl implements AnyTypeDataObject +{ + /** + * The cached value of the '{@link #getMixed() Mixed}' attribute list. + * + * + * @see #getMixed() + * @generated + * @ordered + */ + protected FeatureMap mixed = null; + + /** + * The cached value of the '{@link #getAnyAttribute() Any Attribute}' attribute list. + * + * + * @see #getAnyAttribute() + * @generated + * @ordered + */ + protected FeatureMap anyAttribute = null; + + /** + * + * + * @generated + */ + protected AnyTypeDataObjectImpl() + { + super(); + } + + /** + * + * + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getAnyTypeDataObject(); + } + + /** + * + * + * @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; + } + + /** + * + * + * @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(); + } + + /** + * + * + * @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; + } + + /** + * + * + * @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); + } + + /** + * + * + * @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); + } + + /** + * + * + * @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); + } + + /** + * + * + * @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); + } + + /** + * + * + * @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); + } + + /** + * + * + * @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); + } + + /** + * + * + * @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); + } + + /** + * + * + * @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/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/AttributeImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/AttributeImpl.java new file mode 100644 index 0000000000..415787f1e8 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/AttributeImpl.java @@ -0,0 +1,163 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.impl; + +import java.util.List; + +//import org.apache.tuscany.sdo.SDOPackage; + +import org.apache.tuscany.sdo.util.BasicSequence; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.EAttributeImpl; +import org.eclipse.emf.ecore.util.FeatureMap; + +import commonj.sdo.Property; +import commonj.sdo.Type; + +/** + * + * An implementation of the model object 'Attribute'. + * + *

+ *

+ * + * @generated + */ +public class AttributeImpl extends EAttributeImpl implements Property +{ + /** + * + * + * @generated + */ + protected AttributeImpl() + { + super(); + } + + /** + * + * + * @generated NOT + */ + protected EClass eStaticClass() + { + return EcorePackage.eINSTANCE.getEAttribute(); + } + + /** + * + * + * @generated NOT + */ + public Object getDefault() + { + return getDefaultValue(); + } + + /** + * + * + * @generated NOT + */ + public boolean isReadOnly() + { + //return "true".equals(EcoreUtil.getAnnotation(this, "commonj.sdo", "readOnly")); + return !isChangeable(); //TODO semantics don't exactly match? + } + + protected List aliasNames = null; + + /** + * + * + * @generated NOT + */ + public List getAliasNames() + { + if (aliasNames == null) + { + aliasNames = DataObjectUtil.getAliasNames(this); + } + return aliasNames; + } + + /** + * + * + * @generated NOT + */ + public Type getType() + { + return (Type)getEType(); + } + + /** + * + * + * @generated NOT + */ + public Type getContainingType() + { + return (Type)getEContainingClass(); + } + + /** + * + * + * @generated NOT + */ + public Property getOpposite() + { + return null; + } + + /** + * + * + * @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; + } + } + +} //AttributeImpl diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummaryImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummaryImpl.java new file mode 100644 index 0000000000..9c749ff598 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummaryImpl.java @@ -0,0 +1,692 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.impl; + + +import java.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.EClass; +import org.eclipse.emf.ecore.EObject; +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.DelegatingFeatureMap; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.FeatureMapUtil; +import org.eclipse.emf.ecore.util.InternalEList; + +import commonj.sdo.ChangeSummary; +//import commonj.sdo.ChangeSummary.Setting; + +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Sequence; + + +/** + * + * An implementation of the model object 'EChange Summary'. + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.apache.tuscany.sdo.impl.ChangeSummaryImpl#getEDataGraph EData Graph}
  • + *
+ *

+ * + * @generated + */ +public class ChangeSummaryImpl extends ChangeDescriptionImpl implements ChangeSummary +{ + /** + * The cached value of the '{@link #getEDataGraph() EData Graph}' reference. + * + * + * @see #getEDataGraph() + * @generated + * @ordered + */ + protected DataGraph eDataGraph = null; + + protected ChangeRecorder changeRecorder = null; + protected EList cachedObjectsToDetach = null; + protected HashMap cachedSDOObjectChanges = new HashMap(); + + /** + * + * + * @generated + */ + protected ChangeSummaryImpl() + { + super(); + } + + /** + * + * + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getChangeSummary(); + } + + /** + * + * + * @generated NOT + */ + public boolean isLogging() + { + return changeRecorder != null; + } + + /** + * + * + * @generated + */ + public DataGraph getEDataGraph() + { + return eDataGraph; + } + + /** + * + * + * @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; + } + + /** + * + * + * @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)); + } + + /** + * + * + * @generated NOT + */ + public void beginLogging() + { + if (isLogging()) + { + throw new IllegalStateException("Already logging"); + } + + getObjectsToAttach().clear(); + getObjectChanges().clear(); + getResourceChanges().clear(); + + oldContainmentInformation = null; + changeRecorder = new SDOChangeRecorder(); + changeRecorder.beginRecording(Collections.singleton(((DataGraphImpl)getEDataGraph()).getRootResource())); +// if (eNotificationRequired()) +// eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.ECHANGE_SUMMARY__LOGGING, false, true)); + } + + /** + * + * + * @generated NOT + */ + public void resumeLogging() + { + if (isLogging()) + { + throw new IllegalStateException("Already logging"); + } + + oldContainmentInformation = null; + + changeRecorder = new SDOChangeRecorder(); + changeRecorder.beginRecording(this, Collections.singleton(((DataGraphImpl)getEDataGraph()).getRootResource())); + +// if (eNotificationRequired()) +// eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.ECHANGE_SUMMARY__LOGGING, false, true)); + } + + /** + * + * + * @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); + } + + /** + * + * + * @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); + } + + /** + * + * + * @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(); + } + return eDynamicGet(featureID, resolve, coreType); + } + + /** + * + * + * @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); + } + + /** + * + * + * @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); + } + + /** + * + * + * @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 class SDOChangeRecorder extends ChangeRecorder + { + public SDOChangeRecorder() + { + super(); + } + + public void beginRecording(ChangeDescription changeDescription, Collection rootObjects) + { + deletedObjects = null; + cachedObjectsToDetach = null; + cachedSDOObjectChanges.clear(); + 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() + { + deletedObjects = null; + cachedObjectsToDetach = null; + cachedSDOObjectChanges.clear(); + super.consolidateChanges(); + } + + protected void addAdapter(Notifier notifier) + { + 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); + } + + } + + /** + * + * + * @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)); + } + + /** + * + * + * @generated NOT + */ + public boolean isCreated(DataObject dataObject) + { + return getObjectsToDetach().contains(dataObject); + } + + /** + * + * + * @generated NOT + */ + public boolean isDeleted(DataObject dataObject) + { + return getDeletedObjects().contains(dataObject); + } + + /** + * + * + * @generated NOT + */ + public List getOldValues(DataObject dataObject) + { + List sdoSettings = (List)cachedSDOObjectChanges.get(dataObject); + if (sdoSettings != null) + { + return sdoSettings; + } + + 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; + } + + /** + * + * + * @generated + */ + public boolean isModified(DataObject dataObject) + { + // TODO: implement this method + // Ensure that you remove @generated or mark it @generated NOT + throw new UnsupportedOperationException(); + } + + /** + * + * + * @generated NOT + */ + public void summarize() + { + if (!isLogging()) + { + throw new IllegalStateException("Not currently logging"); + } + + changeRecorder.summarize(); + } + + public boolean isChanged(DataObject dataObject) + { + return getObjectChanges().containsKey(dataObject) && !isDeleted(dataObject) && !isCreated(dataObject); + } + + 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); + } + + /** + * + * + * @generated + */ + public Sequence getOldSequence(DataObject dataObject) + { + // TODO: implement this method + // Ensure that you remove @generated or mark it @generated NOT + throw new UnsupportedOperationException(); + } + + /** + * + * + * @generated + */ + public void undoChanges() + { + // TODO: implement this method + // Ensure that you remove @generated or mark it @generated NOT + throw new UnsupportedOperationException(); + } + + public EList getObjectsToDetach() + { + if (cachedObjectsToDetach == null) + { + cachedObjectsToDetach = super.getObjectsToDetach(); + } + return cachedObjectsToDetach; + } + + /** + * + * + * @generated NOT + */ + public DataGraph getDataGraph() + { + return getEDataGraph(); + } + + /** + * + * + * @generated + */ + public List getChangedObjects() + { + // TODO: implement this method + // Ensure that you remove @generated or mark it @generated NOT + throw new UnsupportedOperationException(); + } + + protected Set deletedObjects; + + protected void preApply(boolean reverse) + { + super.preApply(reverse); + deletedObjects = null; + } + + protected Set getDeletedObjects() + { + if (deletedObjects == null) + { + deletedObjects = new HashSet(); + for (Iterator i = EcoreUtil.getAllContents(getObjectsToAttach()); i.hasNext(); ) + { + deletedObjects.add(i.next()); + } + } + return deletedObjects; + } + + /** + * + * + * @generated NOT + */ + public EList getChangedDataObjectsGen() + { + EList result = new UniqueEList.FastCompare(getDeletedObjects()); + result.addAll(getObjectsToDetach()); + for (Iterator i = getObjectChanges().iterator(); i.hasNext(); ) + { + Map.Entry entry = (Map.Entry)i.next(); + result.add(entry.getKey()); + } + return result; + } + + public List getChangedDataObjects() + { + return getChangedDataObjectsGen(); + } + + /** + * + * + * @generated + */ + public DataObject getRootObject() + { + // TODO: implement this method + // Ensure that you remove @generated or mark it @generated NOT + throw new UnsupportedOperationException(); + } + +} //EChangeSummaryImpl diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummarySettingImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummarySettingImpl.java new file mode 100644 index 0000000000..9f714b9cfa --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummarySettingImpl.java @@ -0,0 +1,110 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.impl; + + +import java.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; +/** + * + * An implementation of the model object 'EChange Summary Setting'. + * + *

+ *

+ * + * @generated + */ +public class ChangeSummarySettingImpl extends FeatureChangeImpl implements ChangeSummary.Setting +{ + /** + * + * + * @generated + */ + protected ChangeSummarySettingImpl() + { + super(); + } + + protected ChangeSummarySettingImpl(EStructuralFeature feature, Object value, boolean isSet) + { + super(feature, value, isSet); + } + + /** + * + * + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getChangeSummarySetting(); + } + + /** + * + * + * @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(); + } + } + + /** + * + * + * @generated NOT + */ + public Property getProperty() + { + return (Property)getFeature(); + } + + /** + * + * + * @generated NOT + */ + public boolean isSet() + { + return super.isSet(); + } + +} //EChangeSummarySettingImpl diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ClassImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ClassImpl.java new file mode 100644 index 0000000000..a56c5f9fb2 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ClassImpl.java @@ -0,0 +1,192 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.impl; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.eclipse.emf.ecore.EClass; +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.ExtendedMetaData; + +import commonj.sdo.Property; +import commonj.sdo.Type; + +/** + * + * An implementation of the model object 'Class'. + * + *

+ *

+ * + * @generated + */ +public class ClassImpl extends EClassImpl implements Type +{ + /** + * + * + * @generated + */ + protected ClassImpl() + { + super(); + } + + /** + * + * + * @generated NOT + */ + protected EClass eStaticClass() + { + return EcorePackage.eINSTANCE.getEClass(); + } + + /** + * + * + * @generated NOT + */ + public String getURI() + { + return getEPackage().getNsURI(); + } + + /** + * + * + * @generated NOT + */ + public boolean isDataType() + { + return false; + } + + /** + * + * + * @generated NOT + */ + public boolean isOpen() + { + for (int i = 0, count = getFeatureCount(); i < count; ++i) + { + EStructuralFeature eStructuralFeature = getEStructuralFeature(i); + switch (ExtendedMetaData.INSTANCE.getFeatureKind(eStructuralFeature)) + { + case ExtendedMetaData.ELEMENT_WILDCARD_FEATURE: + case ExtendedMetaData.ATTRIBUTE_WILDCARD_FEATURE: + case ExtendedMetaData.GROUP_FEATURE: + return true; + } + } + return false; + } + + /** + * + * + * @generated NOT + */ + public boolean isSequenced() + { + // isSequenced == isMixed + return ExtendedMetaData.INSTANCE.getMixedFeature(this) != null; + } + + protected List aliasNames = null; + + /** + * + * + * @generated NOT + */ + public List getAliasNames() + { + if (aliasNames == null) + { + aliasNames = DataObjectUtil.getAliasNames(this); + } + return aliasNames; + } + + /** + * + * + * @generated NOT + */ + public List getDeclaredProperties() + { + return getEStructuralFeatures(); + } + + /** + * + * + * @generated NOT + */ + public List getProperties() + { + return getEAllStructuralFeatures(); + } + + /** + * + * + * @generated NOT + */ + public List getBaseTypes() + { + return getESuperTypes(); + } + + /** + * + * + * @generated NOT + */ + public Property getProperty(String propertyName) + { + if (propertyNameToPropertyMap == null) //FB use eNameToFeatureMap for this? + { + 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; + } + + return (Property)propertyNameToPropertyMap.get(propertyName); + } + + protected Map propertyNameToPropertyMap; + +} //ClassTypeImpl diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataGraphImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataGraphImpl.java new file mode 100644 index 0000000000..725c0211dc --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataGraphImpl.java @@ -0,0 +1,816 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.impl; + + +import java.io.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 java.util.Map; + +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.SDOPackage; +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.notify.impl.AdapterImpl; +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; + + +/** + * + * An implementation of the model object 'EData Graph'. + * @extends DataGraph, Adapter, Serializable + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.apache.tuscany.sdo.impl.DataGraphImpl#getResourceSet Resource Set}
  • + *
  • {@link org.apache.tuscany.sdo.impl.DataGraphImpl#getRootResource Root Resource}
  • + *
  • {@link org.apache.tuscany.sdo.impl.DataGraphImpl#getEChangeSummary EChange Summary}
  • + *
  • {@link org.apache.tuscany.sdo.impl.DataGraphImpl#getERootObject ERoot Object}
  • + *
+ *

+ * + * @generated + */ +public class DataGraphImpl extends EObjectImpl implements DataGraph, Adapter, Serializable +{ + /** + * The default value of the '{@link #getResourceSet() Resource Set}' attribute. + * + * + * @see #getResourceSet() + * @generated + * @ordered + */ + protected static final ResourceSet RESOURCE_SET_EDEFAULT = null; + + /** + * The cached value of the '{@link #getResourceSet() Resource Set}' attribute. + * + * + * @see #getResourceSet() + * @generated + * @ordered + */ + protected ResourceSet resourceSet = RESOURCE_SET_EDEFAULT; + + /** + * The default value of the '{@link #getRootResource() Root Resource}' attribute. + * + * + * @see #getRootResource() + * @generated + * @ordered + */ + protected static final Resource ROOT_RESOURCE_EDEFAULT = null; + + /** + * The cached value of the '{@link #getEChangeSummary() EChange Summary}' reference. + * + * + * @see #getEChangeSummary() + * @generated + * @ordered + */ + protected ChangeSummary eChangeSummary = null; + + /** + * The cached value of the '{@link #getERootObject() ERoot Object}' reference. + * + * + * @see #getERootObject() + * @generated + * @ordered + */ + protected EObject eRootObject = null; + + /** + * The cached extended metadata to wrap the resource set's package registry. + */ + protected ExtendedMetaData extendedMetaData; + + /** + * + * + * @generated + */ + protected DataGraphImpl() + { + super(); + } + + /** + * + * + * @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; + } + + /** + * + * + * @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); + } + } + + /** + * + * + * @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); + } + + /** + * + * + * @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; + } + + /** + * + * + * @generated + */ + public ChangeSummary getEChangeSummary() + { + return eChangeSummary; + } + + /** + * + * + * @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; + } + + /** + * + * + * @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)); + } + + /** + * + * + * @generated + */ + public EObject getERootObject() + { + return eRootObject; + } + + /** + * + * + * @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); + } + } + } + + /** + * + * + * @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; + } + } + + /** + * + * + * @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); + } + + /** + * + * + * @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); + } + + /** + * + * + * @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); + } + + /** + * + * + * @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); + } + + /** + * + * + * @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); + } + + /** + * + * + * @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); + } + + /** + * + * + * @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) + { + DataObject dataObject = DataObjectUtil.create(getType(namespaceURI, typeName)); + setERootObject((EObject)dataObject); + return dataObject; + } + + public DataObject createRootObject(Type type) + { + 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")); + resource.load(new ByteArrayInputStream(bytes), null); + 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); + } + } + + /** + * + * + * @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/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectImpl.java new file mode 100644 index 0000000000..a815d28e4d --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectImpl.java @@ -0,0 +1,1705 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.impl; + + +import java.io.InvalidObjectException; +import java.io.ObjectStreamException; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +//import org.apache.sdo.util.SDOUtil; + +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.impl.ChangeSummaryImpl.SDOChangeRecorder; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.common.util.UniqueEList; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.EStructuralFeature.Internal.DynamicValueHolder; +import org.eclipse.emf.ecore.impl.BasicEObjectImpl; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.util.BasicExtendedMetaData; +import org.eclipse.emf.ecore.util.EContentsEList; +import org.eclipse.emf.ecore.util.ECrossReferenceEList; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.ecore.util.FeatureMapUtil; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Sequence; +import commonj.sdo.Type; + + +/** + * + * Base implementation of the SDO DataObject interface. This implementation allocates the minimum storage + * overhead needed for SDO. It provides a complete implementation of the API, but does not, however, allocate + * any storage for the actual properties of the data object. It instead requires subclasses for this purpose. + * The subclass, DynamicDataObjectImpl serves as a concrete implementation class for dynamic data objects. + * Static data object storage is provided by generated classes, which also directly or indirectly derive from + * this class. + * + *

+ *

+ * + * @generated + */ +public abstract class DataObjectImpl extends BasicEObjectImpl implements DataObject +{ + protected InternalEObject eContainer; + protected int eContainerFeatureID; + protected SDOChangeRecorder changeRecorder; + protected Object location; // Resource.Internal (if object is directly contained in a resource) or URI (if it is a proxy) + + /** + * + * + * @generated + */ + protected DataObjectImpl() + { + super(); + } + + /** + * + * + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getDataObject(); + } + + /** + * + * + * @generated NOT + */ + public Object writeReplace() throws ObjectStreamException + { + //TODO implement this method properly + DataGraph dataGraph = getDataGraph(); + if (dataGraph != null) + { + return ((DataGraphImpl)dataGraph).getWriteReplacement(this); + } + else + { + throw new InvalidObjectException("The object must be in a datagraph to be serialized " + this); + } + } + + /** + * + * + * @generated NOT + */ + public Object get(String path) + { + Property property = getType().getProperty(path); + if (property != null) + { + return get(property); + } + else + { + return DataObjectUtil.Accessor.create(this, path).getAndRecyle(); + } + } + + /** + * + * + * @generated NOT + */ + public void set(String path, Object value) + { + Property property = getType().getProperty(path); + if (property != null) + { + set(property, value); + } + else + { + DataObjectUtil.Accessor.create(this, path).setAndRecyle(value); + } + } + + /** + * + * + * @generated NOT + */ + public boolean isSet(String path) + { + Property property = getType().getProperty(path); + if (property != null) + { + return isSet(property); + } + else + { + return DataObjectUtil.Accessor.create(this, path).isSetAndRecyle(); + } + } + + /** + * + * + * @generated NOT + */ + public void unset(String path) + { + Property property = getType().getProperty(path); + if (property != null) + { + unset(property); + } + else + { + DataObjectUtil.Accessor.create(this, path).unsetAndRecyle(); + } + } + + /** + * + * + * @generated NOT + */ + public Object get(int propertyIndex) + { + return eGet(propertyIndex, true, false); + } + + /** + * + * + * @generated NOT + */ + public void set(int propertyIndex, Object value) + { + eSet(propertyIndex, value); + } + + /** + * + * + * @generated NOT + */ + public boolean isSet(int propertyIndex) + { + return eIsSet(propertyIndex); + } + + /** + * + * + * @generated NOT + */ + public void unset(int propertyIndex) + { + eUnset(propertyIndex); + } + + /** + * + * + * @generated NOT + */ + public Object get(Property property) + { + return eGet((EStructuralFeature)property, true, false); + } + + /** + * + * + * @generated NOT + */ + public void set(Property property, Object value) + { + eSet((EStructuralFeature)property, value); + } + + /** + * + * + * @generated NOT + */ + public boolean isSet(Property property) + { + return eIsSet((EStructuralFeature)property); + } + + /** + * + * + * @generated NOT + */ + public void unset(Property property) + { + eUnset((EStructuralFeature)property); + } + + /** + * + * + * @generated NOT + */ + public DataObject getContainer() + { + return (DataObject)eContainer(); + } + + /** + * + * + * @generated NOT + */ + public Property getContainmentProperty() + { + return (Property)eContainmentFeature(); + } + + /** + * + * + * @generated NOT + */ + public DataGraph getDataGraph() + { + Resource resource = eResource(); + if (resource != null) + { + ResourceSet resourceSet = resource.getResourceSet(); + if (resourceSet != null) + { + return (DataGraphImpl)EcoreUtil.getAdapter(resourceSet.eAdapters(), DataGraph.class); + } + } + return null; + } + + /** + * + * + * @generated NOT + */ + public Type getType() + { + return (Type)eClass(); + } + + /** + * + * + * @generated NOT + */ + public BigDecimal getBigDecimal(String path) + { + return DataObjectUtil.getBigDecimal(get(path)); + } + + /** + * + * + * @generated NOT + */ + public BigInteger getBigInteger(String path) + { + return DataObjectUtil.getBigInteger(get(path)); + } + + /** + * + * + * @generated NOT + */ + public boolean getBoolean(String path) + { + return DataObjectUtil.getBoolean(get(path)); + } + + /** + * + * + * @generated NOT + */ + public byte getByte(String path) + { + return DataObjectUtil.getByte(get(path)); + } + + /** + * + * + * @generated NOT + */ + public byte[] getBytes(String path) + { + return DataObjectUtil.getBytes(get(path)); + } + + /** + * + * + * @generated NOT + */ + public char getChar(String path) + { + return DataObjectUtil.getChar(get(path)); + } + + /** + * + * + * @generated NOT + */ + public DataObject getDataObject(String path) + { + return (DataObject)get(path); + } + + /** + * + * + * @generated NOT + */ + public Date getDate(String path) + { + return DataObjectUtil.getDate(get(path)); + } + + /** + * + * + * @generated NOT + */ + public double getDouble(String path) + { + return DataObjectUtil.getDouble(get(path)); + } + + /** + * + * + * @generated NOT + */ + public float getFloat(String path) + { + return DataObjectUtil.getFloat(get(path)); + } + + /** + * + * + * @generated NOT + */ + public int getInt(String path) + { + return DataObjectUtil.getInt(get(path)); + } + + /** + * + * + * @generated NOT + */ + public List getList(String path) + { + return (List)get(path); + } + + /** + * + * + * @generated NOT + */ + public long getLong(String path) + { + return DataObjectUtil.getLong(get(path)); + } + + /** + * + * + * @generated NOT + */ + public Sequence getSequence(String path) + { + return (Sequence)get(path); + } + + /** + * + * + * @generated NOT + */ + public short getShort(String path) + { + return DataObjectUtil.getShort(get(path)); + } + + /** + * + * + * @generated NOT + */ + public String getString(String path) + { + return DataObjectUtil.getString(get(path)); + } + + /** + * + * + * @generated NOT + */ + public void setBigDecimal(String path, BigDecimal value) + { + Property property = getType().getProperty(path); + if (property != null) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create(this, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + /** + * + * + * @generated NOT + */ + public void setBigInteger(String path, BigInteger value) + { + Property property = getType().getProperty(path); + if (property != null) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create(this, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + /** + * + * + * @generated NOT + */ + public void setBoolean(String path, boolean value) + { + Property property = getType().getProperty(path); + if (property != null) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create(this, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + /** + * + * + * @generated NOT + */ + public void setByte(String path, byte value) + { + Property property = getType().getProperty(path); + if (property != null) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create(this, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + /** + * + * + * @generated NOT + */ + public void setBytes(String path, byte[] value) + { + Property property = getType().getProperty(path); + if (property != null) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create(this, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + /** + * + * + * @generated NOT + */ + public void setChar(String path, char value) + { + Property property = getType().getProperty(path); + if (property != null) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create(this, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + /** + * + * + * @generated NOT + */ + public void setDataObject(String path, DataObject value) + { + set(path, value); + } + + /** + * + * + * @generated NOT + */ + public void setDate(String path, Date value) + { + Property property = getType().getProperty(path); + if (property != null) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create(this, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + /** + * + * + * @generated NOT + */ + public void setDouble(String path, double value) + { + Property property = getType().getProperty(path); + if (property != null) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create(this, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + /** + * + * + * @generated NOT + */ + public void setFloat(String path, float value) + { + Property property = getType().getProperty(path); + if (property != null) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create(this, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + /** + * + * + * @generated NOT + */ + public void setInt(String path, int value) + { + Property property = getType().getProperty(path); + if (property != null) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create(this, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + /** + * + * + * @generated NOT + */ + public void setList(String path, List value) + { + set(path, value); + } + + /** + * + * + * @generated NOT + */ + public void setLong(String path, long value) + { + Property property = getType().getProperty(path); + if (property != null) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create(this, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + /** + * + * + * @generated NOT + */ + public void setShort(String path, short value) + { + Property property = getType().getProperty(path); + if (property != null) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create(this, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + /** + * + * + * @generated NOT + */ + public void setString(String path, String value) + { + Property property = getType().getProperty(path); + if (property != null) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create(this, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + /** + * + * + * @generated NOT + */ + public BigDecimal getBigDecimal(int propertyIndex) + { + return DataObjectUtil.getBigDecimal(get(propertyIndex)); + } + + /** + * + * + * @generated NOT + */ + public BigInteger getBigInteger(int propertyIndex) + { + return DataObjectUtil.getBigInteger(get(propertyIndex)); + } + + /** + * + * + * @generated NOT + */ + public boolean getBoolean(int propertyIndex) + { + return DataObjectUtil.getBoolean(get(propertyIndex)); + } + + /** + * + * + * @generated NOT + */ + public byte getByte(int propertyIndex) + { + return DataObjectUtil.getByte(get(propertyIndex)); + } + + /** + * + * + * @generated NOT + */ + public byte[] getBytes(int propertyIndex) + { + return DataObjectUtil.getBytes(get(propertyIndex)); + } + + /** + * + * + * @generated NOT + */ + public char getChar(int propertyIndex) + { + return DataObjectUtil.getChar(get(propertyIndex)); + } + + /** + * + * + * @generated NOT + */ + public DataObject getDataObject(int propertyIndex) + { + return (DataObject)get(propertyIndex); + } + + /** + * + * + * @generated NOT + */ + public Date getDate(int propertyIndex) + { + return DataObjectUtil.getDate(get(propertyIndex)); + } + + /** + * + * + * @generated NOT + */ + public double getDouble(int propertyIndex) + { + return DataObjectUtil.getDouble(get(propertyIndex)); + } + + /** + * + * + * @generated NOT + */ + public float getFloat(int propertyIndex) + { + return DataObjectUtil.getFloat(get(propertyIndex)); + } + + /** + * + * + * @generated NOT + */ + public int getInt(int propertyIndex) + { + return DataObjectUtil.getInt(get(propertyIndex)); + } + + /** + * + * + * @generated NOT + */ + public List getList(int propertyIndex) + { + return (List)get(propertyIndex); + } + + /** + * + * + * @generated NOT + */ + public long getLong(int propertyIndex) + { + return DataObjectUtil.getLong(get(propertyIndex)); + } + + /** + * + * + * @generated NOT + */ + public Sequence getSequence(int propertyIndex) + { + return (Sequence)get(propertyIndex); + } + + /** + * + * + * @generated NOT + */ + public short getShort(int propertyIndex) + { + return DataObjectUtil.getShort(get(propertyIndex)); + } + + /** + * + * + * @generated NOT + */ + public String getString(int propertyIndex) + { + return DataObjectUtil.getString(get(propertyIndex)); + } + + /** + * + * + * @generated NOT + */ + public void setBigDecimal(int propertyIndex, BigDecimal value) + { + set(propertyIndex, DataObjectUtil.getSetValue((Property)eClass().getEStructuralFeature(propertyIndex), value)); + } + + /** + * + * + * @generated NOT + */ + public void setBigInteger(int propertyIndex, BigInteger value) + { + set(propertyIndex, DataObjectUtil.getSetValue((Property)eClass().getEStructuralFeature(propertyIndex), value)); + } + + /** + * + * + * @generated NOT + */ + public void setBoolean(int propertyIndex, boolean value) + { + set(propertyIndex, DataObjectUtil.getSetValue((Property)eClass().getEStructuralFeature(propertyIndex), value)); + } + + /** + * + * + * @generated NOT + */ + public void setByte(int propertyIndex, byte value) + { + set(propertyIndex, DataObjectUtil.getSetValue((Property)eClass().getEStructuralFeature(propertyIndex), value)); + } + + /** + * + * + * @generated NOT + */ + public void setBytes(int propertyIndex, byte[] value) + { + set(propertyIndex, DataObjectUtil.getSetValue((Property)eClass().getEStructuralFeature(propertyIndex), value)); + } + + /** + * + * + * @generated NOT + */ + public void setChar(int propertyIndex, char value) + { + set(propertyIndex, DataObjectUtil.getSetValue((Property)eClass().getEStructuralFeature(propertyIndex), value)); + } + + /** + * + * + * @generated NOT + */ + public void setDataObject(int propertyIndex, DataObject value) + { + set(propertyIndex, value); + } + + /** + * + * + * @generated NOT + */ + public void setDate(int propertyIndex, Date value) + { + set(propertyIndex, DataObjectUtil.getSetValue((Property)eClass().getEStructuralFeature(propertyIndex), value)); + } + + /** + * + * + * @generated NOT + */ + public void setDouble(int propertyIndex, double value) + { + set(propertyIndex, DataObjectUtil.getSetValue((Property)eClass().getEStructuralFeature(propertyIndex), value)); + } + + /** + * + * + * @generated NOT + */ + public void setFloat(int propertyIndex, float value) + { + set(propertyIndex, DataObjectUtil.getSetValue((Property)eClass().getEStructuralFeature(propertyIndex), value)); + } + + /** + * + * + * @generated NOT + */ + public void setInt(int propertyIndex, int value) + { + set(propertyIndex, DataObjectUtil.getSetValue((Property)eClass().getEStructuralFeature(propertyIndex), value)); + } + + /** + * + * + * @generated NOT + */ + public void setList(int propertyIndex, List value) + { + set(propertyIndex, value); + } + + /** + * + * + * @generated NOT + */ + public void setLong(int propertyIndex, long value) + { + set(propertyIndex, DataObjectUtil.getSetValue((Property)eClass().getEStructuralFeature(propertyIndex), value)); + } + + /** + * + * + * @generated NOT + */ + public void setShort(int propertyIndex, short value) + { + set(propertyIndex, DataObjectUtil.getSetValue((Property)eClass().getEStructuralFeature(propertyIndex), value)); + } + + /** + * + * + * @generated NOT + */ + public void setString(int propertyIndex, String value) + { + set(propertyIndex, DataObjectUtil.getSetValue((Property)eClass().getEStructuralFeature(propertyIndex), value)); + } + + /** + * + * + * @generated NOT + */ + public BigDecimal getBigDecimal(Property property) + { + return DataObjectUtil.getBigDecimal(get(property)); + } + + /** + * + * + * @generated NOT + */ + public BigInteger getBigInteger(Property property) + { + return DataObjectUtil.getBigInteger(get(property)); + } + + /** + * + * + * @generated NOT + */ + public boolean getBoolean(Property property) + { + return DataObjectUtil.getBoolean(get(property)); + } + + /** + * + * + * @generated NOT + */ + public byte getByte(Property property) + { + return DataObjectUtil.getByte(get(property)); + } + + /** + * + * + * @generated NOT + */ + public byte[] getBytes(Property property) + { + return DataObjectUtil.getBytes(get(property)); + } + + /** + * + * + * @generated NOT + */ + public char getChar(Property property) + { + return DataObjectUtil.getChar(get(property)); + } + + /** + * + * + * @generated NOT + */ + public DataObject getDataObject(Property property) + { + return (DataObject)get(property); + } + + /** + * + * + * @generated NOT + */ + public Date getDate(Property property) + { + return DataObjectUtil.getDate(get(property)); + } + + /** + * + * + * @generated NOT + */ + public double getDouble(Property property) + { + return DataObjectUtil.getDouble(get(property)); + } + + /** + * + * + * @generated NOT + */ + public float getFloat(Property property) + { + return DataObjectUtil.getFloat(get(property)); + } + + /** + * + * + * @generated NOT + */ + public int getInt(Property property) + { + return DataObjectUtil.getInt(get(property)); + } + + /** + * + * + * @generated NOT + */ + public List getList(Property property) + { + return (List)get(property); + } + + /** + * + * + * @generated NOT + */ + public long getLong(Property property) + { + return DataObjectUtil.getLong(get(property)); + } + + /** + * + * + * @generated NOT + */ + public Sequence getSequence(Property property) + { + return (Sequence)get(property); + } + + /** + * + * + * @generated NOT + */ + public short getShort(Property property) + { + return DataObjectUtil.getShort(get(property)); + } + + /** + * + * + * @generated NOT + */ + public String getString(Property property) + { + return DataObjectUtil.getString(get(property)); + } + + /** + * + * + * @generated NOT + */ + public void setBigDecimal(Property property, BigDecimal value) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + + /** + * + * + * @generated NOT + */ + public void setBigInteger(Property property, BigInteger value) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + + /** + * + * + * @generated NOT + */ + public void setBoolean(Property property, boolean value) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + + /** + * + * + * @generated NOT + */ + public void setByte(Property property, byte value) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + + /** + * + * + * @generated NOT + */ + public void setBytes(Property property, byte[] value) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + + /** + * + * + * @generated NOT + */ + public void setChar(Property property, char value) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + + /** + * + * + * @generated NOT + */ + public void setDataObject(Property property, DataObject value) + { + set(property, value); + } + + /** + * + * + * @generated NOT + */ + public void setDate(Property property, Date value) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + + /** + * + * + * @generated NOT + */ + public void setDouble(Property property, double value) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + + /** + * + * + * @generated NOT + */ + public void setFloat(Property property, float value) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + + /** + * + * + * @generated NOT + */ + public void setInt(Property property, int value) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + + /** + * + * + * @generated NOT + */ + public void setList(Property property, List value) + { + set(property, value); + } + + /** + * + * + * @generated NOT + */ + public void setLong(Property property, long value) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + + /** + * + * + * @generated NOT + */ + public void setShort(Property property, short value) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + + /** + * + * + * @generated NOT + */ + public void setString(Property property, String value) + { + set(property, DataObjectUtil.getSetValue(property, value)); + } + + /** + * + * + * @generated NOT + */ + public DataObject createDataObject(String propertyName) + { + Property property = (Property)DataObjectUtil.getProperty(this, propertyName); + Type type = property.getType(); + return createDataObject(property, type); + } + + /** + * + * + * @generated NOT + */ + public DataObject createDataObject(int propertyIndex) + { + Property property = DataObjectUtil.getProperty(this, propertyIndex); + Type type = property.getType(); + return createDataObject(property, type); + } + + /** + * + * + * @generated NOT + */ + public DataObject createDataObject(Property property) + { + Type type = property.getType(); + return createDataObject(property, type); + } + + /** + * + * + * @generated NOT + */ + public DataObject createDataObject(String propertyName, String namespaceURI, String typeName) + { + Property property = DataObjectUtil.getProperty(this, propertyName); + Type type = DataObjectUtil.getType(this, namespaceURI, typeName); + return createDataObject(property, type); + } + + /** + * + * + * @generated NOT + */ + public DataObject createDataObject(int propertyIndex, String namespaceURI, String typeName) + { + Property property = DataObjectUtil.getProperty(this, propertyIndex); + Type type = DataObjectUtil.getType(this, namespaceURI, typeName); + return createDataObject(property, type); + } + + /** + * + * + * @generated NOT + */ + public DataObject createDataObject(Property property, Type type) + { + if (!property.isContainment()) + { + throw new IllegalArgumentException("The property '" + property.getName() + "' of '" + property.getContainingType().getName() + + "' isn't a containment"); + } + DataObject result = DataObjectUtil.create(type); + if (FeatureMapUtil.isMany(this, (EStructuralFeature)property)) + { + ((List)get(property)).add(result); + } + else + { + set(property, result); + } + return result; + } + + /** + * + * + * @generated NOT + */ + public void delete() + { + EcoreUtil.remove(this); + List contents = new ArrayList(eContents()); + for (int i = 0, size = contents.size(); i < size; ++i) + { + ((DataObject)contents.get(i)).delete(); + } + EClass eClass = eClass(); + for (int i = 0, size = eClass.getFeatureCount(); i < size; ++i) + { + EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature(i); + if (eStructuralFeature.isChangeable() && !eStructuralFeature.isDerived() && !((Property)eStructuralFeature).isReadOnly()) + { + eUnset(eStructuralFeature); + } + } + } + + /** + * + * + * @generated NOT + */ + public Sequence getSequence() + { + EAttribute mixedFeature = BasicExtendedMetaData.INSTANCE.getMixedFeature(eClass()); + return mixedFeature != null ? (Sequence)eGet(mixedFeature, true, false) : null; + } + + /** + * + * + * @generated NOT + */ + public List getInstanceProperties() + { + //TODO maybe optimize this to just return type.getProperties if type.isOpen (isOpen would need to be cached) + List result = new UniqueEList(eClass().getEAllStructuralFeatures()); + for (int i = 0, count = result.size(); i < count; ++i) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)result.get(i); + if (!eStructuralFeature.isDerived() && FeatureMapUtil.isFeatureMap(eStructuralFeature)) + { + List features = (List)eGet(eStructuralFeature); + for (int j = 0, size = features.size(); j < size; ++j) + { + FeatureMap.Entry entry = (FeatureMap.Entry)features.get(j); + EStructuralFeature entryFeature = entry.getEStructuralFeature(); + result.add(entryFeature); + } + } + } + return result; + } + + /** + * + * + * @generated NOT + */ + public Property getProperty(String propertyName) + { + Property property = getType().getProperty(propertyName); + if (property == null) + { + property = (Property)DataObjectUtil.getOpenFeature(this, propertyName); + } + return property; + } + + /** + * + * + * @generated NOT + */ + public DataObject getRootObject() + { + return (DataObject)EcoreUtil.getRootContainer(this); + } + + /** + * + * + * @generated NOT + */ + public ChangeSummary getChangeSummary() + { + // TODO: implement this method + throw new UnsupportedOperationException(); + } + + /** + * + * + * @generated NOT + */ + public void detach() + { + EcoreUtil.remove(this); + } + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Following methods customize BasicEObjectImpl, optimized for SDO + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + public boolean eNotificationRequired() + { + return changeRecorder != null; + } + + public void eNotify(Notification notification) + { + changeRecorder.notifyChanged(notification); + } + + public void setChangeRecorder(SDOChangeRecorder changeRecorder) + { + if (this.changeRecorder != null) + { + this.changeRecorder.unsetTarget(this); + } + + if (changeRecorder != null) + { + changeRecorder.setTarget(this); + } + + this.changeRecorder = changeRecorder; + } + + public InternalEObject eInternalContainer() + { + return eContainer; + } + + public int eContainerFeatureID() + { + return eContainerFeatureID; + } + + protected void eBasicSetContainer(InternalEObject newContainer, int newContainerFeatureID) + { + eContainer = newContainer; + eContainerFeatureID = newContainerFeatureID; + } + + public EClass eClass() + { + return eStaticClass(); + } + + public EList eContents() + { + return new EContentsEList(this); + } + + public EList eCrossReferences() + { + return new ECrossReferenceEList(this); + } + + public Resource.Internal eDirectResource() + { + return location instanceof Resource.Internal ? (Resource.Internal)location : null; + } + + protected EClass eDynamicClass() + { + return null; + } + + protected boolean eHasSettings() + { + return false; + } + + public boolean eIsProxy() + { + return location instanceof URI; + } + + public URI eProxyURI() + { + return location instanceof URI ? (URI)location : null; + } + + public void eSetClass(EClass eClass) + { + throw new UnsupportedOperationException(); + } + + protected void eSetDirectResource(Resource.Internal resource) + { + location = resource; + } + + public void eSetProxyURI(URI uri) + { + location = uri; + } + + protected DynamicValueHolder eSettings() + { + return null; + } + + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + return eDynamicGet(featureID, resolve, coreType); + } + + public void eSet(int featureID, Object newValue) + { + eDynamicSet(featureID, newValue); + } + + public void eUnset(int featureID) + { + eDynamicUnset(featureID); + } + + public boolean eIsSet(int featureID) + { + return eDynamicIsSet(featureID); + } + + public Object eDynamicGet(int featureID, boolean resolve, boolean coreType) + { + return eOpenGet(DataObjectUtil.getOpenFeature(this, featureID), resolve); + } + + public void eDynamicSet(int featureID, Object newValue) + { + eOpenSet(DataObjectUtil.getOpenFeature(this, featureID), newValue); + } + + public void eDynamicUnset(int featureID) + { + eOpenUnset(DataObjectUtil.getOpenFeature(this, featureID)); + } + + public boolean eDynamicIsSet(int featureID) + { + return eOpenIsSet(DataObjectUtil.getOpenFeature(this, featureID)); + } + +} //EDataObjectImpl + diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataTypeImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataTypeImpl.java new file mode 100644 index 0000000000..cbe5f36cab --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataTypeImpl.java @@ -0,0 +1,177 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.impl; + +import java.util.Collections; +import java.util.List; + +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.impl.EDataTypeImpl; +import org.eclipse.emf.ecore.util.ExtendedMetaData; + +import commonj.sdo.Property; +import commonj.sdo.Type; + +/** + * + * An implementation of the model object 'Data Type'. + * + *

+ *

+ * + * @generated + */ +public class DataTypeImpl extends EDataTypeImpl implements Type +{ + /** + * + * + * @generated + */ + protected DataTypeImpl() + { + super(); + } + + /** + * + * + * @generated NOT + */ + protected EClass eStaticClass() + { + return EcorePackage.eINSTANCE.getEDataType(); + } + + /** + * + * + * @generated NOT + */ + public String getURI() + { + return getEPackage().getNsURI(); + } + + /** + * + * + * @generated NOT + */ + public boolean isDataType() + { + return true; + } + + /** + * + * + * @generated NOT + */ + public boolean isOpen() + { + return false; + } + + /** + * + * + * @generated NOT + */ + public boolean isSequenced() + { + return false; + } + + protected List aliasNames = null; + + /** + * + * + * @generated NOT + */ + public List getAliasNames() + { + if (aliasNames == null) + { + aliasNames = DataObjectUtil.getAliasNames(this); + } + return aliasNames; + } + + /** + * + * + * @generated NOT + */ + public List getDeclaredProperties() + { + return Collections.EMPTY_LIST; + } + + /** + * + * + * @generated NOT + */ + public List getProperties() + { + return Collections.EMPTY_LIST; + } + + /** + * + * + * @generated NOT + */ + public List getBaseTypes() + { + EDataType dataType = ExtendedMetaData.INSTANCE.getBaseType(this); + if (dataType == null) + { + return Collections.EMPTY_LIST; + } + else + { + return Collections.singletonList(dataType); + } + } + + /** + * + * + * @generated NOT + */ + public Property getProperty(String propertyName) + { + return null; + } + + /** + * + * + * @generated NOT + */ + public boolean isAbstract() + { + return false; + } + +} //DataTypeImpl diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicDataObjectImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicDataObjectImpl.java new file mode 100644 index 0000000000..dd9cdfa779 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicDataObjectImpl.java @@ -0,0 +1,196 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.impl; + +import 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; + +/** + * + * An implementation of the model object 'Dynamic Data Object'. + * @extends EStructuralFeature.Internal.DynamicValueHolder + * + *

+ *

+ * + * @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]; + + /** + * + * + * @generated + */ + protected DynamicDataObjectImpl() + { + super(); + } + + /** + * Creates a dynamic DataObject. + */ + public DynamicDataObjectImpl(EClass eClass) + { + super(); + eSetClass(eClass); + } + + /** + * + * + * @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); + 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 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/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicStoreDataObjectImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicStoreDataObjectImpl.java new file mode 100644 index 0000000000..d3b709c070 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicStoreDataObjectImpl.java @@ -0,0 +1,88 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.impl; + +import org.apache.tuscany.sdo.SDOPackage; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import commonj.sdo.DataObject; + +/** + * + * An implementation of the model object 'Dynamic Store Data Object'. + * + *

+ *

+ * + * @generated + */ +public class DynamicStoreDataObjectImpl extends StoreDataObjectImpl implements DataObject +{ + protected EClass eClass; + + /** + * + * + * @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); + } + + /** + * + * + * @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/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/EnumImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/EnumImpl.java new file mode 100644 index 0000000000..5f7256da9a --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/EnumImpl.java @@ -0,0 +1,169 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.impl; + +import java.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; + +/** + * + * An implementation of the model object 'Enum'. + * + *

+ *

+ * + * @generated + */ +public class EnumImpl extends EEnumImpl implements Type +{ + /** + * + * + * @generated + */ + protected EnumImpl() + { + super(); + } + + /** + * + * + * @generated NOT + */ + protected EClass eStaticClass() + { + return EcorePackage.eINSTANCE.getEEnum(); + } + + /** + * + * + * @generated NOT + */ + public String getURI() + { + return getEPackage().getNsURI(); + } + + /** + * + * + * @generated NOT + */ + public boolean isDataType() + { + return true; + } + + /** + * + * + * @generated NOT + */ + public boolean isOpen() + { + return false; + } + + /** + * + * + * @generated NOT + */ + public boolean isSequenced() + { + return false; + } + + protected List aliasNames = null; + + /** + * + * + * @generated NOT + */ + public List getAliasNames() + { + if (aliasNames == null) + { + aliasNames = DataObjectUtil.getAliasNames(this); + } + return aliasNames; + } + + /** + * + * + * @generated NOT + */ + public List getDeclaredProperties() + { + return Collections.EMPTY_LIST; + } + + /** + * + * + * @generated NOT + */ + public List getProperties() + { + return Collections.EMPTY_LIST; + } + + /** + * + * + * @generated NOT + */ + public List getBaseTypes() + { + return Collections.EMPTY_LIST; + } + + /** + * + * + * @generated NOT + */ + public Property getProperty(String propertyName) + { + return null; + } + + /** + * + * + * @generated NOT + */ + public boolean isAbstract() + { + return false; + } + +} //EnumTypeImpl diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ReferenceImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ReferenceImpl.java new file mode 100644 index 0000000000..8dbdec3d41 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ReferenceImpl.java @@ -0,0 +1,129 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.impl; + +import java.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.EReferenceImpl; + +import commonj.sdo.Property; +import commonj.sdo.Type; + +/** + * + * An implementation of the model object 'Reference'. + * + *

+ *

+ * + * @generated + */ +public class ReferenceImpl extends EReferenceImpl implements Property +{ + /** + * + * + * @generated + */ + protected ReferenceImpl() + { + super(); + } + + /** + * + * + * @generated NOT + */ + protected EClass eStaticClass() + { + return EcorePackage.eINSTANCE.getEReference(); + } + + /** + * + * + * @generated NOT + */ + public Object getDefault() + { + return getDefaultValue(); + } + + /** + * + * + * @generated NOT + */ + public boolean isReadOnly() + { + //return "true".equals(EcoreUtil.getAnnotation(this, "commonj.sdo", "readOnly")); + return !isChangeable(); //TODO semantics don't exactly match? + } + + protected List aliasNames = null; + + /** + * + * + * @generated NOT + */ + public List getAliasNames() + { + if (aliasNames == null) + { + aliasNames = DataObjectUtil.getAliasNames(this); + } + return aliasNames; + } + + /** + * + * + * @generated NOT + */ + public Type getType() + { + return (Type)getEType(); + } + + /** + * + * + * @generated NOT + */ + public Type getContainingType() + { + return (Type)getEContainingClass(); + } + + /** + * + * + * @generated NOT + */ + public Property getOpposite() + { + return (Property)getEOpposite(); + } + +} //ReferenceImpl diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOFactoryImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOFactoryImpl.java new file mode 100644 index 0000000000..fa299cb95e --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOFactoryImpl.java @@ -0,0 +1,325 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.impl; + + +import 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.EEnum; +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.plugin.EcorePlugin; + +import org.eclipse.emf.ecore.impl.EcoreFactoryImpl; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; +/** + * + * An implementation of the model Factory. + * + * @generated + */ +public class SDOFactoryImpl extends EFactoryImpl implements SDOFactory +{ + /** + * Creates the default factory implementation. + * + * + * @generated + */ + public static SDOFactory init() + { + try + { + SDOFactory theSDOFactory = (SDOFactory)EPackage.Registry.INSTANCE.getEFactory("http://www.eclipse.org/emf/2003/SDO"); + 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. + * + * + * @generated + */ + public SDOFactoryImpl() + { + super(); + } + + /** + * + * + * @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(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + public Object createFromString(EDataType eDataType, String initialValue) + { + switch (eDataType.getClassifierID()) + { + default: + throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + public String convertToString(EDataType eDataType, Object instanceValue) + { + switch (eDataType.getClassifierID()) + { + default: + throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + public ChangeSummary createChangeSummary() + { + ChangeSummaryImpl changeSummary = new ChangeSummaryImpl(); + return changeSummary; + } + + /** + * + * + * @generated + */ + public ChangeSummary.Setting createChangeSummarySetting() + { + ChangeSummarySettingImpl changeSummarySetting = new ChangeSummarySettingImpl(); + return changeSummarySetting; + } + + /** + * + * + * @generated + */ + public DataGraph createDataGraph() + { + DataGraphImpl dataGraph = new DataGraphImpl(); + return dataGraph; + } + + /** + * + * + * @generated + */ + public AnyTypeDataObject createAnyTypeDataObject() + { + AnyTypeDataObjectImpl anyTypeDataObject = new AnyTypeDataObjectImpl(); + return anyTypeDataObject; + } + + /** + * + * + * @generated + */ + public SimpleAnyTypeDataObject createSimpleAnyTypeDataObject() + { + SimpleAnyTypeDataObjectImpl simpleAnyTypeDataObject = new SimpleAnyTypeDataObjectImpl(); + return simpleAnyTypeDataObject; + } + + /** + * + * + * @generated + */ + public Type createClass() + { + ClassImpl class_ = new ClassImpl(); + return class_; + } + + /** + * + * + * @generated + */ + public Type createDataType() + { + DataTypeImpl dataType = new DataTypeImpl(); + return dataType; + } + + /** + * + * + * @generated + */ + public Property createAttribute() + { + AttributeImpl attribute = new AttributeImpl(); + return attribute; + } + + /** + * + * + * @generated + */ + public Property createReference() + { + ReferenceImpl reference = new ReferenceImpl(); + return reference; + } + + /** + * + * + * @generated + */ + public Type createEnum() + { + EnumImpl enum_ = new EnumImpl(); + return enum_; + } + + /** + * + * + * @generated + */ + public DataObject createDynamicDataObject() + { + DynamicDataObjectImpl dynamicDataObject = new DynamicDataObjectImpl(); + return dynamicDataObject; + } + + /** + * + * + * @generated + */ + public DataObject createStoreDataObject() + { + StoreDataObjectImpl storeDataObject = new StoreDataObjectImpl(); + return storeDataObject; + } + + /** + * + * + * @generated + */ + public DataObject createDynamicStoreDataObject() + { + DynamicStoreDataObjectImpl dynamicStoreDataObject = new DynamicStoreDataObjectImpl(); + return dynamicStoreDataObject; + } + + /** + * + * + * @generated + */ + public SDOPackage getSDOPackage() + { + return (SDOPackage)getEPackage(); + } + + /** + * + * + * @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/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOPackageImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOPackageImpl.java new file mode 100644 index 0000000000..15011fc37f --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOPackageImpl.java @@ -0,0 +1,2133 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.impl; + +import java.io.ObjectStreamException; +import java.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.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.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; + +/** + * + * An implementation of the model Package. + * + * @generated + */ +public class SDOPackageImpl extends EPackageImpl implements SDOPackage +{ + /** + * + * + * @generated + */ + private EClass changeSummaryEClass = null; + + /** + * + * + * @generated + */ + private EClass changeSummarySettingEClass = null; + + /** + * + * + * @generated + */ + private EClass dataGraphEClass = null; + + /** + * + * + * @generated + */ + private EClass dataObjectEClass = null; + + /** + * + * + * @generated + */ + private EClass propertyEClass = null; + + /** + * + * + * @generated + */ + private EClass sequenceEClass = null; + + /** + * + * + * @generated + */ + private EClass typeEClass = null; + + /** + * + * + * @generated + */ + private EClass anyTypeDataObjectEClass = null; + + /** + * + * + * @generated + */ + private EClass simpleAnyTypeDataObjectEClass = null; + + /** + * + * + * @generated + */ + private EClass classEClass = null; + + /** + * + * + * @generated + */ + private EClass dataTypeEClass = null; + + /** + * + * + * @generated + */ + private EClass attributeEClass = null; + + /** + * + * + * @generated + */ + private EClass referenceEClass = null; + + /** + * + * + * @generated + */ + private EClass enumEClass = null; + + /** + * + * + * @generated + */ + private EClass dynamicDataObjectEClass = null; + + /** + * + * + * @generated + */ + private EClass storeDataObjectEClass = null; + + /** + * + * + * @generated + */ + private EClass dynamicStoreDataObjectEClass = null; + + /** + * + * + * @generated + */ + private EDataType eJavaListEDataType = null; + + /** + * + * + * @generated + */ + private EDataType eObjectStreamExceptionEDataType = null; + + /** + * Creates an instance of the model Package, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + *

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. + * + * + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see org.apache.tuscany.sdo.SDOPackage#eNS_URI + * @see #init() + * @generated + */ + private SDOPackageImpl() + { + super(eNS_URI, SDOFactory.eINSTANCE); + } + + /** + * + * + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the Package 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. + *

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. + *

Invocation of this method will not affect any packages that have + * already been initialized. + * + * + * @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; + } + + /** + * + * + * @generated + */ + public EClass getChangeSummary() + { + return changeSummaryEClass; + } + + /** + * + * + * @generated + */ + public EReference getChangeSummary_EDataGraph() + { + return (EReference)changeSummaryEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EClass getChangeSummarySetting() + { + return changeSummarySettingEClass; + } + + /** + * + * + * @generated + */ + public EClass getDataGraph() + { + return dataGraphEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getDataGraph_ResourceSet() + { + return (EAttribute)dataGraphEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EAttribute getDataGraph_RootResource() + { + return (EAttribute)dataGraphEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EReference getDataGraph_EChangeSummary() + { + return (EReference)dataGraphEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + public EReference getDataGraph_ERootObject() + { + return (EReference)dataGraphEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + public EClass getDataObject() + { + return dataObjectEClass; + } + + /** + * + * + * @generated + */ + public EClass getProperty() + { + return propertyEClass; + } + + /** + * + * + * @generated + */ + public EClass getSequence() + { + return sequenceEClass; + } + + /** + * + * + * @generated + */ + public EClass getType() + { + return typeEClass; + } + + /** + * + * + * @generated + */ + public EClass getAnyTypeDataObject() + { + return anyTypeDataObjectEClass; + } + + /** + * + * + * @generated + */ + public EClass getSimpleAnyTypeDataObject() + { + return simpleAnyTypeDataObjectEClass; + } + + /** + * + * + * @generated + */ + public EClass getClass_() + { + return classEClass; + } + + /** + * + * + * @generated + */ + public EClass getDataType() + { + return dataTypeEClass; + } + + /** + * + * + * @generated + */ + public EClass getAttribute() + { + return attributeEClass; + } + + /** + * + * + * @generated + */ + public EClass getReference() + { + return referenceEClass; + } + + /** + * + * + * @generated + */ + public EClass getEnum() + { + return enumEClass; + } + + /** + * + * + * @generated + */ + public EClass getDynamicDataObject() + { + return dynamicDataObjectEClass; + } + + /** + * + * + * @generated + */ + public EClass getStoreDataObject() + { + return storeDataObjectEClass; + } + + /** + * + * + * @generated + */ + public EClass getDynamicStoreDataObject() + { + return dynamicStoreDataObjectEClass; + } + + /** + * + * + * @generated + */ + public EDataType getEJavaList() + { + return eJavaListEDataType; + } + + /** + * + * + * @generated + */ + public EDataType getEObjectStreamException() + { + return eObjectStreamExceptionEDataType; + } + + /** + * + * + * @generated + */ + public SDOFactory getSDOFactory() + { + return (SDOFactory)getEFactoryInstance(); + } + + /** + * + * + * @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. + * + * + * @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); + + // Create data types + eJavaListEDataType = createEDataType(EJAVA_LIST); + eObjectStreamExceptionEDataType = createEDataType(EOBJECT_STREAM_EXCEPTION); + } + + /** + * + * + * @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. + * + * + * @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()); + + // 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); + + // 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 http://www.eclipse.org/emf/2002/GenModel. + * + * + * @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 http:///org/eclipse/emf/ecore/util/ExtendedMetaData. + * + * + * @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/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/SimpleAnyTypeDataObjectImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/SimpleAnyTypeDataObjectImpl.java new file mode 100644 index 0000000000..33ca015ac9 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/SimpleAnyTypeDataObjectImpl.java @@ -0,0 +1,330 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.impl; + +import java.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; + +/** + * + * An implementation of the model object 'EData Object Simple Any Type'. + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.apache.tuscany.sdo.impl.SimpleAnyTypeDataObjectImpl#getRawValue Raw Value}
  • + *
  • {@link org.apache.tuscany.sdo.impl.SimpleAnyTypeDataObjectImpl#getValue Value}
  • + *
  • {@link org.apache.tuscany.sdo.impl.SimpleAnyTypeDataObjectImpl#getInstanceType Instance Type}
  • + *
+ *

+ * + * @generated + */ +public class SimpleAnyTypeDataObjectImpl extends AnyTypeDataObjectImpl implements SimpleAnyTypeDataObject +{ + /** + * The default value of the '{@link #getRawValue() Raw Value}' attribute. + * + * + * @see #getRawValue() + * @generated + * @ordered + */ + protected static final String RAW_VALUE_EDEFAULT = null; + + /** + * The default value of the '{@link #getValue() Value}' attribute. + * + * + * @see #getValue() + * @generated + * @ordered + */ + protected static final Object VALUE_EDEFAULT = null; + + /** + * The cached value of the '{@link #getInstanceType() Instance Type}' reference. + * + * + * @see #getInstanceType() + * @generated + * @ordered + */ + protected EDataType instanceType = null; + + /** + * + * + * @generated + */ + protected SimpleAnyTypeDataObjectImpl() + { + super(); + } + + /** + * + * + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getSimpleAnyTypeDataObject(); + } + + /** + * + * + * @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(); + } + + /** + * + * + * @generated NOT + */ + public void setRawValue(String newRawValue) + { + getMixed().clear(); + if (newRawValue != null) + { + getMixed().add(XMLTypePackage.eINSTANCE.getXMLTypeDocumentRoot_Text(), newRawValue); + } + } + + /** + * + * + * @generated NOT + */ + public Object getValue() + { + return EcoreUtil.createFromString(instanceType, getRawValue()); + } + + /** + * + * + * @generated NOT + */ + public void setValue(Object newValue) + { + setRawValue(EcoreUtil.convertToString(instanceType, newValue)); + } + + /** + * + * + * @generated + */ + public EDataType getInstanceType() + { + return instanceType; + } + + /** + * + * + * @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)); + } + + /** + * + * + * @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); + } + + /** + * + * + * @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); + } + + /** + * + * + * @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); + } + + /** + * + * + * @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); + } + + /** + * + * + * @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); + } + + /** + * + * + * @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/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/StoreDataObjectImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/StoreDataObjectImpl.java new file mode 100644 index 0000000000..06bb3a6d05 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/StoreDataObjectImpl.java @@ -0,0 +1,311 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.impl; + +import 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; + +/** + * + * An implementation of the model object 'Store Data Object'. + * @extends EStructuralFeature.Internal.DynamicValueHolder + * + *

+ *

+ * + * @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; + } + + /** + * + * + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getStoreDataObject(); + } + +} //StoreDataObjectImpl diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/BasicSequence.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/BasicSequence.java new file mode 100644 index 0000000000..5a631dde77 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/BasicSequence.java @@ -0,0 +1,134 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.util; + +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.ecore.util.FeatureMapUtil; +import org.eclipse.emf.ecore.xml.type.XMLTypePackage; + +import commonj.sdo.Property; +import commonj.sdo.Sequence; + +/** + * SDO Sequance implementation which delegates to a feature map. + */ +public class BasicSequence implements Sequence, FeatureMap.Internal.Wrapper +{ + protected FeatureMap.Internal featureMap; + + public BasicSequence(FeatureMap.Internal featureMap) + { + this.featureMap = featureMap; + featureMap.setWrapper(this); + } + + public FeatureMap featureMap() + { + return featureMap; + } + + public int size() + { + return featureMap.size(); + } + + public Property getProperty(int index) + { + EStructuralFeature feature = featureMap.getEStructuralFeature(index); + boolean isText = + feature == XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__TEXT || + feature == XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__CDATA || + feature == XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__COMMENT; + return isText ? null : (Property)feature; + } + + public Object getValue(int index) + { + return featureMap.getValue(index); + } + + public Object setValue(int index, Object value) + { + return featureMap.setValue(index, value); + } + + protected EStructuralFeature getEStructuralFeature(String propertyName) + { + return featureMap.getEObject().eClass().getEStructuralFeature(propertyName); + } + + protected EStructuralFeature getEStructuralFeature(int propertyIndex) + { + return featureMap.getEObject().eClass().getEStructuralFeature(propertyIndex); + } + + public boolean add(String propertyName, Object value) + { + return featureMap.add(getEStructuralFeature(propertyName), value); + } + + public boolean add(int propertyIndex, Object value) + { + return featureMap.add(getEStructuralFeature(propertyIndex), value); + } + + public boolean add(Property property, Object value) + { + return featureMap.add((EStructuralFeature)property, value); + } + + public void add(int index, String propertyName, Object value) + { + featureMap.add(index, getEStructuralFeature(propertyName), value); + } + + public void add(int index, int propertyIndex, Object value) + { + featureMap.add(index, getEStructuralFeature(propertyIndex), value); + } + + public void add(int index, Property property, Object value) + { + featureMap.add(index, (EStructuralFeature)property, value); + } + + public void add(String text) + { + FeatureMapUtil.addText(featureMap, text); + } + + public void add(int index, String text) + { + FeatureMapUtil.addText(featureMap, index, text); + } + + public void remove(int index) + { + featureMap.remove(index); + } + + public void move(int toIndex, int fromIndex) + { + featureMap.move(toIndex, fromIndex); + } + + public String toString() + { + return featureMap.toString(); + } +} diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataGraphResourceFactoryImpl.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataGraphResourceFactoryImpl.java new file mode 100644 index 0000000000..3631a88203 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataGraphResourceFactoryImpl.java @@ -0,0 +1,644 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.util; + + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.impl.ChangeSummaryImpl; +import org.apache.tuscany.sdo.impl.DataGraphImpl; +import org.apache.tuscany.sdo.impl.DynamicDataObjectImpl; +import org.eclipse.emf.common.util.EMap; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EFactory; +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.EcorePackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.ExtendedMetaData; +import org.eclipse.emf.ecore.xmi.EcoreBuilder; +import org.eclipse.emf.ecore.xmi.NameInfo; +import org.eclipse.emf.ecore.xmi.XMLHelper; +import org.eclipse.emf.ecore.xmi.XMLLoad; +import org.eclipse.emf.ecore.xmi.XMLResource; +import org.eclipse.emf.ecore.xmi.XMLSave; +import org.eclipse.emf.ecore.xmi.impl.SAXXMLHandler; +import org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl; +import org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl; +import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; +import org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl; +import org.eclipse.emf.ecore.xmi.util.DefaultEcoreBuilder; +import org.w3c.dom.Element; +import org.xml.sax.helpers.DefaultHandler; + +import commonj.sdo.ChangeSummary; + + +public class DataGraphResourceFactoryImpl extends ResourceFactoryImpl +{ + /** + * Constructor for DataGraphResourceFactoryImpl. + */ + public DataGraphResourceFactoryImpl() + { + super(); + } + + public Resource createResource(URI uri) + { + XMLResourceImpl result = new DataGraphResourceImpl(uri); + + result.setEncoding("UTF-8"); + + result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE); + + result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); + result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); + + result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE); + result.getDefaultSaveOptions().put(XMLResource.OPTION_LINE_WIDTH, new Integer(80)); + + result.getDefaultLoadOptions().put(XMLResource.OPTION_ANY_TYPE, SDOPackage.eINSTANCE.getAnyTypeDataObject()); + result.getDefaultSaveOptions().put(XMLResource.OPTION_ANY_TYPE, SDOPackage.eINSTANCE.getAnyTypeDataObject()); + + result.getDefaultLoadOptions().put(XMLResource.OPTION_ANY_SIMPLE_TYPE, SDOPackage.eINSTANCE.getSimpleAnyTypeDataObject()); + result.getDefaultSaveOptions().put(XMLResource.OPTION_ANY_SIMPLE_TYPE, SDOPackage.eINSTANCE.getSimpleAnyTypeDataObject()); + + return result; + } + + public static class DataGraphResourceImpl extends XMLResourceImpl + { + public DataGraphResourceImpl(URI uri) + { + super(uri); + } + + public static class HelperImpl extends XMLHelperImpl + { + protected DataGraphImpl eDataGraph; + + protected List resources; + protected List uris; + + public HelperImpl(XMLResource xmlResource) + { + super(xmlResource); + } + + public void setResource(XMLResource resource) + { + super.setResource(resource); + if (!resource.getContents().isEmpty()) + { + eDataGraph = (DataGraphImpl)resource.getContents().get(0); + + resources = new ArrayList(); + uris = new ArrayList(); + + resources.add(eDataGraph.getRootResource()); + uris.add("#" + resource.getURIFragment(eDataGraph) + "/@eRootObject"); + + if (eDataGraph.getEChangeSummary() != null) + { + // Ensure that resource exists. + // + resources.add(((EObject)eDataGraph.getChangeSummary()).eResource()); + uris.add("#" + resource.getURIFragment(eDataGraph) + "/@eChangeSummary"); + } + + if (eDataGraph.eResource() != null && eDataGraph.eResource().getResourceSet() != null) + { + int count = 0; + for (Iterator i = eDataGraph.eResource().getResourceSet().getResources().iterator(); i.hasNext();) + { + Resource ePackageResource = (Resource)i.next(); + List resourceContents = ePackageResource.getContents(); + if (resourceContents.size() == 1 && resourceContents.get(0) instanceof EPackage) + { + resources.add(ePackageResource); + uris.add("#" + resource.getURIFragment(eDataGraph) + "/@models." + count++); + } + } + } + } + } + + public String getID(EObject eObject) + { + return super.getID(eObject); + } + + public String getIDREF(EObject eObject) + { + return super.getIDREF(eObject); + } + + public String getHREF(EObject eObject) + { + return super.getHREF(eObject); + } + + protected URI getHREF(Resource otherResource, EObject obj) + { + int index = resources.indexOf(otherResource); + if (index == -1) + { + return super.getHREF(otherResource, obj); + } + else + { + return createHREF((String)uris.get(index), otherResource.getURIFragment(obj)); + } + } + + protected URI createHREF(String baseURI, String fragment) + { + if (fragment.startsWith("/")) + { + return URI.createURI(baseURI + fragment.substring(1)); + } + else + { + return URI.createURI("#" + fragment); + } + } + + public void populateNameInfo(NameInfo nameInfo, EClass c) + { + if (c == SDOPackage.eINSTANCE.getDataGraph()) + { + if (extendedMetaData != null) + { + extendedMetaData.demandPackage("commonj.sdo").setNsPrefix("sdo"); + } + nameInfo.setQualifiedName(getQName("commonj.sdo", "datagraph")); + nameInfo.setNamespaceURI("commonj.sdo"); + nameInfo.setLocalPart("datagraph"); + } + else if (c == SDOPackage.eINSTANCE.getChangeSummary()) + { + if (extendedMetaData != null) + { + extendedMetaData.demandPackage("commonj.sdo").setNsPrefix("sdo"); + } + nameInfo.setQualifiedName("changeSummary"); + nameInfo.setNamespaceURI(null); + nameInfo.setLocalPart("changeSummary"); + } + else + { + super.populateNameInfo(nameInfo, c); + } + } + + public String getQName(EClass c) + { + if (c == SDOPackage.eINSTANCE.getDataGraph()) + { + if (extendedMetaData != null) + { + extendedMetaData.demandPackage("commonj.sdo").setNsPrefix("sdo"); + } + return getQName("commonj.sdo", "datagraph"); + } + else if (c == SDOPackage.eINSTANCE.getChangeSummary()) + { + if (extendedMetaData != null) + { + extendedMetaData.demandPackage("commonj.sdo").setNsPrefix("sdo"); + } + return getQName((String)null, "changeSummary"); + } + else + { + return super.getQName(c); + } + } + } + + protected XMLHelper createXMLHelper() + { + return new HelperImpl(this); + } + + protected EObject getEObjectByID(String id) + { + List contents = getContents(); + if (contents.size() >= 1) + { + Object rootObject = contents.get(0); + if (rootObject instanceof DataGraphImpl) + { + DataGraphImpl eDataGraph = (DataGraphImpl)rootObject; + EObject result = eDataGraph.getRootResource().getEObject(id); + if (result != null) + { + return result; + } + else + { + ChangeSummary eChangeSummary = eDataGraph.getEChangeSummary(); + if (eChangeSummary != null) + { + result = ((EObject)eDataGraph.getChangeSummary()).eResource().getEObject(id); + if (result != null) + { + return result; + } + } + } + } + } + return super.getEObjectByID(id); + } + + public static class SaveImpl extends XMLSaveImpl + { + protected DataGraphImpl eDataGraph; + + public SaveImpl(XMLHelper xmlHelper) + { + super(xmlHelper); + } + + public void traverse(List contents) + { + if (contents.size() >= 1 && contents.get(0) instanceof DataGraphImpl) + { + eDataGraph = (DataGraphImpl)contents.get(0); + + Object datagraphMark = null; + if (!toDOM) + { + if (declareXML) + { + doc.add(""); + doc.addLine(); + } + String elementName = helper.getQName(eDataGraph.eClass()); + doc.startElement(elementName); + datagraphMark = doc.mark(); + } + else + { + helper.populateNameInfo(nameInfo, eDataGraph.eClass()); + currentNode = document.createElementNS(nameInfo.getNamespaceURI(), nameInfo.getQualifiedName()); + document.appendChild(currentNode); + // not calling handler since there is no corresponding EObject + } + + if (eDataGraph.eResource() != null && eDataGraph.eResource().getResourceSet() != null) + { + List ePackages = new ArrayList(); + for (Iterator i = eDataGraph.eResource().getResourceSet().getResources().iterator(); i.hasNext();) + { + List resourceContents = ((Resource)i.next()).getContents(); + if (resourceContents.size() == 1 && resourceContents.get(0) instanceof EPackage) + { + ePackages.add(resourceContents.get(0)); + } + } + if (!ePackages.isEmpty()) + { + if (!toDOM) + { + doc.startElement("models"); + doc.addAttribute("xmlns", ""); + } + else + { + currentNode = currentNode.appendChild(document.createElementNS(null, "models")); + ((Element)currentNode).setAttributeNS(ExtendedMetaData.XMLNS_URI, ExtendedMetaData.XMLNS_PREFIX, ""); + // not calling handler since there is no corresponding EObject + } + for (Iterator i = ePackages.iterator(); i.hasNext();) + { + writeTopObject((EPackage)i.next()); + } + if (!toDOM) + { + doc.endElement(); + } + else + { + currentNode = currentNode.getParentNode(); + } + } + } + + // use namespace declarations defined in the document (if any) + EObject eRootObject = eDataGraph.getERootObject(); + EReference xmlnsPrefixMapFeature = extendedMetaData.getXMLNSPrefixMapFeature(eRootObject.eClass()); + if (xmlnsPrefixMapFeature != null) + { + EMap xmlnsPrefixMap = (EMap)eRootObject.eGet(xmlnsPrefixMapFeature); + helper.setPrefixToNamespaceMap(xmlnsPrefixMap); + } + ChangeSummary changeSummary = eDataGraph.getEChangeSummary(); + + if (changeSummary != null) + { + helper.setMustHavePrefix(true); + if (changeSummary.isLogging()) + { + ((ChangeSummaryImpl)changeSummary).summarize(); + writeTopObject((EObject)changeSummary); + } + else + { + writeTopObject((EObject)changeSummary); + } + helper.setMustHavePrefix(false); + } + + if (eRootObject != null && writeTopObject(eRootObject) == null && !toDOM) + { + doc.addLine(); + doc.setMixed(false); + } + if (!toDOM) + { + doc.endElement(); + // reset to add namespace declarations + // + doc.resetToMark(datagraphMark); + } + else + { + currentNode = document.getFirstChild(); + } + addNamespaceDeclarations(); + } + else + { + super.traverse(contents); + } + } + + protected void writeTopAttributes(EObject top) + { + if (top == eDataGraph.getEChangeSummary()) + { + if (!toDOM) + { + doc.addAttribute("xmlns", ""); + } + else + { + ((Element)currentNode).setAttributeNS(ExtendedMetaData.XMLNS_URI, ExtendedMetaData.XMLNS_PREFIX, ""); + } + } + } + + protected EObject getSchemaLocationRoot(EObject eObject) + { + return eDataGraph.getERootObject(); + } + } + + protected XMLSave createXMLSave() + { + return new SaveImpl(createXMLHelper()); + } + + public static class LoadImpl extends XMLLoadImpl + { + public LoadImpl(XMLHelper xmlHelper) + { + super(xmlHelper); + } + + protected DefaultHandler makeDefaultHandler() + { + return new SAXXMLHandler(resource, helper, options) + { + protected DataGraphImpl eDataGraph; + + protected boolean isInModels; + + protected List ePackages = new ArrayList(); + + protected EMap recordNamespacesSchemaLocations(EObject root) + { + EObject dgroot = eDataGraph.getERootObject(); + if (dgroot == null) + { + return null; + } + EMap prefixToNamespaceMap = super.recordNamespacesSchemaLocations(dgroot); + if (prefixToNamespaceMap != null) + { + for (Iterator i = prefixToNamespaceMap.iterator(); i.hasNext();) + { + Map.Entry entry = (Map.Entry)i.next(); + String prefix = (String)entry.getKey(); + String namespace = (String)entry.getValue(); + if (namespace.equals("commonj.sdo")) + { + prefixToNamespaceMap.removeKey(prefix); + break; + } + } + } + return prefixToNamespaceMap; + } + + protected void handleFeature(String prefix, String name) + { + if (isInModels && objects.size() == 2) + { + EObject modelObject = createObjectByType(prefix, name, false); + processObject(modelObject); + ePackages.add(modelObject); + } + else if (objects.size() == 1) + { + eDataGraph = (DataGraphImpl)objects.peek(); + eDataGraph.getResourceSet(); + if ("".equals(prefix) && "changeSummary".equals(name)) + { + ChangeSummary eChangeSummary = (ChangeSummary)createObjectFromFactory(SDOFactory.eINSTANCE, "EChangeSummary"); + eDataGraph.setEChangeSummary(eChangeSummary); + processObject((EObject)eChangeSummary); + } + else if ("".equals(prefix) && "models".equals(name)) + { + isInModels = true; + types.push(OBJECT_TYPE); + objects.push(eDataGraph); + mixedTargets.push(null); + } + else if (eDataGraph.getERootObject() == null) + { + if (processAnyXML) + { + // Ensure that anything can be handled, even if it's not recognized. + // + String namespaceURI = helper.getURI(prefix); + if (extendedMetaData.getPackage(namespaceURI) == null) + { + EStructuralFeature rootFeature = extendedMetaData.demandFeature(namespaceURI, name, true); + rootFeature.getEContainingClass().getEPackage().setEFactoryInstance(new DynamicDataObjectImpl.FactoryImpl()); + } + } + + EObject rootObject = createObjectByType(prefix, name, false); + eDataGraph.setERootObject(rootObject); + processObject(rootObject); + if (rootObject != null + && rootObject.eClass() == ExtendedMetaData.INSTANCE.getDocumentRoot(rootObject.eClass().getEPackage())) + { + super.handleFeature(prefix, name); + + // Remove the document root from the stack. + // + Object mixedTarget = mixedTargets.pop(); + Object object = objects.pop(); + mixedTargets.pop(); + objects.pop(); + mixedTargets.push(mixedTarget); + objects.push(object); + } + } + } + else + { + super.handleFeature(prefix, name); + } + } + + public void endElement(String uri, String localName, String name) + { + if (isInModels && objects.size() == 2) + { + if (!ePackages.isEmpty()) + { + for (Iterator i = ePackages.iterator(); i.hasNext();) + { + EPackage ePackage = (EPackage)i.next(); + ePackage.setEFactoryInstance(new DynamicDataObjectImpl.FactoryImpl()); + Resource resource = resourceSet.createResource(URI.createURI("*.ecore")); + resource.getContents().add(ePackage); + if (ePackage.getNsURI() != null) + { + resource.setURI(URI.createURI(ePackage.getNsURI())); + } + + if (extendedMetaData != null) + { + extendedMetaData.putPackage(extendedMetaData.getNamespace(ePackage), ePackage); + } + else + { + packageRegistry.put(ePackage.getNsURI(), ePackage); + } + } + handleForwardReferences(); + } + isInModels = false; + } + super.endElement(uri, localName, name); + } + + protected EPackage getPackageForURI(String uriString) + { + if ("commonj.sdo".equals(uriString)) + { + return SDOPackage.eINSTANCE; + } + else + { + return super.getPackageForURI(uriString); + } + } + + protected EObject createObjectFromFactory(EFactory factory, String typeName) + { + if (factory == SDOFactory.eINSTANCE) + { + if ("datagraph".equals(typeName)) + { + return super.createObjectFromFactory(factory, "EDataGraph"); + } + } + return super.createObjectFromFactory(factory, typeName); + } + + protected EcoreBuilder createEcoreBuilder(Map options, ExtendedMetaData extendedMetaData) + { + return new DefaultEcoreBuilder(extendedMetaData) + { + public Collection generate(Map urisToLocations) throws Exception + { + Collection result = super.generate(urisToLocations); + return updateDynamicFactory(result); + } + + public Collection generate(Collection urisToLocations) throws Exception + { + Collection result = super.generate(urisToLocations); + return updateDynamicFactory(result); + } + + protected Collection updateDynamicFactory(Collection result) + { + for (Iterator i = result.iterator(); i.hasNext();) + { + Resource resource = (Resource)i.next(); + for (Iterator j = EcoreUtil.getObjectsByType(resource.getContents(), EcorePackage.eINSTANCE.getEPackage()).iterator(); j.hasNext();) + { + EPackage ePackage = (EPackage)j.next(); + ePackage.setEFactoryInstance(new DynamicDataObjectImpl.FactoryImpl()); + } + } + return result; + } + + }; + } + + protected EPackage handleMissingPackage(String uriString) + { + EPackage result = super.handleMissingPackage(uriString); + if (processAnyXML && objects.size() == 1) + { + result = extendedMetaData.demandPackage(uriString); + } + return result; + } + }; + } + } + + protected XMLLoad createXMLLoad() + { + return new LoadImpl(createXMLHelper()); + } + } +} diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java new file mode 100644 index 0000000000..6c816090a4 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java @@ -0,0 +1,1727 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.util; + + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.tuscany.sdo.impl.SDOFactoryImpl; +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EFactory; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.ExtendedMetaData; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.ecore.util.FeatureMapUtil; +import org.eclipse.emf.ecore.xmi.impl.EMOFResourceFactoryImpl; +import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; +import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl; +import org.eclipse.emf.ecore.xml.type.internal.XMLCalendar; +import org.eclipse.xsd.util.XSDResourceFactoryImpl; + +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; +import commonj.sdo.helper.TypeHelper; + + +public final class DataObjectUtil +{ + public static BigDecimal getBigDecimal(Object value) + { + if (value instanceof BigDecimal) + { + return (BigDecimal)value; + } + + if (value instanceof BigInteger) + { + return new BigDecimal((BigInteger)value); + } + + if (value instanceof Number) + { + return new BigDecimal(((Number)value).doubleValue()); + } + + if (value instanceof String) + { + return new BigDecimal((String)value); + } + + if (value == null) + { + return null; + } + + throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to BigDecimal"); + } + + public static Object getSetValue(Property property, BigDecimal value) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)property; + EClassifier eType = eStructuralFeature.getEType(); + if (value == null) + { + return eType.getDefaultValue(); + } + + String name = eType.getInstanceClassName(); + if (name == "java.math.BigDecimal") + { + return value; + } + + if (name == "java.math.BigInteger") + { + return value.toBigInteger(); + } + + if (name == "java.lang.Byte" || name == "byte") + { + return new Byte(value.byteValue()); + } + + if (name == "java.lang.Double" || name == "double") + { + return new Double(value.doubleValue()); + } + + if (name == "java.lang.Float" || name == "float") + { + return new Float(value.floatValue()); + } + + if (name == "java.lang.Integer" || name == "int") + { + return new Integer(value.intValue()); + } + + if (name == "java.lang.Long" || name == "long") + { + return new Long(value.longValue()); + } + + if (name == "java.lang.Short" || name == "short") + { + return new Short(value.shortValue()); + } + + if (name == "java.lang.String") + { + return String.valueOf(value); + } + + //Instead of throwing an IllegalArgumentException we will pass the value to the property + return value; + } + + public static BigInteger getBigInteger(Object value) + { + if (value instanceof BigInteger) + { + return (BigInteger)value; + } + + if (value instanceof BigDecimal) + { + return ((BigDecimal)value).toBigInteger(); + } + + if (value instanceof Number) + { + return BigInteger.valueOf(((Number)value).longValue()); + } + + if (value instanceof String) + { + return new BigInteger((String)value); + } + + if (value instanceof byte[]) + { + return new BigInteger((byte[])value); + } + + if (value == null) + { + return null; + } + + throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to BigInteger"); + } + + public static Object getSetValue(Property property, BigInteger value) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)property; + EClassifier eType = eStructuralFeature.getEType(); + if (value == null) + { + return eType.getDefaultValue(); + } + + String name = eType.getInstanceClassName(); + if (name == "java.math.BigInteger") + { + return value; + } + + if (name == "java.math.BigDecimal") + { + return new BigDecimal(value); + } + + if (name == "java.lang.Byte" || name == "byte") + { + return new Byte(value.byteValue()); + } + + if (name == "java.lang.Double" || name == "double") + { + return new Double(value.doubleValue()); + } + + if (name == "java.lang.Float" || name == "float") + { + return new Float(value.floatValue()); + } + + if (name == "java.lang.Integer" || name == "int") + { + return new Integer(value.intValue()); + } + + if (name == "java.lang.Long" || name == "long") + { + return new Long(value.longValue()); + } + + if (name == "java.lang.Short" || name == "short") + { + return new Short(value.shortValue()); + } + + if (name == "java.lang.String") + { + return String.valueOf(value); + } + + if (name == "byte[]") + { + return value.toByteArray(); + } + + //Instead of throwing an IllegalArgumentException we will pass the value to the property + return value; + } + + public static boolean getBoolean(Object value) + { + if (value instanceof Boolean) + { + return ((Boolean)value).booleanValue(); + } + + if (value instanceof String) + { + return Boolean.valueOf((String)value).booleanValue(); + } + + if (value == null) + { + return false; + } + + throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to boolean"); + } + + public static Object getSetValue(Property property, boolean value) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)property; + String name = eStructuralFeature.getEType().getInstanceClassName(); + if (name == "java.lang.Boolean" || name == "boolean") + { + return value ? Boolean.TRUE : Boolean.FALSE; + } + + if (name == "java.lang.String") + { + return String.valueOf(value); + } + + //Instead of throwing an IllegalArgumentException we will pass the value to the property + return value ? Boolean.TRUE : Boolean.FALSE; + } + + public static byte getByte(Object value) + { + if (value instanceof Number) + { + return ((Number)value).byteValue(); + } + + if (value instanceof String) + { + return Byte.parseByte((String)value); + } + + if (value == null) + { + return 0; + } + + throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to byte"); + } + + public static Object getSetValue(Property property, byte value) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)property; + String name = eStructuralFeature.getEType().getInstanceClassName(); + if (name == "java.lang.Byte" || name == "byte") + { + return new Byte(value); + } + + if (name == "java.lang.Double" || name == "double") + { + return new Double(value); + } + + if (name == "java.lang.Float" || name == "float") + { + return new Float(value); + } + + if (name == "java.lang.Integer" || name == "int") + { + return new Integer(value); + } + + if (name == "java.lang.Long" || name == "long") + { + return new Long(value); + } + + if (name == "java.lang.Short" || name == "short") + { + return new Short(value); + } + + if (name == "java.math.BigDecimal") + { + return getBigDecimal(new Byte(value)); + } + + if (name == "java.math.BigInteger") + { + return getBigInteger(new Byte(value)); + } + + if (name == "java.lang.String") + { + return String.valueOf(value); + } + + //Instead of throwing an IllegalArgumentException we will pass the value to the property + return new Byte(value); + } + + public static byte[] getBytes(Object value) + { + if (value instanceof byte[]) + { + return (byte[])value; + } + + if (value instanceof BigInteger) + { + return ((BigInteger)value).toByteArray(); + } + + if (value == null) + { + return null; + } + + throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to byte array"); + } + + public static Object getSetValue(Property property, byte[] value) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)property; + EClassifier eType = eStructuralFeature.getEType(); + if (value == null) + { + return eType.getDefaultValue(); + } + + String name = eType.getInstanceClassName(); + if (name == "byte[]") + { + return value; + } + + if (name == "java.math.BigInteger") + { + return new BigInteger(value); + } + + //Instead of throwing an IllegalArgumentException we will pass the value to the property + return value; + } + + public static char getChar(Object value) + { + if (value instanceof Character) + { + return ((Character)value).charValue(); + } + + if (value instanceof String) + { + return ((String)value).charAt(0); + } + + if (value == null) + { + return 0; + } + + throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to char"); + } + + public static Object getSetValue(Property property, char value) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)property; + String name = eStructuralFeature.getEType().getInstanceClassName(); + if (name == "java.lang.Character" || name == "char") + { + return new Character(value); + } + + if (name == "java.lang.String") + { + return String.valueOf(value); + } + + //Instead of throwing an IllegalArgumentException we will pass the value to the property + return new Character(value); + } + + public static Date getDate(Object value) + { + if (value instanceof XMLCalendar) + { + return ((XMLCalendar)value).getDate(); + } + + if (value instanceof Date) + { + return (Date)value; + } + + if (value instanceof Long) + { + return new Date(((Long)value).longValue()); + } + + if (value == null) + { + return null; + } + + throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to Date"); + } + + public static Object getSetValue(Property property, Date value) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)property; + EClassifier eType = eStructuralFeature.getEType(); + if (value == null) + { + return eType.getDefaultValue(); + } + + String name = eType.getInstanceClassName(); + if (name == "java.lang.Object") + { + String typeName = getDateTypeName((EDataType)eType); + if ("Date".equals(typeName)) + { + return new XMLCalendar(value, XMLCalendar.DATE); + } + if ("DateTime".equals(typeName)) + { + return new XMLCalendar(value, XMLCalendar.DATETIME); + } + // Instead of throwing an IllegalArgumentException we will pass the value to the property + return value; + } + + if (name == "java.lang.Long" || name == "long") + { + return new Long(value.getTime()); + } + if (name == "java.lang.String") + { + return value.toString(); + } + + // Instead of throwing an IllegalArgumentException we will pass the value to the property + return value; + } + + protected static String getDateTypeName(EDataType eDataType) + { + String name = eDataType.getName(); + if (("DateTime".equals(name)) || ("Date".equals(name))) + { + return name; + } + + EDataType baseType = ExtendedMetaData.INSTANCE.getBaseType(eDataType); + if (baseType != null) + { + return getDateTypeName(baseType); + } + + List memberTypes = ExtendedMetaData.INSTANCE.getMemberTypes(eDataType); + if (!memberTypes.isEmpty()) + { + for (int i = 0, size = memberTypes.size(); i < size; ++i) + { + EDataType memberType = (EDataType)memberTypes.get(i); + String memberTypeName = getDateTypeName(memberType); + if (("DateTime".equals(memberTypeName)) || ("Date".equals(memberTypeName))) + { + return memberTypeName; + } + } + } + + return ""; + } + + public static double getDouble(Object value) + { + if (value instanceof Number) + { + return ((Number)value).doubleValue(); + } + + if (value instanceof String) + { + return Double.parseDouble((String)value); + } + + if (value == null) + { + return 0; + } + + throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to double"); + } + + public static Object getSetValue(Property property, double value) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)property; + String name = eStructuralFeature.getEType().getInstanceClassName(); + if (name == "java.lang.Byte" || name == "byte") + { + return new Byte((byte)value); + } + + if (name == "java.lang.Double" || name == "double") + { + return new Double(value); + } + + if (name == "java.lang.Float" || name == "float") + { + return new Float(value); + } + + if (name == "java.lang.Integer" || name == "int") + { + return new Integer((int)value); + } + + if (name == "java.lang.Long" || name == "long") + { + return new Long((long)value); + } + + if (name == "java.lang.Short" || name == "short") + { + return new Short((short)value); + } + + if (name == "java.math.BigDecimal") + { + return getBigDecimal(new Double(value)); + } + + if (name == "java.math.BigInteger") + { + return getBigInteger(new Double(value)); + } + + if (name == "java.lang.String") + { + return String.valueOf(value); + } + + //Instead of throwing an IllegalArgumentException we will pass the value to the property + return new Double(value); + } + + public static float getFloat(Object value) + { + if (value instanceof Number) + { + return ((Number)value).floatValue(); + } + + if (value instanceof String) + { + return Float.parseFloat((String)value); + } + + if (value == null) + { + return 0; + } + + throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to float"); + } + + public static Object getSetValue(Property property, float value) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)property; + String name = eStructuralFeature.getEType().getInstanceClassName(); + if (name == "java.lang.Byte" || name == "byte") + { + return new Byte((byte)value); + } + + if (name == "java.lang.Double" || name == "double") + { + return new Double(value); + } + + if (name == "java.lang.Float" || name == "float") + { + return new Float(value); + } + + if (name == "java.lang.Integer" || name == "int") + { + return new Integer((int)value); + } + + if (name == "java.lang.Long" || name == "long") + { + return new Long((long)value); + } + + if (name == "java.lang.Short" || name == "short") + { + return new Short((short)value); + } + + if (name == "java.math.BigDecimal") + { + return getBigDecimal(new Float(value)); + } + + if (name == "java.math.BigInteger") + { + return getBigInteger(new Float(value)); + } + + if (name == "java.lang.String") + { + return String.valueOf(value); + } + + // Instead of throwing an IllegalArgumentException we will pass the value to the property + return new Float(value); + } + + public static int getInt(Object value) + { + if (value instanceof Number) + { + return ((Number)value).intValue(); + } + + if (value instanceof String) + { + return Integer.parseInt((String)value); + } + + if (value == null) + { + return 0; + } + + throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to int"); + } + + public static Object getSetValue(Property property, int value) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)property; + String name = eStructuralFeature.getEType().getInstanceClassName(); + if (name == "java.lang.Byte" || name == "byte") + { + return new Byte((byte)value); + } + + if (name == "java.lang.Double" || name == "double") + { + return new Double(value); + } + + if (name == "java.lang.Float" || name == "float") + { + return new Float(value); + } + + if (name == "java.lang.Integer" || name == "int") + { + return new Integer(value); + } + + if (name == "java.lang.Long" || name == "long") + { + return new Long(value); + } + + if (name == "java.lang.Short" || name == "short") + { + return new Short((short)value); + } + + if (name == "java.math.BigDecimal") + { + return getBigDecimal(new Integer(value)); + } + + if (name == "java.math.BigInteger") + { + return getBigInteger(new Integer(value)); + } + + if (name == "java.lang.String") + { + return String.valueOf(value); + } + + // Instead of throwing an IllegalArgumentException we will pass the value to the property + return new Integer(value); + } + + public static long getLong(Object value) + { + if (value instanceof Number) + { + return ((Number)value).longValue(); + } + + if (value instanceof String) + { + return Long.parseLong((String)value); + } + + if (value instanceof Date) + { + return ((Date)value).getTime(); + } + + if (value == null) + { + return 0; + } + + throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to long"); + } + + public static Object getSetValue(Property property, long value) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)property; + String name = eStructuralFeature.getEType().getInstanceClassName(); + if (name == "java.lang.Byte" || name == "byte") + { + return new Byte((byte)value); + } + + if (name == "java.lang.Double" || name == "double") + { + return new Double(value); + } + + if (name == "java.lang.Float" || name == "float") + { + return new Float(value); + } + + if (name == "java.lang.Integer" || name == "int") + { + return new Integer((int)value); + } + + if (name == "java.lang.Long" || name == "long") + { + return new Long(value); + } + + if (name == "java.lang.Short" || name == "short") + { + return new Short((short)value); + } + + if (name == "java.math.BigDecimal") + { + return getBigDecimal(new Long(value)); + } + + if (name == "java.math.BigInteger") + { + return getBigInteger(new Long(value)); + } + + if (name == "java.lang.String") + { + return String.valueOf(value); + } + + if (name == "java.util.Date") + { + return new Date(value); + } + + // Instead of throwing an IllegalArgumentException we will pass the value to the property + return new Long(value); + } + + public static short getShort(Object value) + { + if (value instanceof Number) + { + return ((Number)value).shortValue(); + } + + if (value instanceof String) + { + return Short.parseShort((String)value); + } + + if (value == null) + { + return 0; + } + + throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to short"); + } + + public static Object getSetValue(Property property, short value) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)property; + String name = eStructuralFeature.getEType().getInstanceClassName(); + if (name == "java.lang.Byte" || name == "byte") + { + return new Byte((byte)value); + } + + if (name == "java.lang.Double" || name == "double") + { + return new Double(value); + } + + if (name == "java.lang.Float" || name == "float") + { + return new Float(value); + } + + if (name == "java.lang.Integer" || name == "int") + { + return new Integer(value); + } + + if (name == "java.lang.Long" || name == "long") + { + return new Long(value); + } + + if (name == "java.lang.Short" || name == "short") + { + return new Short(value); + } + + if (name == "java.math.BigDecimal") + { + return getBigDecimal(new Short(value)); + } + + if (name == "java.math.BigInteger") + { + return getBigInteger(new Short(value)); + } + + if (name == "java.lang.String") + { + return String.valueOf(value); + } + + // Instead of throwing an IllegalArgumentException we will pass the value to the property + return new Short(value); + } + + public static String getString(Object value) + { + if (value instanceof String) + { + return (String)value; + } + + if (value instanceof Number || value instanceof Boolean || value instanceof Character) + { + return String.valueOf(value); + } + + if (value == null) + { + return null; + } + + throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to String"); + } + + public static Object getSetValue(Property property, String value) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)property; + EClassifier eType = eStructuralFeature.getEType(); + if (value == null) + { + return eType.getDefaultValue(); + } + + String name = eType.getInstanceClassName(); + if (name == "java.lang.String") + { + return value; + } + + if (name == "java.lang.Byte" || name == "byte") + { + return Byte.valueOf(value); + } + + if (name == "java.lang.Double" || name == "double" || name == "java.lang.Number") + { + return Double.valueOf(value); + } + + if (name == "java.lang.Float" || name == "float") + { + return new Float(value); + } + + if (name == "java.lang.Integer" || name == "int") + { + return Integer.valueOf(value); + } + + if (name == "java.lang.Long" || name == "long") + { + return Long.valueOf(value); + } + + if (name == "java.lang.Short" || name == "short") + { + return Short.valueOf(value); + } + + if (name == "java.lang.Character" || name == "char") + { + return new Character(value.charAt(0)); + } + + if (name == "java.math.BigDecimal") + { + return getBigDecimal(value); + } + + if (name == "java.math.BigInteger") + { + return getBigInteger(value); + } + + if (name == "java.lang.Boolean" || name == "boolean") + { + return Boolean.valueOf(value); + } + + // Instead of throwing an IllegalArgumentException we will pass the value to the property + return value; + } + + public static EStructuralFeature getOpenFeature(EObject eObject, int featureID) + { + EClass eClass = eObject.eClass(); + int openFeatureCount = featureID - eClass.getFeatureCount(); + Set openFeatureSet = new HashSet(); + for (int i = 0, count = eClass.getEAllStructuralFeatures().size(); i < count; ++i) + { + EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature(i); + if (!eStructuralFeature.isDerived() && 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)) + { + if (--openFeatureCount < 0) return entryFeature; + } + } + } + } + throw new IndexOutOfBoundsException(); + } + + public static EStructuralFeature getOpenFeature(EObject eObject, String featureName) + { + 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 (/*!eStructuralFeature.isDerived() && */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 entryFeature; + + List aliasNames = property.getAliasNames(); + for (int aliasCount = aliasNames.size(); aliasCount > 0; ) + { + if (aliasNames.get(--aliasCount).equals(featureName)) return entryFeature; + } + } + } + } + } + throw new IllegalArgumentException("Class '" + eObject.eClass().getName() + "' does not have a feature named '" + featureName + "'"); + } + + public static List getAliasNames(EStructuralFeature eStructuralFeature) + { + List aliasNames = new ArrayList(); + String xmlName = ExtendedMetaData.INSTANCE.getName(eStructuralFeature); + if (!xmlName.equals(eStructuralFeature.getName())) + { + aliasNames.add(xmlName); + } + return aliasNames; + } + + public static List getAliasNames(EClassifier eClassifier) + { + List aliasNames = new ArrayList(); + String xmlName = ExtendedMetaData.INSTANCE.getName(eClassifier); + if (!xmlName.equals(eClassifier.getName())) + { + aliasNames.add(xmlName); + } + return aliasNames; + } + + /** + * Process the default EMF path and minimal XPath syntax. + * This design is still under review and construction. + * + * Syntax: + * + *
+   * path = /? (step '/')* step
+   * step = feature
+   *      | feature '.' index_from_0 
+   *      | feature '[' index_from_1 ']'
+   *      | reference '[' attribute '=' value ']'
+   *      | ..
+   *      | '@' step
+   *
+ * + * feature = the name of an attribute or reference + * attribute = the name of an attribute + * reference = the name of a reference + * index = positive integer + * value = the string value of an attribute + * leading / begins at the root + * .. is containing object + * + * features must be multi-valued to use '.' and '[' operations. + * Only the last step may have an attribute as the feature. + */ + public static final class Accessor //TODO rewrite this using SDO APIs + { + /** + * Creates an accessor for the path of the object. + */ + public static Accessor create(EObject eObject, String path) + { + Accessor result = pool.get(); + result.init(eObject, path); + return result; + } + + /** + * Only the get and recycle methods should be call; they are the only synchronized methods. + */ + protected static class Pool extends BasicEList + { + protected Accessor[] accessors; + + public Pool() + { + super(10); + } + + protected Object[] newData(int capacity) + { + return accessors = new Accessor [capacity]; + } + + /** + * Returns a recyled instance or a new instance. + */ + public synchronized Accessor get() + { + if (size > 0) + { + return accessors[--size]; + } + else + { + return new Accessor(); + } + } + + /** Safely gives the accessor back for recycled use. + */ + public synchronized void recycle(Accessor accessor) + { + int minimumCapacity = size + 1; + if (minimumCapacity > data.length) + { + grow(minimumCapacity); + } + accessors[size++] = accessor; + } + } + + /** + * A static thread safe pool of Accessors. + */ + static final Pool pool = new Pool(); + + protected static final int NO_INDEX = -1; + + protected EObject eObject; + + protected EStructuralFeature feature; + + protected int index; + + protected Accessor() + { + } + + protected Accessor(EObject eObject, String path) + { + init(eObject, path); + } + + protected void init(EObject eObject, String path) + { + this.eObject = eObject; + + // This should only be called with a path right now. + // + //feature = getType(eObject).getProperty(path).getEStructuralFeature(); + //if (feature == null) + { + process(path); + } + //else + { + //index = NO_INDEX; + } + } + + public Object get() + { + if (feature == null) + { + return eObject; + } + else + { + Object value = eObject.eGet(feature, true); + if (index >= 0) + { + value = ((List)value).get(index); + if (value instanceof FeatureMap.Entry) + { + value = ((FeatureMap.Entry)value).getValue(); + } + } + else if (FeatureMapUtil.isFeatureMap(feature)) + { + value = new BasicSequence((FeatureMap.Internal)value); + } + return value; + } + } + + public Object getAndRecyle() + { + Object result = get(); + pool.recycle(this); + return result; + } + + public void set(Object newValue) + { + if (index >= 0) + { + List list = (List)eObject.eGet(feature, true); + list.set(index, newValue); + } + else + { + // EATM newValue = string2Enum(feature, newValue); + eObject.eSet(feature, newValue); + } + } + + public void setAndRecyle(Object newValue) + { + set(newValue); + pool.recycle(this); + } + + public boolean isSet() + { + return eObject.eIsSet(feature); + } + + public boolean isSetAndRecyle() + { + boolean result = isSet(); + pool.recycle(this); + return result; + } + + public void unset() + { + eObject.eUnset(feature); + } + + public void unsetAndRecyle() + { + unset(); + pool.recycle(this); + } + + public void recycle() + { + pool.recycle(this); + } + + public EObject getEObject() + { + return eObject; + } + + protected void setEObject(EObject eObject) + { + this.eObject = eObject; + feature = null; + index = NO_INDEX; + } + + public EStructuralFeature getEStructuralFeature() + { + return feature; + } + + public Property getProperty() + { + return (Property)feature; + } + + protected void setFeatureName(String name) + { + if (name != null) + { + feature = (EStructuralFeature)((DataObject)eObject).getProperty(name); + } + else + { + feature = null; + } + index = NO_INDEX; + } + + protected int getIndex() + { + return index; + } + + protected void setIndex(int index) + { + this.index = index; + if (!FeatureMapUtil.isMany(eObject, feature)) + { + throw new IndexOutOfBoundsException("Index applies only to multi-valued features."); + } + } + + protected void process(String pathString) + { + TokenList tokens = new TokenList(pathString.toCharArray()); + String token; + int size = tokens.size(); + int x = 0; + + if ("/".equals(tokens.peek(0))) + { + setEObject(EcoreUtil.getRootContainer(eObject)); + x++; + } + + for (; x < size; x++) + { + token = tokens.peek(x); + char c = token.charAt(0); + if ('/' == c) + { + setEObject((EObject)get()); + } + else if ("..".equals(token)) + { + EObject container = eObject.eContainer(); + if (container == null) + { + throw new IllegalArgumentException("No containing object for " + eObject); + } + setEObject(container); + } + else if ('.' == c) + { + x++; // skip . + token = tokens.peek(x); + int index = Integer.parseInt(token); + setIndex(index); + } + else if ('[' == c) + { + x++; // skip [ + token = tokens.peek(x); // name or index + char following = tokens.peek(x + 1).charAt(0); + if ('=' != following) + { + int index = Integer.parseInt(token) - 1; + setIndex(index); + x++; // skip ] + } + else + { + x++; // done name + x++; // skip = + String attributeValue = tokens.peek(x); // value + if ("\"".equals(attributeValue)) + { + x++; // skip " + attributeValue = tokens.peek(++x); + } + x++; // skip ] + int index = matchingIndex((List)get(), token, attributeValue); + if (index < 0) + { + setEObject(null); + } + else + { + setIndex(index); + } + } + } + else if ('@' == c) + { + x++; // skip @ + } + else + { + setFeatureName(token); + } + } + } + + protected static int matchingIndex(List eObjects, String attributeName, String attributeValue) + { + for (int i = 0, size = eObjects.size(); i < size; i++) + { + EObject eObject = (EObject)eObjects.get(i); + EStructuralFeature feature = (EStructuralFeature)((Type)eObject.eClass()).getProperty(attributeName); + if (feature != null) + { + Object test = eObject.eGet(feature, true); + if (test != null) + { + String testString = EcoreUtil.convertToString((EDataType)feature.getEType(), test); + if (attributeValue.equals(testString)) + { + return i; + } + } + } + } + return -1; + } + + protected static class TokenList extends BasicEList + { + public TokenList(char[] path) + { + super(4); + + int pathLength = path.length; + StringBuffer token = new StringBuffer(); + char cPrev; + char c = 0; + char cNext; + char stringConstant = 0; + for (int pos = 0; pos < pathLength; pos++) + { + cPrev = c; + c = path[pos]; + cNext = pos < pathLength - 1 ? path[pos + 1] : 0; + + if (stringConstant != 0) + { + if (c == stringConstant) + { + endToken(token, true); + stringConstant = 0; + } + else + { + token.append(c); + } + } + else + { + switch (c) + { + case ' ': + case 0xA: + case 0xD: + case 0x9: + if (cPrev != ' ') + { + endToken(token, false); + } + c = ' '; + break; + + case '"': + case '\'': + endToken(token, false); + stringConstant = c; + break; + + // double or single tokens + case '/': + case ':': + case '.': + if (cPrev != c) + { + endToken(token, false); + } + token.append(c); + if (cNext != c) + { + endToken(token, false); + } + break; + + // single tokens + case '*': + case '@': + case '[': + case ']': + case '(': + case ')': + case '|': + endToken(token, false); + add(String.valueOf(c)); + break; + + // TODO: < > <= >= + - != + case '!': + endToken(token, false); + token.append(c); + break; + + case '=': + endToken(token, false); + add(String.valueOf(c)); + break; + + default: + token.append(c); + } + } + } + endToken(token, false); + } + + public String peek() + { + return size > 0 ? (String)data[0] : " "; + } + + public String peek(int index) + { + return index < size ? (String)data[index] : " "; + } + + public TokenList pop() + { + remove(0); + return this; + } + + public TokenList pop(int count) + { + while (count-- > 0) + { + remove(count); + } + return this; + } + + protected void endToken(StringBuffer token, boolean includeEmpty) + { + if (includeEmpty || token.length() > 0) + { + add(token.toString()); + } + token.setLength(0); + } + + protected boolean canContainNull() + { + return false; + } + + protected Object[] newData(int capacity) + { + return new String [capacity]; + } + } + + public String toString() + { + StringBuffer result = new StringBuffer("Accessor (object:"); + result.append(eObject == null ? "null" : eObject.toString()); + result.append(", feature:"); + result.append(feature == null ? "null" : feature.getName()); + result.append(", index:"); + result.append(index); + result.append(")"); + return result.toString(); + } + } + + public static Type getType(DataObject dataObject, String namespaceURI, String typeName) + { + DataGraph dataGraph = dataObject.getDataGraph(); + if (dataGraph != null) + { + return dataGraph.getType(namespaceURI, typeName); + } + else + { + //TODO think about where else to find the type + return TypeHelper.INSTANCE.getType(namespaceURI, typeName); + } + } + + public static Property getProperty(DataObject dataObject, String propertyName) + { + Property property = dataObject.getProperty(propertyName); + if (property == null) + { + throw new IllegalArgumentException("Type '" + dataObject.getType().getName() + "' does not have a property named '" + propertyName + "'"); + } + + return property; + } + + public static Property getProperty(DataObject dataObject, int propertyIndex) + { + List typeProperties = dataObject.getType().getProperties(); + + Property property = propertyIndex < typeProperties.size() ? + (Property)typeProperties.get(propertyIndex) : + (Property)dataObject.getInstanceProperties().get(propertyIndex); + + //FB maybe should catch bad index exception and throw IllegalArgumentException? + return property; + } + + public static Property getContainmentProperty(Property property) + { + if (property.isContainment()) + { + return property; + } + throw new IllegalArgumentException("The property '" + property.getName() + "' of '" + property.getContainingType().getName() + + "' isn't a containment"); + } + + public static DataObject create(Type type) + { + return (DataObject)EcoreUtil.create((EClass)type); + } + + public static ResourceSet createResourceSet() + { + ResourceSet result = new ResourceSetImpl(); + configureResourceSet(result); + return result; + } + + protected static Map registrations; + + protected static Map getRegistrations() + { + if (registrations == null) + { + Map result = new HashMap(); + + if (!(Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.datagraph")) instanceof DataGraphResourceFactoryImpl)) + { + result.put("datagraph", new DataGraphResourceFactoryImpl()); + } + if (!(Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.ecore")) instanceof EcoreResourceFactoryImpl)) + { + result.put("ecore", new EcoreResourceFactoryImpl()); + } + + if (!(Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.emof")) instanceof EMOFResourceFactoryImpl)) + { + result.put("emof", new EMOFResourceFactoryImpl()); + } + + if (Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.xsd")) == null) + { + result.put("xsd", new XSDResourceFactoryImpl()); + } + + //FIXME ClassCastException in XSDHelper.define() if you give it a WSDL file + // Patch for JIRA TUSCANY-42 + if (Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.wsdl")) == null) + { + result.put("wsdl", new XSDResourceFactoryImpl()); + } + + if (Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.*")) == null) + { + result.put("*", new XMLResourceFactoryImpl()); + } + + registrations = result; + } + + return registrations; + } + + protected static void configureResourceSet(ResourceSet resourceSet) + { + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().putAll(getRegistrations()); + } + + /** + * Configure EMF to support the SDO runtime by registering a specialized Ecore factory, SDOEcoreFactory. + * This static initializion must run before any SDO metadata is created or loaded. + * As long as SDO helper classes (e.g., TypeHelper, XMLHelper, etc.) are accessed though their + * corresponding INSTANCE fields (e.g., TypeHelper.INSTANCE), or using the SDOUtil methods (e.g., + * SDOUtil.createTypeHelper(), this will always be the case. + */ + static + { + EPackage.Registry.INSTANCE.put(EcorePackage.eNS_URI, new EPackage.Descriptor() + { + public EPackage getEPackage() + { + return EcorePackage.eINSTANCE; + } + + public EFactory getEFactory() + { + return new SDOFactoryImpl.SDOEcoreFactory(); + } + }); + } + + public static void initRuntime() + { + // NOOP since init is done during static initialization of this class. See above. + } + +} diff --git a/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/SDOUtil.java b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/SDOUtil.java new file mode 100644 index 0000000000..521bdec886 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/SDOUtil.java @@ -0,0 +1,221 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.util; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.reflect.Field; +import java.util.Map; + +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.helper.DataFactoryImpl; +import org.apache.tuscany.sdo.helper.TypeHelperImpl; +import org.apache.tuscany.sdo.helper.XMLHelperImpl; +import org.apache.tuscany.sdo.helper.XSDHelperImpl; +import org.apache.tuscany.sdo.impl.DataGraphImpl; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.impl.EPackageRegistryImpl; +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.EcoreUtil; +import org.eclipse.emf.ecore.util.ExtendedMetaData; +import org.eclipse.emf.ecore.xml.type.XMLTypePackage; + +import commonj.sdo.DataGraph; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; + +/** + * This class provides some useful static utility functions which are not specified in the SDO + * specification itself. Use of the functions in this class is recommended, instead of resorting + * to low-level implementation-specific APIs. + */ +public final class SDOUtil +{ + /** + * Creates an instance of a data type from the specified string. + * @param dataType a Type, for which isDataType() returns true, to instantiate. + * @param literal the string value of the dataType. + * @return an instance of the dataType. + * @see #convertToString(Type, Object) + */ + public static Object createFromString(Type dataType, String literal) + { + return EcoreUtil.createFromString((EDataType)dataType, literal); + } + + /** + * Converts an instance of a data type to a string literal representation. + * @param dataType the Type, for which isDataType() returns true, of the value to convert. + * @param value a value of the dataType. + * @return the string literal representation of the value. + * @see #createFromString(Type, String) + */ + public static String convertToString(Type dataType, Object value) + { + return EcoreUtil.convertToString((EDataType)dataType, value); + } + + /** + * Get the SDO built-in type corresponding to the specified XSD type in the XML Schema + * namespace ("http://www.w3.org/2001/XMLSchema"). + * @param xsdType a type name in the XML Schema namespace. + * @return the SDO built-in Type corresponding to the specified XSD type. + */ + public static Type getXSDSDOType(String xsdType) + { + //FIXME Temporary impl to be replaced with proper XSD to SDO mapping (see SDO spec - pg 95) + return (Type) + ("anyType".equals(xsdType) ? + SDOPackage.eINSTANCE.getDataObject() : + ExtendedMetaData.INSTANCE.getType(XMLTypePackage.eINSTANCE, xsdType)); + } + + /** + * Create an empty data graph. + * @return the new data graph instance. + */ + public static DataGraph createDataGraph() + { + return SDOFactory.eINSTANCE.createDataGraph(); + } + + /** + * Load a serialized data graph from the specified insputStream. + * @param inputStream the inputStream of the data graph. + * @param options loader control options, or null. + * @return the de-serialized data graph. + * @throws IOException + */ + public static DataGraph loadDataGraph(InputStream inputStream, Map options) throws IOException + { + ResourceSet resourceSet = DataObjectUtil.createResourceSet(); + Resource resource = resourceSet.createResource(URI.createURI("all.datagraph")); + resource.load(inputStream, options); + return (DataGraph)resource.getContents().get(0); + } + + /** + * Serialize the specified data graph to the specified outputStream. + * @param dataGraph the data graph to save. + * @param outputStream the outputStream for the data graph. + * @param options serializer control options, or null. + * @throws IOException + */ + public static void saveDataGraph(DataGraph dataGraph, OutputStream outputStream, Map options) throws IOException + { + ((DataGraphImpl)dataGraph).getDataGraphResource().save(outputStream, options); + } + + /** + * Create a new TypeHelper instance. The returned type helper will have visibility of types registered + * directly by calling a define method on it or by calling define on an associated XSDHelper. It will + * also have visibility of static types registered by calling SDOUtil.registerStaticTypes in the + * same classLoader scope. + * @return the new TypeHelper. + */ + public static TypeHelper createTypeHelper() + { + EPackage.Registry registry = new EPackageRegistryImpl(EPackage.Registry.INSTANCE); + ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(registry); //TODO create subclass that makes demand() methods synchronous + return new TypeHelperImpl(extendedMetaData); + } + + /** + * Create a new DataFactory, with visibility to types in the specified TypeHelper scope. + * @param scope the TypeHelper to use for locating types. + * @return the new DataFactory. + */ + public static DataFactory createDataFactory(TypeHelper scope) + { + return new DataFactoryImpl(scope); + } + + /** + * Create a new XMLHelper, with visibility to types in the specified TypeHelper scope. + * @param scope the TypeHelper to use for locating types. + * @return the new XMLHelper. + */ + public static XMLHelper createXMLHelper(TypeHelper scope) + { + return new XMLHelperImpl(scope); + } + + /** + * Create a new XSDHelper, with visibility to types in the specified TypeHelper scope. + * @param scope the TypeHelper to use for locating and populating types. + * @return the new XSDHelper. + */ + public static XSDHelper createXSDHelper(TypeHelper scope) + { + return new XSDHelperImpl(scope); + } + + /** + * Register and initialize the SDO types supported by the specified generated factory class. + * This function must be called before instances of the generated types can be created/used. + * The registered types will be visible in all TypeHelper's created in the same classLoader + * scope as the call to this function. + * @param factoryClass the generated factory class. + */ + public static void registerStaticTypes(Class factoryClass) + { + //TODO this implementation is a temporary kludge until the SDO generated factory pattern is decided + String temp = factoryClass.getName().replaceFirst("Factory$", "PackageImpl"); + int lastDot = temp.lastIndexOf('.'); + String packageName = temp.substring(0, lastDot) + ".impl" + temp.substring(lastDot); + try + { + Class javaClass = factoryClass.getClassLoader().loadClass(packageName); + Field field = javaClass.getField("eINSTANCE"); + field.get(null); + } + catch (Exception e1) + { + packageName = factoryClass.getName().replaceFirst("Factory$", "Package"); + try + { + Class javaClass = factoryClass.getClassLoader().loadClass(packageName); + Field field = javaClass.getField("eINSTANCE"); + field.get(null); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + } + + /** + * Initialize SDO runtime. + */ + static + { + DataObjectUtil.initRuntime(); + } + +} diff --git a/tags/java-stable-20060304/sdo/impl/src/main/resources/META-INF/MANIFEST.MF b/tags/java-stable-20060304/sdo/impl/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..240400a930 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/resources/META-INF/MANIFEST.MF @@ -0,0 +1,19 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: SDO Runtime Implementation +Bundle-SymbolicName: org.apache.tuscany.sdo.impl +Bundle-Version: 1.0.0 +Bundle-Localization: plugin +Bundle-Vendor: Apache +Require-Bundle: org.eclipse.emf.common, + org.eclipse.emf.ecore, + org.eclipse.emf.ecore.change, + org.eclipse.emf.ecore.xmi, + org.eclipse.xsd, + org.apache.tuscany.sdo.spec;visibility:=reexport +Export-Package: commonj.sdo.impl, + org.apache.tuscany.sdo, + org.apache.tuscany.sdo.helper, + org.apache.tuscany.sdo.impl, + org.apache.tuscany.sdo.test, + org.apache.tuscany.sdo.util diff --git a/tags/java-stable-20060304/sdo/impl/src/main/resources/META-INF/services/commonj.sdo.impl.HelperProvider b/tags/java-stable-20060304/sdo/impl/src/main/resources/META-INF/services/commonj.sdo.impl.HelperProvider new file mode 100644 index 0000000000..73693d6556 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/main/resources/META-INF/services/commonj.sdo.impl.HelperProvider @@ -0,0 +1 @@ +org.apache.tuscany.sdo.helper.HelperProviderImpl \ No newline at end of file diff --git a/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java new file mode 100644 index 0000000000..f862837715 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java @@ -0,0 +1,23 @@ +/** + * + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.codegen; + +/** + * @version $Rev$ $Date$ + */ +public interface Bar1 { +} diff --git a/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java new file mode 100644 index 0000000000..35a878015f --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java @@ -0,0 +1,23 @@ +/** + * + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.codegen; + +/** + * @version $Rev$ $Date$ + */ +public interface Bar2 { +} diff --git a/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java new file mode 100644 index 0000000000..61f0ebd4fe --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java @@ -0,0 +1,164 @@ +/** + * + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.codegen; + +import java.lang.reflect.Method; +import java.util.List; + +import junit.framework.TestCase; + +/** + * @version $Rev$ $Date$ + */ +public class BytecodeInterfaceGeneratorTestCase extends TestCase { + private MockType foo; + private BytecodeInterfaceGenerator gen; + private TestClassLoader cl; + + public void testHeaderNoBaseClass() { + gen.visitType(foo); + gen.visitEnd(); + Class c = cl.addClass(gen.getClassData()); + assertEquals("Foo", c.getName()); + assertTrue(c.isInterface()); + assertEquals(0, c.getInterfaces().length); + assertEquals(0, c.getMethods().length); + } + + public void testHeaderWithPackage() { + gen.visitType(new MockType("org.apache.Foo", null)); + gen.visitEnd(); + Class c = cl.addClass(gen.getClassData()); + assertEquals("org.apache.Foo", c.getName()); + assertEquals(0, c.getInterfaces().length); + assertEquals(0, c.getMethods().length); + } + + public void testHeaderOneBaseClass() throws NoJavaImplementationException { + foo.addBaseType(new MockType("bar1", Bar1.class)); + gen.visitType(foo); + gen.visitEnd(); + Class c = cl.addClass(gen.getClassData()); + assertEquals("Foo", c.getName()); + assertEquals(1, c.getInterfaces().length); + assertEquals(Bar1.class, c.getInterfaces()[0]); + assertEquals(0, c.getMethods().length); + } + + public void testHeaderMultipleBaseClass() throws NoJavaImplementationException { + foo.addBaseType(new MockType("bar1", Bar1.class)); + foo.addBaseType(new MockType("bar2", Bar2.class)); + gen.visitType(foo); + gen.visitEnd(); + Class c = cl.addClass(gen.getClassData()); + assertEquals("Foo", c.getName()); + assertEquals(2, c.getInterfaces().length); + assertEquals(Bar1.class, c.getInterfaces()[0]); + assertEquals(Bar2.class, c.getInterfaces()[1]); + assertEquals(0, c.getMethods().length); + } + + public void testBooleanProperty() throws NoJavaImplementationException, NoSuchMethodException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("true", Boolean.TYPE, false, false)); + gen.visitEnd(); + Class c = cl.addClass(gen.getClassData()); + assertEquals(2, c.getMethods().length); + Method getter = c.getMethod("isTrue"); + assertEquals(boolean.class, getter.getReturnType()); + Method setter = c.getMethod("setTrue", boolean.class); + assertEquals(void.class, setter.getReturnType()); + } + + public void testByteArrayProperty() throws NoJavaImplementationException, NoSuchMethodException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("bytes", byte[].class, false, false)); + gen.visitEnd(); + Class c = cl.addClass(gen.getClassData()); + assertEquals(2, c.getMethods().length); + Method getter = c.getMethod("getBytes"); + assertEquals(byte[].class, getter.getReturnType()); + Method setter = c.getMethod("setBytes", byte[].class); + assertEquals(void.class, setter.getReturnType()); + } + + public void testObjectProperty() throws NoJavaImplementationException, NoSuchMethodException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("bar", Bar1.class, false, false)); + gen.visitEnd(); + Class c = cl.addClass(gen.getClassData()); + assertEquals(2, c.getMethods().length); + Method getter = c.getMethod("getBar"); + assertEquals(Bar1.class, getter.getReturnType()); + Method setter = c.getMethod("setBar", Bar1.class); + assertEquals(void.class, setter.getReturnType()); + } + + public void testReadOnlyProperty() throws NoJavaImplementationException, NoSuchMethodException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("int", Integer.TYPE, false, true)); + gen.visitEnd(); + Class c = cl.addClass(gen.getClassData()); + assertEquals(1, c.getMethods().length); + Method getter = c.getMethod("getInt"); + assertEquals(int.class, getter.getReturnType()); + } + + public void testManyProperty() throws NoJavaImplementationException, NoSuchMethodException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("list", Integer.TYPE, true, false)); + gen.visitEnd(); + Class c = cl.addClass(gen.getClassData()); + assertEquals(1, c.getMethods().length); + Method getter = c.getMethod("getList"); + assertEquals(List.class, getter.getReturnType()); + } + + public void testTwoProperties() throws NoJavaImplementationException, NoSuchMethodException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("true", Boolean.TYPE, false, false)); + gen.visitProperty(new MockProperty("int", Integer.TYPE, false, false)); + gen.visitEnd(); + Class c = cl.addClass(gen.getClassData()); + assertEquals(4, c.getMethods().length); + Method getter = c.getMethod("isTrue"); + assertEquals(boolean.class, getter.getReturnType()); + Method setter = c.getMethod("setTrue", boolean.class); + assertEquals(void.class, setter.getReturnType()); + getter = c.getMethod("getInt"); + assertEquals(int.class, getter.getReturnType()); + setter = c.getMethod("setInt", int.class); + assertEquals(void.class, setter.getReturnType()); + } + + protected void setUp() throws Exception { + super.setUp(); + foo = new MockType("foo", null); + gen = new BytecodeInterfaceGenerator(); + cl = new TestClassLoader(); + } + + private class TestClassLoader extends ClassLoader { + public TestClassLoader() { + super(TestClassLoader.class.getClassLoader()); + } + + Class addClass(byte[] bytes) { + return defineClass(null, bytes, 0, bytes.length); + } + } +} diff --git a/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java new file mode 100644 index 0000000000..6a401d48bb --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java @@ -0,0 +1,23 @@ +/** + * + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.codegen; + +/** + * @version $Rev$ $Date$ + */ +public interface Foo { +} diff --git a/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java new file mode 100644 index 0000000000..ada15e151d --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java @@ -0,0 +1,126 @@ +/** + * + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.codegen; + +import java.io.PrintWriter; +import java.io.StringWriter; + +import junit.framework.TestCase; + +/** + * @version $Rev$ $Date$ + */ +public class JavaInterfaceGeneratorTestCase extends TestCase { + private static final String SEP = System.getProperty("line.separator"); + + private JavaInterfaceGenerator gen; + private StringWriter writer; + private MockType foo; + + public void testHeaderNoBaseClass() { + gen.visitType(foo); + gen.visitEnd(); + assertEquals(localize("public interface Foo {\n}\n"), writer.toString()); + } + + public void testHeaderWithPackage() { + gen.visitType(new MockType("org.apache.Foo", null)); + gen.visitEnd(); + assertEquals(localize("package org.apache;\n\npublic interface Foo {\n}\n"), writer.toString()); + } + + public void testHeaderOneBaseClass() throws NoJavaImplementationException { + foo.addBaseType(new MockType("bar1", Bar1.class)); + gen.visitType(foo); + gen.visitEnd(); + assertEquals(localize("public interface Foo extends org.apache.tuscany.sdo.codegen.Bar1 {\n}\n"), writer.toString()); + } + + public void testHeaderMultipleBaseClass() throws NoJavaImplementationException { + foo.addBaseType(new MockType("bar1", Bar1.class)); + foo.addBaseType(new MockType("bar2", Bar2.class)); + gen.visitType(foo); + gen.visitEnd(); + assertEquals(localize("public interface Foo extends org.apache.tuscany.sdo.codegen.Bar1, org.apache.tuscany.sdo.codegen.Bar2 {\n}\n"), writer.toString()); + } + + public void testBooleanProperty() throws NoJavaImplementationException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("true", Boolean.TYPE, false, false)); + gen.visitEnd(); + assertEquals(localize("public interface Foo {\n\tboolean isTrue();\n\tvoid setTrue(boolean value);\n}\n"), writer.toString()); + } + + public void testByteArrayProperty() throws NoJavaImplementationException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("bytes", byte[].class, false, false)); + gen.visitEnd(); + assertEquals(localize("public interface Foo {\n\tbyte[] getBytes();\n\tvoid setBytes(byte[] value);\n}\n"), writer.toString()); + } + + public void testObjectProperty() throws NoJavaImplementationException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("bar", Bar1.class, false, false)); + gen.visitEnd(); + assertEquals(localize("public interface Foo {\n\torg.apache.tuscany.sdo.codegen.Bar1 getBar();\n\tvoid setBar(org.apache.tuscany.sdo.codegen.Bar1 value);\n}\n"), writer.toString()); + } + + public void testReadOnlyProperty() throws NoJavaImplementationException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("int", Integer.TYPE, false, true)); + gen.visitEnd(); + assertEquals(localize("public interface Foo {\n\tint getInt();\n}\n"), writer.toString()); + } + + public void testManyProperty() throws NoJavaImplementationException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("list", Integer.TYPE, true, false)); + gen.visitEnd(); + assertEquals(localize("public interface Foo {\n\tjava.util.List getList();\n}\n"), writer.toString()); + } + + public void testTwoProperties() throws NoJavaImplementationException { + gen.visitType(foo); + gen.visitProperty(new MockProperty("true", Boolean.TYPE, false, false)); + gen.visitProperty(new MockProperty("int", Integer.TYPE, false, false)); + gen.visitEnd(); + assertEquals(localize("public interface Foo {\n\tboolean isTrue();\n\tvoid setTrue(boolean value);\n\tint getInt();\n\tvoid setInt(int value);\n}\n"), writer.toString()); + } + + protected void setUp() throws Exception { + super.setUp(); + writer = new StringWriter(); + gen = new JavaInterfaceGenerator(new PrintWriter(writer)); + foo = new MockType("foo", null); + } + + private String localize(String s) { + StringBuilder b = new StringBuilder(s.length() + s.length()/10); + for (int i = 0; i < s.length(); i++) { + char ch = s.charAt(i); + if (ch == '\t') { + b.append(" "); + } else if (ch == '\n') { + b.append(SEP); + } else { + b.append(ch); + } + } + return b.toString(); + } + +} diff --git a/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java new file mode 100644 index 0000000000..5cee856217 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java @@ -0,0 +1,75 @@ +/** + * + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.codegen; + +import java.util.List; + +import commonj.sdo.Property; +import commonj.sdo.Type; + +/** + * @version $Rev$ $Date$ + */ +class MockProperty implements Property { + private final String name; + private final Type type; + private final boolean many; + private final boolean readOnly; + + public MockProperty(String name, Class type, boolean many, boolean readOnly) { + this.name = name; + this.type = new MockType(null, type); + this.many = many; + this.readOnly = readOnly; + } + + public String getName() { + return name; + } + + public Type getType() { + return type; + } + + public boolean isMany() { + return many; + } + + public boolean isContainment() { + throw new UnsupportedOperationException(); + } + + public Type getContainingType() { + throw new UnsupportedOperationException(); + } + + public Object getDefault() { + throw new UnsupportedOperationException(); + } + + public boolean isReadOnly() { + return readOnly; + } + + public Property getOpposite() { + throw new UnsupportedOperationException(); + } + + public List /*String*/ getAliasNames() { + throw new UnsupportedOperationException(); + } +} diff --git a/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java new file mode 100644 index 0000000000..7aa880b1e9 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java @@ -0,0 +1,93 @@ +/** + * + * Copyright 2005 The Apache Software Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.codegen; + +import java.util.List; +import java.util.ArrayList; + +import commonj.sdo.Type; +import commonj.sdo.Property; + +/** + * @version $Rev$ $Date$ + */ +class MockType implements Type { + private final String name; + private final Class javaClass; + private final List baseTypes = new ArrayList(); + + public MockType(String name, Class javaClass) { + this.javaClass = javaClass; + this.name = name; + } + + public void addBaseType(Type baseType) { + baseTypes.add(baseType); + } + + public String getName() { + return name; + } + + public String getURI() { + throw new UnsupportedOperationException(); + } + + public Class getInstanceClass() { + return javaClass; + } + + public boolean isInstance(Object object) { + throw new UnsupportedOperationException(); + } + + public List /*Property*/ getProperties() { + throw new UnsupportedOperationException(); + } + + public Property getProperty(String propertyName) { + throw new UnsupportedOperationException(); + } + + public boolean isDataType() { + throw new UnsupportedOperationException(); + } + + public boolean isOpen() { + throw new UnsupportedOperationException(); + } + + public boolean isSequenced() { + throw new UnsupportedOperationException(); + } + + public boolean isAbstract() { + throw new UnsupportedOperationException(); + } + + public List /*Type*/ getBaseTypes() { + return baseTypes; + } + + public List /*Property*/ getDeclaredProperties() { + throw new UnsupportedOperationException(); + } + + public List /*String*/ getAliasNames() { + throw new UnsupportedOperationException(); + } +} diff --git a/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java new file mode 100644 index 0000000000..dbb6b7af46 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java @@ -0,0 +1,90 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.test; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.net.URL; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.helper.XSDHelper; +import junit.framework.TestCase; + +import org.apache.tuscany.sdo.util.SDOUtil; + + +public class ChangeSummaryTestCase extends TestCase { + private final String TEST_MODEL = "/simple.xsd"; + private final String TEST_DATA = "/simplechangesummary.xml"; + + /** + * Simple ChangeSummary test. + */ + public void testChangeSummary() throws IOException { + // Create an empty data graph and add a root object, an instance of type Quote + // + + DataGraph dataGraph = SDOUtil.createDataGraph(); + DataObject quote = dataGraph.createRootObject("http://www.example.com/simple", "Quote"); + + // Begin logging changes + // + ChangeSummary changeSummary = dataGraph.getChangeSummary(); + changeSummary.beginLogging(); + + // Modify the data graph in various fun and interesting ways + // + quote.setString("symbol", "fbnt"); + quote.setString("companyName", "FlyByNightTechnology"); + quote.setBigDecimal("price", new BigDecimal("1000.0")); + quote.setBigDecimal("open1", new BigDecimal("1000.0")); + quote.setBigDecimal("high", new BigDecimal("1000.0")); + quote.setBigDecimal("low", new BigDecimal("1000.0")); + quote.setDouble("volume", 1000); + quote.setDouble("change1", 1000); + + DataObject child = quote.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("2000.0")); + + // Stop logging changes and print the resulting data graph to stdout + // + changeSummary.endLogging(); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SDOUtil.saveDataGraph(dataGraph, baos, null); + + assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(TEST_DATA))); + } + + protected void setUp() throws Exception { + super.setUp(); + + // Populate the meta data for the test (Stock Quote) model + URL url = getClass().getResource(TEST_MODEL); + InputStream inputStream = url.openStream(); + XSDHelper.INSTANCE.define(inputStream, url.toString()); + inputStream.close(); + } +} diff --git a/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java new file mode 100644 index 0000000000..faa8782a77 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java @@ -0,0 +1,65 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.test; + + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.List; + +import junit.framework.TestCase; + +import commonj.sdo.Type; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XSDHelper; + + +public class DataTypeBaseTypeTestCase extends TestCase { + private final String TEST_MODEL = "/datatype.xsd"; + private final String TEST_NAMESPACE = "http://www.example.com/datatype"; + + public void testSimpleSDOType() throws IOException + { + Type type = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "SimpleSDOType"); + List baseTypes = type.getBaseTypes(); + assertTrue(baseTypes.size() == 1); + } + + public void testSimpleSDOTypeInstanceClass() throws IOException + { + Type type = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "SimpleSDOTypeInstanceClass"); + List baseTypes = type.getBaseTypes(); + assertTrue(baseTypes.size() == 0); + } + + public void testSimpleSDOTypeExtendedInstanceClass() throws IOException + { + Type type = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "SimpleSDOTypeExtendedInstanceClass"); + List baseTypes = type.getBaseTypes(); + assertTrue(baseTypes.size() == 1); + } + + public void setUp() throws Exception + { + URL url = getClass().getResource(TEST_MODEL); + InputStream inputStream = url.openStream(); + XSDHelper.INSTANCE.define(inputStream, url.toString()); + inputStream.close(); + } + +} diff --git a/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java new file mode 100644 index 0000000000..e46f9858e2 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java @@ -0,0 +1,86 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.test; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.net.URL; + +import commonj.sdo.DataObject; +import commonj.sdo.Sequence; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; +import junit.framework.TestCase; + + +public class MixedTypeTestCase extends TestCase { + private final String TEST_MODEL = "/mixed.xsd"; + private final String TEST_NAMESPACE = "http://www.example.com/mixed"; + private final String TEST_DATA = "/mixed.xml"; + + /** + * Sequenced type SDO 2 test. + */ + public void testSequencedType() throws IOException { + Type quoteType = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "MixedQuote"); + DataObject quote = DataFactory.INSTANCE.create(quoteType); + + Sequence sequence = quote.getSequence(); + + sequence.add("\n "); + + quote.setString("symbol", "fbnt"); + + sequence.add("\n "); + + quote.setString("companyName", "FlyByNightTechnology"); + + sequence.add("\n some text\n "); + + DataObject child = quote.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("2000.0")); + + sequence.add("\n more text\n "); + + // quote.setBigDecimal("price", new BigDecimal("1000.0")); + sequence.add("price", new BigDecimal("1000.0")); + + sequence.add("\n"); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + XMLHelper.INSTANCE.save(quote, TEST_NAMESPACE, "mixedStockQuote", baos); + + assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(TEST_DATA))); + } + + protected void setUp() throws Exception { + super.setUp(); + + // Populate the meta data for the test (Stock Quote) model + URL url = getClass().getResource(TEST_MODEL); + InputStream inputStream = url.openStream(); + XSDHelper.INSTANCE.define(inputStream, url.toString()); + inputStream.close(); + } +} diff --git a/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java new file mode 100644 index 0000000000..7e743e296a --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java @@ -0,0 +1,82 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.test; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.net.URL; +import java.util.Iterator; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; +import junit.framework.TestCase; + + +public class OpenTypeTestCase extends TestCase { + private final String TEST_MODEL = "/open.xsd"; + private final String TEST_NAMESPACE = "http://www.example.com/open"; + private final String TEST_DATA = "/open.xml"; + + /** + * Open content SDO 2 test. + */ + public void testOpenType() throws IOException { + Type quoteType = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "OpenQuote"); + DataObject quote = DataFactory.INSTANCE.create(quoteType); + + quote.setString("symbol", "s1"); + + for (Iterator iter = quote.getInstanceProperties().iterator(); iter.hasNext();) { + Property property = (Property) iter.next(); + } + + Property companyProperty = XSDHelper.INSTANCE.getGlobalProperty(TEST_NAMESPACE, "company", true); + DataObject company = quote.createDataObject(companyProperty); + company.setString("name", "FlyByNightTechnology"); + + Property priceProperty = XSDHelper.INSTANCE.getGlobalProperty(TEST_NAMESPACE, "price", true); + quote.getList(priceProperty).add(new BigDecimal("1000.0")); + + for (Iterator iter = quote.getInstanceProperties().iterator(); iter.hasNext();) { + Property property = (Property) iter.next(); + } + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + XMLHelper.INSTANCE.save(quote, TEST_NAMESPACE, "openStockQuote", baos); + + assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(TEST_DATA))); + } + + protected void setUp() throws Exception { + super.setUp(); + + // Populate the meta data for the test (Stock Quote) model + URL url = getClass().getResource(TEST_MODEL); + InputStream inputStream = url.openStream(); + XSDHelper.INSTANCE.define(inputStream, url.toString()); + inputStream.close(); + } +} diff --git a/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java new file mode 100644 index 0000000000..2e91a1a66f --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java @@ -0,0 +1,68 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.test; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; + +import commonj.sdo.DataObject; +import commonj.sdo.helper.CopyHelper; +import commonj.sdo.helper.XMLDocument; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; +import junit.framework.TestCase; + +public class SimpleCopyTestCase extends TestCase { + + private final String TEST_MODEL = "/simple.xsd"; + private final String TEST_NAMESPACE = "http://www.example.com/simple"; + private final String QUOTE_XML = "/quote.xml"; + private final String SHALLOW_QUOTE_XML = "/shallowquote.xml"; + + public void testSimpleCopy() throws IOException { + XMLDocument doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(QUOTE_XML)); + DataObject sdo = doc.getRootObject(); + + DataObject copiedSdo = CopyHelper.INSTANCE.copyShallow(sdo); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + XMLHelper.INSTANCE.save(copiedSdo, TEST_NAMESPACE, "stockQuote", baos); + assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(SHALLOW_QUOTE_XML))); + assertFalse(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(QUOTE_XML))); + + copiedSdo = CopyHelper.INSTANCE.copy(sdo); + + baos.reset(); + XMLHelper.INSTANCE.save(copiedSdo, TEST_NAMESPACE, "stockQuote", baos); + assertFalse(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(SHALLOW_QUOTE_XML))); + assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(QUOTE_XML))); + } + + protected void setUp() throws Exception { + super.setUp(); + + // Populate the meta data for the test (Stock Quote) model + URL url = getClass().getResource(TEST_MODEL); + InputStream inputStream = url.openStream(); + XSDHelper.INSTANCE.define(inputStream, url.toString()); + inputStream.close(); + } + +} diff --git a/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java new file mode 100644 index 0000000000..d4f425457f --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java @@ -0,0 +1,81 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.test; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.File; +import java.io.FileInputStream; +import java.math.BigDecimal; +import java.net.URL; + +import commonj.sdo.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XMLDocument; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; +import junit.framework.TestCase; + + +public class SimpleDynamicTestCase extends TestCase { + private final String TEST_MODEL = "/simple.xsd"; + private final String TEST_NAMESPACE = "http://www.example.com/simple"; + private final String QUOTE_XML = "/quote.xml"; + + /** + * Simple Dynamic SDO 2 test. + */ + public void testDynamic() throws IOException { + Type quoteType = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "Quote"); + DataObject quote = DataFactory.INSTANCE.create(quoteType); + + quote.setString("symbol", "fbnt"); + quote.setString("companyName", "FlyByNightTechnology"); + quote.setBigDecimal("price", new BigDecimal("1000.0")); + quote.setBigDecimal("open1", new BigDecimal("1000.0")); + quote.setBigDecimal("high", new BigDecimal("1000.0")); + quote.setBigDecimal("low", new BigDecimal("1000.0")); + quote.setDouble("volume", 1000); + quote.setDouble("change1", 1000); + + DataObject child = quote.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("2000.0")); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + XMLHelper.INSTANCE.save(quote, TEST_NAMESPACE, "stockQuote", baos); + + assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(QUOTE_XML))); + } + + + protected void setUp() throws Exception { + super.setUp(); + + // Populate the meta data for the test (Stock Quote) model + URL url = getClass().getResource(TEST_MODEL); + InputStream inputStream = url.openStream(); + XSDHelper.INSTANCE.define(inputStream, url.toString()); + inputStream.close(); + } + +} diff --git a/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java new file mode 100644 index 0000000000..ac05b362d9 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java @@ -0,0 +1,60 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.test; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; + +import commonj.sdo.DataObject; +import commonj.sdo.helper.EqualityHelper; +import commonj.sdo.helper.XMLDocument; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; +import junit.framework.TestCase; + +public class SimpleEqualityTestCase extends TestCase { + private static final String TEST_MODEL = "/simple.xsd"; + private static final String QUOTE_XML = "/quote.xml"; + private static final String SHALLOW_QUOTE_XML = "/shallowquote.xml"; + + public void testEquality() throws IOException { + + XMLDocument doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(QUOTE_XML)); + DataObject sdo = doc.getRootObject(); + + doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(SHALLOW_QUOTE_XML)); + DataObject shallowSdo = doc.getRootObject(); + + boolean result = EqualityHelper.INSTANCE.equalShallow(sdo, shallowSdo); + assertTrue(result); + + result = EqualityHelper.INSTANCE.equal(sdo, shallowSdo); + assertFalse(result); + } + + + protected void setUp() throws Exception { + super.setUp(); + + // Populate the meta data for the test (Stock Quote) model + URL url = getClass().getResource(TEST_MODEL); + InputStream inputStream = url.openStream(); + XSDHelper.INSTANCE.define(inputStream, url.toString()); + inputStream.close(); + } +} diff --git a/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java new file mode 100644 index 0000000000..a377281622 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java @@ -0,0 +1,168 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.test; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.FactoryConfigurationError; +import javax.xml.parsers.ParserConfigurationException; + +import org.w3c.dom.Document; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +public class TestUtil +{ + private static void getAllNodes(NodeList nodeList, List nodes) + { + int length = nodeList.getLength(); + if (length == 0) + { + return; + } + + for (int i=0; i sourceNodes = new ArrayList(); + ArrayList targetNodes = new ArrayList(); + + getAllNodes(sourceNodeList, sourceNodes); + getAllNodes(targetNodeList, targetNodes); + + int sourceLength = sourceNodes.size(); + int targetLength = targetNodes.size(); + + if (sourceLength != targetLength) + { + return false; + } + + for (int i=0; i types = XSDHelper.INSTANCE.define(modelURL.openStream(), modelURL.toString()); + assertEquals(2, types.size()); + } + + public void testDefineWithNoLocation() { + List types = XSDHelper.INSTANCE.define(getClass().getResourceAsStream(TEST_MODEL), null); + assertEquals(2, types.size()); + } + + public void testDuplicateDefineWithLocation() throws IOException { + List types = XSDHelper.INSTANCE.define(modelURL.openStream(), modelURL.toString()); + assertEquals(2, types.size()); + + List types2 = XSDHelper.INSTANCE.define(modelURL.openStream(), modelURL.toString()); + assertEquals(types, types2); + } + + protected void setUp() throws Exception { + super.setUp(); + modelURL = getClass().getResource(TEST_MODEL); + } +} diff --git a/tags/java-stable-20060304/sdo/impl/src/test/resources/datatype.xsd b/tags/java-stable-20060304/sdo/impl/src/test/resources/datatype.xsd new file mode 100644 index 0000000000..73b2c25e79 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/resources/datatype.xsd @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + diff --git a/tags/java-stable-20060304/sdo/impl/src/test/resources/mixed.xml b/tags/java-stable-20060304/sdo/impl/src/test/resources/mixed.xml new file mode 100644 index 0000000000..42ff3a3a5b --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/resources/mixed.xml @@ -0,0 +1,9 @@ + + + fbnt + FlyByNightTechnology + some text + 2000.0 + more text + 1000.0 + \ No newline at end of file diff --git a/tags/java-stable-20060304/sdo/impl/src/test/resources/mixed.xsd b/tags/java-stable-20060304/sdo/impl/src/test/resources/mixed.xsd new file mode 100644 index 0000000000..d4881d915e --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/resources/mixed.xsd @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/tags/java-stable-20060304/sdo/impl/src/test/resources/open.xml b/tags/java-stable-20060304/sdo/impl/src/test/resources/open.xml new file mode 100644 index 0000000000..d4a5b92e0c --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/resources/open.xml @@ -0,0 +1,8 @@ + + + s1 + + FlyByNightTechnology + + 1000.0 + \ No newline at end of file diff --git a/tags/java-stable-20060304/sdo/impl/src/test/resources/open.xsd b/tags/java-stable-20060304/sdo/impl/src/test/resources/open.xsd new file mode 100644 index 0000000000..bac23dd051 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/resources/open.xsd @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tags/java-stable-20060304/sdo/impl/src/test/resources/quote.xml b/tags/java-stable-20060304/sdo/impl/src/test/resources/quote.xml new file mode 100644 index 0000000000..d7b5969e23 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/resources/quote.xml @@ -0,0 +1,14 @@ + + + fbnt + FlyByNightTechnology + 1000.0 + 1000.0 + 1000.0 + 1000.0 + 1000.0 + 1000.0 + + 2000.0 + + \ No newline at end of file diff --git a/tags/java-stable-20060304/sdo/impl/src/test/resources/shallowquote.xml b/tags/java-stable-20060304/sdo/impl/src/test/resources/shallowquote.xml new file mode 100644 index 0000000000..a56f2fe2b7 --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/resources/shallowquote.xml @@ -0,0 +1,11 @@ + + + fbnt + FlyByNightTechnology + 1000.0 + 1000.0 + 1000.0 + 1000.0 + 1000.0 + 1000.0 + \ No newline at end of file diff --git a/tags/java-stable-20060304/sdo/impl/src/test/resources/simple.xsd b/tags/java-stable-20060304/sdo/impl/src/test/resources/simple.xsd new file mode 100644 index 0000000000..f5b0b982af --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/resources/simple.xsd @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/tags/java-stable-20060304/sdo/impl/src/test/resources/simplechangesummary.xml b/tags/java-stable-20060304/sdo/impl/src/test/resources/simplechangesummary.xml new file mode 100644 index 0000000000..7ac7a7cb2a --- /dev/null +++ b/tags/java-stable-20060304/sdo/impl/src/test/resources/simplechangesummary.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + fbnt + FlyByNightTechnology + 1000.0 + 1000.0 + 1000.0 + 1000.0 + 1000.0 + 1000.0 + + 2000.0 + + + -- cgit v1.2.3