diff options
author | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
---|---|---|
committer | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
commit | bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a (patch) | |
tree | 38a92061c0793434c4be189f1d70c3458b6bc41d /sandbox/jboynes/sdo/impl/src |
Move Tuscany from Incubator to top level.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sandbox/jboynes/sdo/impl/src')
170 files changed, 47948 insertions, 0 deletions
diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/AnyTypeDataObject.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/AnyTypeDataObject.java new file mode 100644 index 0000000000..79deec6d29 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/AnyTypeDataObject.java @@ -0,0 +1,37 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo; + +import commonj.sdo.DataObject; + +import org.eclipse.emf.ecore.xml.type.AnyType; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Any Type Data Object</b></em>'. + * <!-- end-user-doc --> + * + * + * @see org.apache.tuscany.sdo.SDOPackage#getAnyTypeDataObject() + * @model extendedMetaData="kind='mixed'" + * @generated + */ +public interface AnyTypeDataObject extends DataObject, AnyType { +} // AnyTypeDataObject diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOExtendedMetaData.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOExtendedMetaData.java new file mode 100644 index 0000000000..355b62f7b2 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOExtendedMetaData.java @@ -0,0 +1,38 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo; + +import java.util.List; + +import org.apache.tuscany.sdo.helper.SDOExtendedMetaDataImpl; +import org.eclipse.emf.ecore.EModelElement; +import org.eclipse.emf.ecore.util.ExtendedMetaData; + +public interface SDOExtendedMetaData extends ExtendedMetaData { + + SDOExtendedMetaData INSTANCE = new SDOExtendedMetaDataImpl(); + + List getAliasNames(EModelElement eModelElement); + + void setAliasNames(EModelElement eModelElement, List aliasNames); + + void setAliasNames(EModelElement eModelElement, String aliasNames); + +} diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOFactory.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOFactory.java new file mode 100644 index 0000000000..6d07e4b01a --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOFactory.java @@ -0,0 +1,176 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo; + +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; + +/** + * <!-- begin-user-doc --> + * The <b>Factory</b> for the model. + * It provides a create method for each non-abstract class of the model. + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.SDOPackage + * @generated + */ +public interface SDOFactory extends EFactory{ + /** + * The singleton instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + SDOFactory eINSTANCE = org.apache.tuscany.sdo.impl.SDOFactoryImpl.init(); + + /** + * Returns a new object of class '<em>Change Summary</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Change Summary</em>'. + * @generated + */ + ChangeSummary createChangeSummary(); + + /** + * Returns a new object of class '<em>Change Summary Setting</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Change Summary Setting</em>'. + * @generated + */ + ChangeSummary.Setting createChangeSummarySetting(); + + /** + * Returns a new object of class '<em>Data Graph</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Data Graph</em>'. + * @generated + */ + DataGraph createDataGraph(); + + /** + * Returns a new object of class '<em>Any Type Data Object</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Any Type Data Object</em>'. + * @generated + */ + AnyTypeDataObject createAnyTypeDataObject(); + + /** + * Returns a new object of class '<em>Simple Any Type Data Object</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Simple Any Type Data Object</em>'. + * @generated + */ + SimpleAnyTypeDataObject createSimpleAnyTypeDataObject(); + + /** + * Returns a new object of class '<em>Class</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Class</em>'. + * @generated + */ + Type createClass(); + + /** + * Returns a new object of class '<em>Data Type</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Data Type</em>'. + * @generated + */ + Type createDataType(); + + /** + * Returns a new object of class '<em>Attribute</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Attribute</em>'. + * @generated + */ + Property createAttribute(); + + /** + * Returns a new object of class '<em>Reference</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Reference</em>'. + * @generated + */ + Property createReference(); + + /** + * Returns a new object of class '<em>Enum</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Enum</em>'. + * @generated + */ + Type createEnum(); + + /** + * Returns a new object of class '<em>Dynamic Data Object</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Dynamic Data Object</em>'. + * @generated + */ + DataObject createDynamicDataObject(); + + /** + * Returns a new object of class '<em>Store Data Object</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Store Data Object</em>'. + * @generated + */ + DataObject createStoreDataObject(); + + /** + * Returns a new object of class '<em>Dynamic Store Data Object</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Dynamic Store Data Object</em>'. + * @generated + */ + DataObject createDynamicStoreDataObject(); + + /** + * Returns the package supported by this factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the package supported by this factory. + * @generated + */ + SDOPackage getSDOPackage(); + + ChangeSummary.Setting createChangeSummarySetting(EStructuralFeature eStructuralFeature, Object value, boolean isSet); + +} //SDOFactory diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOPackage.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOPackage.java new file mode 100644 index 0000000000..f9023aec4b --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOPackage.java @@ -0,0 +1,1602 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo; + +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; + +/** + * <!-- begin-user-doc --> + * The <b>Package</b> for the model. + * It contains accessors for the meta objects to represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.SDOFactory + * @model kind="package" + * @generated + */ +public interface SDOPackage extends EPackage{ + /** + * The package name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNAME = "sdo"; + + /** + * The package namespace URI. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNS_URI = "http://www.apache.org/tuscany/2005/SDO"; + + /** + * The package namespace name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + String eNS_PREFIX = "sdo"; + + /** + * The singleton instance of the package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + SDOPackage eINSTANCE = org.apache.tuscany.sdo.impl.SDOPackageImpl.init(); + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.DataGraphImpl <em>Data Graph</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 <em>Change Summary</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 '<em><b>Object Changes</b></em>' map. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CHANGE_SUMMARY__OBJECT_CHANGES = ChangePackage.CHANGE_DESCRIPTION__OBJECT_CHANGES; + + /** + * The feature id for the '<em><b>Objects To Detach</b></em>' reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CHANGE_SUMMARY__OBJECTS_TO_DETACH = ChangePackage.CHANGE_DESCRIPTION__OBJECTS_TO_DETACH; + + /** + * The feature id for the '<em><b>Objects To Attach</b></em>' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CHANGE_SUMMARY__OBJECTS_TO_ATTACH = ChangePackage.CHANGE_DESCRIPTION__OBJECTS_TO_ATTACH; + + /** + * The feature id for the '<em><b>Resource Changes</b></em>' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CHANGE_SUMMARY__RESOURCE_CHANGES = ChangePackage.CHANGE_DESCRIPTION__RESOURCE_CHANGES; + + /** + * The feature id for the '<em><b>EData Graph</b></em>' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CHANGE_SUMMARY__EDATA_GRAPH = ChangePackage.CHANGE_DESCRIPTION_FEATURE_COUNT + 0; + + /** + * The number of structural features of the '<em>Change Summary</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 <em>Change Summary Setting</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 '<em><b>Feature Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING__FEATURE_NAME = ChangePackage.FEATURE_CHANGE__FEATURE_NAME; + + /** + * The feature id for the '<em><b>Data Value</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING__DATA_VALUE = ChangePackage.FEATURE_CHANGE__DATA_VALUE; + + /** + * The feature id for the '<em><b>Set</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING__SET = ChangePackage.FEATURE_CHANGE__SET; + + /** + * The feature id for the '<em><b>Value</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING__VALUE = ChangePackage.FEATURE_CHANGE__VALUE; + + /** + * The feature id for the '<em><b>Feature</b></em>' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING__FEATURE = ChangePackage.FEATURE_CHANGE__FEATURE; + + /** + * The feature id for the '<em><b>Reference Value</b></em>' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING__REFERENCE_VALUE = ChangePackage.FEATURE_CHANGE__REFERENCE_VALUE; + + /** + * The feature id for the '<em><b>List Changes</b></em>' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING__LIST_CHANGES = ChangePackage.FEATURE_CHANGE__LIST_CHANGES; + + /** + * The number of structural features of the '<em>Change Summary Setting</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING_FEATURE_COUNT = ChangePackage.FEATURE_CHANGE_FEATURE_COUNT + 0; + + /** + * The feature id for the '<em><b>Resource Set</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int DATA_GRAPH__RESOURCE_SET = EcorePackage.EOBJECT_FEATURE_COUNT + 0; + + /** + * The feature id for the '<em><b>Root Resource</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int DATA_GRAPH__ROOT_RESOURCE = EcorePackage.EOBJECT_FEATURE_COUNT + 1; + + /** + * The feature id for the '<em><b>EChange Summary</b></em>' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int DATA_GRAPH__ECHANGE_SUMMARY = EcorePackage.EOBJECT_FEATURE_COUNT + 2; + + /** + * The feature id for the '<em><b>ERoot Object</b></em>' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int DATA_GRAPH__EROOT_OBJECT = EcorePackage.EOBJECT_FEATURE_COUNT + 3; + + /** + * The number of structural features of the '<em>Data Graph</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 <em>Data Object</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 <em>Property</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 <em>Sequence</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 <em>Type</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see commonj.sdo.Type + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getType() + * @generated + */ + int TYPE = 6; + + /** + * The number of structural features of the '<em>Data Object</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int DATA_OBJECT_FEATURE_COUNT = 0; + + /** + * The number of structural features of the '<em>Property</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int PROPERTY_FEATURE_COUNT = 0; + + /** + * The number of structural features of the '<em>Sequence</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int SEQUENCE_FEATURE_COUNT = 0; + + /** + * The number of structural features of the '<em>Type</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int TYPE_FEATURE_COUNT = 0; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.AnyTypeDataObjectImpl <em>Any Type Data Object</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 '<em><b>Mixed</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ANY_TYPE_DATA_OBJECT__MIXED = DATA_OBJECT_FEATURE_COUNT + 0; + + /** + * The feature id for the '<em><b>Any</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ANY_TYPE_DATA_OBJECT__ANY = DATA_OBJECT_FEATURE_COUNT + 1; + + /** + * The feature id for the '<em><b>Any Attribute</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE = DATA_OBJECT_FEATURE_COUNT + 2; + + /** + * The number of structural features of the '<em>Any Type Data Object</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 <em>Simple Any Type Data Object</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 '<em><b>Mixed</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int SIMPLE_ANY_TYPE_DATA_OBJECT__MIXED = ANY_TYPE_DATA_OBJECT__MIXED; + + /** + * The feature id for the '<em><b>Any</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int SIMPLE_ANY_TYPE_DATA_OBJECT__ANY = ANY_TYPE_DATA_OBJECT__ANY; + + /** + * The feature id for the '<em><b>Any Attribute</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int SIMPLE_ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE = ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE; + + /** + * The feature id for the '<em><b>Raw Value</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int SIMPLE_ANY_TYPE_DATA_OBJECT__RAW_VALUE = ANY_TYPE_DATA_OBJECT_FEATURE_COUNT + 0; + + /** + * The feature id for the '<em><b>Value</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int SIMPLE_ANY_TYPE_DATA_OBJECT__VALUE = ANY_TYPE_DATA_OBJECT_FEATURE_COUNT + 1; + + /** + * The feature id for the '<em><b>Instance Type</b></em>' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE = ANY_TYPE_DATA_OBJECT_FEATURE_COUNT + 2; + + /** + * The number of structural features of the '<em>Simple Any Type Data Object</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 <em>Class</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.impl.ClassImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getClass_() + * @generated + */ + int CLASS = 9; + + /** + * The feature id for the '<em><b>EAnnotations</b></em>' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS__EANNOTATIONS = EcorePackage.ECLASS__EANNOTATIONS; + + /** + * The feature id for the '<em><b>Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS__NAME = EcorePackage.ECLASS__NAME; + + /** + * The feature id for the '<em><b>Instance Class Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS__INSTANCE_CLASS_NAME = EcorePackage.ECLASS__INSTANCE_CLASS_NAME; + + /** + * The feature id for the '<em><b>Instance Class</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS__INSTANCE_CLASS = EcorePackage.ECLASS__INSTANCE_CLASS; + + /** + * The feature id for the '<em><b>Default Value</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS__DEFAULT_VALUE = EcorePackage.ECLASS__DEFAULT_VALUE; + + /** + * The feature id for the '<em><b>EPackage</b></em>' container reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS__EPACKAGE = EcorePackage.ECLASS__EPACKAGE; + + /** + * The feature id for the '<em><b>Abstract</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS__ABSTRACT = EcorePackage.ECLASS__ABSTRACT; + + /** + * The feature id for the '<em><b>Interface</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS__INTERFACE = EcorePackage.ECLASS__INTERFACE; + + /** + * The feature id for the '<em><b>ESuper Types</b></em>' reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS__ESUPER_TYPES = EcorePackage.ECLASS__ESUPER_TYPES; + + /** + * The feature id for the '<em><b>EOperations</b></em>' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS__EOPERATIONS = EcorePackage.ECLASS__EOPERATIONS; + + /** + * The feature id for the '<em><b>EAll Attributes</b></em>' reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS__EALL_ATTRIBUTES = EcorePackage.ECLASS__EALL_ATTRIBUTES; + + /** + * The feature id for the '<em><b>EAll References</b></em>' reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS__EALL_REFERENCES = EcorePackage.ECLASS__EALL_REFERENCES; + + /** + * The feature id for the '<em><b>EReferences</b></em>' reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS__EREFERENCES = EcorePackage.ECLASS__EREFERENCES; + + /** + * The feature id for the '<em><b>EAttributes</b></em>' reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS__EATTRIBUTES = EcorePackage.ECLASS__EATTRIBUTES; + + /** + * The feature id for the '<em><b>EAll Containments</b></em>' reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS__EALL_CONTAINMENTS = EcorePackage.ECLASS__EALL_CONTAINMENTS; + + /** + * The feature id for the '<em><b>EAll Operations</b></em>' reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS__EALL_OPERATIONS = EcorePackage.ECLASS__EALL_OPERATIONS; + + /** + * The feature id for the '<em><b>EAll Structural Features</b></em>' reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS__EALL_STRUCTURAL_FEATURES = EcorePackage.ECLASS__EALL_STRUCTURAL_FEATURES; + + /** + * The feature id for the '<em><b>EAll Super Types</b></em>' reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS__EALL_SUPER_TYPES = EcorePackage.ECLASS__EALL_SUPER_TYPES; + + /** + * The feature id for the '<em><b>EID Attribute</b></em>' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS__EID_ATTRIBUTE = EcorePackage.ECLASS__EID_ATTRIBUTE; + + /** + * The feature id for the '<em><b>EStructural Features</b></em>' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS__ESTRUCTURAL_FEATURES = EcorePackage.ECLASS__ESTRUCTURAL_FEATURES; + + /** + * The number of structural features of the '<em>Class</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int CLASS_FEATURE_COUNT = EcorePackage.ECLASS_FEATURE_COUNT + 0; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.DataTypeImpl <em>Data Type</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 '<em><b>EAnnotations</b></em>' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int DATA_TYPE__EANNOTATIONS = EcorePackage.EDATA_TYPE__EANNOTATIONS; + + /** + * The feature id for the '<em><b>Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int DATA_TYPE__NAME = EcorePackage.EDATA_TYPE__NAME; + + /** + * The feature id for the '<em><b>Instance Class Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int DATA_TYPE__INSTANCE_CLASS_NAME = EcorePackage.EDATA_TYPE__INSTANCE_CLASS_NAME; + + /** + * The feature id for the '<em><b>Instance Class</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int DATA_TYPE__INSTANCE_CLASS = EcorePackage.EDATA_TYPE__INSTANCE_CLASS; + + /** + * The feature id for the '<em><b>Default Value</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int DATA_TYPE__DEFAULT_VALUE = EcorePackage.EDATA_TYPE__DEFAULT_VALUE; + + /** + * The feature id for the '<em><b>EPackage</b></em>' container reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int DATA_TYPE__EPACKAGE = EcorePackage.EDATA_TYPE__EPACKAGE; + + /** + * The feature id for the '<em><b>Serializable</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int DATA_TYPE__SERIALIZABLE = EcorePackage.EDATA_TYPE__SERIALIZABLE; + + /** + * The number of structural features of the '<em>Data Type</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 <em>Attribute</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.impl.AttributeImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getAttribute() + * @generated + */ + int ATTRIBUTE = 11; + + /** + * The feature id for the '<em><b>EAnnotations</b></em>' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE__EANNOTATIONS = EcorePackage.EATTRIBUTE__EANNOTATIONS; + + /** + * The feature id for the '<em><b>Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE__NAME = EcorePackage.EATTRIBUTE__NAME; + + /** + * The feature id for the '<em><b>Ordered</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE__ORDERED = EcorePackage.EATTRIBUTE__ORDERED; + + /** + * The feature id for the '<em><b>Unique</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE__UNIQUE = EcorePackage.EATTRIBUTE__UNIQUE; + + /** + * The feature id for the '<em><b>Lower Bound</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE__LOWER_BOUND = EcorePackage.EATTRIBUTE__LOWER_BOUND; + + /** + * The feature id for the '<em><b>Upper Bound</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE__UPPER_BOUND = EcorePackage.EATTRIBUTE__UPPER_BOUND; + + /** + * The feature id for the '<em><b>Many</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE__MANY = EcorePackage.EATTRIBUTE__MANY; + + /** + * The feature id for the '<em><b>Required</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE__REQUIRED = EcorePackage.EATTRIBUTE__REQUIRED; + + /** + * The feature id for the '<em><b>EType</b></em>' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE__ETYPE = EcorePackage.EATTRIBUTE__ETYPE; + + /** + * The feature id for the '<em><b>Changeable</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE__CHANGEABLE = EcorePackage.EATTRIBUTE__CHANGEABLE; + + /** + * The feature id for the '<em><b>Volatile</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE__VOLATILE = EcorePackage.EATTRIBUTE__VOLATILE; + + /** + * The feature id for the '<em><b>Transient</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE__TRANSIENT = EcorePackage.EATTRIBUTE__TRANSIENT; + + /** + * The feature id for the '<em><b>Default Value Literal</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE__DEFAULT_VALUE_LITERAL = EcorePackage.EATTRIBUTE__DEFAULT_VALUE_LITERAL; + + /** + * The feature id for the '<em><b>Default Value</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE__DEFAULT_VALUE = EcorePackage.EATTRIBUTE__DEFAULT_VALUE; + + /** + * The feature id for the '<em><b>Unsettable</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE__UNSETTABLE = EcorePackage.EATTRIBUTE__UNSETTABLE; + + /** + * The feature id for the '<em><b>Derived</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE__DERIVED = EcorePackage.EATTRIBUTE__DERIVED; + + /** + * The feature id for the '<em><b>EContaining Class</b></em>' container reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE__ECONTAINING_CLASS = EcorePackage.EATTRIBUTE__ECONTAINING_CLASS; + + /** + * The feature id for the '<em><b>ID</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE__ID = EcorePackage.EATTRIBUTE__ID; + + /** + * The feature id for the '<em><b>EAttribute Type</b></em>' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE__EATTRIBUTE_TYPE = EcorePackage.EATTRIBUTE__EATTRIBUTE_TYPE; + + /** + * The number of structural features of the '<em>Attribute</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ATTRIBUTE_FEATURE_COUNT = EcorePackage.EATTRIBUTE_FEATURE_COUNT + 0; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.ReferenceImpl <em>Reference</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.impl.ReferenceImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getReference() + * @generated + */ + int REFERENCE = 12; + + /** + * The feature id for the '<em><b>EAnnotations</b></em>' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REFERENCE__EANNOTATIONS = EcorePackage.EREFERENCE__EANNOTATIONS; + + /** + * The feature id for the '<em><b>Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REFERENCE__NAME = EcorePackage.EREFERENCE__NAME; + + /** + * The feature id for the '<em><b>Ordered</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REFERENCE__ORDERED = EcorePackage.EREFERENCE__ORDERED; + + /** + * The feature id for the '<em><b>Unique</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REFERENCE__UNIQUE = EcorePackage.EREFERENCE__UNIQUE; + + /** + * The feature id for the '<em><b>Lower Bound</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REFERENCE__LOWER_BOUND = EcorePackage.EREFERENCE__LOWER_BOUND; + + /** + * The feature id for the '<em><b>Upper Bound</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REFERENCE__UPPER_BOUND = EcorePackage.EREFERENCE__UPPER_BOUND; + + /** + * The feature id for the '<em><b>Many</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REFERENCE__MANY = EcorePackage.EREFERENCE__MANY; + + /** + * The feature id for the '<em><b>Required</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REFERENCE__REQUIRED = EcorePackage.EREFERENCE__REQUIRED; + + /** + * The feature id for the '<em><b>EType</b></em>' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REFERENCE__ETYPE = EcorePackage.EREFERENCE__ETYPE; + + /** + * The feature id for the '<em><b>Changeable</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REFERENCE__CHANGEABLE = EcorePackage.EREFERENCE__CHANGEABLE; + + /** + * The feature id for the '<em><b>Volatile</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REFERENCE__VOLATILE = EcorePackage.EREFERENCE__VOLATILE; + + /** + * The feature id for the '<em><b>Transient</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REFERENCE__TRANSIENT = EcorePackage.EREFERENCE__TRANSIENT; + + /** + * The feature id for the '<em><b>Default Value Literal</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REFERENCE__DEFAULT_VALUE_LITERAL = EcorePackage.EREFERENCE__DEFAULT_VALUE_LITERAL; + + /** + * The feature id for the '<em><b>Default Value</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REFERENCE__DEFAULT_VALUE = EcorePackage.EREFERENCE__DEFAULT_VALUE; + + /** + * The feature id for the '<em><b>Unsettable</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REFERENCE__UNSETTABLE = EcorePackage.EREFERENCE__UNSETTABLE; + + /** + * The feature id for the '<em><b>Derived</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REFERENCE__DERIVED = EcorePackage.EREFERENCE__DERIVED; + + /** + * The feature id for the '<em><b>EContaining Class</b></em>' container reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REFERENCE__ECONTAINING_CLASS = EcorePackage.EREFERENCE__ECONTAINING_CLASS; + + /** + * The feature id for the '<em><b>Containment</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REFERENCE__CONTAINMENT = EcorePackage.EREFERENCE__CONTAINMENT; + + /** + * The feature id for the '<em><b>Container</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REFERENCE__CONTAINER = EcorePackage.EREFERENCE__CONTAINER; + + /** + * The feature id for the '<em><b>Resolve Proxies</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REFERENCE__RESOLVE_PROXIES = EcorePackage.EREFERENCE__RESOLVE_PROXIES; + + /** + * The feature id for the '<em><b>EOpposite</b></em>' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REFERENCE__EOPPOSITE = EcorePackage.EREFERENCE__EOPPOSITE; + + /** + * The feature id for the '<em><b>EReference Type</b></em>' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REFERENCE__EREFERENCE_TYPE = EcorePackage.EREFERENCE__EREFERENCE_TYPE; + + /** + * The number of structural features of the '<em>Reference</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int REFERENCE_FEATURE_COUNT = EcorePackage.EREFERENCE_FEATURE_COUNT + 0; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.EnumImpl <em>Enum</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.impl.EnumImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getEnum() + * @generated + */ + int ENUM = 13; + + /** + * The feature id for the '<em><b>EAnnotations</b></em>' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ENUM__EANNOTATIONS = EcorePackage.EENUM__EANNOTATIONS; + + /** + * The feature id for the '<em><b>Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ENUM__NAME = EcorePackage.EENUM__NAME; + + /** + * The feature id for the '<em><b>Instance Class Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ENUM__INSTANCE_CLASS_NAME = EcorePackage.EENUM__INSTANCE_CLASS_NAME; + + /** + * The feature id for the '<em><b>Instance Class</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ENUM__INSTANCE_CLASS = EcorePackage.EENUM__INSTANCE_CLASS; + + /** + * The feature id for the '<em><b>Default Value</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ENUM__DEFAULT_VALUE = EcorePackage.EENUM__DEFAULT_VALUE; + + /** + * The feature id for the '<em><b>EPackage</b></em>' container reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ENUM__EPACKAGE = EcorePackage.EENUM__EPACKAGE; + + /** + * The feature id for the '<em><b>Serializable</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ENUM__SERIALIZABLE = EcorePackage.EENUM__SERIALIZABLE; + + /** + * The feature id for the '<em><b>ELiterals</b></em>' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ENUM__ELITERALS = EcorePackage.EENUM__ELITERALS; + + /** + * The number of structural features of the '<em>Enum</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int ENUM_FEATURE_COUNT = EcorePackage.EENUM_FEATURE_COUNT + 0; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.DynamicDataObjectImpl <em>Dynamic Data Object</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 '<em>Dynamic Data Object</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 <em>Store Data Object</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 '<em>Store Data Object</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 <em>Dynamic Store Data Object</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 '<em>Dynamic Store Data Object</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + int DYNAMIC_STORE_DATA_OBJECT_FEATURE_COUNT = STORE_DATA_OBJECT_FEATURE_COUNT + 0; + + /** + * The meta object id for the '<em>EJava List</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.util.List + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getEJavaList() + * @generated + */ + int EJAVA_LIST = 17; + + /** + * The meta object id for the '<em>EObject Stream Exception</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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 <em>Change Summary</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Change Summary</em>'. + * @see commonj.sdo.ChangeSummary + * @model instanceClass="commonj.sdo.ChangeSummary" + * @generated + */ + EClass getChangeSummary(); + + /** + * Returns the meta object for the reference '{@link commonj.sdo.ChangeSummary#getEDataGraph <em>EData Graph</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the reference '<em>EData Graph</em>'. + * @see commonj.sdo.ChangeSummary#getEDataGraph() + * @see #getChangeSummary() + * @generated + */ + EReference getChangeSummary_EDataGraph(); + + /** + * Returns the meta object for class '{@link commonj.sdo.ChangeSummary.Setting <em>Change Summary Setting</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Change Summary Setting</em>'. + * @see commonj.sdo.ChangeSummary.Setting + * @model instanceClass="commonj.sdo.ChangeSummary$Setting" + * @generated + */ + EClass getChangeSummarySetting(); + + /** + * Returns the meta object for class '{@link commonj.sdo.DataGraph <em>Data Graph</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Data Graph</em>'. + * @see commonj.sdo.DataGraph + * @model instanceClass="commonj.sdo.DataGraph" + * @generated + */ + EClass getDataGraph(); + + /** + * Returns the meta object for the attribute '{@link commonj.sdo.DataGraph#getResourceSet <em>Resource Set</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Resource Set</em>'. + * @see commonj.sdo.DataGraph#getResourceSet() + * @see #getDataGraph() + * @generated + */ + EAttribute getDataGraph_ResourceSet(); + + /** + * Returns the meta object for the attribute '{@link commonj.sdo.DataGraph#getRootResource <em>Root Resource</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Root Resource</em>'. + * @see commonj.sdo.DataGraph#getRootResource() + * @see #getDataGraph() + * @generated + */ + EAttribute getDataGraph_RootResource(); + + /** + * Returns the meta object for the reference '{@link commonj.sdo.DataGraph#getEChangeSummary <em>EChange Summary</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the reference '<em>EChange Summary</em>'. + * @see commonj.sdo.DataGraph#getEChangeSummary() + * @see #getDataGraph() + * @generated + */ + EReference getDataGraph_EChangeSummary(); + + /** + * Returns the meta object for the reference '{@link commonj.sdo.DataGraph#getERootObject <em>ERoot Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the reference '<em>ERoot Object</em>'. + * @see commonj.sdo.DataGraph#getERootObject() + * @see #getDataGraph() + * @generated + */ + EReference getDataGraph_ERootObject(); + + /** + * Returns the meta object for class '{@link commonj.sdo.DataObject <em>Data Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Data Object</em>'. + * @see commonj.sdo.DataObject + * @model instanceClass="commonj.sdo.DataObject" + * @generated + */ + EClass getDataObject(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Property <em>Property</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Property</em>'. + * @see commonj.sdo.Property + * @model instanceClass="commonj.sdo.Property" + * @generated + */ + EClass getProperty(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Sequence <em>Sequence</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Sequence</em>'. + * @see commonj.sdo.Sequence + * @model instanceClass="commonj.sdo.Sequence" + * @generated + */ + EClass getSequence(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Type <em>Type</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Type</em>'. + * @see commonj.sdo.Type + * @model instanceClass="commonj.sdo.Type" + * @generated + */ + EClass getType(); + + /** + * Returns the meta object for class '{@link org.apache.tuscany.sdo.AnyTypeDataObject <em>Any Type Data Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Any Type Data Object</em>'. + * @see org.apache.tuscany.sdo.AnyTypeDataObject + * @generated + */ + EClass getAnyTypeDataObject(); + + /** + * Returns the meta object for class '{@link org.apache.tuscany.sdo.SimpleAnyTypeDataObject <em>Simple Any Type Data Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Simple Any Type Data Object</em>'. + * @see org.apache.tuscany.sdo.SimpleAnyTypeDataObject + * @generated + */ + EClass getSimpleAnyTypeDataObject(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Type <em>Class</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Class</em>'. + * @see commonj.sdo.Type + * @model instanceClass="commonj.sdo.Type" + * @generated + */ + EClass getClass_(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Type <em>Data Type</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Data Type</em>'. + * @see commonj.sdo.Type + * @model instanceClass="commonj.sdo.Type" + * @generated + */ + EClass getDataType(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Property <em>Attribute</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Attribute</em>'. + * @see commonj.sdo.Property + * @model instanceClass="commonj.sdo.Property" + * @generated + */ + EClass getAttribute(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Property <em>Reference</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Reference</em>'. + * @see commonj.sdo.Property + * @model instanceClass="commonj.sdo.Property" + * @generated + */ + EClass getReference(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Type <em>Enum</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Enum</em>'. + * @see commonj.sdo.Type + * @model instanceClass="commonj.sdo.Type" + * @generated + */ + EClass getEnum(); + + /** + * Returns the meta object for class '{@link commonj.sdo.DataObject <em>Dynamic Data Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Dynamic Data Object</em>'. + * @see commonj.sdo.DataObject + * @model instanceClass="commonj.sdo.DataObject" + * @generated + */ + EClass getDynamicDataObject(); + + /** + * Returns the meta object for class '{@link commonj.sdo.DataObject <em>Store Data Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Store Data Object</em>'. + * @see commonj.sdo.DataObject + * @model instanceClass="commonj.sdo.DataObject" + * @generated + */ + EClass getStoreDataObject(); + + /** + * Returns the meta object for class '{@link commonj.sdo.DataObject <em>Dynamic Store Data Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Dynamic Store Data Object</em>'. + * @see commonj.sdo.DataObject + * @model instanceClass="commonj.sdo.DataObject" + * @generated + */ + EClass getDynamicStoreDataObject(); + + /** + * Returns the meta object for data type '{@link java.util.List <em>EJava List</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>EJava List</em>'. + * @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 <em>EObject Stream Exception</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>EObject Stream Exception</em>'. + * @see java.io.ObjectStreamException + * @model instanceClass="java.io.ObjectStreamException" serializable="false" + * @generated + */ + EDataType getEObjectStreamException(); + + /** + * Returns the factory that creates the instances of the model. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the factory that creates the instances of the model. + * @generated + */ + SDOFactory getSDOFactory(); + +} //SDOPackage diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOTypeVisitor.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOTypeVisitor.java new file mode 100644 index 0000000000..5d3640100c --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/SDOTypeVisitor.java @@ -0,0 +1,49 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo; + +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/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/SimpleAnyTypeDataObject.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/SimpleAnyTypeDataObject.java new file mode 100644 index 0000000000..93ff2ebf14 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/SimpleAnyTypeDataObject.java @@ -0,0 +1,35 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo; + +import org.eclipse.emf.ecore.xml.type.SimpleAnyType; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Simple Any Type Data Object</b></em>'. + * <!-- end-user-doc --> + * + * + * @see org.apache.tuscany.sdo.SDOPackage#getSimpleAnyTypeDataObject() + * @model extendedMetaData="kind='simple'" + * @generated + */ +public interface SimpleAnyTypeDataObject extends AnyTypeDataObject, SimpleAnyType { +} // SimpleAnyTypeDataObject diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGenerator.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGenerator.java new file mode 100644 index 0000000000..3fe2cd952e --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGenerator.java @@ -0,0 +1,98 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.codegen; + +import java.util.List; + +import commonj.sdo.Property; +import commonj.sdo.Type; +import org.objectweb.asm.ClassWriter; +import 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(Opcodes.V1_4, + Opcodes.ACC_PUBLIC + Opcodes.ACC_ABSTRACT + Opcodes.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(Opcodes.ACC_PUBLIC + Opcodes.ACC_ABSTRACT, "get" + propertyName, "()Ljava/util/List;", null, null).visitEnd(); + } else { + if (boolean.class.equals(javaType)) { + cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_ABSTRACT, "is" + propertyName, "()Z", null, null).visitEnd(); + } else { + cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.ACC_ABSTRACT, "get" + propertyName, "()" + desc, null, null).visitEnd(); + } + if (!property.isReadOnly()) { + cw.visitMethod(Opcodes.ACC_PUBLIC + Opcodes.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/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/GenerationException.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/GenerationException.java new file mode 100644 index 0000000000..3d645be1da --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/GenerationException.java @@ -0,0 +1,42 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.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/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGenerator.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGenerator.java new file mode 100644 index 0000000000..dc88a0d60d --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGenerator.java @@ -0,0 +1,179 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.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 static String canonicalize(String className) { + if (className == null) { + return ""; + } + if (className.charAt(0) != '[') { // if not array + return className; + } + // process array + boolean invalidClassName = false; + int nestLevel = 1; + StringBuffer sb = new StringBuffer(); + try { + while (className.charAt(nestLevel) == '[') { + nestLevel++; + } + char typeChar = className.charAt(nestLevel); + int end = nestLevel; + switch (typeChar) { + case 'L': + end = className.length() - 1; + if (className.charAt(end) != ';') { + invalidClassName = true; + } else { + sb.append(className.substring(nestLevel+1, end)); + } + break; + case 'Z': + sb.append("boolean"); + break; + case 'B': + sb.append("byte"); + break; + case 'C': + sb.append("char"); + break; + case 'D': + sb.append("double"); + break; + case 'F': + sb.append("float"); + break; + case 'I': + sb.append("int"); + break; + case 'J': + sb.append("long"); + break; + case 'S': + sb.append("short"); + break; + default: + invalidClassName = true; + break; + } + if (end != (className.length() - 1)) { + invalidClassName = true; // we have not used all the characters + } else { + for (int i=0; i<nestLevel; i++) { + sb.append("[]"); + } + } + } catch(Exception e) { + invalidClassName = true; + } + if (invalidClassName) { + System.err.println("unable to canonicalize class name: "+className); + return className; + } + return sb.toString(); + } + + 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 = canonicalize(property.getType().getInstanceClass().getName()); + + 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(); + } +} diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/NoJavaImplementationException.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/NoJavaImplementationException.java new file mode 100644 index 0000000000..a6253e8131 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/codegen/NoJavaImplementationException.java @@ -0,0 +1,61 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.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/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/CopyHelperImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/CopyHelperImpl.java new file mode 100644 index 0000000000..16bafe68ca --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/CopyHelperImpl.java @@ -0,0 +1,54 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.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/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/CrossScopeCopyHelperImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/CrossScopeCopyHelperImpl.java new file mode 100644 index 0000000000..b7a5534800 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/CrossScopeCopyHelperImpl.java @@ -0,0 +1,255 @@ +/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.helper;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.util.FeatureMap;
+import org.eclipse.emf.ecore.util.FeatureMapUtil;
+import org.eclipse.emf.ecore.util.InternalEList;
+import org.eclipse.emf.ecore.util.EcoreUtil.Copier;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.CopyHelper;
+import commonj.sdo.helper.TypeHelper;
+
+/**
+ * A CopyHelper implementation that creates the copy objects in a specific metadata scope.
+ * The target scope must contain a compatible version of the Types needed to create the copy objects.
+ */
+public class CrossScopeCopyHelperImpl implements CopyHelper
+{
+ protected TypeHelper scope;
+
+ public CrossScopeCopyHelperImpl(TypeHelper targetScope)
+ {
+ scope = targetScope;
+ }
+
+ public DataObject copyShallow(DataObject dataObject)
+ {
+ Copier copier = new CrossScopeCopier()
+ {
+ protected void copyContainment(EReference eReference, EObject eObject, EObject copyEObject)
+ {
+ }
+ protected void copyAttribute(EAttribute eAttribute, EObject eObject, EObject copyEObject)
+ {
+ if (eObject.eIsSet(eAttribute) && !FeatureMapUtil.isFeatureMap(eAttribute))
+ {
+ super.copyAttribute(eAttribute,eObject,copyEObject);
+ }
+ }
+ };
+ EObject result = copier.copy((EObject)dataObject);
+ copier.copyReferences();
+ return (DataObject)result;
+ }
+
+ public DataObject copy(DataObject dataObject)
+ {
+ Copier copier = new CrossScopeCopier();
+ DataObject result = (DataObject)copier.copy((EObject)dataObject);
+ copier.copyReferences();
+ return (DataObject)result;
+ }
+
+ protected class CrossScopeCopier extends EcoreUtil.Copier
+ {
+ protected boolean useOriginalReferences = false;
+
+ protected EClass getTarget(EClass eClass)
+ {
+ EClass target = (EClass)get(eClass);
+ if (target == null)
+ {
+ Type type = (Type)eClass;
+ target = (EClass)scope.getType(type.getURI(), type.getName());
+ }
+ return target;
+ }
+
+ protected EStructuralFeature getTarget(EStructuralFeature eStructuralFeature)
+ {
+ EClass eClass = getTarget(eStructuralFeature.getEContainingClass());
+ EStructuralFeature targetEf = eClass.getEStructuralFeature(eStructuralFeature.getName());
+ return targetEf;
+ }
+
+ /**
+ * This Method WILL BE REMOVED when EMF 3.0 is available
+ */
+ public void copyReferences()
+ {
+ for (Iterator i = entrySet().iterator(); i.hasNext();)
+ {
+ Map.Entry entry = (Map.Entry)i.next();
+ EObject eObject = (EObject)entry.getKey();
+ EObject copyEObject = (EObject)entry.getValue();
+ EClass eClass = eObject.eClass();
+ for (int j = 0, size = eClass.getFeatureCount(); j < size; ++j)
+ {
+ EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature(j);
+ if (eStructuralFeature.isChangeable() && !eStructuralFeature.isDerived())
+ {
+ if (eStructuralFeature instanceof EReference)
+ {
+ EReference eReference = (EReference)eStructuralFeature;
+ if (!eReference.isContainment() && !eReference.isContainer())
+ {
+ copyReference(eReference, eObject, copyEObject);
+ }
+ }
+ else if (FeatureMapUtil.isFeatureMap(eStructuralFeature))
+ {
+ FeatureMap featureMap = (FeatureMap)eObject.eGet(eStructuralFeature);
+ FeatureMap copyFeatureMap = (FeatureMap)copyEObject.eGet(getTarget(eStructuralFeature));
+ int copyFeatureMapSize = copyFeatureMap.size();
+ for (int k = 0, featureMapSize = featureMap.size(); k < featureMapSize; ++k)
+ {
+ EStructuralFeature feature = featureMap.getEStructuralFeature(k);
+ if (feature instanceof EReference)
+ {
+ Object referencedEObject = featureMap.getValue(k);
+ Object copyReferencedEObject = get(referencedEObject);
+ if (copyReferencedEObject == null && referencedEObject != null)
+ {
+ EReference reference = (EReference)feature;
+ if (!useOriginalReferences || reference.isContainment() || reference.getEOpposite() != null)
+ {
+ continue;
+ }
+ copyReferencedEObject = referencedEObject;
+ }
+ // If we can't add it, it must aleady be in the list so find it and move it to the end.
+ //
+ if (!copyFeatureMap.add(feature, copyReferencedEObject))
+ {
+ for (int l = 0; l < copyFeatureMapSize; ++l)
+ {
+ if (copyFeatureMap.getEStructuralFeature(l) == feature && copyFeatureMap.getValue(l) == copyReferencedEObject)
+ {
+ copyFeatureMap.move(copyFeatureMap.size() - 1, l);
+ --copyFeatureMapSize;
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ copyFeatureMap.add(featureMap.get(k));
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * This Method WILL BE REMOVED when EMF 3.0 is available
+ */
+ protected void copyReference(EReference eReference, EObject eObject, EObject copyEObject)
+ {
+ if (eObject.eIsSet(eReference))
+ {
+ if (eReference.isMany())
+ {
+ InternalEList source = (InternalEList)eObject.eGet(eReference);
+ InternalEList target = (InternalEList)copyEObject.eGet(getTarget(eReference));
+ if (source.isEmpty())
+ {
+ target.clear();
+ }
+ else
+ {
+ boolean isBidirectional = eReference.getEOpposite() != null;
+ int index = 0;
+ for (Iterator k = resolveProxies ? source.iterator() : source.basicIterator(); k.hasNext();)
+ {
+ Object referencedEObject = k.next();
+ Object copyReferencedEObject = get(referencedEObject);
+ if (copyReferencedEObject == null)
+ {
+ if (useOriginalReferences && !isBidirectional)
+ {
+ target.addUnique(index, referencedEObject);
+ ++index;
+ }
+ }
+ else
+ {
+ if (isBidirectional)
+ {
+ int position = target.indexOf(copyReferencedEObject);
+ if (position == -1)
+ {
+ target.addUnique(index, copyReferencedEObject);
+ }
+ else if (index != position)
+ {
+ target.move(index, copyReferencedEObject);
+ }
+ }
+ else
+ {
+ target.addUnique(index, copyReferencedEObject);
+ }
+ ++index;
+ }
+ }
+ }
+ }
+ else
+ {
+ Object referencedEObject = eObject.eGet(eReference, resolveProxies);
+ if (referencedEObject == null)
+ {
+ copyEObject.eSet(getTarget(eReference), null);
+ }
+ else
+ {
+ Object copyReferencedEObject = get(referencedEObject);
+ if (copyReferencedEObject == null)
+ {
+ if (useOriginalReferences && eReference.getEOpposite() == null)
+ {
+ copyEObject.eSet(getTarget(eReference), referencedEObject);
+ }
+ }
+ else
+ {
+ copyEObject.eSet(getTarget(eReference), copyReferencedEObject);
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DataFactoryImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DataFactoryImpl.java new file mode 100644 index 0000000000..128f63f4d7 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DataFactoryImpl.java @@ -0,0 +1,65 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.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) + { + if (type instanceof EClass) + { + EClass eClass = (EClass)type; + return (DataObject)EcoreUtil.create(eClass); + } + throw new IllegalArgumentException(); + } +} diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DataHelperImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DataHelperImpl.java new file mode 100644 index 0000000000..2406af1a8a --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DataHelperImpl.java @@ -0,0 +1,469 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.helper; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.TimeZone; +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) + { + Date result = null; + dateString = dateString.trim(); + boolean negative = false; + + if (dateString == null) + { + return null; + } + + // Determine if it is a negative Date, DateTime, or Duration + if (dateString.length() > 2 && dateString.charAt(0) == '-' && dateString.charAt(1) != '-') + { + negative = true; + dateString = dateString.substring(1); + } + + // SDO Date Format ends with a Z + + if (dateString.endsWith("Z")) + { + SimpleDateFormat[] SDO_DATE_FORMATS = + { + new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSS'Z'"), + new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'") + }; + + for (int i = 0; i < SDO_DATE_FORMATS.length; i++) + { + SDO_DATE_FORMATS[i].setTimeZone(TimeZone.getTimeZone("GMT")); + } + + result = checkFormats(dateString, SDO_DATE_FORMATS); + + // If no match, continue to try further possibilities + + if (result != null) + { + if (negative) + return handleBCE(result); + else + return result; + } + + } + + // Duration format begins with a P + + if (dateString.startsWith("P")) + { + // Remove any spaces in the dateString + + String durationString = dateString.replaceAll(" ", ""); + + // For Duration format, there are so many possibilities due to so many optional + // inclusions, that we will build the format string rather than create + // a potential SimpleDateFormat for each possibility. + + SimpleDateFormat[] DURATION_FORMATS = obtainDurationFormats(durationString); + result = checkFormats(durationString, DURATION_FORMATS); + if (result != null) + { + if (negative) + return handleNegative(result); + else + return result; + } + } + + // Check the remaining possibilities. Note that time zone is optional for each. + + SimpleDateFormat [] DATE_PATTERNS = + { + new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSS z"), + new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss z"), + new SimpleDateFormat("yyyy-MM-dd'T'HH:mm z"), + new SimpleDateFormat("'--'MM'-'dd z"), + new SimpleDateFormat("'--'MM z"), + new SimpleDateFormat("'---'dd zzzz"), + new SimpleDateFormat("HH:mm:ss'.'SSS z"), + new SimpleDateFormat("HH:mm:ss z"), + new SimpleDateFormat("yyyy-MM-dd z"), + new SimpleDateFormat("yyyy-MM z"), + new SimpleDateFormat("yyyy 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("'--'MM'-'dd"), + new SimpleDateFormat("'--'MM"), + new SimpleDateFormat("'---'dd"), + new SimpleDateFormat("HH:mm:ss'.'SSS"), + new SimpleDateFormat("HH:mm:ss"), + new SimpleDateFormat("yyyy-MM-dd"), + new SimpleDateFormat("yyyy-MM"), + new SimpleDateFormat("yyyy") + }; + + result = checkFormats(dateString, DATE_PATTERNS); + if (result != null) + { + if (negative) + return handleBCE(result); + else + return result; + } + + return null; + } + + private synchronized Date checkFormats (String dateString, SimpleDateFormat[] format_array) + { + for (int i = 0; i < format_array.length; ++i) + { + try + { + format_array[i].setLenient(false); + return format_array[i].parse(dateString); + } + catch (ParseException parseException) + { + } + } + + return null; + } + + public synchronized SimpleDateFormat[] obtainDurationFormats(String dateString) + { + String first_part, second_part; + StringBuffer format_buffer = new StringBuffer("'P'"); + + // Must divide it into two parts to distinguish between Months and Minutes + + int time_index = dateString.indexOf("T"); + if (time_index != -1) + { + first_part = dateString.substring(0, time_index + 1); + second_part = dateString.substring(time_index); + } + else + { + first_part = dateString; + second_part = null; + } + + if (first_part.indexOf("Y") != -1) + format_buffer.append("yyyy'Y'"); + if (first_part.indexOf("M") != -1) + format_buffer.append("MM'M'"); + if (first_part.indexOf("D") != -1) + format_buffer.append("dd'D'"); + if (time_index != -1) + { + format_buffer.append("'T'"); + + if (second_part.indexOf("H") != -1) + format_buffer.append("HH'H'"); + if (second_part.indexOf("M") != -1) + format_buffer.append("mm'M'"); + if (second_part.indexOf("S.") != -1) + format_buffer.append("ss'S'.S"); + else if (second_part.indexOf("S") != -1) + format_buffer.append("ss'S'"); + } + + String format_string = format_buffer.toString().replaceAll("''", ""); + + SimpleDateFormat [] DURATION_FORMATS = + { + new SimpleDateFormat(format_string) + }; + + return DURATION_FORMATS; + } + + // Return a negative Duration if a negative sign existed in dateString + public synchronized Date handleNegative(Date output) + { + return new Date(0 - output.getTime()); + } + + // Return the date in BCE if a negative sign existed in dateString + + public synchronized Date handleBCE(Date output) + { + GregorianCalendar temp = new GregorianCalendar(); + temp.setTime(output); + temp.set(GregorianCalendar.ERA, GregorianCalendar.BC); + + return temp.getTime(); + } + + 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/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/EqualityHelperImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/EqualityHelperImpl.java new file mode 100644 index 0000000000..e59a7d9f1c --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/EqualityHelperImpl.java @@ -0,0 +1,70 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.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/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/HelperProviderImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/HelperProviderImpl.java new file mode 100644 index 0000000000..24734cfaaf --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/HelperProviderImpl.java @@ -0,0 +1,215 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.helper; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.NotSerializableException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.io.ObjectStreamException; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; + +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.apache.tuscany.sdo.util.SDOUtil; + +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +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.XMLDocument; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; +import commonj.sdo.impl.HelperProvider; +import commonj.sdo.impl.ExternalizableDelegator.Resolvable; + + +/** + * 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() + { + return new ResolvableImpl(); + } + + public Resolvable resolvable(Object target) + { + return new ResolvableImpl(target); + } + + protected class ResolvableImpl implements Resolvable + { + protected Object target; + + public ResolvableImpl(Object target) { this.target = target; } + + public ResolvableImpl() { this.target = null; } + + public void writeExternal(ObjectOutput out) throws IOException + { + if (target instanceof DataObject) + { + writeDataObject((DataObject)target, out); + } + else + { + throw new NotSerializableException(); // should never happen + } + } + + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException + { + target = readDataObject(in); + } + + public Object readResolve() throws ObjectStreamException + { + return target; + } + + protected void writeDataObject(DataObject dataObject, ObjectOutput objectOutput) throws IOException + { + DataGraph dataGraph = dataObject.getDataGraph(); + if (dataGraph != null) + { + objectOutput.writeByte(0); + objectOutput.writeUTF(DataObjectUtil.getXPath(dataObject)); + objectOutput.writeObject(dataGraph); + } + else if (dataObject.getContainer() != null) + { + objectOutput.writeByte(0); + objectOutput.writeUTF(DataObjectUtil.getXPath(dataObject)); + objectOutput.writeObject(dataObject.getRootObject()); + } + else + { + // Root object + objectOutput.writeByte(1); + + ByteArrayOutputStream compressedByteArrayOutputStream = new ByteArrayOutputStream(); + GZIPOutputStream gzipOutputStream = new GZIPOutputStream(compressedByteArrayOutputStream); + + xmlHelper.save(dataObject, "commonj.sdo", "dataObject", gzipOutputStream); + gzipOutputStream.close(); // Flush the contents + + byte[] byteArray = compressedByteArrayOutputStream.toByteArray(); + objectOutput.writeInt(byteArray.length); + objectOutput.write(byteArray); + } + } + + protected DataObject readDataObject(ObjectInput objectInput) throws IOException, ClassNotFoundException + { + boolean isRoot = objectInput.readByte() == 1; + if (isRoot) + { + // Root object: [rootXML] = length + XML contents + int length = objectInput.readInt(); + byte[] compressedBytes = new byte [length]; + objectInput.read(compressedBytes, 0, length); + + GZIPInputStream gzipInputStream = new GZIPInputStream(new ByteArrayInputStream(compressedBytes)); + + XMLDocument doc = xmlHelper.load(gzipInputStream); + gzipInputStream.close(); + + return doc.getRootObject(); + } + else + { + // Non root object: [path] [root] + String xpath = objectInput.readUTF(); + Object object = objectInput.readObject(); + + DataObject root = object instanceof DataGraph ? ((DataGraph)object).getRootObject() : (DataObject)object; + return xpath.equals("") ? root : root.getDataObject(xpath); + } + } + } +} diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOAnnotations.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOAnnotations.java new file mode 100644 index 0000000000..816fb3bf9f --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOAnnotations.java @@ -0,0 +1,51 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.helper; + +public class SDOAnnotations +{ + public static final String COLON = ":"; + public static final String COMMONJ_SDO_NS = "commonj.sdo"; + public static final String COMMONJ_SDO_NS_PREFIX = "sdo"; + public static final String SDO_JAVA_NS = "commonj.sdo/java"; + public static final String SDO_JAVA_NS_PREFIX = "sdoJava"; + + public static final String JAVA_PACKAGE = SDO_JAVA_NS_PREFIX + COLON + "package"; + public static final String ALIAS_NAMES = COMMONJ_SDO_NS_PREFIX + COLON + "aliasName"; + public static final String READ_ONLY = COMMONJ_SDO_NS_PREFIX + COLON + "readOnly"; + public static final String INSTANCE_CLASS = SDO_JAVA_NS_PREFIX + COLON + "instanceClass"; + public static final String ABSTRACT_TYPE = "abstract"; + public static final String PROPERTY_TYPE = COMMONJ_SDO_NS_PREFIX + COLON + "propertyType"; + public static final String OPPOSITE_PROPERTY = COMMONJ_SDO_NS_PREFIX + COLON + "oppositeProperty"; + + + //used by the annotations map to uniquely identify schema elements that need to be annotated + //and to store the corresponding annotations in a map + public static final String SCHEMA = "schema"; + public static final String ELEMENT = "element"; + public static final String COMPLEX_TYPE = "complexType"; + public static final String SIMPLE_TYPE = "simpleType"; + public static final String ATTRIBUTE = "attribute"; + + public static String makeAnnotationMapKey(String namespace, String schemaElementType, String nameAttrValue) + { + return namespace + schemaElementType + nameAttrValue; + } +} diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOExtendedMetaDataImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOExtendedMetaDataImpl.java new file mode 100644 index 0000000000..b8bbfcb2d5 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOExtendedMetaDataImpl.java @@ -0,0 +1,99 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.helper; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.StringTokenizer; + +import org.apache.tuscany.sdo.SDOExtendedMetaData; +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.ecore.EModelElement; +import org.eclipse.emf.ecore.EPackage.Registry; +import org.eclipse.emf.ecore.util.BasicExtendedMetaData; + +public class SDOExtendedMetaDataImpl + extends BasicExtendedMetaData + implements SDOExtendedMetaData { + + + + public SDOExtendedMetaDataImpl() { + super(); + } + + public SDOExtendedMetaDataImpl(Registry registry) { + super(registry); + } + + public SDOExtendedMetaDataImpl(String annotationURI, Registry registry, Map annotationMap) { + super(annotationURI, registry, annotationMap); + } + + public SDOExtendedMetaDataImpl(String annotationURI, Registry registry) { + super(annotationURI, registry); + } + + /** + * Returns the listing of alias names as specified by the sdo:aliasNames + * property. + */ + public List getAliasNames(EModelElement modelElement) { + EAnnotation eAnnotation = getAnnotation(modelElement, false); + List list = null; + if (eAnnotation != null) { + String aliasNames = (String)eAnnotation.getDetails().get("aliasNames"); + if (aliasNames != null) { + list = new ArrayList(); + StringTokenizer st = new StringTokenizer(aliasNames, " "); + while (st.hasMoreTokens()) { + String t = st.nextToken(); + list.add(t); + } + } + } + return list; + } + + + public void setAliasNames(EModelElement modelElement, List aliasNames) { + if (aliasNames == null || aliasNames.isEmpty()) { + setAliasNames(modelElement, (String)null); + } else { + StringBuffer buf = new StringBuffer(); + for (int n = 0; n < aliasNames.size(); n++) { + String name = (String) aliasNames.get(n); + buf.append(name); + buf.append(" "); + } + setAliasNames(modelElement, buf.toString()); + } + } + + /** + * Adds an alias name per sdo:aliasName + */ + public void setAliasNames(EModelElement modelElement, String aliasNames) { + EAnnotation eAnnotation = getAnnotation(modelElement, true); + eAnnotation.getDetails().put("aliasNames", aliasNames); + } + +} diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOXSDEcoreBuilder.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOXSDEcoreBuilder.java new file mode 100644 index 0000000000..9ec309b547 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOXSDEcoreBuilder.java @@ -0,0 +1,458 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.helper; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import org.apache.tuscany.sdo.SDOExtendedMetaData; +import org.apache.tuscany.sdo.model.ModelPackage; +import org.apache.tuscany.sdo.util.SDOUtil; +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.EEnum; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.util.ExtendedMetaData; +import org.eclipse.xsd.XSDComplexTypeDefinition; +import org.eclipse.xsd.XSDComponent; +import org.eclipse.xsd.XSDConcreteComponent; +import org.eclipse.xsd.XSDFeature; +import org.eclipse.xsd.XSDNamedComponent; +import org.eclipse.xsd.XSDSchema; +import org.eclipse.xsd.XSDSimpleTypeDefinition; +import org.eclipse.xsd.XSDTypeDefinition; +import org.eclipse.xsd.ecore.XSDEcoreBuilder; +import org.w3c.dom.Element; + +/** + * TODO: + * - Implement support for the SDO XSD Schema annotations + * - Override the default ecore type mappings + * + * DONE: + * - Override the default XSDEcoreBuilder name mangling + */ +public class SDOXSDEcoreBuilder extends XSDEcoreBuilder +{ + public SDOXSDEcoreBuilder(ExtendedMetaData extendedMetaData) + { + super(extendedMetaData); + populateTypeToTypeObjectMap(ModelPackage.eINSTANCE); + } + + /** + * Overrides method in EMF. This will cause the SDO Properties to be in the + * order in which the Attributes appeared in the XSD. + */ + protected boolean useSortedAttributes() + { + return false; + } + + public EClassifier getEClassifier(XSDTypeDefinition xsdTypeDefinition) { + EClassifier eClassifier = null; + if (rootSchema.getSchemaForSchemaNamespace().equals(xsdTypeDefinition.getTargetNamespace())) { + eClassifier = + getBuiltInEClassifier( + xsdTypeDefinition.getURI(), + xsdTypeDefinition.getName()); + } else { + eClassifier = super.getEClassifier(xsdTypeDefinition); + } + return eClassifier; + } + + public EDataType getEDataType(XSDSimpleTypeDefinition xsdSimpleTypeDefinition) { + EDataType eClassifier = null; + if (rootSchema.getSchemaForSchemaNamespace().equals(xsdSimpleTypeDefinition.getTargetNamespace())) { + eClassifier = + (EDataType)getBuiltInEClassifier( + xsdSimpleTypeDefinition.getURI(), + xsdSimpleTypeDefinition.getName()); + } else { + eClassifier = super.getEDataType(xsdSimpleTypeDefinition); + } + return (EDataType)eClassifier; + } + + protected EClassifier getBuiltInEClassifier(String namespace, String name) + { + EClassifier eClassifier = (EClassifier)SDOUtil.getXSDSDOType(name); + if (eClassifier == null) { + eClassifier = super.getBuiltInEClassifier(namespace, name); + } + return eClassifier; + } + + public EClass computeEClass(XSDComplexTypeDefinition xsdComplexTypeDefinition) { + EClass eclass = super.computeEClass(xsdComplexTypeDefinition); + String aliasNames = getEcoreAttribute(xsdComplexTypeDefinition.getElement(), "aliasName"); + if (aliasNames != null) { + SDOExtendedMetaData.INSTANCE.setAliasNames(eclass, aliasNames); + } + return eclass; + } + + protected EClassifier computeEClassifier(XSDTypeDefinition xsdTypeDefinition) { + EClassifier eclassifier = super.computeEClassifier(xsdTypeDefinition); + EClassifier etype = (EClassifier) typeToTypeObjectMap.get(eclassifier); + String aliasNames = getEcoreAttribute(xsdTypeDefinition.getElement(), "aliasName"); + if (aliasNames != null) { + SDOExtendedMetaData.INSTANCE.setAliasNames(eclassifier, aliasNames); + if (etype != null) { + SDOExtendedMetaData.INSTANCE.setAliasNames(etype, aliasNames); + } + } + return eclassifier; + } + + protected EDataType computeEDataType(XSDSimpleTypeDefinition xsdSimpleTypeDefinition) { + EDataType edatatype = super.computeEDataType(xsdSimpleTypeDefinition); + String aliasNames = getEcoreAttribute(xsdSimpleTypeDefinition.getElement(), "aliasName"); + if (aliasNames != null) { + SDOExtendedMetaData.INSTANCE.setAliasNames(edatatype, aliasNames); + } + return edatatype; + } + + protected EEnum computeEEnum(XSDSimpleTypeDefinition xsdSimpleTypeDefinition) { + return null; + } + + protected EStructuralFeature createFeature(EClass eClass, String name, EClassifier type, XSDComponent xsdComponent, int minOccurs, int maxOccurs) { + EStructuralFeature feature = + super.createFeature(eClass, name, type, xsdComponent, minOccurs, maxOccurs); + feature.setName(name); // this is needed because super.createFeature() does EMF name mangling (toLower) + if (xsdComponent != null) { + String aliasNames = getEcoreAttribute(xsdComponent.getElement(), "aliasName"); + if (aliasNames != null) { + SDOExtendedMetaData.INSTANCE.setAliasNames(feature, aliasNames); + } + } + return feature; + } + + protected String getInstanceClassName(XSDTypeDefinition typeDefinition, EDataType baseEDataType) { + String name = getEcoreAttribute(typeDefinition, "extendedInstanceClass"); + return (name != null) ? name : super.getInstanceClassName(typeDefinition, baseEDataType); + } + + 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"; + else if ("string".equals(attribute)) + sdoAttribute = "string"; + else if ("changeable".equals(attribute)) + sdoAttribute = "readOnly"; + else if ("aliasName".equals(attribute)) + sdoAttribute = "aliasName"; + + if (sdoAttribute != null) + { + String value = + element != null && element.hasAttributeNS("commonj.sdo/xml", sdoAttribute) ? + element.getAttributeNS("commonj.sdo/xml", sdoAttribute) : + null; + if ("changeable".equals(attribute)) { + if ("true".equals(value)) value = "false"; + else if ("false".equals(value)) value = "true"; + } + return value; + } + + if ("package".equals(attribute)) + sdoAttribute = "package"; + else if ("instanceClass".equals(attribute)) + sdoAttribute = "instanceClass"; + else if ("extendedInstanceClass".equals(attribute)) + sdoAttribute = "extendedInstanceClass"; + else if ("nestedInterfaces".equals(attribute)) + sdoAttribute = "nestedInterfaces"; + + 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 String getEcoreAttribute(XSDConcreteComponent xsdConcreteComponent, String attribute) + { + String value = super.getEcoreAttribute(xsdConcreteComponent, attribute); + if ("package".equals(attribute) && value == null) + { + XSDSchema xsdSchema = (XSDSchema)xsdConcreteComponent; + value = getDefaultPackageName(xsdSchema.getTargetNamespace()); + } + return value; + } + */ + + protected XSDTypeDefinition getEcoreTypeQNameAttribute(XSDConcreteComponent xsdConcreteComponent, String attribute) + { + if (xsdConcreteComponent == null) return null; + String sdoAttribute = null; + + if ("reference".equals(attribute)) sdoAttribute = "propertyType"; + if ("dataType".equals(attribute)) sdoAttribute = "dataType"; + + if (sdoAttribute != null) + { + Element element = xsdConcreteComponent.getElement(); + return element == null ? null : getEcoreTypeQNameAttribute(xsdConcreteComponent, element, "commonj.sdo/xml", sdoAttribute); + } + + return super.getEcoreTypeQNameAttribute(xsdConcreteComponent, attribute); + } + + /** + * Override default EMF behavior so that the name is not mangled. + */ + protected String validName(String name, int casing, String prefix) { + return name; + } + + /** + * Override default EMF name mangling for anonymous types (simple and complex) + */ + protected String validAliasName(XSDTypeDefinition xsdTypeDefinition, boolean isUpperCase) { + return getAliasName(xsdTypeDefinition); + } + + protected String getAliasName(XSDNamedComponent xsdNamedComponent) { + String result = xsdNamedComponent.getName(); + if (result == null) + { + XSDConcreteComponent container = xsdNamedComponent.getContainer(); + if (container instanceof XSDNamedComponent) + { + result = getAliasName((XSDNamedComponent)container); + } + } + return result; + } + + protected XSDTypeDefinition getEffectiveTypeDefinition(XSDComponent xsdComponent, XSDFeature xsdFeature) { + XSDTypeDefinition typeDef = getEcoreTypeQNameAttribute(xsdComponent, "dataType"); + + String isString = getEcoreAttribute(xsdComponent, xsdFeature, "string"); + if ("true".equalsIgnoreCase(isString)) { + typeDef = + xsdFeature.resolveSimpleTypeDefinition(rootSchema.getSchemaForSchemaNamespace(), "string"); + } + if (typeDef == null) + typeDef = xsdFeature.getType(); + return typeDef; + } + + /** + * Override EMF algorithm. + */ + public String qualifiedPackageName(String namespace) + { + return getDefaultPackageName(namespace); + } + + //Code below here to provide common URI to java packagname + + public static String uncapNameStatic(String name) + { + if (name.length() == 0) + { + return name; + } + else + { + String lowerName = name.toLowerCase(); + int i; + for (i = 0; i < name.length(); i++) + { + if (name.charAt(i) == lowerName.charAt(i)) + { + break; + } + } + if (i > 1 && i < name.length() && !Character.isDigit(name.charAt(i))) + { + --i; + } + return name.substring(0, i).toLowerCase() + name.substring(i); + } + } + + protected static String validNameStatic(String name, int casing, String prefix) + { + List parsedName = parseNameStatic(name, '_'); + StringBuffer result = new StringBuffer(); + for (Iterator i = parsedName.iterator(); i.hasNext(); ) + { + String nameComponent = (String)i.next(); + if (nameComponent.length() > 0) + { + if (result.length() > 0 || casing == UPPER_CASE) + { + result.append(Character.toUpperCase(nameComponent.charAt(0))); + result.append(nameComponent.substring(1)); + } + else + { + result.append(nameComponent); + } + } + } + + return + result.length() == 0 ? + prefix : + Character.isJavaIdentifierStart(result.charAt(0)) ? + casing == LOWER_CASE ? + uncapNameStatic(result.toString()) : + result.toString() : + prefix + result; + } + + protected static List parseNameStatic(String sourceName, char separator) + { + List result = new ArrayList(); + if (sourceName != null) + { + StringBuffer currentWord = new StringBuffer(); + boolean lastIsLower = false; + for (int index = 0, length = sourceName.length(); index < length; ++index) + { + char curChar = sourceName.charAt(index); + if (!Character.isJavaIdentifierPart(curChar)) + { + curChar = separator; + } + if (Character.isUpperCase(curChar) || (!lastIsLower && Character.isDigit(curChar)) || curChar == separator) + { + if (lastIsLower && currentWord.length() > 1 || curChar == separator && currentWord.length() > 0) + { + result.add(currentWord.toString()); + currentWord = new StringBuffer(); + } + lastIsLower = false; + } + else + { + if (!lastIsLower) + { + int currentWordLength = currentWord.length(); + if (currentWordLength > 1) + { + char lastChar = currentWord.charAt(--currentWordLength); + currentWord.setLength(currentWordLength); + result.add(currentWord.toString()); + currentWord = new StringBuffer(); + currentWord.append(lastChar); + } + } + lastIsLower = true; + } + + if (curChar != separator) + { + currentWord.append(curChar); + } + } + + result.add(currentWord.toString()); + } + return result; + } + + public static String getDefaultPackageName(String targetNamespace) + { + if (targetNamespace == null) + return null; + + URI uri = URI.createURI(targetNamespace); + List parsedName; + if (uri.isHierarchical()) + { + String host = uri.host(); + if (host != null && host.startsWith("www.")) + { + host = host.substring(4); + } + parsedName = parseNameStatic(host, '.'); + Collections.reverse(parsedName); + if (!parsedName.isEmpty()) + { + parsedName.set(0, ((String)parsedName.get(0)).toLowerCase()); + } + + parsedName.addAll(parseNameStatic(uri.trimFileExtension().path(), '/')); + } + else + { + String opaquePart = uri.opaquePart(); + int index = opaquePart.indexOf(":"); + if (index != -1 && "urn".equalsIgnoreCase(uri.scheme())) + { + parsedName = parseNameStatic(opaquePart.substring(0, index), '-'); + if (parsedName.size() > 0 && DOMAINS.contains(parsedName.get(parsedName.size() - 1))) + { + Collections.reverse(parsedName); + parsedName.set(0, ((String)parsedName.get(0)).toLowerCase()); + } + parsedName.addAll(parseNameStatic(opaquePart.substring(index + 1), '/')); + } + else + { + parsedName = parseNameStatic(opaquePart, '/'); + } + } + + StringBuffer qualifiedPackageName = new StringBuffer(); + for (Iterator i = parsedName.iterator(); i.hasNext(); ) + { + String packageName = (String)i.next(); + if (packageName.length() > 0) + { + if (qualifiedPackageName.length() > 0) + { + qualifiedPackageName.append('.'); + } + qualifiedPackageName.append(validNameStatic(packageName, LOWER_CASE,"_")); + } + } + + return qualifiedPackageName.toString().toLowerCase(); //make sure it's lower case .. we can't work with Axis if not. + } + +} diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/SchemaBuilder.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/SchemaBuilder.java new file mode 100644 index 0000000000..1597d0bd9e --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/SchemaBuilder.java @@ -0,0 +1,786 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.helper; + +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Vector; + +import javax.xml.namespace.QName; + +import org.apache.tuscany.sdo.util.SDOUtil; +import org.eclipse.xsd.XSDAttributeDeclaration; +import org.eclipse.xsd.XSDAttributeUse; +import org.eclipse.xsd.XSDComplexTypeDefinition; +import org.eclipse.xsd.XSDCompositor; +import org.eclipse.xsd.XSDConstraint; +import org.eclipse.xsd.XSDDerivationMethod; +import org.eclipse.xsd.XSDElementDeclaration; +import org.eclipse.xsd.XSDFactory; +import org.eclipse.xsd.XSDForm; +import org.eclipse.xsd.XSDImport; +import org.eclipse.xsd.XSDInclude; +import org.eclipse.xsd.XSDModelGroup; +import org.eclipse.xsd.XSDParticle; +import org.eclipse.xsd.XSDProcessContents; +import org.eclipse.xsd.XSDSchema; +import org.eclipse.xsd.XSDSchemaContent; +import org.eclipse.xsd.XSDSimpleTypeDefinition; +import org.eclipse.xsd.XSDTypeDefinition; +import org.eclipse.xsd.XSDWildcard; + +import commonj.sdo.Property; +import commonj.sdo.Type; +import commonj.sdo.helper.XSDHelper; + +public class SchemaBuilder extends SDOAnnotations +{ + public static final String DEFAULT_SCHEMA_LOCATION = ""; + public static final String NAME_SPACE_PREFIX = "stn_"; + private static int prefixCount = 1; + + //public static final String MIXED = "mixed"; + //public static final String GROUP = "group"; + public static final String EFEATURE_MAP_ENTRY = "EFeatureMapEntry"; + + private Map schemaMap = null; + protected Map targetNamespacePrefixMap = new Hashtable(); + protected Map schemaLocationMap = null; + protected TypeTable typeTable = null; + protected XSDFactory xsdFactory = XSDFactory.eINSTANCE; + + + protected SchemaBuilder(Map schemaMap, + Map nsPrefixMap, + TypeTable typeTable, + Map schemaLocMap ) + { + this.schemaMap = schemaMap; + this.targetNamespacePrefixMap = nsPrefixMap; + this.typeTable = typeTable; + this.schemaLocationMap = schemaLocMap; + } + + + + + private QName addAttribute2ComplexType(String targetNamespace, + XSDComplexTypeDefinition complexType, + Property aProperty) + { + QName attributeSchemaType = null; + String prefix = null; + + try + { + attributeSchemaType = buildSchema(aProperty.getType()); + } + catch ( IllegalArgumentException e ) + { + //schema cannot be generated for this type as there exists an xsd already + //so include that original XSD + attributeSchemaType = new QName(aProperty.getType().getURI(), + aProperty.getType().getName(), + generatePrefix()); + if ( aProperty.getType().isDataType() ) + { + typeTable.addSimpleSchemaType(aProperty.getType().getName(), attributeSchemaType); + + XSDSimpleTypeDefinition simpleType = xsdFactory.createXSDSimpleTypeDefinition(); + simpleType.setName(aProperty.getType().getName()); + simpleType.setTargetNamespace(aProperty.getType().getURI()); + typeTable.addXSDTypeDef(attributeSchemaType.getNamespaceURI(), + attributeSchemaType.getLocalPart(), + simpleType); + } + else + { + typeTable.addComplexSchemaType(aProperty.getType().getURI(), + aProperty.getType().getName(), + attributeSchemaType); + + XSDComplexTypeDefinition extComplexType = xsdFactory.createXSDComplexTypeDefinition(); + extComplexType.setName(aProperty.getType().getName()); + extComplexType.setTargetNamespace(aProperty.getType().getURI()); + typeTable.addXSDTypeDef(attributeSchemaType.getNamespaceURI(), + attributeSchemaType.getLocalPart(), + extComplexType); + } + includeExtXSD(aProperty.getType()); + } + //ensure than an import is done rightaway so that the right prefixes will be used by the + //attribute whose type is set as 'this type'. Otherwise when setting the type for the attribute + //there will be a duplicate prefix (like Q1 or Q2... ) that will be created + prefix = addImports((XSDSchema)schemaMap.get(targetNamespace), attributeSchemaType); + + XSDAttributeDeclaration attribute = xsdFactory.createXSDAttributeDeclaration(); + attribute.setName(aProperty.getName()); + XSDAttributeUse orderDateAttributeUse = xsdFactory.createXSDAttributeUse(); + orderDateAttributeUse.setContent(attribute); + complexType.getAttributeContents().add(orderDateAttributeUse); + attribute.updateElement(); + + if ( aProperty.getType().isDataType() ) + { + attribute.setTypeDefinition((XSDSimpleTypeDefinition)typeTable.getXSDTypeDef(attributeSchemaType.getNamespaceURI(), + attributeSchemaType.getLocalPart())); + + } + else + { + attribute.setTypeDefinition((XSDSimpleTypeDefinition)typeTable.getXSDTypeDef( + typeTable.getSimpleSchemaTypeName("URI").getNamespaceURI(), + typeTable.getSimpleSchemaTypeName("URI").getLocalPart())); + + } + + if ( aProperty.getDefault() != null ) + { + attribute.setConstraint(XSDConstraint.DEFAULT_LITERAL); + attribute.setLexicalValue(aProperty.getDefault().toString()); + } + + addAnnotations(attribute, aProperty ); + if ( !aProperty.getType().isDataType() ) + { + String value = prefix + COLON + attributeSchemaType.getLocalPart(); + attribute.getElement().setAttribute(PROPERTY_TYPE, value); + } + + return attributeSchemaType; + } + + private QName addElement2ComplexType(String targetNamespace, + XSDComplexTypeDefinition complexType, + Property aProperty) + { + String prefix = null; + QName elementSchemaType = null; + try + { + elementSchemaType = buildSchema(aProperty.getType()); + } + catch ( IllegalArgumentException e ) + { + //schema cannot be generated for this type as there exists an xsd already + //so include that original XSD + elementSchemaType = new QName(aProperty.getType().getURI(), + aProperty.getType().getName(), + generatePrefix()); + if ( aProperty.getType().isDataType() ) + { + typeTable.addSimpleSchemaType(aProperty.getType().getName(), elementSchemaType); + + XSDSimpleTypeDefinition simpleType = xsdFactory.createXSDSimpleTypeDefinition(); + simpleType.setName(aProperty.getType().getName()); + simpleType.setTargetNamespace(aProperty.getType().getURI()); + typeTable.addXSDTypeDef(elementSchemaType.getNamespaceURI(), + elementSchemaType.getLocalPart(), + simpleType); + } + else + { + typeTable.addComplexSchemaType(aProperty.getType().getURI(), + aProperty.getType().getName(), + elementSchemaType); + XSDComplexTypeDefinition extComplexType = xsdFactory.createXSDComplexTypeDefinition(); + extComplexType.setName(aProperty.getType().getName()); + extComplexType.setTargetNamespace(aProperty.getType().getURI()); + typeTable.addXSDTypeDef(elementSchemaType.getNamespaceURI(), + elementSchemaType.getLocalPart(), + extComplexType); + } + includeExtXSD(aProperty.getType()); + } + + //ensure than an import is done rightaway so that the right prefixes will be used by the + //element whose type is set as 'this type'. Otherwise when setting the type for the element + //there will be a duplicate prefix (like Q1 or Q2... ) that will be created + prefix = addImports((XSDSchema)schemaMap.get(targetNamespace), elementSchemaType); + + //XmlSchemaElement element = new XmlSchemaElement(); + XSDElementDeclaration element = xsdFactory.createXSDElementDeclaration(); + element.setName(aProperty.getName()); + + XSDParticle aParticle = xsdFactory.createXSDParticle(); + aParticle.setContent(element); + + ((XSDModelGroup)((XSDParticle)complexType.getContent()).getContent()). + getContents().add(aParticle); + + element.updateElement(); + + if ( aProperty.isMany() ) + { + aParticle.setMaxOccurs(-1); + aParticle.setMinOccurs(0); + + } + + if ( aProperty.isContainment() ) + { + element.setTypeDefinition(typeTable.getXSDTypeDef(elementSchemaType.getNamespaceURI(), + elementSchemaType.getLocalPart())); + } + else + { + if ( !aProperty.getType().isDataType() ) + { + QName qName = typeTable.getSimpleSchemaTypeName("URI"); + element.setTypeDefinition(typeTable.getXSDTypeDef(qName.getNamespaceURI(), + qName.getLocalPart())); + } + } + + addAnnotations(element, aProperty); + if ( !aProperty.isContainment() && !aProperty.getType().isDataType() ) + { + String value = prefix + COLON + elementSchemaType.getLocalPart(); + element.getElement().setAttribute(PROPERTY_TYPE, value); + } + return elementSchemaType; + + } + + private void addAnnotations(XSDSchemaContent xsdContent, Property aProperty) + { + if ( !aProperty.getAliasNames().isEmpty() ) + { + addAliasNamesAnnotation(xsdContent, aProperty.getAliasNames()); + } + + if ( aProperty.isReadOnly() ) + { + xsdContent.getElement().setAttribute(READ_ONLY, Boolean.toString(aProperty.isReadOnly())); + } + + if ( aProperty.getOpposite() != null ) + { + xsdContent.getElement().setAttribute(OPPOSITE_PROPERTY, aProperty.getOpposite().getName()); + } + } + + + private QName buildComplexSchemaTypeContents(String targetNamespace, + XSDComplexTypeDefinition complexType, + Type dataType) + { + //clipProperties(dataType); + List properties = dataType.getDeclaredProperties(); + Iterator iterator = properties.iterator(); + Property aProperty; + QName propertySchemaTypeName = null; + + while ( iterator.hasNext() ) + { + aProperty = (Property)iterator.next(); + if ( aProperty.isContainment() || aProperty.isMany() || !aProperty.getType().isDataType() ) + { + propertySchemaTypeName = addElement2ComplexType(targetNamespace, complexType, aProperty); + } + else + { + propertySchemaTypeName = addAttribute2ComplexType(targetNamespace, complexType, aProperty); + } + + /*if ( !EFEATURE_MAP_ENTRY.equals(aProperty.getType().getName()) ) + { + addContents2ComplexType(targetNamespace, complexType, aProperty); + }*/ + } + + return propertySchemaTypeName; + + } + + public QName buildComplexSchemaType(Type dataType) + { + //this is called from buildSchema only if isXSD(dataType) is false + QName complexSchemaTypeName = null ; + if ( !dataType.isDataType() && + (complexSchemaTypeName = typeTable.getComplexSchemaTypeName(dataType.getURI(), dataType.getName())) == null ) + { + XSDSchema xmlSchema = getXmlSchema(dataType); + String targetNamespace = dataType.getURI(); + String targetNamespacePrefix = (String)targetNamespacePrefixMap.get(targetNamespace); + + complexSchemaTypeName = new QName(targetNamespace, + dataType.getName(), + targetNamespacePrefix); + + XSDComplexTypeDefinition complexType = xsdFactory.createXSDComplexTypeDefinition(); + complexType.setName(dataType.getName()); + complexType.setTargetNamespace(targetNamespace); + complexType.setAbstract(dataType.isAbstract()); + + xmlSchema.getTypeDefinitions().add(complexType); + xmlSchema.getContents().add(complexType); + + complexType.updateElement(); + + addAnnotations(complexType, dataType); + + handleBaseExtn(xmlSchema, dataType, complexType); + handleSDOSequence(dataType, complexType); + handleSDOOpenType(dataType, complexType); + + //add before constructing the contents because a content element could + //possibly be of type 'complexType'. + typeTable.addComplexSchemaType(dataType.getURI(), dataType.getName(), complexSchemaTypeName); + typeTable.addXSDTypeDef(dataType.getURI(), dataType.getName(), complexType); + + //now compose the contents for this complex type + buildComplexSchemaTypeContents(targetNamespace, complexType, dataType); + + //finally create a global element for this type + createGlobalElement(xmlSchema, complexType, complexSchemaTypeName); + } + + return complexSchemaTypeName; + } + + private void addAnnotations(XSDTypeDefinition xsdType, Type dataType) + { + if ( dataType.isAbstract() ) + { + if ( xsdType instanceof XSDComplexTypeDefinition ) + { + ((XSDComplexTypeDefinition)xsdType).setAbstract(dataType.isAbstract()); + } + else + { + xsdType.getElement().setAttribute(ABSTRACT_TYPE, + Boolean.toString(dataType.isAbstract())); + } + } + + //add alias names if it exists + addAliasNamesAnnotation(xsdType, + dataType.getAliasNames()); + + //add instanceClass annotation + if ( dataType.getInstanceClass() != null ) + { + xsdType.getElement().setAttribute(INSTANCE_CLASS, dataType.getInstanceClass().getName()); + } + } + + + private QName buildSimpleSchemaType(Type dataType) + { + QName simpleSchemaTypeName = null; + if ( dataType.isDataType() && + (simpleSchemaTypeName = typeTable.getSimpleSchemaTypeName(dataType.getName()) ) == null ) + { + XSDSchema xmlSchema = getXmlSchema(dataType); + XSDSimpleTypeDefinition simpleType = xsdFactory.createXSDSimpleTypeDefinition(); + //set the name + simpleType.setName(dataType.getName()); + simpleType.setTargetNamespace(dataType.getURI()); + //set abstract=true if abstract + simpleSchemaTypeName = new QName(dataType.getURI(), + dataType.getName(), + (String)targetNamespacePrefixMap.get(dataType.getURI())); + xmlSchema.getContents().add(simpleType); + simpleType.updateElement(); + + addAnnotations(simpleType, dataType); + + if ( !dataType.getBaseTypes().isEmpty() ) + { + Type baseType = (Type)dataType.getBaseTypes().get(0); + + QName baseSchemaType = null; + + try + { + baseSchemaType = buildSchema(baseType); + } + catch ( IllegalArgumentException e ) + { + //this means that the base type comes from a original xsd and hence not generated + baseSchemaType = new QName(baseType.getURI(), + baseType.getName(), + generatePrefix()); + + typeTable.addSimpleSchemaType(baseType.getName(), baseSchemaType); + + XSDSimpleTypeDefinition baseTypeDef = xsdFactory.createXSDSimpleTypeDefinition(); + baseTypeDef.setName(baseType.getName()); + baseTypeDef.setTargetNamespace(baseType.getURI()); + typeTable.addXSDTypeDef(baseType.getURI(), baseType.getName(), baseTypeDef); + + //include external XSD locations + includeExtXSD(baseType); + } + + simpleType.setBaseTypeDefinition((XSDSimpleTypeDefinition)typeTable. + getXSDTypeDef(baseSchemaType.getNamespaceURI(),baseSchemaType.getLocalPart())); + addImports(xmlSchema, baseSchemaType); + } + + + typeTable.addSimpleSchemaType(dataType.getName(), simpleSchemaTypeName); + typeTable.addXSDTypeDef(dataType.getURI(), dataType.getName(), simpleType); + } + return simpleSchemaTypeName; + } + + private void includeExtXSD(Type dataType) + { + //now we know there is a type for which the xsd must come from outside + //create a schema for the namespace of this type and add an include in it for + //the xsd that is defined externally + XSDSchema xmlSchema = getXmlSchema(dataType); + + //ideally there could be more than one external schema defintions for a namespace + //and hence schemalocations will be a list of locations + //List schemaLocations = (List)schemaLocationMap.get(dataType.getURI()); + + //since as per the specs the input to XSDHelper is a map of <String, String> allowing + //only one schemalocation for a namespace. So for now this single location will be + //picked up and put into a list + List schemaLocations = new Vector(); + if ( schemaLocationMap.get(dataType.getURI()) != null ) + { + schemaLocations.add(schemaLocationMap.get(dataType.getURI())); + } + + if ( schemaLocations.size() <= 0 ) + { + schemaLocations.add(DEFAULT_SCHEMA_LOCATION); + } + + Object schemaContent = null; + Iterator includesIterator = xmlSchema.getContents().iterator(); + Iterator schemaLocIterator = schemaLocations.iterator(); + String aSchemaLocation = null; + boolean includeExists = false; + //include all external schema locations + while ( schemaLocIterator.hasNext() ) + { + aSchemaLocation = (String)schemaLocIterator.next(); + while ( includesIterator.hasNext() ) + { + schemaContent = includesIterator.next(); + if ( schemaContent instanceof XSDInclude ) + { + if ( !includeExists && aSchemaLocation.equals( + ((XSDInclude)schemaContent).getSchemaLocation() + )) + { + includeExists = true; + } + } + } + + if ( !includeExists ) + { + XSDInclude includeElement = xsdFactory.createXSDInclude(); + includeElement.setSchemaLocation(aSchemaLocation); + xmlSchema.getContents().add(0, includeElement); + } + } + } + + protected QName buildSchema(Type dataType) throws IllegalArgumentException + { + QName schemaTypeName = null; + + if ( dataType.isDataType() ) + { + schemaTypeName = typeTable.getSimpleSchemaTypeName(dataType.getName()); + } + else + { + schemaTypeName = typeTable.getComplexSchemaTypeName(dataType.getURI(), dataType.getName()); + } + + //attempt to generate only if we have not done it already..i.e the type is + //not found in the typetable + if ( schemaTypeName == null ) + { + XSDHelper xsdHelper = SDOUtil.createXSDHelper(SDOUtil.createTypeHelper()); + + if ( !xsdHelper.isXSD( dataType ) ) + { + if ( dataType.isDataType() ) + { + schemaTypeName = buildSimpleSchemaType(dataType); + } + else + { + schemaTypeName = buildComplexSchemaType(dataType); + } + } + else + { + throw new IllegalArgumentException("Cannot generate XSD since SDO Type '" + + dataType.getName() + "' was orginally generated from XSD. Use original XSD"); + } + } + return schemaTypeName; + } + + + private XSDSchema getXmlSchema(Type dataType) + { + XSDSchema xmlSchema = null; + + if ((xmlSchema = (XSDSchema) schemaMap.get(dataType.getURI())) == null) + { + String targetNamespacePrefix = generatePrefix(); + + xmlSchema = xsdFactory.createXSDSchema(); + xmlSchema.setTargetNamespace(dataType.getURI()); + xmlSchema.setAttributeFormDefault(XSDForm.QUALIFIED_LITERAL); + xmlSchema.setElementFormDefault(XSDForm.QUALIFIED_LITERAL); + + targetNamespacePrefixMap.put(dataType.getURI(), targetNamespacePrefix); + schemaMap.put(dataType.getURI(), xmlSchema); + + xmlSchema.getQNamePrefixToNamespaceMap().put(TypeTable.XS_URI_PREFIX, TypeTable.XML_SCHEMA_URI); + xmlSchema.setSchemaForSchemaQNamePrefix(TypeTable.XS_URI_PREFIX); + + xmlSchema.getQNamePrefixToNamespaceMap().put(targetNamespacePrefix, dataType.getURI()); + //xmlSchema.setSchemaForSchemaQNamePrefix(targetNamespacePrefix); + + addSDONamespaces(xmlSchema); + addPackageAnnotation(xmlSchema, dataType); + } + return xmlSchema; + } + + + private void addSDONamespaces(XSDSchema xmlSchema) + { + xmlSchema.getQNamePrefixToNamespaceMap().put(COMMONJ_SDO_NS_PREFIX, COMMONJ_SDO_NS); + //xmlSchema.setSchemaForSchemaQNamePrefix(COMMONJ_SDO_NS_PREFIX); + + xmlSchema.getQNamePrefixToNamespaceMap().put(SDO_JAVA_NS_PREFIX, SDO_JAVA_NS); + //xmlSchema.setSchemaForSchemaQNamePrefix(SDO_JAVA_NS_PREFIX); + } + + + /** + * JAM convert first name of an attribute into UpperCase as an example if + * there is a instance variable called foo in a bean , then Jam give that as + * Foo so this method is to correct that error + * + * @param wrongName + * @return the right name, using english as the locale for case conversion + */ + public static String getCorrectName(String wrongName) + { + if (wrongName.length() > 1) { + return wrongName.substring(0, 1).toLowerCase(Locale.ENGLISH) + + wrongName.substring(1, wrongName.length()); + } else { + return wrongName.substring(0, 1).toLowerCase(Locale.ENGLISH); + } + } + + private String addImports(XSDSchema xmlSchema, QName schemaTypeName) + { + String prefix = null; + Iterator iterator = xmlSchema.getQNamePrefixToNamespaceMap().keySet().iterator(); + while ( iterator.hasNext() ) + { + prefix = (String)iterator.next(); + + if ( schemaTypeName.getNamespaceURI().equals( + xmlSchema.getQNamePrefixToNamespaceMap().get(prefix)) ) + { + return prefix; + } + } + + //the following lines are executed only if a prefix was not found which implies that the + //schemaTypeName was not imported earlier and also it does not belong to the targetnamespace + XSDImport importElement = xsdFactory.createXSDImport(); + importElement.setNamespace(schemaTypeName.getNamespaceURI()); + xmlSchema.getContents().add(0, importElement); + prefix = schemaTypeName.getPrefix(); + if ( prefix == null || prefix.length() <= 0 ) + { + prefix = generatePrefix(); + } + xmlSchema.getQNamePrefixToNamespaceMap().put(prefix, schemaTypeName.getNamespaceURI()); + + return prefix; + } + + private void handleSDOSequence(Type datatype, XSDComplexTypeDefinition complexType) + { + if ( datatype.isSequenced() ) + { + complexType.setMixed(true); + XSDModelGroup choice = xsdFactory.createXSDModelGroup(); + choice.setCompositor(XSDCompositor.CHOICE_LITERAL); + XSDParticle aParticle = xsdFactory.createXSDParticle(); + aParticle.setContent(choice); + aParticle.setMaxOccurs(-1); + complexType.setContent(aParticle); + } + else + { + //hack to handle group property as choice + /*if ( getPropertyStartsWithName(datatype.getDeclaredProperties(), GROUP).size() > 0 ) + { + XmlSchemaChoice choice = new XmlSchemaChoice(); + choice.setMaxOccurs(Long.MAX_VALUE); + complexType.setParticle(choice); + } + else*/ + { + XSDModelGroup sequence = xsdFactory.createXSDModelGroup(); + sequence.setCompositor(XSDCompositor.SEQUENCE_LITERAL); + XSDParticle aParticle = xsdFactory.createXSDParticle(); + aParticle.setContent(sequence); + complexType.setContent(aParticle); + } + } + } + + private void handleSDOOpenType(Type datatype, XSDComplexTypeDefinition complexType) + { + if ( datatype.isOpen() /*&& + getPropertyStartsWithName(datatype.getDeclaredProperties(), GROUP).size() <= 0 */) + { + XSDWildcard elementWildcard = xsdFactory.createXSDWildcard(); + elementWildcard.getLexicalNamespaceConstraint().add("##other"); + elementWildcard.setProcessContents(XSDProcessContents.LAX_LITERAL); + // Create a particle to hold the wildcard. + XSDParticle wildcardParticle = xsdFactory.createXSDParticle(); + wildcardParticle.setContent(elementWildcard); + wildcardParticle.setMaxOccurs(-1); + ((XSDModelGroup)((XSDParticle)complexType.getContent()).getContent()). + getContents().add(wildcardParticle); + + XSDWildcard attributeWildcard = xsdFactory.createXSDWildcard(); + attributeWildcard.getLexicalNamespaceConstraint().add("##other"); + attributeWildcard.setProcessContents(XSDProcessContents.LAX_LITERAL); + complexType.setAttributeWildcard(attributeWildcard); + } + } + + private void handleBaseExtn(XSDSchema xmlSchema, + Type datatype, + XSDComplexTypeDefinition complexType) + { + if ( datatype.getBaseTypes().size() > 0 ) + { + Type baseType = (Type)datatype.getBaseTypes().get(0); + QName baseSchemaType = null; + + try + { + baseSchemaType = buildSchema(baseType); + } + catch ( IllegalArgumentException e ) + { + //schema cannot be generated for this type as there exists an xsd already + //so include that original XSD + baseSchemaType = new QName(baseType.getURI(), + baseType.getName(), + generatePrefix()); + + XSDSimpleTypeDefinition baseTypeDef = xsdFactory.createXSDSimpleTypeDefinition(); + baseTypeDef.setName(baseType.getName()); + baseTypeDef.setTargetNamespace(baseType.getURI()); + typeTable.addXSDTypeDef(baseType.getURI(), baseType.getName(), baseTypeDef); + + includeExtXSD(baseType); + } + + complexType.setDerivationMethod(XSDDerivationMethod.EXTENSION_LITERAL); + + if ( baseType.isDataType() ) + { + XSDSimpleTypeDefinition anonymousSimpleTypeDefinition + = xsdFactory.createXSDSimpleTypeDefinition(); + anonymousSimpleTypeDefinition.setBaseTypeDefinition((XSDSimpleTypeDefinition)typeTable. + getXSDTypeDef(baseSchemaType.getNamespaceURI(),baseSchemaType.getLocalPart())); + complexType.setContent(anonymousSimpleTypeDefinition); + } + else + { + complexType.setBaseTypeDefinition((XSDSimpleTypeDefinition)typeTable. + getXSDTypeDef(baseSchemaType.getNamespaceURI(),baseSchemaType.getLocalPart())); + + } + + addImports(xmlSchema, baseSchemaType); + } + } + + private String formGlobalElementName(String typeName) + { + String firstChar = typeName.substring(0,1); + return typeName.replaceFirst(firstChar, firstChar.toLowerCase()); + } + + private void createGlobalElement(XSDSchema xmlSchema, + XSDComplexTypeDefinition complexType, + QName schemaElementName ) + { + XSDElementDeclaration globalElement = xsdFactory.createXSDElementDeclaration(); + globalElement.setTargetNamespace(xmlSchema.getTargetNamespace()); + globalElement.setName(formGlobalElementName(complexType.getName())); + globalElement.setTypeDefinition + (typeTable.getXSDTypeDef(schemaElementName.getNamespaceURI(), + schemaElementName.getLocalPart())); + xmlSchema.getContents().add(globalElement); + xmlSchema.getElementDeclarations().add(globalElement); + } + + private void addAliasNamesAnnotation(XSDSchemaContent typeDef, + List aliasNames) + { + if ( !aliasNames.isEmpty() ) + { + StringBuffer sb = new StringBuffer(); + Iterator iterator = aliasNames.iterator(); + while ( iterator.hasNext() ) + { + sb.append(iterator.next()); + } + typeDef.getElement().setAttribute(ALIAS_NAMES, sb.toString()); + } + } + + private void addPackageAnnotation(XSDSchema xmlSchema, Type dataType) + { + if ( dataType.getInstanceClass() != null ) + { + xmlSchema.updateElement(); + xmlSchema.getElement().setAttribute(JAVA_PACKAGE, + dataType.getInstanceClass().getPackage().getName()); + } + } + + private String generatePrefix() + { + return NAME_SPACE_PREFIX + prefixCount++; + } +} diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java new file mode 100644 index 0000000000..eee90b866f --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java @@ -0,0 +1,286 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.helper; + + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.apache.tuscany.sdo.model.impl.ModelPackageImpl; +import org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl; +import org.apache.tuscany.sdo.util.SDOUtil; +import org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl; +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.Property; +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 ExtendedMetaData getExtendedMetaData() + { + return extendedMetaData; + } + + public TypeHelperImpl(ExtendedMetaData extendedMetaData) + { + this.extendedMetaData = extendedMetaData; + + // Register the standard (predefined) SDO types + ModelPackageImpl.init(); + JavaPackageImpl.init(); + MetadataPackageImpl.init(); + } + + 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) + { + Type type = SDOUtil.getJavaSDOType(interfaceClass); + if (type != null) + { + return type; + } + + //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) + { + if (!(type instanceof org.apache.tuscany.sdo.model.Type)) + throw new IllegalArgumentException(); + org.apache.tuscany.sdo.model.Type modeledType = (org.apache.tuscany.sdo.model.Type)type; + + boolean isDataType = modeledType.isDataType(); + Type definedType = SDOUtil.createType(this, modeledType.getUri(), modeledType.getName(), isDataType); + if (definedType == null) + { + // If type already defined, return the existing Type. + return getType(modeledType.getUri(), modeledType.getName()); + } + + SDOUtil.setJavaClassName(definedType, modeledType.getInstanceClassName()); + + if (!isDataType) + { + SDOUtil.setSequenced(definedType, modeledType.isSequenced()); + SDOUtil.setOpen(definedType, modeledType.isOpen()); + SDOUtil.setAbstract(definedType, modeledType.isAbstract()); + + for (Iterator iter = modeledType.getBaseType().iterator(); iter.hasNext(); ) + { + Type baseType = getDefinedType((org.apache.tuscany.sdo.model.Type)iter.next()); + SDOUtil.addBaseType(definedType, baseType); + } + + for (Iterator iter = modeledType.getAliasName().iterator(); iter.hasNext(); ) + { + String aliasName = (String)iter.next(); + SDOUtil.addAliasName(definedType, aliasName); + } + + for (Iterator iter = modeledType.getProperty().iterator(); iter.hasNext(); ) + { + org.apache.tuscany.sdo.model.Property modeledProperty = (org.apache.tuscany.sdo.model.Property)iter.next(); + + Type propertyType = getDefinedType(modeledProperty.getType_()); + Property definedProperty = SDOUtil.createProperty(definedType, modeledProperty.getName(), propertyType); + + SDOUtil.setMany(definedProperty, modeledProperty.isMany()); + SDOUtil.setDefault(definedProperty, modeledProperty.getDefault_()); + SDOUtil.setReadOnly(definedProperty, modeledProperty.isReadOnly()); + + for (Iterator iter2 = modeledProperty.getAliasName().iterator(); iter2.hasNext(); ) + { + String aliasName = (String)iter2.next(); + SDOUtil.addAliasName(definedProperty, aliasName); + } + + if (!propertyType.isDataType()) + { + SDOUtil.setContainment(definedProperty, modeledProperty.isContainment()); + if (modeledProperty.getOpposite_() != null) + { + SDOUtil.setOpposite(definedProperty, getDefinedProperty(modeledProperty.getOpposite_())); + } + } + } + } // if (!isDataType) + + return definedType; + } + + public List /*Type*/define(List /*DataObject*/types) + { + int count = types.size(); + List definedTypes = new ArrayList(count); + for (int i = 0; i < count; i++) + { + definedTypes.add(define((DataObject)types.get(i))); + } + return definedTypes; + } + + protected Type getDefinedType(org.apache.tuscany.sdo.model.Type modeledType) + { + if (modeledType instanceof Type) + { + return (Type)modeledType; + } + else + { + EClassifier eClassifier = extendedMetaData.getType(modeledType.getUri(), modeledType.getName()); + if (eClassifier != null) + { + return (Type)eClassifier; + } + else + { + return define((DataObject)modeledType); + } + } + } + + protected Property getDefinedProperty(org.apache.tuscany.sdo.model.Property modeledProperty) + { + if (modeledProperty instanceof Property) + { + return (Property)modeledProperty; + } + else + { + DataObject modeledContainingType = ((DataObject)modeledProperty).getContainer(); + + Type definedContainingType = getDefinedType((org.apache.tuscany.sdo.model.Type)modeledContainingType); + String propertyName = modeledProperty.getName(); + + return definedContainingType.getProperty(propertyName); + } + } + + public static final String TUSCANY_NO_URI="http://tuscany-no-uri"; + + public Property defineOpenContentProperty(String uri, DataObject property) + { + // validate property and get type + if (!(property instanceof org.apache.tuscany.sdo.model.impl.PropertyImpl)) + throw new IllegalArgumentException(); + org.apache.tuscany.sdo.model.Property modeledProperty = (org.apache.tuscany.sdo.model.Property)property; + Type propertyType = getDefinedType(modeledProperty.getType_()); + + if (uri == null) uri = TUSCANY_NO_URI; + + // get/create document root + EPackage ePackage = extendedMetaData.getPackage(uri); + Type documentRoot = + ePackage != null ? (Type)extendedMetaData.getType(extendedMetaData.getPackage(uri), "") : null; + if (documentRoot == null) + { + documentRoot = SDOUtil.createType(this, uri, null, false); + } + + // Determine if property already exists + Property newProperty = documentRoot.getProperty(modeledProperty.getName()); + if (newProperty == null) + { + //FB TBD ... is this code really supposed to be the same as in define()? If so, factor it out and reuse + + // Create the new property 'under' the document root..... + newProperty = SDOUtil.createProperty(documentRoot, modeledProperty.getName(), propertyType); + + // Propagate the modeled property's attributes + SDOUtil.setMany(newProperty, modeledProperty.isMany()); + SDOUtil.setDefault(newProperty, modeledProperty.getDefault_()); + SDOUtil.setReadOnly(newProperty, modeledProperty.isReadOnly()); + for (Iterator iter = modeledProperty.getAliasName().iterator(); iter.hasNext();) + { + String aliasName = (String)iter.next(); + SDOUtil.addAliasName(newProperty, aliasName); + } + if (!propertyType.isDataType()) + { + SDOUtil.setContainment(newProperty, modeledProperty.isContainment()); + if (modeledProperty.getOpposite_() != null) + { + SDOUtil.setOpposite(newProperty, getDefinedProperty(modeledProperty.getOpposite_())); + } + } + } + else + { + // if property already exists, validate the expected type + if (!newProperty.getType().equals(propertyType)) + throw new IllegalArgumentException(); + } + + return newProperty; + } + + public Property getOpenContentProperty(String uri, String propertyName) + { + //FB TBD ... in the future we will allow elements or attributes - see SDOUtil.createProperty() + return (Property)extendedMetaData.getElement(uri, propertyName); + } +} diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeTable.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeTable.java new file mode 100644 index 0000000000..a28492e28e --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeTable.java @@ -0,0 +1,254 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.helper; + +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Vector; + +import javax.xml.namespace.QName; + +//import org.apache.axiom.om.OMElement; +import org.eclipse.xsd.XSDFactory; +import org.eclipse.xsd.XSDTypeDefinition; +import org.w3c.dom.Element; + + + +public class TypeTable +{ + public static final String XML_SCHEMA_URI = "http://www.w3.org/2001/XMLSchema"; + public static final String XS_URI_PREFIX = "xs"; + public static final QName XS_QNAME = new QName(XML_SCHEMA_URI, "schema", XS_URI_PREFIX); + public static final String DELIMITER = "#"; + + private Hashtable simpleXSDTypes; + private Hashtable complexXSDTypes; + private Hashtable xsdTypeDefs; + + public static String asQualifiedName(String uri, String typeName) + { + return (uri + DELIMITER + typeName); + } + + + public TypeTable() + { + simpleXSDTypes = new Hashtable(); + complexXSDTypes = new Hashtable(); + xsdTypeDefs = new Hashtable(); + populateSimpleXSDTypes(); + populateStdSDOTypes(); + } + + private void populateStdSDOTypes() + { + simpleXSDTypes.put("Boolean", + new QName(XML_SCHEMA_URI, "boolean", XS_URI_PREFIX)); + simpleXSDTypes.put("Byte", + new QName(XML_SCHEMA_URI, "byte", XS_URI_PREFIX)); + simpleXSDTypes.put("Bytes", + new QName(XML_SCHEMA_URI, "hexBinary", XS_URI_PREFIX)); + simpleXSDTypes.put("Character", + new QName(XML_SCHEMA_URI, "string", XS_URI_PREFIX)); + simpleXSDTypes.put("DataObject", + new QName(XML_SCHEMA_URI, "anyType", XS_URI_PREFIX)); + simpleXSDTypes.put("Date", + new QName(XML_SCHEMA_URI, "dateTime", XS_URI_PREFIX)); + simpleXSDTypes.put("Day", + new QName(XML_SCHEMA_URI, "gDay", XS_URI_PREFIX)); + simpleXSDTypes.put("Decimal", + new QName(XML_SCHEMA_URI, "decimal", XS_URI_PREFIX)); + simpleXSDTypes.put("Double", + new QName(XML_SCHEMA_URI, "double", XS_URI_PREFIX)); + simpleXSDTypes.put("Duration", + new QName(XML_SCHEMA_URI, "duration", XS_URI_PREFIX)); + simpleXSDTypes.put("Float", + new QName(XML_SCHEMA_URI, "float", XS_URI_PREFIX)); + simpleXSDTypes.put("Int", + new QName(XML_SCHEMA_URI, "int", XS_URI_PREFIX)); + simpleXSDTypes.put("Integer", + new QName(XML_SCHEMA_URI, "integer", XS_URI_PREFIX)); + simpleXSDTypes.put("Long", + new QName(XML_SCHEMA_URI, "long", XS_URI_PREFIX)); + simpleXSDTypes.put("Month", + new QName(XML_SCHEMA_URI, "gMonth", XS_URI_PREFIX)); + simpleXSDTypes.put("monthDay", + new QName(XML_SCHEMA_URI, "gMonthDay", XS_URI_PREFIX)); + simpleXSDTypes.put("Object", + new QName(XML_SCHEMA_URI, "anySimpleType", XS_URI_PREFIX)); + simpleXSDTypes.put("Short", + new QName(XML_SCHEMA_URI, "short", XS_URI_PREFIX)); + simpleXSDTypes.put("String", + new QName(XML_SCHEMA_URI, "string", XS_URI_PREFIX)); + simpleXSDTypes.put("Strings", + new QName(XML_SCHEMA_URI, "string", XS_URI_PREFIX)); + simpleXSDTypes.put("Time", + new QName(XML_SCHEMA_URI, "time", XS_URI_PREFIX)); + simpleXSDTypes.put("Year", + new QName(XML_SCHEMA_URI, "gYear", XS_URI_PREFIX)); + simpleXSDTypes.put("YearMonth", + new QName(XML_SCHEMA_URI, "gYearMonth", XS_URI_PREFIX)); + simpleXSDTypes.put("YearMonthDay", + new QName(XML_SCHEMA_URI, "date", XS_URI_PREFIX)); + simpleXSDTypes.put("URI", + new QName(XML_SCHEMA_URI, "anyURI", XS_URI_PREFIX)); + } + + private void populateSimpleXSDTypes() { + //todo pls use the types from org.apache.ws.commons.schema.constants.Constants + simpleXSDTypes.put("int", + new QName(XML_SCHEMA_URI, "int", XS_URI_PREFIX)); + simpleXSDTypes.put("java.lang.String", + new QName(XML_SCHEMA_URI, "string", XS_URI_PREFIX)); + simpleXSDTypes.put("boolean", + new QName(XML_SCHEMA_URI, "boolean", XS_URI_PREFIX)); + simpleXSDTypes.put("float", + new QName(XML_SCHEMA_URI, "float", XS_URI_PREFIX)); + simpleXSDTypes.put("double", + new QName(XML_SCHEMA_URI, "double", XS_URI_PREFIX)); + simpleXSDTypes.put("short", + new QName(XML_SCHEMA_URI, "short", XS_URI_PREFIX)); + simpleXSDTypes.put("long", + new QName(XML_SCHEMA_URI, "long", XS_URI_PREFIX)); + simpleXSDTypes.put("byte", + new QName(XML_SCHEMA_URI, "byte", XS_URI_PREFIX)); + simpleXSDTypes.put("char", + new QName(XML_SCHEMA_URI, "anyType", XS_URI_PREFIX)); + simpleXSDTypes.put("java.lang.Integer", + new QName(XML_SCHEMA_URI, "int", XS_URI_PREFIX)); + simpleXSDTypes.put("java.lang.Double", + new QName(XML_SCHEMA_URI, "double", XS_URI_PREFIX)); + simpleXSDTypes.put("java.lang.Float", + new QName(XML_SCHEMA_URI, "float", XS_URI_PREFIX)); + simpleXSDTypes.put("java.lang.Long", + new QName(XML_SCHEMA_URI, "long", XS_URI_PREFIX)); + simpleXSDTypes.put("java.lang.Character", + new QName(XML_SCHEMA_URI, "anyType", XS_URI_PREFIX)); + simpleXSDTypes.put("java.lang.Boolean", + new QName(XML_SCHEMA_URI, "boolean", XS_URI_PREFIX)); + simpleXSDTypes.put("java.lang.Byte", + new QName(XML_SCHEMA_URI, "byte", XS_URI_PREFIX)); + simpleXSDTypes.put("java.lang.Short", + new QName(XML_SCHEMA_URI, "short", XS_URI_PREFIX)); + simpleXSDTypes.put("java.util.Date", + new QName(XML_SCHEMA_URI, "dateTime", XS_URI_PREFIX)); + simpleXSDTypes.put("java.util.Calendar", + new QName(XML_SCHEMA_URI, "dateTime", XS_URI_PREFIX)); + simpleXSDTypes.put("java.lang.Object", + new QName(XML_SCHEMA_URI, "anyType", XS_URI_PREFIX)); + simpleXSDTypes.put("java.math.BigDecimal", + new QName(XML_SCHEMA_URI, "decimal", XS_URI_PREFIX)); + + // Any types + simpleXSDTypes.put(Element.class.getName(), + new QName(XML_SCHEMA_URI, "anyType", XS_URI_PREFIX)); + simpleXSDTypes.put(ArrayList.class.getName(), + new QName(XML_SCHEMA_URI, "anyType", XS_URI_PREFIX)); + simpleXSDTypes.put(Vector.class.getName(), + new QName(XML_SCHEMA_URI, "anyType", XS_URI_PREFIX)); + simpleXSDTypes.put(List.class.getName(), + new QName(XML_SCHEMA_URI, "anyType", XS_URI_PREFIX)); + } + + public QName getStdSdoType(String typename) + { + return (QName) simpleXSDTypes.get(typename); + } + + public QName getComplexSchemaTypeName(String sdoURI, String sdoTypeName) + { + return (QName) complexXSDTypes.get(asQualifiedName(sdoURI, sdoTypeName)); + } + + public boolean isSimpleType(String typeName) + { + Iterator keys = simpleXSDTypes.keySet().iterator(); + while (keys.hasNext()) { + String s = (String) keys.next(); + if (s.equals(typeName)) { + return true; + } + } + return false; + } + + public QName getSimpleSchemaTypeName(String typename) + { + return (QName) simpleXSDTypes.get(typename); + } + + public void addSimpleSchemaType(String typeName, QName schemaType) + { + simpleXSDTypes.put(typeName, schemaType); + } + + + public void addComplexSchemaType(String namespaceURI, String name, QName schemaType) + { + complexXSDTypes.put(asQualifiedName(namespaceURI, name), schemaType); + } + + + public QName getQNamefortheType(String namespaceURI, String typeName) + { + if ( XML_SCHEMA_URI.equals(namespaceURI)) + { + return getSimpleSchemaTypeName(typeName); + } + else + { + return getComplexSchemaTypeName(namespaceURI, typeName); + } + } + + public void addXSDTypeDef(String namespaceURI, String typeName, XSDTypeDefinition aTypeDef) + { + if ( namespaceURI != null && typeName != null && aTypeDef != null ) + { + xsdTypeDefs.put(asQualifiedName(namespaceURI, typeName), aTypeDef); + } + } + + public XSDTypeDefinition getXSDTypeDef(String namespaceURI, String typeName) + { + XSDTypeDefinition typeDef = null; + if ( namespaceURI != null && typeName != null ) + { + if ( XML_SCHEMA_URI.equals(namespaceURI) ) + { + if ( ( typeDef = (XSDTypeDefinition)xsdTypeDefs.get(asQualifiedName(namespaceURI, typeName)) ) == null ) + { + typeDef = XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition(); + typeDef.setName(typeName); + typeDef.setTargetNamespace(namespaceURI); + addXSDTypeDef(namespaceURI, typeName, typeDef); + } + } + else + { + typeDef = (XSDTypeDefinition)xsdTypeDefs.get(asQualifiedName(namespaceURI, typeName)); + } + } + return typeDef; + } +} diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLDocumentImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLDocumentImpl.java new file mode 100644 index 0000000000..ce0031940f --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLDocumentImpl.java @@ -0,0 +1,536 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.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.Iterator; +import java.util.List; +import java.util.Map; + +import javax.xml.stream.XMLStreamReader; + +import org.apache.tuscany.sdo.SimpleAnyTypeDataObject; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.apache.tuscany.sdo.util.SDOUtil; +import org.apache.tuscany.sdo.util.resource.SDOXMLResourceImpl; +import org.eclipse.emf.common.util.EMap; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.resource.ResourceSet; +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.xmi.XMLResource; +import org.eclipse.emf.ecore.xml.type.XMLTypePackage; +import org.xml.sax.InputSource; + +import commonj.sdo.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.XMLDocument; + + +/** + * Represents an XML Document containing a tree of DataObjects. + * + * An example XMLDocument fragment is: + * <?xml version="1.0"?> + * <purchaseOrder orderDate="1999-10-20"> + * + * created from this XML Schema fragment: + * <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + * <xsd:element name="purchaseOrder" type="PurchaseOrderType"/> + * <xsd:complexType name="PurchaseOrderType"> + * + * 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 final static String WHITESPACE_REGEX = "\\s"; + + //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")); + DataObjectUtil.configureXMLResource(resource, extendedMetaData); + } + + 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); + } + + Object rootValue = + rootElement instanceof EAttribute && rootObject instanceof SimpleAnyTypeDataObject ? + ((SimpleAnyTypeDataObject)rootObject).getValue() : rootObject; + + documentRoot.eSet(rootElement, rootValue); + } + } + + 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(XMLStreamReader reader) throws IOException + { + ((SDOXMLResourceImpl)resource).load(reader, null); + initLoadedRoot(); + } + + protected void load(InputSource inputSource, String locationURI, Object options) throws IOException + { + if (locationURI != null) + { + inputSource.setSystemId(locationURI); + resource.setURI(URI.createURI(locationURI)); + } + resource.load(inputSource, (Map)options); + initLoadedRoot(); + } + + private void initLoadedRoot() + { + rootObject = null; + rootElement = null; + documentRoot = null; + + 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? + { + FeatureMap featureMap = (FeatureMap)documentRoot.eGet(documentRootClass.getEStructuralFeature(0)); // get mixed feature + int size = featureMap.size(); + for (int index = 0; index < size; 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; + if (!isText) + { + if (feature instanceof EReference) + { + rootObject = (EObject)featureMap.getValue(index); + documentRoot.eUnset(feature); + } + else //EAttribute + { + rootObject = (EObject)SDOUtil.createDataTypeWrapper((Type)feature.getEType(), featureMap.getValue(index)); + } + rootElement = feature; + break; + } + } //for + } + 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 resource.getXMLVersion(); + } + + public void setXMLVersion(String xmlVersion) + { + resource.setXMLVersion(xmlVersion); + } + + /** + * @return an EMap containing the schema locations or null when no map + */ + protected EMap getSchemaLocationMap() + { + EMap result = null; + if ((documentRoot != null) && (extendedMetaData != null)) + { + EReference xsiSchemaLocationMapFeature = extendedMetaData + .getXSISchemaLocationMapFeature(documentRoot.eClass()); + if (xsiSchemaLocationMapFeature != null) + { + result = (EMap) documentRoot.eGet(xsiSchemaLocationMapFeature); + } + } + return result; + } + + /** + * @param value + * from schema location map. + * @return string form of URI from provided value, deresolved if appropriate. + */ + protected String deresolve(String value) + { + URI location = URI.createURI(value); + URI resourceURI = resource.getURI(); + boolean shouldDeresolve = resourceURI != null && !resourceURI.isRelative() + && resourceURI.isHierarchical(); + if (shouldDeresolve && !location.isRelative()) + { + URI deresolvedURI = location.deresolve(resourceURI, true, true, false); + if (deresolvedURI.hasRelativePath()) + { + location = deresolvedURI; + } + } + return location.toString(); + } + + /** + * @param value + * for schema location from input parameter. + * @return string form of URI from provided value, resolved if appropriate. + */ + protected String resolve(String value) + { + URI location = URI.createURI(value); + URI resourceURI = resource.getURI(); + boolean shouldResolve = resourceURI != null && resourceURI.isHierarchical() + && !resourceURI.isRelative(); + if (shouldResolve && location.isRelative() && location.hasRelativePath()) + { + location = location.resolve(resourceURI, false); + } + return location.toString(); + } + + public String getSchemaLocation() + { + EMap xsiSchemaLocationMap = getSchemaLocationMap(); + if (xsiSchemaLocationMap != null) + { + if (!xsiSchemaLocationMap.isEmpty()) + { + StringBuffer xsiSchemaLocation = new StringBuffer(); + for (Iterator i = xsiSchemaLocationMap.entrySet().iterator(); i + .hasNext();) + { + Map.Entry entry = (Map.Entry) i.next(); + String namespace = (String) entry.getKey(); + if (namespace != null) + { + if (xsiSchemaLocation.length() > 0) + { + xsiSchemaLocation.append(' '); + } + xsiSchemaLocation.append(namespace); + xsiSchemaLocation.append(' '); + String value = entry.getValue().toString(); + xsiSchemaLocation.append(deresolve(value)); + } + } + return xsiSchemaLocation.toString().equals("") ? null + : xsiSchemaLocation.toString(); + } + } + return null; + } + + public void setSchemaLocation(String schemaLocation) + { + EMap xsiSchemaLocationMap = getSchemaLocationMap(); + if (xsiSchemaLocationMap != null) + { + // only remove the entries from xsiSchemaLocationMap that contain a + // non-null key + for (Iterator i = xsiSchemaLocationMap.entrySet().iterator(); i.hasNext();) + { + Map.Entry entry = (Map.Entry) i.next(); + if (entry.getKey() != null) + { + i.remove(); + } + } + if (xsiSchemaLocationMap.size() == 0) + { + resource.getDefaultSaveOptions().put( + XMLResource.OPTION_SCHEMA_LOCATION, Boolean.FALSE); + } + if (schemaLocation != null) + { + String[] values = schemaLocation.split(WHITESPACE_REGEX); + for (int i = 0; i < values.length; i++) // note: also incremented in + // loop + { + String key = values[i++]; + if (i < values.length) + { + xsiSchemaLocationMap.put(key, resolve(values[i])); + } + } + if (xsiSchemaLocationMap.size() != 0) + { + resource.getDefaultSaveOptions().put( + XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE); + } + } + } + } + + public String getNoNamespaceSchemaLocation() + { + EMap xsiSchemaLocationMap = getSchemaLocationMap(); + if (xsiSchemaLocationMap != null) + { + StringBuffer xsiSchemaLocation = new StringBuffer(); + if (!xsiSchemaLocationMap.isEmpty()) + { + Object valueObject = xsiSchemaLocationMap.get(null); + if (valueObject != null) + { + String valueString = (String) valueObject; + String[] values = valueString.split(WHITESPACE_REGEX); + for (int i = 0; i < values.length; i++) + { + if (xsiSchemaLocation.length() > 0) + { + xsiSchemaLocation.append(' '); + } + xsiSchemaLocation.append(deresolve(values[i])); + } + } + String result = xsiSchemaLocation.toString(); + return result.equals("") ? null : result; + } + } + return null; + } + + public void setNoNamespaceSchemaLocation(String schemaLocation) + { + EMap xsiSchemaLocationMap = getSchemaLocationMap(); + if (xsiSchemaLocationMap != null) + { + // only remove the entries from xsiSchemaLocationMap that contain a null + // key + xsiSchemaLocationMap.removeKey(null); + if (xsiSchemaLocationMap.size() == 0) + { + resource.getDefaultSaveOptions().put( + XMLResource.OPTION_SCHEMA_LOCATION, Boolean.FALSE); + } + if (schemaLocation != null) + { + String[] values = schemaLocation.split(WHITESPACE_REGEX); + for (int i = 0; i < values.length; i++) + { + xsiSchemaLocationMap.put(null, resolve(values[i])); + } + if (xsiSchemaLocationMap.size() != 0) + { + resource.getDefaultSaveOptions().put( + XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE); + } + } + } + } +} diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLHelperImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLHelperImpl.java new file mode 100644 index 0000000000..8a94167108 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLHelperImpl.java @@ -0,0 +1,119 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.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/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLStreamHelper.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLStreamHelper.java new file mode 100644 index 0000000000..8b01398adf --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLStreamHelper.java @@ -0,0 +1,92 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.helper; + +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import commonj.sdo.DataObject; +import commonj.sdo.helper.XMLDocument; + +/** + * Helper interface for reading and writing SDO DataObjects from XML streams (StAX). + * + * @version $Rev$ $Date$ + */ +public interface XMLStreamHelper { + /** + * Creates and returns an XMLDocument from an XML input stream. + * The reader must be positioned on a START_DOCUMENT event. + * + * @param reader the stream to read + * @return an XMLDocument created from the stream + * @throws XMLStreamException if there was a problem reading the stream + * @throws IllegalStateException if the reader is not positioned on a START_DOCUMENT event + */ + XMLDocument load(XMLStreamReader reader) throws XMLStreamException, IllegalStateException; + + /** + * Save a XMLDocument to an XML stream. + * + * @param document the document to be written + * @param writer the stream to write to + * @throws XMLStreamException if there was a problem writing to the stream + */ + void save(XMLDocument document, XMLStreamWriter writer) throws XMLStreamException; + + /** + * Creates and returns a XMLStreamReader that can be used to read an XMLDocument as a XML event stream. + * The reader will be positioned on a START_DOCUMENT event. + * + * @param document the XMLDocument to be read + * @return an XMLStreamReader that can be used to read the document + */ + XMLStreamReader createXMLStreamReader(XMLDocument document) throws XMLStreamException; + + /** + * Create a DataObject from an element in a XML stream. + * The reader must be positioned on a START_ELEMENT event. + * + * @param reader the stream to read + * @return a DataObject created from the element in the stream + * @throws XMLStreamException if there was a problem reading the stream + * @throws IllegalStateException if the reader is not positioned on a START_ELEMENT event + */ + DataObject loadObject(XMLStreamReader reader) throws XMLStreamException, IllegalStateException; + + /** + * Save a DataObject to an XML stream. + * + * @param sdo the DataObject to be written + * @param writer the stream to write to + * @throws XMLStreamException if there was a problem writing to the stream + */ + void saveObject(DataObject sdo, XMLStreamWriter writer) throws XMLStreamException; + + /** + * Creates and returns a XMLStreamReader that can be used to read a DataObject as a XML event stream. + * The reader will be positioned on a START_ELEMENT event. + * + * @param sdo the DataObject to be read + * @return an XMLStreamReader that can be used to read the DataObject + */ + XMLStreamReader createXMLStreamReader(DataObject sdo); +} diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLStreamHelperImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLStreamHelperImpl.java new file mode 100644 index 0000000000..306c60ca2b --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLStreamHelperImpl.java @@ -0,0 +1,129 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.helper; + +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sdo.util.resource.DataObjectXMLStreamReader; +import org.apache.tuscany.sdo.util.resource.XMLDocumentStreamReader; +import org.apache.tuscany.sdo.util.resource.XMLStreamSerializer; +import org.eclipse.emf.ecore.resource.Resource; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XMLDocument; + +/** + * @version $Rev$ $Date$ + */ +public class XMLStreamHelperImpl implements XMLStreamHelper +{ + TypeHelperImpl typeHelper; + + public XMLStreamHelperImpl(TypeHelper typeHelper) + { + this.typeHelper = (TypeHelperImpl)typeHelper; + } + + public XMLDocument load(XMLStreamReader reader) throws XMLStreamException, IllegalStateException + { + if (reader.getEventType() != XMLStreamConstants.START_DOCUMENT) + throw new IllegalStateException(); + + return loadDocument(reader); + } + + public void save(XMLDocument document, XMLStreamWriter writer) throws XMLStreamException + { + XMLStreamReader reader = createXMLStreamReader(document); + new XMLStreamSerializer().serialize(reader, writer); + } + + public XMLStreamReader createXMLStreamReader(XMLDocument document) throws XMLStreamException + { + XMLStreamReader reader = new DataObjectXMLStreamReader(document.getRootObject(), document.getRootElementURI(), document.getRootElementName(), typeHelper); + // Wrap the reader so that its position will be START_ELEMENT + return new XMLDocumentStreamReader(reader); + + } + + public DataObject loadObject(XMLStreamReader reader) throws XMLStreamException, IllegalStateException + { + if (reader.getEventType() != XMLStreamConstants.START_ELEMENT) + throw new IllegalStateException(); + + // StAX2SAXAdapter won't produce START_DOCUMENT if the reader is posisitioned at START_ELEMENT and the EMF loader will fail + // Wrap the reader so it represents a document + reader = new XMLDocumentStreamReader(reader); + + return loadDocument(reader).getRootObject(); + } + + public void saveObject(DataObject sdo, XMLStreamWriter writer) throws XMLStreamException + { + XMLStreamReader reader = createXMLStreamReader(sdo); + new XMLStreamSerializer().serialize(new XMLDocumentStreamReader(reader), writer); + } + + public XMLStreamReader createXMLStreamReader(DataObject dataObject) + { + String rootElementURI; + String rootElementName; + + Property property = dataObject.getContainmentProperty(); + if (property != null) + { + rootElementName = property.getName(); + rootElementURI = property.getType().getURI(); + } + else + { + rootElementName = dataObject.getType().getName(); + rootElementURI = dataObject.getType().getURI(); + } + + return new DataObjectXMLStreamReader(dataObject, rootElementURI, rootElementName, typeHelper); + } + + protected XMLDocument loadDocument(XMLStreamReader reader) throws XMLStreamException + { + try { + XMLDocumentImpl document = new XMLDocumentImpl(typeHelper.extendedMetaData, null); + document.load(reader); + return document; + } + catch (Exception e) { + if (e instanceof Resource.IOWrappedException) + { + Resource.IOWrappedException ioe = (Resource.IOWrappedException)e; + if (ioe.getWrappedException() instanceof XMLStreamException) + { + throw (XMLStreamException)ioe.getWrappedException(); + } + } + throw new RuntimeException(e); // ???? + } + } + +} diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XSDHelperImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XSDHelperImpl.java new file mode 100644 index 0000000000..f67d35d74d --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/XSDHelperImpl.java @@ -0,0 +1,285 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.helper; + + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.io.Reader; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.Hashtable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.xml.transform.OutputKeys; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +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.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.XSDSchema; +import org.eclipse.xsd.ecore.XSDEcoreBuilder; +import org.eclipse.xsd.util.XSDResourceImpl; +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); + + List newTypes = new ArrayList(); + for (Iterator schemaIter = model.getContents().iterator(); schemaIter.hasNext(); ) + { + XSDSchema schema = (XSDSchema)schemaIter.next(); + + EPackage ePackage = extendedMetaData.getPackage(schema.getTargetNamespace()); + if (ePackage == null) + { + Collection originalEPackages = new HashSet(ecoreBuilder.getTargetNamespaceToEPackageMap().values()); + ecoreBuilder.generate(schema); + Collection newEPackages = ecoreBuilder.getTargetNamespaceToEPackageMap().values(); + + for (Iterator iter = newEPackages.iterator(); iter.hasNext();) + { + EPackage currentPackage = (EPackage)iter.next(); + if (!originalEPackages.contains(currentPackage)) + { + currentPackage.setEFactoryInstance(new DynamicDataObjectImpl.FactoryImpl()); + EcoreUtil.freeze(currentPackage); + newTypes.addAll(currentPackage.getEClassifiers()); + } + } + } + } + + return newTypes; + } + catch (Exception e) + { + //e.printStackTrace(); + throw new IllegalArgumentException(e.getMessage()); + } + } + + public String generate(List /*Type*/types) throws IllegalArgumentException + { + return generate(types, new Hashtable()); + } + + public String generate(List /*Type*/types, Map /*String, String*/namespaceToSchemaLocation) throws IllegalArgumentException + { + if ( types != null && !types.isEmpty() ) + { + Hashtable schemaMap = new Hashtable(); + Hashtable nsPrefixMap = new Hashtable(); + TypeTable typeTable = new TypeTable(); + + SchemaBuilder schemaBuilder = new SchemaBuilder( schemaMap, + nsPrefixMap, + typeTable, + namespaceToSchemaLocation); + + Iterator iterator = types.iterator(); + Type dataType = null; + + try + { + while ( iterator.hasNext() ) + { + dataType = (Type)iterator.next(); + schemaBuilder.buildSchema(dataType); + } + + XSDSchema xmlSchema = null; + iterator = schemaMap.values().iterator(); + StringWriter writer = new StringWriter(); + + TransformerFactory transformerFactory = TransformerFactory.newInstance(); + Transformer transformer = transformerFactory.newTransformer(); + transformer.setOutputProperty(OutputKeys.INDENT, "yes"); + transformer.setOutputProperty(OutputKeys.METHOD, "xml"); + transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); + + while ( iterator.hasNext() ) + { + xmlSchema = (XSDSchema)iterator.next(); + + if(xmlSchema.getElement() == null) + { + xmlSchema.updateElement(); + } + + transformer.transform(new DOMSource(xmlSchema.getElement().getOwnerDocument()), + new StreamResult(writer)); + } + writer.close(); + return writer.getBuffer().toString(); + } + catch ( Exception e ) + { + //System.out.println("Unable to generate schema due to ..." + e); + //e.printStackTrace(); + throw new IllegalArgumentException(e.getMessage()); + } + } + else + { + //System.out.println("No SDO Types to generate schema ..."); + return ""; + } + } + +} diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/AnyTypeDataObjectImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/AnyTypeDataObjectImpl.java new file mode 100644 index 0000000000..b7d22c3be0 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/AnyTypeDataObjectImpl.java @@ -0,0 +1,299 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + +import org.apache.tuscany.sdo.AnyTypeDataObject; +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.util.BasicSequence; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.util.BasicFeatureMap; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.ecore.util.InternalEList; +import org.eclipse.emf.ecore.xml.type.AnyType; +import org.eclipse.emf.ecore.xml.type.XMLTypePackage; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>EData Object Any Type</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.sdo.impl.AnyTypeDataObjectImpl#getMixed <em>Mixed</em>}</li> + * <li>{@link org.apache.tuscany.sdo.impl.AnyTypeDataObjectImpl#getAny <em>Any</em>}</li> + * <li>{@link org.apache.tuscany.sdo.impl.AnyTypeDataObjectImpl#getAnyAttribute <em>Any Attribute</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class AnyTypeDataObjectImpl extends DataObjectImpl implements AnyTypeDataObject +{ + /** + * The cached value of the '{@link #getMixed() <em>Mixed</em>}' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getMixed() + * @generated + * @ordered + */ + protected FeatureMap mixed = null; + + /** + * The cached value of the '{@link #getAnyAttribute() <em>Any Attribute</em>}' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getAnyAttribute() + * @generated + * @ordered + */ + protected FeatureMap anyAttribute = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected AnyTypeDataObjectImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getAnyTypeDataObject(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public FeatureMap getMixed() + { + if (mixed == null) + { + //mixed = new BasicFeatureMap(this, SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED); + mixed = new BasicSequence(new BasicFeatureMap(this, SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED)).featureMap(); + } + return mixed; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public FeatureMap getAny() + { + //return (FeatureMap)((FeatureMap)getMixed()).list(XMLTypePackage.eINSTANCE.getAnyType_Any()); + return new BasicSequence((FeatureMap.Internal)((FeatureMap)getMixed()).list(XMLTypePackage.eINSTANCE.getAnyType_Any())).featureMap(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public FeatureMap getAnyAttribute() + { + if (anyAttribute == null) + { + //anyAttribute = new BasicFeatureMap(this, SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE); + anyAttribute = new BasicSequence(new BasicFeatureMap(this, SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE)).featureMap(); + } + return anyAttribute; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) + { + if (featureID >= 0) + { + switch (eDerivedStructuralFeatureID(featureID, baseClass)) + { + case SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED: + return ((InternalEList)getMixed()).basicRemove(otherEnd, msgs); + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY: + return ((InternalEList)getAny()).basicRemove(otherEnd, msgs); + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + return ((InternalEList)getAnyAttribute()).basicRemove(otherEnd, msgs); + default: + return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs); + } + } + return eBasicSetContainer(null, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED: + if (coreType) return getMixed(); + return ((FeatureMap.Internal)getMixed()).getWrapper(); + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY: + if (coreType) return getAny(); + return ((FeatureMap.Internal)getAny()).getWrapper(); + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + if (coreType) return getAnyAttribute(); + return ((FeatureMap.Internal)getAnyAttribute()).getWrapper(); + } + return eDynamicGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED: + ((FeatureMap.Internal)getMixed()).set(newValue); + return; + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY: + ((FeatureMap.Internal)getAny()).set(newValue); + return; + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + ((FeatureMap.Internal)getAnyAttribute()).set(newValue); + return; + } + eDynamicSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED: + getMixed().clear(); + return; + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY: + getAny().clear(); + return; + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + getAnyAttribute().clear(); + return; + } + eDynamicUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED: + return mixed != null && !mixed.isEmpty(); + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY: + return !getAny().isEmpty(); + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + return anyAttribute != null && !anyAttribute.isEmpty(); + } + return eDynamicIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public int eBaseStructuralFeatureID(int derivedFeatureID, Class baseClass) + { + if (baseClass == AnyType.class) + { + switch (derivedFeatureID) + { + case SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED: return XMLTypePackage.ANY_TYPE__MIXED; + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY: return XMLTypePackage.ANY_TYPE__ANY; + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: return XMLTypePackage.ANY_TYPE__ANY_ATTRIBUTE; + default: return -1; + } + } + return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) + { + if (baseClass == AnyType.class) + { + switch (baseFeatureID) + { + case XMLTypePackage.ANY_TYPE__MIXED: return SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED; + case XMLTypePackage.ANY_TYPE__ANY: return SDOPackage.ANY_TYPE_DATA_OBJECT__ANY; + case XMLTypePackage.ANY_TYPE__ANY_ATTRIBUTE: return SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE; + default: return -1; + } + } + return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (mixed: "); + result.append(mixed); + result.append(", anyAttribute: "); + result.append(anyAttribute); + result.append(')'); + return result.toString(); + } + +} //EDataObjectAnyTypeImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/AttributeImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/AttributeImpl.java new file mode 100644 index 0000000000..d3e2b7c997 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/AttributeImpl.java @@ -0,0 +1,735 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + +import java.util.List; + +import org.apache.tuscany.sdo.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.Sequence; +import commonj.sdo.Type; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Attribute</b></em>'. + * <!-- end-user-doc --> + * <p> + * </p> + * + * @generated + */ +public class AttributeImpl extends EAttributeImpl implements Property, org.apache.tuscany.sdo.model.Property/*, DataObject*/ +{ + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected AttributeImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + protected EClass eStaticClass() + { + return EcorePackage.eINSTANCE.getEAttribute(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Object getDefault() + { + return getDefaultValue(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isReadOnly() + { + //return "true".equals(EcoreUtil.getAnnotation(this, "commonj.sdo", "readOnly")); + return !isChangeable(); //TODO semantics don't exactly match? + } + + protected List aliasNames = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getAliasNames() + { + if (aliasNames == null) + { + aliasNames = DataObjectUtil.getAliasNames(this); + } + return aliasNames; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Type getType() + { + return (Type)getEType(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Type getContainingType() + { + return (Type)getEContainingClass(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Property getOpposite() + { + return null; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isContainment() + { + return false; + } + + protected EStructuralFeature.Internal.SettingDelegate createFeatureMapSettingDelegate() + { + return new InternalSettingDelegateSequence(this); + } + + public static class InternalSettingDelegateSequence extends InternalSettingDelegateMany + { + InternalSettingDelegateSequence(EStructuralFeature feature) + { + super(InternalSettingDelegateMany.FEATURE_MAP, feature); + } + + protected EStructuralFeature.Setting createDynamicSetting(InternalEObject owner) + { + FeatureMap.Internal featureMap = (FeatureMap.Internal)super.createDynamicSetting(owner); + new BasicSequence(featureMap); + return featureMap; + } + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // org.apache.tuscany.sdo.model.Property methods + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + + public List getAliasName() { + return this.getAliasNames(); + } + + public Sequence getAny() { + throw new UnsupportedOperationException(); + } + + public void unsetContainment() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetContainment() { + return false; + } + + public void setMany(boolean value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void unsetMany() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetMany() { + return isMany(); + } + + public void setReadOnly(boolean value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void unsetReadOnly() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetReadOnly() { + return isReadOnly(); + } + + public org.apache.tuscany.sdo.model.Type getType_() { + return (org.apache.tuscany.sdo.model.Type)getType(); + } + + public void setType(org.apache.tuscany.sdo.model.Type value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public Sequence getAnyAttribute() { + throw new UnsupportedOperationException(); + } + + public String getDefault_() { + return (String) this.getDefault(); + } + + public void setDefault_(String value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public org.apache.tuscany.sdo.model.Property getOpposite_() { + return (org.apache.tuscany.sdo.model.Property) getOpposite(); + } + + public void setOpposite_(org.apache.tuscany.sdo.model.Property value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void setContainment(boolean value) { + throw new UnsupportedOperationException(); + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // DataObject method implementations + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + /* + public Object get(int propertyIndex) { + return DataObjectUtil.get(this, propertyIndex); + } + + public void set(int propertyIndex, Object value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSet(int propertyIndex) { + return DataObjectUtil.isSet(this, propertyIndex); + } + + public void unset(int propertyIndex) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public Object get(Property property) { + return DataObjectUtil.get(this, ((EStructuralFeature)property).getFeatureID()); + } + + public void set(Property property, Object value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSet(Property property) { + return DataObjectUtil.isSet(this, ((EStructuralFeature)property).getFeatureID()); + } + + public void unset(Property property) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject getContainer() { + return (DataObject)eContainer(); + } + + public Property getContainmentProperty() { + return (Property)eContainmentFeature(); + } + + // Remaining DataObject methods are (will be) implemented as straight delegation to DataObjectUtil + + public Object get(String path) { + return DataObjectUtil.get(this, path); + } + + public void set(String path, Object value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSet(String path) { + return DataObjectUtil.isSet(this, path); + } + + public void unset(String path) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean getBoolean(String path) { + return DataObjectUtil.getBoolean(get(path)); + } + + public byte getByte(String path) { + return DataObjectUtil.getByte(get(path)); + } + + public char getChar(String path) { + return DataObjectUtil.getChar(get(path)); + } + + public double getDouble(String path) { + return DataObjectUtil.getDouble(get(path)); + } + + public float getFloat(String path) { + return DataObjectUtil.getFloat(get(path)); + } + + public int getInt(String path) { + return DataObjectUtil.getInt(get(path)); + } + + public long getLong(String path) { + return DataObjectUtil.getLong(get(path)); + } + + public short getShort(String path) { + return DataObjectUtil.getShort(get(path)); + } + + public byte[] getBytes(String path) { + return DataObjectUtil.getBytes(get(path)); + } + + public BigDecimal getBigDecimal(String path) { + return DataObjectUtil.getBigDecimal(get(path)); + } + + public BigInteger getBigInteger(String path) { + return DataObjectUtil.getBigInteger(get(path)); + } + + public DataObject getDataObject(String path) { + return (DataObject)get(path); + } + + public Date getDate(String path) { + return DataObjectUtil.getDate(get(path)); + } + + public String getString(String path) { + return DataObjectUtil.getString(get(path)); + } + + public List getList(String path) { + return (List)get(path); + } + + public Sequence getSequence(String path) { + return (Sequence)get(path); + } + + public void setBoolean(String path, boolean value) { + set(path, new Boolean(value)); + } + + public void setByte(String path, byte value) { + set(path, new Byte(value)); + } + + public void setChar(String path, char value) { + set(path, new Character(value)); + } + + public void setDouble(String path, double value) { + set(path, new Double(value)); + } + + public void setFloat(String path, float value) { + set(path, new Float(value)); + } + + public void setInt(String path, int value) { + set(path, new Integer(value)); + } + + public void setLong(String path, long value) { + set(path, new Long(value)); + } + + public void setShort(String path, short value) { + set(path, new Short(value)); + } + + public void setBytes(String path, byte[] value) { + set(path, value); + } + + public void setBigDecimal(String path, BigDecimal value) { + set(path, value); + } + + public void setBigInteger(String path, BigInteger value) { + set(path, value); + } + + public void setDataObject(String path, DataObject value) { + set(path, value); + } + + public void setDate(String path, Date value) { + set(path, value); + } + + public void setString(String path, String value) { + set(path, value); + } + + public void setList(String path, List value) { + set(path, value); + } + + public boolean getBoolean(int propertyIndex) { + return DataObjectUtil.getBoolean(this, propertyIndex); + } + + public byte getByte(int propertyIndex) { + return DataObjectUtil.getByte(this, propertyIndex); + } + + public char getChar(int propertyIndex) { + return DataObjectUtil.getChar(this, propertyIndex); + } + + public double getDouble(int propertyIndex) { + return DataObjectUtil.getDouble(this, propertyIndex); + } + + public float getFloat(int propertyIndex) { + return DataObjectUtil.getFloat(this, propertyIndex); + } + + public int getInt(int propertyIndex) { + return DataObjectUtil.getInt(this, propertyIndex); + } + + public long getLong(int propertyIndex) { + return DataObjectUtil.getLong(this, propertyIndex); + } + + public short getShort(int propertyIndex) { + return DataObjectUtil.getShort(this, propertyIndex); + } + + public byte[] getBytes(int propertyIndex) { + return DataObjectUtil.getBytes(this, propertyIndex); + } + + public BigDecimal getBigDecimal(int propertyIndex) { + return DataObjectUtil.getBigDecimal(this, propertyIndex); + } + + public BigInteger getBigInteger(int propertyIndex) { + return DataObjectUtil.getBigInteger(this, propertyIndex); + } + + public DataObject getDataObject(int propertyIndex) { + return DataObjectUtil.getDataObject(this, propertyIndex); + } + + public Date getDate(int propertyIndex) { + return DataObjectUtil.getDate(this, propertyIndex); + } + + public String getString(int propertyIndex) { + return DataObjectUtil.getString(this, propertyIndex); + } + + public List getList(int propertyIndex) { + return DataObjectUtil.getList(this, propertyIndex); + } + + public Sequence getSequence(int propertyIndex) { + return DataObjectUtil.getSequence(this, propertyIndex); + } + + public void setBoolean(int propertyIndex, boolean value) { + set(propertyIndex, new Boolean(value)); + } + + public void setByte(int propertyIndex, byte value) { + set(propertyIndex, new Byte(value)); + } + + public void setChar(int propertyIndex, char value) { + set(propertyIndex, new Character(value)); + } + + public void setDouble(int propertyIndex, double value) { + set(propertyIndex, new Double(value)); + } + + public void setFloat(int propertyIndex, float value) { + set(propertyIndex, new Float(value)); + } + + public void setInt(int propertyIndex, int value) { + set(propertyIndex, new Integer(value)); + } + + public void setLong(int propertyIndex, long value) { + set(propertyIndex, new Long(value)); + } + + public void setShort(int propertyIndex, short value) { + set(propertyIndex, new Short(value)); + } + + public void setBytes(int propertyIndex, byte[] value) { + set(propertyIndex, value); + } + + public void setBigDecimal(int propertyIndex, BigDecimal value) { + set(propertyIndex, value); + } + + public void setBigInteger(int propertyIndex, BigInteger value) { + set(propertyIndex, value); + } + + public void setDataObject(int propertyIndex, DataObject value) { + set(propertyIndex, value); + } + + public void setDate(int propertyIndex, Date value) { + set(propertyIndex, value); + } + + public void setString(int propertyIndex, String value) { + set(propertyIndex, value); + } + + public void setList(int propertyIndex, List value) { + set(propertyIndex, value); + } + + public boolean getBoolean(Property property) { + return DataObjectUtil.getBoolean(this, property); + } + + public byte getByte(Property property) { + return DataObjectUtil.getByte(this, property); + } + + public char getChar(Property property) { + return DataObjectUtil.getChar(this, property); + } + + public double getDouble(Property property) { + return DataObjectUtil.getDouble(this, property); + } + + public float getFloat(Property property) { + return DataObjectUtil.getFloat(this, property); + } + + public int getInt(Property property) { + return DataObjectUtil.getInt(this, property); + } + + public long getLong(Property property) { + return DataObjectUtil.getLong(this, property); + } + + public short getShort(Property property) { + return DataObjectUtil.getShort(this, property); + } + + public byte[] getBytes(Property property) { + return DataObjectUtil.getBytes(this, property); + } + + public BigDecimal getBigDecimal(Property property) { + return DataObjectUtil.getBigDecimal(this, property); + } + + public BigInteger getBigInteger(Property property) { + return DataObjectUtil.getBigInteger(this, property); + } + + public DataObject getDataObject(Property property) { + return DataObjectUtil.getDataObject(this, property); + } + + public Date getDate(Property property) { + return DataObjectUtil.getDate(this, property); + } + + public String getString(Property property) { + return DataObjectUtil.getString(this, property); + } + + public List getList(Property property) { + return DataObjectUtil.getList(this, property); + } + + public Sequence getSequence(Property property) { + return DataObjectUtil.getSequence(this, property); + } + + public void setBoolean(Property property, boolean value) { + set(property, new Boolean(value)); + } + + public void setByte(Property property, byte value) { + set(property, new Byte(value)); + } + + public void setChar(Property property, char value) { + set(property, new Character(value)); + } + + public void setDouble(Property property, double value) { + set(property, new Double(value)); + } + + public void setFloat(Property property, float value) { + set(property, new Float(value)); + } + + public void setInt(Property property, int value) { + set(property, new Integer(value)); + } + + public void setLong(Property property, long value) { + set(property, new Long(value)); + } + + public void setShort(Property property, short value) { + set(property, new Short(value)); + } + + public void setBytes(Property property, byte[] value) { + set(property, value); + } + + public void setBigDecimal(Property property, BigDecimal value) { + set(property, value); + } + + public void setBigInteger(Property property, BigInteger value) { + set(property, value); + } + + public void setDataObject(Property property, DataObject value) { + set(property, value); + } + + public void setDate(Property property, Date value) { + set(property, value); + } + + public void setString(Property property, String value) { + set(property, value); + } + + public void setList(Property property, List value) { + set(property, value); + } + + public DataObject createDataObject(String propertyName) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(String propertyName, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property, Type type) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void delete() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataGraph getDataGraph() { + return DataObjectUtil.getDataGraph(this); + } + + public Sequence getSequence() { + EAttribute mixedFeature = BasicExtendedMetaData.INSTANCE.getMixedFeature(eClass()); + return mixedFeature != null ? (Sequence)eGet(mixedFeature, true, false) : null; + } + + public List getInstanceProperties() { + return DataObjectUtil.getInstanceProperties(this); + } + + public DataObject getRootObject() { + return DataObjectUtil.getRootObject(this); + } + + public ChangeSummary getChangeSummary() { + // TODO: implement this method + throw new UnsupportedOperationException(); + } + + public void detach() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + //DataObjectUtil.detach(this); + } + + public Property getProperty(String propertyName) { + return DataObjectUtil.getProperty(this, propertyName); + } + */ + +} //AttributeImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummaryImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummaryImpl.java new file mode 100644 index 0000000000..d3c6a0b96e --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummaryImpl.java @@ -0,0 +1,682 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.util.BasicSequence; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.UniqueEList; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.change.ChangeDescription; +import org.eclipse.emf.ecore.change.FeatureChange; +import org.eclipse.emf.ecore.change.impl.ChangeDescriptionImpl; +import org.eclipse.emf.ecore.change.util.ChangeRecorder; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.util.BasicExtendedMetaData; +import org.eclipse.emf.ecore.util.DelegatingFeatureMap; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.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; + + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>EChange Summary</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.sdo.impl.ChangeSummaryImpl#getEDataGraph <em>EData Graph</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class ChangeSummaryImpl extends ChangeDescriptionImpl implements ChangeSummary +{ + /** + * The cached value of the '{@link #getEDataGraph() <em>EData Graph</em>}' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getEDataGraph() + * @generated + * @ordered + */ + protected DataGraph eDataGraph = null; + + protected ChangeRecorder changeRecorder = null; + protected EList cachedObjectsToDetach = null; + protected HashMap cachedSDOObjectChanges = new HashMap(); + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected ChangeSummaryImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getChangeSummary(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isLogging() + { + return changeRecorder != null; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public DataGraph getEDataGraph() + { + return eDataGraph; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain basicSetEDataGraph(DataGraph newEDataGraph, NotificationChain msgs) + { + DataGraph oldEDataGraph = eDataGraph; + eDataGraph = newEDataGraph; + if (eNotificationRequired()) + { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH, oldEDataGraph, newEDataGraph); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setEDataGraph(DataGraph newEDataGraph) + { + if (newEDataGraph != eDataGraph) + { + NotificationChain msgs = null; + if (eDataGraph != null) + msgs = ((InternalEObject)eDataGraph).eInverseRemove(this, SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY, DataGraph.class, msgs); + if (newEDataGraph != null) + msgs = ((InternalEObject)newEDataGraph).eInverseAdd(this, SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY, DataGraph.class, msgs); + msgs = basicSetEDataGraph(newEDataGraph, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH, newEDataGraph, newEDataGraph)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void beginLogging() + { + if (isLogging()) + { + throw new IllegalStateException("Already logging"); + } + + getObjectsToAttach().clear(); + getObjectChanges().clear(); + getResourceChanges().clear(); + + oldContainmentInformation = null; + changeRecorder = new SDOChangeRecorder(); + changeRecorder.beginRecording(Collections.singleton(((DataGraphImpl)getEDataGraph()).getRootResource())); +// if (eNotificationRequired()) +// eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.ECHANGE_SUMMARY__LOGGING, false, true)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) + { + if (featureID >= 0) + { + switch (eDerivedStructuralFeatureID(featureID, baseClass)) + { + case SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH: + if (eDataGraph != null) + msgs = ((InternalEObject)eDataGraph).eInverseRemove(this, SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY, DataGraph.class, msgs); + return basicSetEDataGraph((DataGraph)otherEnd, msgs); + default: + return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs); + } + } + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + return eBasicSetContainer(otherEnd, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) + { + if (featureID >= 0) + { + switch (eDerivedStructuralFeatureID(featureID, baseClass)) + { + case SDOPackage.CHANGE_SUMMARY__OBJECT_CHANGES: + return ((InternalEList)getObjectChanges()).basicRemove(otherEnd, msgs); + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_ATTACH: + return ((InternalEList)getObjectsToAttach()).basicRemove(otherEnd, msgs); + case SDOPackage.CHANGE_SUMMARY__RESOURCE_CHANGES: + return ((InternalEList)getResourceChanges()).basicRemove(otherEnd, msgs); + case SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH: + return basicSetEDataGraph(null, msgs); + default: + return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs); + } + } + return eBasicSetContainer(null, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case SDOPackage.CHANGE_SUMMARY__OBJECT_CHANGES: + if (coreType) return getObjectChanges(); + else return getObjectChanges().map(); + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_DETACH: + return getObjectsToDetach(); + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_ATTACH: + return getObjectsToAttach(); + case SDOPackage.CHANGE_SUMMARY__RESOURCE_CHANGES: + return getResourceChanges(); + case SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH: + return getEDataGraph(); + } + return eDynamicGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case SDOPackage.CHANGE_SUMMARY__OBJECT_CHANGES: + ((EStructuralFeature.Setting)getObjectChanges()).set(newValue); + return; + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_DETACH: + getObjectsToDetach().clear(); + getObjectsToDetach().addAll((Collection)newValue); + return; + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_ATTACH: + getObjectsToAttach().clear(); + getObjectsToAttach().addAll((Collection)newValue); + return; + case SDOPackage.CHANGE_SUMMARY__RESOURCE_CHANGES: + getResourceChanges().clear(); + getResourceChanges().addAll((Collection)newValue); + return; + case SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH: + setEDataGraph((DataGraph)newValue); + return; + } + eDynamicSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case SDOPackage.CHANGE_SUMMARY__OBJECT_CHANGES: + getObjectChanges().clear(); + return; + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_DETACH: + getObjectsToDetach().clear(); + return; + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_ATTACH: + getObjectsToAttach().clear(); + return; + case SDOPackage.CHANGE_SUMMARY__RESOURCE_CHANGES: + getResourceChanges().clear(); + return; + case SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH: + setEDataGraph((DataGraph)null); + return; + } + eDynamicUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case SDOPackage.CHANGE_SUMMARY__OBJECT_CHANGES: + return objectChanges != null && !objectChanges.isEmpty(); + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_DETACH: + return objectsToDetach != null && !objectsToDetach.isEmpty(); + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_ATTACH: + return objectsToAttach != null && !objectsToAttach.isEmpty(); + case SDOPackage.CHANGE_SUMMARY__RESOURCE_CHANGES: + return resourceChanges != null && !resourceChanges.isEmpty(); + case SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH: + return eDataGraph != null; + } + return eDynamicIsSet(featureID); + } + + protected 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); + } + + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void endLogging() + { + if (!isLogging()) + { + throw new IllegalStateException("Not currently logging"); + } + + changeRecorder.endRecording(); + changeRecorder.dispose(); + changeRecorder = null; +// if (eNotificationRequired()) +// eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.ECHANGE_SUMMARY__LOGGING, true, false)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isCreated(DataObject dataObject) + { + return getObjectsToDetach().contains(dataObject); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isDeleted(DataObject dataObject) + { + return getDeletedObjects().contains(dataObject); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @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; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isModified(DataObject dataObject) + { + return getObjectChanges().containsKey(dataObject) && !isDeleted(dataObject) && !isCreated(dataObject); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void summarize() + { + if (!isLogging()) + { + throw new IllegalStateException("Not currently logging"); + } + + changeRecorder.summarize(); + } + + public Setting getOldValue(DataObject dataObject, Property property) + { + for (Iterator i = getOldValues(dataObject).iterator(); i.hasNext(); ) + { + Setting setting = (Setting)i.next(); + if (setting.getProperty() == property) + { + return setting; + } + } + + return null; + } + + public DataObject getOldContainer(DataObject dataObject) + { + return (DataObject)getOldContainer((EObject)dataObject); + } + + public Property getOldContainmentProperty(DataObject dataObject) + { + return (Property)getOldContainmentFeature((EObject)dataObject); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Sequence getOldSequence(DataObject dataObject) + { + EAttribute mixedFeature = BasicExtendedMetaData.INSTANCE.getMixedFeature((EClass)dataObject.getType()); + if (mixedFeature != null) + { + return (Sequence)getOldValue(dataObject, (Property)mixedFeature).getValue(); + } + return null; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void undoChanges() + { + if (isLogging()) + { + changeRecorder.summarize(); + } + apply(); + } + + public EList getObjectsToDetach() + { + if (cachedObjectsToDetach == null) + { + cachedObjectsToDetach = super.getObjectsToDetach(); + } + return cachedObjectsToDetach; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataGraph getDataGraph() + { + return getEDataGraph(); + } + + 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; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getChangedDataObjects() + { + 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; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject getRootObject() + { + DataGraph dataGraph = getDataGraph(); + if (dataGraph != null) + { + return dataGraph.getRootObject(); + } + // TODO: handle ChangeSummary-type property + return null; + } + +} //EChangeSummaryImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummarySettingImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummarySettingImpl.java new file mode 100644 index 0000000000..d1cd1d3e05 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummarySettingImpl.java @@ -0,0 +1,113 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + + +import java.util.Map; + +import org.apache.tuscany.sdo.SDOPackage; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.change.impl.FeatureChangeImpl; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.Property; +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>EChange Summary Setting</b></em>'. + * <!-- end-user-doc --> + * <p> + * </p> + * + * @generated + */ +public class ChangeSummarySettingImpl extends FeatureChangeImpl implements ChangeSummary.Setting +{ + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected ChangeSummarySettingImpl() + { + super(); + } + + protected ChangeSummarySettingImpl(EStructuralFeature feature, Object value, boolean isSet) + { + super(feature, value, isSet); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getChangeSummarySetting(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Object getValue() + { + EStructuralFeature feature = getFeature(); + if (feature.isMany()) + { + if (value == null) + { + EObject eObject = (EObject)((Map.Entry)eContainer()).getKey(); + value = getListValue((EList)eObject.eGet(feature)); + } + return value; + } + else + { + return super.getValue(); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Property getProperty() + { + return (Property)getFeature(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isSet() + { + return super.isSet(); + } + +} //EChangeSummarySettingImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ClassImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ClassImpl.java new file mode 100644 index 0000000000..581af61285 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ClassImpl.java @@ -0,0 +1,772 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + +import java.util.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.Sequence; +import commonj.sdo.Type; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Class</b></em>'. + * <!-- end-user-doc --> + * <p> + * </p> + * + * @generated + */ +public class ClassImpl extends EClassImpl implements Type, org.apache.tuscany.sdo.model.Type/*, DataObject*/ +{ + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected ClassImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + protected EClass eStaticClass() + { + return EcorePackage.eINSTANCE.getEClass(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String getURI() + { + return getEPackage().getNsURI(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isDataType() + { + return false; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isOpen() + { + for (int i = 0, count = getFeatureCount(); i < count; ++i) + { + EStructuralFeature eStructuralFeature = getEStructuralFeature(i); + switch (ExtendedMetaData.INSTANCE.getFeatureKind(eStructuralFeature)) + { + case ExtendedMetaData.ELEMENT_WILDCARD_FEATURE: + if (eStructuralFeature == ExtendedMetaData.INSTANCE.getMixedFeature(this)) break; + case ExtendedMetaData.ATTRIBUTE_WILDCARD_FEATURE: + case ExtendedMetaData.GROUP_FEATURE: + return true; + } + } + return false; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isSequenced() + { + // isSequenced == isMixed + return ExtendedMetaData.INSTANCE.getMixedFeature(this) != null; + } + + protected List aliasNames = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getAliasNames() + { + if (aliasNames == null) + { + aliasNames = DataObjectUtil.getAliasNames(this); + } + return aliasNames; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getDeclaredProperties() + { + return getEStructuralFeatures(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getProperties() + { + return getEAllStructuralFeatures(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getBaseTypes() + { + return getESuperTypes(); + } + + private void initAliasNames() { + Map result = new HashMap(); + for (Iterator i = getProperties().iterator(); i.hasNext();) + { + Property property = (Property)i.next(); + result.put(property.getName(), property); + + List aliasNames = property.getAliasNames(); + for (int count = aliasNames.size(); count > 0;) + { + result.put(aliasNames.get(--count), property); + } + } + propertyNameToPropertyMap = result; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Property getProperty(String propertyName) + { + if (propertyNameToPropertyMap == null) initAliasNames(); + Property property = (Property)propertyNameToPropertyMap.get(propertyName); + if (property == null && !isOpen()) { + initAliasNames(); + property = (Property)propertyNameToPropertyMap.get(propertyName); + } + return property; + } + + protected Map propertyNameToPropertyMap; + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // org.apache.tuscany.sdo.model.Type method implementations + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + + public List getBaseType() { + return this.getBaseTypes(); + } + + public List getProperty() { + return this.getProperties(); + } + + public List getAliasName() { + return this.getAliasNames(); + } + + public void unsetAbstract() { + eUnset(EcorePackage.eINSTANCE.getEClass_Abstract()); + } + + public boolean isSetAbstract() { + return eIsSet(EcorePackage.eINSTANCE.getEClass_Abstract()); + } + + public Sequence getAny() { + throw new UnsupportedOperationException(); + } + + public Sequence getAnyAttribute() { + throw new UnsupportedOperationException(); + } + + public void setDataType(boolean value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void unsetDataType() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetDataType() { + return false; + } + + public void setOpen(boolean value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void unsetOpen() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetOpen() { + return isOpen(); + } + + public void setSequenced(boolean value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void unsetSequenced() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetSequenced() { + return isSequenced(); + } + + public void setUri(String value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public String getUri() { + return getURI(); + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // DataObject method implementations + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + /* + public Object get(int propertyIndex) { + return DataObjectUtil.get(this, propertyIndex); + } + + public void set(int propertyIndex, Object value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSet(int propertyIndex) { + return DataObjectUtil.isSet(this, propertyIndex); + } + + public void unset(int propertyIndex) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public Object get(Property property) { + return DataObjectUtil.get(this, ((EStructuralFeature)property).getFeatureID()); + } + + public void set(Property property, Object value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSet(Property property) { + return DataObjectUtil.isSet(this, ((EStructuralFeature)property).getFeatureID()); + } + + public void unset(Property property) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject getContainer() { + return (DataObject)eContainer(); + } + + public Property getContainmentProperty() { + return (Property)eContainmentFeature(); + } + + public Type getType() { + return (Type)ModelPackageImpl.eINSTANCE.getType(); + } + + // Remaining DataObject methods are (will be) implemented as straight delegation to DataObjectUtil + + public Object get(String path) { + return DataObjectUtil.get(this, path); + } + + public void set(String path, Object value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSet(String path) { + return DataObjectUtil.isSet(this, path); + } + + public void unset(String path) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean getBoolean(String path) { + return DataObjectUtil.getBoolean(get(path)); + } + + public byte getByte(String path) { + return DataObjectUtil.getByte(get(path)); + } + + public char getChar(String path) { + return DataObjectUtil.getChar(get(path)); + } + + public double getDouble(String path) { + return DataObjectUtil.getDouble(get(path)); + } + + public float getFloat(String path) { + return DataObjectUtil.getFloat(get(path)); + } + + public int getInt(String path) { + return DataObjectUtil.getInt(get(path)); + } + + public long getLong(String path) { + return DataObjectUtil.getLong(get(path)); + } + + public short getShort(String path) { + return DataObjectUtil.getShort(get(path)); + } + + public byte[] getBytes(String path) { + return DataObjectUtil.getBytes(get(path)); + } + + public BigDecimal getBigDecimal(String path) { + return DataObjectUtil.getBigDecimal(get(path)); + } + + public BigInteger getBigInteger(String path) { + return DataObjectUtil.getBigInteger(get(path)); + } + + public DataObject getDataObject(String path) { + return (DataObject)get(path); + } + + public Date getDate(String path) { + return DataObjectUtil.getDate(get(path)); + } + + public String getString(String path) { + return DataObjectUtil.getString(get(path)); + } + + public List getList(String path) { + return (List)get(path); + } + + public Sequence getSequence(String path) { + return (Sequence)get(path); + } + + public void setBoolean(String path, boolean value) { + set(path, new Boolean(value)); + } + + public void setByte(String path, byte value) { + set(path, new Byte(value)); + } + + public void setChar(String path, char value) { + set(path, new Character(value)); + } + + public void setDouble(String path, double value) { + set(path, new Double(value)); + } + + public void setFloat(String path, float value) { + set(path, new Float(value)); + } + + public void setInt(String path, int value) { + set(path, new Integer(value)); + } + + public void setLong(String path, long value) { + set(path, new Long(value)); + } + + public void setShort(String path, short value) { + set(path, new Short(value)); + } + + public void setBytes(String path, byte[] value) { + set(path, value); + } + + public void setBigDecimal(String path, BigDecimal value) { + set(path, value); + } + + public void setBigInteger(String path, BigInteger value) { + set(path, value); + } + + public void setDataObject(String path, DataObject value) { + set(path, value); + } + + public void setDate(String path, Date value) { + set(path, value); + } + + public void setString(String path, String value) { + set(path, value); + } + + public void setList(String path, List value) { + set(path, value); + } + + public boolean getBoolean(int propertyIndex) { + return DataObjectUtil.getBoolean(this, propertyIndex); + } + + public byte getByte(int propertyIndex) { + return DataObjectUtil.getByte(this, propertyIndex); + } + + public char getChar(int propertyIndex) { + return DataObjectUtil.getChar(this, propertyIndex); + } + + public double getDouble(int propertyIndex) { + return DataObjectUtil.getDouble(this, propertyIndex); + } + + public float getFloat(int propertyIndex) { + return DataObjectUtil.getFloat(this, propertyIndex); + } + + public int getInt(int propertyIndex) { + return DataObjectUtil.getInt(this, propertyIndex); + } + + public long getLong(int propertyIndex) { + return DataObjectUtil.getLong(this, propertyIndex); + } + + public short getShort(int propertyIndex) { + return DataObjectUtil.getShort(this, propertyIndex); + } + + public byte[] getBytes(int propertyIndex) { + return DataObjectUtil.getBytes(this, propertyIndex); + } + + public BigDecimal getBigDecimal(int propertyIndex) { + return DataObjectUtil.getBigDecimal(this, propertyIndex); + } + + public BigInteger getBigInteger(int propertyIndex) { + return DataObjectUtil.getBigInteger(this, propertyIndex); + } + + public DataObject getDataObject(int propertyIndex) { + return DataObjectUtil.getDataObject(this, propertyIndex); + } + + public Date getDate(int propertyIndex) { + return DataObjectUtil.getDate(this, propertyIndex); + } + + public String getString(int propertyIndex) { + return DataObjectUtil.getString(this, propertyIndex); + } + + public List getList(int propertyIndex) { + return DataObjectUtil.getList(this, propertyIndex); + } + + public Sequence getSequence(int propertyIndex) { + return DataObjectUtil.getSequence(this, propertyIndex); + } + + public void setBoolean(int propertyIndex, boolean value) { + set(propertyIndex, new Boolean(value)); + } + + public void setByte(int propertyIndex, byte value) { + set(propertyIndex, new Byte(value)); + } + + public void setChar(int propertyIndex, char value) { + set(propertyIndex, new Character(value)); + } + + public void setDouble(int propertyIndex, double value) { + set(propertyIndex, new Double(value)); + } + + public void setFloat(int propertyIndex, float value) { + set(propertyIndex, new Float(value)); + } + + public void setInt(int propertyIndex, int value) { + set(propertyIndex, new Integer(value)); + } + + public void setLong(int propertyIndex, long value) { + set(propertyIndex, new Long(value)); + } + + public void setShort(int propertyIndex, short value) { + set(propertyIndex, new Short(value)); + } + + public void setBytes(int propertyIndex, byte[] value) { + set(propertyIndex, value); + } + + public void setBigDecimal(int propertyIndex, BigDecimal value) { + set(propertyIndex, value); + } + + public void setBigInteger(int propertyIndex, BigInteger value) { + set(propertyIndex, value); + } + + public void setDataObject(int propertyIndex, DataObject value) { + set(propertyIndex, value); + } + + public void setDate(int propertyIndex, Date value) { + set(propertyIndex, value); + } + + public void setString(int propertyIndex, String value) { + set(propertyIndex, value); + } + + public void setList(int propertyIndex, List value) { + set(propertyIndex, value); + } + + public boolean getBoolean(Property property) { + return DataObjectUtil.getBoolean(this, property); + } + + public byte getByte(Property property) { + return DataObjectUtil.getByte(this, property); + } + + public char getChar(Property property) { + return DataObjectUtil.getChar(this, property); + } + + public double getDouble(Property property) { + return DataObjectUtil.getDouble(this, property); + } + + public float getFloat(Property property) { + return DataObjectUtil.getFloat(this, property); + } + + public int getInt(Property property) { + return DataObjectUtil.getInt(this, property); + } + + public long getLong(Property property) { + return DataObjectUtil.getLong(this, property); + } + + public short getShort(Property property) { + return DataObjectUtil.getShort(this, property); + } + + public byte[] getBytes(Property property) { + return DataObjectUtil.getBytes(this, property); + } + + public BigDecimal getBigDecimal(Property property) { + return DataObjectUtil.getBigDecimal(this, property); + } + + public BigInteger getBigInteger(Property property) { + return DataObjectUtil.getBigInteger(this, property); + } + + public DataObject getDataObject(Property property) { + return DataObjectUtil.getDataObject(this, property); + } + + public Date getDate(Property property) { + return DataObjectUtil.getDate(this, property); + } + + public String getString(Property property) { + return DataObjectUtil.getString(this, property); + } + + public List getList(Property property) { + return DataObjectUtil.getList(this, property); + } + + public Sequence getSequence(Property property) { + return DataObjectUtil.getSequence(this, property); + } + + public void setBoolean(Property property, boolean value) { + set(property, new Boolean(value)); + } + + public void setByte(Property property, byte value) { + set(property, new Byte(value)); + } + + public void setChar(Property property, char value) { + set(property, new Character(value)); + } + + public void setDouble(Property property, double value) { + set(property, new Double(value)); + } + + public void setFloat(Property property, float value) { + set(property, new Float(value)); + } + + public void setInt(Property property, int value) { + set(property, new Integer(value)); + } + + public void setLong(Property property, long value) { + set(property, new Long(value)); + } + + public void setShort(Property property, short value) { + set(property, new Short(value)); + } + + public void setBytes(Property property, byte[] value) { + set(property, value); + } + + public void setBigDecimal(Property property, BigDecimal value) { + set(property, value); + } + + public void setBigInteger(Property property, BigInteger value) { + set(property, value); + } + + public void setDataObject(Property property, DataObject value) { + set(property, value); + } + + public void setDate(Property property, Date value) { + set(property, value); + } + + public void setString(Property property, String value) { + set(property, value); + } + + public void setList(Property property, List value) { + set(property, value); + } + + public DataObject createDataObject(String propertyName) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(String propertyName, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property, Type type) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void delete() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataGraph getDataGraph() { + return DataObjectUtil.getDataGraph(this); + } + + public Sequence getSequence() { + EAttribute mixedFeature = BasicExtendedMetaData.INSTANCE.getMixedFeature(eClass()); + return mixedFeature != null ? (Sequence)eGet(mixedFeature, true, false) : null; + } + + public List getInstanceProperties() { + return DataObjectUtil.getInstanceProperties(this); + } + + public DataObject getRootObject() { + return DataObjectUtil.getRootObject(this); + } + + public ChangeSummary getChangeSummary() { + // TODO: implement this method + throw new UnsupportedOperationException(); + } + + public void detach() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + //DataObjectUtil.detach(this); + } + */ + +} //ClassTypeImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataGraphImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataGraphImpl.java new file mode 100644 index 0000000000..704ec8c3bc --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataGraphImpl.java @@ -0,0 +1,823 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; + +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.util.URI; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.EObjectImpl; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.util.BasicExtendedMetaData; +import org.eclipse.emf.ecore.util.ExtendedMetaData; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.TypeHelper; + + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>EData Graph</b></em>'. + * @extends DataGraph, Adapter, Serializable + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.sdo.impl.DataGraphImpl#getResourceSet <em>Resource Set</em>}</li> + * <li>{@link org.apache.tuscany.sdo.impl.DataGraphImpl#getRootResource <em>Root Resource</em>}</li> + * <li>{@link org.apache.tuscany.sdo.impl.DataGraphImpl#getEChangeSummary <em>EChange Summary</em>}</li> + * <li>{@link org.apache.tuscany.sdo.impl.DataGraphImpl#getERootObject <em>ERoot Object</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class DataGraphImpl extends EObjectImpl implements DataGraph, Adapter, Serializable +{ + /** + * The default value of the '{@link #getResourceSet() <em>Resource Set</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getResourceSet() + * @generated + * @ordered + */ + protected static final ResourceSet RESOURCE_SET_EDEFAULT = null; + + /** + * The cached value of the '{@link #getResourceSet() <em>Resource Set</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getResourceSet() + * @generated + * @ordered + */ + protected ResourceSet resourceSet = RESOURCE_SET_EDEFAULT; + + /** + * The default value of the '{@link #getRootResource() <em>Root Resource</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getRootResource() + * @generated + * @ordered + */ + protected static final Resource ROOT_RESOURCE_EDEFAULT = null; + + /** + * The cached value of the '{@link #getEChangeSummary() <em>EChange Summary</em>}' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getEChangeSummary() + * @generated + * @ordered + */ + protected ChangeSummary eChangeSummary = null; + + /** + * The cached value of the '{@link #getERootObject() <em>ERoot Object</em>}' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getERootObject() + * @generated + * @ordered + */ + protected EObject eRootObject = null; + + /** + * The cached extended metadata to wrap the resource set's package registry. + */ + protected ExtendedMetaData extendedMetaData; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected DataGraphImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getDataGraph(); + } + + public boolean isAdapterForType(Object type) + { + return type == DataGraph.class; + } + + public void notifyChanged(Notification msg) + { + } + + public Notifier getTarget() + { + return getResourceSet(); + } + + public void setTarget(Notifier newTarget) + { + } + + protected ExtendedMetaData getExtendedMetaData() + { + if (extendedMetaData == null) + { + getResourceSet(); + } + return extendedMetaData; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public ResourceSet getResourceSet() + { + if (resourceSet == null) + { + if (eResource() != null) + { + resourceSet = eResource().getResourceSet(); + } + if (resourceSet == null) + { + resourceSet = createResourceSet(); + } + initializeResourceSet(resourceSet); + } + return resourceSet; + } + + protected ResourceSet createResourceSet() + { + return DataObjectUtil.createResourceSet(); + } + + protected Resource createRootResource() + { + Resource result = resourceSet.createResource(URI.createURI("root.xml")); + result.getContents().clear(); + return result; + } + + protected Resource createChangeSummaryResource() + { + Resource result = resourceSet.createResource(URI.createURI("change-summary.xml")); + result.getContents().clear(); + return result; + } + + protected void initializeResourceSet(ResourceSet resourceSet) + { + if (resourceSet == null) + { + extendedMetaData = null; + } + else + { + extendedMetaData = new BasicExtendedMetaData(resourceSet.getPackageRegistry()); + resourceSet.eAdapters().add(this); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setResourceSetGen(ResourceSet newResourceSet) + { + ResourceSet oldResourceSet = resourceSet; + resourceSet = newResourceSet; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.DATA_GRAPH__RESOURCE_SET, oldResourceSet, resourceSet)); + } + + public void setResourceSet(ResourceSet newResourceSet) + { + if (resourceSet != null) + { + resourceSet.eAdapters().remove(this); + } + setResourceSetGen(newResourceSet); + initializeResourceSet(newResourceSet); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Resource getRootResource() + { + if (eRootObject == null) + { + Resource result = getResourceSet().getResource(URI.createURI("root.xml"), false); + if (result == null) + { + result = createRootResource(); + } + + return result; + } + else + { + return eRootObject.eResource(); + } + } + + public Resource getDataGraphResource() + { + Resource result = eResource(); + if (result == null) + { + result = getResourceSet().createResource(URI.createURI("all.datagraph")); + result.getContents().add(this); + } + return result; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ChangeSummary getEChangeSummary() + { + return eChangeSummary; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain basicSetEChangeSummary(ChangeSummary newEChangeSummary, NotificationChain msgs) + { + ChangeSummary oldEChangeSummary = eChangeSummary; + eChangeSummary = newEChangeSummary; + if (eNotificationRequired()) + { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY, oldEChangeSummary, newEChangeSummary); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setEChangeSummary(ChangeSummary newEChangeSummary) + { + if (newEChangeSummary != eChangeSummary) + { + NotificationChain msgs = null; + if (eChangeSummary != null) + msgs = ((InternalEObject)eChangeSummary).eInverseRemove(this, SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH, ChangeSummary.class, msgs); + if (newEChangeSummary != null) + msgs = ((InternalEObject)newEChangeSummary).eInverseAdd(this, SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH, ChangeSummary.class, msgs); + msgs = basicSetEChangeSummary(newEChangeSummary, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY, newEChangeSummary, newEChangeSummary)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EObject getERootObject() + { + return eRootObject; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setERootObjectGen(EObject newERootObject) + { + EObject oldERootObject = eRootObject; + eRootObject = newERootObject; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.DATA_GRAPH__EROOT_OBJECT, oldERootObject, eRootObject)); + } + + public void setERootObject(EObject newERootObject) + { + // If there is a resource set already... + // + if (resourceSet != null) + { + // Get the root resource and if there's a root object in it already, clear it. + // Then set the root object and add it to the root resource. + // + List contents = getRootResource().getContents(); + if (eRootObject != null) + { + contents.clear(); + } + setERootObjectGen(newERootObject); + if (newERootObject != null) + { + contents.add(newERootObject); + } + } + else + { + // Set the root object and see if it has a resource we can reuse. + // + setERootObjectGen(newERootObject); + Resource rootResource = newERootObject.eResource(); + if (rootResource != null) + { + // If there is no resource set + // + if (rootResource.getResourceSet() == null) + { + // Demand create one and add this resource to it. + // + getResourceSet().getResources().add(rootResource); + } + else + { + // Reuse the existing resource set. + // + setResourceSet(rootResource.getResourceSet()); + } + } + else + { + // Demand create the resource set and the root resource, and add to it's contents. + // + getResourceSet(); + createRootResource().getContents().add(newERootObject); + } + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public EClassifier getEClassifier(String namespaceURI, String typeName) + { + ExtendedMetaData extendedMetaData = getExtendedMetaData(); + EPackage ePackage = extendedMetaData.getPackage(namespaceURI); + if (ePackage != null) + { + EClassifier eClassifier = ePackage.getEClassifier(typeName); + if (eClassifier == null) + { + eClassifier = extendedMetaData.getType(ePackage, typeName); + } + return eClassifier; + } + else + { + return null; + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Type getType(String namespaceURI, String typeName) + { + return TypeHelper.INSTANCE.getType(namespaceURI, typeName); + //EClassifier eClassifier = getEClassifier(namespaceURI, typeName); + //return eClassifier == null ? null : SDOUtil.getType(eClassifier); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) + { + if (featureID >= 0) + { + switch (eDerivedStructuralFeatureID(featureID, baseClass)) + { + case SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY: + if (eChangeSummary != null) + msgs = ((InternalEObject)eChangeSummary).eInverseRemove(this, SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH, ChangeSummary.class, msgs); + return basicSetEChangeSummary((ChangeSummary)otherEnd, msgs); + default: + return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs); + } + } + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + return eBasicSetContainer(otherEnd, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) + { + if (featureID >= 0) + { + switch (eDerivedStructuralFeatureID(featureID, baseClass)) + { + case SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY: + return basicSetEChangeSummary(null, msgs); + default: + return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs); + } + } + return eBasicSetContainer(null, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case SDOPackage.DATA_GRAPH__RESOURCE_SET: + return getResourceSet(); + case SDOPackage.DATA_GRAPH__ROOT_RESOURCE: + return getRootResource(); + case SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY: + return getEChangeSummary(); + case SDOPackage.DATA_GRAPH__EROOT_OBJECT: + return getERootObject(); + } + return eDynamicGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case SDOPackage.DATA_GRAPH__RESOURCE_SET: + setResourceSet((ResourceSet)newValue); + return; + case SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY: + setEChangeSummary((ChangeSummary)newValue); + return; + case SDOPackage.DATA_GRAPH__EROOT_OBJECT: + setERootObject((EObject)newValue); + return; + } + eDynamicSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case SDOPackage.DATA_GRAPH__RESOURCE_SET: + setResourceSet(RESOURCE_SET_EDEFAULT); + return; + case SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY: + setEChangeSummary((ChangeSummary)null); + return; + case SDOPackage.DATA_GRAPH__EROOT_OBJECT: + setERootObject((EObject)null); + return; + } + eDynamicUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case SDOPackage.DATA_GRAPH__RESOURCE_SET: + return RESOURCE_SET_EDEFAULT == null ? resourceSet != null : !RESOURCE_SET_EDEFAULT.equals(resourceSet); + case SDOPackage.DATA_GRAPH__ROOT_RESOURCE: + return ROOT_RESOURCE_EDEFAULT == null ? getRootResource() != null : !ROOT_RESOURCE_EDEFAULT.equals(getRootResource()); + case SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY: + return eChangeSummary != null; + case SDOPackage.DATA_GRAPH__EROOT_OBJECT: + return eRootObject != null; + } + return eDynamicIsSet(featureID); + } + + public DataObject createEDataObject(Type type) + { + return DataObjectUtil.create(type); + } + + public DataObject getRootObject() + { + return (DataObject)getERootObject(); + } + + public DataObject createRootObject(String namespaceURI, String typeName) + { + 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); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (resourceSet: "); + result.append(resourceSet); + result.append(')'); + return result.toString(); + } + +} //EDataGraphImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectBase.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectBase.java new file mode 100644 index 0000000000..2392d07961 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectBase.java @@ -0,0 +1,313 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + + +import java.util.List; + +import org.apache.tuscany.sdo.util.BasicSequence; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.util.BasicFeatureMap; +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.ecore.util.InternalEList; + + +import commonj.sdo.Sequence; +import commonj.sdo.Type; + + +/** + * Base implementation of the SDO DataObject interface. Used as base class for prototype of EMF-less generated subclasses + */ +public abstract class DataObjectBase extends DataObjectImpl +{ + + protected int OPPOSITE_FEATURE_BASE = EOPPOSITE_FEATURE_BASE; + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Following methods should be proposed SPI for generated subclasses to use + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + protected boolean isNotifying() + { + return changeRecorder != null; + } + + protected interface ChangeKind + { + int SET = Notification.SET; + int UNSET = Notification.UNSET; + int RESOLVE = Notification.RESOLVE; + } + + protected void notify(int changeKind, int property, Object oldValue, Object newValue) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldValue, newValue)); + } + + protected void notify(int changeKind, int property, Object oldValue, Object newValue, boolean isSetChange) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldValue, newValue, isSetChange)); + } + + protected void notify(int changeKind, int property, double oldDoubleValue, double newDoubleValue, boolean isSetChange) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldDoubleValue, newDoubleValue, isSetChange)); + } + + protected void notify(int changeKind, int property, boolean oldBooleanValue, boolean newBooleanValue, boolean isSetChange) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldBooleanValue, newBooleanValue, isSetChange)); + } + + protected interface ListKind + { + int CONTAINMENT = 0; + } + + protected List createPropertyList(int listKind, Class dataClass, int property) + { + switch (listKind) + { + case ListKind.CONTAINMENT: + return new EObjectContainmentEList(dataClass, this, property); + } + return null; + } + + protected BasicSequence createSequence(int property) { + return new BasicSequence(new BasicFeatureMap(this, property)); + } + + protected Sequence createSequence(Sequence sequence, Type type, int propertyIndex) { + return new BasicSequence((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)sequence).featureMap().list(((EClass)type).getEStructuralFeature(propertyIndex))); + } + + /* + * get the value of the type's property at propertyIndex via the sequence + * @param seq + * @param type + * @param propertyIndex + * @return + */ + protected Object get(Sequence seq, Type type, int propertyIndex) { + return ((FeatureMap.Internal.Wrapper)seq).featureMap().get(((EClass)type).getEStructuralFeature(propertyIndex), true); + } + + protected List getList(Sequence seq, Type type, int propertyIndex) { + return ((FeatureMap.Internal.Wrapper)seq).featureMap().list(((EClass)type).getEStructuralFeature(propertyIndex)); + } + + protected void set(Sequence seq, Type type, int propertyIndex, Object newValue) { + ((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)seq).featureMap()).set(((EClass)type).getEStructuralFeature(propertyIndex), newValue); + } + + protected void unset(Sequence seq, Type type, int propertyIndex) { + ((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)seq).featureMap()).clear(((EClass)type).getEStructuralFeature(propertyIndex)); + + } + protected boolean isSet(Sequence seq, Type type, int propertyIndex) { + return !((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)seq).featureMap()).isEmpty(((EClass)type).getEStructuralFeature(propertyIndex)); + } + + protected boolean isSequenceEmpty(Sequence sequence) { + return ((FeatureMap.Internal.Wrapper)sequence).featureMap().isEmpty(); + } + + protected void setSequence(Sequence seq, Object newValue) { + ((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)seq).featureMap()).set(newValue); + } + + protected void unsetSequence(Sequence seq) { + ((FeatureMap.Internal.Wrapper)seq).featureMap().clear(); + } + + protected ChangeContext basicAdd(Sequence seq, Type type, int propertyIndex, Object newValue, ChangeContext changeContext) { + ChangeContextImpl changeContextImpl = (ChangeContextImpl)changeContext; + changeContextImpl.notificationChain = ((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)seq).featureMap()).basicAdd(((EClass)type).getEStructuralFeature(propertyIndex), newValue, changeContextImpl.notificationChain); + return changeContextImpl; + } + + protected Object get(int featureID, boolean resolve) + { + return null; + } + + private ChangeContextImpl initializeChangeContext(ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl; + if (changeContext == null) + { + changeContextImpl = new ChangeContextImpl(null); + } else + { + changeContextImpl = (ChangeContextImpl)changeContext; + } + return changeContextImpl; + } + + protected interface ChangeContext {} + + protected ChangeContext inverseRemove(Object otherEnd, int propertyIndex, ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + changeContextImpl.notificationChain = super.eInverseRemove((InternalEObject)otherEnd, propertyIndex, changeContextImpl.notificationChain); + return changeContextImpl; + } + + protected ChangeContext inverseAdd(Object otherEnd, int propertyIndex, ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + changeContextImpl = (ChangeContextImpl)changeContext; + changeContextImpl.notificationChain = super.eInverseAdd((InternalEObject)otherEnd, propertyIndex, changeContextImpl.notificationChain); + return changeContextImpl; + } + + protected ChangeContext inverseRemove(Object thisEnd, Object otherEnd, int propertyIndex, Class baseClass, ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + changeContextImpl = (ChangeContextImpl)changeContext; + changeContextImpl.notificationChain = ((InternalEObject)thisEnd).eInverseRemove((InternalEObject)otherEnd, propertyIndex, baseClass, changeContextImpl.notificationChain); + return changeContextImpl; + } + + protected ChangeContext inverseAdd(Object thisEnd, Object otherEnd, int propertyIndex, Class baseClass, ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + changeContextImpl.notificationChain = ((InternalEObject)thisEnd).eInverseAdd((InternalEObject)otherEnd, propertyIndex, baseClass, changeContextImpl.notificationChain); + return changeContextImpl; + } + + protected ChangeContext addNotification(Object notifier, int eventType, int featureID, Object oldValue, Object newValue, ChangeContext changeContext) + { + ENotificationImpl notification = new ENotificationImpl((InternalEObject)notifier, eventType, featureID, oldValue, newValue); + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + if (changeContextImpl.notificationChain == null) changeContextImpl.notificationChain = notification; else changeContextImpl.notificationChain.add(notification); + return changeContextImpl; + } + + protected ChangeContext removeFromList(List propertyList, Object objectToRemove, ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + changeContextImpl.notificationChain = ((InternalEList)propertyList).basicRemove(objectToRemove, changeContextImpl.notificationChain); + return changeContextImpl; + } + + protected ChangeContext removeFromSequence(Sequence sequence, Object otherEnd, ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + changeContextImpl.notificationChain = ((InternalEList)((FeatureMap.Internal.Wrapper)sequence).featureMap()).basicRemove(otherEnd, changeContextImpl.notificationChain); + return changeContextImpl; + } + + protected void dispatch(ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + if (changeContextImpl.notificationChain != null) + { + changeContextImpl.notificationChain.dispatch(); + } + } + + protected boolean isProxy() + { + return eIsProxy(); + } + + protected Object resolveProxy(Object proxy) + { + return EcoreUtil.resolve((EObject)proxy, this); + } + + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Following methods override EMF methods to work with pure SDO generated subclasses + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + public EClass eStaticClass() + { + return (EClass)getType(); + } + + public Type getType() // must be overridem in subclasses + { + throw new UnsupportedOperationException(); + } + + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + Object result = get(featureID, resolve); + if (coreType) + { + if (result instanceof FeatureMap.Internal.Wrapper) result = ((FeatureMap.Internal.Wrapper)result).featureMap(); + } + return result; + } + + public void eSet(int featureID, Object newValue) + { + set(featureID, newValue); + } + + public void eUnset(int featureID) + { + unset(featureID); + } + + public boolean eIsSet(int featureID) + { + return isSet(featureID); + } + + private class ChangeContextImpl implements ChangeContext + { + protected NotificationChain notificationChain; + public ChangeContextImpl(NotificationChain notificationChain) { + this.notificationChain = notificationChain; + } + } + + public NotificationChain eInverseRemove(InternalEObject otherEnd, int propertyIndex, NotificationChain msgs) + { + return ((ChangeContextImpl)inverseRemove(otherEnd, propertyIndex, new ChangeContextImpl(msgs))).notificationChain; + } + + public String toString() + { + StringBuffer result = new StringBuffer(getClass().getName()); + result.append('@'); + result.append(Integer.toHexString(hashCode())); + if (eIsProxy()) + { + result.append(" (proxyURI: "); + result.append(eProxyURI()); + result.append(')'); + } + return result.toString(); + } + +} //DataObjectBase + diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectImpl.java new file mode 100644 index 0000000000..7c8dffe02e --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectImpl.java @@ -0,0 +1,1511 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + + +import java.io.ObjectStreamException; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Date; +import java.util.List; + +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.impl.ChangeSummaryImpl.SDOChangeRecorder; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.EStructuralFeature.Internal.DynamicValueHolder; +import org.eclipse.emf.ecore.impl.BasicEObjectImpl; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.util.BasicExtendedMetaData; +import org.eclipse.emf.ecore.util.EContentsEList; +import org.eclipse.emf.ecore.util.ECrossReferenceEList; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Sequence; +import commonj.sdo.Type; +import commonj.sdo.impl.ExternalizableDelegator; + + +/** + * <!-- begin-user-doc --> + * Base implementation of the SDO DataObject interface. This implementation allocates the minimum storage + * overhead needed for SDO. It provides a complete implementation of the API, but does not, however, allocate + * any storage for the actual properties of the data object. It instead requires subclasses for this purpose. + * The subclass, DynamicDataObjectImpl serves as a concrete implementation class for dynamic data objects. + * Static data object storage is provided by generated classes, which also directly or indirectly derive from + * this class. + * <!-- end-user-doc --> + * <p> + * </p> + * + * @generated + */ +public abstract class DataObjectImpl extends BasicEObjectImpl implements DataObject +{ + protected InternalEObject eContainer; + protected int eContainerFeatureID; + protected SDOChangeRecorder changeRecorder; + protected Object location; // Resource.Internal (if object is directly contained in a resource) or URI (if it is a proxy) + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected DataObjectImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Object get(int propertyIndex) + { + return eGet(propertyIndex, true, false); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void set(int propertyIndex, Object value) + { + eSet(propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isSet(int propertyIndex) + { + return eIsSet(propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void unset(int propertyIndex) + { + eUnset(propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Object get(Property property) + { + return eGet((EStructuralFeature)property, true, false); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void set(Property property, Object value) + { + eSet((EStructuralFeature)property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isSet(Property property) + { + return eIsSet((EStructuralFeature)property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void unset(Property property) + { + eUnset((EStructuralFeature)property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject getContainer() + { + return (DataObject)eContainer(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Property getContainmentProperty() + { + return (Property)eContainmentFeature(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Type getType() + { + return (Type)eClass(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Object writeReplace() throws ObjectStreamException + { + return new ExternalizableDelegator(this); + } + + + // Remaining DataObject methods are (will be) implemented as straight delegation to DataObjectUtil + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Object get(String path) + { + return DataObjectUtil.get(this, path); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void set(String path, Object value) + { + DataObjectUtil.set(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isSet(String path) + { + return DataObjectUtil.isSet(this, path); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void unset(String path) + { + DataObjectUtil.unset(this, path); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataGraph getDataGraph() + { + return DataObjectUtil.getDataGraph(this); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public BigDecimal getBigDecimal(String path) + { + return DataObjectUtil.getBigDecimal(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public BigInteger getBigInteger(String path) + { + return DataObjectUtil.getBigInteger(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean getBoolean(String path) + { + return DataObjectUtil.getBoolean(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public byte getByte(String path) + { + return DataObjectUtil.getByte(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public byte[] getBytes(String path) + { + return DataObjectUtil.getBytes(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public char getChar(String path) + { + return DataObjectUtil.getChar(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject getDataObject(String path) + { + return (DataObject)get(path); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Date getDate(String path) + { + return DataObjectUtil.getDate(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public double getDouble(String path) + { + return DataObjectUtil.getDouble(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public float getFloat(String path) + { + return DataObjectUtil.getFloat(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public int getInt(String path) + { + return DataObjectUtil.getInt(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getList(String path) + { + return (List)get(path); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public long getLong(String path) + { + return DataObjectUtil.getLong(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Sequence getSequence(String path) + { + return (Sequence)get(path); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public short getShort(String path) + { + return DataObjectUtil.getShort(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String getString(String path) + { + return DataObjectUtil.getString(get(path)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBigDecimal(String path, BigDecimal value) + { + DataObjectUtil.setBigDecimal(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBigInteger(String path, BigInteger value) + { + DataObjectUtil.setBigInteger(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBoolean(String path, boolean value) + { + DataObjectUtil.setBoolean(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setByte(String path, byte value) + { + DataObjectUtil.setByte(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBytes(String path, byte[] value) + { + DataObjectUtil.setBytes(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setChar(String path, char value) + { + DataObjectUtil.setChar(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setDataObject(String path, DataObject value) + { + DataObjectUtil.set(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setDate(String path, Date value) + { + DataObjectUtil.setDate(this,path,value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setDouble(String path, double value) + { + DataObjectUtil.setDouble(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setFloat(String path, float value) + { + DataObjectUtil.setFloat(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setInt(String path, int value) + { + DataObjectUtil.setInt(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setList(String path, List value) + { + DataObjectUtil.set(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setLong(String path, long value) + { + DataObjectUtil.setLong(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setShort(String path, short value) + { + DataObjectUtil.setShort(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setString(String path, String value) + { + DataObjectUtil.setString(this, path, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public BigDecimal getBigDecimal(int propertyIndex) + { + return DataObjectUtil.getBigDecimal(this, propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public BigInteger getBigInteger(int propertyIndex) + { + return DataObjectUtil.getBigInteger(this,propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean getBoolean(int propertyIndex) + { + return DataObjectUtil.getBoolean(this, propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public byte getByte(int propertyIndex) + { + return DataObjectUtil.getByte(this, propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public byte[] getBytes(int propertyIndex) + { + return DataObjectUtil.getBytes(this, propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public char getChar(int propertyIndex) + { + return DataObjectUtil.getChar(this, propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject getDataObject(int propertyIndex) + { + return DataObjectUtil.getDataObject(this, propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Date getDate(int propertyIndex) + { + return DataObjectUtil.getDate(this,propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public double getDouble(int propertyIndex) + { + return DataObjectUtil.getDouble(this, propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public float getFloat(int propertyIndex) + { + return DataObjectUtil.getFloat(this,propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public int getInt(int propertyIndex) + { + return DataObjectUtil.getInt(this,propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getList(int propertyIndex) + { + return DataObjectUtil.getList(this, propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public long getLong(int propertyIndex) + { + return DataObjectUtil.getLong(this,propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Sequence getSequence(int propertyIndex) + { + return DataObjectUtil.getSequence(this, propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public short getShort(int propertyIndex) + { + return DataObjectUtil.getShort(this,propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String getString(int propertyIndex) + { + return DataObjectUtil.getString(this,propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBigDecimal(int propertyIndex, BigDecimal value) + { + DataObjectUtil.setBigDecimal(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBigInteger(int propertyIndex, BigInteger value) + { + DataObjectUtil.setBigInteger(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBoolean(int propertyIndex, boolean value) + { + DataObjectUtil.setBoolean(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setByte(int propertyIndex, byte value) + { + DataObjectUtil.setByte(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBytes(int propertyIndex, byte[] value) + { + DataObjectUtil.setBytes(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setChar(int propertyIndex, char value) + { + DataObjectUtil.setChar(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setDataObject(int propertyIndex, DataObject value) + { + DataObjectUtil.setDataObject(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setDate(int propertyIndex, Date value) + { + DataObjectUtil.setDate(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setDouble(int propertyIndex, double value) + { + DataObjectUtil.setDouble(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setFloat(int propertyIndex, float value) + { + DataObjectUtil.setFloat(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setInt(int propertyIndex, int value) + { + DataObjectUtil.setInt(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setList(int propertyIndex, List value) + { + DataObjectUtil.setList(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setLong(int propertyIndex, long value) + { + DataObjectUtil.setLong(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setShort(int propertyIndex, short value) + { + DataObjectUtil.setShort(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setString(int propertyIndex, String value) + { + DataObjectUtil.setString(this, propertyIndex, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public BigDecimal getBigDecimal(Property property) + { + return DataObjectUtil.getBigDecimal(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public BigInteger getBigInteger(Property property) + { + return DataObjectUtil.getBigInteger(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean getBoolean(Property property) + { + return DataObjectUtil.getBoolean(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public byte getByte(Property property) + { + return DataObjectUtil.getByte(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public byte[] getBytes(Property property) + { + return DataObjectUtil.getBytes(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public char getChar(Property property) + { + return DataObjectUtil.getChar(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject getDataObject(Property property) + { + return (DataObject)DataObjectUtil.getDataObject(this,property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Date getDate(Property property) + { + return DataObjectUtil.getDate(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public double getDouble(Property property) + { + return DataObjectUtil.getDouble(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public float getFloat(Property property) + { + return DataObjectUtil.getFloat(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public int getInt(Property property) + { + return DataObjectUtil.getInt(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getList(Property property) + { + return (List)DataObjectUtil.getList(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public long getLong(Property property) + { + return DataObjectUtil.getLong(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Sequence getSequence(Property property) + { + return (Sequence)DataObjectUtil.getSequence(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public short getShort(Property property) + { + return DataObjectUtil.getShort(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String getString(Property property) + { + return DataObjectUtil.getString(this, property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBigDecimal(Property property, BigDecimal value) + { + DataObjectUtil.setBigDecimal(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBigInteger(Property property, BigInteger value) + { + DataObjectUtil.setBigInteger(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBoolean(Property property, boolean value) + { + DataObjectUtil.setBoolean(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setByte(Property property, byte value) + { + DataObjectUtil.setByte(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setBytes(Property property, byte[] value) + { + DataObjectUtil.setBytes(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setChar(Property property, char value) + { + DataObjectUtil.setChar(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setDataObject(Property property, DataObject value) + { + DataObjectUtil.setDataObject(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setDate(Property property, Date value) + { + DataObjectUtil.setDate(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setDouble(Property property, double value) + { + DataObjectUtil.setDouble(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setFloat(Property property, float value) + { + DataObjectUtil.setFloat(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setInt(Property property, int value) + { + DataObjectUtil.setInt(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setList(Property property, List value) + { + DataObjectUtil.setList(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setLong(Property property, long value) + { + DataObjectUtil.setLong(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setShort(Property property, short value) + { + DataObjectUtil.setShort(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setString(Property property, String value) + { + DataObjectUtil.setString(this,property, value); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject createDataObject(String propertyName) + { + return DataObjectUtil.createDataObject(this, propertyName); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject createDataObject(int propertyIndex) + { + return DataObjectUtil.createDataObject(this, propertyIndex); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject createDataObject(Property property) + { + return DataObjectUtil.createDataObject(this,property); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject createDataObject(String propertyName, String namespaceURI, String typeName) + { + return DataObjectUtil.createDataObject(this, propertyName, namespaceURI, typeName); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject createDataObject(int propertyIndex, String namespaceURI, String typeName) + { + return DataObjectUtil.createDataObject(this, propertyIndex, namespaceURI, typeName); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject createDataObject(Property property, Type type) + { + return DataObjectUtil.createDataObject(this, property, type); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void delete() + { + DataObjectUtil.delete(this); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Sequence getSequence() + { + EAttribute mixedFeature = BasicExtendedMetaData.INSTANCE.getMixedFeature(eClass()); + return mixedFeature != null ? (Sequence)eGet(mixedFeature, true, false) : null; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getInstanceProperties() + { + return DataObjectUtil.getInstanceProperties(this); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Property getProperty(String propertyName) + { + return DataObjectUtil.getProperty(this, propertyName); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public DataObject getRootObject() + { + return DataObjectUtil.getRootObject(this); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public ChangeSummary getChangeSummary() + { + return DataObjectUtil.getChangeSummary(this); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void detach() + { + DataObjectUtil.detach(this); + } + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Following methods customize BasicEObjectImpl, optimized for SDO + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getDataObject(); + } + + public boolean eNotificationRequired() + { + return changeRecorder != null; + } + + public void eNotify(Notification notification) + { + changeRecorder.notifyChanged(notification); + } + + public void setChangeRecorder(SDOChangeRecorder changeRecorder) + { + if (this.changeRecorder != null) + { + this.changeRecorder.unsetTarget(this); + } + + if (changeRecorder != null) + { + changeRecorder.setTarget(this); + } + + this.changeRecorder = changeRecorder; + } + + public InternalEObject eInternalContainer() + { + return eContainer; + } + + public int eContainerFeatureID() + { + return eContainerFeatureID; + } + + protected void eBasicSetContainer(InternalEObject newContainer, int newContainerFeatureID) + { + eContainer = newContainer; + eContainerFeatureID = newContainerFeatureID; + } + + public EClass eClass() + { + return eStaticClass(); + } + + public EList eContents() + { + return new EContentsEList(this); + } + + public EList eCrossReferences() + { + return new ECrossReferenceEList(this); + } + + public Resource.Internal eDirectResource() + { + return location instanceof Resource.Internal ? (Resource.Internal)location : null; + } + + protected EClass eDynamicClass() + { + return null; + } + + protected boolean eHasSettings() + { + return false; + } + + public boolean eIsProxy() + { + return location instanceof URI; + } + + public URI eProxyURI() + { + return location instanceof URI ? (URI)location : null; + } + + public void eSetClass(EClass eClass) + { + throw new UnsupportedOperationException(); + } + + protected void eSetDirectResource(Resource.Internal resource) + { + location = resource; + } + + public void eSetProxyURI(URI uri) + { + location = uri; + } + + protected DynamicValueHolder eSettings() + { + return null; + } + + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + return eDynamicGet(featureID, resolve, coreType); + } + + public void eSet(int featureID, Object newValue) + { + eDynamicSet(featureID, newValue); + } + + public void eUnset(int featureID) + { + eDynamicUnset(featureID); + } + + public boolean eIsSet(int featureID) + { + return eDynamicIsSet(featureID); + } + + public Object eDynamicGet(int featureID, boolean resolve, boolean coreType) + { + return eOpenGet(DataObjectUtil.getOpenFeature(this, featureID), resolve); + } + + public void eDynamicSet(int featureID, Object newValue) + { + eOpenSet(DataObjectUtil.getOpenFeature(this, featureID), newValue); + } + + public void eDynamicUnset(int featureID) + { + eOpenUnset(DataObjectUtil.getOpenFeature(this, featureID)); + } + + public boolean eDynamicIsSet(int featureID) + { + return eOpenIsSet(DataObjectUtil.getOpenFeature(this, featureID)); + } + + /* + public int eDerivedStructuralFeatureID(EStructuralFeature eStructuralFeature) + { + Class containerClass = eStructuralFeature.getContainerClass(); + return + containerClass == null ? + eClass().getFeatureID(eStructuralFeature) : + containerClass.isInstance(this) ? + eDerivedStructuralFeatureID(eStructuralFeature.getFeatureID(), containerClass) : + -1; + } + + public void eOpenSet(EStructuralFeature eFeature, Object newValue) + { + EStructuralFeature openFeature = ExtendedMetaData.INSTANCE.getAffiliation(eClass(), eFeature); + if (openFeature == null) + { + openFeature = (EStructuralFeature)eClass().getEStructuralFeature("any"); + } + if (openFeature != null) + { + if (!FeatureMapUtil.isFeatureMap(openFeature)) + { + openFeature = ExtendedMetaData.INSTANCE.getGroup(openFeature); + } + FeatureMap featureMap = (FeatureMap)eGet(openFeature); + ((FeatureMap.Internal)featureMap).set(eFeature, newValue); + } + else + { + throw new IllegalArgumentException("The feature '" + eFeature.getName() + "' is not a valid changeable feature"); + } + } + */ + +} //DataObjectImpl + diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataTypeImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataTypeImpl.java new file mode 100644 index 0000000000..4e676741be --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DataTypeImpl.java @@ -0,0 +1,753 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + +import java.util.Collections; +import java.util.List; + +import org.apache.tuscany.sdo.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.Sequence; +import commonj.sdo.Type; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Data Type</b></em>'. + * <!-- end-user-doc --> + * <p> + * </p> + * + * @generated + */ +public class DataTypeImpl extends EDataTypeImpl implements Type, org.apache.tuscany.sdo.model.Type/*, DataObject*/ +{ + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected DataTypeImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + protected EClass eStaticClass() + { + return EcorePackage.eINSTANCE.getEDataType(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String getURI() + { + return getEPackage().getNsURI(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isDataType() + { + return true; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isOpen() + { + return false; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isSequenced() + { + return false; + } + + protected List aliasNames = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getAliasNames() + { + if (aliasNames == null) + { + aliasNames = DataObjectUtil.getAliasNames(this); + } + return aliasNames; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getDeclaredProperties() + { + return Collections.EMPTY_LIST; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getProperties() + { + return Collections.EMPTY_LIST; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getBaseTypes() + { + EDataType dataType = ExtendedMetaData.INSTANCE.getBaseType(this); + if (dataType == null) + { + return Collections.EMPTY_LIST; + } + else + { + return Collections.singletonList(dataType); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Property getProperty(String propertyName) + { + return null; + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // org.apache.tuscany.sdo.model.Type method implementations + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + + public List getBaseType() { + return this.getBaseTypes(); + } + + public List getProperty() { + return this.getProperties(); + } + + public List getAliasName() { + return this.getAliasNames(); + } + + public Sequence getAny() { + throw new UnsupportedOperationException(); + } + + public Sequence getAnyAttribute() { + throw new UnsupportedOperationException(); + } + + public boolean isAbstract() + { + return false; + } + + public void setAbstract(boolean value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetAbstract() { + return false; + } + + public void unsetAbstract() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void setDataType(boolean value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void unsetDataType() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetDataType() { + return true; + } + + public void setOpen(boolean value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void unsetOpen() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetOpen() { + return false; + } + + public void setSequenced(boolean value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void unsetSequenced() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetSequenced() { + return false; + } + + public void setUri(String value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public String getUri() { + return getURI(); + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // DataObject method implementations + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + /* + public Object get(int propertyIndex) { + Object ret = DataObjectUtil.get(this, propertyIndex); + return (ret != null) ? + ret : eGet(propertyIndex, true, false); + } + + public void set(int propertyIndex, Object value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSet(int propertyIndex) { + return eIsSet(propertyIndex); + } + + public void unset(int propertyIndex) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public Object get(Property property) { + Object ret = DataObjectUtil.get(this, ((EStructuralFeature)property).getFeatureID()); + return (ret != null) ? + ret : eGet((EStructuralFeature)property, true, false); + } + + public void set(Property property, Object value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSet(Property property) { + return eIsSet((EStructuralFeature)property); + } + + public void unset(Property property) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject getContainer() { + return (DataObject)eContainer(); + } + + public Property getContainmentProperty() { + return (Property)eContainmentFeature(); + } + + public Type getType() { + return (Type)ModelPackageImpl.eINSTANCE.getType(); + } + + // Remaining DataObject methods are (will be) implemented as straight delegation to DataObjectUtil + + public Object get(String path) { + return DataObjectUtil.get(this, path); + } + + public void set(String path, Object value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSet(String path) { + return DataObjectUtil.isSet(this, path); + } + + public void unset(String path) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean getBoolean(String path) { + return DataObjectUtil.getBoolean(get(path)); + } + + public byte getByte(String path) { + return DataObjectUtil.getByte(get(path)); + } + + public char getChar(String path) { + return DataObjectUtil.getChar(get(path)); + } + + public double getDouble(String path) { + return DataObjectUtil.getDouble(get(path)); + } + + public float getFloat(String path) { + return DataObjectUtil.getFloat(get(path)); + } + + public int getInt(String path) { + return DataObjectUtil.getInt(get(path)); + } + + public long getLong(String path) { + return DataObjectUtil.getLong(get(path)); + } + + public short getShort(String path) { + return DataObjectUtil.getShort(get(path)); + } + + public byte[] getBytes(String path) { + return DataObjectUtil.getBytes(get(path)); + } + + public BigDecimal getBigDecimal(String path) { + return DataObjectUtil.getBigDecimal(get(path)); + } + + public BigInteger getBigInteger(String path) { + return DataObjectUtil.getBigInteger(get(path)); + } + + public DataObject getDataObject(String path) { + return (DataObject)get(path); + } + + public Date getDate(String path) { + return DataObjectUtil.getDate(get(path)); + } + + public String getString(String path) { + return DataObjectUtil.getString(get(path)); + } + + public List getList(String path) { + return (List)get(path); + } + + public Sequence getSequence(String path) { + return (Sequence)get(path); + } + + public void setBoolean(String path, boolean value) { + set(path, new Boolean(value)); + } + + public void setByte(String path, byte value) { + set(path, new Byte(value)); + } + + public void setChar(String path, char value) { + set(path, new Character(value)); + } + + public void setDouble(String path, double value) { + set(path, new Double(value)); + } + + public void setFloat(String path, float value) { + set(path, new Float(value)); + } + + public void setInt(String path, int value) { + set(path, new Integer(value)); + } + + public void setLong(String path, long value) { + set(path, new Long(value)); + } + + public void setShort(String path, short value) { + set(path, new Short(value)); + } + + public void setBytes(String path, byte[] value) { + set(path, value); + } + + public void setBigDecimal(String path, BigDecimal value) { + set(path, value); + } + + public void setBigInteger(String path, BigInteger value) { + set(path, value); + } + + public void setDataObject(String path, DataObject value) { + set(path, value); + } + + public void setDate(String path, Date value) { + set(path, value); + } + + public void setString(String path, String value) { + set(path, value); + } + + public void setList(String path, List value) { + set(path, value); + } + + public boolean getBoolean(int propertyIndex) { + return DataObjectUtil.getBoolean(this, propertyIndex); + } + + public byte getByte(int propertyIndex) { + return DataObjectUtil.getByte(this, propertyIndex); + } + + public char getChar(int propertyIndex) { + return DataObjectUtil.getChar(this, propertyIndex); + } + + public double getDouble(int propertyIndex) { + return DataObjectUtil.getDouble(this, propertyIndex); + } + + public float getFloat(int propertyIndex) { + return DataObjectUtil.getFloat(this, propertyIndex); + } + + public int getInt(int propertyIndex) { + return DataObjectUtil.getInt(this, propertyIndex); + } + + public long getLong(int propertyIndex) { + return DataObjectUtil.getLong(this, propertyIndex); + } + + public short getShort(int propertyIndex) { + return DataObjectUtil.getShort(this, propertyIndex); + } + + public byte[] getBytes(int propertyIndex) { + return DataObjectUtil.getBytes(this, propertyIndex); + } + + public BigDecimal getBigDecimal(int propertyIndex) { + return DataObjectUtil.getBigDecimal(this, propertyIndex); + } + + public BigInteger getBigInteger(int propertyIndex) { + return DataObjectUtil.getBigInteger(this, propertyIndex); + } + + public DataObject getDataObject(int propertyIndex) { + return DataObjectUtil.getDataObject(this, propertyIndex); + } + + public Date getDate(int propertyIndex) { + return DataObjectUtil.getDate(this, propertyIndex); + } + + public String getString(int propertyIndex) { + return DataObjectUtil.getString(this, propertyIndex); + } + + public List getList(int propertyIndex) { + return DataObjectUtil.getList(this, propertyIndex); + } + + public Sequence getSequence(int propertyIndex) { + return DataObjectUtil.getSequence(this, propertyIndex); + } + + public void setBoolean(int propertyIndex, boolean value) { + set(propertyIndex, new Boolean(value)); + } + + public void setByte(int propertyIndex, byte value) { + set(propertyIndex, new Byte(value)); + } + + public void setChar(int propertyIndex, char value) { + set(propertyIndex, new Character(value)); + } + + public void setDouble(int propertyIndex, double value) { + set(propertyIndex, new Double(value)); + } + + public void setFloat(int propertyIndex, float value) { + set(propertyIndex, new Float(value)); + } + + public void setInt(int propertyIndex, int value) { + set(propertyIndex, new Integer(value)); + } + + public void setLong(int propertyIndex, long value) { + set(propertyIndex, new Long(value)); + } + + public void setShort(int propertyIndex, short value) { + set(propertyIndex, new Short(value)); + } + + public void setBytes(int propertyIndex, byte[] value) { + set(propertyIndex, value); + } + + public void setBigDecimal(int propertyIndex, BigDecimal value) { + set(propertyIndex, value); + } + + public void setBigInteger(int propertyIndex, BigInteger value) { + set(propertyIndex, value); + } + + public void setDataObject(int propertyIndex, DataObject value) { + set(propertyIndex, value); + } + + public void setDate(int propertyIndex, Date value) { + set(propertyIndex, value); + } + + public void setString(int propertyIndex, String value) { + set(propertyIndex, value); + } + + public void setList(int propertyIndex, List value) { + set(propertyIndex, value); + } + + public boolean getBoolean(Property property) { + return DataObjectUtil.getBoolean(this, property); + } + + public byte getByte(Property property) { + return DataObjectUtil.getByte(this, property); + } + + public char getChar(Property property) { + return DataObjectUtil.getChar(this, property); + } + + public double getDouble(Property property) { + return DataObjectUtil.getDouble(this, property); + } + + public float getFloat(Property property) { + return DataObjectUtil.getFloat(this, property); + } + + public int getInt(Property property) { + return DataObjectUtil.getInt(this, property); + } + + public long getLong(Property property) { + return DataObjectUtil.getLong(this, property); + } + + public short getShort(Property property) { + return DataObjectUtil.getShort(this, property); + } + + public byte[] getBytes(Property property) { + return DataObjectUtil.getBytes(this, property); + } + + public BigDecimal getBigDecimal(Property property) { + return DataObjectUtil.getBigDecimal(this, property); + } + + public BigInteger getBigInteger(Property property) { + return DataObjectUtil.getBigInteger(this, property); + } + + public DataObject getDataObject(Property property) { + return DataObjectUtil.getDataObject(this, property); + } + + public Date getDate(Property property) { + return DataObjectUtil.getDate(this, property); + } + + public String getString(Property property) { + return DataObjectUtil.getString(this, property); + } + + public List getList(Property property) { + return DataObjectUtil.getList(this, property); + } + + public Sequence getSequence(Property property) { + return DataObjectUtil.getSequence(this, property); + } + + public void setBoolean(Property property, boolean value) { + set(property, new Boolean(value)); + } + + public void setByte(Property property, byte value) { + set(property, new Byte(value)); + } + + public void setChar(Property property, char value) { + set(property, new Character(value)); + } + + public void setDouble(Property property, double value) { + set(property, new Double(value)); + } + + public void setFloat(Property property, float value) { + set(property, new Float(value)); + } + + public void setInt(Property property, int value) { + set(property, new Integer(value)); + } + + public void setLong(Property property, long value) { + set(property, new Long(value)); + } + + public void setShort(Property property, short value) { + set(property, new Short(value)); + } + + public void setBytes(Property property, byte[] value) { + set(property, value); + } + + public void setBigDecimal(Property property, BigDecimal value) { + set(property, value); + } + + public void setBigInteger(Property property, BigInteger value) { + set(property, value); + } + + public void setDataObject(Property property, DataObject value) { + set(property, value); + } + + public void setDate(Property property, Date value) { + set(property, value); + } + + public void setString(Property property, String value) { + set(property, value); + } + + public void setList(Property property, List value) { + set(property, value); + } + + public DataObject createDataObject(String propertyName) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(String propertyName, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property, Type type) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void delete() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataGraph getDataGraph() { + return DataObjectUtil.getDataGraph(this); + } + + public Sequence getSequence() { + EAttribute mixedFeature = BasicExtendedMetaData.INSTANCE.getMixedFeature(eClass()); + return mixedFeature != null ? (Sequence)eGet(mixedFeature, true, false) : null; + } + + public List getInstanceProperties() { + return DataObjectUtil.getInstanceProperties(this); + } + + public DataObject getRootObject() { + return DataObjectUtil.getRootObject(this); + } + + public ChangeSummary getChangeSummary() { + // TODO: implement this method + throw new UnsupportedOperationException(); + } + + public void detach() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + */ + +} //DataTypeImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicDataObjectImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicDataObjectImpl.java new file mode 100644 index 0000000000..20cf2a3058 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicDataObjectImpl.java @@ -0,0 +1,199 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + +import org.apache.tuscany.sdo.SDOPackage; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import commonj.sdo.DataObject; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Dynamic Data Object</b></em>'. + * @extends EStructuralFeature.Internal.DynamicValueHolder + * <!-- end-user-doc --> + * <p> + * </p> + * + * @generated + */ +public class DynamicDataObjectImpl extends DataObjectImpl implements DataObject, EStructuralFeature.Internal.DynamicValueHolder +{ + protected EClass eClass; + protected Object [] eSettings; + + protected static final Object [] ENO_SETTINGS = new Object [0]; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected DynamicDataObjectImpl() + { + super(); + } + + /** + * Creates a dynamic DataObject. + */ + public DynamicDataObjectImpl(EClass eClass) + { + super(); + eSetClass(eClass); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getDynamicDataObject(); + } + + protected int eStaticFeatureCount() + { + return 0; + } + + public int eDerivedStructuralFeatureID(EStructuralFeature eStructuralFeature) + { + return eClass().getFeatureID(eStructuralFeature); + } + + protected boolean eHasSettings() + { + return eSettings != null; + } + + protected EStructuralFeature.Internal.DynamicValueHolder eSettings() + { + if (eSettings == null) + { + int size = eClass().getFeatureCount() - eStaticFeatureCount(); + eSettings = size == 0 ? ENO_SETTINGS : new Object [size]; + } + + return this; + } + + protected EClass eDynamicClass() + { + return eClass; + } + + public EClass eClass() + { + return eClass; + } + + public void eSetClass(EClass eClass) + { + this.eClass = eClass; + } + + public Object dynamicGet(int dynamicFeatureID) + { + return eSettings[dynamicFeatureID]; + } + + public void dynamicSet(int dynamicFeatureID, Object value) + { + eSettings[dynamicFeatureID] = value; + } + + public void dynamicUnset(int dynamicFeatureID) + { + eSettings[dynamicFeatureID] = null; + } + + public Object eDynamicGet(int featureID, boolean resolve, boolean coreType) + { + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + return eSettingDelegate(eFeature).dynamicGet(this, eSettings(), featureID, resolve, coreType); + } + else + { + return super.eDynamicGet(featureID, resolve, coreType); + } + } + + public void eDynamicSet(int featureID, Object newValue) + { + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + 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/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicStoreDataObjectImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicStoreDataObjectImpl.java new file mode 100644 index 0000000000..d9d39bad49 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicStoreDataObjectImpl.java @@ -0,0 +1,91 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + +import org.apache.tuscany.sdo.SDOPackage; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import commonj.sdo.DataObject; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Dynamic Store Data Object</b></em>'. + * <!-- end-user-doc --> + * <p> + * </p> + * + * @generated + */ +public class DynamicStoreDataObjectImpl extends StoreDataObjectImpl implements DataObject +{ + protected EClass eClass; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected DynamicStoreDataObjectImpl() + { + super(); + } + + public DynamicStoreDataObjectImpl(InternalEObject.EStore eStore) + { + super(eStore); + } + + public DynamicStoreDataObjectImpl(EClass eClass) + { + super(eClass); + } + + public DynamicStoreDataObjectImpl(EClass eClass, InternalEObject.EStore eStore) + { + super(eClass, eStore); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getDynamicStoreDataObject(); + } + + protected EClass eDynamicClass() + { + return eClass; + } + + public EClass eClass() + { + return eClass; + } + + public void eSetClass(EClass eClass) + { + this.eClass = eClass; + } + +} //DynamicStoreDataObjectImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/EnumImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/EnumImpl.java new file mode 100644 index 0000000000..af17b7b2b0 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/EnumImpl.java @@ -0,0 +1,173 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + +import java.util.Collections; +import java.util.List; + +//import org.apache.tuscany.sdo.SDOPackage; + +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.impl.EEnumImpl; + +import commonj.sdo.Property; +import commonj.sdo.Type; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Enum</b></em>'. + * <!-- end-user-doc --> + * <p> + * </p> + * + * @generated + * @deprecated SDO doesn't support Enum types + */ +public class EnumImpl extends EEnumImpl implements Type +{ + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EnumImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + protected EClass eStaticClass() + { + return EcorePackage.eINSTANCE.getEEnum(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String getURI() + { + return getEPackage().getNsURI(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isDataType() + { + return true; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isOpen() + { + return false; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isSequenced() + { + return false; + } + + protected List aliasNames = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getAliasNames() + { + if (aliasNames == null) + { + aliasNames = DataObjectUtil.getAliasNames(this); + } + return aliasNames; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getDeclaredProperties() + { + return Collections.EMPTY_LIST; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getProperties() + { + return Collections.EMPTY_LIST; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getBaseTypes() + { + return Collections.EMPTY_LIST; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Property getProperty(String propertyName) + { + return null; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isAbstract() + { + return false; + } + +} //EnumTypeImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/FactoryBase.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/FactoryBase.java new file mode 100644 index 0000000000..2ff31233d0 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/FactoryBase.java @@ -0,0 +1,304 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + +import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl; +import org.apache.tuscany.sdo.model.impl.ModelPackageImpl; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.ENamedElement; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.impl.EClassImpl; +import org.eclipse.emf.ecore.impl.EFactoryImpl; +import org.eclipse.emf.ecore.impl.EPackageImpl; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; + +/** + */ +public class FactoryBase extends EPackageImpl +{ + + public static final boolean IS_ATTRIBUTE = true; + + protected FactoryBase(String namespaceURI, String namespacePrefix) + { + super(new SDOEFactoryImpl()); + + int index = namespacePrefix.lastIndexOf("."); + setName(index != -1 ? namespacePrefix.substring(index + 1) : namespacePrefix); + setNsPrefix(namespacePrefix); + + createResource(namespaceURI); + setNsURI(namespaceURI); + //FIXME ... figure out proper (scoped) way to register static packages + EPackage.Registry.INSTANCE.put(namespaceURI, this); + + ((SDOEFactoryImpl)getEFactoryInstance()).sdoFactory = this; + } + + public DataObject create(int typeNumber) + { + return null; + } + + protected Type createType(boolean isDataType, int typeNumber) + { + if (isDataType) + return (Type)createEDataType(typeNumber); + else + return (Type)createEClass(typeNumber); + } + + protected void createProperty(boolean isDataType, Type containingType, int propertyNumber) + { + if (isDataType) + createEAttribute((EClass)containingType, propertyNumber); + else + createEReference((EClass)containingType, propertyNumber); + } + + protected void initializeType(Type type, Class instanceClass, String name) + { + initEClass((EClass)type, instanceClass, name, !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + } + + protected void initializeType(Type type, Class instanceClass, String name, boolean isSerializable, boolean isGenerated) + { + initEDataType((EDataType)type, instanceClass, name, isSerializable, isGenerated); + } + + protected void initializeProperty(Property property, Type type, String name, String defaultValue, int lower, int upper, Class containerClass, boolean isReadonly, boolean isUnsettable, boolean isDerived) + { + initEAttribute((EAttribute)property, (EClassifier)type, name, defaultValue, lower, upper, containerClass, isDerived, isDerived, !isReadonly, isUnsettable, !IS_ID, !IS_UNIQUE, isDerived, IS_ORDERED); + } + + protected void initializeProperty(Property property, Type type, String name, String defaultValue, int lower, int upper, Class containerClass, boolean isReadonly, boolean isUnsettable, boolean isDerived, boolean isComposite, Property oppositeProperty) + { + initEReference((EReference)property, (EClassifier)type, (EReference)oppositeProperty, name, defaultValue, lower, upper, containerClass, isDerived, isDerived, !isReadonly, isComposite, !isComposite /*resolve*/, isUnsettable, IS_UNIQUE, isDerived, IS_ORDERED); + } + + protected void createXSDMetaData() + { + createDocumentRoot(); + } + + protected void addXSDMapping(String[] xsdMappings, String annotationSource) + { + addAnnotation((ENamedElement)this, annotationSource, xsdMappings); + } + + protected void addXSDMapping(Type type, String[] xsdMappings) + { + addAnnotation((ENamedElement)type, ANNOTATION_SOURCE, xsdMappings); + } + + protected void addXSDMapping(Property property, String[] xsdMappings) + { + addAnnotation((ENamedElement)property, ANNOTATION_SOURCE, xsdMappings); + } + + protected void setInstanceProperty(Type type, String namespaceURI, String propertyName, String propertyValue) + { + setInstanceProperty((ENamedElement)type, namespaceURI, propertyName, propertyValue); + } + + protected void setInstanceProperty(Property property, String namespaceURI, String propertyName, String propertyValue) + { + setInstanceProperty((ENamedElement)property, namespaceURI, propertyName, propertyValue); + } + + private void setInstanceProperty(ENamedElement eNamedElement, String namespaceURI, String propertyName, String propertyValue) + { + EAnnotation annotation = eNamedElement.getEAnnotation(namespaceURI); + if (annotation == null) + { + addAnnotation(eNamedElement, namespaceURI, new String[]{propertyName, propertyValue}); + } else + { + annotation.getDetails().put(propertyName, propertyValue); + } + } + + protected Property createGlobalProperty(String name, Type type, String[] xsdMappings) + { + return createGlobalProperty(name, type, xsdMappings, false); + } + + protected Property createGlobalProperty(String name, Type type, String[] xsdMappings, boolean asAttribute) + { + return createGlobalProperty(name, type, xsdMappings, asAttribute, ANNOTATION_SOURCE); + } + + protected Property createGlobalProperty(String name, Type type, String[] xsdMappings, boolean asAttribute, String annotationSource) + { + int propertyNumber = documentRootEClass.getEStructuralFeatures().size(); + + EStructuralFeature globalProperty; + if(asAttribute) { + createEAttribute(documentRootEClass, propertyNumber); + EAttribute gatt = (EAttribute)documentRootEClass.getEStructuralFeatures().get(propertyNumber); + initEAttribute(gatt, (EDataType)type, name, null, 0, -2, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, IS_DERIVED, IS_ORDERED); + globalProperty = gatt; + } else { + createEReference(documentRootEClass, propertyNumber); + EReference gref = (EReference)documentRootEClass.getEStructuralFeatures().get(propertyNumber); + initEReference(gref, (EClass)type, null, name, null, 0, -2, null, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + globalProperty = gref; + } + addAnnotation((ENamedElement)globalProperty, annotationSource, xsdMappings); + return (Property) globalProperty; + } + + protected Type getSequence() + { + return (Type)ecorePackage.getEFeatureMapEntry(); + } + + protected void addSuperType(Type subType, Type superType) + { + ((EClass)subType).getESuperTypes().add((EClass)superType); + } + + //public static FactoryBase getStaticFactory(String namespaceURI) + // temporarily return Object - until everything is gen'd with new codegen pattern + public static Object getStaticFactory(String namespaceURI) + { + EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(namespaceURI); + //return (FactoryBase)ePackage; + return ePackage instanceof FactoryBase ? (Object)ePackage : (Object)ePackage.getEFactoryInstance(); + } + + // default implementation of createFromString + public Object createFromString(Type type, String stringValue, int propertyValue) + { + return (String)ModelFactoryImpl.eINSTANCE.createFromString(ModelPackageImpl.Literals.STRING, stringValue); + } + + // default implementation of convertToString + public String convertToString(Type type, Object objectValue, int propertyValue) + { + return ModelFactoryImpl.eINSTANCE.convertToString(ModelPackageImpl.Literals.STRING, objectValue); + } + + // private EMF-specific methods + + private static class SDOEFactoryImpl extends EFactoryImpl + { + protected FactoryBase sdoFactory; + + public SDOEFactoryImpl() + { + super(); + } + + public EObject create(EClass eClass) + { + DataObject result = sdoFactory.create(eClass.getClassifierID()); + if (result == null) { + return super.create(eClass); + } + return (EObject)result; + } + + public Object createFromString(EDataType eDataType, String stringValue) + { + return sdoFactory.createFromString((Type)eDataType, stringValue, eDataType.getClassifierID()); + } + + public String convertToString(EDataType eDataType, Object objectValue) + { + return sdoFactory.convertToString((Type)eDataType, objectValue, eDataType.getClassifierID()); + } + } + + private static final int DOCUMENT_ROOT = 0; + private static final int DOCUMENT_ROOT__MIXED = 0; + private static final int DOCUMENT_ROOT__XMLNS_PREFIX_MAP = 1; + private static final int DOCUMENT_ROOT__XSI_SCHEMA_LOCATION = 2; + private static final String ANNOTATION_SOURCE = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData"; + private EClass documentRootEClass = null; + + private void createDocumentRoot() + { + documentRootEClass = ecoreFactory.createEClass(); + ((EClassImpl)documentRootEClass).setClassifierID(DOCUMENT_ROOT); + getEClassifiers().add(DOCUMENT_ROOT, documentRootEClass); + + createEAttribute(documentRootEClass, DOCUMENT_ROOT__MIXED); + createEReference(documentRootEClass, DOCUMENT_ROOT__XMLNS_PREFIX_MAP); + createEReference(documentRootEClass, DOCUMENT_ROOT__XSI_SCHEMA_LOCATION); + + initEClass(documentRootEClass, null, "DocumentRoot", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + initEAttribute((EAttribute)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__MIXED), ecorePackage.getEFeatureMapEntry(), "mixed", null, 0, -1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference((EReference)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__XMLNS_PREFIX_MAP), ecorePackage.getEStringToStringMapEntry(), null, "xMLNSPrefixMap", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference((EReference)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__XSI_SCHEMA_LOCATION), ecorePackage.getEStringToStringMapEntry(), null, "xSISchemaLocation", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + addAnnotation + (documentRootEClass, + ANNOTATION_SOURCE, + new String[] + { + "name", "", + "kind", "mixed" + }); + addAnnotation + ((EAttribute)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__MIXED), + ANNOTATION_SOURCE, + new String[] + { + "kind", "elementWildcard", + "name", ":mixed" + }); + addAnnotation + ((EReference)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__XMLNS_PREFIX_MAP), + ANNOTATION_SOURCE, + new String[] + { + "kind", "attribute", + "name", "xmlns:prefix" + }); + addAnnotation + ((EReference)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__XSI_SCHEMA_LOCATION), + ANNOTATION_SOURCE, + new String[] + { + "kind", "attribute", + "name", "xsi:schemaLocation" + }); + } + + /** + * Initialize SDO runtime. + */ + static + { + DataObjectUtil.initRuntime(); + } +} diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ReferenceImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ReferenceImpl.java new file mode 100644 index 0000000000..c90b8f8ee9 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ReferenceImpl.java @@ -0,0 +1,701 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + +import java.util.List; + +import org.apache.tuscany.sdo.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.Sequence; +import commonj.sdo.Type; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Reference</b></em>'. + * <!-- end-user-doc --> + * <p> + * </p> + * + * @generated + */ +public class ReferenceImpl extends EReferenceImpl implements Property,/* DataObject,*/ org.apache.tuscany.sdo.model.Property +{ + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected ReferenceImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + protected EClass eStaticClass() + { + return EcorePackage.eINSTANCE.getEReference(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Object getDefault() + { + return getDefaultValue(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public boolean isReadOnly() + { + //return "true".equals(EcoreUtil.getAnnotation(this, "commonj.sdo", "readOnly")); + return !isChangeable(); //TODO semantics don't exactly match? + } + + protected List aliasNames = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List getAliasNames() + { + if (aliasNames == null) + { + aliasNames = DataObjectUtil.getAliasNames(this); + } + return aliasNames; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Type getType() + { + // Note that Property.getType() conflicts with DataObject.getType(), so we can only implement + // it one way or the other here. We're implementing it to return the property type so it will + // return the wrong type when the caller is using the DataObject interface. Not much we can + // do about it tho. -- James Snell + return (Type)getEType(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Type getContainingType() + { + return (Type)getEContainingClass(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Property getOpposite() + { + return (Property)getEOpposite(); + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // org.apache.tuscany.sdo.model.Property methods + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + + public List getAliasName() { + return this.getAliasNames(); + } + + public Sequence getAny() { + throw new UnsupportedOperationException(); + } + + public void setMany(boolean value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void unsetMany() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetMany() { + return isMany(); + } + + public void setReadOnly(boolean value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void unsetReadOnly() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetReadOnly() { + return isReadOnly(); + } + + public org.apache.tuscany.sdo.model.Type getType_() { + return (org.apache.tuscany.sdo.model.Type)getType(); + } + + public void setType(org.apache.tuscany.sdo.model.Type value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public Sequence getAnyAttribute() { + throw new UnsupportedOperationException(); + } + + public String getDefault_() { + return (String) this.getDefault(); + } + + public void setDefault_(String value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public org.apache.tuscany.sdo.model.Property getOpposite_() { + return (org.apache.tuscany.sdo.model.Property) getOpposite(); + } + + public void setOpposite_(org.apache.tuscany.sdo.model.Property value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void unsetContainment() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetContainment() { + return isContainment(); + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // DataObject method implementations + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + /* + public Object get(int propertyIndex) { + return DataObjectUtil.get(this, propertyIndex); + } + + public void set(int propertyIndex, Object value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSet(int propertyIndex) { + return DataObjectUtil.isSet(this, propertyIndex); + } + + public void unset(int propertyIndex) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public Object get(Property property) { + return DataObjectUtil.get(this, ((EStructuralFeature)property).getFeatureID()); + } + + public void set(Property property, Object value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSet(Property property) { + return DataObjectUtil.isSet(this, ((EStructuralFeature)property).getFeatureID()); + } + + public void unset(Property property) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject getContainer() { + return (DataObject)eContainer(); + } + + public Property getContainmentProperty() { + return (Property)eContainmentFeature(); + } + + // Remaining DataObject methods are (will be) implemented as straight delegation to DataObjectUtil + + public Object get(String path) { + return DataObjectUtil.get(this, path); + } + + public void set(String path, Object value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSet(String path) { + return DataObjectUtil.isSet(this, path); + } + + public void unset(String path) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean getBoolean(String path) { + return DataObjectUtil.getBoolean(get(path)); + } + + public byte getByte(String path) { + return DataObjectUtil.getByte(get(path)); + } + + public char getChar(String path) { + return DataObjectUtil.getChar(get(path)); + } + + public double getDouble(String path) { + return DataObjectUtil.getDouble(get(path)); + } + + public float getFloat(String path) { + return DataObjectUtil.getFloat(get(path)); + } + + public int getInt(String path) { + return DataObjectUtil.getInt(get(path)); + } + + public long getLong(String path) { + return DataObjectUtil.getLong(get(path)); + } + + public short getShort(String path) { + return DataObjectUtil.getShort(get(path)); + } + + public byte[] getBytes(String path) { + return DataObjectUtil.getBytes(get(path)); + } + + public BigDecimal getBigDecimal(String path) { + return DataObjectUtil.getBigDecimal(get(path)); + } + + public BigInteger getBigInteger(String path) { + return DataObjectUtil.getBigInteger(get(path)); + } + + public DataObject getDataObject(String path) { + return (DataObject)get(path); + } + + public Date getDate(String path) { + return DataObjectUtil.getDate(get(path)); + } + + public String getString(String path) { + return DataObjectUtil.getString(get(path)); + } + + public List getList(String path) { + return (List)get(path); + } + + public Sequence getSequence(String path) { + return (Sequence)get(path); + } + + public void setBoolean(String path, boolean value) { + set(path, new Boolean(value)); + } + + public void setByte(String path, byte value) { + set(path, new Byte(value)); + } + + public void setChar(String path, char value) { + set(path, new Character(value)); + } + + public void setDouble(String path, double value) { + set(path, new Double(value)); + } + + public void setFloat(String path, float value) { + set(path, new Float(value)); + } + + public void setInt(String path, int value) { + set(path, new Integer(value)); + } + + public void setLong(String path, long value) { + set(path, new Long(value)); + } + + public void setShort(String path, short value) { + set(path, new Short(value)); + } + + public void setBytes(String path, byte[] value) { + set(path, value); + } + + public void setBigDecimal(String path, BigDecimal value) { + set(path, value); + } + + public void setBigInteger(String path, BigInteger value) { + set(path, value); + } + + public void setDataObject(String path, DataObject value) { + set(path, value); + } + + public void setDate(String path, Date value) { + set(path, value); + } + + public void setString(String path, String value) { + set(path, value); + } + + public void setList(String path, List value) { + set(path, value); + } + + public boolean getBoolean(int propertyIndex) { + return DataObjectUtil.getBoolean(this, propertyIndex); + } + + public byte getByte(int propertyIndex) { + return DataObjectUtil.getByte(this, propertyIndex); + } + + public char getChar(int propertyIndex) { + return DataObjectUtil.getChar(this, propertyIndex); + } + + public double getDouble(int propertyIndex) { + return DataObjectUtil.getDouble(this, propertyIndex); + } + + public float getFloat(int propertyIndex) { + return DataObjectUtil.getFloat(this, propertyIndex); + } + + public int getInt(int propertyIndex) { + return DataObjectUtil.getInt(this, propertyIndex); + } + + public long getLong(int propertyIndex) { + return DataObjectUtil.getLong(this, propertyIndex); + } + + public short getShort(int propertyIndex) { + return DataObjectUtil.getShort(this, propertyIndex); + } + + public byte[] getBytes(int propertyIndex) { + return DataObjectUtil.getBytes(this, propertyIndex); + } + + public BigDecimal getBigDecimal(int propertyIndex) { + return DataObjectUtil.getBigDecimal(this, propertyIndex); + } + + public BigInteger getBigInteger(int propertyIndex) { + return DataObjectUtil.getBigInteger(this, propertyIndex); + } + + public DataObject getDataObject(int propertyIndex) { + return DataObjectUtil.getDataObject(this, propertyIndex); + } + + public Date getDate(int propertyIndex) { + return DataObjectUtil.getDate(this, propertyIndex); + } + + public String getString(int propertyIndex) { + return DataObjectUtil.getString(this, propertyIndex); + } + + public List getList(int propertyIndex) { + return DataObjectUtil.getList(this, propertyIndex); + } + + public Sequence getSequence(int propertyIndex) { + return DataObjectUtil.getSequence(this, propertyIndex); + } + + public void setBoolean(int propertyIndex, boolean value) { + set(propertyIndex, new Boolean(value)); + } + + public void setByte(int propertyIndex, byte value) { + set(propertyIndex, new Byte(value)); + } + + public void setChar(int propertyIndex, char value) { + set(propertyIndex, new Character(value)); + } + + public void setDouble(int propertyIndex, double value) { + set(propertyIndex, new Double(value)); + } + + public void setFloat(int propertyIndex, float value) { + set(propertyIndex, new Float(value)); + } + + public void setInt(int propertyIndex, int value) { + set(propertyIndex, new Integer(value)); + } + + public void setLong(int propertyIndex, long value) { + set(propertyIndex, new Long(value)); + } + + public void setShort(int propertyIndex, short value) { + set(propertyIndex, new Short(value)); + } + + public void setBytes(int propertyIndex, byte[] value) { + set(propertyIndex, value); + } + + public void setBigDecimal(int propertyIndex, BigDecimal value) { + set(propertyIndex, value); + } + + public void setBigInteger(int propertyIndex, BigInteger value) { + set(propertyIndex, value); + } + + public void setDataObject(int propertyIndex, DataObject value) { + set(propertyIndex, value); + } + + public void setDate(int propertyIndex, Date value) { + set(propertyIndex, value); + } + + public void setString(int propertyIndex, String value) { + set(propertyIndex, value); + } + + public void setList(int propertyIndex, List value) { + set(propertyIndex, value); + } + + public boolean getBoolean(Property property) { + return DataObjectUtil.getBoolean(this, property); + } + + public byte getByte(Property property) { + return DataObjectUtil.getByte(this, property); + } + + public char getChar(Property property) { + return DataObjectUtil.getChar(this, property); + } + + public double getDouble(Property property) { + return DataObjectUtil.getDouble(this, property); + } + + public float getFloat(Property property) { + return DataObjectUtil.getFloat(this, property); + } + + public int getInt(Property property) { + return DataObjectUtil.getInt(this, property); + } + + public long getLong(Property property) { + return DataObjectUtil.getLong(this, property); + } + + public short getShort(Property property) { + return DataObjectUtil.getShort(this, property); + } + + public byte[] getBytes(Property property) { + return DataObjectUtil.getBytes(this, property); + } + + public BigDecimal getBigDecimal(Property property) { + return DataObjectUtil.getBigDecimal(this, property); + } + + public BigInteger getBigInteger(Property property) { + return DataObjectUtil.getBigInteger(this, property); + } + + public DataObject getDataObject(Property property) { + return DataObjectUtil.getDataObject(this, property); + } + + public Date getDate(Property property) { + return DataObjectUtil.getDate(this, property); + } + + public String getString(Property property) { + return DataObjectUtil.getString(this, property); + } + + public List getList(Property property) { + return DataObjectUtil.getList(this, property); + } + + public Sequence getSequence(Property property) { + return DataObjectUtil.getSequence(this, property); + } + + public void setBoolean(Property property, boolean value) { + set(property, new Boolean(value)); + } + + public void setByte(Property property, byte value) { + set(property, new Byte(value)); + } + + public void setChar(Property property, char value) { + set(property, new Character(value)); + } + + public void setDouble(Property property, double value) { + set(property, new Double(value)); + } + + public void setFloat(Property property, float value) { + set(property, new Float(value)); + } + + public void setInt(Property property, int value) { + set(property, new Integer(value)); + } + + public void setLong(Property property, long value) { + set(property, new Long(value)); + } + + public void setShort(Property property, short value) { + set(property, new Short(value)); + } + + public void setBytes(Property property, byte[] value) { + set(property, value); + } + + public void setBigDecimal(Property property, BigDecimal value) { + set(property, value); + } + + public void setBigInteger(Property property, BigInteger value) { + set(property, value); + } + + public void setDataObject(Property property, DataObject value) { + set(property, value); + } + + public void setDate(Property property, Date value) { + set(property, value); + } + + public void setString(Property property, String value) { + set(property, value); + } + + public void setList(Property property, List value) { + set(property, value); + } + + public DataObject createDataObject(String propertyName) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(String propertyName, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property, Type type) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void delete() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataGraph getDataGraph() { + return DataObjectUtil.getDataGraph(this); + } + + public Sequence getSequence() { + EAttribute mixedFeature = BasicExtendedMetaData.INSTANCE.getMixedFeature(eClass()); + return mixedFeature != null ? (Sequence)eGet(mixedFeature, true, false) : null; + } + + public List getInstanceProperties() { + return DataObjectUtil.getInstanceProperties(this); + } + + public DataObject getRootObject() { + return DataObjectUtil.getRootObject(this); + } + + public ChangeSummary getChangeSummary() { + // TODO: implement this method + throw new UnsupportedOperationException(); + } + + public void detach() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + //DataObjectUtil.detach(this); + } + + public Property getProperty(String propertyName) { + return DataObjectUtil.getProperty(this, propertyName); + } + */ + +} //ReferenceImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOFactoryImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOFactoryImpl.java new file mode 100644 index 0000000000..8bb10297ff --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOFactoryImpl.java @@ -0,0 +1,328 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + + +import org.apache.tuscany.sdo.AnyTypeDataObject; +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.SimpleAnyTypeDataObject; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.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; +/** + * <!-- begin-user-doc --> + * An implementation of the model <b>Factory</b>. + * <!-- end-user-doc --> + * @generated + */ +public class SDOFactoryImpl extends EFactoryImpl implements SDOFactory +{ + /** + * Creates the default factory implementation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + 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. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public SDOFactoryImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EObject create(EClass eClass) + { + switch (eClass.getClassifierID()) + { + case SDOPackage.CHANGE_SUMMARY: return (EObject)createChangeSummary(); + case SDOPackage.CHANGE_SUMMARY_SETTING: return (EObject)createChangeSummarySetting(); + case SDOPackage.DATA_GRAPH: return (EObject)createDataGraph(); + case SDOPackage.ANY_TYPE_DATA_OBJECT: return createAnyTypeDataObject(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT: return createSimpleAnyTypeDataObject(); + case SDOPackage.CLASS: return (EObject)createClass(); + case SDOPackage.DATA_TYPE: return (EObject)createDataType(); + case SDOPackage.ATTRIBUTE: return (EObject)createAttribute(); + case SDOPackage.REFERENCE: return (EObject)createReference(); + case SDOPackage.ENUM: return (EObject)createEnum(); + case SDOPackage.DYNAMIC_DATA_OBJECT: return (EObject)createDynamicDataObject(); + case SDOPackage.STORE_DATA_OBJECT: return (EObject)createStoreDataObject(); + case SDOPackage.DYNAMIC_STORE_DATA_OBJECT: return (EObject)createDynamicStoreDataObject(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object createFromString(EDataType eDataType, String initialValue) + { + switch (eDataType.getClassifierID()) + { + default: + throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String convertToString(EDataType eDataType, Object instanceValue) + { + switch (eDataType.getClassifierID()) + { + default: + throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ChangeSummary createChangeSummary() + { + ChangeSummaryImpl changeSummary = new ChangeSummaryImpl(); + return changeSummary; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ChangeSummary.Setting createChangeSummarySetting() + { + ChangeSummarySettingImpl changeSummarySetting = new ChangeSummarySettingImpl(); + return changeSummarySetting; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public DataGraph createDataGraph() + { + DataGraphImpl dataGraph = new DataGraphImpl(); + return dataGraph; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public AnyTypeDataObject createAnyTypeDataObject() + { + AnyTypeDataObjectImpl anyTypeDataObject = new AnyTypeDataObjectImpl(); + return anyTypeDataObject; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public SimpleAnyTypeDataObject createSimpleAnyTypeDataObject() + { + SimpleAnyTypeDataObjectImpl simpleAnyTypeDataObject = new SimpleAnyTypeDataObjectImpl(); + return simpleAnyTypeDataObject; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Type createClass() + { + ClassImpl class_ = new ClassImpl(); + return class_; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Type createDataType() + { + DataTypeImpl dataType = new DataTypeImpl(); + return dataType; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Property createAttribute() + { + AttributeImpl attribute = new AttributeImpl(); + return attribute; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Property createReference() + { + ReferenceImpl reference = new ReferenceImpl(); + return reference; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Type createEnum() + { + EnumImpl enum_ = new EnumImpl(); + return enum_; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public DataObject createDynamicDataObject() + { + DynamicDataObjectImpl dynamicDataObject = new DynamicDataObjectImpl(); + return dynamicDataObject; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public DataObject createStoreDataObject() + { + StoreDataObjectImpl storeDataObject = new StoreDataObjectImpl(); + return storeDataObject; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public DataObject createDynamicStoreDataObject() + { + DynamicStoreDataObjectImpl dynamicStoreDataObject = new DynamicStoreDataObjectImpl(); + return dynamicStoreDataObject; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public SDOPackage getSDOPackage() + { + return (SDOPackage)getEPackage(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @deprecated + * @generated + */ + public static SDOPackage getPackage() + { + return SDOPackage.eINSTANCE; + } + + public ChangeSummary.Setting createChangeSummarySetting(EStructuralFeature eStructuralFeature, Object value, boolean isSet) + { + ChangeSummarySettingImpl eChangeSummarySetting = new ChangeSummarySettingImpl(eStructuralFeature, value, isSet); + return eChangeSummarySetting; + } + +} //SDOFactoryImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOPackageImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOPackageImpl.java new file mode 100644 index 0000000000..5c7192d9f6 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOPackageImpl.java @@ -0,0 +1,2136 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + +import java.io.ObjectStreamException; +import java.util.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; + +/** + * <!-- begin-user-doc --> + * An implementation of the model <b>Package</b>. + * <!-- end-user-doc --> + * @generated + */ +public class SDOPackageImpl extends EPackageImpl implements SDOPackage +{ + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass changeSummaryEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass changeSummarySettingEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass dataGraphEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass dataObjectEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass propertyEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass sequenceEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass typeEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass anyTypeDataObjectEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass simpleAnyTypeDataObjectEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass classEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass dataTypeEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass attributeEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass referenceEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass enumEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass dynamicDataObjectEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass storeDataObjectEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass dynamicStoreDataObjectEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType eJavaListEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType eObjectStreamExceptionEDataType = null; + + /** + * Creates an instance of the model <b>Package</b>, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + * <p>Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see org.apache.tuscany.sdo.SDOPackage#eNS_URI + * @see #init() + * @generated + */ + private SDOPackageImpl() + { + super(eNS_URI, SDOFactory.eINSTANCE); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the <b>Package</b> for this + * model, and for any others upon which it depends. Simple + * dependencies are satisfied by calling this method on all + * dependent packages before doing anything else. This method drives + * initialization for interdependent packages directly, in parallel + * with this package, itself. + * <p>Of this package and its interdependencies, all packages which + * have not yet been registered by their URI values are first created + * and registered. The packages are then initialized in two steps: + * meta-model objects for all of the packages are created before any + * are initialized, since one package's meta-model objects may refer to + * those of another. + * <p>Invocation of this method will not affect any packages that have + * already been initialized. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static SDOPackage init() + { + if (isInited) return (SDOPackage)EPackage.Registry.INSTANCE.getEPackage(SDOPackage.eNS_URI); + + // Obtain or create and register package + SDOPackageImpl theSDOPackage = (SDOPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof SDOPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new SDOPackageImpl()); + + isInited = true; + + // Initialize simple dependencies + EcorePackageImpl.init(); + XMLTypePackageImpl.init(); + ChangePackageImpl.init(); + + // Create package meta-data objects + theSDOPackage.createPackageContents(); + + // Initialize created meta-data + theSDOPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theSDOPackage.freeze(); + + return theSDOPackage; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getChangeSummary() + { + return changeSummaryEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EReference getChangeSummary_EDataGraph() + { + return (EReference)changeSummaryEClass.getEStructuralFeatures().get(0); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getChangeSummarySetting() + { + return changeSummarySettingEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getDataGraph() + { + return dataGraphEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EAttribute getDataGraph_ResourceSet() + { + return (EAttribute)dataGraphEClass.getEStructuralFeatures().get(0); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EAttribute getDataGraph_RootResource() + { + return (EAttribute)dataGraphEClass.getEStructuralFeatures().get(1); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EReference getDataGraph_EChangeSummary() + { + return (EReference)dataGraphEClass.getEStructuralFeatures().get(2); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EReference getDataGraph_ERootObject() + { + return (EReference)dataGraphEClass.getEStructuralFeatures().get(3); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getDataObject() + { + return dataObjectEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getProperty() + { + return propertyEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getSequence() + { + return sequenceEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getType() + { + return typeEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getAnyTypeDataObject() + { + return anyTypeDataObjectEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getSimpleAnyTypeDataObject() + { + return simpleAnyTypeDataObjectEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getClass_() + { + return classEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getDataType() + { + return dataTypeEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getAttribute() + { + return attributeEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getReference() + { + return referenceEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getEnum() + { + return enumEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getDynamicDataObject() + { + return dynamicDataObjectEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getStoreDataObject() + { + return storeDataObjectEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EClass getDynamicStoreDataObject() + { + return dynamicStoreDataObjectEClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EDataType getEJavaList() + { + return eJavaListEDataType; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EDataType getEObjectStreamException() + { + return eObjectStreamExceptionEDataType; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public SDOFactory getSDOFactory() + { + return (SDOFactory)getEFactoryInstance(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void createPackageContents() + { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + changeSummaryEClass = createEClass(CHANGE_SUMMARY); + createEReference(changeSummaryEClass, CHANGE_SUMMARY__EDATA_GRAPH); + + changeSummarySettingEClass = createEClass(CHANGE_SUMMARY_SETTING); + + dataGraphEClass = createEClass(DATA_GRAPH); + createEAttribute(dataGraphEClass, DATA_GRAPH__RESOURCE_SET); + createEAttribute(dataGraphEClass, DATA_GRAPH__ROOT_RESOURCE); + createEReference(dataGraphEClass, DATA_GRAPH__ECHANGE_SUMMARY); + createEReference(dataGraphEClass, DATA_GRAPH__EROOT_OBJECT); + + dataObjectEClass = createEClass(DATA_OBJECT); + + propertyEClass = createEClass(PROPERTY); + + sequenceEClass = createEClass(SEQUENCE); + + typeEClass = createEClass(TYPE); + + anyTypeDataObjectEClass = createEClass(ANY_TYPE_DATA_OBJECT); + + simpleAnyTypeDataObjectEClass = createEClass(SIMPLE_ANY_TYPE_DATA_OBJECT); + + classEClass = createEClass(CLASS); + + dataTypeEClass = createEClass(DATA_TYPE); + + attributeEClass = createEClass(ATTRIBUTE); + + referenceEClass = createEClass(REFERENCE); + + enumEClass = createEClass(ENUM); + + dynamicDataObjectEClass = createEClass(DYNAMIC_DATA_OBJECT); + + storeDataObjectEClass = createEClass(STORE_DATA_OBJECT); + + dynamicStoreDataObjectEClass = createEClass(DYNAMIC_STORE_DATA_OBJECT); + + // Create data types + eJavaListEDataType = createEDataType(EJAVA_LIST); + eObjectStreamExceptionEDataType = createEDataType(EOBJECT_STREAM_EXCEPTION); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void initializePackageContents() + { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Obtain other dependent packages + ChangePackageImpl theChangePackage = (ChangePackageImpl)EPackage.Registry.INSTANCE.getEPackage(ChangePackage.eNS_URI); + EcorePackageImpl theEcorePackage = (EcorePackageImpl)EPackage.Registry.INSTANCE.getEPackage(EcorePackage.eNS_URI); + XMLTypePackageImpl theXMLTypePackage = (XMLTypePackageImpl)EPackage.Registry.INSTANCE.getEPackage(XMLTypePackage.eNS_URI); + + // Add supertypes to classes + changeSummaryEClass.getESuperTypes().add(theChangePackage.getChangeDescription()); + changeSummarySettingEClass.getESuperTypes().add(theChangePackage.getFeatureChange()); + dataGraphEClass.getESuperTypes().add(theEcorePackage.getEObject()); + anyTypeDataObjectEClass.getESuperTypes().add(this.getDataObject()); + anyTypeDataObjectEClass.getESuperTypes().add(theXMLTypePackage.getAnyType()); + simpleAnyTypeDataObjectEClass.getESuperTypes().add(this.getAnyTypeDataObject()); + simpleAnyTypeDataObjectEClass.getESuperTypes().add(theXMLTypePackage.getSimpleAnyType()); + classEClass.getESuperTypes().add(theEcorePackage.getEClass()); + classEClass.getESuperTypes().add(this.getType()); + dataTypeEClass.getESuperTypes().add(theEcorePackage.getEDataType()); + dataTypeEClass.getESuperTypes().add(this.getType()); + attributeEClass.getESuperTypes().add(theEcorePackage.getEAttribute()); + attributeEClass.getESuperTypes().add(this.getProperty()); + referenceEClass.getESuperTypes().add(theEcorePackage.getEReference()); + referenceEClass.getESuperTypes().add(this.getProperty()); + enumEClass.getESuperTypes().add(theEcorePackage.getEEnum()); + enumEClass.getESuperTypes().add(this.getType()); + dynamicDataObjectEClass.getESuperTypes().add(this.getDataObject()); + storeDataObjectEClass.getESuperTypes().add(this.getDataObject()); + dynamicStoreDataObjectEClass.getESuperTypes().add(this.getStoreDataObject()); + + // 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 <b>http://www.eclipse.org/emf/2002/GenModel</b>. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected void createGenModelAnnotations() + { + String source = "http://www.eclipse.org/emf/2002/GenModel"; + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(0), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.get(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(1), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.set(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(2), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.isSet(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(3), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.unset(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(4), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.get(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(5), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.set(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(6), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.isSet(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(7), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.unset(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(8), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.get(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(9), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.set(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(10), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.isSet(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(11), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.unset(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(12), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getContainer(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(13), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getContainmentProperty(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(14), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDataGraph(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(15), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getType(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(16), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBigDecimal(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(17), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBigInteger(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(18), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBoolean(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(19), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getByte(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(20), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBytes(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(21), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getChar(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(22), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDataObject(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(23), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDate(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(24), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDouble(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(25), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getFloat(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(26), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getInt(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(27), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getList(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(28), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getLong(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(29), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getSequence(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(30), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getShort(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(31), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getString(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(32), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBigDecimal(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(33), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBigInteger(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(34), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBoolean(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(35), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setByte(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(36), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBytes(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(37), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setChar(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(38), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDataObject(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(39), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDate(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(40), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDouble(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(41), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setFloat(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(42), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setInt(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(43), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setList(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(44), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setLong(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(45), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setShort(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(46), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setString(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(47), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBigDecimal(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(48), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBigInteger(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(49), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBoolean(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(50), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getByte(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(51), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBytes(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(52), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getChar(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(53), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDataObject(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(54), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDate(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(55), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDouble(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(56), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getFloat(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(57), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getInt(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(58), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getList(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(59), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getLong(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(60), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getSequence(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(61), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getShort(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(62), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getString(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(63), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBigDecimal(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(64), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBigInteger(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(65), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBoolean(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(66), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setByte(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(67), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBytes(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(68), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setChar(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(69), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDataObject(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(70), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDate(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(71), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDouble(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(72), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setFloat(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(73), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setInt(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(74), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setList(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(75), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setLong(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(76), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setShort(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(77), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setString(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(78), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBigDecimal(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(79), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBigInteger(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(80), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBoolean(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(81), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getByte(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(82), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBytes(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(83), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getChar(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(84), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDataObject(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(85), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDate(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(86), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDouble(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(87), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getFloat(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(88), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getInt(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(89), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getList(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(90), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getLong(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(91), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getSequence(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(92), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getShort(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(93), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getString(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(94), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBigDecimal(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(95), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBigInteger(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(96), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBoolean(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(97), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setByte(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(98), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBytes(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(99), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setChar(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(100), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDataObject(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(101), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDate(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(102), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDouble(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(103), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setFloat(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(104), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setInt(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(105), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setList(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(106), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setLong(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(107), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setShort(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(108), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setString(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(109), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, propertyName);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(110), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(111), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(112), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, propertyName, namespaceURI, typeName);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(113), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, propertyIndex, namespaceURI, typeName);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(114), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, property, type);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(115), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.delete(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(116), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getSequence(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(117), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getInstanceProperties(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(118), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getProperty(this, propertyName);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(119), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getRootObject(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(120), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getChangeSummary(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(121), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.detach(this);" + }); + } + + /** + * Initializes the annotations for <b>http:///org/eclipse/emf/ecore/util/ExtendedMetaData</b>. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected void createExtendedMetaDataAnnotations() + { + String source = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData"; + addAnnotation + (anyTypeDataObjectEClass, + source, + new String[] + { + "kind", "mixed" + }); + addAnnotation + (simpleAnyTypeDataObjectEClass, + source, + new String[] + { + "kind", "simple" + }); + } + +} //SDOPackageImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/SimpleAnyTypeDataObjectImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/SimpleAnyTypeDataObjectImpl.java new file mode 100644 index 0000000000..e257e30d27 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/SimpleAnyTypeDataObjectImpl.java @@ -0,0 +1,333 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + +import java.util.Iterator; + +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.SimpleAnyTypeDataObject; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.ecore.xml.type.SimpleAnyType; +import org.eclipse.emf.ecore.xml.type.XMLTypePackage; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>EData Object Simple Any Type</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.sdo.impl.SimpleAnyTypeDataObjectImpl#getRawValue <em>Raw Value</em>}</li> + * <li>{@link org.apache.tuscany.sdo.impl.SimpleAnyTypeDataObjectImpl#getValue <em>Value</em>}</li> + * <li>{@link org.apache.tuscany.sdo.impl.SimpleAnyTypeDataObjectImpl#getInstanceType <em>Instance Type</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class SimpleAnyTypeDataObjectImpl extends AnyTypeDataObjectImpl implements SimpleAnyTypeDataObject +{ + /** + * The default value of the '{@link #getRawValue() <em>Raw Value</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getRawValue() + * @generated + * @ordered + */ + protected static final String RAW_VALUE_EDEFAULT = null; + + /** + * The default value of the '{@link #getValue() <em>Value</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getValue() + * @generated + * @ordered + */ + protected static final Object VALUE_EDEFAULT = null; + + /** + * The cached value of the '{@link #getInstanceType() <em>Instance Type</em>}' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getInstanceType() + * @generated + * @ordered + */ + protected EDataType instanceType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected SimpleAnyTypeDataObjectImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getSimpleAnyTypeDataObject(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String getRawValue() + { + StringBuffer value = new StringBuffer(); + for (Iterator i = getMixed().iterator(); i.hasNext(); ) + { + FeatureMap.Entry entry = (FeatureMap.Entry)i.next(); + if (entry.getEStructuralFeature() == XMLTypePackage.eINSTANCE.getXMLTypeDocumentRoot_Text()) + { + value.append(entry.getValue()); + } + } + return value.toString(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setRawValue(String newRawValue) + { + getMixed().clear(); + if (newRawValue != null) + { + getMixed().add(XMLTypePackage.eINSTANCE.getXMLTypeDocumentRoot_Text(), newRawValue); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Object getValue() + { + return EcoreUtil.createFromString(instanceType, getRawValue()); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setValue(Object newValue) + { + setRawValue(EcoreUtil.convertToString(instanceType, newValue)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EDataType getInstanceType() + { + return instanceType; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setInstanceType(EDataType newInstanceType) + { + EDataType oldInstanceType = instanceType; + instanceType = newInstanceType; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE, oldInstanceType, instanceType)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__MIXED: + if (coreType) return getMixed(); + return ((FeatureMap.Internal)getMixed()).getWrapper(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY: + if (coreType) return getAny(); + return ((FeatureMap.Internal)getAny()).getWrapper(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + if (coreType) return getAnyAttribute(); + return ((FeatureMap.Internal)getAnyAttribute()).getWrapper(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__RAW_VALUE: + return getRawValue(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__VALUE: + return getValue(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE: + return getInstanceType(); + } + return eDynamicGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__MIXED: + ((FeatureMap.Internal)getMixed()).set(newValue); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY: + ((FeatureMap.Internal)getAny()).set(newValue); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + ((FeatureMap.Internal)getAnyAttribute()).set(newValue); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__RAW_VALUE: + setRawValue((String)newValue); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__VALUE: + setValue((Object)newValue); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE: + setInstanceType((EDataType)newValue); + return; + } + eDynamicSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__MIXED: + getMixed().clear(); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY: + getAny().clear(); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + getAnyAttribute().clear(); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__RAW_VALUE: + setRawValue(RAW_VALUE_EDEFAULT); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__VALUE: + setValue(VALUE_EDEFAULT); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE: + setInstanceType((EDataType)null); + return; + } + eDynamicUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__MIXED: + return mixed != null && !mixed.isEmpty(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY: + return !getAny().isEmpty(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + return anyAttribute != null && !anyAttribute.isEmpty(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__RAW_VALUE: + return RAW_VALUE_EDEFAULT == null ? getRawValue() != null : !RAW_VALUE_EDEFAULT.equals(getRawValue()); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__VALUE: + return VALUE_EDEFAULT == null ? getValue() != null : !VALUE_EDEFAULT.equals(getValue()); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE: + return instanceType != null; + } + return eDynamicIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public int eBaseStructuralFeatureID(int derivedFeatureID, Class baseClass) + { + if (baseClass == SimpleAnyType.class) + { + switch (derivedFeatureID) + { + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__RAW_VALUE: return XMLTypePackage.SIMPLE_ANY_TYPE__RAW_VALUE; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__VALUE: return XMLTypePackage.SIMPLE_ANY_TYPE__VALUE; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE: return XMLTypePackage.SIMPLE_ANY_TYPE__INSTANCE_TYPE; + default: return -1; + } + } + return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) + { + if (baseClass == SimpleAnyType.class) + { + switch (baseFeatureID) + { + case XMLTypePackage.SIMPLE_ANY_TYPE__RAW_VALUE: return SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__RAW_VALUE; + case XMLTypePackage.SIMPLE_ANY_TYPE__VALUE: return SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__VALUE; + case XMLTypePackage.SIMPLE_ANY_TYPE__INSTANCE_TYPE: return SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE; + default: return -1; + } + } + return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); + } + +} //EDataObjectSimpleAnyTypeImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/StoreDataObjectImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/StoreDataObjectImpl.java new file mode 100644 index 0000000000..0cf7f3586c --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/StoreDataObjectImpl.java @@ -0,0 +1,314 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + +import org.apache.tuscany.sdo.SDOPackage; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.EStoreEObjectImpl.EStoreEList; +import org.eclipse.emf.ecore.impl.EStoreEObjectImpl.EStoreFeatureMap; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.ecore.util.FeatureMapUtil; + +import commonj.sdo.DataObject; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Store Data Object</b></em>'. + * @extends EStructuralFeature.Internal.DynamicValueHolder + * <!-- end-user-doc --> + * <p> + * </p> + * + * @generated + */ +public class StoreDataObjectImpl extends DataObjectImpl implements DataObject, EStructuralFeature.Internal.DynamicValueHolder +{ + //TODO consider factoring the eSettings code into a new base class that this and DynamicDataObjectImpl could extend + + protected static final Object [] ENO_SETTINGS = new Object [0]; + protected static final InternalEObject EUNINITIALIZED_CONTAINER = new DynamicDataObjectImpl(); + + protected Object [] eSettings; + protected InternalEObject.EStore eStore; + + /** + * Creates a store-based DataObject. + */ + public StoreDataObjectImpl() + { + super(); + eContainer = EUNINITIALIZED_CONTAINER; + } + + /** + * Creates a store-based DataObject. + */ + public StoreDataObjectImpl(InternalEObject.EStore eStore) + { + super(); + eSetStore(eStore); + eContainer = EUNINITIALIZED_CONTAINER; + } + + /** + * Creates a store-based DataObject. + */ + public StoreDataObjectImpl(EClass eClass) + { + super(); + eSetClass(eClass); + eContainer = EUNINITIALIZED_CONTAINER; + } + + /** + * Creates a store-based DataObject. + */ + public StoreDataObjectImpl(EClass eClass, InternalEObject.EStore eStore) + { + super(); + eSetClass(eClass); + eSetStore(eStore); + eContainer = EUNINITIALIZED_CONTAINER; + } + + protected boolean eIsCaching() + { + return true; + } + + public Object dynamicGet(int dynamicFeatureID) + { + Object result = eSettings[dynamicFeatureID]; + if (result == null) + { + EStructuralFeature eStructuralFeature = eDynamicFeature(dynamicFeatureID); + if (!eStructuralFeature.isTransient()) + { + if (FeatureMapUtil.isFeatureMap(eStructuralFeature)) + { + eSettings[dynamicFeatureID] = result = createFeatureMap(eStructuralFeature); + } + else if (eStructuralFeature.isMany()) + { + eSettings[dynamicFeatureID] = result = createList(eStructuralFeature); + } + else + { + result = eStore().get(this, eStructuralFeature, InternalEObject.EStore.NO_INDEX); + if (eIsCaching()) + { + eSettings[dynamicFeatureID] = result; + } + } + } + } + return result; + } + + public void dynamicSet(int dynamicFeatureID, Object value) + { + EStructuralFeature eStructuralFeature = eDynamicFeature(dynamicFeatureID); + if (eStructuralFeature.isTransient()) + { + eSettings[dynamicFeatureID] = value; + } + else + { + eStore().set(this, eStructuralFeature, InternalEObject.EStore.NO_INDEX, value == NIL ? null : value); + if (eIsCaching()) + { + eSettings[dynamicFeatureID] = value; + } + } + } + + public void dynamicUnset(int dynamicFeatureID) + { + eStore().unset(this, eDynamicFeature(dynamicFeatureID)); + eSettings[dynamicFeatureID] = null; + } + + public Object eDynamicGet(int featureID, boolean resolve, boolean coreType) + { + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + return eSettingDelegate(eFeature).dynamicGet(this, eSettings(), featureID, resolve, coreType); + } + else + { + return super.eDynamicGet(featureID, resolve, coreType); + } + } + + public void eDynamicSet(int featureID, Object newValue) + { + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + eDynamicSet(featureID, eFeature, newValue); + } + else + { + super.eDynamicSet(featureID, newValue); + } + } + + public void eDynamicUnset(int featureID) + { + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + eDynamicUnset(featureID, eFeature); + } + else + { + super.eDynamicUnset(featureID); + } + } + + public boolean eDynamicIsSet(int featureID) + { + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + return eFeature.isTransient() ? + eSettingDelegate(eFeature).dynamicIsSet(this, eSettings(), featureID) : + eStore().isSet(this, eFeature); + } + else + { + return super.eDynamicIsSet(featureID); + } + } + + /* + public boolean eDynamicIsSet(EStructuralFeature eStructuralFeature) + { + return + eStructuralFeature.isTransient() ? + super.eDynamicIsSet(eStructuralFeature) : + eStore().isSet(this, eStructuralFeature); + } + */ + + protected EList createList(EStructuralFeature eStructuralFeature) + { + return new EStoreEList(this, eStructuralFeature, eStore()); + } + + protected FeatureMap createFeatureMap(EStructuralFeature eStructuralFeature) + { + return new EStoreFeatureMap(this, eStructuralFeature, eStore()); + } + + public EObject eContainer() + { + if (eContainer == EUNINITIALIZED_CONTAINER) + { + eInitializeContainer(); + } + + return eContainer; + } + + public int eContainerFeatureID() + { + if (eContainer == EUNINITIALIZED_CONTAINER) + { + eInitializeContainer(); + } + + return eContainerFeatureID; + } + + protected void eInitializeContainer() + { + eContainer = eStore().getContainer(this); + if (eContainer != null) + { + EStructuralFeature eContainingFeature = eStore().getContainingFeature(this); + if (eContainingFeature instanceof EReference) + { + EReference eContainingReference = (EReference)eContainingFeature; + EReference eOpposite = eContainingReference.getEOpposite(); + if (eOpposite != null) + { + eContainerFeatureID = eClass().getFeatureID(eOpposite); + return; + } + } + + eContainerFeatureID = EOPPOSITE_FEATURE_BASE - eContainer.eClass().getFeatureID(eContainingFeature); + } + } + + public InternalEObject.EStore eStore() + { + return eStore; + } + + public void eSetStore(InternalEObject.EStore store) + { + this.eStore = store; + } + + protected int eStaticFeatureCount() + { + return 0; + } + + public int eDerivedStructuralFeatureID(EStructuralFeature eStructuralFeature) + { + return eClass().getFeatureID(eStructuralFeature); + } + + protected boolean eHasSettings() + { + return eSettings != null; + } + + protected EStructuralFeature.Internal.DynamicValueHolder eSettings() + { + if (eSettings == null) + { + int size = eClass().getFeatureCount() - eStaticFeatureCount(); + eSettings = size == 0 ? ENO_SETTINGS : new Object [size]; + } + + return this; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getStoreDataObject(); + } + +} //StoreDataObjectImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/BaseDataGraphType.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/BaseDataGraphType.java new file mode 100644 index 0000000000..baa0654a74 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/BaseDataGraphType.java @@ -0,0 +1,128 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model; + +import commonj.sdo.Sequence; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Base Data Graph Type</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getModels <em>Models</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getXsd <em>Xsd</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getChangeSummary <em>Change Summary</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getAnyAttribute <em>Any Attribute</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public interface BaseDataGraphType +{ + /** + * Returns the value of the '<em><b>Models</b></em>' containment reference. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Models</em>' containment reference isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Models</em>' containment reference. + * @see #setModels(ModelsType) + * @generated + */ + ModelsType getModels(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getModels <em>Models</em>}' containment reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Models</em>' containment reference. + * @see #getModels() + * @generated + */ + void setModels(ModelsType value); + + /** + * Returns the value of the '<em><b>Xsd</b></em>' containment reference. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Xsd</em>' containment reference isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Xsd</em>' containment reference. + * @see #setXsd(XSDType) + * @generated + */ + XSDType getXsd(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getXsd <em>Xsd</em>}' containment reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Xsd</em>' containment reference. + * @see #getXsd() + * @generated + */ + void setXsd(XSDType value); + + /** + * Returns the value of the '<em><b>Change Summary</b></em>' containment reference. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Change Summary</em>' containment reference isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Change Summary</em>' containment reference. + * @see #setChangeSummary(ChangeSummaryType) + * @generated + */ + ChangeSummaryType getChangeSummary_(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getChangeSummary <em>Change Summary</em>}' containment reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Change Summary</em>' containment reference. + * @see #getChangeSummary() + * @generated + */ + void setChangeSummary(ChangeSummaryType value); + + /** + * Returns the value of the '<em><b>Any Attribute</b></em>' attribute list. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Any Attribute</em>' attribute list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Any Attribute</em>' attribute list. + * @generated + */ + Sequence getAnyAttribute(); + +} // BaseDataGraphType diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/ChangeSummaryType.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/ChangeSummaryType.java new file mode 100644 index 0000000000..c22cfbc5e8 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/ChangeSummaryType.java @@ -0,0 +1,155 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model; + +import commonj.sdo.Sequence; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Change Summary Type</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.apache.tuscany.sdo.model.ChangeSummaryType#getAny <em>Any</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.ChangeSummaryType#getCreate <em>Create</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.ChangeSummaryType#getDelete <em>Delete</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.ChangeSummaryType#isLogging <em>Logging</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public interface ChangeSummaryType +{ + /** + * Returns the value of the '<em><b>Any</b></em>' attribute list. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Any</em>' attribute list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Any</em>' attribute list. + * @generated + */ + Sequence getAny(); + + /** + * Returns the value of the '<em><b>Create</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Create</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Create</em>' attribute. + * @see #setCreate(String) + * @generated + */ + String getCreate(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.ChangeSummaryType#getCreate <em>Create</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Create</em>' attribute. + * @see #getCreate() + * @generated + */ + void setCreate(String value); + + /** + * Returns the value of the '<em><b>Delete</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Delete</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Delete</em>' attribute. + * @see #setDelete(String) + * @generated + */ + String getDelete(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.ChangeSummaryType#getDelete <em>Delete</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Delete</em>' attribute. + * @see #getDelete() + * @generated + */ + void setDelete(String value); + + /** + * Returns the value of the '<em><b>Logging</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Logging</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Logging</em>' attribute. + * @see #isSetLogging() + * @see #unsetLogging() + * @see #setLogging(boolean) + * @generated + */ + boolean isLogging(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.ChangeSummaryType#isLogging <em>Logging</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Logging</em>' attribute. + * @see #isSetLogging() + * @see #unsetLogging() + * @see #isLogging() + * @generated + */ + void setLogging(boolean value); + + /** + * Unsets the value of the '{@link org.apache.tuscany.sdo.model.ChangeSummaryType#isLogging <em>Logging</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isSetLogging() + * @see #isLogging() + * @see #setLogging(boolean) + * @generated + */ + void unsetLogging(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.ChangeSummaryType#isLogging <em>Logging</em>}' attribute is set. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return whether the value of the '<em>Logging</em>' attribute is set. + * @see #unsetLogging() + * @see #isLogging() + * @see #setLogging(boolean) + * @generated + */ + boolean isSetLogging(); + +} // ChangeSummaryType diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/DataGraphType.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/DataGraphType.java new file mode 100644 index 0000000000..2c83244789 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/DataGraphType.java @@ -0,0 +1,53 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model; + +import commonj.sdo.Sequence; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Data Graph Type</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.apache.tuscany.sdo.model.DataGraphType#getAny <em>Any</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public interface DataGraphType extends BaseDataGraphType +{ + /** + * Returns the value of the '<em><b>Any</b></em>' attribute list. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Any</em>' attribute list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Any</em>' attribute list. + * @generated + */ + Sequence getAny(); + +} // DataGraphType diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/DataObject.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/DataObject.java new file mode 100644 index 0000000000..1c02e5b988 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/DataObject.java @@ -0,0 +1,33 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model; + + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Data Object</b></em>'. + * <!-- end-user-doc --> + * + * + * @generated + */ +public interface DataObject +{ +} // DataObject diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/ModelFactory.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/ModelFactory.java new file mode 100644 index 0000000000..1432d36c63 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/ModelFactory.java @@ -0,0 +1,103 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model; + + +/** + * <!-- begin-user-doc --> + * The <b>Factory</b> for the model. + * It provides a create method for each non-abstract class of the model. + * <!-- end-user-doc --> + * @generated + */ +public interface ModelFactory +{ + /** + * The singleton instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + ModelFactory INSTANCE = org.apache.tuscany.sdo.model.impl.ModelFactoryImpl.eINSTANCE; + + /** + * Returns a new object of class '<em>Change Summary Type</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Change Summary Type</em>'. + * @generated + */ + ChangeSummaryType createChangeSummaryType(); + + /** + * Returns a new object of class '<em>Data Graph Type</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Data Graph Type</em>'. + * @generated + */ + DataGraphType createDataGraphType(); + + /** + * Returns a new object of class '<em>Models Type</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Models Type</em>'. + * @generated + */ + ModelsType createModelsType(); + + /** + * Returns a new object of class '<em>Property</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Property</em>'. + * @generated + */ + Property createProperty(); + + /** + * Returns a new object of class '<em>Type</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Type</em>'. + * @generated + */ + Type createType(); + + /** + * Returns a new object of class '<em>Types</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Types</em>'. + * @generated + */ + Types createTypes(); + + /** + * Returns a new object of class '<em>XSD Type</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>XSD Type</em>'. + * @generated + */ + XSDType createXSDType(); + +} //ModelFactory diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/ModelPackage.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/ModelPackage.java new file mode 100644 index 0000000000..602e7a9403 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/ModelPackage.java @@ -0,0 +1,144 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model; + +import org.apache.tuscany.sdo.model.impl.ModelPackageImpl; +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; + +public interface ModelPackage extends EPackage { + + /** + * The package name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final String eNAME = "model"; + + /** + * The package namespace URI. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final String eNS_URI = "commonj.sdo"; + + /** + * The package namespace name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final String eNS_PREFIX = "commonj"; + + public static final ModelPackage eINSTANCE = ModelPackageImpl.eINSTANCE; + + public EClass getBaseDataGraphType(); + public EReference getBaseDataGraphType_Models(); + public EReference getBaseDataGraphType_Xsd(); + public EReference getBaseDataGraphType_ChangeSummary(); + public EAttribute getBaseDataGraphType_AnyAttribute(); + public EClass getChangeSummaryType(); + public EAttribute getChangeSummaryType_Any(); + public EAttribute getChangeSummaryType_Create(); + public EAttribute getChangeSummaryType_Delete(); + public EAttribute getChangeSummaryType_Logging(); + public EClass getDataGraphType(); + public EAttribute getDataGraphType_Any(); + public EClass getDataObject(); + public EClass getDocumentRoot(); + public EAttribute getDocumentRoot_Mixed(); + public EReference getDocumentRoot_XMLNSPrefixMap(); + public EReference getDocumentRoot_XSISchemaLocation(); + public EReference getDocumentRoot_Datagraph(); + public EReference getDocumentRoot_DataObject(); + public EReference getDocumentRoot_Type(); + public EReference getDocumentRoot_Types(); + public EAttribute getDocumentRoot_Ref(); + public EClass getModelsType(); + public EAttribute getModelsType_Any(); + public EClass getProperty(); + public EAttribute getProperty_AliasName(); + public EAttribute getProperty_Any(); + public EAttribute getProperty_Containment(); + public EAttribute getProperty_Default(); + public EAttribute getProperty_Many(); + public EAttribute getProperty_Name(); + public EReference getProperty_Opposite(); + public EAttribute getProperty_ReadOnly(); + public EReference getProperty_Type(); + public EAttribute getProperty_AnyAttribute(); + public EClass getTextType(); + public EAttribute getTextType_Text(); + public EClass getType(); + public EReference getType_BaseType(); + public EReference getType_Property(); + public EAttribute getType_AliasName(); + public EAttribute getType_Any(); + public EAttribute getType_Abstract(); + public EAttribute getType_DataType(); + public EAttribute getType_Name(); + public EAttribute getType_Open(); + public EAttribute getType_Sequenced(); + public EAttribute getType_Uri(); + public EAttribute getType_AnyAttribute(); + public EClass getTypes(); + public EReference getTypes_Type(); + public EClass getXSDType(); + public EAttribute getXSDType_Any(); + public EDataType getBoolean(); + public EDataType getBooleanObject(); + public EDataType getByte(); + public EDataType getByteObject(); + public EDataType getBytes(); + public EDataType getCharacter(); + public EDataType getCharacterObject(); + public EDataType getDate(); + public EDataType getDateTime(); + public EDataType getDay(); + public EDataType getDecimal(); + public EDataType getDouble(); + public EDataType getDoubleObject(); + public EDataType getDuration(); + public EDataType getFloat(); + public EDataType getFloatObject(); + public EDataType getInt(); + public EDataType getInteger(); + public EDataType getIntObject(); + public EDataType getLong(); + public EDataType getLongObject(); + public EDataType getMonth(); + public EDataType getMonthDay(); + public EDataType getObject(); + public EDataType getShort(); + public EDataType getShortObject(); + public EDataType getString(); + public EDataType getStrings(); + public EDataType getTime(); + public EDataType getURI(); + public EDataType getYear(); + public EDataType getYearMonth(); + public EDataType getYearMonthDay(); + public ModelFactory getModelFactory(); +} diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/ModelsType.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/ModelsType.java new file mode 100644 index 0000000000..a88e7f4f4d --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/ModelsType.java @@ -0,0 +1,59 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model; + +import commonj.sdo.Sequence; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Models Type</b></em>'. + * <!-- end-user-doc --> + * + * <!-- begin-model-doc --> + * + * Expected type is emof:Package. + * + * <!-- end-model-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.apache.tuscany.sdo.model.ModelsType#getAny <em>Any</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public interface ModelsType +{ + /** + * Returns the value of the '<em><b>Any</b></em>' attribute list. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Any</em>' attribute list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Any</em>' attribute list. + * @generated + */ + Sequence getAny(); + +} // ModelsType diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/Property.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/Property.java new file mode 100644 index 0000000000..12139ad29f --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/Property.java @@ -0,0 +1,345 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model; + +import commonj.sdo.Sequence; + +import java.util.List; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Property</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.apache.tuscany.sdo.model.Property#getAliasName <em>Alias Name</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.Property#getAny <em>Any</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.Property#isContainment <em>Containment</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.Property#getDefault <em>Default</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.Property#isMany <em>Many</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.Property#getName <em>Name</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.Property#getOpposite <em>Opposite</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.Property#isReadOnly <em>Read Only</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.Property#getType <em>Type</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.Property#getAnyAttribute <em>Any Attribute</em>}</li> + * </ul> + * </p> + * + * Note: The getDefault and getOpposite methods had to be renamed to avoid + * conflict with the commonj.sdo.Property getDefault and getOpposite + * methods in classes that implement both. Eventually, the two interfaces + * should be brought in-line with one another -- James Snell + * + * @generated + */ +public interface Property +{ + /** + * Returns the value of the '<em><b>Alias Name</b></em>' attribute list. + * The list contents are of type {@link java.lang.String}. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Alias Name</em>' attribute list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Alias Name</em>' attribute list. + * @generated + */ + List getAliasName(); + + /** + * Returns the value of the '<em><b>Any</b></em>' attribute list. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Any</em>' attribute list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Any</em>' attribute list. + * @generated + */ + Sequence getAny(); + + /** + * Returns the value of the '<em><b>Containment</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Containment</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Containment</em>' attribute. + * @see #isSetContainment() + * @see #unsetContainment() + * @see #setContainment(boolean) + * @generated + */ + boolean isContainment(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Property#isContainment <em>Containment</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Containment</em>' attribute. + * @see #isSetContainment() + * @see #unsetContainment() + * @see #isContainment() + * @generated + */ + void setContainment(boolean value); + + /** + * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Property#isContainment <em>Containment</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isSetContainment() + * @see #isContainment() + * @see #setContainment(boolean) + * @generated + */ + void unsetContainment(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Property#isContainment <em>Containment</em>}' attribute is set. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return whether the value of the '<em>Containment</em>' attribute is set. + * @see #unsetContainment() + * @see #isContainment() + * @see #setContainment(boolean) + * @generated + */ + boolean isSetContainment(); + + /** + * Returns the value of the '<em><b>Default</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Default</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Default</em>' attribute. + * @see #setDefault(String) + * @generated NOT + */ + String getDefault_(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Property#getDefault <em>Default</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Default</em>' attribute. + * @see #getDefault() + * @generated + */ + void setDefault_(String value); + + /** + * Returns the value of the '<em><b>Many</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Many</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Many</em>' attribute. + * @see #isSetMany() + * @see #unsetMany() + * @see #setMany(boolean) + * @generated + */ + boolean isMany(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Property#isMany <em>Many</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Many</em>' attribute. + * @see #isSetMany() + * @see #unsetMany() + * @see #isMany() + * @generated + */ + void setMany(boolean value); + + /** + * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Property#isMany <em>Many</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isSetMany() + * @see #isMany() + * @see #setMany(boolean) + * @generated + */ + void unsetMany(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Property#isMany <em>Many</em>}' attribute is set. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return whether the value of the '<em>Many</em>' attribute is set. + * @see #unsetMany() + * @see #isMany() + * @see #setMany(boolean) + * @generated + */ + boolean isSetMany(); + + /** + * Returns the value of the '<em><b>Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Name</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Name</em>' attribute. + * @see #setName(String) + * @generated + */ + String getName(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Property#getName <em>Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Name</em>' attribute. + * @see #getName() + * @generated + */ + void setName(String value); + + /** + * Returns the value of the '<em><b>Opposite</b></em>' reference. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Opposite</em>' reference isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Opposite</em>' reference. + * @see #setOpposite(Property) + * @generated + */ + Property getOpposite_(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Property#getOpposite <em>Opposite</em>}' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Opposite</em>' reference. + * @see #getOpposite() + * @generated + */ + void setOpposite_(Property value); + + /** + * Returns the value of the '<em><b>Read Only</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Read Only</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Read Only</em>' attribute. + * @see #isSetReadOnly() + * @see #unsetReadOnly() + * @see #setReadOnly(boolean) + * @generated + */ + boolean isReadOnly(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Property#isReadOnly <em>Read Only</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Read Only</em>' attribute. + * @see #isSetReadOnly() + * @see #unsetReadOnly() + * @see #isReadOnly() + * @generated + */ + void setReadOnly(boolean value); + + /** + * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Property#isReadOnly <em>Read Only</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isSetReadOnly() + * @see #isReadOnly() + * @see #setReadOnly(boolean) + * @generated + */ + void unsetReadOnly(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Property#isReadOnly <em>Read Only</em>}' attribute is set. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return whether the value of the '<em>Read Only</em>' attribute is set. + * @see #unsetReadOnly() + * @see #isReadOnly() + * @see #setReadOnly(boolean) + * @generated + */ + boolean isSetReadOnly(); + + /** + * Returns the value of the '<em><b>Type</b></em>' reference. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Type</em>' reference isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Type</em>' reference. + * @see #setType(Type) + * @generated + */ + Type getType_(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Property#getType <em>Type</em>}' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Type</em>' reference. + * @see #getType() + * @generated + */ + void setType(Type value); + + /** + * Returns the value of the '<em><b>Any Attribute</b></em>' attribute list. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Any Attribute</em>' attribute list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Any Attribute</em>' attribute list. + * @generated + */ + Sequence getAnyAttribute(); + +} // Property diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/TextType.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/TextType.java new file mode 100644 index 0000000000..74a1176647 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/TextType.java @@ -0,0 +1,54 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model; + +import java.util.List; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Text Type</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.apache.tuscany.sdo.model.TextType#getText <em>Text</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public interface TextType +{ + /** + * Returns the value of the '<em><b>Text</b></em>' attribute list. + * The list contents are of type {@link java.lang.String}. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Text</em>' attribute list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Text</em>' attribute list. + * @generated + */ + List getText(); + +} // TextType diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/Type.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/Type.java new file mode 100644 index 0000000000..12f7043bb8 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/Type.java @@ -0,0 +1,374 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model; + +import commonj.sdo.Sequence; + +import java.util.List; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Type</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.apache.tuscany.sdo.model.Type#getBaseType <em>Base Type</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.Type#getProperty <em>Property</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.Type#getAliasName <em>Alias Name</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.Type#getAny <em>Any</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.Type#isAbstract <em>Abstract</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.Type#isDataType <em>Data Type</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.Type#getName <em>Name</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.Type#isOpen <em>Open</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.Type#isSequenced <em>Sequenced</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.Type#getUri <em>Uri</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.Type#getAnyAttribute <em>Any Attribute</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public interface Type +{ + /** + * Returns the value of the '<em><b>Base Type</b></em>' reference list. + * The list contents are of type {@link org.apache.tuscany.sdo.model.Type}. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Base Type</em>' reference list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Base Type</em>' reference list. + * @generated + */ + List getBaseType(); + + /** + * Returns the value of the '<em><b>Property</b></em>' containment reference list. + * The list contents are of type {@link org.apache.tuscany.sdo.model.Property}. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Property</em>' containment reference list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Property</em>' containment reference list. + * @generated + */ + List getProperty(); + + /** + * Returns the value of the '<em><b>Alias Name</b></em>' attribute list. + * The list contents are of type {@link java.lang.String}. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Alias Name</em>' attribute list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Alias Name</em>' attribute list. + * @generated + */ + List getAliasName(); + + /** + * Returns the value of the '<em><b>Any</b></em>' attribute list. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Any</em>' attribute list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Any</em>' attribute list. + * @generated + */ + Sequence getAny(); + + /** + * Returns the value of the '<em><b>Abstract</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Abstract</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Abstract</em>' attribute. + * @see #isSetAbstract() + * @see #unsetAbstract() + * @see #setAbstract(boolean) + * @generated + */ + boolean isAbstract(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Type#isAbstract <em>Abstract</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Abstract</em>' attribute. + * @see #isSetAbstract() + * @see #unsetAbstract() + * @see #isAbstract() + * @generated + */ + void setAbstract(boolean value); + + /** + * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Type#isAbstract <em>Abstract</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isSetAbstract() + * @see #isAbstract() + * @see #setAbstract(boolean) + * @generated + */ + void unsetAbstract(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Type#isAbstract <em>Abstract</em>}' attribute is set. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return whether the value of the '<em>Abstract</em>' attribute is set. + * @see #unsetAbstract() + * @see #isAbstract() + * @see #setAbstract(boolean) + * @generated + */ + boolean isSetAbstract(); + + /** + * Returns the value of the '<em><b>Data Type</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Data Type</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Data Type</em>' attribute. + * @see #isSetDataType() + * @see #unsetDataType() + * @see #setDataType(boolean) + * @generated + */ + boolean isDataType(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Type#isDataType <em>Data Type</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Data Type</em>' attribute. + * @see #isSetDataType() + * @see #unsetDataType() + * @see #isDataType() + * @generated + */ + void setDataType(boolean value); + + /** + * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Type#isDataType <em>Data Type</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isSetDataType() + * @see #isDataType() + * @see #setDataType(boolean) + * @generated + */ + void unsetDataType(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Type#isDataType <em>Data Type</em>}' attribute is set. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return whether the value of the '<em>Data Type</em>' attribute is set. + * @see #unsetDataType() + * @see #isDataType() + * @see #setDataType(boolean) + * @generated + */ + boolean isSetDataType(); + + /** + * Returns the value of the '<em><b>Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Name</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Name</em>' attribute. + * @see #setName(String) + * @generated + */ + String getName(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Type#getName <em>Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Name</em>' attribute. + * @see #getName() + * @generated + */ + void setName(String value); + + /** + * Returns the value of the '<em><b>Open</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Open</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Open</em>' attribute. + * @see #isSetOpen() + * @see #unsetOpen() + * @see #setOpen(boolean) + * @generated + */ + boolean isOpen(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Type#isOpen <em>Open</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Open</em>' attribute. + * @see #isSetOpen() + * @see #unsetOpen() + * @see #isOpen() + * @generated + */ + void setOpen(boolean value); + + /** + * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Type#isOpen <em>Open</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isSetOpen() + * @see #isOpen() + * @see #setOpen(boolean) + * @generated + */ + void unsetOpen(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Type#isOpen <em>Open</em>}' attribute is set. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return whether the value of the '<em>Open</em>' attribute is set. + * @see #unsetOpen() + * @see #isOpen() + * @see #setOpen(boolean) + * @generated + */ + boolean isSetOpen(); + + /** + * Returns the value of the '<em><b>Sequenced</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Sequenced</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Sequenced</em>' attribute. + * @see #isSetSequenced() + * @see #unsetSequenced() + * @see #setSequenced(boolean) + * @generated + */ + boolean isSequenced(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Type#isSequenced <em>Sequenced</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Sequenced</em>' attribute. + * @see #isSetSequenced() + * @see #unsetSequenced() + * @see #isSequenced() + * @generated + */ + void setSequenced(boolean value); + + /** + * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Type#isSequenced <em>Sequenced</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isSetSequenced() + * @see #isSequenced() + * @see #setSequenced(boolean) + * @generated + */ + void unsetSequenced(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Type#isSequenced <em>Sequenced</em>}' attribute is set. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return whether the value of the '<em>Sequenced</em>' attribute is set. + * @see #unsetSequenced() + * @see #isSequenced() + * @see #setSequenced(boolean) + * @generated + */ + boolean isSetSequenced(); + + /** + * Returns the value of the '<em><b>Uri</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Uri</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Uri</em>' attribute. + * @see #setUri(String) + * @generated + */ + String getUri(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Type#getUri <em>Uri</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Uri</em>' attribute. + * @see #getUri() + * @generated + */ + void setUri(String value); + + /** + * Returns the value of the '<em><b>Any Attribute</b></em>' attribute list. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Any Attribute</em>' attribute list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Any Attribute</em>' attribute list. + * @generated + */ + Sequence getAnyAttribute(); + + String getInstanceClassName(); + +} // Type diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/Types.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/Types.java new file mode 100644 index 0000000000..4fa53f5bf9 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/Types.java @@ -0,0 +1,56 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model; + +import java.util.List; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Types</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.apache.tuscany.sdo.model.Types#getType <em>Type</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public interface Types +{ + /** + * Returns the value of the '<em><b>Type</b></em>' containment reference list. + * The list contents are of type {@link org.apache.tuscany.sdo.model.Type}. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Type</em>' containment reference list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Type</em>' containment reference list. + * @generated + */ + List getType_(); + + List getTypeList(); + +} // Types diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/XSDType.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/XSDType.java new file mode 100644 index 0000000000..1e818adb30 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/XSDType.java @@ -0,0 +1,59 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model; + +import commonj.sdo.Sequence; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>XSD Type</b></em>'. + * <!-- end-user-doc --> + * + * <!-- begin-model-doc --> + * + * Expected type is xsd:schema. + * + * <!-- end-model-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.apache.tuscany.sdo.model.XSDType#getAny <em>Any</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public interface XSDType +{ + /** + * Returns the value of the '<em><b>Any</b></em>' attribute list. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Any</em>' attribute list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Any</em>' attribute list. + * @generated + */ + Sequence getAny(); + +} // XSDType diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/BaseDataGraphTypeImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/BaseDataGraphTypeImpl.java new file mode 100644 index 0000000000..23d631b925 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/BaseDataGraphTypeImpl.java @@ -0,0 +1,411 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model.impl; + +import commonj.sdo.Sequence; + + +import org.apache.tuscany.sdo.impl.DataObjectImpl; +import org.apache.tuscany.sdo.model.BaseDataGraphType; +import org.apache.tuscany.sdo.model.ChangeSummaryType; +import org.apache.tuscany.sdo.model.ModelsType; +import org.apache.tuscany.sdo.model.XSDType; + +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.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; + +import org.eclipse.emf.ecore.util.BasicFeatureMap; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Base Data Graph Type</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.sdo.model.impl.BaseDataGraphTypeImpl#getModels <em>Models</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.BaseDataGraphTypeImpl#getXsd <em>Xsd</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.BaseDataGraphTypeImpl#getChangeSummary <em>Change Summary</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.BaseDataGraphTypeImpl#getAnyAttribute <em>Any Attribute</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public abstract class BaseDataGraphTypeImpl extends DataObjectImpl implements BaseDataGraphType +{ + /** + * The cached value of the '{@link #getModels() <em>Models</em>}' containment reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getModels() + * @generated + * @ordered + */ + protected ModelsType models = null; + + /** + * The cached value of the '{@link #getXsd() <em>Xsd</em>}' containment reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getXsd() + * @generated + * @ordered + */ + protected XSDType xsd = null; + + /** + * The cached value of the '{@link #getChangeSummary() <em>Change Summary</em>}' containment reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getChangeSummary() + * @generated + * @ordered + */ + protected ChangeSummaryType changeSummary = null; + + /** + * The cached value of the '{@link #getAnyAttribute() <em>Any Attribute</em>}' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getAnyAttribute() + * @generated + * @ordered + */ + protected BasicSequence anyAttribute = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected BaseDataGraphTypeImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return ModelPackageImpl.Literals.BASE_DATA_GRAPH_TYPE; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ModelsType getModels() + { + return models; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain basicSetModels(ModelsType newModels, NotificationChain msgs) + { + ModelsType oldModels = models; + models = newModels; + if (eNotificationRequired()) + { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelPackageImpl.BASE_DATA_GRAPH_TYPE__MODELS, oldModels, newModels); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setModels(ModelsType newModels) + { + if (newModels != models) + { + NotificationChain msgs = null; + if (models != null) + msgs = ((InternalEObject)models).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ModelPackageImpl.BASE_DATA_GRAPH_TYPE__MODELS, null, msgs); + if (newModels != null) + msgs = ((InternalEObject)newModels).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ModelPackageImpl.BASE_DATA_GRAPH_TYPE__MODELS, null, msgs); + msgs = basicSetModels(newModels, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ModelPackageImpl.BASE_DATA_GRAPH_TYPE__MODELS, newModels, newModels)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public XSDType getXsd() + { + return xsd; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain basicSetXsd(XSDType newXsd, NotificationChain msgs) + { + XSDType oldXsd = xsd; + xsd = newXsd; + if (eNotificationRequired()) + { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelPackageImpl.BASE_DATA_GRAPH_TYPE__XSD, oldXsd, newXsd); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setXsd(XSDType newXsd) + { + if (newXsd != xsd) + { + NotificationChain msgs = null; + if (xsd != null) + msgs = ((InternalEObject)xsd).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ModelPackageImpl.BASE_DATA_GRAPH_TYPE__XSD, null, msgs); + if (newXsd != null) + msgs = ((InternalEObject)newXsd).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ModelPackageImpl.BASE_DATA_GRAPH_TYPE__XSD, null, msgs); + msgs = basicSetXsd(newXsd, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ModelPackageImpl.BASE_DATA_GRAPH_TYPE__XSD, newXsd, newXsd)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ChangeSummaryType getChangeSummary_() + { + return changeSummary; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain basicSetChangeSummary(ChangeSummaryType newChangeSummary, NotificationChain msgs) + { + ChangeSummaryType oldChangeSummary = changeSummary; + changeSummary = newChangeSummary; + if (eNotificationRequired()) + { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ModelPackageImpl.BASE_DATA_GRAPH_TYPE__CHANGE_SUMMARY, oldChangeSummary, newChangeSummary); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setChangeSummary(ChangeSummaryType newChangeSummary) + { + if (newChangeSummary != changeSummary) + { + NotificationChain msgs = null; + if (changeSummary != null) + msgs = ((InternalEObject)changeSummary).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - ModelPackageImpl.BASE_DATA_GRAPH_TYPE__CHANGE_SUMMARY, null, msgs); + if (newChangeSummary != null) + msgs = ((InternalEObject)newChangeSummary).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - ModelPackageImpl.BASE_DATA_GRAPH_TYPE__CHANGE_SUMMARY, null, msgs); + msgs = basicSetChangeSummary(newChangeSummary, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ModelPackageImpl.BASE_DATA_GRAPH_TYPE__CHANGE_SUMMARY, newChangeSummary, newChangeSummary)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Sequence getAnyAttribute() + { + if (anyAttribute == null) + { + anyAttribute = new BasicSequence(new BasicFeatureMap(this, ModelPackageImpl.BASE_DATA_GRAPH_TYPE__ANY_ATTRIBUTE)); + } + return anyAttribute; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) + { + switch (featureID) + { + case ModelPackageImpl.BASE_DATA_GRAPH_TYPE__MODELS: + return basicSetModels(null, msgs); + case ModelPackageImpl.BASE_DATA_GRAPH_TYPE__XSD: + return basicSetXsd(null, msgs); + case ModelPackageImpl.BASE_DATA_GRAPH_TYPE__CHANGE_SUMMARY: + return basicSetChangeSummary(null, msgs); + case ModelPackageImpl.BASE_DATA_GRAPH_TYPE__ANY_ATTRIBUTE: + return ((InternalEList)((FeatureMap.Internal.Wrapper)getAnyAttribute()).featureMap()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case ModelPackageImpl.BASE_DATA_GRAPH_TYPE__MODELS: + return getModels(); + case ModelPackageImpl.BASE_DATA_GRAPH_TYPE__XSD: + return getXsd(); + case ModelPackageImpl.BASE_DATA_GRAPH_TYPE__CHANGE_SUMMARY: + return getChangeSummary(); + case ModelPackageImpl.BASE_DATA_GRAPH_TYPE__ANY_ATTRIBUTE: + if (coreType) return ((FeatureMap.Internal.Wrapper)getAnyAttribute()).featureMap(); + return getAnyAttribute(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case ModelPackageImpl.BASE_DATA_GRAPH_TYPE__MODELS: + setModels((ModelsType)newValue); + return; + case ModelPackageImpl.BASE_DATA_GRAPH_TYPE__XSD: + setXsd((XSDType)newValue); + return; + case ModelPackageImpl.BASE_DATA_GRAPH_TYPE__CHANGE_SUMMARY: + setChangeSummary((ChangeSummaryType)newValue); + return; + case ModelPackageImpl.BASE_DATA_GRAPH_TYPE__ANY_ATTRIBUTE: + ((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)getAnyAttribute()).featureMap()).set(newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case ModelPackageImpl.BASE_DATA_GRAPH_TYPE__MODELS: + setModels((ModelsType)null); + return; + case ModelPackageImpl.BASE_DATA_GRAPH_TYPE__XSD: + setXsd((XSDType)null); + return; + case ModelPackageImpl.BASE_DATA_GRAPH_TYPE__CHANGE_SUMMARY: + setChangeSummary((ChangeSummaryType)null); + return; + case ModelPackageImpl.BASE_DATA_GRAPH_TYPE__ANY_ATTRIBUTE: + ((FeatureMap.Internal.Wrapper)getAnyAttribute()).featureMap().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case ModelPackageImpl.BASE_DATA_GRAPH_TYPE__MODELS: + return models != null; + case ModelPackageImpl.BASE_DATA_GRAPH_TYPE__XSD: + return xsd != null; + case ModelPackageImpl.BASE_DATA_GRAPH_TYPE__CHANGE_SUMMARY: + return changeSummary != null; + case ModelPackageImpl.BASE_DATA_GRAPH_TYPE__ANY_ATTRIBUTE: + return anyAttribute != null && !anyAttribute.featureMap().isEmpty(); + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (anyAttribute: "); + result.append(anyAttribute); + result.append(')'); + return result.toString(); + } + +} //BaseDataGraphTypeImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ChangeSummaryTypeImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ChangeSummaryTypeImpl.java new file mode 100644 index 0000000000..047b35adb6 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ChangeSummaryTypeImpl.java @@ -0,0 +1,399 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model.impl; + +import commonj.sdo.Sequence; + + +import org.apache.tuscany.sdo.impl.DataObjectImpl; +import org.apache.tuscany.sdo.model.ChangeSummaryType; + +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.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; + +import org.eclipse.emf.ecore.util.BasicFeatureMap; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Change Summary Type</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.sdo.model.impl.ChangeSummaryTypeImpl#getAny <em>Any</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.ChangeSummaryTypeImpl#getCreate <em>Create</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.ChangeSummaryTypeImpl#getDelete <em>Delete</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.ChangeSummaryTypeImpl#isLogging <em>Logging</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class ChangeSummaryTypeImpl extends DataObjectImpl implements ChangeSummaryType +{ + /** + * The cached value of the '{@link #getAny() <em>Any</em>}' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getAny() + * @generated + * @ordered + */ + protected BasicSequence any = null; + + /** + * The default value of the '{@link #getCreate() <em>Create</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getCreate() + * @generated + * @ordered + */ + protected static final String CREATE_EDEFAULT = null; + + /** + * The cached value of the '{@link #getCreate() <em>Create</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getCreate() + * @generated + * @ordered + */ + protected String create = CREATE_EDEFAULT; + + /** + * The default value of the '{@link #getDelete() <em>Delete</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getDelete() + * @generated + * @ordered + */ + protected static final String DELETE_EDEFAULT = null; + + /** + * The cached value of the '{@link #getDelete() <em>Delete</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getDelete() + * @generated + * @ordered + */ + protected String delete = DELETE_EDEFAULT; + + /** + * The default value of the '{@link #isLogging() <em>Logging</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isLogging() + * @generated + * @ordered + */ + protected static final boolean LOGGING_EDEFAULT = false; + + /** + * The cached value of the '{@link #isLogging() <em>Logging</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isLogging() + * @generated + * @ordered + */ + protected boolean logging = LOGGING_EDEFAULT; + + /** + * This is true if the Logging attribute has been set. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + protected boolean loggingESet = false; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected ChangeSummaryTypeImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return ModelPackageImpl.Literals.CHANGE_SUMMARY_TYPE; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Sequence getAny() + { + if (any == null) + { + any = new BasicSequence(new BasicFeatureMap(this, ModelPackageImpl.CHANGE_SUMMARY_TYPE__ANY)); + } + return any; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getCreate() + { + return create; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setCreate(String newCreate) + { + String oldCreate = create; + create = newCreate; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ModelPackageImpl.CHANGE_SUMMARY_TYPE__CREATE, oldCreate, create)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getDelete() + { + return delete; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setDelete(String newDelete) + { + String oldDelete = delete; + delete = newDelete; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ModelPackageImpl.CHANGE_SUMMARY_TYPE__DELETE, oldDelete, delete)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isLogging() + { + return logging; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setLogging(boolean newLogging) + { + boolean oldLogging = logging; + logging = newLogging; + boolean oldLoggingESet = loggingESet; + loggingESet = true; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ModelPackageImpl.CHANGE_SUMMARY_TYPE__LOGGING, oldLogging, logging, !oldLoggingESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void unsetLogging() + { + boolean oldLogging = logging; + boolean oldLoggingESet = loggingESet; + logging = LOGGING_EDEFAULT; + loggingESet = false; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.UNSET, ModelPackageImpl.CHANGE_SUMMARY_TYPE__LOGGING, oldLogging, LOGGING_EDEFAULT, oldLoggingESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isSetLogging() + { + return loggingESet; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) + { + switch (featureID) + { + case ModelPackageImpl.CHANGE_SUMMARY_TYPE__ANY: + return ((InternalEList)((FeatureMap.Internal.Wrapper)getAny()).featureMap()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case ModelPackageImpl.CHANGE_SUMMARY_TYPE__ANY: + if (coreType) return ((FeatureMap.Internal.Wrapper)getAny()).featureMap(); + return getAny(); + case ModelPackageImpl.CHANGE_SUMMARY_TYPE__CREATE: + return getCreate(); + case ModelPackageImpl.CHANGE_SUMMARY_TYPE__DELETE: + return getDelete(); + case ModelPackageImpl.CHANGE_SUMMARY_TYPE__LOGGING: + return isLogging() ? Boolean.TRUE : Boolean.FALSE; + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case ModelPackageImpl.CHANGE_SUMMARY_TYPE__ANY: + ((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)getAny()).featureMap()).set(newValue); + return; + case ModelPackageImpl.CHANGE_SUMMARY_TYPE__CREATE: + setCreate((String)newValue); + return; + case ModelPackageImpl.CHANGE_SUMMARY_TYPE__DELETE: + setDelete((String)newValue); + return; + case ModelPackageImpl.CHANGE_SUMMARY_TYPE__LOGGING: + setLogging(((Boolean)newValue).booleanValue()); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case ModelPackageImpl.CHANGE_SUMMARY_TYPE__ANY: + ((FeatureMap.Internal.Wrapper)getAny()).featureMap().clear(); + return; + case ModelPackageImpl.CHANGE_SUMMARY_TYPE__CREATE: + setCreate(CREATE_EDEFAULT); + return; + case ModelPackageImpl.CHANGE_SUMMARY_TYPE__DELETE: + setDelete(DELETE_EDEFAULT); + return; + case ModelPackageImpl.CHANGE_SUMMARY_TYPE__LOGGING: + unsetLogging(); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case ModelPackageImpl.CHANGE_SUMMARY_TYPE__ANY: + return any != null && !any.featureMap().isEmpty(); + case ModelPackageImpl.CHANGE_SUMMARY_TYPE__CREATE: + return CREATE_EDEFAULT == null ? create != null : !CREATE_EDEFAULT.equals(create); + case ModelPackageImpl.CHANGE_SUMMARY_TYPE__DELETE: + return DELETE_EDEFAULT == null ? delete != null : !DELETE_EDEFAULT.equals(delete); + case ModelPackageImpl.CHANGE_SUMMARY_TYPE__LOGGING: + return isSetLogging(); + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (any: "); + result.append(any); + result.append(", create: "); + result.append(create); + result.append(", delete: "); + result.append(delete); + result.append(", logging: "); + if (loggingESet) result.append(logging); else result.append("<unset>"); + result.append(')'); + return result.toString(); + } + +} //ChangeSummaryTypeImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/DataGraphTypeImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/DataGraphTypeImpl.java new file mode 100644 index 0000000000..0e166165a0 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/DataGraphTypeImpl.java @@ -0,0 +1,190 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model.impl; + +import commonj.sdo.Sequence; + + +import org.apache.tuscany.sdo.model.DataGraphType; +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; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Data Graph Type</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.sdo.model.impl.DataGraphTypeImpl#getAny <em>Any</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class DataGraphTypeImpl extends BaseDataGraphTypeImpl implements DataGraphType +{ + /** + * The cached value of the '{@link #getAny() <em>Any</em>}' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getAny() + * @generated + * @ordered + */ + protected BasicSequence any = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected DataGraphTypeImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return ModelPackageImpl.Literals.DATA_GRAPH_TYPE; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Sequence getAny() + { + if (any == null) + { + any = new BasicSequence(new BasicFeatureMap(this, ModelPackageImpl.DATA_GRAPH_TYPE__ANY)); + } + return any; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) + { + switch (featureID) + { + case ModelPackageImpl.DATA_GRAPH_TYPE__ANY: + return ((InternalEList)((FeatureMap.Internal.Wrapper)getAny()).featureMap()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case ModelPackageImpl.DATA_GRAPH_TYPE__ANY: + if (coreType) return ((FeatureMap.Internal.Wrapper)getAny()).featureMap(); + return getAny(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case ModelPackageImpl.DATA_GRAPH_TYPE__ANY: + ((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)getAny()).featureMap()).set(newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case ModelPackageImpl.DATA_GRAPH_TYPE__ANY: + ((FeatureMap.Internal.Wrapper)getAny()).featureMap().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case ModelPackageImpl.DATA_GRAPH_TYPE__ANY: + return any != null && !any.featureMap().isEmpty(); + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (any: "); + result.append(any); + result.append(')'); + return result.toString(); + } + +} //DataGraphTypeImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/DataObjectImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/DataObjectImpl.java new file mode 100644 index 0000000000..d40c7cced4 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/DataObjectImpl.java @@ -0,0 +1,57 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model.impl; + +import org.apache.tuscany.sdo.model.DataObject; + +import org.eclipse.emf.ecore.EClass; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Data Object</b></em>'. + * <!-- end-user-doc --> + * <p> + * </p> + * + * @generated + */ +public abstract class DataObjectImpl extends org.apache.tuscany.sdo.impl.DataObjectImpl implements DataObject +{ + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected DataObjectImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return ModelPackageImpl.Literals.DATA_OBJECT; + } + +} //DataObjectImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ModelFactoryImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ModelFactoryImpl.java new file mode 100644 index 0000000000..7bf9052a89 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ModelFactoryImpl.java @@ -0,0 +1,1108 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model.impl; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.List; +import java.util.TimeZone; + +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.model.ChangeSummaryType; +import org.apache.tuscany.sdo.model.DataGraphType; +import org.apache.tuscany.sdo.model.ModelFactory; +import org.apache.tuscany.sdo.model.ModelsType; +import org.apache.tuscany.sdo.model.Property; +import org.apache.tuscany.sdo.model.Type; +import org.apache.tuscany.sdo.model.Types; +import org.apache.tuscany.sdo.model.XSDType; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.impl.EFactoryImpl; +import org.eclipse.emf.ecore.plugin.EcorePlugin; +import org.eclipse.emf.ecore.xml.type.XMLTypeFactory; + +import commonj.sdo.helper.DataHelper; + +/** + * <!-- begin-user-doc --> + * An implementation of the model <b>Factory</b>. + * <!-- end-user-doc --> + * @generated + */ +public class ModelFactoryImpl extends EFactoryImpl implements ModelFactory +{ + /** + * The singleton instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final ModelFactoryImpl eINSTANCE = init(); + + /** + * Creates the default factory implementation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static ModelFactoryImpl init() + { + try + { + ModelFactoryImpl theModelFactory = (ModelFactoryImpl)EPackage.Registry.INSTANCE.getEFactory("commonj.sdo"); + if (theModelFactory != null) + { + return theModelFactory; + } + } + catch (Exception exception) + { + EcorePlugin.INSTANCE.log(exception); + } + return new ModelFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ModelFactoryImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EObject createGen(EClass eClass) + { + switch (eClass.getClassifierID()) + { + case ModelPackageImpl.CHANGE_SUMMARY_TYPE: return (EObject)createChangeSummaryType(); + case ModelPackageImpl.DATA_GRAPH_TYPE: return (EObject)createDataGraphType(); + case ModelPackageImpl.DOCUMENT_ROOT: return (EObject)createDocumentRoot(); + case ModelPackageImpl.MODELS_TYPE: return (EObject)createModelsType(); + case ModelPackageImpl.PROPERTY: return (EObject)createProperty(); + case ModelPackageImpl.TYPE: return (EObject)createType(); + case ModelPackageImpl.TYPES: return (EObject)createTypes(); + case ModelPackageImpl.XSD_TYPE: return (EObject)createXSDType(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + public EObject create(EClass eClass) + { + if (eClass.getClassifierID() == ModelPackageImpl.DATA_OBJECT) return SDOFactory.eINSTANCE.createAnyTypeDataObject(); + return createGen(eClass); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object createFromString(EDataType eDataType, String initialValue) + { + switch (eDataType.getClassifierID()) + { + case ModelPackageImpl.BOOLEAN: + return createBooleanFromString(eDataType, initialValue); + case ModelPackageImpl.BOOLEAN_OBJECT: + return createBooleanObjectFromString(eDataType, initialValue); + case ModelPackageImpl.BYTE: + return createByteFromString(eDataType, initialValue); + case ModelPackageImpl.BYTE_OBJECT: + return createByteObjectFromString(eDataType, initialValue); + case ModelPackageImpl.BYTES: + return createBytesFromString(eDataType, initialValue); + case ModelPackageImpl.CHARACTER: + return createCharacterFromString(eDataType, initialValue); + case ModelPackageImpl.CHARACTER_OBJECT: + return createCharacterObjectFromString(eDataType, initialValue); + case ModelPackageImpl.DATE: + return createDateFromString(eDataType, initialValue); + case ModelPackageImpl.DATE_TIME: + return createDateTimeFromString(eDataType, initialValue); + case ModelPackageImpl.DAY: + return createDayFromString(eDataType, initialValue); + case ModelPackageImpl.DECIMAL: + return createDecimalFromString(eDataType, initialValue); + case ModelPackageImpl.DOUBLE: + return createDoubleFromString(eDataType, initialValue); + case ModelPackageImpl.DOUBLE_OBJECT: + return createDoubleObjectFromString(eDataType, initialValue); + case ModelPackageImpl.DURATION: + return createDurationFromString(eDataType, initialValue); + case ModelPackageImpl.FLOAT: + return createFloatFromString(eDataType, initialValue); + case ModelPackageImpl.FLOAT_OBJECT: + return createFloatObjectFromString(eDataType, initialValue); + case ModelPackageImpl.INT: + return createIntFromString(eDataType, initialValue); + case ModelPackageImpl.INTEGER: + return createIntegerFromString(eDataType, initialValue); + case ModelPackageImpl.INT_OBJECT: + return createIntObjectFromString(eDataType, initialValue); + case ModelPackageImpl.LONG: + return createLongFromString(eDataType, initialValue); + case ModelPackageImpl.LONG_OBJECT: + return createLongObjectFromString(eDataType, initialValue); + case ModelPackageImpl.MONTH: + return createMonthFromString(eDataType, initialValue); + case ModelPackageImpl.MONTH_DAY: + return createMonthDayFromString(eDataType, initialValue); + case ModelPackageImpl.OBJECT: + return createObjectFromString(eDataType, initialValue); + case ModelPackageImpl.SHORT: + return createShortFromString(eDataType, initialValue); + case ModelPackageImpl.SHORT_OBJECT: + return createShortObjectFromString(eDataType, initialValue); + case ModelPackageImpl.STRING: + return createStringFromString(eDataType, initialValue); + case ModelPackageImpl.STRINGS: + return createStringsFromString(eDataType, initialValue); + case ModelPackageImpl.TIME: + return createTimeFromString(eDataType, initialValue); + case ModelPackageImpl.URI: + return createURIFromString(eDataType, initialValue); + case ModelPackageImpl.YEAR: + return createYearFromString(eDataType, initialValue); + case ModelPackageImpl.YEAR_MONTH: + return createYearMonthFromString(eDataType, initialValue); + case ModelPackageImpl.YEAR_MONTH_DAY: + return createYearMonthDayFromString(eDataType, initialValue); + default: + throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String convertToString(EDataType eDataType, Object instanceValue) + { + switch (eDataType.getClassifierID()) + { + case ModelPackageImpl.BOOLEAN: + return convertBooleanToString(eDataType, instanceValue); + case ModelPackageImpl.BOOLEAN_OBJECT: + return convertBooleanObjectToString(eDataType, instanceValue); + case ModelPackageImpl.BYTE: + return convertByteToString(eDataType, instanceValue); + case ModelPackageImpl.BYTE_OBJECT: + return convertByteObjectToString(eDataType, instanceValue); + case ModelPackageImpl.BYTES: + return convertBytesToString(eDataType, instanceValue); + case ModelPackageImpl.CHARACTER: + return convertCharacterToString(eDataType, instanceValue); + case ModelPackageImpl.CHARACTER_OBJECT: + return convertCharacterObjectToString(eDataType, instanceValue); + case ModelPackageImpl.DATE: + return convertDateToString(eDataType, instanceValue); + case ModelPackageImpl.DATE_TIME: + return convertDateTimeToString(eDataType, instanceValue); + case ModelPackageImpl.DAY: + return convertDayToString(eDataType, instanceValue); + case ModelPackageImpl.DECIMAL: + return convertDecimalToString(eDataType, instanceValue); + case ModelPackageImpl.DOUBLE: + return convertDoubleToString(eDataType, instanceValue); + case ModelPackageImpl.DOUBLE_OBJECT: + return convertDoubleObjectToString(eDataType, instanceValue); + case ModelPackageImpl.DURATION: + return convertDurationToString(eDataType, instanceValue); + case ModelPackageImpl.FLOAT: + return convertFloatToString(eDataType, instanceValue); + case ModelPackageImpl.FLOAT_OBJECT: + return convertFloatObjectToString(eDataType, instanceValue); + case ModelPackageImpl.INT: + return convertIntToString(eDataType, instanceValue); + case ModelPackageImpl.INTEGER: + return convertIntegerToString(eDataType, instanceValue); + case ModelPackageImpl.INT_OBJECT: + return convertIntObjectToString(eDataType, instanceValue); + case ModelPackageImpl.LONG: + return convertLongToString(eDataType, instanceValue); + case ModelPackageImpl.LONG_OBJECT: + return convertLongObjectToString(eDataType, instanceValue); + case ModelPackageImpl.MONTH: + return convertMonthToString(eDataType, instanceValue); + case ModelPackageImpl.MONTH_DAY: + return convertMonthDayToString(eDataType, instanceValue); + case ModelPackageImpl.OBJECT: + return convertObjectToString(eDataType, instanceValue); + case ModelPackageImpl.SHORT: + return convertShortToString(eDataType, instanceValue); + case ModelPackageImpl.SHORT_OBJECT: + return convertShortObjectToString(eDataType, instanceValue); + case ModelPackageImpl.STRING: + return convertStringToString(eDataType, instanceValue); + case ModelPackageImpl.STRINGS: + return convertStringsToString(eDataType, instanceValue); + case ModelPackageImpl.TIME: + return convertTimeToString(eDataType, instanceValue); + case ModelPackageImpl.URI: + return convertURIToString(eDataType, instanceValue); + case ModelPackageImpl.YEAR: + return convertYearToString(eDataType, instanceValue); + case ModelPackageImpl.YEAR_MONTH: + return convertYearMonthToString(eDataType, instanceValue); + case ModelPackageImpl.YEAR_MONTH_DAY: + return convertYearMonthDayToString(eDataType, instanceValue); + default: + throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ChangeSummaryType createChangeSummaryType() + { + ChangeSummaryTypeImpl changeSummaryType = new ChangeSummaryTypeImpl(); + return changeSummaryType; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public DataGraphType createDataGraphType() + { + DataGraphTypeImpl dataGraphType = new DataGraphTypeImpl(); + return dataGraphType; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EObject createDocumentRoot() + { + EObject documentRoot = super.create(ModelPackageImpl.Literals.DOCUMENT_ROOT); + return documentRoot; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ModelsType createModelsType() + { + ModelsTypeImpl modelsType = new ModelsTypeImpl(); + return modelsType; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Property createProperty() + { + PropertyImpl property = new PropertyImpl(); + return property; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Type createType() + { + TypeImpl type = new TypeImpl(); + return type; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Types createTypes() + { + TypesImpl types = new TypesImpl(); + return types; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public XSDType createXSDType() + { + XSDTypeImpl xsdType = new XSDTypeImpl(); + return xsdType; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Boolean createBooleanFromString(EDataType eDataType, String initialValue) + { + return XMLTypeFactory.eINSTANCE.createBooleanObject(initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertBooleanToString(EDataType eDataType, Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertBooleanObject((Boolean)instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Boolean createBooleanObjectFromString(EDataType eDataType, String initialValue) + { + return (Boolean)createBooleanFromString(ModelPackageImpl.Literals.BOOLEAN, initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertBooleanObjectToString(EDataType eDataType, Object instanceValue) + { + return convertBooleanToString(ModelPackageImpl.Literals.BOOLEAN, instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Byte createByteFromString(EDataType eDataType, String initialValue) + { + return XMLTypeFactory.eINSTANCE.createByteObject(initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertByteToString(EDataType eDataType, Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertByteObject((Byte)instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Byte createByteObjectFromString(EDataType eDataType, String initialValue) + { + return (Byte)createByteFromString(ModelPackageImpl.Literals.BYTE, initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertByteObjectToString(EDataType eDataType, Object instanceValue) + { + return convertByteToString(ModelPackageImpl.Literals.BYTE, instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public byte[] createBytesFromString(EDataType eDataType, String initialValue) + { + return XMLTypeFactory.eINSTANCE.createHexBinary(initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertBytesToString(EDataType eDataType, Object instanceValue) + { + if (instanceValue instanceof byte[]) { + return XMLTypeFactory.eINSTANCE.convertHexBinary((byte[])instanceValue); + } else { + return XMLTypeFactory.eINSTANCE.convertHexBinary(instanceValue.toString().getBytes()); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Character createCharacterFromString(EDataType eDataType, String initialValue) + { + return (initialValue == null && initialValue.length() > 0) + ? null : (new Character(collapseWhiteSpace(initialValue).charAt(0))); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertCharacterToString(EDataType eDataType, Object instanceValue) + { + return String.valueOf(((Character)instanceValue).charValue()); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Character createCharacterObjectFromString(EDataType eDataType, String initialValue) + { + return (Character)createCharacterFromString(ModelPackageImpl.Literals.CHARACTER, initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertCharacterObjectToString(EDataType eDataType, Object instanceValue) + { + return convertCharacterToString(ModelPackageImpl.Literals.CHARACTER, instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Date createDateFromString(EDataType eDataType, String initialValue) + { + // XMLCalendar cal = (XMLCalendar) XMLTypeFactory.eINSTANCE.createDate(initialValue); + // return (cal != null) ? cal.getDate() : null; + return DataHelper.INSTANCE.toDate(initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertDateToString(EDataType eDataType, Object instanceValue) + { + if (instanceValue == null) + { + return null; + } + + SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'.'SSS'Z'"); + f.setTimeZone(TimeZone.getTimeZone("GMT")); + + return f.format((Date)instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String createDateTimeFromString(EDataType eDataType, String initialValue) + { + return initialValue; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertDateTimeToString(EDataType eDataType, Object instanceValue) + { + return (String)instanceValue; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String createDayFromString(EDataType eDataType, String initialValue) + { + return initialValue; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertDayToString(EDataType eDataType, Object instanceValue) + { + return (String)instanceValue; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public BigDecimal createDecimalFromString(EDataType eDataType, String initialValue) + { + return XMLTypeFactory.eINSTANCE.createDecimal(initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertDecimalToString(EDataType eDataType, Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertDecimal((BigDecimal)instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Double createDoubleFromString(EDataType eDataType, String initialValue) + { + return XMLTypeFactory.eINSTANCE.createDoubleObject(initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertDoubleToString(EDataType eDataType, Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertDoubleObject((Double)instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Double createDoubleObjectFromString(EDataType eDataType, String initialValue) + { + return (Double)createDoubleFromString(ModelPackageImpl.Literals.DOUBLE, initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertDoubleObjectToString(EDataType eDataType, Object instanceValue) + { + return convertDoubleToString(ModelPackageImpl.Literals.DOUBLE, instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String createDurationFromString(EDataType eDataType, String initialValue) + { + return initialValue; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertDurationToString(EDataType eDataType, Object instanceValue) + { + return (String)instanceValue; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Float createFloatFromString(EDataType eDataType, String initialValue) + { + return XMLTypeFactory.eINSTANCE.createFloatObject(initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertFloatToString(EDataType eDataType, Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertFloatObject((Float)instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Float createFloatObjectFromString(EDataType eDataType, String initialValue) + { + return (Float)createFloatFromString(ModelPackageImpl.Literals.FLOAT, initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertFloatObjectToString(EDataType eDataType, Object instanceValue) + { + return convertFloatToString(ModelPackageImpl.Literals.FLOAT, instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Integer createIntFromString(EDataType eDataType, String initialValue) + { + return XMLTypeFactory.eINSTANCE.createIntObject(initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertIntToString(EDataType eDataType, Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertIntObject((Integer)instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public BigInteger createIntegerFromString(EDataType eDataType, String initialValue) + { + return XMLTypeFactory.eINSTANCE.createInteger(initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertIntegerToString(EDataType eDataType, Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertInteger((BigInteger)instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Integer createIntObjectFromString(EDataType eDataType, String initialValue) + { + return (Integer)createIntFromString(ModelPackageImpl.Literals.INT, initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertIntObjectToString(EDataType eDataType, Object instanceValue) + { + return convertIntToString(ModelPackageImpl.Literals.INT, instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Long createLongFromString(EDataType eDataType, String initialValue) + { + return XMLTypeFactory.eINSTANCE.createLongObject(initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertLongToString(EDataType eDataType, Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertLongObject((Long)instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Long createLongObjectFromString(EDataType eDataType, String initialValue) + { + return (Long)createLongFromString(ModelPackageImpl.Literals.LONG, initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertLongObjectToString(EDataType eDataType, Object instanceValue) + { + return convertLongToString(ModelPackageImpl.Literals.LONG, instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String createMonthFromString(EDataType eDataType, String initialValue) + { + return initialValue; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertMonthToString(EDataType eDataType, Object instanceValue) + { + return (String)instanceValue; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String createMonthDayFromString(EDataType eDataType, String initialValue) + { + return initialValue; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertMonthDayToString(EDataType eDataType, Object instanceValue) + { + return (String)instanceValue; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Object createObjectFromString(EDataType eDataType, String initialValue) + { + return initialValue; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertObjectToString(EDataType eDataType, Object instanceValue) + { + return (instanceValue != null) ? instanceValue.toString() : null; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Short createShortFromString(EDataType eDataType, String initialValue) + { + return XMLTypeFactory.eINSTANCE.createShortObject(initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertShortToString(EDataType eDataType, Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertShortObject((Short)instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Short createShortObjectFromString(EDataType eDataType, String initialValue) + { + return (Short)createShortFromString(ModelPackageImpl.Literals.SHORT, initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertShortObjectToString(EDataType eDataType, Object instanceValue) + { + return convertShortToString(ModelPackageImpl.Literals.SHORT, instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String createStringFromString(EDataType eDataType, String initialValue) + { + return initialValue; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertStringToString(EDataType eDataType, Object instanceValue) + { + return (instanceValue != null) ? instanceValue.toString() : null; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public List createStringsFromString(EDataType eDataType, String initialValue) + { + return XMLTypeFactory.eINSTANCE.createENTITIES(initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertStringsToString(EDataType eDataType, Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertENTITIES((List)instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String createTimeFromString(EDataType eDataType, String initialValue) + { + return initialValue; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertTimeToString(EDataType eDataType, Object instanceValue) + { + return (String)instanceValue; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String createURIFromString(EDataType eDataType, String initialValue) + { + return initialValue; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertURIToString(EDataType eDataType, Object instanceValue) + { + return (instanceValue != null) ? instanceValue.toString() : null; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String createYearFromString(EDataType eDataType, String initialValue) + { + return initialValue; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertYearToString(EDataType eDataType, Object instanceValue) + { + return (String)instanceValue; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String createYearMonthFromString(EDataType eDataType, String initialValue) + { + return initialValue; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertYearMonthToString(EDataType eDataType, Object instanceValue) + { + return (String)instanceValue; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String createYearMonthDayFromString(EDataType eDataType, String initialValue) + { + return initialValue; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertYearMonthDayToString(EDataType eDataType, Object instanceValue) + { + return (String)instanceValue; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public ModelPackageImpl getModelPackageImpl() + { + return (ModelPackageImpl)getEPackage(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @deprecated + * @generated + */ + public static ModelPackageImpl getPackage() + { + return ModelPackageImpl.eINSTANCE; + } + + // Following methods are temporary ... for interop with new factory codegen pattern + // + public static final String NAMESPACE_URI = ModelPackageImpl.eNS_URI; + public commonj.sdo.Type getBoolean() { return (commonj.sdo.Type)getModelPackageImpl().getBoolean(); } + public commonj.sdo.Type getBooleanObject() { return (commonj.sdo.Type)getModelPackageImpl().getBooleanObject(); } + public commonj.sdo.Type getByte() { return (commonj.sdo.Type)getModelPackageImpl().getByte(); } + public commonj.sdo.Type getByteObject() { return (commonj.sdo.Type)getModelPackageImpl().getByteObject(); } + public commonj.sdo.Type getBytes() { return (commonj.sdo.Type)getModelPackageImpl().getBytes(); } + public commonj.sdo.Type getCharacter() { return (commonj.sdo.Type)getModelPackageImpl().getCharacter(); } + public commonj.sdo.Type getCharacterObject() { return (commonj.sdo.Type)getModelPackageImpl().getCharacterObject(); } + public commonj.sdo.Type getDate() { return (commonj.sdo.Type)getModelPackageImpl().getDate(); } + public commonj.sdo.Type getDateTime() { return (commonj.sdo.Type)getModelPackageImpl().getDateTime(); } + public commonj.sdo.Type getDay() { return (commonj.sdo.Type)getModelPackageImpl().getDay(); } + public commonj.sdo.Type getDecimal() { return (commonj.sdo.Type)getModelPackageImpl().getDecimal(); } + public commonj.sdo.Type getDouble() { return (commonj.sdo.Type)getModelPackageImpl().getDouble(); } + public commonj.sdo.Type getDoubleObject() { return (commonj.sdo.Type)getModelPackageImpl().getDoubleObject(); } + public commonj.sdo.Type getDuration() { return (commonj.sdo.Type)getModelPackageImpl().getDuration(); } + public commonj.sdo.Type getFloat() { return (commonj.sdo.Type)getModelPackageImpl().getFloat(); } + public commonj.sdo.Type getFloatObject() { return (commonj.sdo.Type)getModelPackageImpl().getFloatObject(); } + public commonj.sdo.Type getInt() { return (commonj.sdo.Type)getModelPackageImpl().getInt(); } + public commonj.sdo.Type getInteger() { return (commonj.sdo.Type)getModelPackageImpl().getInteger(); } + public commonj.sdo.Type getIntObject() { return (commonj.sdo.Type)getModelPackageImpl().getIntObject(); } + public commonj.sdo.Type getLong() { return (commonj.sdo.Type)getModelPackageImpl().getLong(); } + public commonj.sdo.Type getLongObject() { return (commonj.sdo.Type)getModelPackageImpl().getLongObject(); } + public commonj.sdo.Type getMonth() { return (commonj.sdo.Type)getModelPackageImpl().getMonth(); } + public commonj.sdo.Type getMonthDay() { return (commonj.sdo.Type)getModelPackageImpl().getMonthDay(); } + public commonj.sdo.Type getObject() { return (commonj.sdo.Type)getModelPackageImpl().getObject(); } + public commonj.sdo.Type getShort() { return (commonj.sdo.Type)getModelPackageImpl().getShort(); } + public commonj.sdo.Type getShortObject() { return (commonj.sdo.Type)getModelPackageImpl().getShortObject(); } + public commonj.sdo.Type getString() { return (commonj.sdo.Type)getModelPackageImpl().getString(); } + public commonj.sdo.Type getStrings() { return (commonj.sdo.Type)getModelPackageImpl().getStrings(); } + public commonj.sdo.Type getTime() { return (commonj.sdo.Type)getModelPackageImpl().getTime(); } + public commonj.sdo.Type getURI() { return (commonj.sdo.Type)getModelPackageImpl().getURI(); } + public commonj.sdo.Type getYear() { return (commonj.sdo.Type)getModelPackageImpl().getYear(); } + public commonj.sdo.Type getYearMonth() { return (commonj.sdo.Type)getModelPackageImpl().getYearMonth(); } + public commonj.sdo.Type getYearMonthDay() { return (commonj.sdo.Type)getModelPackageImpl().getYearMonthDay(); } + public commonj.sdo.Type getDataObject() { return (commonj.sdo.Type)getModelPackageImpl().getDataObject(); } + +} //ModelFactoryImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ModelPackageImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ModelPackageImpl.java new file mode 100644 index 0000000000..4f3efa332d --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ModelPackageImpl.java @@ -0,0 +1,4334 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model.impl; + +import java.math.BigDecimal; +import java.math.BigInteger; + +import java.util.Date; +import java.util.List; + +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.model.BaseDataGraphType; +import org.apache.tuscany.sdo.model.ChangeSummaryType; +import org.apache.tuscany.sdo.model.DataGraphType; +import org.apache.tuscany.sdo.model.DataObject; +import org.apache.tuscany.sdo.model.ModelFactory; +import org.apache.tuscany.sdo.model.ModelPackage; +import org.apache.tuscany.sdo.model.ModelsType; +import org.apache.tuscany.sdo.model.Property; +import org.apache.tuscany.sdo.model.TextType; +import org.apache.tuscany.sdo.model.Type; +import org.apache.tuscany.sdo.model.Types; +import org.apache.tuscany.sdo.model.XSDType; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EFactory; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +import org.eclipse.emf.ecore.xml.type.XMLTypePackage; + +/** + * <!-- begin-user-doc --> + * The <b>Package</b> for the model. + * It contains accessors for the meta objects to represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.ModelFactory + * @generated + */ +public class ModelPackageImpl extends EPackageImpl implements ModelPackage +{ + /** + * The package name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final String eNAME = "model"; + + /** + * The package namespace URI. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final String eNS_URI = "commonj.sdo"; + + /** + * The package namespace name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public static final String eNS_PREFIX = "sdo"; //FB why was this generated = "commonj" ? + + /** + * The singleton instance of the package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final ModelPackageImpl eINSTANCE = org.apache.tuscany.sdo.model.impl.ModelPackageImpl.init(); + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.model.impl.BaseDataGraphTypeImpl <em>Base Data Graph Type</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.BaseDataGraphTypeImpl + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getBaseDataGraphType() + * @generated + */ + public static final int BASE_DATA_GRAPH_TYPE = 0; + + /** + * The feature id for the '<em><b>Models</b></em>' containment reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int BASE_DATA_GRAPH_TYPE__MODELS = 0; + + /** + * The feature id for the '<em><b>Xsd</b></em>' containment reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int BASE_DATA_GRAPH_TYPE__XSD = 1; + + /** + * The feature id for the '<em><b>Change Summary</b></em>' containment reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int BASE_DATA_GRAPH_TYPE__CHANGE_SUMMARY = 2; + + /** + * The feature id for the '<em><b>Any Attribute</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int BASE_DATA_GRAPH_TYPE__ANY_ATTRIBUTE = 3; + + /** + * The number of structural features of the '<em>Base Data Graph Type</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int BASE_DATA_GRAPH_TYPE_FEATURE_COUNT = 4; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.model.impl.ChangeSummaryTypeImpl <em>Change Summary Type</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.ChangeSummaryTypeImpl + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getChangeSummaryType() + * @generated + */ + public static final int CHANGE_SUMMARY_TYPE = 1; + + /** + * The feature id for the '<em><b>Any</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int CHANGE_SUMMARY_TYPE__ANY = 0; + + /** + * The feature id for the '<em><b>Create</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int CHANGE_SUMMARY_TYPE__CREATE = 1; + + /** + * The feature id for the '<em><b>Delete</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int CHANGE_SUMMARY_TYPE__DELETE = 2; + + /** + * The feature id for the '<em><b>Logging</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int CHANGE_SUMMARY_TYPE__LOGGING = 3; + + /** + * The number of structural features of the '<em>Change Summary Type</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int CHANGE_SUMMARY_TYPE_FEATURE_COUNT = 4; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.model.impl.DataGraphTypeImpl <em>Data Graph Type</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.DataGraphTypeImpl + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getDataGraphType() + * @generated + */ + public static final int DATA_GRAPH_TYPE = 2; + + /** + * The feature id for the '<em><b>Models</b></em>' containment reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DATA_GRAPH_TYPE__MODELS = BASE_DATA_GRAPH_TYPE__MODELS; + + /** + * The feature id for the '<em><b>Xsd</b></em>' containment reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DATA_GRAPH_TYPE__XSD = BASE_DATA_GRAPH_TYPE__XSD; + + /** + * The feature id for the '<em><b>Change Summary</b></em>' containment reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DATA_GRAPH_TYPE__CHANGE_SUMMARY = BASE_DATA_GRAPH_TYPE__CHANGE_SUMMARY; + + /** + * The feature id for the '<em><b>Any Attribute</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DATA_GRAPH_TYPE__ANY_ATTRIBUTE = BASE_DATA_GRAPH_TYPE__ANY_ATTRIBUTE; + + /** + * The feature id for the '<em><b>Any</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DATA_GRAPH_TYPE__ANY = BASE_DATA_GRAPH_TYPE_FEATURE_COUNT + 0; + + /** + * The number of structural features of the '<em>Data Graph Type</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DATA_GRAPH_TYPE_FEATURE_COUNT = BASE_DATA_GRAPH_TYPE_FEATURE_COUNT + 1; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.model.impl.DataObjectImpl <em>Data Object</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.DataObjectImpl + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getDataObject() + * @generated + */ + public static final int DATA_OBJECT = 3; + + /** + * The number of structural features of the '<em>Data Object</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DATA_OBJECT_FEATURE_COUNT = 0; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.model.impl.DocumentRootImpl <em>Document Root</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.DocumentRootImpl + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getDocumentRoot() + * @generated + */ + public static final int DOCUMENT_ROOT = 4; + + /** + * The feature id for the '<em><b>Mixed</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__MIXED = 0; + + /** + * The feature id for the '<em><b>XMLNS Prefix Map</b></em>' map. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__XMLNS_PREFIX_MAP = 1; + + /** + * The feature id for the '<em><b>XSI Schema Location</b></em>' map. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__XSI_SCHEMA_LOCATION = 2; + + /** + * The feature id for the '<em><b>Datagraph</b></em>' containment reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__DATAGRAPH = 3; + + /** + * The feature id for the '<em><b>Data Object</b></em>' containment reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__DATA_OBJECT = 4; + + /** + * The feature id for the '<em><b>Type</b></em>' containment reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__TYPE = 5; + + /** + * The feature id for the '<em><b>Types</b></em>' containment reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__TYPES = 6; + + /** + * The feature id for the '<em><b>Ref</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__REF = 7; + + /** + * The number of structural features of the '<em>Document Root</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT_FEATURE_COUNT = 8; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.model.impl.ModelsTypeImpl <em>Models Type</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.ModelsTypeImpl + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getModelsType() + * @generated + */ + public static final int MODELS_TYPE = 5; + + /** + * The feature id for the '<em><b>Any</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int MODELS_TYPE__ANY = 0; + + /** + * The number of structural features of the '<em>Models Type</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int MODELS_TYPE_FEATURE_COUNT = 1; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.model.impl.PropertyImpl <em>Property</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.PropertyImpl + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getProperty() + * @generated + */ + public static final int PROPERTY = 6; + + /** + * The feature id for the '<em><b>Alias Name</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int PROPERTY__ALIAS_NAME = 0; + + /** + * The feature id for the '<em><b>Any</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int PROPERTY__ANY = 1; + + /** + * The feature id for the '<em><b>Containment</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int PROPERTY__CONTAINMENT = 2; + + /** + * The feature id for the '<em><b>Default</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int PROPERTY__DEFAULT = 3; + + /** + * The feature id for the '<em><b>Many</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int PROPERTY__MANY = 4; + + /** + * The feature id for the '<em><b>Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int PROPERTY__NAME = 5; + + /** + * The feature id for the '<em><b>Opposite</b></em>' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int PROPERTY__OPPOSITE = 6; + + /** + * The feature id for the '<em><b>Read Only</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int PROPERTY__READ_ONLY = 7; + + /** + * The feature id for the '<em><b>Type</b></em>' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int PROPERTY__TYPE = 8; + + /** + * The feature id for the '<em><b>Any Attribute</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int PROPERTY__ANY_ATTRIBUTE = 9; + + /** + * The number of structural features of the '<em>Property</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int PROPERTY_FEATURE_COUNT = 10; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.model.impl.TextTypeImpl <em>Text Type</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.TextTypeImpl + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getTextType() + * @generated + */ + public static final int TEXT_TYPE = 7; + + /** + * The feature id for the '<em><b>Text</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int TEXT_TYPE__TEXT = 0; + + /** + * The number of structural features of the '<em>Text Type</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int TEXT_TYPE_FEATURE_COUNT = 1; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.model.impl.TypeImpl <em>Type</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.TypeImpl + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getType() + * @generated + */ + public static final int TYPE = 8; + + /** + * The feature id for the '<em><b>Base Type</b></em>' reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int TYPE__BASE_TYPE = 0; + + /** + * The feature id for the '<em><b>Property</b></em>' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int TYPE__PROPERTY = 1; + + /** + * The feature id for the '<em><b>Alias Name</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int TYPE__ALIAS_NAME = 2; + + /** + * The feature id for the '<em><b>Any</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int TYPE__ANY = 3; + + /** + * The feature id for the '<em><b>Abstract</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int TYPE__ABSTRACT = 4; + + /** + * The feature id for the '<em><b>Data Type</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int TYPE__DATA_TYPE = 5; + + /** + * The feature id for the '<em><b>Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int TYPE__NAME = 6; + + /** + * The feature id for the '<em><b>Open</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int TYPE__OPEN = 7; + + /** + * The feature id for the '<em><b>Sequenced</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int TYPE__SEQUENCED = 8; + + /** + * The feature id for the '<em><b>Uri</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int TYPE__URI = 9; + + /** + * The feature id for the '<em><b>Any Attribute</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int TYPE__ANY_ATTRIBUTE = 10; + + /** + * The number of structural features of the '<em>Type</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int TYPE_FEATURE_COUNT = 11; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.model.impl.TypesImpl <em>Types</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.TypesImpl + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getTypes() + * @generated + */ + public static final int TYPES = 9; + + /** + * The feature id for the '<em><b>Type</b></em>' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int TYPES__TYPE = 0; + + /** + * The number of structural features of the '<em>Types</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int TYPES_FEATURE_COUNT = 1; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.model.impl.XSDTypeImpl <em>XSD Type</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.XSDTypeImpl + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getXSDType() + * @generated + */ + public static final int XSD_TYPE = 10; + + /** + * The feature id for the '<em><b>Any</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int XSD_TYPE__ANY = 0; + + /** + * The number of structural features of the '<em>XSD Type</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int XSD_TYPE_FEATURE_COUNT = 1; + + /** + * The meta object id for the '<em>Boolean</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getBoolean() + * @generated + */ + public static final int BOOLEAN = 11; + + /** + * The meta object id for the '<em>Boolean Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Boolean + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getBooleanObject() + * @generated + */ + public static final int BOOLEAN_OBJECT = 12; + + /** + * The meta object id for the '<em>Byte</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getByte() + * @generated + */ + public static final int BYTE = 13; + + /** + * The meta object id for the '<em>Byte Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Byte + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getByteObject() + * @generated + */ + public static final int BYTE_OBJECT = 14; + + /** + * The meta object id for the '<em>Bytes</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getBytes() + * @generated + */ + public static final int BYTES = 15; + + /** + * The meta object id for the '<em>Character</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getCharacter() + * @generated + */ + public static final int CHARACTER = 16; + + /** + * The meta object id for the '<em>Character Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Character + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getCharacterObject() + * @generated + */ + public static final int CHARACTER_OBJECT = 17; + + /** + * The meta object id for the '<em>Date</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.util.Date + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getDate() + * @generated + */ + public static final int DATE = 18; + + /** + * The meta object id for the '<em>Date Time</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getDateTime() + * @generated + */ + public static final int DATE_TIME = 19; + + /** + * The meta object id for the '<em>Day</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getDay() + * @generated + */ + public static final int DAY = 20; + + /** + * The meta object id for the '<em>Decimal</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.math.BigDecimal + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getDecimal() + * @generated + */ + public static final int DECIMAL = 21; + + /** + * The meta object id for the '<em>Double</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getDouble() + * @generated + */ + public static final int DOUBLE = 22; + + /** + * The meta object id for the '<em>Double Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Double + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getDoubleObject() + * @generated + */ + public static final int DOUBLE_OBJECT = 23; + + /** + * The meta object id for the '<em>Duration</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getDuration() + * @generated + */ + public static final int DURATION = 24; + + /** + * The meta object id for the '<em>Float</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getFloat() + * @generated + */ + public static final int FLOAT = 25; + + /** + * The meta object id for the '<em>Float Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Float + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getFloatObject() + * @generated + */ + public static final int FLOAT_OBJECT = 26; + + /** + * The meta object id for the '<em>Int</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getInt() + * @generated + */ + public static final int INT = 27; + + /** + * The meta object id for the '<em>Integer</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.math.BigInteger + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getInteger() + * @generated + */ + public static final int INTEGER = 28; + + /** + * The meta object id for the '<em>Int Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Integer + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getIntObject() + * @generated + */ + public static final int INT_OBJECT = 29; + + /** + * The meta object id for the '<em>Long</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getLong() + * @generated + */ + public static final int LONG = 30; + + /** + * The meta object id for the '<em>Long Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Long + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getLongObject() + * @generated + */ + public static final int LONG_OBJECT = 31; + + /** + * The meta object id for the '<em>Month</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getMonth() + * @generated + */ + public static final int MONTH = 32; + + /** + * The meta object id for the '<em>Month Day</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getMonthDay() + * @generated + */ + public static final int MONTH_DAY = 33; + + /** + * The meta object id for the '<em>Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Object + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getObject() + * @generated + */ + public static final int OBJECT = 34; + + /** + * The meta object id for the '<em>Short</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getShort() + * @generated + */ + public static final int SHORT = 35; + + /** + * The meta object id for the '<em>Short Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Short + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getShortObject() + * @generated + */ + public static final int SHORT_OBJECT = 36; + + /** + * The meta object id for the '<em>String</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getString() + * @generated + */ + public static final int STRING = 37; + + /** + * The meta object id for the '<em>Strings</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.util.List + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getStrings() + * @generated + */ + public static final int STRINGS = 38; + + /** + * The meta object id for the '<em>Time</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getTime() + * @generated + */ + public static final int TIME = 39; + + /** + * The meta object id for the '<em>URI</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getURI() + * @generated + */ + public static final int URI = 40; + + /** + * The meta object id for the '<em>Year</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getYear() + * @generated + */ + public static final int YEAR = 41; + + /** + * The meta object id for the '<em>Year Month</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getYearMonth() + * @generated + */ + public static final int YEAR_MONTH = 42; + + /** + * The meta object id for the '<em>Year Month Day</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getYearMonthDay() + * @generated + */ + public static final int YEAR_MONTH_DAY = 43; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass baseDataGraphTypeEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass changeSummaryTypeEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass dataGraphTypeEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass dataObjectEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass documentRootEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass modelsTypeEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass propertyEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass textTypeEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass typeEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass typesEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass xsdTypeEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType booleanEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType booleanObjectEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType byteEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType byteObjectEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType bytesEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType characterEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType characterObjectEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType dateEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType dateTimeEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType dayEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType decimalEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType doubleEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType doubleObjectEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType durationEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType floatEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType floatObjectEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType intEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType integerEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType intObjectEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType longEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType longObjectEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType monthEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType monthDayEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType objectEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType shortEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType shortObjectEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType stringEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType stringsEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType timeEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType uriEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType yearEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType yearMonthEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType yearMonthDayEDataType = null; + + /** + * Creates an instance of the model <b>Package</b>, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + * <p>Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#eNS_URI + * @see #init() + * @generated + */ + private ModelPackageImpl() + { + super(eNS_URI, ((EFactory)ModelFactory.INSTANCE)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the <b>Package</b> for this + * model, and for any others upon which it depends. Simple + * dependencies are satisfied by calling this method on all + * dependent packages before doing anything else. This method drives + * initialization for interdependent packages directly, in parallel + * with this package, itself. + * <p>Of this package and its interdependencies, all packages which + * have not yet been registered by their URI values are first created + * and registered. The packages are then initialized in two steps: + * meta-model objects for all of the packages are created before any + * are initialized, since one package's meta-model objects may refer to + * those of another. + * <p>Invocation of this method will not affect any packages that have + * already been initialized. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static ModelPackageImpl init() + { + if (isInited) return (ModelPackageImpl)EPackage.Registry.INSTANCE.getEPackage(ModelPackageImpl.eNS_URI); + + // Obtain or create and register package + ModelPackageImpl theModelPackageImpl = (ModelPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof ModelPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new ModelPackageImpl()); + + isInited = true; + + // Initialize simple dependencies + XMLTypePackage.eINSTANCE.eClass(); + + // Create package meta-data objects + theModelPackageImpl.createPackageContents(); + + // Initialize created meta-data + theModelPackageImpl.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theModelPackageImpl.freeze(); + + return theModelPackageImpl; + } + + + /** + * Returns the meta object for class '{@link org.apache.tuscany.sdo.model.BaseDataGraphType <em>Base Data Graph Type</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Base Data Graph Type</em>'. + * @see org.apache.tuscany.sdo.model.BaseDataGraphType + * @generated + */ + public EClass getBaseDataGraphType() + { + return baseDataGraphTypeEClass; + } + + /** + * Returns the meta object for the containment reference '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getModels <em>Models</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the containment reference '<em>Models</em>'. + * @see org.apache.tuscany.sdo.model.BaseDataGraphType#getModels() + * @see #getBaseDataGraphType() + * @generated + */ + public EReference getBaseDataGraphType_Models() + { + return (EReference)baseDataGraphTypeEClass.getEStructuralFeatures().get(0); + } + + /** + * Returns the meta object for the containment reference '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getXsd <em>Xsd</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the containment reference '<em>Xsd</em>'. + * @see org.apache.tuscany.sdo.model.BaseDataGraphType#getXsd() + * @see #getBaseDataGraphType() + * @generated + */ + public EReference getBaseDataGraphType_Xsd() + { + return (EReference)baseDataGraphTypeEClass.getEStructuralFeatures().get(1); + } + + /** + * Returns the meta object for the containment reference '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getChangeSummary <em>Change Summary</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the containment reference '<em>Change Summary</em>'. + * @see org.apache.tuscany.sdo.model.BaseDataGraphType#getChangeSummary() + * @see #getBaseDataGraphType() + * @generated + */ + public EReference getBaseDataGraphType_ChangeSummary() + { + return (EReference)baseDataGraphTypeEClass.getEStructuralFeatures().get(2); + } + + /** + * Returns the meta object for the attribute list '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getAnyAttribute <em>Any Attribute</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute list '<em>Any Attribute</em>'. + * @see org.apache.tuscany.sdo.model.BaseDataGraphType#getAnyAttribute() + * @see #getBaseDataGraphType() + * @generated + */ + public EAttribute getBaseDataGraphType_AnyAttribute() + { + return (EAttribute)baseDataGraphTypeEClass.getEStructuralFeatures().get(3); + } + + /** + * Returns the meta object for class '{@link org.apache.tuscany.sdo.model.ChangeSummaryType <em>Change Summary Type</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Change Summary Type</em>'. + * @see org.apache.tuscany.sdo.model.ChangeSummaryType + * @generated + */ + public EClass getChangeSummaryType() + { + return changeSummaryTypeEClass; + } + + /** + * Returns the meta object for the attribute list '{@link org.apache.tuscany.sdo.model.ChangeSummaryType#getAny <em>Any</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute list '<em>Any</em>'. + * @see org.apache.tuscany.sdo.model.ChangeSummaryType#getAny() + * @see #getChangeSummaryType() + * @generated + */ + public EAttribute getChangeSummaryType_Any() + { + return (EAttribute)changeSummaryTypeEClass.getEStructuralFeatures().get(0); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.sdo.model.ChangeSummaryType#getCreate <em>Create</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Create</em>'. + * @see org.apache.tuscany.sdo.model.ChangeSummaryType#getCreate() + * @see #getChangeSummaryType() + * @generated + */ + public EAttribute getChangeSummaryType_Create() + { + return (EAttribute)changeSummaryTypeEClass.getEStructuralFeatures().get(1); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.sdo.model.ChangeSummaryType#getDelete <em>Delete</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Delete</em>'. + * @see org.apache.tuscany.sdo.model.ChangeSummaryType#getDelete() + * @see #getChangeSummaryType() + * @generated + */ + public EAttribute getChangeSummaryType_Delete() + { + return (EAttribute)changeSummaryTypeEClass.getEStructuralFeatures().get(2); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.sdo.model.ChangeSummaryType#isLogging <em>Logging</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Logging</em>'. + * @see org.apache.tuscany.sdo.model.ChangeSummaryType#isLogging() + * @see #getChangeSummaryType() + * @generated + */ + public EAttribute getChangeSummaryType_Logging() + { + return (EAttribute)changeSummaryTypeEClass.getEStructuralFeatures().get(3); + } + + /** + * Returns the meta object for class '{@link org.apache.tuscany.sdo.model.DataGraphType <em>Data Graph Type</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Data Graph Type</em>'. + * @see org.apache.tuscany.sdo.model.DataGraphType + * @generated + */ + public EClass getDataGraphType() + { + return dataGraphTypeEClass; + } + + /** + * Returns the meta object for the attribute list '{@link org.apache.tuscany.sdo.model.DataGraphType#getAny <em>Any</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute list '<em>Any</em>'. + * @see org.apache.tuscany.sdo.model.DataGraphType#getAny() + * @see #getDataGraphType() + * @generated + */ + public EAttribute getDataGraphType_Any() + { + return (EAttribute)dataGraphTypeEClass.getEStructuralFeatures().get(0); + } + + /** + * Returns the meta object for class '{@link org.apache.tuscany.sdo.model.DataObject <em>Data Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Data Object</em>'. + * @see org.apache.tuscany.sdo.model.DataObject + * @generated + */ + public EClass getDataObject() + { + return dataObjectEClass; + } + + /** + * Returns the meta object for class '{@link org.eclipse.emf.ecore.EObject <em>Document Root</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Document Root</em>'. + * @see org.eclipse.emf.ecore.EObject + * @generated + */ + public EClass getDocumentRoot() + { + return documentRootEClass; + } + + /** + * Returns the meta object for the attribute list '{@link org.eclipse.emf.ecore.EObject#getMixed <em>Mixed</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute list '<em>Mixed</em>'. + * @see org.eclipse.emf.ecore.EObject#getMixed() + * @see #getDocumentRoot() + * @generated + */ + public EAttribute getDocumentRoot_Mixed() + { + return (EAttribute)documentRootEClass.getEStructuralFeatures().get(0); + } + + /** + * Returns the meta object for the map '{@link org.eclipse.emf.ecore.EObject#getXMLNSPrefixMap <em>XMLNS Prefix Map</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the map '<em>XMLNS Prefix Map</em>'. + * @see org.eclipse.emf.ecore.EObject#getXMLNSPrefixMap() + * @see #getDocumentRoot() + * @generated + */ + public EReference getDocumentRoot_XMLNSPrefixMap() + { + return (EReference)documentRootEClass.getEStructuralFeatures().get(1); + } + + /** + * Returns the meta object for the map '{@link org.eclipse.emf.ecore.EObject#getXSISchemaLocation <em>XSI Schema Location</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the map '<em>XSI Schema Location</em>'. + * @see org.eclipse.emf.ecore.EObject#getXSISchemaLocation() + * @see #getDocumentRoot() + * @generated + */ + public EReference getDocumentRoot_XSISchemaLocation() + { + return (EReference)documentRootEClass.getEStructuralFeatures().get(2); + } + + /** + * Returns the meta object for the containment reference '{@link org.eclipse.emf.ecore.EObject#getDatagraph <em>Datagraph</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the containment reference '<em>Datagraph</em>'. + * @see org.eclipse.emf.ecore.EObject#getDatagraph() + * @see #getDocumentRoot() + * @generated + */ + public EReference getDocumentRoot_Datagraph() + { + return (EReference)documentRootEClass.getEStructuralFeatures().get(3); + } + + /** + * Returns the meta object for the containment reference '{@link org.eclipse.emf.ecore.EObject#getDataObject <em>Data Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the containment reference '<em>Data Object</em>'. + * @see org.eclipse.emf.ecore.EObject#getDataObject() + * @see #getDocumentRoot() + * @generated + */ + public EReference getDocumentRoot_DataObject() + { + return (EReference)documentRootEClass.getEStructuralFeatures().get(4); + } + + /** + * Returns the meta object for the containment reference '{@link org.eclipse.emf.ecore.EObject#getType <em>Type</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the containment reference '<em>Type</em>'. + * @see org.eclipse.emf.ecore.EObject#getType() + * @see #getDocumentRoot() + * @generated + */ + public EReference getDocumentRoot_Type() + { + return (EReference)documentRootEClass.getEStructuralFeatures().get(5); + } + + /** + * Returns the meta object for the containment reference '{@link org.eclipse.emf.ecore.EObject#getTypes <em>Types</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the containment reference '<em>Types</em>'. + * @see org.eclipse.emf.ecore.EObject#getTypes() + * @see #getDocumentRoot() + * @generated + */ + public EReference getDocumentRoot_Types() + { + return (EReference)documentRootEClass.getEStructuralFeatures().get(6); + } + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.ecore.EObject#getRef <em>Ref</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Ref</em>'. + * @see org.eclipse.emf.ecore.EObject#getRef() + * @see #getDocumentRoot() + * @generated + */ + public EAttribute getDocumentRoot_Ref() + { + return (EAttribute)documentRootEClass.getEStructuralFeatures().get(7); + } + + /** + * Returns the meta object for class '{@link org.apache.tuscany.sdo.model.ModelsType <em>Models Type</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Models Type</em>'. + * @see org.apache.tuscany.sdo.model.ModelsType + * @generated + */ + public EClass getModelsType() + { + return modelsTypeEClass; + } + + /** + * Returns the meta object for the attribute list '{@link org.apache.tuscany.sdo.model.ModelsType#getAny <em>Any</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute list '<em>Any</em>'. + * @see org.apache.tuscany.sdo.model.ModelsType#getAny() + * @see #getModelsType() + * @generated + */ + public EAttribute getModelsType_Any() + { + return (EAttribute)modelsTypeEClass.getEStructuralFeatures().get(0); + } + + /** + * Returns the meta object for class '{@link org.apache.tuscany.sdo.model.Property <em>Property</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Property</em>'. + * @see org.apache.tuscany.sdo.model.Property + * @generated + */ + public EClass getProperty() + { + return propertyEClass; + } + + /** + * Returns the meta object for the attribute list '{@link org.apache.tuscany.sdo.model.Property#getAliasName <em>Alias Name</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute list '<em>Alias Name</em>'. + * @see org.apache.tuscany.sdo.model.Property#getAliasName() + * @see #getProperty() + * @generated + */ + public EAttribute getProperty_AliasName() + { + return (EAttribute)propertyEClass.getEStructuralFeatures().get(0); + } + + /** + * Returns the meta object for the attribute list '{@link org.apache.tuscany.sdo.model.Property#getAny <em>Any</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute list '<em>Any</em>'. + * @see org.apache.tuscany.sdo.model.Property#getAny() + * @see #getProperty() + * @generated + */ + public EAttribute getProperty_Any() + { + return (EAttribute)propertyEClass.getEStructuralFeatures().get(1); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.sdo.model.Property#isContainment <em>Containment</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Containment</em>'. + * @see org.apache.tuscany.sdo.model.Property#isContainment() + * @see #getProperty() + * @generated + */ + public EAttribute getProperty_Containment() + { + return (EAttribute)propertyEClass.getEStructuralFeatures().get(2); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.sdo.model.Property#getDefault <em>Default</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Default</em>'. + * @see org.apache.tuscany.sdo.model.Property#getDefault() + * @see #getProperty() + * @generated + */ + public EAttribute getProperty_Default() + { + return (EAttribute)propertyEClass.getEStructuralFeatures().get(3); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.sdo.model.Property#isMany <em>Many</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Many</em>'. + * @see org.apache.tuscany.sdo.model.Property#isMany() + * @see #getProperty() + * @generated + */ + public EAttribute getProperty_Many() + { + return (EAttribute)propertyEClass.getEStructuralFeatures().get(4); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.sdo.model.Property#getName <em>Name</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Name</em>'. + * @see org.apache.tuscany.sdo.model.Property#getName() + * @see #getProperty() + * @generated + */ + public EAttribute getProperty_Name() + { + return (EAttribute)propertyEClass.getEStructuralFeatures().get(5); + } + + /** + * Returns the meta object for the reference '{@link org.apache.tuscany.sdo.model.Property#getOpposite <em>Opposite</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the reference '<em>Opposite</em>'. + * @see org.apache.tuscany.sdo.model.Property#getOpposite() + * @see #getProperty() + * @generated + */ + public EReference getProperty_Opposite() + { + return (EReference)propertyEClass.getEStructuralFeatures().get(6); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.sdo.model.Property#isReadOnly <em>Read Only</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Read Only</em>'. + * @see org.apache.tuscany.sdo.model.Property#isReadOnly() + * @see #getProperty() + * @generated + */ + public EAttribute getProperty_ReadOnly() + { + return (EAttribute)propertyEClass.getEStructuralFeatures().get(7); + } + + /** + * Returns the meta object for the reference '{@link org.apache.tuscany.sdo.model.Property#getType <em>Type</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the reference '<em>Type</em>'. + * @see org.apache.tuscany.sdo.model.Property#getType() + * @see #getProperty() + * @generated + */ + public EReference getProperty_Type() + { + return (EReference)propertyEClass.getEStructuralFeatures().get(8); + } + + /** + * Returns the meta object for the attribute list '{@link org.apache.tuscany.sdo.model.Property#getAnyAttribute <em>Any Attribute</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute list '<em>Any Attribute</em>'. + * @see org.apache.tuscany.sdo.model.Property#getAnyAttribute() + * @see #getProperty() + * @generated + */ + public EAttribute getProperty_AnyAttribute() + { + return (EAttribute)propertyEClass.getEStructuralFeatures().get(9); + } + + /** + * Returns the meta object for class '{@link org.apache.tuscany.sdo.model.TextType <em>Text Type</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Text Type</em>'. + * @see org.apache.tuscany.sdo.model.TextType + * @generated + */ + public EClass getTextType() + { + return textTypeEClass; + } + + /** + * Returns the meta object for the attribute list '{@link org.apache.tuscany.sdo.model.TextType#getText <em>Text</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute list '<em>Text</em>'. + * @see org.apache.tuscany.sdo.model.TextType#getText() + * @see #getTextType() + * @generated + */ + public EAttribute getTextType_Text() + { + return (EAttribute)textTypeEClass.getEStructuralFeatures().get(0); + } + + /** + * Returns the meta object for class '{@link org.apache.tuscany.sdo.model.Type <em>Type</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Type</em>'. + * @see org.apache.tuscany.sdo.model.Type + * @generated + */ + public EClass getType() + { + return typeEClass; + } + + /** + * Returns the meta object for the reference list '{@link org.apache.tuscany.sdo.model.Type#getBaseType <em>Base Type</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the reference list '<em>Base Type</em>'. + * @see org.apache.tuscany.sdo.model.Type#getBaseType() + * @see #getType() + * @generated + */ + public EReference getType_BaseType() + { + return (EReference)typeEClass.getEStructuralFeatures().get(0); + } + + /** + * Returns the meta object for the containment reference list '{@link org.apache.tuscany.sdo.model.Type#getProperty <em>Property</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the containment reference list '<em>Property</em>'. + * @see org.apache.tuscany.sdo.model.Type#getProperty() + * @see #getType() + * @generated + */ + public EReference getType_Property() + { + return (EReference)typeEClass.getEStructuralFeatures().get(1); + } + + /** + * Returns the meta object for the attribute list '{@link org.apache.tuscany.sdo.model.Type#getAliasName <em>Alias Name</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute list '<em>Alias Name</em>'. + * @see org.apache.tuscany.sdo.model.Type#getAliasName() + * @see #getType() + * @generated + */ + public EAttribute getType_AliasName() + { + return (EAttribute)typeEClass.getEStructuralFeatures().get(2); + } + + /** + * Returns the meta object for the attribute list '{@link org.apache.tuscany.sdo.model.Type#getAny <em>Any</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute list '<em>Any</em>'. + * @see org.apache.tuscany.sdo.model.Type#getAny() + * @see #getType() + * @generated + */ + public EAttribute getType_Any() + { + return (EAttribute)typeEClass.getEStructuralFeatures().get(3); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.sdo.model.Type#isAbstract <em>Abstract</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Abstract</em>'. + * @see org.apache.tuscany.sdo.model.Type#isAbstract() + * @see #getType() + * @generated + */ + public EAttribute getType_Abstract() + { + return (EAttribute)typeEClass.getEStructuralFeatures().get(4); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.sdo.model.Type#isDataType <em>Data Type</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Data Type</em>'. + * @see org.apache.tuscany.sdo.model.Type#isDataType() + * @see #getType() + * @generated + */ + public EAttribute getType_DataType() + { + return (EAttribute)typeEClass.getEStructuralFeatures().get(5); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.sdo.model.Type#getName <em>Name</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Name</em>'. + * @see org.apache.tuscany.sdo.model.Type#getName() + * @see #getType() + * @generated + */ + public EAttribute getType_Name() + { + return (EAttribute)typeEClass.getEStructuralFeatures().get(6); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.sdo.model.Type#isOpen <em>Open</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Open</em>'. + * @see org.apache.tuscany.sdo.model.Type#isOpen() + * @see #getType() + * @generated + */ + public EAttribute getType_Open() + { + return (EAttribute)typeEClass.getEStructuralFeatures().get(7); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.sdo.model.Type#isSequenced <em>Sequenced</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Sequenced</em>'. + * @see org.apache.tuscany.sdo.model.Type#isSequenced() + * @see #getType() + * @generated + */ + public EAttribute getType_Sequenced() + { + return (EAttribute)typeEClass.getEStructuralFeatures().get(8); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.sdo.model.Type#getUri <em>Uri</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Uri</em>'. + * @see org.apache.tuscany.sdo.model.Type#getUri() + * @see #getType() + * @generated + */ + public EAttribute getType_Uri() + { + return (EAttribute)typeEClass.getEStructuralFeatures().get(9); + } + + /** + * Returns the meta object for the attribute list '{@link org.apache.tuscany.sdo.model.Type#getAnyAttribute <em>Any Attribute</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute list '<em>Any Attribute</em>'. + * @see org.apache.tuscany.sdo.model.Type#getAnyAttribute() + * @see #getType() + * @generated + */ + public EAttribute getType_AnyAttribute() + { + return (EAttribute)typeEClass.getEStructuralFeatures().get(10); + } + + /** + * Returns the meta object for class '{@link org.apache.tuscany.sdo.model.Types <em>Types</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Types</em>'. + * @see org.apache.tuscany.sdo.model.Types + * @generated + */ + public EClass getTypes() + { + return typesEClass; + } + + /** + * Returns the meta object for the containment reference list '{@link org.apache.tuscany.sdo.model.Types#getType <em>Type</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the containment reference list '<em>Type</em>'. + * @see org.apache.tuscany.sdo.model.Types#getType() + * @see #getTypes() + * @generated + */ + public EReference getTypes_Type() + { + return (EReference)typesEClass.getEStructuralFeatures().get(0); + } + + /** + * Returns the meta object for class '{@link org.apache.tuscany.sdo.model.XSDType <em>XSD Type</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>XSD Type</em>'. + * @see org.apache.tuscany.sdo.model.XSDType + * @generated + */ + public EClass getXSDType() + { + return xsdTypeEClass; + } + + /** + * Returns the meta object for the attribute list '{@link org.apache.tuscany.sdo.model.XSDType#getAny <em>Any</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute list '<em>Any</em>'. + * @see org.apache.tuscany.sdo.model.XSDType#getAny() + * @see #getXSDType() + * @generated + */ + public EAttribute getXSDType_Any() + { + return (EAttribute)xsdTypeEClass.getEStructuralFeatures().get(0); + } + + /** + * Returns the meta object for data type '<em>Boolean</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Boolean</em>'. + * @generated + */ + public EDataType getBoolean() + { + return booleanEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.Boolean <em>Boolean Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Boolean Object</em>'. + * @see java.lang.Boolean + * @generated + */ + public EDataType getBooleanObject() + { + return booleanObjectEDataType; + } + + /** + * Returns the meta object for data type '<em>Byte</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Byte</em>'. + * @generated + */ + public EDataType getByte() + { + return byteEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.Byte <em>Byte Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Byte Object</em>'. + * @see java.lang.Byte + * @generated + */ + public EDataType getByteObject() + { + return byteObjectEDataType; + } + + /** + * Returns the meta object for data type '<em>Bytes</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Bytes</em>'. + * @generated + */ + public EDataType getBytes() + { + return bytesEDataType; + } + + /** + * Returns the meta object for data type '<em>Character</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Character</em>'. + * @generated + */ + public EDataType getCharacter() + { + return characterEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.Character <em>Character Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Character Object</em>'. + * @see java.lang.Character + * @generated + */ + public EDataType getCharacterObject() + { + return characterObjectEDataType; + } + + /** + * Returns the meta object for data type '{@link java.util.Date <em>Date</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Date</em>'. + * @see java.util.Date + * @generated + */ + public EDataType getDate() + { + return dateEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.String <em>Date Time</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Date Time</em>'. + * @see java.lang.String + * @generated + */ + public EDataType getDateTime() + { + return dateTimeEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.String <em>Day</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Day</em>'. + * @see java.lang.String + * @generated + */ + public EDataType getDay() + { + return dayEDataType; + } + + /** + * Returns the meta object for data type '{@link java.math.BigDecimal <em>Decimal</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Decimal</em>'. + * @see java.math.BigDecimal + * @generated + */ + public EDataType getDecimal() + { + return decimalEDataType; + } + + /** + * Returns the meta object for data type '<em>Double</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Double</em>'. + * @generated + */ + public EDataType getDouble() + { + return doubleEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.Double <em>Double Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Double Object</em>'. + * @see java.lang.Double + * @generated + */ + public EDataType getDoubleObject() + { + return doubleObjectEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.String <em>Duration</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Duration</em>'. + * @see java.lang.String + * @generated + */ + public EDataType getDuration() + { + return durationEDataType; + } + + /** + * Returns the meta object for data type '<em>Float</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Float</em>'. + * @generated + */ + public EDataType getFloat() + { + return floatEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.Float <em>Float Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Float Object</em>'. + * @see java.lang.Float + * @generated + */ + public EDataType getFloatObject() + { + return floatObjectEDataType; + } + + /** + * Returns the meta object for data type '<em>Int</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Int</em>'. + * @generated + */ + public EDataType getInt() + { + return intEDataType; + } + + /** + * Returns the meta object for data type '{@link java.math.BigInteger <em>Integer</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Integer</em>'. + * @see java.math.BigInteger + * @generated + */ + public EDataType getInteger() + { + return integerEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.Integer <em>Int Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Int Object</em>'. + * @see java.lang.Integer + * @generated + */ + public EDataType getIntObject() + { + return intObjectEDataType; + } + + /** + * Returns the meta object for data type '<em>Long</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Long</em>'. + * @generated + */ + public EDataType getLong() + { + return longEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.Long <em>Long Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Long Object</em>'. + * @see java.lang.Long + * @generated + */ + public EDataType getLongObject() + { + return longObjectEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.String <em>Month</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Month</em>'. + * @see java.lang.String + * @generated + */ + public EDataType getMonth() + { + return monthEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.String <em>Month Day</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Month Day</em>'. + * @see java.lang.String + * @generated + */ + public EDataType getMonthDay() + { + return monthDayEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.Object <em>Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Object</em>'. + * @see java.lang.Object + * @generated + */ + public EDataType getObject() + { + return objectEDataType; + } + + /** + * Returns the meta object for data type '<em>Short</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Short</em>'. + * @generated + */ + public EDataType getShort() + { + return shortEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.Short <em>Short Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Short Object</em>'. + * @see java.lang.Short + * @generated + */ + public EDataType getShortObject() + { + return shortObjectEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.String <em>String</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>String</em>'. + * @see java.lang.String + * @generated + */ + public EDataType getString() + { + return stringEDataType; + } + + /** + * Returns the meta object for data type '{@link java.util.List <em>Strings</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Strings</em>'. + * @see java.util.List + * @generated + */ + public EDataType getStrings() + { + return stringsEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.String <em>Time</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Time</em>'. + * @see java.lang.String + * @generated + */ + public EDataType getTime() + { + return timeEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.String <em>URI</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>URI</em>'. + * @see java.lang.String + * @generated + */ + public EDataType getURI() + { + return uriEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.String <em>Year</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Year</em>'. + * @see java.lang.String + * @generated + */ + public EDataType getYear() + { + return yearEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.String <em>Year Month</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Year Month</em>'. + * @see java.lang.String + * @generated + */ + public EDataType getYearMonth() + { + return yearMonthEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.String <em>Year Month Day</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Year Month Day</em>'. + * @see java.lang.String + * @generated + */ + public EDataType getYearMonthDay() + { + return yearMonthDayEDataType; + } + + /** + * Returns the factory that creates the instances of the model. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the factory that creates the instances of the model. + * @generated + */ + public ModelFactory getModelFactory() + { + return (ModelFactory)getEFactoryInstance(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void createPackageContents() + { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + baseDataGraphTypeEClass = createEClass(BASE_DATA_GRAPH_TYPE); + createEReference(baseDataGraphTypeEClass, BASE_DATA_GRAPH_TYPE__MODELS); + createEReference(baseDataGraphTypeEClass, BASE_DATA_GRAPH_TYPE__XSD); + createEReference(baseDataGraphTypeEClass, BASE_DATA_GRAPH_TYPE__CHANGE_SUMMARY); + createEAttribute(baseDataGraphTypeEClass, BASE_DATA_GRAPH_TYPE__ANY_ATTRIBUTE); + + changeSummaryTypeEClass = createEClass(CHANGE_SUMMARY_TYPE); + createEAttribute(changeSummaryTypeEClass, CHANGE_SUMMARY_TYPE__ANY); + createEAttribute(changeSummaryTypeEClass, CHANGE_SUMMARY_TYPE__CREATE); + createEAttribute(changeSummaryTypeEClass, CHANGE_SUMMARY_TYPE__DELETE); + createEAttribute(changeSummaryTypeEClass, CHANGE_SUMMARY_TYPE__LOGGING); + + dataGraphTypeEClass = createEClass(DATA_GRAPH_TYPE); + createEAttribute(dataGraphTypeEClass, DATA_GRAPH_TYPE__ANY); + + dataObjectEClass = createEClass(DATA_OBJECT); + + documentRootEClass = createEClass(DOCUMENT_ROOT); + createEAttribute(documentRootEClass, DOCUMENT_ROOT__MIXED); + createEReference(documentRootEClass, DOCUMENT_ROOT__XMLNS_PREFIX_MAP); + createEReference(documentRootEClass, DOCUMENT_ROOT__XSI_SCHEMA_LOCATION); + createEReference(documentRootEClass, DOCUMENT_ROOT__DATAGRAPH); + createEReference(documentRootEClass, DOCUMENT_ROOT__DATA_OBJECT); + createEReference(documentRootEClass, DOCUMENT_ROOT__TYPE); + createEReference(documentRootEClass, DOCUMENT_ROOT__TYPES); + createEAttribute(documentRootEClass, DOCUMENT_ROOT__REF); + + modelsTypeEClass = createEClass(MODELS_TYPE); + createEAttribute(modelsTypeEClass, MODELS_TYPE__ANY); + + propertyEClass = createEClass(PROPERTY); + createEAttribute(propertyEClass, PROPERTY__ALIAS_NAME); + createEAttribute(propertyEClass, PROPERTY__ANY); + createEAttribute(propertyEClass, PROPERTY__CONTAINMENT); + createEAttribute(propertyEClass, PROPERTY__DEFAULT); + createEAttribute(propertyEClass, PROPERTY__MANY); + createEAttribute(propertyEClass, PROPERTY__NAME); + createEReference(propertyEClass, PROPERTY__OPPOSITE); + createEAttribute(propertyEClass, PROPERTY__READ_ONLY); + createEReference(propertyEClass, PROPERTY__TYPE); + createEAttribute(propertyEClass, PROPERTY__ANY_ATTRIBUTE); + + textTypeEClass = createEClass(TEXT_TYPE); + createEAttribute(textTypeEClass, TEXT_TYPE__TEXT); + + typeEClass = createEClass(TYPE); + createEReference(typeEClass, TYPE__BASE_TYPE); + createEReference(typeEClass, TYPE__PROPERTY); + createEAttribute(typeEClass, TYPE__ALIAS_NAME); + createEAttribute(typeEClass, TYPE__ANY); + createEAttribute(typeEClass, TYPE__ABSTRACT); + createEAttribute(typeEClass, TYPE__DATA_TYPE); + createEAttribute(typeEClass, TYPE__NAME); + createEAttribute(typeEClass, TYPE__OPEN); + createEAttribute(typeEClass, TYPE__SEQUENCED); + createEAttribute(typeEClass, TYPE__URI); + createEAttribute(typeEClass, TYPE__ANY_ATTRIBUTE); + + typesEClass = createEClass(TYPES); + createEReference(typesEClass, TYPES__TYPE); + + xsdTypeEClass = createEClass(XSD_TYPE); + createEAttribute(xsdTypeEClass, XSD_TYPE__ANY); + + // Create data types + booleanEDataType = createEDataType(BOOLEAN); + booleanObjectEDataType = createEDataType(BOOLEAN_OBJECT); + byteEDataType = createEDataType(BYTE); + byteObjectEDataType = createEDataType(BYTE_OBJECT); + bytesEDataType = createEDataType(BYTES); + characterEDataType = createEDataType(CHARACTER); + characterObjectEDataType = createEDataType(CHARACTER_OBJECT); + dateEDataType = createEDataType(DATE); + dateTimeEDataType = createEDataType(DATE_TIME); + dayEDataType = createEDataType(DAY); + decimalEDataType = createEDataType(DECIMAL); + doubleEDataType = createEDataType(DOUBLE); + doubleObjectEDataType = createEDataType(DOUBLE_OBJECT); + durationEDataType = createEDataType(DURATION); + floatEDataType = createEDataType(FLOAT); + floatObjectEDataType = createEDataType(FLOAT_OBJECT); + intEDataType = createEDataType(INT); + integerEDataType = createEDataType(INTEGER); + intObjectEDataType = createEDataType(INT_OBJECT); + longEDataType = createEDataType(LONG); + longObjectEDataType = createEDataType(LONG_OBJECT); + monthEDataType = createEDataType(MONTH); + monthDayEDataType = createEDataType(MONTH_DAY); + objectEDataType = createEDataType(OBJECT); + shortEDataType = createEDataType(SHORT); + shortObjectEDataType = createEDataType(SHORT_OBJECT); + stringEDataType = createEDataType(STRING); + stringsEDataType = createEDataType(STRINGS); + timeEDataType = createEDataType(TIME); + uriEDataType = createEDataType(URI); + yearEDataType = createEDataType(YEAR); + yearMonthEDataType = createEDataType(YEAR_MONTH); + yearMonthDayEDataType = createEDataType(YEAR_MONTH_DAY); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void initializePackageContents() + { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Obtain other dependent packages + XMLTypePackage theXMLTypePackage = (XMLTypePackage)EPackage.Registry.INSTANCE.getEPackage(XMLTypePackage.eNS_URI); + + // Add supertypes to classes + dataGraphTypeEClass.getESuperTypes().add(this.getBaseDataGraphType()); + + // Initialize classes and features; add operations and parameters + initEClass(baseDataGraphTypeEClass, BaseDataGraphType.class, "BaseDataGraphType", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getBaseDataGraphType_Models(), this.getModelsType(), null, "models", null, 0, 1, BaseDataGraphType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getBaseDataGraphType_Xsd(), this.getXSDType(), null, "xsd", null, 0, 1, BaseDataGraphType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getBaseDataGraphType_ChangeSummary(), this.getChangeSummaryType(), null, "changeSummary", null, 0, 1, BaseDataGraphType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getBaseDataGraphType_AnyAttribute(), ecorePackage.getEFeatureMapEntry(), "anyAttribute", null, 0, -1, BaseDataGraphType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(changeSummaryTypeEClass, ChangeSummaryType.class, "ChangeSummaryType", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getChangeSummaryType_Any(), ecorePackage.getEFeatureMapEntry(), "any", null, 0, -1, ChangeSummaryType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getChangeSummaryType_Create(), theXMLTypePackage.getString(), "create", null, 0, 1, ChangeSummaryType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getChangeSummaryType_Delete(), theXMLTypePackage.getString(), "delete", null, 0, 1, ChangeSummaryType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getChangeSummaryType_Logging(), theXMLTypePackage.getBoolean(), "logging", null, 0, 1, ChangeSummaryType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(dataGraphTypeEClass, DataGraphType.class, "DataGraphType", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getDataGraphType_Any(), ecorePackage.getEFeatureMapEntry(), "any", null, 0, 1, DataGraphType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(dataObjectEClass, DataObject.class, "DataObject", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + + initEClass(documentRootEClass, null, "DocumentRoot", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getDocumentRoot_Mixed(), ecorePackage.getEFeatureMapEntry(), "mixed", null, 0, -1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getDocumentRoot_XMLNSPrefixMap(), ecorePackage.getEStringToStringMapEntry(), null, "xMLNSPrefixMap", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getDocumentRoot_XSISchemaLocation(), ecorePackage.getEStringToStringMapEntry(), null, "xSISchemaLocation", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getDocumentRoot_Datagraph(), this.getDataGraphType(), null, "datagraph", null, 0, -2, null, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + initEReference(getDocumentRoot_DataObject(), ecorePackage.getEObject(), null, "dataObject", null, 0, -2, null, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + initEReference(getDocumentRoot_Type(), this.getType(), null, "type", null, 0, -2, null, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + initEReference(getDocumentRoot_Types(), this.getTypes(), null, "types", null, 0, -2, null, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + initEAttribute(getDocumentRoot_Ref(), theXMLTypePackage.getString(), "ref", null, 0, 1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(modelsTypeEClass, ModelsType.class, "ModelsType", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getModelsType_Any(), ecorePackage.getEFeatureMapEntry(), "any", null, 0, -1, ModelsType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(propertyEClass, Property.class, "Property", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getProperty_AliasName(), this.getString(), "aliasName", null, 0, -1, Property.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getProperty_Any(), ecorePackage.getEFeatureMapEntry(), "any", null, 0, -1, Property.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getProperty_Containment(), this.getBoolean(), "containment", null, 0, 1, Property.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getProperty_Default(), this.getString(), "default", null, 0, 1, Property.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getProperty_Many(), this.getBoolean(), "many", null, 0, 1, Property.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getProperty_Name(), this.getString(), "name", null, 0, 1, Property.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getProperty_Opposite(), this.getProperty(), null, "opposite", null, 0, 1, Property.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getProperty_ReadOnly(), this.getBoolean(), "readOnly", null, 0, 1, Property.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getProperty_Type(), this.getType(), null, "type", null, 0, 1, Property.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getProperty_AnyAttribute(), ecorePackage.getEFeatureMapEntry(), "anyAttribute", null, 0, -1, Property.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(textTypeEClass, TextType.class, "TextType", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getTextType_Text(), theXMLTypePackage.getString(), "text", null, 0, -1, TextType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(typeEClass, Type.class, "Type", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getType_BaseType(), this.getType(), null, "baseType", null, 0, -1, Type.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getType_Property(), this.getProperty(), null, "property", null, 0, -1, Type.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getType_AliasName(), this.getString(), "aliasName", null, 0, -1, Type.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getType_Any(), ecorePackage.getEFeatureMapEntry(), "any", null, 0, -1, Type.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getType_Abstract(), this.getBoolean(), "abstract", null, 0, 1, Type.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getType_DataType(), this.getBoolean(), "dataType", null, 0, 1, Type.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getType_Name(), theXMLTypePackage.getID(), "name", null, 0, 1, Type.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getType_Open(), this.getBoolean(), "open", null, 0, 1, Type.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getType_Sequenced(), this.getBoolean(), "sequenced", null, 0, 1, Type.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getType_Uri(), this.getURI(), "uri", null, 0, 1, Type.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getType_AnyAttribute(), ecorePackage.getEFeatureMapEntry(), "anyAttribute", null, 0, -1, Type.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(typesEClass, Types.class, "Types", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getTypes_Type(), this.getType(), null, "type", null, 0, -1, Types.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(xsdTypeEClass, XSDType.class, "XSDType", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getXSDType_Any(), ecorePackage.getEFeatureMapEntry(), "any", null, 0, -1, XSDType.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Initialize data types + initEDataType(booleanEDataType, boolean.class, "Boolean", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(booleanObjectEDataType, Boolean.class, "BooleanObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(byteEDataType, byte.class, "Byte", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(byteObjectEDataType, Byte.class, "ByteObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(bytesEDataType, byte[].class, "Bytes", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(characterEDataType, char.class, "Character", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(characterObjectEDataType, Character.class, "CharacterObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(dateEDataType, Date.class, "Date", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(dateTimeEDataType, String.class, "DateTime", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(dayEDataType, String.class, "Day", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(decimalEDataType, BigDecimal.class, "Decimal", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(doubleEDataType, double.class, "Double", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(doubleObjectEDataType, Double.class, "DoubleObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(durationEDataType, String.class, "Duration", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(floatEDataType, float.class, "Float", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(floatObjectEDataType, Float.class, "FloatObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(intEDataType, int.class, "Int", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(integerEDataType, BigInteger.class, "Integer", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(intObjectEDataType, Integer.class, "IntObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(longEDataType, long.class, "Long", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(longObjectEDataType, Long.class, "LongObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(monthEDataType, String.class, "Month", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(monthDayEDataType, String.class, "MonthDay", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(objectEDataType, Object.class, "Object", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(shortEDataType, short.class, "Short", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(shortObjectEDataType, Short.class, "ShortObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(stringEDataType, String.class, "String", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(stringsEDataType, List.class, "Strings", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(timeEDataType, String.class, "Time", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(uriEDataType, String.class, "URI", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(yearEDataType, String.class, "Year", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(yearMonthEDataType, String.class, "YearMonth", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(yearMonthDayEDataType, String.class, "YearMonthDay", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + + // Create resource + createResource(eNS_URI); + + // Create annotations + // http:///org/eclipse/emf/ecore/util/ExtendedMetaData + createExtendedMetaDataAnnotations(); + } + + /** + * Initializes the annotations for <b>http:///org/eclipse/emf/ecore/util/ExtendedMetaData</b>. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected void createExtendedMetaDataAnnotations() + { + String source = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData"; + addAnnotation + (baseDataGraphTypeEClass, + source, + new String[] + { + "name", "BaseDataGraphType", + "kind", "elementOnly" + }); + addAnnotation + (getBaseDataGraphType_Models(), + source, + new String[] + { + "kind", "element", + "name", "models" + }); + addAnnotation + (getBaseDataGraphType_Xsd(), + source, + new String[] + { + "kind", "element", + "name", "xsd" + }); + addAnnotation + (getBaseDataGraphType_ChangeSummary(), + source, + new String[] + { + "kind", "element", + "name", "changeSummary" + }); + addAnnotation + (getBaseDataGraphType_AnyAttribute(), + source, + new String[] + { + "kind", "attributeWildcard", + "wildcards", "##other", + "name", ":3", + "processing", "lax" + }); + addAnnotation + (booleanEDataType, + source, + new String[] + { + "name", "Boolean" + }); + addAnnotation + (booleanObjectEDataType, + source, + new String[] + { + "name", "Boolean:Object", + "baseType", "Boolean" + }); + addAnnotation + (byteEDataType, + source, + new String[] + { + "name", "Byte" + }); + addAnnotation + (byteObjectEDataType, + source, + new String[] + { + "name", "Byte:Object", + "baseType", "Byte" + }); + addAnnotation + (bytesEDataType, + source, + new String[] + { + "name", "Bytes" + }); + addAnnotation + (changeSummaryTypeEClass, + source, + new String[] + { + "name", "ChangeSummaryType", + "kind", "elementOnly" + }); + addAnnotation + (getChangeSummaryType_Any(), + source, + new String[] + { + "kind", "elementWildcard", + "wildcards", "##any", + "name", ":0", + "processing", "lax" + }); + addAnnotation + (getChangeSummaryType_Create(), + source, + new String[] + { + "kind", "attribute", + "name", "create" + }); + addAnnotation + (getChangeSummaryType_Delete(), + source, + new String[] + { + "kind", "attribute", + "name", "delete" + }); + addAnnotation + (getChangeSummaryType_Logging(), + source, + new String[] + { + "kind", "attribute", + "name", "logging" + }); + addAnnotation + (characterEDataType, + source, + new String[] + { + "name", "Character" + }); + addAnnotation + (characterObjectEDataType, + source, + new String[] + { + "name", "Character:Object", + "baseType", "Character" + }); + addAnnotation + (dataGraphTypeEClass, + source, + new String[] + { + "name", "DataGraphType", + "kind", "elementOnly" + }); + addAnnotation + (getDataGraphType_Any(), + source, + new String[] + { + "kind", "elementWildcard", + "wildcards", "##other", + "name", ":4", + "processing", "lax" + }); + addAnnotation + (dataObjectEClass, + source, + new String[] + { + "name", "DataObject", + "kind", "empty" + }); + addAnnotation + (dateEDataType, + source, + new String[] + { + "name", "Date" + }); + addAnnotation + (dateTimeEDataType, + source, + new String[] + { + "name", "DateTime" + }); + addAnnotation + (dayEDataType, + source, + new String[] + { + "name", "Day" + }); + addAnnotation + (decimalEDataType, + source, + new String[] + { + "name", "Decimal" + }); + addAnnotation + (documentRootEClass, + source, + new String[] + { + "name", "", + "kind", "mixed" + }); + addAnnotation + (getDocumentRoot_Mixed(), + source, + new String[] + { + "kind", "elementWildcard", + "name", ":mixed" + }); + addAnnotation + (getDocumentRoot_XMLNSPrefixMap(), + source, + new String[] + { + "kind", "attribute", + "name", "xmlns:prefix" + }); + addAnnotation + (getDocumentRoot_XSISchemaLocation(), + source, + new String[] + { + "kind", "attribute", + "name", "xsi:schemaLocation" + }); + addAnnotation + (getDocumentRoot_Datagraph(), + source, + new String[] + { + "kind", "element", + "name", "datagraph", + "namespace", "##targetNamespace" + }); + addAnnotation + (getDocumentRoot_DataObject(), + source, + new String[] + { + "kind", "element", + "name", "dataObject", + "namespace", "##targetNamespace" + }); + addAnnotation + (getDocumentRoot_Type(), + source, + new String[] + { + "kind", "element", + "name", "type", + "namespace", "##targetNamespace" + }); + addAnnotation + (getDocumentRoot_Types(), + source, + new String[] + { + "kind", "element", + "name", "types", + "namespace", "##targetNamespace" + }); + addAnnotation + (getDocumentRoot_Ref(), + source, + new String[] + { + "kind", "attribute", + "name", "ref", + "namespace", "##targetNamespace" + }); + addAnnotation + (doubleEDataType, + source, + new String[] + { + "name", "Double" + }); + addAnnotation + (doubleObjectEDataType, + source, + new String[] + { + "name", "Double:Object", + "baseType", "Double" + }); + addAnnotation + (durationEDataType, + source, + new String[] + { + "name", "Duration" + }); + addAnnotation + (floatEDataType, + source, + new String[] + { + "name", "Float" + }); + addAnnotation + (floatObjectEDataType, + source, + new String[] + { + "name", "Float:Object", + "baseType", "Float" + }); + addAnnotation + (intEDataType, + source, + new String[] + { + "name", "Int" + }); + addAnnotation + (integerEDataType, + source, + new String[] + { + "name", "Integer" + }); + addAnnotation + (intObjectEDataType, + source, + new String[] + { + "name", "Int:Object", + "baseType", "Int" + }); + addAnnotation + (longEDataType, + source, + new String[] + { + "name", "Long" + }); + addAnnotation + (longObjectEDataType, + source, + new String[] + { + "name", "Long:Object", + "baseType", "Long" + }); + addAnnotation + (modelsTypeEClass, + source, + new String[] + { + "name", "ModelsType", + "kind", "elementOnly" + }); + addAnnotation + (getModelsType_Any(), + source, + new String[] + { + "kind", "elementWildcard", + "wildcards", "##other", + "name", ":0", + "processing", "lax" + }); + addAnnotation + (monthEDataType, + source, + new String[] + { + "name", "Month" + }); + addAnnotation + (monthDayEDataType, + source, + new String[] + { + "name", "MonthDay" + }); + addAnnotation + (objectEDataType, + source, + new String[] + { + "name", "Object" + }); + addAnnotation + (propertyEClass, + source, + new String[] + { + "name", "Property", + "kind", "elementOnly" + }); + addAnnotation + (getProperty_AliasName(), + source, + new String[] + { + "kind", "element", + "name", "aliasName", + "namespace", "##targetNamespace" + }); + addAnnotation + (getProperty_Any(), + source, + new String[] + { + "kind", "elementWildcard", + "wildcards", "##other", + "name", ":1", + "processing", "lax" + }); + addAnnotation + (getProperty_Containment(), + source, + new String[] + { + "kind", "attribute", + "name", "containment" + }); + addAnnotation + (getProperty_Default(), + source, + new String[] + { + "kind", "attribute", + "name", "default" + }); + addAnnotation + (getProperty_Many(), + source, + new String[] + { + "kind", "attribute", + "name", "many" + }); + addAnnotation + (getProperty_Name(), + source, + new String[] + { + "kind", "attribute", + "name", "name" + }); + addAnnotation + (getProperty_Opposite(), + source, + new String[] + { + "kind", "attribute", + "name", "opposite" + }); + addAnnotation + (getProperty_ReadOnly(), + source, + new String[] + { + "kind", "attribute", + "name", "readOnly" + }); + addAnnotation + (getProperty_Type(), + source, + new String[] + { + "kind", "attribute", + "name", "type" + }); + addAnnotation + (getProperty_AnyAttribute(), + source, + new String[] + { + "kind", "attributeWildcard", + "wildcards", "##any", + "name", ":9", + "processing", "lax" + }); + addAnnotation + (shortEDataType, + source, + new String[] + { + "name", "Short" + }); + addAnnotation + (shortObjectEDataType, + source, + new String[] + { + "name", "Short:Object", + "baseType", "Short" + }); + addAnnotation + (stringEDataType, + source, + new String[] + { + "name", "String" + }); + addAnnotation + (stringsEDataType, + source, + new String[] + { + "name", "Strings" + }); + addAnnotation + (textTypeEClass, + source, + new String[] + { + "name", "TextType", + "kind", "elementOnly" + }); + addAnnotation + (getTextType_Text(), + source, + new String[] + { + "kind", "element", + "name", "text", + "namespace", "##targetNamespace" + }); + addAnnotation + (timeEDataType, + source, + new String[] + { + "name", "Time" + }); + addAnnotation + (typeEClass, + source, + new String[] + { + "name", "Type", + "kind", "elementOnly" + }); + addAnnotation + (getType_BaseType(), + source, + new String[] + { + "kind", "element", + "name", "baseType", + "namespace", "##targetNamespace" + }); + addAnnotation + (getType_Property(), + source, + new String[] + { + "kind", "element", + "name", "property", + "namespace", "##targetNamespace" + }); + addAnnotation + (getType_AliasName(), + source, + new String[] + { + "kind", "element", + "name", "aliasName", + "namespace", "##targetNamespace" + }); + addAnnotation + (getType_Any(), + source, + new String[] + { + "kind", "elementWildcard", + "wildcards", "##other", + "name", ":3", + "processing", "lax" + }); + addAnnotation + (getType_Abstract(), + source, + new String[] + { + "kind", "attribute", + "name", "abstract" + }); + addAnnotation + (getType_DataType(), + source, + new String[] + { + "kind", "attribute", + "name", "dataType" + }); + addAnnotation + (getType_Name(), + source, + new String[] + { + "kind", "attribute", + "name", "name" + }); + addAnnotation + (getType_Open(), + source, + new String[] + { + "kind", "attribute", + "name", "open" + }); + addAnnotation + (getType_Sequenced(), + source, + new String[] + { + "kind", "attribute", + "name", "sequenced" + }); + addAnnotation + (getType_Uri(), + source, + new String[] + { + "kind", "attribute", + "name", "uri" + }); + addAnnotation + (getType_AnyAttribute(), + source, + new String[] + { + "kind", "attributeWildcard", + "wildcards", "##any", + "name", ":10", + "processing", "lax" + }); + addAnnotation + (typesEClass, + source, + new String[] + { + "name", "Types", + "kind", "elementOnly" + }); + addAnnotation + (getTypes_Type(), + source, + new String[] + { + "kind", "element", + "name", "type", + "namespace", "##targetNamespace" + }); + addAnnotation + (uriEDataType, + source, + new String[] + { + "name", "URI" + }); + addAnnotation + (xsdTypeEClass, + source, + new String[] + { + "name", "XSDType", + "kind", "elementOnly" + }); + addAnnotation + (getXSDType_Any(), + source, + new String[] + { + "kind", "elementWildcard", + "wildcards", "http://www.w3.org/2001/XMLSchema", + "name", ":0", + "processing", "lax" + }); + addAnnotation + (yearEDataType, + source, + new String[] + { + "name", "Year" + }); + addAnnotation + (yearMonthEDataType, + source, + new String[] + { + "name", "YearMonth" + }); + addAnnotation + (yearMonthDayEDataType, + source, + new String[] + { + "name", "YearMonthDay" + }); + } + + /** + * <!-- begin-user-doc --> + * Defines literals for the meta objects that represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @generated + */ + public interface Literals + { + /** + * The meta object literal for the '{@link org.apache.tuscany.sdo.model.impl.BaseDataGraphTypeImpl <em>Base Data Graph Type</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.BaseDataGraphTypeImpl + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getBaseDataGraphType() + * @generated + */ + public static final EClass BASE_DATA_GRAPH_TYPE = eINSTANCE.getBaseDataGraphType(); + + /** + * The meta object literal for the '<em><b>Models</b></em>' containment reference feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference BASE_DATA_GRAPH_TYPE__MODELS = eINSTANCE.getBaseDataGraphType_Models(); + + /** + * The meta object literal for the '<em><b>Xsd</b></em>' containment reference feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference BASE_DATA_GRAPH_TYPE__XSD = eINSTANCE.getBaseDataGraphType_Xsd(); + + /** + * The meta object literal for the '<em><b>Change Summary</b></em>' containment reference feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference BASE_DATA_GRAPH_TYPE__CHANGE_SUMMARY = eINSTANCE.getBaseDataGraphType_ChangeSummary(); + + /** + * The meta object literal for the '<em><b>Any Attribute</b></em>' attribute list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute BASE_DATA_GRAPH_TYPE__ANY_ATTRIBUTE = eINSTANCE.getBaseDataGraphType_AnyAttribute(); + + /** + * The meta object literal for the '{@link org.apache.tuscany.sdo.model.impl.ChangeSummaryTypeImpl <em>Change Summary Type</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.ChangeSummaryTypeImpl + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getChangeSummaryType() + * @generated + */ + public static final EClass CHANGE_SUMMARY_TYPE = eINSTANCE.getChangeSummaryType(); + + /** + * The meta object literal for the '<em><b>Any</b></em>' attribute list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute CHANGE_SUMMARY_TYPE__ANY = eINSTANCE.getChangeSummaryType_Any(); + + /** + * The meta object literal for the '<em><b>Create</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute CHANGE_SUMMARY_TYPE__CREATE = eINSTANCE.getChangeSummaryType_Create(); + + /** + * The meta object literal for the '<em><b>Delete</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute CHANGE_SUMMARY_TYPE__DELETE = eINSTANCE.getChangeSummaryType_Delete(); + + /** + * The meta object literal for the '<em><b>Logging</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute CHANGE_SUMMARY_TYPE__LOGGING = eINSTANCE.getChangeSummaryType_Logging(); + + /** + * The meta object literal for the '{@link org.apache.tuscany.sdo.model.impl.DataGraphTypeImpl <em>Data Graph Type</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.DataGraphTypeImpl + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getDataGraphType() + * @generated + */ + public static final EClass DATA_GRAPH_TYPE = eINSTANCE.getDataGraphType(); + + /** + * The meta object literal for the '<em><b>Any</b></em>' attribute list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute DATA_GRAPH_TYPE__ANY = eINSTANCE.getDataGraphType_Any(); + + /** + * The meta object literal for the '{@link org.apache.tuscany.sdo.model.impl.DataObjectImpl <em>Data Object</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.DataObjectImpl + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getDataObject() + * @generated + */ + public static final EClass DATA_OBJECT = eINSTANCE.getDataObject(); + + /** + * The meta object literal for the '{@link org.apache.tuscany.sdo.model.impl.DocumentRootImpl <em>Document Root</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.DocumentRootImpl + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getDocumentRoot() + * @generated + */ + public static final EClass DOCUMENT_ROOT = eINSTANCE.getDocumentRoot(); + + /** + * The meta object literal for the '<em><b>Mixed</b></em>' attribute list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute DOCUMENT_ROOT__MIXED = eINSTANCE.getDocumentRoot_Mixed(); + + /** + * The meta object literal for the '<em><b>XMLNS Prefix Map</b></em>' map feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference DOCUMENT_ROOT__XMLNS_PREFIX_MAP = eINSTANCE.getDocumentRoot_XMLNSPrefixMap(); + + /** + * The meta object literal for the '<em><b>XSI Schema Location</b></em>' map feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference DOCUMENT_ROOT__XSI_SCHEMA_LOCATION = eINSTANCE.getDocumentRoot_XSISchemaLocation(); + + /** + * The meta object literal for the '<em><b>Datagraph</b></em>' containment reference feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference DOCUMENT_ROOT__DATAGRAPH = eINSTANCE.getDocumentRoot_Datagraph(); + + /** + * The meta object literal for the '<em><b>Data Object</b></em>' containment reference feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference DOCUMENT_ROOT__DATA_OBJECT = eINSTANCE.getDocumentRoot_DataObject(); + + /** + * The meta object literal for the '<em><b>Type</b></em>' containment reference feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference DOCUMENT_ROOT__TYPE = eINSTANCE.getDocumentRoot_Type(); + + /** + * The meta object literal for the '<em><b>Types</b></em>' containment reference feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference DOCUMENT_ROOT__TYPES = eINSTANCE.getDocumentRoot_Types(); + + /** + * The meta object literal for the '<em><b>Ref</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute DOCUMENT_ROOT__REF = eINSTANCE.getDocumentRoot_Ref(); + + /** + * The meta object literal for the '{@link org.apache.tuscany.sdo.model.impl.ModelsTypeImpl <em>Models Type</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.ModelsTypeImpl + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getModelsType() + * @generated + */ + public static final EClass MODELS_TYPE = eINSTANCE.getModelsType(); + + /** + * The meta object literal for the '<em><b>Any</b></em>' attribute list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute MODELS_TYPE__ANY = eINSTANCE.getModelsType_Any(); + + /** + * The meta object literal for the '{@link org.apache.tuscany.sdo.model.impl.PropertyImpl <em>Property</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.PropertyImpl + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getProperty() + * @generated + */ + public static final EClass PROPERTY = eINSTANCE.getProperty(); + + /** + * The meta object literal for the '<em><b>Alias Name</b></em>' attribute list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute PROPERTY__ALIAS_NAME = eINSTANCE.getProperty_AliasName(); + + /** + * The meta object literal for the '<em><b>Any</b></em>' attribute list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute PROPERTY__ANY = eINSTANCE.getProperty_Any(); + + /** + * The meta object literal for the '<em><b>Containment</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute PROPERTY__CONTAINMENT = eINSTANCE.getProperty_Containment(); + + /** + * The meta object literal for the '<em><b>Default</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute PROPERTY__DEFAULT = eINSTANCE.getProperty_Default(); + + /** + * The meta object literal for the '<em><b>Many</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute PROPERTY__MANY = eINSTANCE.getProperty_Many(); + + /** + * The meta object literal for the '<em><b>Name</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute PROPERTY__NAME = eINSTANCE.getProperty_Name(); + + /** + * The meta object literal for the '<em><b>Opposite</b></em>' reference feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference PROPERTY__OPPOSITE = eINSTANCE.getProperty_Opposite(); + + /** + * The meta object literal for the '<em><b>Read Only</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute PROPERTY__READ_ONLY = eINSTANCE.getProperty_ReadOnly(); + + /** + * The meta object literal for the '<em><b>Type</b></em>' reference feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference PROPERTY__TYPE = eINSTANCE.getProperty_Type(); + + /** + * The meta object literal for the '<em><b>Any Attribute</b></em>' attribute list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute PROPERTY__ANY_ATTRIBUTE = eINSTANCE.getProperty_AnyAttribute(); + + /** + * The meta object literal for the '{@link org.apache.tuscany.sdo.model.impl.TextTypeImpl <em>Text Type</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.TextTypeImpl + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getTextType() + * @generated + */ + public static final EClass TEXT_TYPE = eINSTANCE.getTextType(); + + /** + * The meta object literal for the '<em><b>Text</b></em>' attribute list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute TEXT_TYPE__TEXT = eINSTANCE.getTextType_Text(); + + /** + * The meta object literal for the '{@link org.apache.tuscany.sdo.model.impl.TypeImpl <em>Type</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.TypeImpl + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getType() + * @generated + */ + public static final EClass TYPE = eINSTANCE.getType(); + + /** + * The meta object literal for the '<em><b>Base Type</b></em>' reference list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference TYPE__BASE_TYPE = eINSTANCE.getType_BaseType(); + + /** + * The meta object literal for the '<em><b>Property</b></em>' containment reference list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference TYPE__PROPERTY = eINSTANCE.getType_Property(); + + /** + * The meta object literal for the '<em><b>Alias Name</b></em>' attribute list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute TYPE__ALIAS_NAME = eINSTANCE.getType_AliasName(); + + /** + * The meta object literal for the '<em><b>Any</b></em>' attribute list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute TYPE__ANY = eINSTANCE.getType_Any(); + + /** + * The meta object literal for the '<em><b>Abstract</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute TYPE__ABSTRACT = eINSTANCE.getType_Abstract(); + + /** + * The meta object literal for the '<em><b>Data Type</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute TYPE__DATA_TYPE = eINSTANCE.getType_DataType(); + + /** + * The meta object literal for the '<em><b>Name</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute TYPE__NAME = eINSTANCE.getType_Name(); + + /** + * The meta object literal for the '<em><b>Open</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute TYPE__OPEN = eINSTANCE.getType_Open(); + + /** + * The meta object literal for the '<em><b>Sequenced</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute TYPE__SEQUENCED = eINSTANCE.getType_Sequenced(); + + /** + * The meta object literal for the '<em><b>Uri</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute TYPE__URI = eINSTANCE.getType_Uri(); + + /** + * The meta object literal for the '<em><b>Any Attribute</b></em>' attribute list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute TYPE__ANY_ATTRIBUTE = eINSTANCE.getType_AnyAttribute(); + + /** + * The meta object literal for the '{@link org.apache.tuscany.sdo.model.impl.TypesImpl <em>Types</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.TypesImpl + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getTypes() + * @generated + */ + public static final EClass TYPES = eINSTANCE.getTypes(); + + /** + * The meta object literal for the '<em><b>Type</b></em>' containment reference list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference TYPES__TYPE = eINSTANCE.getTypes_Type(); + + /** + * The meta object literal for the '{@link org.apache.tuscany.sdo.model.impl.XSDTypeImpl <em>XSD Type</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.XSDTypeImpl + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getXSDType() + * @generated + */ + public static final EClass XSD_TYPE = eINSTANCE.getXSDType(); + + /** + * The meta object literal for the '<em><b>Any</b></em>' attribute list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute XSD_TYPE__ANY = eINSTANCE.getXSDType_Any(); + + /** + * The meta object literal for the '<em>Boolean</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getBoolean() + * @generated + */ + public static final EDataType BOOLEAN = eINSTANCE.getBoolean(); + + /** + * The meta object literal for the '<em>Boolean Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Boolean + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getBooleanObject() + * @generated + */ + public static final EDataType BOOLEAN_OBJECT = eINSTANCE.getBooleanObject(); + + /** + * The meta object literal for the '<em>Byte</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getByte() + * @generated + */ + public static final EDataType BYTE = eINSTANCE.getByte(); + + /** + * The meta object literal for the '<em>Byte Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Byte + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getByteObject() + * @generated + */ + public static final EDataType BYTE_OBJECT = eINSTANCE.getByteObject(); + + /** + * The meta object literal for the '<em>Bytes</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getBytes() + * @generated + */ + public static final EDataType BYTES = eINSTANCE.getBytes(); + + /** + * The meta object literal for the '<em>Character</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getCharacter() + * @generated + */ + public static final EDataType CHARACTER = eINSTANCE.getCharacter(); + + /** + * The meta object literal for the '<em>Character Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Character + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getCharacterObject() + * @generated + */ + public static final EDataType CHARACTER_OBJECT = eINSTANCE.getCharacterObject(); + + /** + * The meta object literal for the '<em>Date</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.util.Date + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getDate() + * @generated + */ + public static final EDataType DATE = eINSTANCE.getDate(); + + /** + * The meta object literal for the '<em>Date Time</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getDateTime() + * @generated + */ + public static final EDataType DATE_TIME = eINSTANCE.getDateTime(); + + /** + * The meta object literal for the '<em>Day</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getDay() + * @generated + */ + public static final EDataType DAY = eINSTANCE.getDay(); + + /** + * The meta object literal for the '<em>Decimal</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.math.BigDecimal + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getDecimal() + * @generated + */ + public static final EDataType DECIMAL = eINSTANCE.getDecimal(); + + /** + * The meta object literal for the '<em>Double</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getDouble() + * @generated + */ + public static final EDataType DOUBLE = eINSTANCE.getDouble(); + + /** + * The meta object literal for the '<em>Double Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Double + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getDoubleObject() + * @generated + */ + public static final EDataType DOUBLE_OBJECT = eINSTANCE.getDoubleObject(); + + /** + * The meta object literal for the '<em>Duration</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getDuration() + * @generated + */ + public static final EDataType DURATION = eINSTANCE.getDuration(); + + /** + * The meta object literal for the '<em>Float</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getFloat() + * @generated + */ + public static final EDataType FLOAT = eINSTANCE.getFloat(); + + /** + * The meta object literal for the '<em>Float Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Float + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getFloatObject() + * @generated + */ + public static final EDataType FLOAT_OBJECT = eINSTANCE.getFloatObject(); + + /** + * The meta object literal for the '<em>Int</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getInt() + * @generated + */ + public static final EDataType INT = eINSTANCE.getInt(); + + /** + * The meta object literal for the '<em>Integer</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.math.BigInteger + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getInteger() + * @generated + */ + public static final EDataType INTEGER = eINSTANCE.getInteger(); + + /** + * The meta object literal for the '<em>Int Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Integer + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getIntObject() + * @generated + */ + public static final EDataType INT_OBJECT = eINSTANCE.getIntObject(); + + /** + * The meta object literal for the '<em>Long</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getLong() + * @generated + */ + public static final EDataType LONG = eINSTANCE.getLong(); + + /** + * The meta object literal for the '<em>Long Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Long + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getLongObject() + * @generated + */ + public static final EDataType LONG_OBJECT = eINSTANCE.getLongObject(); + + /** + * The meta object literal for the '<em>Month</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getMonth() + * @generated + */ + public static final EDataType MONTH = eINSTANCE.getMonth(); + + /** + * The meta object literal for the '<em>Month Day</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getMonthDay() + * @generated + */ + public static final EDataType MONTH_DAY = eINSTANCE.getMonthDay(); + + /** + * The meta object literal for the '<em>Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Object + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getObject() + * @generated + */ + public static final EDataType OBJECT = eINSTANCE.getObject(); + + /** + * The meta object literal for the '<em>Short</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getShort() + * @generated + */ + public static final EDataType SHORT = eINSTANCE.getShort(); + + /** + * The meta object literal for the '<em>Short Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Short + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getShortObject() + * @generated + */ + public static final EDataType SHORT_OBJECT = eINSTANCE.getShortObject(); + + /** + * The meta object literal for the '<em>String</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getString() + * @generated + */ + public static final EDataType STRING = eINSTANCE.getString(); + + /** + * The meta object literal for the '<em>Strings</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.util.List + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getStrings() + * @generated + */ + public static final EDataType STRINGS = eINSTANCE.getStrings(); + + /** + * The meta object literal for the '<em>Time</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getTime() + * @generated + */ + public static final EDataType TIME = eINSTANCE.getTime(); + + /** + * The meta object literal for the '<em>URI</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getURI() + * @generated + */ + public static final EDataType URI = eINSTANCE.getURI(); + + /** + * The meta object literal for the '<em>Year</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getYear() + * @generated + */ + public static final EDataType YEAR = eINSTANCE.getYear(); + + /** + * The meta object literal for the '<em>Year Month</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getYearMonth() + * @generated + */ + public static final EDataType YEAR_MONTH = eINSTANCE.getYearMonth(); + + /** + * The meta object literal for the '<em>Year Month Day</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.String + * @see org.apache.tuscany.sdo.model.impl.ModelPackageImpl#getYearMonthDay() + * @generated + */ + public static final EDataType YEAR_MONTH_DAY = eINSTANCE.getYearMonthDay(); + + } + +} //ModelPackageImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ModelsTypeImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ModelsTypeImpl.java new file mode 100644 index 0000000000..4c0f107f1f --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ModelsTypeImpl.java @@ -0,0 +1,192 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model.impl; + +import commonj.sdo.Sequence; + + +import org.apache.tuscany.sdo.impl.DataObjectImpl; +import org.apache.tuscany.sdo.model.ModelsType; + +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; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Models Type</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.sdo.model.impl.ModelsTypeImpl#getAny <em>Any</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class ModelsTypeImpl extends DataObjectImpl implements ModelsType +{ + /** + * The cached value of the '{@link #getAny() <em>Any</em>}' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getAny() + * @generated + * @ordered + */ + protected BasicSequence any = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected ModelsTypeImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return ModelPackageImpl.Literals.MODELS_TYPE; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Sequence getAny() + { + if (any == null) + { + any = new BasicSequence(new BasicFeatureMap(this, ModelPackageImpl.MODELS_TYPE__ANY)); + } + return any; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) + { + switch (featureID) + { + case ModelPackageImpl.MODELS_TYPE__ANY: + return ((InternalEList)((FeatureMap.Internal.Wrapper)getAny()).featureMap()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case ModelPackageImpl.MODELS_TYPE__ANY: + if (coreType) return ((FeatureMap.Internal.Wrapper)getAny()).featureMap(); + return getAny(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case ModelPackageImpl.MODELS_TYPE__ANY: + ((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)getAny()).featureMap()).set(newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case ModelPackageImpl.MODELS_TYPE__ANY: + ((FeatureMap.Internal.Wrapper)getAny()).featureMap().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case ModelPackageImpl.MODELS_TYPE__ANY: + return any != null && !any.featureMap().isEmpty(); + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (any: "); + result.append(any); + result.append(')'); + return result.toString(); + } + +} //ModelsTypeImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/PropertyImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/PropertyImpl.java new file mode 100644 index 0000000000..c7936d28f0 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/PropertyImpl.java @@ -0,0 +1,804 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model.impl; + +import commonj.sdo.Sequence; + +import java.util.Collection; +import java.util.List; + + +import org.apache.tuscany.sdo.impl.DataObjectImpl; +import org.apache.tuscany.sdo.model.Property; +import org.apache.tuscany.sdo.model.Type; + +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.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; + +import org.eclipse.emf.ecore.util.BasicFeatureMap; +import org.eclipse.emf.ecore.util.EDataTypeEList; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Property</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.sdo.model.impl.PropertyImpl#getAliasName <em>Alias Name</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.PropertyImpl#getAny <em>Any</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.PropertyImpl#isContainment <em>Containment</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.PropertyImpl#getDefault <em>Default</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.PropertyImpl#isMany <em>Many</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.PropertyImpl#getName <em>Name</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.PropertyImpl#getOpposite <em>Opposite</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.PropertyImpl#isReadOnly <em>Read Only</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.PropertyImpl#getType <em>Type</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.PropertyImpl#getAnyAttribute <em>Any Attribute</em>}</li> + * </ul> + * </p> + * + * Note: The getDefault and getOpposite methods had to be renamed to avoid + * conflict with the commonj.sdo.Property getDefault and getOpposite + * methods in classes that implement both. Eventually, the two interfaces + * should be brought in-line with one another -- James Snell + * + * @generated + */ +public class PropertyImpl extends DataObjectImpl implements Property +{ + /** + * The cached value of the '{@link #getAliasName() <em>Alias Name</em>}' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getAliasName() + * @generated + * @ordered + */ + protected EList aliasName = null; + + /** + * The cached value of the '{@link #getAny() <em>Any</em>}' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getAny() + * @generated + * @ordered + */ + protected BasicSequence any = null; + + /** + * The default value of the '{@link #isContainment() <em>Containment</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isContainment() + * @generated + * @ordered + */ + protected static final boolean CONTAINMENT_EDEFAULT = false; + + /** + * The cached value of the '{@link #isContainment() <em>Containment</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isContainment() + * @generated + * @ordered + */ + protected boolean containment = CONTAINMENT_EDEFAULT; + + /** + * This is true if the Containment attribute has been set. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + protected boolean containmentESet = false; + + /** + * The default value of the '{@link #getDefault() <em>Default</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getDefault() + * @generated + * @ordered + */ + protected static final String DEFAULT_EDEFAULT = null; + + /** + * The cached value of the '{@link #getDefault() <em>Default</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getDefault() + * @generated + * @ordered + */ + protected String default_ = DEFAULT_EDEFAULT; + + /** + * The default value of the '{@link #isMany() <em>Many</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isMany() + * @generated + * @ordered + */ + protected static final boolean MANY_EDEFAULT = false; + + /** + * The cached value of the '{@link #isMany() <em>Many</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isMany() + * @generated + * @ordered + */ + protected boolean many = MANY_EDEFAULT; + + /** + * This is true if the Many attribute has been set. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + protected boolean manyESet = false; + + /** + * The default value of the '{@link #getName() <em>Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getName() + * @generated + * @ordered + */ + protected static final String NAME_EDEFAULT = null; + + /** + * The cached value of the '{@link #getName() <em>Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getName() + * @generated + * @ordered + */ + protected String name = NAME_EDEFAULT; + + /** + * The cached value of the '{@link #getOpposite() <em>Opposite</em>}' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getOpposite() + * @generated + * @ordered + */ + protected Property opposite = null; + + /** + * The default value of the '{@link #isReadOnly() <em>Read Only</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isReadOnly() + * @generated + * @ordered + */ + protected static final boolean READ_ONLY_EDEFAULT = false; + + /** + * The cached value of the '{@link #isReadOnly() <em>Read Only</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isReadOnly() + * @generated + * @ordered + */ + protected boolean readOnly = READ_ONLY_EDEFAULT; + + /** + * This is true if the Read Only attribute has been set. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + protected boolean readOnlyESet = false; + + /** + * The cached value of the '{@link #getType() <em>Type</em>}' reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getType() + * @generated + * @ordered + */ + protected Type type = null; + + /** + * The cached value of the '{@link #getAnyAttribute() <em>Any Attribute</em>}' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getAnyAttribute() + * @generated + * @ordered + */ + protected BasicSequence anyAttribute = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected PropertyImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return ModelPackageImpl.Literals.PROPERTY; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public List getAliasName() + { + if (aliasName == null) + { + aliasName = new EDataTypeEList(String.class, this, ModelPackageImpl.PROPERTY__ALIAS_NAME); + } + return aliasName; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Sequence getAny() + { + if (any == null) + { + any = new BasicSequence(new BasicFeatureMap(this, ModelPackageImpl.PROPERTY__ANY)); + } + return any; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isContainment() + { + return containment; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setContainment(boolean newContainment) + { + boolean oldContainment = containment; + containment = newContainment; + boolean oldContainmentESet = containmentESet; + containmentESet = true; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ModelPackageImpl.PROPERTY__CONTAINMENT, oldContainment, containment, !oldContainmentESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void unsetContainment() + { + boolean oldContainment = containment; + boolean oldContainmentESet = containmentESet; + containment = CONTAINMENT_EDEFAULT; + containmentESet = false; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.UNSET, ModelPackageImpl.PROPERTY__CONTAINMENT, oldContainment, CONTAINMENT_EDEFAULT, oldContainmentESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isSetContainment() + { + return containmentESet; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String getDefault_() + { + return default_; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setDefault_(String newDefault) + { + String oldDefault = default_; + default_ = newDefault; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ModelPackageImpl.PROPERTY__DEFAULT, oldDefault, default_)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isMany() + { + return many; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setMany(boolean newMany) + { + boolean oldMany = many; + many = newMany; + boolean oldManyESet = manyESet; + manyESet = true; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ModelPackageImpl.PROPERTY__MANY, oldMany, many, !oldManyESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void unsetMany() + { + boolean oldMany = many; + boolean oldManyESet = manyESet; + many = MANY_EDEFAULT; + manyESet = false; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.UNSET, ModelPackageImpl.PROPERTY__MANY, oldMany, MANY_EDEFAULT, oldManyESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isSetMany() + { + return manyESet; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getName() + { + return name; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setName(String newName) + { + String oldName = name; + name = newName; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ModelPackageImpl.PROPERTY__NAME, oldName, name)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Property getOpposite_() + { + if (opposite != null && ((EObject)opposite).eIsProxy()) + { + InternalEObject oldOpposite = (InternalEObject)opposite; + opposite = (Property)eResolveProxy(oldOpposite); + if (opposite != oldOpposite) + { + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, ModelPackageImpl.PROPERTY__OPPOSITE, oldOpposite, opposite)); + } + } + return opposite; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Property basicGetOpposite() + { + return opposite; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public void setOpposite_(Property newOpposite) + { + Property oldOpposite = opposite; + opposite = newOpposite; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ModelPackageImpl.PROPERTY__OPPOSITE, oldOpposite, opposite)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isReadOnly() + { + return readOnly; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setReadOnly(boolean newReadOnly) + { + boolean oldReadOnly = readOnly; + readOnly = newReadOnly; + boolean oldReadOnlyESet = readOnlyESet; + readOnlyESet = true; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ModelPackageImpl.PROPERTY__READ_ONLY, oldReadOnly, readOnly, !oldReadOnlyESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void unsetReadOnly() + { + boolean oldReadOnly = readOnly; + boolean oldReadOnlyESet = readOnlyESet; + readOnly = READ_ONLY_EDEFAULT; + readOnlyESet = false; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.UNSET, ModelPackageImpl.PROPERTY__READ_ONLY, oldReadOnly, READ_ONLY_EDEFAULT, oldReadOnlyESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isSetReadOnly() + { + return readOnlyESet; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Type getType_() + { + if (type != null && ((EObject)type).eIsProxy()) + { + InternalEObject oldType = (InternalEObject)type; + type = (Type)eResolveProxy(oldType); + if (type != oldType) + { + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, ModelPackageImpl.PROPERTY__TYPE, oldType, type)); + } + } + return type; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Type basicGetType() + { + return type; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setType(Type newType) + { + Type oldType = type; + type = newType; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ModelPackageImpl.PROPERTY__TYPE, oldType, type)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Sequence getAnyAttribute() + { + if (anyAttribute == null) + { + anyAttribute = new BasicSequence(new BasicFeatureMap(this, ModelPackageImpl.PROPERTY__ANY_ATTRIBUTE)); + } + return anyAttribute; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) + { + switch (featureID) + { + case ModelPackageImpl.PROPERTY__ANY: + return ((InternalEList)((FeatureMap.Internal.Wrapper)getAny()).featureMap()).basicRemove(otherEnd, msgs); + case ModelPackageImpl.PROPERTY__ANY_ATTRIBUTE: + return ((InternalEList)((FeatureMap.Internal.Wrapper)getAnyAttribute()).featureMap()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case ModelPackageImpl.PROPERTY__ALIAS_NAME: + return getAliasName(); + case ModelPackageImpl.PROPERTY__ANY: + if (coreType) return ((FeatureMap.Internal.Wrapper)getAny()).featureMap(); + return getAny(); + case ModelPackageImpl.PROPERTY__CONTAINMENT: + return isContainment() ? Boolean.TRUE : Boolean.FALSE; + case ModelPackageImpl.PROPERTY__DEFAULT: + return getDefault_(); + case ModelPackageImpl.PROPERTY__MANY: + return isMany() ? Boolean.TRUE : Boolean.FALSE; + case ModelPackageImpl.PROPERTY__NAME: + return getName(); + case ModelPackageImpl.PROPERTY__OPPOSITE: + if (resolve) return getOpposite_(); + return basicGetOpposite(); + case ModelPackageImpl.PROPERTY__READ_ONLY: + return isReadOnly() ? Boolean.TRUE : Boolean.FALSE; + case ModelPackageImpl.PROPERTY__TYPE: + if (resolve) return getType_(); + return basicGetType(); + case ModelPackageImpl.PROPERTY__ANY_ATTRIBUTE: + if (coreType) return ((FeatureMap.Internal.Wrapper)getAnyAttribute()).featureMap(); + return getAnyAttribute(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case ModelPackageImpl.PROPERTY__ALIAS_NAME: + getAliasName().clear(); + getAliasName().addAll((Collection)newValue); + return; + case ModelPackageImpl.PROPERTY__ANY: + ((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)getAny()).featureMap()).set(newValue); + return; + case ModelPackageImpl.PROPERTY__CONTAINMENT: + setContainment(((Boolean)newValue).booleanValue()); + return; + case ModelPackageImpl.PROPERTY__DEFAULT: + setDefault_((String)newValue); + return; + case ModelPackageImpl.PROPERTY__MANY: + setMany(((Boolean)newValue).booleanValue()); + return; + case ModelPackageImpl.PROPERTY__NAME: + setName((String)newValue); + return; + case ModelPackageImpl.PROPERTY__OPPOSITE: + setOpposite_((Property)newValue); + return; + case ModelPackageImpl.PROPERTY__READ_ONLY: + setReadOnly(((Boolean)newValue).booleanValue()); + return; + case ModelPackageImpl.PROPERTY__TYPE: + setType((Type)newValue); + return; + case ModelPackageImpl.PROPERTY__ANY_ATTRIBUTE: + ((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)getAnyAttribute()).featureMap()).set(newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case ModelPackageImpl.PROPERTY__ALIAS_NAME: + getAliasName().clear(); + return; + case ModelPackageImpl.PROPERTY__ANY: + ((FeatureMap.Internal.Wrapper)getAny()).featureMap().clear(); + return; + case ModelPackageImpl.PROPERTY__CONTAINMENT: + unsetContainment(); + return; + case ModelPackageImpl.PROPERTY__DEFAULT: + setDefault_(DEFAULT_EDEFAULT); + return; + case ModelPackageImpl.PROPERTY__MANY: + unsetMany(); + return; + case ModelPackageImpl.PROPERTY__NAME: + setName(NAME_EDEFAULT); + return; + case ModelPackageImpl.PROPERTY__OPPOSITE: + setOpposite_((Property)null); + return; + case ModelPackageImpl.PROPERTY__READ_ONLY: + unsetReadOnly(); + return; + case ModelPackageImpl.PROPERTY__TYPE: + setType((Type)null); + return; + case ModelPackageImpl.PROPERTY__ANY_ATTRIBUTE: + ((FeatureMap.Internal.Wrapper)getAnyAttribute()).featureMap().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case ModelPackageImpl.PROPERTY__ALIAS_NAME: + return aliasName != null && !aliasName.isEmpty(); + case ModelPackageImpl.PROPERTY__ANY: + return any != null && !any.featureMap().isEmpty(); + case ModelPackageImpl.PROPERTY__CONTAINMENT: + return isSetContainment(); + case ModelPackageImpl.PROPERTY__DEFAULT: + return DEFAULT_EDEFAULT == null ? default_ != null : !DEFAULT_EDEFAULT.equals(default_); + case ModelPackageImpl.PROPERTY__MANY: + return isSetMany(); + case ModelPackageImpl.PROPERTY__NAME: + return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); + case ModelPackageImpl.PROPERTY__OPPOSITE: + return opposite != null; + case ModelPackageImpl.PROPERTY__READ_ONLY: + return isSetReadOnly(); + case ModelPackageImpl.PROPERTY__TYPE: + return type != null; + case ModelPackageImpl.PROPERTY__ANY_ATTRIBUTE: + return anyAttribute != null && !anyAttribute.featureMap().isEmpty(); + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (aliasName: "); + result.append(aliasName); + result.append(", any: "); + result.append(any); + result.append(", containment: "); + if (containmentESet) result.append(containment); else result.append("<unset>"); + result.append(", default: "); + result.append(default_); + result.append(", many: "); + if (manyESet) result.append(many); else result.append("<unset>"); + result.append(", name: "); + result.append(name); + result.append(", readOnly: "); + if (readOnlyESet) result.append(readOnly); else result.append("<unset>"); + result.append(", anyAttribute: "); + result.append(anyAttribute); + result.append(')'); + return result.toString(); + } + +} //PropertyImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/TextTypeImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/TextTypeImpl.java new file mode 100644 index 0000000000..1c93857644 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/TextTypeImpl.java @@ -0,0 +1,173 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model.impl; + +import java.util.Collection; +import java.util.List; + + +import org.apache.tuscany.sdo.impl.DataObjectImpl; +import org.apache.tuscany.sdo.model.TextType; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.util.EDataTypeEList; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Text Type</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.sdo.model.impl.TextTypeImpl#getText <em>Text</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public abstract class TextTypeImpl extends DataObjectImpl implements TextType +{ + /** + * The cached value of the '{@link #getText() <em>Text</em>}' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getText() + * @generated + * @ordered + */ + protected EList text = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected TextTypeImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return ModelPackageImpl.Literals.TEXT_TYPE; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public List getText() + { + if (text == null) + { + text = new EDataTypeEList(String.class, this, ModelPackageImpl.TEXT_TYPE__TEXT); + } + return text; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case ModelPackageImpl.TEXT_TYPE__TEXT: + return getText(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case ModelPackageImpl.TEXT_TYPE__TEXT: + getText().clear(); + getText().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case ModelPackageImpl.TEXT_TYPE__TEXT: + getText().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case ModelPackageImpl.TEXT_TYPE__TEXT: + return text != null && !text.isEmpty(); + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (text: "); + result.append(text); + result.append(')'); + return result.toString(); + } + +} //TextTypeImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/TypeImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/TypeImpl.java new file mode 100644 index 0000000000..723858bec4 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/TypeImpl.java @@ -0,0 +1,854 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model.impl; + +import commonj.sdo.Sequence; + +import java.util.Collection; +import java.util.List; + + +import org.apache.tuscany.sdo.impl.DataObjectImpl; +import org.apache.tuscany.sdo.model.Property; +import org.apache.tuscany.sdo.model.Type; +import org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl; + +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.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; + +import org.eclipse.emf.ecore.util.BasicFeatureMap; +import org.eclipse.emf.ecore.util.EDataTypeEList; +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.EObjectResolvingEList; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Type</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.sdo.model.impl.TypeImpl#getBaseType <em>Base Type</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.TypeImpl#getProperty <em>Property</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.TypeImpl#getAliasName <em>Alias Name</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.TypeImpl#getAny <em>Any</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.TypeImpl#isAbstract <em>Abstract</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.TypeImpl#isDataType <em>Data Type</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.TypeImpl#getName <em>Name</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.TypeImpl#isOpen <em>Open</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.TypeImpl#isSequenced <em>Sequenced</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.TypeImpl#getUri <em>Uri</em>}</li> + * <li>{@link org.apache.tuscany.sdo.model.impl.TypeImpl#getAnyAttribute <em>Any Attribute</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class TypeImpl extends DataObjectImpl implements Type +{ + /** + * The cached value of the '{@link #getBaseType() <em>Base Type</em>}' reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getBaseType() + * @generated + * @ordered + */ + protected EList baseType = null; + + /** + * The cached value of the '{@link #getProperty() <em>Property</em>}' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getProperty() + * @generated + * @ordered + */ + protected EList property = null; + + /** + * The cached value of the '{@link #getAliasName() <em>Alias Name</em>}' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getAliasName() + * @generated + * @ordered + */ + protected EList aliasName = null; + + /** + * The cached value of the '{@link #getAny() <em>Any</em>}' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getAny() + * @generated + * @ordered + */ + protected BasicSequence any = null; + + /** + * The default value of the '{@link #isAbstract() <em>Abstract</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isAbstract() + * @generated + * @ordered + */ + protected static final boolean ABSTRACT_EDEFAULT = false; + + /** + * The cached value of the '{@link #isAbstract() <em>Abstract</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isAbstract() + * @generated + * @ordered + */ + protected boolean abstract_ = ABSTRACT_EDEFAULT; + + /** + * This is true if the Abstract attribute has been set. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + protected boolean abstractESet = false; + + /** + * The default value of the '{@link #isDataType() <em>Data Type</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isDataType() + * @generated + * @ordered + */ + protected static final boolean DATA_TYPE_EDEFAULT = false; + + /** + * The cached value of the '{@link #isDataType() <em>Data Type</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isDataType() + * @generated + * @ordered + */ + protected boolean dataType = DATA_TYPE_EDEFAULT; + + /** + * This is true if the Data Type attribute has been set. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + protected boolean dataTypeESet = false; + + /** + * The default value of the '{@link #getName() <em>Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getName() + * @generated + * @ordered + */ + protected static final String NAME_EDEFAULT = null; + + /** + * The cached value of the '{@link #getName() <em>Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getName() + * @generated + * @ordered + */ + protected String name = NAME_EDEFAULT; + + /** + * The default value of the '{@link #isOpen() <em>Open</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isOpen() + * @generated + * @ordered + */ + protected static final boolean OPEN_EDEFAULT = false; + + /** + * The cached value of the '{@link #isOpen() <em>Open</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isOpen() + * @generated + * @ordered + */ + protected boolean open = OPEN_EDEFAULT; + + /** + * This is true if the Open attribute has been set. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + protected boolean openESet = false; + + /** + * The default value of the '{@link #isSequenced() <em>Sequenced</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isSequenced() + * @generated + * @ordered + */ + protected static final boolean SEQUENCED_EDEFAULT = false; + + /** + * The cached value of the '{@link #isSequenced() <em>Sequenced</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isSequenced() + * @generated + * @ordered + */ + protected boolean sequenced = SEQUENCED_EDEFAULT; + + /** + * This is true if the Sequenced attribute has been set. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + protected boolean sequencedESet = false; + + /** + * The default value of the '{@link #getUri() <em>Uri</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getUri() + * @generated + * @ordered + */ + protected static final String URI_EDEFAULT = null; + + /** + * The cached value of the '{@link #getUri() <em>Uri</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getUri() + * @generated + * @ordered + */ + protected String uri = URI_EDEFAULT; + + /** + * The cached value of the '{@link #getAnyAttribute() <em>Any Attribute</em>}' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getAnyAttribute() + * @generated + * @ordered + */ + protected BasicSequence anyAttribute = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected TypeImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return ModelPackageImpl.Literals.TYPE; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public List getBaseType() + { + if (baseType == null) + { + baseType = new EObjectResolvingEList(Type.class, this, ModelPackageImpl.TYPE__BASE_TYPE); + } + return baseType; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public List getProperty() + { + if (property == null) + { + property = new EObjectContainmentEList(Property.class, this, ModelPackageImpl.TYPE__PROPERTY); + } + return property; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public List getAliasName() + { + if (aliasName == null) + { + aliasName = new EDataTypeEList(String.class, this, ModelPackageImpl.TYPE__ALIAS_NAME); + } + return aliasName; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Sequence getAny() + { + if (any == null) + { + any = new BasicSequence(new BasicFeatureMap(this, ModelPackageImpl.TYPE__ANY)); + } + return any; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isAbstract() + { + return abstract_; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setAbstract(boolean newAbstract) + { + boolean oldAbstract = abstract_; + abstract_ = newAbstract; + boolean oldAbstractESet = abstractESet; + abstractESet = true; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ModelPackageImpl.TYPE__ABSTRACT, oldAbstract, abstract_, !oldAbstractESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void unsetAbstract() + { + boolean oldAbstract = abstract_; + boolean oldAbstractESet = abstractESet; + abstract_ = ABSTRACT_EDEFAULT; + abstractESet = false; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.UNSET, ModelPackageImpl.TYPE__ABSTRACT, oldAbstract, ABSTRACT_EDEFAULT, oldAbstractESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isSetAbstract() + { + return abstractESet; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isDataType() + { + return dataType; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setDataType(boolean newDataType) + { + boolean oldDataType = dataType; + dataType = newDataType; + boolean oldDataTypeESet = dataTypeESet; + dataTypeESet = true; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ModelPackageImpl.TYPE__DATA_TYPE, oldDataType, dataType, !oldDataTypeESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void unsetDataType() + { + boolean oldDataType = dataType; + boolean oldDataTypeESet = dataTypeESet; + dataType = DATA_TYPE_EDEFAULT; + dataTypeESet = false; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.UNSET, ModelPackageImpl.TYPE__DATA_TYPE, oldDataType, DATA_TYPE_EDEFAULT, oldDataTypeESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isSetDataType() + { + return dataTypeESet; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getName() + { + return name; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setName(String newName) + { + String oldName = name; + name = newName; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ModelPackageImpl.TYPE__NAME, oldName, name)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isOpen() + { + return open; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setOpen(boolean newOpen) + { + boolean oldOpen = open; + open = newOpen; + boolean oldOpenESet = openESet; + openESet = true; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ModelPackageImpl.TYPE__OPEN, oldOpen, open, !oldOpenESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void unsetOpen() + { + boolean oldOpen = open; + boolean oldOpenESet = openESet; + open = OPEN_EDEFAULT; + openESet = false; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.UNSET, ModelPackageImpl.TYPE__OPEN, oldOpen, OPEN_EDEFAULT, oldOpenESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isSetOpen() + { + return openESet; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isSequenced() + { + return sequenced; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setSequenced(boolean newSequenced) + { + boolean oldSequenced = sequenced; + sequenced = newSequenced; + boolean oldSequencedESet = sequencedESet; + sequencedESet = true; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ModelPackageImpl.TYPE__SEQUENCED, oldSequenced, sequenced, !oldSequencedESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void unsetSequenced() + { + boolean oldSequenced = sequenced; + boolean oldSequencedESet = sequencedESet; + sequenced = SEQUENCED_EDEFAULT; + sequencedESet = false; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.UNSET, ModelPackageImpl.TYPE__SEQUENCED, oldSequenced, SEQUENCED_EDEFAULT, oldSequencedESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isSetSequenced() + { + return sequencedESet; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getUri() + { + return uri; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setUri(String newUri) + { + String oldUri = uri; + uri = newUri; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, ModelPackageImpl.TYPE__URI, oldUri, uri)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Sequence getAnyAttribute() + { + if (anyAttribute == null) + { + anyAttribute = new BasicSequence(new BasicFeatureMap(this, ModelPackageImpl.TYPE__ANY_ATTRIBUTE)); + } + return anyAttribute; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) + { + switch (featureID) + { + case ModelPackageImpl.TYPE__PROPERTY: + return ((InternalEList)getProperty()).basicRemove(otherEnd, msgs); + case ModelPackageImpl.TYPE__ANY: + return ((InternalEList)((FeatureMap.Internal.Wrapper)getAny()).featureMap()).basicRemove(otherEnd, msgs); + case ModelPackageImpl.TYPE__ANY_ATTRIBUTE: + return ((InternalEList)((FeatureMap.Internal.Wrapper)getAnyAttribute()).featureMap()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case ModelPackageImpl.TYPE__BASE_TYPE: + return getBaseType(); + case ModelPackageImpl.TYPE__PROPERTY: + return getProperty(); + case ModelPackageImpl.TYPE__ALIAS_NAME: + return getAliasName(); + case ModelPackageImpl.TYPE__ANY: + if (coreType) return ((FeatureMap.Internal.Wrapper)getAny()).featureMap(); + return getAny(); + case ModelPackageImpl.TYPE__ABSTRACT: + return isAbstract() ? Boolean.TRUE : Boolean.FALSE; + case ModelPackageImpl.TYPE__DATA_TYPE: + return isDataType() ? Boolean.TRUE : Boolean.FALSE; + case ModelPackageImpl.TYPE__NAME: + return getName(); + case ModelPackageImpl.TYPE__OPEN: + return isOpen() ? Boolean.TRUE : Boolean.FALSE; + case ModelPackageImpl.TYPE__SEQUENCED: + return isSequenced() ? Boolean.TRUE : Boolean.FALSE; + case ModelPackageImpl.TYPE__URI: + return getUri(); + case ModelPackageImpl.TYPE__ANY_ATTRIBUTE: + if (coreType) return ((FeatureMap.Internal.Wrapper)getAnyAttribute()).featureMap(); + return getAnyAttribute(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case ModelPackageImpl.TYPE__BASE_TYPE: + getBaseType().clear(); + getBaseType().addAll((Collection)newValue); + return; + case ModelPackageImpl.TYPE__PROPERTY: + getProperty().clear(); + getProperty().addAll((Collection)newValue); + return; + case ModelPackageImpl.TYPE__ALIAS_NAME: + getAliasName().clear(); + getAliasName().addAll((Collection)newValue); + return; + case ModelPackageImpl.TYPE__ANY: + ((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)getAny()).featureMap()).set(newValue); + return; + case ModelPackageImpl.TYPE__ABSTRACT: + setAbstract(((Boolean)newValue).booleanValue()); + return; + case ModelPackageImpl.TYPE__DATA_TYPE: + setDataType(((Boolean)newValue).booleanValue()); + return; + case ModelPackageImpl.TYPE__NAME: + setName((String)newValue); + return; + case ModelPackageImpl.TYPE__OPEN: + setOpen(((Boolean)newValue).booleanValue()); + return; + case ModelPackageImpl.TYPE__SEQUENCED: + setSequenced(((Boolean)newValue).booleanValue()); + return; + case ModelPackageImpl.TYPE__URI: + setUri((String)newValue); + return; + case ModelPackageImpl.TYPE__ANY_ATTRIBUTE: + ((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)getAnyAttribute()).featureMap()).set(newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case ModelPackageImpl.TYPE__BASE_TYPE: + getBaseType().clear(); + return; + case ModelPackageImpl.TYPE__PROPERTY: + getProperty().clear(); + return; + case ModelPackageImpl.TYPE__ALIAS_NAME: + getAliasName().clear(); + return; + case ModelPackageImpl.TYPE__ANY: + ((FeatureMap.Internal.Wrapper)getAny()).featureMap().clear(); + return; + case ModelPackageImpl.TYPE__ABSTRACT: + unsetAbstract(); + return; + case ModelPackageImpl.TYPE__DATA_TYPE: + unsetDataType(); + return; + case ModelPackageImpl.TYPE__NAME: + setName(NAME_EDEFAULT); + return; + case ModelPackageImpl.TYPE__OPEN: + unsetOpen(); + return; + case ModelPackageImpl.TYPE__SEQUENCED: + unsetSequenced(); + return; + case ModelPackageImpl.TYPE__URI: + setUri(URI_EDEFAULT); + return; + case ModelPackageImpl.TYPE__ANY_ATTRIBUTE: + ((FeatureMap.Internal.Wrapper)getAnyAttribute()).featureMap().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case ModelPackageImpl.TYPE__BASE_TYPE: + return baseType != null && !baseType.isEmpty(); + case ModelPackageImpl.TYPE__PROPERTY: + return property != null && !property.isEmpty(); + case ModelPackageImpl.TYPE__ALIAS_NAME: + return aliasName != null && !aliasName.isEmpty(); + case ModelPackageImpl.TYPE__ANY: + return any != null && !any.featureMap().isEmpty(); + case ModelPackageImpl.TYPE__ABSTRACT: + return isSetAbstract(); + case ModelPackageImpl.TYPE__DATA_TYPE: + return isSetDataType(); + case ModelPackageImpl.TYPE__NAME: + return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); + case ModelPackageImpl.TYPE__OPEN: + return isSetOpen(); + case ModelPackageImpl.TYPE__SEQUENCED: + return isSetSequenced(); + case ModelPackageImpl.TYPE__URI: + return URI_EDEFAULT == null ? uri != null : !URI_EDEFAULT.equals(uri); + case ModelPackageImpl.TYPE__ANY_ATTRIBUTE: + return anyAttribute != null && !anyAttribute.featureMap().isEmpty(); + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (aliasName: "); + result.append(aliasName); + result.append(", any: "); + result.append(any); + result.append(", abstract: "); + if (abstractESet) result.append(abstract_); else result.append("<unset>"); + result.append(", dataType: "); + if (dataTypeESet) result.append(dataType); else result.append("<unset>"); + result.append(", name: "); + result.append(name); + result.append(", open: "); + if (openESet) result.append(open); else result.append("<unset>"); + result.append(", sequenced: "); + if (sequencedESet) result.append(sequenced); else result.append("<unset>"); + result.append(", uri: "); + result.append(uri); + result.append(", anyAttribute: "); + result.append(anyAttribute); + result.append(')'); + return result.toString(); + } + + public String getInstanceClassName() + { + EStructuralFeature javaClassFeature = JavaPackageImpl.eINSTANCE.getDocumentRoot_JavaClass(); + Sequence anyAttribute = getAnyAttribute(); + int count = anyAttribute.size(); + for (int i = 0; i < count; i++) + { + EStructuralFeature eFeature = (EStructuralFeature)anyAttribute.getProperty(i); + if (eFeature == javaClassFeature) + { + return (String)anyAttribute.getValue(i); + } + } + return null; + } + +} //TypeImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/TypesImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/TypesImpl.java new file mode 100644 index 0000000000..59d3dda2c1 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/TypesImpl.java @@ -0,0 +1,182 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model.impl; + +import java.util.Collection; +import java.util.List; + + +import org.apache.tuscany.sdo.impl.DataObjectImpl; +import org.apache.tuscany.sdo.model.Type; +import org.apache.tuscany.sdo.model.Types; + +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Types</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.sdo.model.impl.TypesImpl#getType <em>Type</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class TypesImpl extends DataObjectImpl implements Types +{ + /** + * The cached value of the '{@link #getType() <em>Type</em>}' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getType() + * @generated + * @ordered + */ + protected EList type = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected TypesImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return ModelPackageImpl.Literals.TYPES; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public List getType_() + { + if (type == null) + { + type = new EObjectContainmentEList(Type.class, this, ModelPackageImpl.TYPES__TYPE); + } + return type; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) + { + switch (featureID) + { + case ModelPackageImpl.TYPES__TYPE: + return ((InternalEList)getType()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case ModelPackageImpl.TYPES__TYPE: + return getType(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case ModelPackageImpl.TYPES__TYPE: + getType_().clear(); + getType_().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case ModelPackageImpl.TYPES__TYPE: + getType_().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case ModelPackageImpl.TYPES__TYPE: + return type != null && !type.isEmpty(); + } + return super.eIsSet(featureID); + } + + public List getTypeList() + { + return getType_(); + } + +} //TypesImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/XSDTypeImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/XSDTypeImpl.java new file mode 100644 index 0000000000..6cd90b2400 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/impl/XSDTypeImpl.java @@ -0,0 +1,192 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model.impl; + +import commonj.sdo.Sequence; + + +import org.apache.tuscany.sdo.impl.DataObjectImpl; +import org.apache.tuscany.sdo.model.XSDType; + +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; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>XSD Type</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.sdo.model.impl.XSDTypeImpl#getAny <em>Any</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class XSDTypeImpl extends DataObjectImpl implements XSDType +{ + /** + * The cached value of the '{@link #getAny() <em>Any</em>}' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getAny() + * @generated + * @ordered + */ + protected BasicSequence any = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected XSDTypeImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return ModelPackageImpl.Literals.XSD_TYPE; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Sequence getAny() + { + if (any == null) + { + any = new BasicSequence(new BasicFeatureMap(this, ModelPackageImpl.XSD_TYPE__ANY)); + } + return any; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) + { + switch (featureID) + { + case ModelPackageImpl.XSD_TYPE__ANY: + return ((InternalEList)((FeatureMap.Internal.Wrapper)getAny()).featureMap()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case ModelPackageImpl.XSD_TYPE__ANY: + if (coreType) return ((FeatureMap.Internal.Wrapper)getAny()).featureMap(); + return getAny(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case ModelPackageImpl.XSD_TYPE__ANY: + ((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)getAny()).featureMap()).set(newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case ModelPackageImpl.XSD_TYPE__ANY: + ((FeatureMap.Internal.Wrapper)getAny()).featureMap().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case ModelPackageImpl.XSD_TYPE__ANY: + return any != null && !any.featureMap().isEmpty(); + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (any: "); + result.append(any); + result.append(')'); + return result.toString(); + } + +} //XSDTypeImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/java/JavaFactory.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/java/JavaFactory.java new file mode 100644 index 0000000000..2afdfdb65d --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/java/JavaFactory.java @@ -0,0 +1,49 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model.java; + + +/** + * <!-- begin-user-doc --> + * The <b>Factory</b> for the model. + * It provides a create method for each non-abstract class of the model. + * <!-- end-user-doc --> + * @generated + */ +public interface JavaFactory +{ + /** + * The singleton instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + JavaFactory INSTANCE = org.apache.tuscany.sdo.model.java.impl.JavaFactoryImpl.eINSTANCE; + + /** + * Returns a new object of class '<em>Info</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Info</em>'. + * @generated + */ + JavaInfo createJavaInfo(); + +} //JavaFactory diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/java/JavaInfo.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/java/JavaInfo.java new file mode 100644 index 0000000000..8ea0baf093 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/java/JavaInfo.java @@ -0,0 +1,63 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model.java; + + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Info</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.apache.tuscany.sdo.model.java.JavaInfo#getJavaClass <em>Java Class</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public interface JavaInfo +{ + /** + * Returns the value of the '<em><b>Java Class</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Java Class</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Java Class</em>' attribute. + * @see #setJavaClass(String) + * @generated + */ + String getJavaClass(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.java.JavaInfo#getJavaClass <em>Java Class</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Java Class</em>' attribute. + * @see #getJavaClass() + * @generated + */ + void setJavaClass(String value); + +} // JavaInfo diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/java/impl/JavaFactoryImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/java/impl/JavaFactoryImpl.java new file mode 100644 index 0000000000..d6284419b1 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/java/impl/JavaFactoryImpl.java @@ -0,0 +1,364 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model.java.impl; + +import org.apache.tuscany.sdo.model.java.*; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import org.eclipse.emf.ecore.plugin.EcorePlugin; +import org.eclipse.emf.ecore.xml.type.XMLTypeFactory; + +/** + * <!-- begin-user-doc --> + * An implementation of the model <b>Factory</b>. + * <!-- end-user-doc --> + * @generated + */ +public class JavaFactoryImpl extends EFactoryImpl implements JavaFactory +{ + /** + * The singleton instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final JavaFactoryImpl eINSTANCE = init(); + + /** + * Creates the default factory implementation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static JavaFactoryImpl init() + { + try + { + JavaFactoryImpl theJavaFactory = (JavaFactoryImpl)EPackage.Registry.INSTANCE.getEFactory("commonj.sdo/java"); + if (theJavaFactory != null) + { + return theJavaFactory; + } + } + catch (Exception exception) + { + EcorePlugin.INSTANCE.log(exception); + } + return new JavaFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public JavaFactoryImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EObject create(EClass eClass) + { + switch (eClass.getClassifierID()) + { + case JavaPackageImpl.DOCUMENT_ROOT: return (EObject)createDocumentRoot(); + case JavaPackageImpl.JAVA_INFO: return (EObject)createJavaInfo(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object createFromString(EDataType eDataType, String initialValue) + { + switch (eDataType.getClassifierID()) + { + case JavaPackageImpl.BOOLEAN_OBJECT: + return createBooleanObjectFromString(eDataType, initialValue); + case JavaPackageImpl.BYTE_OBJECT: + return createByteObjectFromString(eDataType, initialValue); + case JavaPackageImpl.CHARACTER_OBJECT: + return createCharacterObjectFromString(eDataType, initialValue); + case JavaPackageImpl.DOUBLE_OBJECT: + return createDoubleObjectFromString(eDataType, initialValue); + case JavaPackageImpl.FLOAT_OBJECT: + return createFloatObjectFromString(eDataType, initialValue); + case JavaPackageImpl.INT_OBJECT: + return createIntObjectFromString(eDataType, initialValue); + case JavaPackageImpl.LONG_OBJECT: + return createLongObjectFromString(eDataType, initialValue); + case JavaPackageImpl.SHORT_OBJECT: + return createShortObjectFromString(eDataType, initialValue); + default: + throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String convertToString(EDataType eDataType, Object instanceValue) + { + switch (eDataType.getClassifierID()) + { + case JavaPackageImpl.BOOLEAN_OBJECT: + return convertBooleanObjectToString(eDataType, instanceValue); + case JavaPackageImpl.BYTE_OBJECT: + return convertByteObjectToString(eDataType, instanceValue); + case JavaPackageImpl.CHARACTER_OBJECT: + return convertCharacterObjectToString(eDataType, instanceValue); + case JavaPackageImpl.DOUBLE_OBJECT: + return convertDoubleObjectToString(eDataType, instanceValue); + case JavaPackageImpl.FLOAT_OBJECT: + return convertFloatObjectToString(eDataType, instanceValue); + case JavaPackageImpl.INT_OBJECT: + return convertIntObjectToString(eDataType, instanceValue); + case JavaPackageImpl.LONG_OBJECT: + return convertLongObjectToString(eDataType, instanceValue); + case JavaPackageImpl.SHORT_OBJECT: + return convertShortObjectToString(eDataType, instanceValue); + default: + throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EObject createDocumentRoot() + { + EObject documentRoot = super.create(JavaPackageImpl.Literals.DOCUMENT_ROOT); + return documentRoot; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public JavaInfo createJavaInfo() + { + JavaInfoImpl javaInfo = new JavaInfoImpl(); + return javaInfo; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Boolean createBooleanObjectFromString(EDataType eDataType, String initialValue) + { + return XMLTypeFactory.eINSTANCE.createBooleanObject(initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertBooleanObjectToString(EDataType eDataType, Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertBooleanObject((Boolean)instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Byte createByteObjectFromString(EDataType eDataType, String initialValue) + { + return XMLTypeFactory.eINSTANCE.createByteObject(initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertByteObjectToString(EDataType eDataType, Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertByteObject((Byte)instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Character createCharacterObjectFromString(EDataType eDataType, String initialValue) + { + return (initialValue == null && initialValue.length() > 0) + ? null : (new Character(collapseWhiteSpace(initialValue).charAt(0))); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertCharacterObjectToString(EDataType eDataType, Object instanceValue) + { + return instanceValue == null ? null : instanceValue.toString(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Double createDoubleObjectFromString(EDataType eDataType, String initialValue) + { + return XMLTypeFactory.eINSTANCE.createDoubleObject(initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertDoubleObjectToString(EDataType eDataType, Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertDoubleObject((Double)instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Float createFloatObjectFromString(EDataType eDataType, String initialValue) + { + return XMLTypeFactory.eINSTANCE.createFloatObject(initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertFloatObjectToString(EDataType eDataType, Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertFloatObject((Float)instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Integer createIntObjectFromString(EDataType eDataType, String initialValue) + { + return XMLTypeFactory.eINSTANCE.createIntObject(initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertIntObjectToString(EDataType eDataType, Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertIntObject((Integer)instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Long createLongObjectFromString(EDataType eDataType, String initialValue) + { + return XMLTypeFactory.eINSTANCE.createLongObject(initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertLongObjectToString(EDataType eDataType, Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertLongObject((Long)instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public Short createShortObjectFromString(EDataType eDataType, String initialValue) + { + return XMLTypeFactory.eINSTANCE.createShortObject(initialValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated NOT + */ + public String convertShortObjectToString(EDataType eDataType, Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertShortObject((Short)instanceValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public JavaPackageImpl getJavaPackageImpl() + { + return (JavaPackageImpl)getEPackage(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @deprecated + * @generated + */ + public static JavaPackageImpl getPackage() + { + return JavaPackageImpl.eINSTANCE; + } + +} //JavaFactoryImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/java/impl/JavaInfoImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/java/impl/JavaInfoImpl.java new file mode 100644 index 0000000000..ba1e7e5ab6 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/java/impl/JavaInfoImpl.java @@ -0,0 +1,188 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model.java.impl; + +import org.apache.tuscany.sdo.impl.DataObjectImpl; + +import org.apache.tuscany.sdo.model.java.JavaInfo; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Info</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.sdo.model.java.impl.JavaInfoImpl#getJavaClass <em>Java Class</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class JavaInfoImpl extends DataObjectImpl implements JavaInfo +{ + /** + * The default value of the '{@link #getJavaClass() <em>Java Class</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getJavaClass() + * @generated + * @ordered + */ + protected static final String JAVA_CLASS_EDEFAULT = null; + + /** + * The cached value of the '{@link #getJavaClass() <em>Java Class</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getJavaClass() + * @generated + * @ordered + */ + protected String javaClass = JAVA_CLASS_EDEFAULT; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected JavaInfoImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return JavaPackageImpl.Literals.JAVA_INFO; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getJavaClass() + { + return javaClass; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setJavaClass(String newJavaClass) + { + String oldJavaClass = javaClass; + javaClass = newJavaClass; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, JavaPackageImpl.JAVA_INFO__JAVA_CLASS, oldJavaClass, javaClass)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case JavaPackageImpl.JAVA_INFO__JAVA_CLASS: + return getJavaClass(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case JavaPackageImpl.JAVA_INFO__JAVA_CLASS: + setJavaClass((String)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case JavaPackageImpl.JAVA_INFO__JAVA_CLASS: + setJavaClass(JAVA_CLASS_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case JavaPackageImpl.JAVA_INFO__JAVA_CLASS: + return JAVA_CLASS_EDEFAULT == null ? javaClass != null : !JAVA_CLASS_EDEFAULT.equals(javaClass); + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (javaClass: "); + result.append(javaClass); + result.append(')'); + return result.toString(); + } + +} //JavaInfoImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/java/impl/JavaPackageImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/java/impl/JavaPackageImpl.java new file mode 100644 index 0000000000..dace50c6c5 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/java/impl/JavaPackageImpl.java @@ -0,0 +1,1152 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.model.java.impl; + +import org.apache.tuscany.sdo.impl.SDOPackageImpl; + +import org.apache.tuscany.sdo.model.impl.ModelPackageImpl; + +import org.apache.tuscany.sdo.model.java.JavaFactory; +import org.apache.tuscany.sdo.model.java.JavaInfo; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EFactory; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +/** + * <!-- begin-user-doc --> + * The <b>Package</b> for the model. + * It contains accessors for the meta objects to represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.java.JavaFactory + * @generated + */ +public class JavaPackageImpl extends EPackageImpl +{ + /** + * The package name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final String eNAME = "java"; + + /** + * The package namespace URI. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final String eNS_URI = "commonj.sdo/java"; + + /** + * The package namespace name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final String eNS_PREFIX = "java"; + + /** + * The singleton instance of the package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final JavaPackageImpl eINSTANCE = org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl.init(); + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.model.java.impl.DocumentRootImpl <em>Document Root</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.java.impl.DocumentRootImpl + * @see org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl#getDocumentRoot() + * @generated + */ + public static final int DOCUMENT_ROOT = 0; + + /** + * The feature id for the '<em><b>Mixed</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__MIXED = 0; + + /** + * The feature id for the '<em><b>XMLNS Prefix Map</b></em>' map. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__XMLNS_PREFIX_MAP = 1; + + /** + * The feature id for the '<em><b>XSI Schema Location</b></em>' map. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__XSI_SCHEMA_LOCATION = 2; + + /** + * The feature id for the '<em><b>Extended Instance Class</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__EXTENDED_INSTANCE_CLASS = 3; + + /** + * The feature id for the '<em><b>Instance Class</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__INSTANCE_CLASS = 4; + + /** + * The feature id for the '<em><b>Java Class</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__JAVA_CLASS = 5; + + /** + * The feature id for the '<em><b>Nested Interfaces</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__NESTED_INTERFACES = 6; + + /** + * The feature id for the '<em><b>Package</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__PACKAGE = 7; + + /** + * The number of structural features of the '<em>Document Root</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT_FEATURE_COUNT = 8; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.model.java.impl.JavaInfoImpl <em>Info</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.java.impl.JavaInfoImpl + * @see org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl#getJavaInfo() + * @generated + */ + public static final int JAVA_INFO = 1; + + /** + * The feature id for the '<em><b>Java Class</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int JAVA_INFO__JAVA_CLASS = 0; + + /** + * The number of structural features of the '<em>Info</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int JAVA_INFO_FEATURE_COUNT = 1; + + /** + * The meta object id for the '<em>Boolean Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Boolean + * @see org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl#getBooleanObject() + * @generated + */ + public static final int BOOLEAN_OBJECT = 2; + + /** + * The meta object id for the '<em>Byte Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Byte + * @see org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl#getByteObject() + * @generated + */ + public static final int BYTE_OBJECT = 3; + + /** + * The meta object id for the '<em>Character Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Character + * @see org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl#getCharacterObject() + * @generated + */ + public static final int CHARACTER_OBJECT = 4; + + /** + * The meta object id for the '<em>Double Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Double + * @see org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl#getDoubleObject() + * @generated + */ + public static final int DOUBLE_OBJECT = 5; + + /** + * The meta object id for the '<em>Float Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Float + * @see org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl#getFloatObject() + * @generated + */ + public static final int FLOAT_OBJECT = 6; + + /** + * The meta object id for the '<em>Int Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Integer + * @see org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl#getIntObject() + * @generated + */ + public static final int INT_OBJECT = 7; + + /** + * The meta object id for the '<em>Long Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Long + * @see org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl#getLongObject() + * @generated + */ + public static final int LONG_OBJECT = 8; + + /** + * The meta object id for the '<em>Short Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Short + * @see org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl#getShortObject() + * @generated + */ + public static final int SHORT_OBJECT = 9; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass documentRootEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass javaInfoEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType booleanObjectEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType byteObjectEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType characterObjectEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType doubleObjectEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType floatObjectEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType intObjectEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType longObjectEDataType = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EDataType shortObjectEDataType = null; + + /** + * Creates an instance of the model <b>Package</b>, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + * <p>Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl#eNS_URI + * @see #init() + * @generated + */ + private JavaPackageImpl() + { + super(eNS_URI, ((EFactory)JavaFactory.INSTANCE)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the <b>Package</b> for this + * model, and for any others upon which it depends. Simple + * dependencies are satisfied by calling this method on all + * dependent packages before doing anything else. This method drives + * initialization for interdependent packages directly, in parallel + * with this package, itself. + * <p>Of this package and its interdependencies, all packages which + * have not yet been registered by their URI values are first created + * and registered. The packages are then initialized in two steps: + * meta-model objects for all of the packages are created before any + * are initialized, since one package's meta-model objects may refer to + * those of another. + * <p>Invocation of this method will not affect any packages that have + * already been initialized. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static JavaPackageImpl init() + { + if (isInited) return (JavaPackageImpl)EPackage.Registry.INSTANCE.getEPackage(JavaPackageImpl.eNS_URI); + + // Obtain or create and register package + JavaPackageImpl theJavaPackageImpl = (JavaPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof JavaPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new JavaPackageImpl()); + + isInited = true; + + // Initialize simple dependencies + SDOPackageImpl.eINSTANCE.eClass(); + ModelPackageImpl.eINSTANCE.eClass(); + + // Create package meta-data objects + theJavaPackageImpl.createPackageContents(); + + // Initialize created meta-data + theJavaPackageImpl.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theJavaPackageImpl.freeze(); + + return theJavaPackageImpl; + } + + + /** + * Returns the meta object for class '{@link org.eclipse.emf.ecore.EObject <em>Document Root</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Document Root</em>'. + * @see org.eclipse.emf.ecore.EObject + * @generated + */ + public EClass getDocumentRoot() + { + return documentRootEClass; + } + + /** + * Returns the meta object for the attribute list '{@link org.eclipse.emf.ecore.EObject#getMixed <em>Mixed</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute list '<em>Mixed</em>'. + * @see org.eclipse.emf.ecore.EObject#getMixed() + * @see #getDocumentRoot() + * @generated + */ + public EAttribute getDocumentRoot_Mixed() + { + return (EAttribute)documentRootEClass.getEStructuralFeatures().get(0); + } + + /** + * Returns the meta object for the map '{@link org.eclipse.emf.ecore.EObject#getXMLNSPrefixMap <em>XMLNS Prefix Map</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the map '<em>XMLNS Prefix Map</em>'. + * @see org.eclipse.emf.ecore.EObject#getXMLNSPrefixMap() + * @see #getDocumentRoot() + * @generated + */ + public EReference getDocumentRoot_XMLNSPrefixMap() + { + return (EReference)documentRootEClass.getEStructuralFeatures().get(1); + } + + /** + * Returns the meta object for the map '{@link org.eclipse.emf.ecore.EObject#getXSISchemaLocation <em>XSI Schema Location</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the map '<em>XSI Schema Location</em>'. + * @see org.eclipse.emf.ecore.EObject#getXSISchemaLocation() + * @see #getDocumentRoot() + * @generated + */ + public EReference getDocumentRoot_XSISchemaLocation() + { + return (EReference)documentRootEClass.getEStructuralFeatures().get(2); + } + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.ecore.EObject#getExtendedInstanceClass <em>Extended Instance Class</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Extended Instance Class</em>'. + * @see org.eclipse.emf.ecore.EObject#getExtendedInstanceClass() + * @see #getDocumentRoot() + * @generated + */ + public EAttribute getDocumentRoot_ExtendedInstanceClass() + { + return (EAttribute)documentRootEClass.getEStructuralFeatures().get(3); + } + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.ecore.EObject#getInstanceClass <em>Instance Class</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Instance Class</em>'. + * @see org.eclipse.emf.ecore.EObject#getInstanceClass() + * @see #getDocumentRoot() + * @generated + */ + public EAttribute getDocumentRoot_InstanceClass() + { + return (EAttribute)documentRootEClass.getEStructuralFeatures().get(4); + } + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.ecore.EObject#getJavaClass <em>Java Class</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Java Class</em>'. + * @see org.eclipse.emf.ecore.EObject#getJavaClass() + * @see #getDocumentRoot() + * @generated + */ + public EAttribute getDocumentRoot_JavaClass() + { + return (EAttribute)documentRootEClass.getEStructuralFeatures().get(5); + } + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.ecore.EObject#isNestedInterfaces <em>Nested Interfaces</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Nested Interfaces</em>'. + * @see org.eclipse.emf.ecore.EObject#isNestedInterfaces() + * @see #getDocumentRoot() + * @generated + */ + public EAttribute getDocumentRoot_NestedInterfaces() + { + return (EAttribute)documentRootEClass.getEStructuralFeatures().get(6); + } + + /** + * Returns the meta object for the attribute '{@link org.eclipse.emf.ecore.EObject#getPackage <em>Package</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Package</em>'. + * @see org.eclipse.emf.ecore.EObject#getPackage() + * @see #getDocumentRoot() + * @generated + */ + public EAttribute getDocumentRoot_Package() + { + return (EAttribute)documentRootEClass.getEStructuralFeatures().get(7); + } + + /** + * Returns the meta object for class '{@link org.apache.tuscany.sdo.model.java.JavaInfo <em>Info</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Info</em>'. + * @see org.apache.tuscany.sdo.model.java.JavaInfo + * @generated + */ + public EClass getJavaInfo() + { + return javaInfoEClass; + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.sdo.model.java.JavaInfo#getJavaClass <em>Java Class</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Java Class</em>'. + * @see org.apache.tuscany.sdo.model.java.JavaInfo#getJavaClass() + * @see #getJavaInfo() + * @generated + */ + public EAttribute getJavaInfo_JavaClass() + { + return (EAttribute)javaInfoEClass.getEStructuralFeatures().get(0); + } + + /** + * Returns the meta object for data type '{@link java.lang.Boolean <em>Boolean Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Boolean Object</em>'. + * @see java.lang.Boolean + * @generated + */ + public EDataType getBooleanObject() + { + return booleanObjectEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.Byte <em>Byte Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Byte Object</em>'. + * @see java.lang.Byte + * @generated + */ + public EDataType getByteObject() + { + return byteObjectEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.Character <em>Character Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Character Object</em>'. + * @see java.lang.Character + * @generated + */ + public EDataType getCharacterObject() + { + return characterObjectEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.Double <em>Double Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Double Object</em>'. + * @see java.lang.Double + * @generated + */ + public EDataType getDoubleObject() + { + return doubleObjectEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.Float <em>Float Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Float Object</em>'. + * @see java.lang.Float + * @generated + */ + public EDataType getFloatObject() + { + return floatObjectEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.Integer <em>Int Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Int Object</em>'. + * @see java.lang.Integer + * @generated + */ + public EDataType getIntObject() + { + return intObjectEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.Long <em>Long Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Long Object</em>'. + * @see java.lang.Long + * @generated + */ + public EDataType getLongObject() + { + return longObjectEDataType; + } + + /** + * Returns the meta object for data type '{@link java.lang.Short <em>Short Object</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for data type '<em>Short Object</em>'. + * @see java.lang.Short + * @generated + */ + public EDataType getShortObject() + { + return shortObjectEDataType; + } + + /** + * Returns the factory that creates the instances of the model. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the factory that creates the instances of the model. + * @generated + */ + public JavaFactory getJavaFactory() + { + return (JavaFactory)getEFactoryInstance(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void createPackageContents() + { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + documentRootEClass = createEClass(DOCUMENT_ROOT); + createEAttribute(documentRootEClass, DOCUMENT_ROOT__MIXED); + createEReference(documentRootEClass, DOCUMENT_ROOT__XMLNS_PREFIX_MAP); + createEReference(documentRootEClass, DOCUMENT_ROOT__XSI_SCHEMA_LOCATION); + createEAttribute(documentRootEClass, DOCUMENT_ROOT__EXTENDED_INSTANCE_CLASS); + createEAttribute(documentRootEClass, DOCUMENT_ROOT__INSTANCE_CLASS); + createEAttribute(documentRootEClass, DOCUMENT_ROOT__JAVA_CLASS); + createEAttribute(documentRootEClass, DOCUMENT_ROOT__NESTED_INTERFACES); + createEAttribute(documentRootEClass, DOCUMENT_ROOT__PACKAGE); + + javaInfoEClass = createEClass(JAVA_INFO); + createEAttribute(javaInfoEClass, JAVA_INFO__JAVA_CLASS); + + // Create data types + booleanObjectEDataType = createEDataType(BOOLEAN_OBJECT); + byteObjectEDataType = createEDataType(BYTE_OBJECT); + characterObjectEDataType = createEDataType(CHARACTER_OBJECT); + doubleObjectEDataType = createEDataType(DOUBLE_OBJECT); + floatObjectEDataType = createEDataType(FLOAT_OBJECT); + intObjectEDataType = createEDataType(INT_OBJECT); + longObjectEDataType = createEDataType(LONG_OBJECT); + shortObjectEDataType = createEDataType(SHORT_OBJECT); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void initializePackageContents() + { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Obtain other dependent packages + ModelPackageImpl theModelPackageImpl = (ModelPackageImpl)EPackage.Registry.INSTANCE.getEPackage(ModelPackageImpl.eNS_URI); + + // Add supertypes to classes + + // Initialize classes and features; add operations and parameters + initEClass(documentRootEClass, null, "DocumentRoot", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getDocumentRoot_Mixed(), ecorePackage.getEFeatureMapEntry(), "mixed", null, 0, -1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getDocumentRoot_XMLNSPrefixMap(), ecorePackage.getEStringToStringMapEntry(), null, "xMLNSPrefixMap", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getDocumentRoot_XSISchemaLocation(), ecorePackage.getEStringToStringMapEntry(), null, "xSISchemaLocation", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getDocumentRoot_ExtendedInstanceClass(), theModelPackageImpl.getString(), "extendedInstanceClass", null, 0, 1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getDocumentRoot_InstanceClass(), theModelPackageImpl.getString(), "instanceClass", null, 0, 1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getDocumentRoot_JavaClass(), theModelPackageImpl.getString(), "javaClass", null, 0, 1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getDocumentRoot_NestedInterfaces(), theModelPackageImpl.getBoolean(), "nestedInterfaces", null, 0, 1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getDocumentRoot_Package(), theModelPackageImpl.getString(), "package", null, 0, 1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(javaInfoEClass, JavaInfo.class, "JavaInfo", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getJavaInfo_JavaClass(), theModelPackageImpl.getString(), "javaClass", null, 0, 1, JavaInfo.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Initialize data types + initEDataType(booleanObjectEDataType, Boolean.class, "BooleanObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(byteObjectEDataType, Byte.class, "ByteObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(characterObjectEDataType, Character.class, "CharacterObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(doubleObjectEDataType, Double.class, "DoubleObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(floatObjectEDataType, Float.class, "FloatObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(intObjectEDataType, Integer.class, "IntObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(longObjectEDataType, Long.class, "LongObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(shortObjectEDataType, Short.class, "ShortObject", IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + + // Create resource + createResource(eNS_URI); + + // Create annotations + // http:///org/eclipse/emf/ecore/util/ExtendedMetaData + createExtendedMetaDataAnnotations(); + } + + /** + * Initializes the annotations for <b>http:///org/eclipse/emf/ecore/util/ExtendedMetaData</b>. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected void createExtendedMetaDataAnnotations() + { + String source = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData"; + addAnnotation + (booleanObjectEDataType, + source, + new String[] + { + "name", "BooleanObject" + }); + addAnnotation + (byteObjectEDataType, + source, + new String[] + { + "name", "ByteObject" + }); + addAnnotation + (characterObjectEDataType, + source, + new String[] + { + "name", "CharacterObject" + }); + addAnnotation + (documentRootEClass, + source, + new String[] + { + "name", "", + "kind", "mixed" + }); + addAnnotation + (getDocumentRoot_Mixed(), + source, + new String[] + { + "kind", "elementWildcard", + "name", ":mixed" + }); + addAnnotation + (getDocumentRoot_XMLNSPrefixMap(), + source, + new String[] + { + "kind", "attribute", + "name", "xmlns:prefix" + }); + addAnnotation + (getDocumentRoot_XSISchemaLocation(), + source, + new String[] + { + "kind", "attribute", + "name", "xsi:schemaLocation" + }); + addAnnotation + (getDocumentRoot_ExtendedInstanceClass(), + source, + new String[] + { + "kind", "attribute", + "name", "extendedInstanceClass", + "namespace", "##targetNamespace" + }); + addAnnotation + (getDocumentRoot_InstanceClass(), + source, + new String[] + { + "kind", "attribute", + "name", "instanceClass", + "namespace", "##targetNamespace" + }); + addAnnotation + (getDocumentRoot_JavaClass(), + source, + new String[] + { + "kind", "attribute", + "name", "javaClass", + "namespace", "##targetNamespace" + }); + addAnnotation + (getDocumentRoot_NestedInterfaces(), + source, + new String[] + { + "kind", "attribute", + "name", "nestedInterfaces", + "namespace", "##targetNamespace" + }); + addAnnotation + (getDocumentRoot_Package(), + source, + new String[] + { + "kind", "attribute", + "name", "package", + "namespace", "##targetNamespace" + }); + addAnnotation + (doubleObjectEDataType, + source, + new String[] + { + "name", "DoubleObject" + }); + addAnnotation + (floatObjectEDataType, + source, + new String[] + { + "name", "FloatObject" + }); + addAnnotation + (intObjectEDataType, + source, + new String[] + { + "name", "IntObject" + }); + addAnnotation + (javaInfoEClass, + source, + new String[] + { + "name", "JavaInfo", + "kind", "empty" + }); + addAnnotation + (getJavaInfo_JavaClass(), + source, + new String[] + { + "kind", "attribute", + "name", "javaClass", + "namespace", "##targetNamespace" + }); + addAnnotation + (longObjectEDataType, + source, + new String[] + { + "name", "LongObject" + }); + addAnnotation + (shortObjectEDataType, + source, + new String[] + { + "name", "ShortObject" + }); + } + + /** + * <!-- begin-user-doc --> + * Defines literals for the meta objects that represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @generated + */ + public interface Literals + { + /** + * The meta object literal for the '{@link org.apache.tuscany.sdo.model.java.impl.DocumentRootImpl <em>Document Root</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.java.impl.DocumentRootImpl + * @see org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl#getDocumentRoot() + * @generated + */ + public static final EClass DOCUMENT_ROOT = eINSTANCE.getDocumentRoot(); + + /** + * The meta object literal for the '<em><b>Mixed</b></em>' attribute list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute DOCUMENT_ROOT__MIXED = eINSTANCE.getDocumentRoot_Mixed(); + + /** + * The meta object literal for the '<em><b>XMLNS Prefix Map</b></em>' map feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference DOCUMENT_ROOT__XMLNS_PREFIX_MAP = eINSTANCE.getDocumentRoot_XMLNSPrefixMap(); + + /** + * The meta object literal for the '<em><b>XSI Schema Location</b></em>' map feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference DOCUMENT_ROOT__XSI_SCHEMA_LOCATION = eINSTANCE.getDocumentRoot_XSISchemaLocation(); + + /** + * The meta object literal for the '<em><b>Extended Instance Class</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute DOCUMENT_ROOT__EXTENDED_INSTANCE_CLASS = eINSTANCE.getDocumentRoot_ExtendedInstanceClass(); + + /** + * The meta object literal for the '<em><b>Instance Class</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute DOCUMENT_ROOT__INSTANCE_CLASS = eINSTANCE.getDocumentRoot_InstanceClass(); + + /** + * The meta object literal for the '<em><b>Java Class</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute DOCUMENT_ROOT__JAVA_CLASS = eINSTANCE.getDocumentRoot_JavaClass(); + + /** + * The meta object literal for the '<em><b>Nested Interfaces</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute DOCUMENT_ROOT__NESTED_INTERFACES = eINSTANCE.getDocumentRoot_NestedInterfaces(); + + /** + * The meta object literal for the '<em><b>Package</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute DOCUMENT_ROOT__PACKAGE = eINSTANCE.getDocumentRoot_Package(); + + /** + * The meta object literal for the '{@link org.apache.tuscany.sdo.model.java.impl.JavaInfoImpl <em>Info</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.model.java.impl.JavaInfoImpl + * @see org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl#getJavaInfo() + * @generated + */ + public static final EClass JAVA_INFO = eINSTANCE.getJavaInfo(); + + /** + * The meta object literal for the '<em><b>Java Class</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute JAVA_INFO__JAVA_CLASS = eINSTANCE.getJavaInfo_JavaClass(); + + /** + * The meta object literal for the '<em>Boolean Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Boolean + * @see org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl#getBooleanObject() + * @generated + */ + public static final EDataType BOOLEAN_OBJECT = eINSTANCE.getBooleanObject(); + + /** + * The meta object literal for the '<em>Byte Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Byte + * @see org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl#getByteObject() + * @generated + */ + public static final EDataType BYTE_OBJECT = eINSTANCE.getByteObject(); + + /** + * The meta object literal for the '<em>Character Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Character + * @see org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl#getCharacterObject() + * @generated + */ + public static final EDataType CHARACTER_OBJECT = eINSTANCE.getCharacterObject(); + + /** + * The meta object literal for the '<em>Double Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Double + * @see org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl#getDoubleObject() + * @generated + */ + public static final EDataType DOUBLE_OBJECT = eINSTANCE.getDoubleObject(); + + /** + * The meta object literal for the '<em>Float Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Float + * @see org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl#getFloatObject() + * @generated + */ + public static final EDataType FLOAT_OBJECT = eINSTANCE.getFloatObject(); + + /** + * The meta object literal for the '<em>Int Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Integer + * @see org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl#getIntObject() + * @generated + */ + public static final EDataType INT_OBJECT = eINSTANCE.getIntObject(); + + /** + * The meta object literal for the '<em>Long Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Long + * @see org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl#getLongObject() + * @generated + */ + public static final EDataType LONG_OBJECT = eINSTANCE.getLongObject(); + + /** + * The meta object literal for the '<em>Short Object</em>' data type. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see java.lang.Short + * @see org.apache.tuscany.sdo.model.java.impl.JavaPackageImpl#getShortObject() + * @generated + */ + public static final EDataType SHORT_OBJECT = eINSTANCE.getShortObject(); + + } + +} //JavaPackageImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/BasicSequence.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/BasicSequence.java new file mode 100644 index 0000000000..4de8b6e1a7 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/BasicSequence.java @@ -0,0 +1,137 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.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/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataGraphResourceFactoryImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataGraphResourceFactoryImpl.java new file mode 100644 index 0000000000..d1b86d59fa --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataGraphResourceFactoryImpl.java @@ -0,0 +1,699 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.util; + + +import java.io.IOException; +import java.io.InputStream; +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.helper.TypeHelperImpl; +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.w3c.dom.Node; +import org.xml.sax.InputSource; +import org.xml.sax.helpers.DefaultHandler; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.helper.TypeHelper; + + +public class DataGraphResourceFactoryImpl extends ResourceFactoryImpl +{ + /** + * Constructor for DataGraphResourceFactoryImpl. + */ + public DataGraphResourceFactoryImpl() + { + super(); + } + + public Resource createResource(URI uri) + { + XMLResourceImpl result = new DataGraphResourceImpl(uri); + + ExtendedMetaData extendedMetaData = ((TypeHelperImpl)TypeHelper.INSTANCE).getExtendedMetaData(); + DataObjectUtil.configureXMLResource(result, extendedMetaData); + + result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE); + result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_DEPRECATED_METHODS, Boolean.TRUE); + //result.setEncoding("UTF-8"); + //result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE); + //result.getDefaultSaveOptions().put(XMLResource.OPTION_LINE_WIDTH, new Integer(80)); + + 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) + { + String fragment = super.getIDREF(eObject); + if (fragment.startsWith("/")) + { + int index = resources.indexOf(eObject.eResource()); + if (index != -1) + { + fragment = ((String)uris.get(index)).substring(1) + fragment.substring(1); + } + } + return fragment; + } + + 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("<?xml version=\"" + xmlVersion + "\" encoding=\"" + encoding + "\"?>"); + 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", ""); + doc.addAttribute("logging", String.valueOf(eDataGraph.getEChangeSummary().isLogging())); + } + else + { + ((Element)currentNode).setAttributeNS(ExtendedMetaData.XMLNS_URI, ExtendedMetaData.XMLNS_PREFIX, ""); + ((Element)currentNode).setAttributeNS("", "logging", String.valueOf(eDataGraph.getEChangeSummary().isLogging())); + } + } + } + + protected EObject getSchemaLocationRoot(EObject eObject) + { + return eDataGraph.getERootObject(); + } + } + + protected XMLSave createXMLSave() + { + return new SaveImpl(createXMLHelper()); + } + + public static class LoadImpl extends XMLLoadImpl + { + protected boolean resumeLogging = false; + + public void load(XMLResource resource, InputSource inputSource, Map options) throws IOException + { + super.load(resource, inputSource, options); + if (resumeLogging) ((ChangeSummaryImpl)((DataGraphImpl)resource.getContents().get(0)).getChangeSummary()).resumeLogging(); + } + + public void load(XMLResource resource, InputStream inputStream, Map options) throws IOException + { + super.load(resource, inputStream, options); + if (resumeLogging) ((ChangeSummaryImpl)((DataGraphImpl)resource.getContents().get(0)).getChangeSummary()).resumeLogging(); + } + + public void load(XMLResource resource, Node node, Map options) throws IOException + { + super.load(resource, node, options); + if (resumeLogging) ((ChangeSummaryImpl)((DataGraphImpl)resource.getContents().get(0)).getChangeSummary()).resumeLogging(); + } + + 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 EObject createDocumentRoot(String prefix, String uri, String name, EFactory eFactory, boolean top) + { + return null; + } + + protected void setAttribValue(EObject object, String name, String value) + { + if ("logging".equals(name) && object instanceof ChangeSummaryImpl) + { + resumeLogging = Boolean.valueOf(value).booleanValue(); + } + else + { + super.setAttribValue(object, name, value); + } + } + + 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, "ChangeSummary"); + 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 (useNewMethods) + { + handleSchemaLocation(); + } + processSchemaLocations(prefix, name); + 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, "DataGraph"); + } + } + 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/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java new file mode 100644 index 0000000000..328858bcaf --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java @@ -0,0 +1,2681 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.util; + + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.text.SimpleDateFormat; +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 java.util.TimeZone; + +import org.apache.tuscany.sdo.SDOExtendedMetaData; +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.impl.DataGraphImpl; +import org.apache.tuscany.sdo.impl.SDOFactoryImpl; +import org.apache.tuscany.sdo.util.resource.SDOXMLResourceFactoryImpl; +import org.eclipse.emf.common.util.BasicEList; +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.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.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.EcoreFactory; +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.XMLOptions; +import org.eclipse.emf.ecore.xmi.XMLParserPool; +import org.eclipse.emf.ecore.xmi.XMLResource; +import org.eclipse.emf.ecore.xmi.impl.EMOFResourceFactoryImpl; +import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; +import org.eclipse.emf.ecore.xmi.impl.XMLOptionsImpl; +import org.eclipse.emf.ecore.xmi.impl.XMLParserPoolImpl; +import org.eclipse.emf.ecore.xml.type.XMLTypeFactory; +import org.eclipse.xsd.util.XSDResourceFactoryImpl; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Sequence; +import commonj.sdo.Type; +import commonj.sdo.helper.DataHelper; +import commonj.sdo.helper.TypeHelper; + + +public final class DataObjectUtil +{ + public static void setString(DataObject dataObject, Property property, String value) { + dataObject.set(property, getSetValue(property, value)); + } + + public static void setShort(DataObject dataObject, Property property, short value) { + dataObject.set(property, getSetValue(property, value)); + } + + public static void setLong(DataObject dataObject, Property property, long value) { + dataObject.set(property, getSetValue(property, value)); + } + + public static void setList(DataObject dataObject, Property property, List value) { + dataObject.set(property, value); + } + + public static void setInt(DataObject dataObject, Property property, int value) { + dataObject.set(property, getSetValue(property, value)); + } + + public static void setFloat(DataObject dataObject, Property property, float value) { + dataObject.set(property, getSetValue(property, value)); + } + + public static void setDouble(DataObject dataObject, Property property, double value) { + dataObject.set(property, getSetValue(property, value)); + } + + public static void setDate(DataObject dataObject, Property property, Date value) { + dataObject.set(property, getSetValue(property, value)); + } + + public static void setDataObject(DataObject dataObject, Property property, DataObject value) { + dataObject.set(property, value); + } + + public static void setChar(DataObject dataObject, Property property, char value) { + dataObject.set(property, getSetValue(property, value)); + } + + public static void setBytes(DataObject dataObject, Property property, byte[] value) { + dataObject.set(property, getSetValue(property, value)); + } + + public static void setByte(DataObject dataObject, Property property, byte value) { + dataObject.set(property, getSetValue(property, value)); + } + + public static void setBoolean(DataObject dataObject, Property property, boolean value) { + dataObject.set(property, getSetValue(property, value)); + } + + public static void setBigInteger(DataObject dataObject, Property property, BigInteger value) + { + dataObject.set(property, getSetValue(property, value)); + } + + public static void setBigDecimal(DataObject dataObject, Property property, BigDecimal value) + { + dataObject.set(property, getSetValue(property, value)); + } + + public static String getString(DataObject dataObject, Property property) + { + return getString(dataObject.get(property)); + } + + public static short getShort(DataObject dataObject, Property property) + { + return getShort(dataObject.get(property)); + } + + public static Sequence getSequence(DataObject dataObject, Property property) + { + return (Sequence)dataObject.get(property); + } + + public static long getLong(DataObject dataObject, Property property) + { + return getLong(dataObject.get(property)); + } + + public static List getList(DataObject dataObject, Property property) + { + return (List)dataObject.get(property); + } + + public static int getInt(DataObject dataObject, Property property) + { + return getInt(dataObject.get(property)); + } + + public static float getFloat(DataObject dataObject, Property property) + { + return getFloat(dataObject.get(property)); + } + + public static double getDouble(DataObject dataObject, Property property) + { + return getDouble(dataObject.get(property)); + } + + public static Date getDate(DataObject dataObject, Property property) + { + return getDate(dataObject.get(property)); + } + + public static DataObject getDataObject(DataObject dataObject, Property property) + { + return (DataObject)dataObject.get(property); + } + + public static char getChar(DataObject dataObject, Property property) + { + return getChar(dataObject.get(property)); + } + + public static byte[] getBytes(DataObject dataObject, Property property) + { + return getBytes(dataObject.get(property)); + } + + public static byte getByte(DataObject dataObject, Property property) + { + return getByte(dataObject.get(property)); + } + + public static boolean getBoolean(DataObject dataObject, Property property) + { + return getBoolean(dataObject.get(property)); + } + + public static BigInteger getBigInteger(DataObject dataObject, Property property) + { + return getBigInteger(dataObject.get(property)); + } + + public static BigDecimal getBigDecimal(DataObject dataObject, Property property) + { + return getBigDecimal(dataObject.get(property)); + } + + + + private static Property getPropertyByIndex(DataObject dataObject, int propertyIndex) { + EObject eObject = (EObject) dataObject; + Property property = (Property)eObject.eClass().getEStructuralFeature(propertyIndex); + return property; + } + + public static void setString(DataObject dataObject, int propertyIndex, String value) { + dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); + } + + public static void setShort(DataObject dataObject, int propertyIndex, short value) { + dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); + } + + public static void setLong(DataObject dataObject, int propertyIndex, long value) { + dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); + } + + public static void setList(DataObject dataObject, int propertyIndex, List value) { + dataObject.set(propertyIndex, value); + } + + public static void setInt(DataObject dataObject, int propertyIndex, int value) { + dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); + } + + public static void setFloat(DataObject dataObject, int propertyIndex, float value) { + dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); + } + + public static void setDouble(DataObject dataObject, int propertyIndex, double value) { + dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); + } + + public static void setDate(DataObject dataObject, int propertyIndex, Date value) { + dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); + } + + public static void setDataObject(DataObject dataObject, int propertyIndex, DataObject value) { + dataObject.set(propertyIndex, value); + } + + public static void setChar(DataObject dataObject, int propertyIndex, char value) { + dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); + } + + public static void setBytes(DataObject dataObject, int propertyIndex, byte[] value) { + dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); + } + + public static void setByte(DataObject dataObject, int propertyIndex, byte value) { + dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); + } + + public static void setBoolean(DataObject dataObject, int propertyIndex, boolean value) { + dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); + } + + public static void setBigInteger(DataObject dataObject, int propertyIndex, BigInteger value) + { + dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); + } + + public static void setBigDecimal(DataObject dataObject, int propertyIndex, BigDecimal value) + { + dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); + } + + public static String getString(DataObject dataObject, int propertyIndex) + { + return getString(dataObject.get(propertyIndex)); + } + + public static short getShort(DataObject dataObject, int propertyIndex) + { + return getShort(dataObject.get(propertyIndex)); + } + + public static Sequence getSequence(DataObject dataObject, int propertyIndex) + { + return (Sequence)dataObject.get(propertyIndex); + } + + public static long getLong(DataObject dataObject, int propertyIndex) + { + return getLong(dataObject.get(propertyIndex)); + } + + public static List getList(DataObject dataObject, int propertyIndex) + { + return (List)dataObject.get(propertyIndex); + } + + public static int getInt(DataObject dataObject, int propertyIndex) + { + return getInt(dataObject.get(propertyIndex)); + } + + public static float getFloat(DataObject dataObject, int propertyIndex) + { + return getFloat(dataObject.get(propertyIndex)); + } + + public static double getDouble(DataObject dataObject, int propertyIndex) + { + return getDouble(dataObject.get(propertyIndex)); + } + + public static Date getDate(DataObject dataObject, int propertyIndex) + { + return getDate(dataObject.get(propertyIndex)); + } + + public static DataObject getDataObject(DataObject dataObject, int propertyIndex) + { + return (DataObject)dataObject.get(propertyIndex); + } + + public static char getChar(DataObject dataObject, int propertyIndex) + { + return getChar(dataObject.get(propertyIndex)); + } + + public static byte[] getBytes(DataObject dataObject, int propertyIndex) + { + return getBytes(dataObject.get(propertyIndex)); + } + + public static byte getByte(DataObject dataObject, int propertyIndex) + { + return getByte(dataObject.get(propertyIndex)); + } + + public static boolean getBoolean(DataObject dataObject, int propertyIndex) + { + return getBoolean(dataObject.get(propertyIndex)); + } + + public static BigInteger getBigInteger(DataObject dataObject, int propertyIndex) + { + return getBigInteger(dataObject.get(propertyIndex)); + } + + public static BigDecimal getBigDecimal(DataObject dataObject, int propertyIndex) + { + return getBigDecimal(dataObject.get(propertyIndex)); + } + + public static void detach(DataObject dataObject) { + EcoreUtil.remove((EObject)dataObject); + } + + public static DataObject getRootObject(DataObject dataObject) + { + return (DataObject)EcoreUtil.getRootContainer((EObject)dataObject); + } + + public static List getInstanceProperties(DataObject dataObject) + { + //TODO maybe optimize this to just return type.getProperties if type.isOpen (isOpen would need to be cached) + EObject eDataObject = (EObject) dataObject; + List result = new UniqueEList(eDataObject.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)eDataObject.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; + } + + public static void delete(DataObject dataObject) + { + EObject eDataObject = (EObject)dataObject; + EcoreUtil.remove(eDataObject); + List contents = new ArrayList((eDataObject).eContents()); + for (int i = 0, size = contents.size(); i < size; ++i) + { + ((DataObject)contents.get(i)).delete(); + } + EClass eClass = eDataObject.eClass(); + for (int i = 0, size = eClass.getFeatureCount(); i < size; ++i) + { + EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature(i); + if (eStructuralFeature.isChangeable() && !eStructuralFeature.isDerived() && !((Property)eStructuralFeature).isReadOnly()) + { + eDataObject.eUnset(eStructuralFeature); + } + } + } + + public static DataObject createDataObject(DataObject dataObject, 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((EObject)dataObject, (EStructuralFeature)property)) + { + ((List)dataObject.get(property)).add(result); + } + else + { + dataObject.set(property, result); + } + return result; + } + + public static DataObject createDataObject(DataObject dataObject, int propertyIndex, String namespaceURI, String typeName) + { + Property property = DataObjectUtil.getProperty(dataObject, propertyIndex); + Type type = DataObjectUtil.getType(dataObject, namespaceURI, typeName); + return createDataObject(dataObject, property, type); + } + + public static DataObject createDataObject(DataObject dataObject, String propertyName, String namespaceURI, String typeName) + { + Property property = getProperty(dataObject, propertyName); + Type type = DataObjectUtil.getType(dataObject, namespaceURI, typeName); + return createDataObject(dataObject, property, type); + } + + public static DataObject createDataObject(DataObject dataObject, Property property) + { + Type type = property.getType(); + return createDataObject(dataObject, property, type); + } + + public static DataObject createDataObject(DataObject dataObject, int propertyIndex) + { + Property property = getProperty(dataObject, propertyIndex); + Type type = property.getType(); + return createDataObject(dataObject,property, type); + } + + public static DataObject createDataObject(DataObject dataObject, String propertyName) + { + Property property = (Property)getProperty(dataObject, propertyName); + Type type = property.getType(); + return createDataObject(dataObject,property, type); + } + + public static void setString(DataObject dataObject, String path, String value) + { + Property property = dataObject.getType().getProperty(path); + if (property != null) + { + dataObject.set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + + public static void setShort(DataObject dataObject, String path, short value) + { + Property property = dataObject.getType().getProperty(path); + if (property != null) + { + dataObject.set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + public static void setLong(DataObject dataObject, String path, long value) + { + Property property = dataObject.getType().getProperty(path); + if (property != null) + { + dataObject.set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + public static void setList(DataObject dataObject, String path, List value) + { + dataObject.set(path, value); + } + + public static void setInt(DataObject dataObject, String path, int value) + { + Property property = dataObject.getType().getProperty(path); + if (property != null) + { + dataObject.set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + public static void setFloat(DataObject dataObject, String path, float value) + { + Property property = dataObject.getType().getProperty(path); + if (property != null) + { + dataObject.set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + public static void setDouble(DataObject dataObject, String path, double value) + { + Property property = dataObject.getType().getProperty(path); + if (property != null) + { + dataObject.set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + public static void setDate(DataObject dataObject, String path, Date value) + { + Property property = dataObject.getType().getProperty(path); + if (property != null) + { + dataObject.set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + public static void setDataObject(DataObject dataObject, String path, DataObject value) + { + dataObject.set(path, value); + } + + public static void setChar(DataObject dataObject, String path, char value) + { + Property property = dataObject.getType().getProperty(path); + if (property != null) + { + dataObject.set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + public static void setBytes(DataObject dataObject, String path, byte[] value) + { + Property property = dataObject.getType().getProperty(path); + if (property != null) + { + dataObject.set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + public static void setByte(DataObject dataObject, String path, byte value) + { + Property property = dataObject.getType().getProperty(path); + if (property != null) + { + dataObject.set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + public static void setBoolean(DataObject dataObject, String path, boolean value) + { + Property property = dataObject.getType().getProperty(path); + if (property != null) + { + dataObject.set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + public static void setBigInteger(DataObject dataObject, String path, BigInteger value) + { + Property property = dataObject.getType().getProperty(path); + if (property != null) + { + dataObject.set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + public static void setBigDecimal(DataObject dataObject, String path, BigDecimal value) + { + Property property = dataObject.getType().getProperty(path); + if (property != null) + { + dataObject.set(property, DataObjectUtil.getSetValue(property, value)); + } + else + { + DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); + accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); + } + } + + public static DataGraph getDataGraph(DataObject dataObject) + { + Resource resource = ((EObject)dataObject).eResource(); + if (resource != null) + { + ResourceSet resourceSet = resource.getResourceSet(); + if (resourceSet != null) + { + return (DataGraphImpl)EcoreUtil.getAdapter(resourceSet.eAdapters(), DataGraph.class); + } + } + return null; + } + + public static ChangeSummary getChangeSummary(DataObject dataObject) + { + DataGraph dataGraph = getDataGraph(dataObject); + if (dataGraph != null) + { + return dataGraph.getChangeSummary(); + } + // TODO: handle ChangeSummary-type property + return null; + } + + public static void unset(DataObject dataObject, String path) + { + Property property = dataObject.getType().getProperty(path); + if (property != null) + { + dataObject.unset(property); + } + else + { + DataObjectUtil.Accessor.create((EObject)dataObject, path).unsetAndRecyle(); + } + } + + public static boolean isSet(DataObject dataObject, String path) + { + Property property = dataObject.getType().getProperty(path); + if (property != null) + { + return dataObject.isSet(property); + } + else + { + return DataObjectUtil.Accessor.create( + (EObject)dataObject, path).isSetAndRecyle(); + } + } + + public static void set(DataObject dataObject, String path, Object value) + { + Property property = dataObject.getType().getProperty(path); + if (property != null) + { + dataObject.set(property, value); + } + else + { + DataObjectUtil.Accessor.create( + (EObject)dataObject, path).setAndRecyle(value); + } + } + + public static Object get(DataObject dataObject, String path) + { + Property property = dataObject.getType().getProperty(path); + if (property != null) { + return dataObject.get(property); + } else { + return Accessor.create((EObject)dataObject, path).getAndRecyle(); + } + } + + 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 String) { + return DataHelper.INSTANCE.toDate((String)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.String") + { + String typeName = getDateTypeName((EDataType)eType); + if ("DateTime".equals(typeName)) { + return DataHelper.INSTANCE.toDateTime(value); + } + else if ("Day".equals(typeName)) { + return DataHelper.INSTANCE.toDay(value); + } + else if ("Duration".equals(typeName)) { + return DataHelper.INSTANCE.toDuration(value); + } + else if ("Month".equals(typeName)) { + return DataHelper.INSTANCE.toMonth(value); + } + else if ("MonthDay".equals(typeName)) { + return DataHelper.INSTANCE.toMonthDay(value); + } + else if ("Time".equals(typeName)) { + return DataHelper.INSTANCE.toTime(value); + } + else if ("Year".equals(typeName)) { + return DataHelper.INSTANCE.toYear(value); + } + else if ("YearMonth".equals(typeName)) { + return DataHelper.INSTANCE.toYearMonth(value); + } + else if ("YearMonthDay".equals(typeName)) { + return DataHelper.INSTANCE.toYearMonthDay(value); + } + else if ("String".equals(typeName)) + { + return DataHelper.INSTANCE.toDateTime(value); + } + + // Instead of throwing an IllegalArgumentException we will pass the value to the property + return value; + } + + //if (name == "java.util.Date") + //{ + //return new XMLCalendar(value, XMLCalendar.DATE); + //} + + if (name == "java.lang.Long" || name == "long") + { + return new Long(value.getTime()); + } + + // 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)) || + ("Day".equals(name)) || + ("Duration".equals(name)) || + ("Month".equals(name)) || + ("MonthDay".equals(name)) || + ("Time".equals(name)) || + ("Year".equals(name)) || + ("YearMonth".equals(name)) || + ("YearMonthDay".equals(name)) || + ("String".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)) || + ("Day".equals(memberTypeName)) || + ("Duration".equals(memberTypeName)) || + ("Month".equals(memberTypeName)) || + ("MonthDay".equals(memberTypeName)) || + ("Time".equals(memberTypeName)) || + ("Year".equals(memberTypeName)) || + ("YearMonth".equals(memberTypeName)) || + ("YearMonthDay".equals(memberTypeName)) || + ("String".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 instanceof Date) + { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy'-'MM'-'dd'T'H':'mm':'ss.S'Z'"); + sdf.setTimeZone(TimeZone.getTimeZone("GMT")); + return sdf.format((Date) value); + } + + if (value instanceof byte[]) { + return XMLTypeFactory.eINSTANCE.convertHexBinary((byte[])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.util.Date") + { + return DataHelper.INSTANCE.toDate(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 list = SDOExtendedMetaData.INSTANCE.getAliasNames(eStructuralFeature); + if (list == null) { + list = new ArrayList(); + } + return list; + } + + public static List getAliasNames(EClassifier eClassifier) + { + List list = SDOExtendedMetaData.INSTANCE.getAliasNames(eClassifier); + if (list == null) { + list = new ArrayList(); + } + return list; + } + + /** + * Process the default EMF path and minimal XPath syntax. + * This design is still under review and construction. + * + * Syntax: + * + *<pre> + * path = /? (step '/')* step + * step = feature + * | feature '.' index_from_0 + * | feature '[' index_from_1 ']' + * | reference '[' attribute '=' value ']' + * | .. + * | '@' step + *</pre> + * + * 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; + } + + /* + * calling constraint, this method is not to be used for semantic of setting index to NO_INDEX + */ + protected void setIndex(int index) + { + if(index < 0) { + // The index value should be greater than 0. An index value which is too high will result in + // an index out of bounds generated later on accessing the data. + throw new IndexOutOfBoundsException("Index value is too low"); + } + 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) + { + // 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 is null, that means it could be an open feature. + if (feature == null) + { + feature = (EStructuralFeature)DataObjectUtil.getOpenFeature(eObject, 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.getType().getProperty(propertyName); + if (property == null) + { + property = (Property)DataObjectUtil.getOpenFeature((EObject)dataObject, propertyName); + //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(); + + Resource.Factory factory = Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.datagraph")); + result.put("datagraph", factory instanceof DataGraphResourceFactoryImpl ? factory : new DataGraphResourceFactoryImpl()); + + factory = Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.ecore")); + result.put("ecore", factory instanceof EcoreResourceFactoryImpl ? factory : new EcoreResourceFactoryImpl()); + + factory = Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.emof")); + result.put("emof", factory instanceof EMOFResourceFactoryImpl ? factory : new EMOFResourceFactoryImpl()); + + factory = Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.xsd")); + result.put("xsd", factory instanceof XSDResourceFactoryImpl ? factory : new XSDResourceFactoryImpl()); + + factory = Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.wsdl")); + result.put("wsdl", factory instanceof XSDResourceFactoryImpl ? factory : new XSDResourceFactoryImpl()); + + factory = Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.*")); + result.put("*", factory instanceof SDOXMLResourceFactoryImpl ? factory : new SDOXMLResourceFactoryImpl()); + + registrations = result; + } + + return registrations; + } + + protected static void configureResourceSet(ResourceSet resourceSet) + { + resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().putAll(getRegistrations()); + } + + public static EClass createDocumentRoot() + { + EClass documentRootEClass = EcoreFactory.eINSTANCE.createEClass(); + ExtendedMetaData.INSTANCE.setName(documentRootEClass, ""); + ExtendedMetaData.INSTANCE.setContentKind(documentRootEClass, ExtendedMetaData.MIXED_CONTENT); + + EAttribute mixed = EcoreFactory.eINSTANCE.createEAttribute(); + mixed.setName("mixed"); + mixed.setEType(EcorePackage.eINSTANCE.getEFeatureMapEntry()); + mixed.setUpperBound(EStructuralFeature.UNBOUNDED_MULTIPLICITY); + ExtendedMetaData.INSTANCE.setName(mixed, ":mixed"); + ExtendedMetaData.INSTANCE.setFeatureKind(mixed, ExtendedMetaData.ELEMENT_WILDCARD_FEATURE); + documentRootEClass.getEStructuralFeatures().add(mixed); + + EReference xmlnsPrefixMap = EcoreFactory.eINSTANCE.createEReference(); + xmlnsPrefixMap.setName("xMLNSPrefixMap"); + xmlnsPrefixMap.setEType(EcorePackage.eINSTANCE.getEStringToStringMapEntry()); + xmlnsPrefixMap.setUpperBound(EStructuralFeature.UNBOUNDED_MULTIPLICITY); + xmlnsPrefixMap.setContainment(true); + xmlnsPrefixMap.setTransient(true); + ExtendedMetaData.INSTANCE.setName(xmlnsPrefixMap, "xmlns:prefix"); + ExtendedMetaData.INSTANCE.setFeatureKind(xmlnsPrefixMap, ExtendedMetaData.ATTRIBUTE_FEATURE); + documentRootEClass.getEStructuralFeatures().add(xmlnsPrefixMap); + + EReference xsiSchemaLocation = EcoreFactory.eINSTANCE.createEReference(); + xsiSchemaLocation.setName("xSISchemaLocation"); + xsiSchemaLocation.setEType(EcorePackage.eINSTANCE.getEStringToStringMapEntry()); + xsiSchemaLocation.setUpperBound(EStructuralFeature.UNBOUNDED_MULTIPLICITY); + xsiSchemaLocation.setContainment(true); + xsiSchemaLocation.setTransient(true); + ExtendedMetaData.INSTANCE.setName(xsiSchemaLocation, "xsi:schemaLocation"); + ExtendedMetaData.INSTANCE.setFeatureKind(xsiSchemaLocation, ExtendedMetaData.ATTRIBUTE_FEATURE); + documentRootEClass.getEStructuralFeatures().add(xsiSchemaLocation); + + return documentRootEClass; + } + + /** + * 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(); + } + }); + } + + protected static StringBuffer getXPath(DataObject dataObject, StringBuffer path) + { + DataObject container = dataObject.getContainer(); + if (container == null) return path; + + boolean first = path.length() == 0; + Property property = dataObject.getContainmentProperty(); + if (property.isMany()) + { + List list = container.getList(property); + int pos = list.indexOf(dataObject); + path.insert(0, property.getName() + "." + pos + (first ? "" : "/")); + } + else + { + path.insert(0, property.getName() + (first ? "" : "/")); + } + + return getXPath(container, path); + } + + public static String getXPath(DataObject dataObject) + { + StringBuffer path = getXPath(dataObject, new StringBuffer()); + return path.toString(); + } + + protected static XMLParserPool globalXMLParserPool = new XMLParserPoolImpl(); + + public static void configureXMLResource(XMLResource resource, ExtendedMetaData extendedMetaData) + { + 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); + } + + public static void initRuntime() + { + // NOOP since init is done during static initialization of this class. See above. + } + + /* + public static Object get(org.apache.tuscany.sdo.model.Property property, int propertyIndex) { + switch(propertyIndex) + { + case ModelPackageImpl.PROPERTY__ALIAS_NAME: + return property.getAliasName(); + case ModelPackageImpl.PROPERTY__ANY: + return property.getAny(); + case ModelPackageImpl.PROPERTY__ANY_ATTRIBUTE: + return property.getAnyAttribute(); + case ModelPackageImpl.PROPERTY__CONTAINMENT: + return Boolean.valueOf(property.isContainment()); + case ModelPackageImpl.PROPERTY__DEFAULT: + return property.getDefault_(); + case ModelPackageImpl.PROPERTY__MANY: + return Boolean.valueOf(property.isMany()); + case ModelPackageImpl.PROPERTY__NAME: + return property.getName(); + case ModelPackageImpl.PROPERTY__OPPOSITE: + return property.getOpposite_(); + case ModelPackageImpl.PROPERTY__READ_ONLY: + return Boolean.valueOf(property.isReadOnly()); + case ModelPackageImpl.PROPERTY__TYPE: + return property.getType_(); + } + return null; + } + + public static boolean isSet(org.apache.tuscany.sdo.model.Property property, int propertyIndex) { + switch(propertyIndex) + { + case ModelPackageImpl.PROPERTY__ALIAS_NAME: + return !property.getAliasName().isEmpty(); + case ModelPackageImpl.PROPERTY__ANY: + return false; + case ModelPackageImpl.PROPERTY__ANY_ATTRIBUTE: + return false; + case ModelPackageImpl.PROPERTY__CONTAINMENT: + return property.isSetContainment(); + case ModelPackageImpl.PROPERTY__DEFAULT: + return property.getDefault_() != null; + case ModelPackageImpl.PROPERTY__MANY: + return property.isSetMany(); + case ModelPackageImpl.PROPERTY__NAME: + return property.getName() != null; + case ModelPackageImpl.PROPERTY__OPPOSITE: + return property.getOpposite_() != null; + case ModelPackageImpl.PROPERTY__READ_ONLY: + return property.isSetReadOnly(); + case ModelPackageImpl.PROPERTY__TYPE: + return property.getType_() != null; + } + return false; + } + + public static Object get(org.apache.tuscany.sdo.model.Type type, int propertyIndex) { + switch (propertyIndex) + { + case ModelPackageImpl.TYPE__BASE_TYPE: + return type.getBaseType(); + case ModelPackageImpl.TYPE__PROPERTY: + return type.getProperty(); + case ModelPackageImpl.TYPE__ALIAS_NAME: + return type.getAliasName(); + case ModelPackageImpl.TYPE__ANY: + return type.getAny(); + case ModelPackageImpl.TYPE__ABSTRACT: + return Boolean.valueOf(type.isAbstract()); + case ModelPackageImpl.TYPE__DATA_TYPE: + return Boolean.valueOf(type.isDataType()); + case ModelPackageImpl.TYPE__NAME: + return type.getName(); + case ModelPackageImpl.TYPE__OPEN: + return Boolean.valueOf(type.isOpen()); + case ModelPackageImpl.TYPE__SEQUENCED: + return Boolean.valueOf(type.isSequenced()); + case ModelPackageImpl.TYPE__URI: + return type.getUri(); + case ModelPackageImpl.TYPE__ANY_ATTRIBUTE: + return type.getAnyAttribute(); + } + return null; + } + + public static boolean isSet(org.apache.tuscany.sdo.model.Type type, int propertyIndex) { + //FB Note that this implementation has the undesirable effect of invoking lazy creation of feature lists + switch (propertyIndex) + { + case ModelPackageImpl.TYPE__BASE_TYPE: + return !type.getBaseType().isEmpty(); + case ModelPackageImpl.TYPE__PROPERTY: + return !type.getProperty().isEmpty(); + case ModelPackageImpl.TYPE__ALIAS_NAME: + return !type.getAliasName().isEmpty(); + case ModelPackageImpl.TYPE__ANY: + return false; + case ModelPackageImpl.TYPE__ABSTRACT: + return type.isSetAbstract(); + case ModelPackageImpl.TYPE__DATA_TYPE: + return type.isSetDataType(); + case ModelPackageImpl.TYPE__NAME: + return type.getName() != null; + case ModelPackageImpl.TYPE__OPEN: + return type.isSetOpen(); + case ModelPackageImpl.TYPE__SEQUENCED: + return type.isSetSequenced(); + case ModelPackageImpl.TYPE__URI: + return type.getUri() != null; + case ModelPackageImpl.TYPE__ANY_ATTRIBUTE: + return false; + } + return false; + } + */ + +} diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/SDOUtil.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/SDOUtil.java new file mode 100644 index 0000000000..d9d4533d4c --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/SDOUtil.java @@ -0,0 +1,702 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.util; + +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.reflect.Field; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.security.AccessController; +import java.security.PrivilegedExceptionAction; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +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.SDOExtendedMetaData; +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.SimpleAnyTypeDataObject; +import org.apache.tuscany.sdo.helper.CrossScopeCopyHelperImpl; +import org.apache.tuscany.sdo.helper.DataFactoryImpl; +import org.apache.tuscany.sdo.helper.SDOExtendedMetaDataImpl; +import org.apache.tuscany.sdo.helper.TypeHelperImpl; +import org.apache.tuscany.sdo.helper.XMLHelperImpl; +import org.apache.tuscany.sdo.helper.XMLStreamHelper; +import org.apache.tuscany.sdo.helper.XMLStreamHelperImpl; +import org.apache.tuscany.sdo.helper.XSDHelperImpl; +import org.apache.tuscany.sdo.impl.DataGraphImpl; +import org.apache.tuscany.sdo.impl.DynamicDataObjectImpl; +import org.apache.tuscany.sdo.model.impl.ModelPackageImpl; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.emf.ecore.EcoreFactory; +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.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.xml.type.XMLTypePackage; + +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Sequence; +import commonj.sdo.Type; +import commonj.sdo.helper.CopyHelper; +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 +{ + /** + * Create a DataObject wrapper for an instance of the specified dataType. + * This method is typically used to create a root object that can be passed to the XMLHelper.save() + * method when the root element to be serialized is an XMLSchema simpleType. + * @param dataType a Type for which isDataType() returns true. + * @param value the instance value. + * @return a DataObject wrapper for the specified value. + */ + public static DataObject createDataTypeWrapper(Type dataType, Object value) + { + SimpleAnyTypeDataObject simpleAnyType = SDOFactory.eINSTANCE.createSimpleAnyTypeDataObject(); + simpleAnyType.setInstanceType((EDataType)dataType); + simpleAnyType.setValue(value); + return simpleAnyType; + } + + /** + * 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) + { + Type type = null; + //if ("anyType".equals(xsdType)) { + // type = (Type)SDOPackage.eINSTANCE.getDataObject(); + //} else { + String name = (String)xsdToSdoMappings.get(xsdType); + if (name != null) { + type = (Type)ModelPackageImpl.eINSTANCE.getEClassifier(name); + } else { + type = (Type)SDOExtendedMetaData.INSTANCE.getType(XMLTypePackage.eINSTANCE, xsdType); + } + //} + return type; + } + + /** + * Gets the Sequence corresponding to the specified substitutable Property of the specified DataObject. + * @param dataObject the data object. + * @param head a substitution group head property. + * @return the Sequence corresponding to the specified substitutable Property of the specified DataObject or + * null if the specified Property isn't a substitution head. + */ + public static Sequence getSubstitutionValues(DataObject dataObject, Property head) + { + final EStructuralFeature group = ExtendedMetaData.INSTANCE.getGroup((EStructuralFeature)head); + return null == group + ? null + : (Sequence)((FeatureMap.Internal)((EObject)dataObject).eGet(group)).getWrapper(); + } + + /** + * Get the SDO built-in type corresponding to the specified Java instanceClass. + * @param javaClass the Java instanceClass of the type. + * @return the SDO built-in Type corresponding to the specified instanceClass. + */ + public static Type getJavaSDOType(Class javaClass) + { + String name = (String)javaToSdoMappings.get(javaClass); + if (name != null) + { + return (Type)ModelPackageImpl.eINSTANCE.getEClassifier(name); + } + return null; + } + + /** + * Return whether at least one value is required for a valid instance of the specified property. + * @param the property in question. + * @return true if the property is required. + */ + public static boolean isRequired(Property property) + { + return ((EStructuralFeature)property).isRequired(); + } + + /** + * Returns whether the Property is many-valued given the specified context. + * @param property The Property in question + * @param context The context to check whether the specified Property is many-valued + * @return true if the Property is many-valued given the specified context. + */ + public static boolean isMany(Property property, DataObject context) + { + return FeatureMapUtil.isMany((EObject) context, (EStructuralFeature) property); + } + + /** + * Create an empty data graph. + * @return the new data graph instance. + */ + public static DataGraph createDataGraph() + { + return SDOFactory.eINSTANCE.createDataGraph(); + } + + /** + * Set the root object of a data graph. + * @param dataGraph the data graph in which to set the root object. + * @param rootObject the root object. + */ + public static void setRootObject(DataGraph dataGraph, DataObject rootObject) + { + ((DataGraphImpl)dataGraph).setERootObject((EObject)rootObject); + } + + /** + * 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); + } + + /** + * Registers the specified {@link Type type}(s) to be serialized along with + * the {@link DataObject data object}(s) in the graph. For example, the list of types returned from + * {@link TypeHelper#define} can be registered with this method, allowing deserialization of + * instances of a dynamically defined model. + * @param dataGraph the DataGraph in which to register the specified type(s). + * @param types a list containing the type(s) to be registered (TBD or null to automatically register all + * types used by the objects in the DataGraph). + */ + public static void registerDataGraphTypes(DataGraph dataGraph, List/*Type*/ types) + { + //if (types == null) + // types = SDOUtil.getDataGraphTypes(dataGraph); + + Set/*EPackage*/ packages = new HashSet(); + for (final Iterator iterator = types.iterator(); iterator.hasNext(); ) { + EClassifier type = (EClassifier)iterator.next(); + packages.add(type.getEPackage()); + } + + ResourceSet resourceSet = ((DataGraphImpl)dataGraph).getResourceSet(); + + for (Iterator iterator = packages.iterator(); iterator.hasNext(); ) { + EPackage typePackage = (EPackage)iterator.next(); + Resource resource = typePackage.eResource(); + if (resource == null) { + resource = resourceSet.createResource(URI.createURI(".ecore")); + resource.setURI(URI.createURI(typePackage.getNsURI())); + resource.getContents().add(typePackage); + } + else if (resource.getResourceSet() != resourceSet) + resourceSet.getResources().add(resource); + } + } + + /** + * 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 SDOExtendedMetaDataImpl(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); + } + + /** + * Create a new XMLStreamHelper, with visibility to types in the specified TypeHelper scope. + * @param scope the TypeHelper to use for locating types. + * @return the new XMLStreamHelper. + */ + public static XMLStreamHelper createXMLStreamHelper(TypeHelper scope) + { + return new XMLStreamHelperImpl(scope); + } + + /** + * Create a new cross scope CopyHelper. + * @param targetScope the TypeHelper containing the Types to use to create the copy objects. + * @return the new CopyHelper. + */ + public static CopyHelper createCrossScopeCopyHelper(TypeHelper targetScope) + { + return new CrossScopeCopyHelperImpl(targetScope); + } + + /** + * Gets all of the types associated with a uri. + * + * @param scope + * the TypeHelper to use for locating types. + * @param uri. + * Uri of the Types + * @return List. List containing instances of Type, null if uri is not found. + */ + public static List getTypes(TypeHelper scope, String uri) { + + EPackage ePackage = ((TypeHelperImpl) scope).getExtendedMetaData().getPackage(uri); + if (ePackage != null) { + /** + * ePackage.getEclassifiers will return an EList ( simple extension of List ). + * + * When a Type is generated from XML EMF will create a DocumentRoot type As this is EMF specific it should be removed + */ + List result = new ArrayList(ePackage.getEClassifiers()); + result.remove(((TypeHelperImpl) scope).getExtendedMetaData().getDocumentRoot(ePackage)); + return result; + } + return null; + } + + public static Type createType(TypeHelper scope, String uri, String name, boolean isDataType) + { + ExtendedMetaData extendedMetaData = ((TypeHelperImpl)scope).getExtendedMetaData(); + + EPackage ePackage = extendedMetaData.getPackage(uri); + if (ePackage == null) + { + ePackage = EcoreFactory.eINSTANCE.createEPackage(); + ePackage.setEFactoryInstance(new DynamicDataObjectImpl.FactoryImpl()); + ePackage.setNsURI(uri); + String packagePrefix = URI.createURI(uri).trimFileExtension().lastSegment(); + ePackage.setName(packagePrefix); + ePackage.setNsPrefix(packagePrefix); + extendedMetaData.putPackage(uri, ePackage); + } + + EClassifier eClassifier = ePackage.getEClassifier(name); + if (eClassifier != null) // already defined? + { + //throw new IllegalArgumentException(); + return null; + } + + if (name != null) + { + eClassifier = isDataType ? (EClassifier)SDOFactory.eINSTANCE.createDataType() : (EClassifier)SDOFactory.eINSTANCE.createClass(); + eClassifier.setName(name); + } + else + { + eClassifier = DataObjectUtil.createDocumentRoot(); + } + + ePackage.getEClassifiers().add(eClassifier); + + return (Type)eClassifier; + } + + public static void addBaseType(Type type, Type baseType) + { + ((EClass)type).getESuperTypes().add(baseType); + } + + public static void addAliasName(Type type, String aliasName) + { + throw new UnsupportedOperationException(); // TODO: implement this method properly + //type.getAliasNames().add(aliasName); + } + + public static void setOpen(Type type, boolean isOpen) + { + if (isOpen == type.isOpen()) return; + + if (isOpen) + { + EAttribute eAttribute = EcoreFactory.eINSTANCE.createEAttribute(); + ((EClass)type).getEStructuralFeatures().add(eAttribute); + + eAttribute.setName("any"); + eAttribute.setUnique(false); + eAttribute.setUpperBound(ETypedElement.UNBOUNDED_MULTIPLICITY); + eAttribute.setEType(EcorePackage.eINSTANCE.getEFeatureMapEntry()); + ExtendedMetaData.INSTANCE.setFeatureKind(eAttribute, ExtendedMetaData.ELEMENT_WILDCARD_FEATURE); + ExtendedMetaData.INSTANCE.setProcessingKind(eAttribute, ExtendedMetaData.LAX_PROCESSING); + ExtendedMetaData.INSTANCE.setWildcards(eAttribute, Collections.singletonList("##any")); + + //FB TBD Add an "anyAttribute" EAttribute as well. + + if (type.isSequenced()) { + eAttribute.setDerived(true); + eAttribute.setTransient(true); + eAttribute.setVolatile(true); + } + } + else + { + EClass eClass = (EClass)type; + EAttribute any = (EAttribute)eClass.getEStructuralFeature("any"); + eClass.getEStructuralFeatures().remove(any); + } + } + + public static void setSequenced(Type type, boolean isSequenced) + { + if (isSequenced == type.isSequenced()) return; + + // currently, we require setSequenced to be called first, before anything else is added to the type. + if (type.isDataType() || !type.getProperties().isEmpty()) + { + if (type.getName() != null) // document root is a special case + throw new IllegalArgumentException(); + } + + if (isSequenced) { + EClass eClass = (EClass)type; + ExtendedMetaData.INSTANCE.setContentKind(eClass, ExtendedMetaData.MIXED_CONTENT); + EAttribute mixedFeature = EcoreFactory.eINSTANCE.createEAttribute(); + mixedFeature.setName("mixed"); + mixedFeature.setUnique(false); + mixedFeature.setEType(EcorePackage.eINSTANCE.getEFeatureMapEntry()); + mixedFeature.setLowerBound(0); + mixedFeature.setUpperBound(-1); + eClass.getEStructuralFeatures().add(mixedFeature); + ExtendedMetaData.INSTANCE.setFeatureKind(mixedFeature, ExtendedMetaData.ELEMENT_WILDCARD_FEATURE); + ExtendedMetaData.INSTANCE.setName(mixedFeature, ":mixed"); + } + else + { + // nothing to do, because of current restriction that setSequence must be called first. + } + } + + public static void setAbstract(Type type, boolean isAbstract) + { + ((EClass)type).setAbstract(isAbstract); + } + + public static void setJavaClassName(Type type, String javaClassName) + { + ((EClassifier)type).setInstanceClassName(javaClassName); + } + + public static Property createProperty(Type containingType, String name, Type propertyType) + { + EStructuralFeature eStructuralFeature = + propertyType.isDataType() ? + (EStructuralFeature)SDOFactory.eINSTANCE.createAttribute() : + (EStructuralFeature)SDOFactory.eINSTANCE.createReference(); + + eStructuralFeature.setName(name); + eStructuralFeature.setEType((EClassifier)propertyType); + ((EClass)containingType).getEStructuralFeatures().add(eStructuralFeature); + + //if (containingType.getName() == null) + if ("".equals(ExtendedMetaData.INSTANCE.getName((EClass)containingType))) // DocumentRoot containingType? + { + //FB TBD ... figure out how to decide whether to use ELEMENT_FEATURE or ATTRIBUTE_FEATURE + ExtendedMetaData.INSTANCE.setFeatureKind(eStructuralFeature, ExtendedMetaData.ELEMENT_FEATURE); + + ExtendedMetaData.INSTANCE.setNamespace(eStructuralFeature, containingType.getURI()); + //FB???eStructuralFeature.setUnique(false); + //FB???eStructuralFeature.setUpperBound(ETypedElement.UNSPECIFIED_MULTIPLICITY); + } + + if (containingType.isSequenced()) { + eStructuralFeature.setDerived(true); + eStructuralFeature.setTransient(true); + eStructuralFeature.setVolatile(true); + } + + return (Property)eStructuralFeature; + } + + public static void addAliasName(Property property, String aliasName) + { + throw new UnsupportedOperationException(); // TODO: implement this method properly + //property.getAliasNames().add(aliasName); + } + + public static void setMany(Property property, boolean isMany) + { + ((EStructuralFeature)property).setUpperBound(isMany ? EStructuralFeature.UNBOUNDED_MULTIPLICITY : 1); + } + + public static void setContainment(Property property, boolean isContainment) + { + ((EReference)property).setContainment(isContainment); + } + + public static void setDefault(Property property, String defaultValue) + { + ((EStructuralFeature)property).setDefaultValueLiteral(defaultValue); + } + + public static void setReadOnly(Property property, boolean isReadOnly) + { + ((EStructuralFeature)property).setChangeable(!isReadOnly); + } + + public static void setOpposite(Property property, Property opposite) + { + ((EReference)property).setEOpposite((EReference)opposite); + } + + /** + * 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 temporary, 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 // this case handles the current default generator pattern + { + Class javaClass = getPackageClass(factoryClass, packageName); + Field field = javaClass.getField("eINSTANCE"); + field.get(null); + } + catch (Exception e1) + { + packageName = factoryClass.getName().replaceFirst("Factory$", "Package"); + try // this case handles the -noInterfaces generator pattern + { + Class javaClass = getPackageClass(factoryClass, packageName); + Field field = javaClass.getField("eINSTANCE"); + field.get(null); + } + catch (Exception e2) + { + try // this case handles the -noEMF generator pattern + { + Field field = factoryClass.getField("INSTANCE"); + field.get(null); + } + catch (Exception e3) + { + e3.printStackTrace(); + } + } + } + } + + private static Class getPackageClass(Class factoryClass, String packageName) throws Exception + { + final Class factoryClassTemp = factoryClass; + final String packageNameTemp = packageName; + return (Class)AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws Exception { + return factoryClassTemp.getClassLoader().loadClass(packageNameTemp); + } + }); + } + + //Java instance class to SDO mappings (p.69 - p.71 of the SDO spec) + private static Map javaToSdoMappings = new HashMap(); + static { + javaToSdoMappings.put(boolean.class, "Boolean"); + javaToSdoMappings.put(byte.class, "Byte"); + javaToSdoMappings.put(char.class, "Character"); + javaToSdoMappings.put(Date.class, "Date"); + javaToSdoMappings.put(BigDecimal.class, "Decimal"); + javaToSdoMappings.put(double.class, "Double"); + javaToSdoMappings.put(float.class, "Float"); + javaToSdoMappings.put(int.class, "Int"); + javaToSdoMappings.put(BigInteger.class, "Integer"); + javaToSdoMappings.put(long.class, "Long"); + javaToSdoMappings.put(Object.class, "Object"); + javaToSdoMappings.put(short.class, "Short"); + javaToSdoMappings.put(String.class, "String"); + javaToSdoMappings.put(Boolean.class, "BooleanObject"); + javaToSdoMappings.put(Byte.class, "ByteObject"); + javaToSdoMappings.put(Character.class, "CharacterObject"); + javaToSdoMappings.put(Double.class, "DoubleObject"); + javaToSdoMappings.put(Float.class, "FloatObject"); + javaToSdoMappings.put(Integer.class, "IntObject"); + javaToSdoMappings.put(Long.class, "LongObject"); + javaToSdoMappings.put(Short.class, "ShortObject"); + } + + //XSD to SDO mappings (p.95 of the SDO spec) + private static Map xsdToSdoMappings = new HashMap(); + static { + xsdToSdoMappings.put("anySimpleType", "Object"); + xsdToSdoMappings.put("anyType", "DataObject"); + xsdToSdoMappings.put("anyURI", "URI"); + // SDO Spec issue: both base64Binary and hexBinary are mapped to Bytes. Workaround is to let base64Binary + // fall through to use EMF's default: XMLTypePackage.base64Binary + // xsdToSdoMappings.put("base64Binary", "Bytes"); + xsdToSdoMappings.put("boolean", "Boolean"); + xsdToSdoMappings.put("byte", "Byte"); + xsdToSdoMappings.put("date", "YearMonthDay"); + xsdToSdoMappings.put("dateTime", "DateTime"); + xsdToSdoMappings.put("decimal", "Decimal"); + xsdToSdoMappings.put("double", "Double"); + xsdToSdoMappings.put("duration", "Duration"); + xsdToSdoMappings.put("ENTITIES", "Strings"); + xsdToSdoMappings.put("ENTITY", "String"); + xsdToSdoMappings.put("float", "Float"); + xsdToSdoMappings.put("gDay", "Day"); + xsdToSdoMappings.put("gMonth", "Month"); + xsdToSdoMappings.put("gMonthDay", "MonthDay"); + xsdToSdoMappings.put("gYear", "Year"); + xsdToSdoMappings.put("gYearMonth", "YearMonth"); + xsdToSdoMappings.put("hexBinary", "Bytes"); + xsdToSdoMappings.put("ID","String"); + xsdToSdoMappings.put("IDREF","String"); + xsdToSdoMappings.put("IDREFS","Strings"); + xsdToSdoMappings.put("int","Int"); + xsdToSdoMappings.put("integer","Integer"); + xsdToSdoMappings.put("language","String"); + xsdToSdoMappings.put("long","Long"); + xsdToSdoMappings.put("Name","String"); + xsdToSdoMappings.put("NCName","String"); + xsdToSdoMappings.put("negativeInteger","Integer"); + xsdToSdoMappings.put("NMTOKEN","String"); + xsdToSdoMappings.put("NMTOKENS","Strings"); + xsdToSdoMappings.put("nonNegativeInteger","Integer"); + xsdToSdoMappings.put("nonPositiveInteger","Integer"); + xsdToSdoMappings.put("normalizedString","String"); + xsdToSdoMappings.put("NOTATION","String"); + xsdToSdoMappings.put("positiveInteger","Integer"); + xsdToSdoMappings.put("QName","URI"); + xsdToSdoMappings.put("short","Short"); + xsdToSdoMappings.put("string","String"); + xsdToSdoMappings.put("time","Time"); + xsdToSdoMappings.put("token","String"); + xsdToSdoMappings.put("unsignedByte","Short"); + xsdToSdoMappings.put("unsignedInt","Long"); + xsdToSdoMappings.put("unsignedLong","Integer"); + xsdToSdoMappings.put("unsignedShort","Int"); + } + + /** + * Initialize SDO runtime. + */ + static + { + DataObjectUtil.initRuntime(); + } + +} diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/StAX2SAXAdapter.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/StAX2SAXAdapter.java new file mode 100644 index 0000000000..932fcff8cb --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/StAX2SAXAdapter.java @@ -0,0 +1,250 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.util; + +import javax.xml.namespace.QName; +import javax.xml.stream.Location; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import org.xml.sax.Attributes; +import org.xml.sax.ContentHandler; +import org.xml.sax.Locator; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.AttributesImpl; + +/** + * Adapter that converts from StAX to SAX event streams. Currently the following SAX events are not generated: + * <ul> + * <li>ignorableWhitespace</li> + * <li>skippedEntity</li> + * <ul> + * Also the following StAX events are not mapped: + * <ul> + * <li>CDATA</li> + * <li>COMMENT</li> + * <li>DTD</li> + * <li>ENTITY_DECLARATION</li> + * <li>ENTITY_REFERENCE</li> + * <li>NOTATION_DECLARATION</li> + * <li>SPACE</li> + * </ul> + * StAX ATTRIBUTE events are ignored but the equivalent attributes (derived from the START_ELEMENT event) are supplied in the SAX startElement event's + * Attributes parameter. If the adaptor is configured to pass namespace prefixes then namespace information will also be included in the Attributes; + * StAX NAMESPACE events are ignored. + * <p/> + * Another issue is namespace processing. If the reader is positioned at a sub-node, we cannot capture all the in-scope namespace bindings. Therefore + * we cannot re-create a proper SAX event stream from a StAX parser. + * <p/> + * For example + * <p/> + * <a:root xmlns:a="foo" xmlns:b="bar"><b:sub>a:foo</b:sub></a:root> + * <p/> + * And if you are handed a parser at <b:sub>, then your SAX events should look like: + * <p/> + * <b:sub xmlns:a="foo" xmlns:b="bar">a:foo</b:sub> + * <p/> + * not: + * <p/> + * <b:sub>a:foo</b:sub> + * <p/> + * <p/> + * Proposal: we change the receiver of SAX events (SDOXMLResourceImpl) so that it uses NamespaceContext to resolve prefix (as opposed to record + * start/endPrefixMappings and use it for resolution.) + * + * @version $Rev$ $Date$ + */ +public class StAX2SAXAdapter { + private final boolean namespacePrefixes; + + /** + * Construct a new StAX to SAX adapter that will convert a StAX event stream into a SAX event stream. + * + * @param namespacePrefixes whether xmlns attributes should be included in startElement events; + */ + public StAX2SAXAdapter(boolean namespacePrefixes) { + this.namespacePrefixes = namespacePrefixes; + } + + /** + * Pull events from the StAX stream and dispatch to the SAX ContentHandler. The StAX stream would typically be located on a START_DOCUMENT or + * START_ELEMENT event and when this method returns it will be located on the associated END_DOCUMENT or END_ELEMENT event. Behaviour with other + * start events is undefined. + * + * @param reader StAX event source to read + * @param handler SAX ContentHandler for processing events + * @throws XMLStreamException if there was a problem reading the stream + * @throws SAXException passed through from the ContentHandler + */ + public void parse(XMLStreamReader reader, ContentHandler handler) throws XMLStreamException, SAXException { + handler.setDocumentLocator(new LocatorAdaptor(reader.getLocation())); + + // remembers the nest level of elements to know when we are done + int level = 0; + int event = reader.getEventType(); + while (true) { + switch (event) { + case XMLStreamConstants.START_DOCUMENT: + level++; + handler.startDocument(); + break; + case XMLStreamConstants.START_ELEMENT: + level++; + handleStartElement(reader, handler); + break; + case XMLStreamConstants.PROCESSING_INSTRUCTION: + handler.processingInstruction(reader.getPITarget(), reader.getPIData()); + break; + case XMLStreamConstants.CHARACTERS: + handler.characters(reader.getTextCharacters(), reader.getTextStart(), reader.getTextLength()); + break; + case XMLStreamConstants.END_ELEMENT: + handleEndElement(reader, handler); + level--; + if (level == 0) { + return; + } + break; + case XMLStreamConstants.END_DOCUMENT: + handler.endDocument(); + return; + /* + * uncomment to handle all events rather than just mapped ones // StAX events that are not mapped to SAX case XMLStreamConstants.COMMENT: + * case XMLStreamConstants.SPACE: case XMLStreamConstants.ENTITY_REFERENCE: case XMLStreamConstants.DTD: case XMLStreamConstants.CDATA: + * case XMLStreamConstants.NOTATION_DECLARATION: case XMLStreamConstants.ENTITY_DECLARATION: break; // StAX events handled in + * START_ELEMENT case XMLStreamConstants.ATTRIBUTE: case XMLStreamConstants.NAMESPACE: break; default: throw new AssertionError("Unknown + * StAX event: " + event); + */ + } + event = reader.next(); + } + } + + private void handleStartElement(XMLStreamReader reader, ContentHandler handler) throws SAXException { + // send startPrefixMapping events immediately before startElement event + int nsCount = reader.getNamespaceCount(); + for (int i = 0; i < nsCount; i++) { + String prefix = reader.getNamespacePrefix(i); + if (prefix == null) { // true for default namespace + prefix = ""; + } + handler.startPrefixMapping(prefix, reader.getNamespaceURI(i)); + } + + // fire startElement + QName qname = reader.getName(); + String prefix = qname.getPrefix(); + String rawname; + if (prefix == null || prefix.length() == 0) { + rawname = qname.getLocalPart(); + } else { + rawname = prefix + ':' + qname.getLocalPart(); + } + Attributes attrs = getAttributes(reader); + handler.startElement(qname.getNamespaceURI(), qname.getLocalPart(), rawname, attrs); + } + + private static void handleEndElement(XMLStreamReader reader, ContentHandler handler) throws SAXException { + // fire endElement + QName qname = reader.getName(); + handler.endElement(qname.getNamespaceURI(), qname.getLocalPart(), qname.toString()); + + // send endPrefixMapping events immediately after endElement event + // we send them in the opposite order to that returned but this is not actually required by SAX + int nsCount = reader.getNamespaceCount(); + for (int i = nsCount - 1; i >= 0; i--) { + String prefix = reader.getNamespacePrefix(i); + if (prefix == null) { // true for default namespace + prefix = ""; + } + handler.endPrefixMapping(prefix); + } + } + + /** + * Get the attributes associated with the current START_ELEMENT event. + * + * @return the StAX attributes converted to org.xml.sax.Attributes + */ + private Attributes getAttributes(XMLStreamReader reader) { + assert reader.getEventType() == XMLStreamConstants.START_ELEMENT; + + AttributesImpl attrs = new AttributesImpl(); + + // add namespace declarations if required + if (namespacePrefixes) { + for (int i = 0; i < reader.getNamespaceCount(); i++) { + String prefix = reader.getNamespacePrefix(i); + String uri = reader.getNamespaceURI(i); + attrs.addAttribute(null, prefix, "xmlns:" + prefix, "CDATA", uri); + } + } + + // Regular attributes + for (int i = 0; i < reader.getAttributeCount(); i++) { + String uri = reader.getAttributeNamespace(i); + if (uri == null) { + uri = ""; + } + String localName = reader.getAttributeLocalName(i); + String prefix = reader.getAttributePrefix(i); + String qname; + if (prefix == null || prefix.length() == 0) { + qname = localName; + } else { + qname = prefix + ':' + localName; + } + String type = reader.getAttributeType(i); + String value = reader.getAttributeValue(i); + + attrs.addAttribute(uri, localName, qname, type, value); + } + + return attrs; + } + + /** + * Adaptor for mapping Locator information. + */ + private static class LocatorAdaptor implements Locator { + private final Location location; + + private LocatorAdaptor(Location location) { + this.location = location; + } + + public int getColumnNumber() { + return location == null ? 0 : location.getColumnNumber(); + } + + public int getLineNumber() { + return location == null ? 0 : location.getLineNumber(); + } + + public String getPublicId() { + return location == null ? "" : location.getPublicId(); + } + + public String getSystemId() { + return location == null ? "" : location.getSystemId(); + } + } +} diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/JavaMetaData.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/JavaMetaData.java new file mode 100644 index 0000000000..d52e9a4e51 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/JavaMetaData.java @@ -0,0 +1,88 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.util.metadata; + + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Java Meta Data</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.apache.tuscany.sdo.util.metadata.JavaMetaData#getFactoryInterface <em>Factory Interface</em>}</li> + * <li>{@link org.apache.tuscany.sdo.util.metadata.JavaMetaData#getTypeInterface <em>Type Interface</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public interface JavaMetaData +{ + /** + * Returns the value of the '<em><b>Factory Interface</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Factory Interface</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Factory Interface</em>' attribute. + * @see #setFactoryInterface(String) + * @generated + */ + String getFactoryInterface(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.util.metadata.JavaMetaData#getFactoryInterface <em>Factory Interface</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Factory Interface</em>' attribute. + * @see #getFactoryInterface() + * @generated + */ + void setFactoryInterface(String value); + + /** + * Returns the value of the '<em><b>Type Interface</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Type Interface</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Type Interface</em>' attribute. + * @see #setTypeInterface(String) + * @generated + */ + String getTypeInterface(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.util.metadata.JavaMetaData#getTypeInterface <em>Type Interface</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Type Interface</em>' attribute. + * @see #getTypeInterface() + * @generated + */ + void setTypeInterface(String value); + +} // JavaMetaData diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/MetadataFactory.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/MetadataFactory.java new file mode 100644 index 0000000000..7d16e6be83 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/MetadataFactory.java @@ -0,0 +1,76 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.util.metadata; + + +/** + * <!-- begin-user-doc --> + * The <b>Factory</b> for the model. + * It provides a create method for each non-abstract class of the model. + * <!-- end-user-doc --> + * @generated + */ +public interface MetadataFactory +{ + /** + * The singleton instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + MetadataFactory INSTANCE = org.apache.tuscany.sdo.util.metadata.impl.MetadataFactoryImpl.eINSTANCE; + + /** + * Returns a new object of class '<em>Java Meta Data</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Java Meta Data</em>'. + * @generated + */ + JavaMetaData createJavaMetaData(); + + /** + * Returns a new object of class '<em>SDO Meta Data Group</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>SDO Meta Data Group</em>'. + * @generated + */ + SDOMetaDataGroup createSDOMetaDataGroup(); + + /** + * Returns a new object of class '<em>Type Meta Data</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Type Meta Data</em>'. + * @generated + */ + TypeMetaData createTypeMetaData(); + + /** + * Returns a new object of class '<em>XSD Meta Data</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>XSD Meta Data</em>'. + * @generated + */ + XSDMetaData createXSDMetaData(); + +} //MetadataFactory diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/SDOMetaDataGroup.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/SDOMetaDataGroup.java new file mode 100644 index 0000000000..dcdb3d77ca --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/SDOMetaDataGroup.java @@ -0,0 +1,89 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.util.metadata; + +import java.util.List; + +import commonj.sdo.helper.TypeHelper; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>SDO Meta Data Group</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getJavaMetaData <em>Java Meta Data</em>}</li> + * <li>{@link org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getXsdMetaData <em>Xsd Meta Data</em>}</li> + * <li>{@link org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getTypeMetaData <em>Type Meta Data</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public interface SDOMetaDataGroup +{ + /** + * Returns the value of the '<em><b>Java Meta Data</b></em>' containment reference list. + * The list contents are of type {@link org.apache.tuscany.sdo.util.metadata.JavaMetaData}. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Java Meta Data</em>' containment reference list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Java Meta Data</em>' containment reference list. + * @generated + */ + List getJavaMetaData(); + + /** + * Returns the value of the '<em><b>Xsd Meta Data</b></em>' containment reference list. + * The list contents are of type {@link org.apache.tuscany.sdo.util.metadata.XSDMetaData}. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Xsd Meta Data</em>' containment reference list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Xsd Meta Data</em>' containment reference list. + * @generated + */ + List getXsdMetaData(); + + /** + * Returns the value of the '<em><b>Type Meta Data</b></em>' containment reference list. + * The list contents are of type {@link org.apache.tuscany.sdo.util.metadata.TypeMetaData}. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Type Meta Data</em>' containment reference list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Type Meta Data</em>' containment reference list. + * @generated + */ + List getTypeMetaData(); + + void register(TypeHelper scope); + void register(TypeHelper scope, ClassLoader classLoader); + +} // SDOMetaDataGroup diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/TypeMetaData.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/TypeMetaData.java new file mode 100644 index 0000000000..fcf4170b80 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/TypeMetaData.java @@ -0,0 +1,63 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.util.metadata; + + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Type Meta Data</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.apache.tuscany.sdo.util.metadata.TypeMetaData#getLocation <em>Location</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public interface TypeMetaData +{ + /** + * Returns the value of the '<em><b>Location</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Location</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Location</em>' attribute. + * @see #setLocation(String) + * @generated + */ + String getLocation(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.util.metadata.TypeMetaData#getLocation <em>Location</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Location</em>' attribute. + * @see #getLocation() + * @generated + */ + void setLocation(String value); + +} // TypeMetaData diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/XSDMetaData.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/XSDMetaData.java new file mode 100644 index 0000000000..44c9d7e124 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/XSDMetaData.java @@ -0,0 +1,63 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.util.metadata; + + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>XSD Meta Data</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link org.apache.tuscany.sdo.util.metadata.XSDMetaData#getLocation <em>Location</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public interface XSDMetaData +{ + /** + * Returns the value of the '<em><b>Location</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Location</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Location</em>' attribute. + * @see #setLocation(String) + * @generated + */ + String getLocation(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.util.metadata.XSDMetaData#getLocation <em>Location</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Location</em>' attribute. + * @see #getLocation() + * @generated + */ + void setLocation(String value); + +} // XSDMetaData diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/JavaMetaDataImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/JavaMetaDataImpl.java new file mode 100644 index 0000000000..b8f842ffe4 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/JavaMetaDataImpl.java @@ -0,0 +1,244 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.util.metadata.impl; + +import org.apache.tuscany.sdo.impl.DataObjectImpl; + +import org.apache.tuscany.sdo.util.metadata.JavaMetaData; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Java Meta Data</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.sdo.util.metadata.impl.JavaMetaDataImpl#getFactoryInterface <em>Factory Interface</em>}</li> + * <li>{@link org.apache.tuscany.sdo.util.metadata.impl.JavaMetaDataImpl#getTypeInterface <em>Type Interface</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class JavaMetaDataImpl extends DataObjectImpl implements JavaMetaData +{ + /** + * The default value of the '{@link #getFactoryInterface() <em>Factory Interface</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getFactoryInterface() + * @generated + * @ordered + */ + protected static final String FACTORY_INTERFACE_EDEFAULT = null; + + /** + * The cached value of the '{@link #getFactoryInterface() <em>Factory Interface</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getFactoryInterface() + * @generated + * @ordered + */ + protected String factoryInterface = FACTORY_INTERFACE_EDEFAULT; + + /** + * The default value of the '{@link #getTypeInterface() <em>Type Interface</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getTypeInterface() + * @generated + * @ordered + */ + protected static final String TYPE_INTERFACE_EDEFAULT = null; + + /** + * The cached value of the '{@link #getTypeInterface() <em>Type Interface</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getTypeInterface() + * @generated + * @ordered + */ + protected String typeInterface = TYPE_INTERFACE_EDEFAULT; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected JavaMetaDataImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return MetadataPackageImpl.Literals.JAVA_META_DATA; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getFactoryInterface() + { + return factoryInterface; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setFactoryInterface(String newFactoryInterface) + { + String oldFactoryInterface = factoryInterface; + factoryInterface = newFactoryInterface; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackageImpl.JAVA_META_DATA__FACTORY_INTERFACE, oldFactoryInterface, factoryInterface)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getTypeInterface() + { + return typeInterface; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setTypeInterface(String newTypeInterface) + { + String oldTypeInterface = typeInterface; + typeInterface = newTypeInterface; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackageImpl.JAVA_META_DATA__TYPE_INTERFACE, oldTypeInterface, typeInterface)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case MetadataPackageImpl.JAVA_META_DATA__FACTORY_INTERFACE: + return getFactoryInterface(); + case MetadataPackageImpl.JAVA_META_DATA__TYPE_INTERFACE: + return getTypeInterface(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case MetadataPackageImpl.JAVA_META_DATA__FACTORY_INTERFACE: + setFactoryInterface((String)newValue); + return; + case MetadataPackageImpl.JAVA_META_DATA__TYPE_INTERFACE: + setTypeInterface((String)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case MetadataPackageImpl.JAVA_META_DATA__FACTORY_INTERFACE: + setFactoryInterface(FACTORY_INTERFACE_EDEFAULT); + return; + case MetadataPackageImpl.JAVA_META_DATA__TYPE_INTERFACE: + setTypeInterface(TYPE_INTERFACE_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case MetadataPackageImpl.JAVA_META_DATA__FACTORY_INTERFACE: + return FACTORY_INTERFACE_EDEFAULT == null ? factoryInterface != null : !FACTORY_INTERFACE_EDEFAULT.equals(factoryInterface); + case MetadataPackageImpl.JAVA_META_DATA__TYPE_INTERFACE: + return TYPE_INTERFACE_EDEFAULT == null ? typeInterface != null : !TYPE_INTERFACE_EDEFAULT.equals(typeInterface); + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (factoryInterface: "); + result.append(factoryInterface); + result.append(", typeInterface: "); + result.append(typeInterface); + result.append(')'); + return result.toString(); + } + +} //JavaMetaDataImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/MetadataFactoryImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/MetadataFactoryImpl.java new file mode 100644 index 0000000000..013a552215 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/MetadataFactoryImpl.java @@ -0,0 +1,177 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.util.metadata.impl; + +import org.apache.tuscany.sdo.util.metadata.*; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +/** + * <!-- begin-user-doc --> + * An implementation of the model <b>Factory</b>. + * <!-- end-user-doc --> + * @generated + */ +public class MetadataFactoryImpl extends EFactoryImpl implements MetadataFactory +{ + /** + * The singleton instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final MetadataFactoryImpl eINSTANCE = init(); + + /** + * Creates the default factory implementation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static MetadataFactoryImpl init() + { + try + { + MetadataFactoryImpl theMetadataFactory = (MetadataFactoryImpl)EPackage.Registry.INSTANCE.getEFactory("org.apache.tuscany.sdo/metadata"); + if (theMetadataFactory != null) + { + return theMetadataFactory; + } + } + catch (Exception exception) + { + EcorePlugin.INSTANCE.log(exception); + } + return new MetadataFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public MetadataFactoryImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EObject create(EClass eClass) + { + switch (eClass.getClassifierID()) + { + case MetadataPackageImpl.DOCUMENT_ROOT: return (EObject)createDocumentRoot(); + case MetadataPackageImpl.JAVA_META_DATA: return (EObject)createJavaMetaData(); + case MetadataPackageImpl.SDO_META_DATA_GROUP: return (EObject)createSDOMetaDataGroup(); + case MetadataPackageImpl.TYPE_META_DATA: return (EObject)createTypeMetaData(); + case MetadataPackageImpl.XSD_META_DATA: return (EObject)createXSDMetaData(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EObject createDocumentRoot() + { + EObject documentRoot = super.create(MetadataPackageImpl.Literals.DOCUMENT_ROOT); + return documentRoot; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public JavaMetaData createJavaMetaData() + { + JavaMetaDataImpl javaMetaData = new JavaMetaDataImpl(); + return javaMetaData; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public SDOMetaDataGroup createSDOMetaDataGroup() + { + SDOMetaDataGroupImpl sdoMetaDataGroup = new SDOMetaDataGroupImpl(); + return sdoMetaDataGroup; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public TypeMetaData createTypeMetaData() + { + TypeMetaDataImpl typeMetaData = new TypeMetaDataImpl(); + return typeMetaData; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public XSDMetaData createXSDMetaData() + { + XSDMetaDataImpl xsdMetaData = new XSDMetaDataImpl(); + return xsdMetaData; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public MetadataPackageImpl getMetadataPackageImpl() + { + return (MetadataPackageImpl)getEPackage(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @deprecated + * @generated + */ + public static MetadataPackageImpl getPackage() + { + return MetadataPackageImpl.eINSTANCE; + } + +} //MetadataFactoryImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/MetadataPackageImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/MetadataPackageImpl.java new file mode 100644 index 0000000000..ac9cda6f41 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/MetadataPackageImpl.java @@ -0,0 +1,1018 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.util.metadata.impl; + +import org.apache.tuscany.sdo.impl.SDOPackageImpl; + +import org.apache.tuscany.sdo.model.impl.ModelPackageImpl; + +import org.apache.tuscany.sdo.util.metadata.JavaMetaData; +import org.apache.tuscany.sdo.util.metadata.MetadataFactory; +import org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup; +import org.apache.tuscany.sdo.util.metadata.TypeMetaData; +import org.apache.tuscany.sdo.util.metadata.XSDMetaData; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EFactory; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +/** + * <!-- begin-user-doc --> + * The <b>Package</b> for the model. + * It contains accessors for the meta objects to represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.util.metadata.MetadataFactory + * @generated + */ +public class MetadataPackageImpl extends EPackageImpl +{ + /** + * The package name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final String eNAME = "metadata"; + + /** + * The package namespace URI. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final String eNS_URI = "org.apache.tuscany.sdo/metadata"; + + /** + * The package namespace name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final String eNS_PREFIX = "metadata"; + + /** + * The singleton instance of the package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final MetadataPackageImpl eINSTANCE = org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl.init(); + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.util.metadata.impl.DocumentRootImpl <em>Document Root</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.util.metadata.impl.DocumentRootImpl + * @see org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl#getDocumentRoot() + * @generated + */ + public static final int DOCUMENT_ROOT = 0; + + /** + * The feature id for the '<em><b>Mixed</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__MIXED = 0; + + /** + * The feature id for the '<em><b>XMLNS Prefix Map</b></em>' map. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__XMLNS_PREFIX_MAP = 1; + + /** + * The feature id for the '<em><b>XSI Schema Location</b></em>' map. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__XSI_SCHEMA_LOCATION = 2; + + /** + * The feature id for the '<em><b>Sdo Meta Data Group</b></em>' containment reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__SDO_META_DATA_GROUP = 3; + + /** + * The number of structural features of the '<em>Document Root</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT_FEATURE_COUNT = 4; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.util.metadata.impl.JavaMetaDataImpl <em>Java Meta Data</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.util.metadata.impl.JavaMetaDataImpl + * @see org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl#getJavaMetaData() + * @generated + */ + public static final int JAVA_META_DATA = 1; + + /** + * The feature id for the '<em><b>Factory Interface</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int JAVA_META_DATA__FACTORY_INTERFACE = 0; + + /** + * The feature id for the '<em><b>Type Interface</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int JAVA_META_DATA__TYPE_INTERFACE = 1; + + /** + * The number of structural features of the '<em>Java Meta Data</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int JAVA_META_DATA_FEATURE_COUNT = 2; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.util.metadata.impl.SDOMetaDataGroupImpl <em>SDO Meta Data Group</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.util.metadata.impl.SDOMetaDataGroupImpl + * @see org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl#getSDOMetaDataGroup() + * @generated + */ + public static final int SDO_META_DATA_GROUP = 2; + + /** + * The feature id for the '<em><b>Java Meta Data</b></em>' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int SDO_META_DATA_GROUP__JAVA_META_DATA = 0; + + /** + * The feature id for the '<em><b>Xsd Meta Data</b></em>' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int SDO_META_DATA_GROUP__XSD_META_DATA = 1; + + /** + * The feature id for the '<em><b>Type Meta Data</b></em>' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int SDO_META_DATA_GROUP__TYPE_META_DATA = 2; + + /** + * The number of structural features of the '<em>SDO Meta Data Group</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int SDO_META_DATA_GROUP_FEATURE_COUNT = 3; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.util.metadata.impl.TypeMetaDataImpl <em>Type Meta Data</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.util.metadata.impl.TypeMetaDataImpl + * @see org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl#getTypeMetaData() + * @generated + */ + public static final int TYPE_META_DATA = 3; + + /** + * The feature id for the '<em><b>Location</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int TYPE_META_DATA__LOCATION = 0; + + /** + * The number of structural features of the '<em>Type Meta Data</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int TYPE_META_DATA_FEATURE_COUNT = 1; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.util.metadata.impl.XSDMetaDataImpl <em>XSD Meta Data</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.util.metadata.impl.XSDMetaDataImpl + * @see org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl#getXSDMetaData() + * @generated + */ + public static final int XSD_META_DATA = 4; + + /** + * The feature id for the '<em><b>Location</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int XSD_META_DATA__LOCATION = 0; + + /** + * The number of structural features of the '<em>XSD Meta Data</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int XSD_META_DATA_FEATURE_COUNT = 1; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass documentRootEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass javaMetaDataEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass sdoMetaDataGroupEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass typeMetaDataEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass xsdMetaDataEClass = null; + + /** + * Creates an instance of the model <b>Package</b>, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + * <p>Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl#eNS_URI + * @see #init() + * @generated + */ + private MetadataPackageImpl() + { + super(eNS_URI, ((EFactory)MetadataFactory.INSTANCE)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the <b>Package</b> for this + * model, and for any others upon which it depends. Simple + * dependencies are satisfied by calling this method on all + * dependent packages before doing anything else. This method drives + * initialization for interdependent packages directly, in parallel + * with this package, itself. + * <p>Of this package and its interdependencies, all packages which + * have not yet been registered by their URI values are first created + * and registered. The packages are then initialized in two steps: + * meta-model objects for all of the packages are created before any + * are initialized, since one package's meta-model objects may refer to + * those of another. + * <p>Invocation of this method will not affect any packages that have + * already been initialized. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static MetadataPackageImpl init() + { + if (isInited) return (MetadataPackageImpl)EPackage.Registry.INSTANCE.getEPackage(MetadataPackageImpl.eNS_URI); + + // Obtain or create and register package + MetadataPackageImpl theMetadataPackageImpl = (MetadataPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof MetadataPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new MetadataPackageImpl()); + + isInited = true; + + // Initialize simple dependencies + SDOPackageImpl.eINSTANCE.eClass(); + ModelPackageImpl.eINSTANCE.eClass(); + + // Create package meta-data objects + theMetadataPackageImpl.createPackageContents(); + + // Initialize created meta-data + theMetadataPackageImpl.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theMetadataPackageImpl.freeze(); + + return theMetadataPackageImpl; + } + + + /** + * Returns the meta object for class '{@link org.eclipse.emf.ecore.EObject <em>Document Root</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Document Root</em>'. + * @see org.eclipse.emf.ecore.EObject + * @generated + */ + public EClass getDocumentRoot() + { + return documentRootEClass; + } + + /** + * Returns the meta object for the attribute list '{@link org.eclipse.emf.ecore.EObject#getMixed <em>Mixed</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute list '<em>Mixed</em>'. + * @see org.eclipse.emf.ecore.EObject#getMixed() + * @see #getDocumentRoot() + * @generated + */ + public EAttribute getDocumentRoot_Mixed() + { + return (EAttribute)documentRootEClass.getEStructuralFeatures().get(0); + } + + /** + * Returns the meta object for the map '{@link org.eclipse.emf.ecore.EObject#getXMLNSPrefixMap <em>XMLNS Prefix Map</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the map '<em>XMLNS Prefix Map</em>'. + * @see org.eclipse.emf.ecore.EObject#getXMLNSPrefixMap() + * @see #getDocumentRoot() + * @generated + */ + public EReference getDocumentRoot_XMLNSPrefixMap() + { + return (EReference)documentRootEClass.getEStructuralFeatures().get(1); + } + + /** + * Returns the meta object for the map '{@link org.eclipse.emf.ecore.EObject#getXSISchemaLocation <em>XSI Schema Location</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the map '<em>XSI Schema Location</em>'. + * @see org.eclipse.emf.ecore.EObject#getXSISchemaLocation() + * @see #getDocumentRoot() + * @generated + */ + public EReference getDocumentRoot_XSISchemaLocation() + { + return (EReference)documentRootEClass.getEStructuralFeatures().get(2); + } + + /** + * Returns the meta object for the containment reference '{@link org.eclipse.emf.ecore.EObject#getSdoMetaDataGroup <em>Sdo Meta Data Group</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the containment reference '<em>Sdo Meta Data Group</em>'. + * @see org.eclipse.emf.ecore.EObject#getSdoMetaDataGroup() + * @see #getDocumentRoot() + * @generated + */ + public EReference getDocumentRoot_SdoMetaDataGroup() + { + return (EReference)documentRootEClass.getEStructuralFeatures().get(3); + } + + /** + * Returns the meta object for class '{@link org.apache.tuscany.sdo.util.metadata.JavaMetaData <em>Java Meta Data</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Java Meta Data</em>'. + * @see org.apache.tuscany.sdo.util.metadata.JavaMetaData + * @generated + */ + public EClass getJavaMetaData() + { + return javaMetaDataEClass; + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.sdo.util.metadata.JavaMetaData#getFactoryInterface <em>Factory Interface</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Factory Interface</em>'. + * @see org.apache.tuscany.sdo.util.metadata.JavaMetaData#getFactoryInterface() + * @see #getJavaMetaData() + * @generated + */ + public EAttribute getJavaMetaData_FactoryInterface() + { + return (EAttribute)javaMetaDataEClass.getEStructuralFeatures().get(0); + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.sdo.util.metadata.JavaMetaData#getTypeInterface <em>Type Interface</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Type Interface</em>'. + * @see org.apache.tuscany.sdo.util.metadata.JavaMetaData#getTypeInterface() + * @see #getJavaMetaData() + * @generated + */ + public EAttribute getJavaMetaData_TypeInterface() + { + return (EAttribute)javaMetaDataEClass.getEStructuralFeatures().get(1); + } + + /** + * Returns the meta object for class '{@link org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup <em>SDO Meta Data Group</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>SDO Meta Data Group</em>'. + * @see org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup + * @generated + */ + public EClass getSDOMetaDataGroup() + { + return sdoMetaDataGroupEClass; + } + + /** + * Returns the meta object for the containment reference list '{@link org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getJavaMetaData <em>Java Meta Data</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the containment reference list '<em>Java Meta Data</em>'. + * @see org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getJavaMetaData() + * @see #getSDOMetaDataGroup() + * @generated + */ + public EReference getSDOMetaDataGroup_JavaMetaData() + { + return (EReference)sdoMetaDataGroupEClass.getEStructuralFeatures().get(0); + } + + /** + * Returns the meta object for the containment reference list '{@link org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getXsdMetaData <em>Xsd Meta Data</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the containment reference list '<em>Xsd Meta Data</em>'. + * @see org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getXsdMetaData() + * @see #getSDOMetaDataGroup() + * @generated + */ + public EReference getSDOMetaDataGroup_XsdMetaData() + { + return (EReference)sdoMetaDataGroupEClass.getEStructuralFeatures().get(1); + } + + /** + * Returns the meta object for the containment reference list '{@link org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getTypeMetaData <em>Type Meta Data</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the containment reference list '<em>Type Meta Data</em>'. + * @see org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getTypeMetaData() + * @see #getSDOMetaDataGroup() + * @generated + */ + public EReference getSDOMetaDataGroup_TypeMetaData() + { + return (EReference)sdoMetaDataGroupEClass.getEStructuralFeatures().get(2); + } + + /** + * Returns the meta object for class '{@link org.apache.tuscany.sdo.util.metadata.TypeMetaData <em>Type Meta Data</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Type Meta Data</em>'. + * @see org.apache.tuscany.sdo.util.metadata.TypeMetaData + * @generated + */ + public EClass getTypeMetaData() + { + return typeMetaDataEClass; + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.sdo.util.metadata.TypeMetaData#getLocation <em>Location</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Location</em>'. + * @see org.apache.tuscany.sdo.util.metadata.TypeMetaData#getLocation() + * @see #getTypeMetaData() + * @generated + */ + public EAttribute getTypeMetaData_Location() + { + return (EAttribute)typeMetaDataEClass.getEStructuralFeatures().get(0); + } + + /** + * Returns the meta object for class '{@link org.apache.tuscany.sdo.util.metadata.XSDMetaData <em>XSD Meta Data</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>XSD Meta Data</em>'. + * @see org.apache.tuscany.sdo.util.metadata.XSDMetaData + * @generated + */ + public EClass getXSDMetaData() + { + return xsdMetaDataEClass; + } + + /** + * Returns the meta object for the attribute '{@link org.apache.tuscany.sdo.util.metadata.XSDMetaData#getLocation <em>Location</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Location</em>'. + * @see org.apache.tuscany.sdo.util.metadata.XSDMetaData#getLocation() + * @see #getXSDMetaData() + * @generated + */ + public EAttribute getXSDMetaData_Location() + { + return (EAttribute)xsdMetaDataEClass.getEStructuralFeatures().get(0); + } + + /** + * Returns the factory that creates the instances of the model. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the factory that creates the instances of the model. + * @generated + */ + public MetadataFactory getMetadataFactory() + { + return (MetadataFactory)getEFactoryInstance(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void createPackageContents() + { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + documentRootEClass = createEClass(DOCUMENT_ROOT); + createEAttribute(documentRootEClass, DOCUMENT_ROOT__MIXED); + createEReference(documentRootEClass, DOCUMENT_ROOT__XMLNS_PREFIX_MAP); + createEReference(documentRootEClass, DOCUMENT_ROOT__XSI_SCHEMA_LOCATION); + createEReference(documentRootEClass, DOCUMENT_ROOT__SDO_META_DATA_GROUP); + + javaMetaDataEClass = createEClass(JAVA_META_DATA); + createEAttribute(javaMetaDataEClass, JAVA_META_DATA__FACTORY_INTERFACE); + createEAttribute(javaMetaDataEClass, JAVA_META_DATA__TYPE_INTERFACE); + + sdoMetaDataGroupEClass = createEClass(SDO_META_DATA_GROUP); + createEReference(sdoMetaDataGroupEClass, SDO_META_DATA_GROUP__JAVA_META_DATA); + createEReference(sdoMetaDataGroupEClass, SDO_META_DATA_GROUP__XSD_META_DATA); + createEReference(sdoMetaDataGroupEClass, SDO_META_DATA_GROUP__TYPE_META_DATA); + + typeMetaDataEClass = createEClass(TYPE_META_DATA); + createEAttribute(typeMetaDataEClass, TYPE_META_DATA__LOCATION); + + xsdMetaDataEClass = createEClass(XSD_META_DATA); + createEAttribute(xsdMetaDataEClass, XSD_META_DATA__LOCATION); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void initializePackageContents() + { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Obtain other dependent packages + ModelPackageImpl theModelPackageImpl = (ModelPackageImpl)EPackage.Registry.INSTANCE.getEPackage(ModelPackageImpl.eNS_URI); + + // Add supertypes to classes + + // Initialize classes and features; add operations and parameters + initEClass(documentRootEClass, null, "DocumentRoot", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getDocumentRoot_Mixed(), ecorePackage.getEFeatureMapEntry(), "mixed", null, 0, -1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getDocumentRoot_XMLNSPrefixMap(), ecorePackage.getEStringToStringMapEntry(), null, "xMLNSPrefixMap", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getDocumentRoot_XSISchemaLocation(), ecorePackage.getEStringToStringMapEntry(), null, "xSISchemaLocation", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getDocumentRoot_SdoMetaDataGroup(), this.getSDOMetaDataGroup(), null, "sdoMetaDataGroup", null, 0, -2, null, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + + initEClass(javaMetaDataEClass, JavaMetaData.class, "JavaMetaData", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getJavaMetaData_FactoryInterface(), theModelPackageImpl.getString(), "factoryInterface", null, 0, 1, JavaMetaData.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getJavaMetaData_TypeInterface(), theModelPackageImpl.getString(), "typeInterface", null, 0, 1, JavaMetaData.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(sdoMetaDataGroupEClass, SDOMetaDataGroup.class, "SDOMetaDataGroup", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getSDOMetaDataGroup_JavaMetaData(), this.getJavaMetaData(), null, "javaMetaData", null, 0, -1, SDOMetaDataGroup.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getSDOMetaDataGroup_XsdMetaData(), this.getXSDMetaData(), null, "xsdMetaData", null, 0, -1, SDOMetaDataGroup.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getSDOMetaDataGroup_TypeMetaData(), this.getTypeMetaData(), null, "typeMetaData", null, 0, -1, SDOMetaDataGroup.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(typeMetaDataEClass, TypeMetaData.class, "TypeMetaData", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getTypeMetaData_Location(), theModelPackageImpl.getString(), "location", null, 1, 1, TypeMetaData.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(xsdMetaDataEClass, XSDMetaData.class, "XSDMetaData", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getXSDMetaData_Location(), theModelPackageImpl.getString(), "location", null, 1, 1, XSDMetaData.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Create resource + createResource(eNS_URI); + + // Create annotations + // http:///org/eclipse/emf/ecore/util/ExtendedMetaData + createExtendedMetaDataAnnotations(); + } + + /** + * Initializes the annotations for <b>http:///org/eclipse/emf/ecore/util/ExtendedMetaData</b>. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected void createExtendedMetaDataAnnotations() + { + String source = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData"; + addAnnotation + (documentRootEClass, + source, + new String[] + { + "name", "", + "kind", "mixed" + }); + addAnnotation + (getDocumentRoot_Mixed(), + source, + new String[] + { + "kind", "elementWildcard", + "name", ":mixed" + }); + addAnnotation + (getDocumentRoot_XMLNSPrefixMap(), + source, + new String[] + { + "kind", "attribute", + "name", "xmlns:prefix" + }); + addAnnotation + (getDocumentRoot_XSISchemaLocation(), + source, + new String[] + { + "kind", "attribute", + "name", "xsi:schemaLocation" + }); + addAnnotation + (getDocumentRoot_SdoMetaDataGroup(), + source, + new String[] + { + "kind", "element", + "name", "sdoMetaDataGroup", + "namespace", "##targetNamespace" + }); + addAnnotation + (javaMetaDataEClass, + source, + new String[] + { + "name", "JavaMetaData", + "kind", "empty" + }); + addAnnotation + (getJavaMetaData_FactoryInterface(), + source, + new String[] + { + "kind", "attribute", + "name", "factoryInterface" + }); + addAnnotation + (getJavaMetaData_TypeInterface(), + source, + new String[] + { + "kind", "attribute", + "name", "typeInterface" + }); + addAnnotation + (sdoMetaDataGroupEClass, + source, + new String[] + { + "name", "SDOMetaDataGroup", + "kind", "elementOnly" + }); + addAnnotation + (getSDOMetaDataGroup_JavaMetaData(), + source, + new String[] + { + "kind", "element", + "name", "javaMetaData" + }); + addAnnotation + (getSDOMetaDataGroup_XsdMetaData(), + source, + new String[] + { + "kind", "element", + "name", "xsdMetaData" + }); + addAnnotation + (getSDOMetaDataGroup_TypeMetaData(), + source, + new String[] + { + "kind", "element", + "name", "typeMetaData" + }); + addAnnotation + (typeMetaDataEClass, + source, + new String[] + { + "name", "TypeMetaData", + "kind", "empty" + }); + addAnnotation + (getTypeMetaData_Location(), + source, + new String[] + { + "kind", "attribute", + "name", "location" + }); + addAnnotation + (xsdMetaDataEClass, + source, + new String[] + { + "name", "XSDMetaData", + "kind", "empty" + }); + addAnnotation + (getXSDMetaData_Location(), + source, + new String[] + { + "kind", "attribute", + "name", "location" + }); + } + + /** + * <!-- begin-user-doc --> + * Defines literals for the meta objects that represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @generated + */ + public interface Literals + { + /** + * The meta object literal for the '{@link org.apache.tuscany.sdo.util.metadata.impl.DocumentRootImpl <em>Document Root</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.util.metadata.impl.DocumentRootImpl + * @see org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl#getDocumentRoot() + * @generated + */ + public static final EClass DOCUMENT_ROOT = eINSTANCE.getDocumentRoot(); + + /** + * The meta object literal for the '<em><b>Mixed</b></em>' attribute list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute DOCUMENT_ROOT__MIXED = eINSTANCE.getDocumentRoot_Mixed(); + + /** + * The meta object literal for the '<em><b>XMLNS Prefix Map</b></em>' map feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference DOCUMENT_ROOT__XMLNS_PREFIX_MAP = eINSTANCE.getDocumentRoot_XMLNSPrefixMap(); + + /** + * The meta object literal for the '<em><b>XSI Schema Location</b></em>' map feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference DOCUMENT_ROOT__XSI_SCHEMA_LOCATION = eINSTANCE.getDocumentRoot_XSISchemaLocation(); + + /** + * The meta object literal for the '<em><b>Sdo Meta Data Group</b></em>' containment reference feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference DOCUMENT_ROOT__SDO_META_DATA_GROUP = eINSTANCE.getDocumentRoot_SdoMetaDataGroup(); + + /** + * The meta object literal for the '{@link org.apache.tuscany.sdo.util.metadata.impl.JavaMetaDataImpl <em>Java Meta Data</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.util.metadata.impl.JavaMetaDataImpl + * @see org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl#getJavaMetaData() + * @generated + */ + public static final EClass JAVA_META_DATA = eINSTANCE.getJavaMetaData(); + + /** + * The meta object literal for the '<em><b>Factory Interface</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute JAVA_META_DATA__FACTORY_INTERFACE = eINSTANCE.getJavaMetaData_FactoryInterface(); + + /** + * The meta object literal for the '<em><b>Type Interface</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute JAVA_META_DATA__TYPE_INTERFACE = eINSTANCE.getJavaMetaData_TypeInterface(); + + /** + * The meta object literal for the '{@link org.apache.tuscany.sdo.util.metadata.impl.SDOMetaDataGroupImpl <em>SDO Meta Data Group</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.util.metadata.impl.SDOMetaDataGroupImpl + * @see org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl#getSDOMetaDataGroup() + * @generated + */ + public static final EClass SDO_META_DATA_GROUP = eINSTANCE.getSDOMetaDataGroup(); + + /** + * The meta object literal for the '<em><b>Java Meta Data</b></em>' containment reference list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference SDO_META_DATA_GROUP__JAVA_META_DATA = eINSTANCE.getSDOMetaDataGroup_JavaMetaData(); + + /** + * The meta object literal for the '<em><b>Xsd Meta Data</b></em>' containment reference list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference SDO_META_DATA_GROUP__XSD_META_DATA = eINSTANCE.getSDOMetaDataGroup_XsdMetaData(); + + /** + * The meta object literal for the '<em><b>Type Meta Data</b></em>' containment reference list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference SDO_META_DATA_GROUP__TYPE_META_DATA = eINSTANCE.getSDOMetaDataGroup_TypeMetaData(); + + /** + * The meta object literal for the '{@link org.apache.tuscany.sdo.util.metadata.impl.TypeMetaDataImpl <em>Type Meta Data</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.util.metadata.impl.TypeMetaDataImpl + * @see org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl#getTypeMetaData() + * @generated + */ + public static final EClass TYPE_META_DATA = eINSTANCE.getTypeMetaData(); + + /** + * The meta object literal for the '<em><b>Location</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute TYPE_META_DATA__LOCATION = eINSTANCE.getTypeMetaData_Location(); + + /** + * The meta object literal for the '{@link org.apache.tuscany.sdo.util.metadata.impl.XSDMetaDataImpl <em>XSD Meta Data</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.apache.tuscany.sdo.util.metadata.impl.XSDMetaDataImpl + * @see org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl#getXSDMetaData() + * @generated + */ + public static final EClass XSD_META_DATA = eINSTANCE.getXSDMetaData(); + + /** + * The meta object literal for the '<em><b>Location</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute XSD_META_DATA__LOCATION = eINSTANCE.getXSDMetaData_Location(); + + } + +} //MetadataPackageImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/SDOMetaDataGroupImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/SDOMetaDataGroupImpl.java new file mode 100644 index 0000000000..6add915cfc --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/SDOMetaDataGroupImpl.java @@ -0,0 +1,326 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.util.metadata.impl; + +import java.io.InputStream; +import java.net.URL; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import org.apache.tuscany.sdo.impl.DataObjectImpl; +import org.apache.tuscany.sdo.model.Types; +import org.apache.tuscany.sdo.util.SDOUtil; +import org.apache.tuscany.sdo.util.metadata.JavaMetaData; +import org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup; +import org.apache.tuscany.sdo.util.metadata.TypeMetaData; +import org.apache.tuscany.sdo.util.metadata.XSDMetaData; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; + +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XMLDocument; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>SDO Meta Data Group</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.sdo.util.metadata.impl.SDOMetaDataGroupImpl#getJavaMetaData <em>Java Meta Data</em>}</li> + * <li>{@link org.apache.tuscany.sdo.util.metadata.impl.SDOMetaDataGroupImpl#getXsdMetaData <em>Xsd Meta Data</em>}</li> + * <li>{@link org.apache.tuscany.sdo.util.metadata.impl.SDOMetaDataGroupImpl#getTypeMetaData <em>Type Meta Data</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class SDOMetaDataGroupImpl extends DataObjectImpl implements SDOMetaDataGroup +{ + public void register(TypeHelper typeHelper) + { + try + { + ClassLoader classLoader = (ClassLoader)AccessController.doPrivileged(new PrivilegedAction() + { + public Object run() + { + return Thread.currentThread().getContextClassLoader(); + } + }); + register(typeHelper, classLoader); + } + catch (SecurityException e) + { + } + } + + public void register(TypeHelper typeHelper, ClassLoader classLoader) + { + try + { + for (Iterator iter = getJavaMetaData().iterator(); iter.hasNext();) + { + JavaMetaData metadata = (JavaMetaData)iter.next(); + String factoryInterface = metadata.getFactoryInterface(); + if (factoryInterface != null) + { + Class factoryInterfaceClass = classLoader.loadClass(factoryInterface); + SDOUtil.registerStaticTypes(factoryInterfaceClass); + } + else + { + String typeInterface = metadata.getTypeInterface(); + Class typeInterfaceClass = classLoader.loadClass(typeInterface); + // TODO: introspect and register the type + } + } + + XSDHelper xsdHelper = SDOUtil.createXSDHelper(typeHelper); + for (Iterator iter = getXsdMetaData().iterator(); iter.hasNext();) + { + XSDMetaData metadata = (XSDMetaData)iter.next(); + URL url = getClass().getResource(metadata.getLocation()); + InputStream inputStream = url.openStream(); + xsdHelper.define(inputStream, url.toString()); + } + + XMLHelper xmlHelper = SDOUtil.createXMLHelper(typeHelper); + for (Iterator iter = getTypeMetaData().iterator(); iter.hasNext();) + { + TypeMetaData metadata = (TypeMetaData)iter.next(); + URL url = getClass().getResource(metadata.getLocation()); + InputStream inputStream = url.openStream(); + XMLDocument xmlDocument = xmlHelper.load(inputStream); + Types types = (Types)xmlDocument.getRootObject(); + typeHelper.define(types.getTypeList()); + } + } + catch (Exception e) + { + } + } + + /** + * The cached value of the '{@link #getJavaMetaData() <em>Java Meta Data</em>}' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getJavaMetaData() + * @generated + * @ordered + */ + protected EList javaMetaData = null; + + /** + * The cached value of the '{@link #getXsdMetaData() <em>Xsd Meta Data</em>}' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getXsdMetaData() + * @generated + * @ordered + */ + protected EList xsdMetaData = null; + + /** + * The cached value of the '{@link #getTypeMetaData() <em>Type Meta Data</em>}' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getTypeMetaData() + * @generated + * @ordered + */ + protected EList typeMetaData = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected SDOMetaDataGroupImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return MetadataPackageImpl.Literals.SDO_META_DATA_GROUP; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public List getJavaMetaData() + { + if (javaMetaData == null) + { + javaMetaData = new EObjectContainmentEList(JavaMetaData.class, this, MetadataPackageImpl.SDO_META_DATA_GROUP__JAVA_META_DATA); + } + return javaMetaData; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public List getXsdMetaData() + { + if (xsdMetaData == null) + { + xsdMetaData = new EObjectContainmentEList(XSDMetaData.class, this, MetadataPackageImpl.SDO_META_DATA_GROUP__XSD_META_DATA); + } + return xsdMetaData; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public List getTypeMetaData() + { + if (typeMetaData == null) + { + typeMetaData = new EObjectContainmentEList(TypeMetaData.class, this, MetadataPackageImpl.SDO_META_DATA_GROUP__TYPE_META_DATA); + } + return typeMetaData; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) + { + switch (featureID) + { + case MetadataPackageImpl.SDO_META_DATA_GROUP__JAVA_META_DATA: + return ((InternalEList)getJavaMetaData()).basicRemove(otherEnd, msgs); + case MetadataPackageImpl.SDO_META_DATA_GROUP__XSD_META_DATA: + return ((InternalEList)getXsdMetaData()).basicRemove(otherEnd, msgs); + case MetadataPackageImpl.SDO_META_DATA_GROUP__TYPE_META_DATA: + return ((InternalEList)getTypeMetaData()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case MetadataPackageImpl.SDO_META_DATA_GROUP__JAVA_META_DATA: + return getJavaMetaData(); + case MetadataPackageImpl.SDO_META_DATA_GROUP__XSD_META_DATA: + return getXsdMetaData(); + case MetadataPackageImpl.SDO_META_DATA_GROUP__TYPE_META_DATA: + return getTypeMetaData(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case MetadataPackageImpl.SDO_META_DATA_GROUP__JAVA_META_DATA: + getJavaMetaData().clear(); + getJavaMetaData().addAll((Collection)newValue); + return; + case MetadataPackageImpl.SDO_META_DATA_GROUP__XSD_META_DATA: + getXsdMetaData().clear(); + getXsdMetaData().addAll((Collection)newValue); + return; + case MetadataPackageImpl.SDO_META_DATA_GROUP__TYPE_META_DATA: + getTypeMetaData().clear(); + getTypeMetaData().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case MetadataPackageImpl.SDO_META_DATA_GROUP__JAVA_META_DATA: + getJavaMetaData().clear(); + return; + case MetadataPackageImpl.SDO_META_DATA_GROUP__XSD_META_DATA: + getXsdMetaData().clear(); + return; + case MetadataPackageImpl.SDO_META_DATA_GROUP__TYPE_META_DATA: + getTypeMetaData().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case MetadataPackageImpl.SDO_META_DATA_GROUP__JAVA_META_DATA: + return javaMetaData != null && !javaMetaData.isEmpty(); + case MetadataPackageImpl.SDO_META_DATA_GROUP__XSD_META_DATA: + return xsdMetaData != null && !xsdMetaData.isEmpty(); + case MetadataPackageImpl.SDO_META_DATA_GROUP__TYPE_META_DATA: + return typeMetaData != null && !typeMetaData.isEmpty(); + } + return super.eIsSet(featureID); + } + +} //SDOMetaDataGroupImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/TypeMetaDataImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/TypeMetaDataImpl.java new file mode 100644 index 0000000000..cabbe5585f --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/TypeMetaDataImpl.java @@ -0,0 +1,188 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.util.metadata.impl; + +import org.apache.tuscany.sdo.impl.DataObjectImpl; + +import org.apache.tuscany.sdo.util.metadata.TypeMetaData; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Type Meta Data</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.sdo.util.metadata.impl.TypeMetaDataImpl#getLocation <em>Location</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class TypeMetaDataImpl extends DataObjectImpl implements TypeMetaData +{ + /** + * The default value of the '{@link #getLocation() <em>Location</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getLocation() + * @generated + * @ordered + */ + protected static final String LOCATION_EDEFAULT = null; + + /** + * The cached value of the '{@link #getLocation() <em>Location</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getLocation() + * @generated + * @ordered + */ + protected String location = LOCATION_EDEFAULT; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected TypeMetaDataImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return MetadataPackageImpl.Literals.TYPE_META_DATA; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getLocation() + { + return location; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setLocation(String newLocation) + { + String oldLocation = location; + location = newLocation; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackageImpl.TYPE_META_DATA__LOCATION, oldLocation, location)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case MetadataPackageImpl.TYPE_META_DATA__LOCATION: + return getLocation(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case MetadataPackageImpl.TYPE_META_DATA__LOCATION: + setLocation((String)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case MetadataPackageImpl.TYPE_META_DATA__LOCATION: + setLocation(LOCATION_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case MetadataPackageImpl.TYPE_META_DATA__LOCATION: + return LOCATION_EDEFAULT == null ? location != null : !LOCATION_EDEFAULT.equals(location); + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (location: "); + result.append(location); + result.append(')'); + return result.toString(); + } + +} //TypeMetaDataImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/XSDMetaDataImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/XSDMetaDataImpl.java new file mode 100644 index 0000000000..96abb49d37 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/XSDMetaDataImpl.java @@ -0,0 +1,188 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.util.metadata.impl; + +import org.apache.tuscany.sdo.impl.DataObjectImpl; + +import org.apache.tuscany.sdo.util.metadata.XSDMetaData; + +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.ecore.EClass; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>XSD Meta Data</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link org.apache.tuscany.sdo.util.metadata.impl.XSDMetaDataImpl#getLocation <em>Location</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class XSDMetaDataImpl extends DataObjectImpl implements XSDMetaData +{ + /** + * The default value of the '{@link #getLocation() <em>Location</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getLocation() + * @generated + * @ordered + */ + protected static final String LOCATION_EDEFAULT = null; + + /** + * The cached value of the '{@link #getLocation() <em>Location</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getLocation() + * @generated + * @ordered + */ + protected String location = LOCATION_EDEFAULT; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected XSDMetaDataImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return MetadataPackageImpl.Literals.XSD_META_DATA; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getLocation() + { + return location; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setLocation(String newLocation) + { + String oldLocation = location; + location = newLocation; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackageImpl.XSD_META_DATA__LOCATION, oldLocation, location)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case MetadataPackageImpl.XSD_META_DATA__LOCATION: + return getLocation(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case MetadataPackageImpl.XSD_META_DATA__LOCATION: + setLocation((String)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case MetadataPackageImpl.XSD_META_DATA__LOCATION: + setLocation(LOCATION_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case MetadataPackageImpl.XSD_META_DATA__LOCATION: + return LOCATION_EDEFAULT == null ? location != null : !LOCATION_EDEFAULT.equals(location); + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (location: "); + result.append(location); + result.append(')'); + return result.toString(); + } + +} //XSDMetaDataImpl diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/DataObjectXMLStreamReader.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/DataObjectXMLStreamReader.java new file mode 100644 index 0000000000..65203af766 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/DataObjectXMLStreamReader.java @@ -0,0 +1,1530 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.util.resource; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.xml.namespace.NamespaceContext; +import javax.xml.namespace.QName; +import javax.xml.stream.Location; +import javax.xml.stream.XMLStreamException; + +import org.apache.tuscany.sdo.impl.AttributeImpl; +import org.apache.tuscany.sdo.impl.ReferenceImpl; +import org.apache.tuscany.sdo.util.SDOUtil; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EReference; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Sequence; +import commonj.sdo.Type; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XMLDocument; +import commonj.sdo.helper.XSDHelper; + +public class DataObjectXMLStreamReader implements XMLFragmentStreamReader { + private static final QName XSI_TYPE_QNAME = new QName("http://www.w3.org/2001/XMLSchema-instance", "type", "xsi"); + private Property rootElement = null; + private DataObject dataObject; + + private String rootElementURI; + + private String rootElementName; + + private TypeHelper typeHelper; + + private XSDHelper xsdHelper; + + private Map.Entry[] properties; + + private Map.Entry[] attributes; + + private QName elementQName; + + // we always create a new namespace context + private DelegatingNamespaceContext namespaceContext = new DelegatingNamespaceContext(null); + + private Map declaredNamespaceMap = new HashMap(); + + // states for this pullparser - it can only have three states + private static final int START_ELEMENT_STATE = 0; + + private static final int END_ELEMENT_STATE = 1; + + private static final int DELEGATED_STATE = 2; + + private static final int TEXT_STATE = 3; + + // integer field that keeps the state of this + // parser. + private int state = START_ELEMENT_STATE; + + // reference to the child reader + private XMLFragmentStreamReader childReader; + + // current property index + // initialized at zero + private int currentPropertyIndex = 0; + + public DataObjectXMLStreamReader(DataObject dataObject, String rootElmentURI, String rootElementName) { + this(dataObject, rootElmentURI, rootElementName, null, null); + } + + public DataObjectXMLStreamReader(DataObject dataObject, String rootElmentURI, String rootElementName, TypeHelper typeHelper) { + this(dataObject, rootElmentURI, rootElementName, typeHelper, null); + } + + public DataObjectXMLStreamReader(DataObject dataObject, String rootElmentURI, String rootElementName, TypeHelper typeHelper, XSDHelper xsdHelper) { + this.dataObject = dataObject; + this.rootElementURI = rootElmentURI; + this.rootElementName = rootElementName; + this.typeHelper = typeHelper == null ? TypeHelper.INSTANCE : typeHelper; + this.xsdHelper = (xsdHelper != null) ? xsdHelper : ((typeHelper == null) ? XSDHelper.INSTANCE : SDOUtil.createXSDHelper(typeHelper)); + rootElement = this.xsdHelper.getGlobalProperty(rootElmentURI, rootElementName, true); + populateProperties(); + } + + protected DataObjectXMLStreamReader(Property rootElement, DataObject dataObject, TypeHelper typeHelper, XSDHelper xsdHelper) { + this.typeHelper = typeHelper == null ? TypeHelper.INSTANCE : typeHelper; + this.xsdHelper = (xsdHelper != null) ? xsdHelper : ((typeHelper == null) ? XSDHelper.INSTANCE : SDOUtil.createXSDHelper(typeHelper)); + this.rootElement = rootElement; + this.dataObject = dataObject; + this.rootElementURI = xsdHelper.getNamespaceURI(rootElement); + this.rootElementName = xsdHelper.getLocalName(rootElement); + populateProperties(); + } + + public DataObjectXMLStreamReader(XMLDocument document, TypeHelper typeHelper) { + this.dataObject = document.getRootObject(); + this.rootElementName = document.getRootElementName(); + this.rootElementURI = document.getRootElementURI(); + this.typeHelper = typeHelper; + this.xsdHelper = typeHelper == null ? XSDHelper.INSTANCE : SDOUtil.createXSDHelper(typeHelper); + populateProperties(); + } + + /* + * we need to pass in a namespace context since when delegated, we've no idea of the current namespace context. So it needs to be passed on here! + */ + protected DataObjectXMLStreamReader(QName elementQName, Map.Entry[] properties, Map.Entry[] attributes) { + // validate the lengths, since both the arrays are supposed + // to have + this.properties = properties; + this.elementQName = elementQName; + this.attributes = attributes; + + } + + private void addProperty(List propertyList, Property property, Object value) { + if (isTransient(property)) + return; + if (property.isMany() && property.getContainingType().isOpen() && value instanceof Sequence) { + addSequenceValue(propertyList, (Sequence) value); + } else if (SDOUtil.isMany(property, dataObject) && value instanceof List) { + addListValue(propertyList, property, (List) value); + } else { + // Complex Type + addSingleValue(propertyList, property, value); + } + } + + private void addSequenceValue(List elements, Sequence seq) { + if (seq != null && seq.size() > 0) { + for (int j = 0; j < seq.size(); j++) { + Object o = seq.getValue(j); + Property p = seq.getProperty(j); + addSingleValue(elements, p, o); + } + } + } + + private boolean isTransient(Property property) { + // HACK: We need some SDOUtil extension to understand a property is derived + if (property instanceof ReferenceImpl) { + ReferenceImpl r = (ReferenceImpl) property; + if (r.isTransient()) + return true; + EReference opposite = r.getEOpposite(); + if (opposite != null && opposite.isContainment()) { + return true; + } + } else if (property instanceof AttributeImpl) { + AttributeImpl a = (AttributeImpl) property; + if (a.isTransient()) + return true; + EDataType d = (EDataType) a.getEType(); + if (!d.isSerializable()) { + return true; + } + } + return false; + } + + private void addListValue(List propertyList, Property property, List objList) { + if (objList != null) { + for (int j = 0; j < objList.size(); j++) { + Object object = objList.get(j); + addSingleValue(propertyList, property, object); + } + } + } + + private void addSingleValue(List propertyList, Property property, Object value) { + String uri = xsdHelper.getNamespaceURI(property); + String name = xsdHelper.getLocalName(property); + QName qname = namespaceContext.createQName(uri, name); + Type propertyType = property.getType(); + + if (property.getName().equals("value") && uri == null && name.equals(":0")) { + // "value" is special property containing the value of simpleContent + Map.Entry entry = new NameValuePair(ELEMENT_TEXT, value); + propertyList.add(entry); + } else + + // FIXME: We need to deal with non-containment properties + if (value == null) { + // Creating xsi:nil="true" for elements + Map.Entry entry = new NameValuePair(qname, null); + propertyList.add(entry); + } else if (propertyType.isDataType()) { + Map.Entry entry = new NameValuePair(qname, SDOUtil.convertToString(propertyType, value)); + propertyList.add(entry); + } else { + DataObjectXMLStreamReader childReader = new DataObjectXMLStreamReader(property, (DataObject) value, typeHelper, xsdHelper); + childReader.rootElement = property; + Map.Entry entry = new NameValuePair(qname, childReader); + propertyList.add(entry); + } + } + + public void populateProperties() { + declaredNamespaceMap.put("xml", "http://www.w3.org/XML/1998/namespace"); + declaredNamespaceMap.put("xmlns", "http://www.w3.org/2000/xmlns/"); + declaredNamespaceMap.put("xsi", "http://www.w3.org/2001/XMLSchema-instance"); + + + if (properties != null) + return; + if (elementQName == null) + elementQName = namespaceContext.createQName(this.rootElementURI, this.rootElementName); + else + elementQName = namespaceContext.createQName(elementQName.getNamespaceURI(), elementQName.getLocalPart()); + + List elementList = new ArrayList(); + List attributeList = new ArrayList(); + Type type = dataObject.getType(); + if (rootElement != null) { + Type modelType = rootElement.getType(); + if (type != modelType) { + // FIXME: XSDHelper.getLocalName() for annoymous type returns null? + String typeName = xsdHelper.getLocalName(type); + if (typeName != null) { + QName realTypeName = namespaceContext.createQName(type.getURI(), typeName); + String typeQName = realTypeName.getPrefix() + ":" + realTypeName.getLocalPart(); + QName xmlns = + new QName("http://www.w3.org/2000/xmlns/", realTypeName.getPrefix(), "xmlns"); + attributeList.add(new NameValuePair(xmlns, realTypeName.getNamespaceURI())); + attributeList.add(new NameValuePair(XSI_TYPE_QNAME, typeQName)); + } + } + } + + if (type.isSequenced()) { + Sequence sequence = dataObject.getSequence(); + for (int i = 0; i < sequence.size(); i++) { + Property property = sequence.getProperty(i); + Object value = sequence.getValue(i); + if (property == null) { + // property == null for text in mixed content + elementList.add(new NameValuePair(ELEMENT_TEXT, value)); + } else { + addProperty(elementList, property, value); + } + } + // Attributes are not in the sequence + List properties = dataObject.getInstanceProperties(); + for (Iterator i = properties.iterator(); i.hasNext();) { + Property property = (Property) i.next(); + if (xsdHelper.isAttribute(property)) { + // FIXME: How to handle nilable=true? + if (!dataObject.isSet(property)) + continue; + Object value = dataObject.get(property); + addProperty(attributeList, property, value); + } + } + } else { + List properties = dataObject.getInstanceProperties(); + for (Iterator i = properties.iterator(); i.hasNext();) { + Property property = (Property) i.next(); + // FIXME: How to handle nilable=true? + if (!dataObject.isSet(property)) + continue; + Object value = dataObject.get(property); + if (xsdHelper.isAttribute(property)) + addProperty(attributeList, property, value); + else + addProperty(elementList, property, value); + } + } + properties = (Map.Entry[]) elementList.toArray(new Map.Entry[0]); + attributes = (Map.Entry[]) attributeList.toArray(new Map.Entry[0]); + } + + public DataObject getDataObject() { + return dataObject; + } + + /** + * add the namespace context + */ + + public void setParentNamespaceContext(NamespaceContext nsContext) { + // register the namespace context passed in to this + this.namespaceContext.setParent(nsContext); + + } + + /** + * we need to split out the calling to the populate namespaces seperately since this needs to be done *after* setting the parent namespace + * context. We cannot assume it will happen at construction! + */ + public void init() { + // here we have an extra issue to attend to. we need to look at the + // prefixes and uris (the combination) and populate a hashmap of + // namespaces. The hashmap of namespaces will be used to serve the + // namespace context + + populateNamespaceContext(); + } + + /** + * + * @param key + * @return + * @throws IllegalArgumentException + */ + public Object getProperty(String key) throws IllegalArgumentException { + if (state == START_ELEMENT_STATE || state == END_ELEMENT_STATE) { + return null; + } else if (state == TEXT_STATE) { + return null; + } else if (state == DELEGATED_STATE) { + return childReader.getProperty(key); + } else { + return null; + } + + } + + public int next() throws XMLStreamException { + return updateStatus(); + } + + public void require(int i, String string, String string1) throws XMLStreamException { + throw new UnsupportedOperationException(); + } + + /** + * todo implement the right contract for this + * + * @return + * @throws XMLStreamException + */ + public String getElementText() throws XMLStreamException { + if (state == DELEGATED_STATE) { + return childReader.getElementText(); + } else { + return null; + } + + } + + /** + * todo implement this + * + * @return + * @throws XMLStreamException + */ + public int nextTag() throws XMLStreamException { + return 0; + } + + /** + * @return + * @throws XMLStreamException + */ + public boolean hasNext() throws XMLStreamException { + if (state == DELEGATED_STATE) { + if (childReader.isEndOfFragment()) { + // the child reader is done. We shouldn't be getting the + // hasnext result from the child pullparser then + return true; + } else { + return childReader.hasNext(); + } + } else { + return (state == START_ELEMENT_STATE || state == TEXT_STATE); + + } + } + + public void close() throws XMLStreamException { + // do nothing here - we have no resources to free + } + + public String getNamespaceURI(String prefix) { + return namespaceContext.getNamespaceURI(prefix); + } + + public boolean isStartElement() { + if (state == START_ELEMENT_STATE) { + return true; + } else if (state == END_ELEMENT_STATE) { + return false; + } + return childReader.isStartElement(); + } + + public boolean isEndElement() { + if (state == START_ELEMENT_STATE) { + return false; + } else if (state == END_ELEMENT_STATE) { + return true; + } + return childReader.isEndElement(); + } + + public boolean isCharacters() { + if (state == START_ELEMENT_STATE || state == END_ELEMENT_STATE) { + return false; + } + return childReader.isCharacters(); + } + + public boolean isWhiteSpace() { + if (state == START_ELEMENT_STATE || state == END_ELEMENT_STATE) { + return false; + } + return childReader.isWhiteSpace(); + } + + // ///////////////////////////////////////////////////////////////////////// + // / attribute handling + // ///////////////////////////////////////////////////////////////////////// + + public String getAttributeValue(String nsUri, String localName) { + + int attribCount = getAttributeCount(); + String returnValue = null; + QName attribQualifiedName; + for (int i = 0; i < attribCount; i++) { + attribQualifiedName = getAttributeName(i); + if (nsUri == null) { + if (localName.equals(attribQualifiedName.getLocalPart())) { + returnValue = getAttributeValue(i); + break; + } + } else { + if (localName.equals(attribQualifiedName.getLocalPart()) && nsUri.equals(attribQualifiedName.getNamespaceURI())) { + returnValue = getAttributeValue(i); + break; + } + } + + } + + return returnValue; + } + + public int getAttributeCount() { + return (state == DELEGATED_STATE) ? childReader.getAttributeCount() + : ((attributes != null) && (state == START_ELEMENT_STATE) ? attributes.length : 0); + } + + /** + * @param i + * @return + */ + public QName getAttributeName(int i) { + if (state == DELEGATED_STATE) { + return childReader.getAttributeName(i); + } else if (state == START_ELEMENT_STATE) { + if (attributes == null) { + return null; + } else { + if ((i >= (attributes.length)) || i < 0) { // out of range + return null; + } else { + // get the attribute pointer + Object attribPointer = attributes[i].getKey(); + // case one - attrib name is null + // this should be the pointer to the OMAttribute then + if (attribPointer instanceof String) { + return new QName((String) attribPointer); + } else if (attribPointer instanceof QName) { + return (QName) attribPointer; + } else { + return null; + } + } + } + } else { + throw new IllegalStateException();// as per the api contract + } + + } + + public String getAttributeNamespace(int i) { + if (state == DELEGATED_STATE) { + return childReader.getAttributeNamespace(i); + } else if (state == START_ELEMENT_STATE) { + QName name = getAttributeName(i); + if (name == null) { + return null; + } else { + return name.getNamespaceURI(); + } + } else { + throw new IllegalStateException(); + } + } + + public String getAttributeLocalName(int i) { + if (state == DELEGATED_STATE) { + return childReader.getAttributeLocalName(i); + } else if (state == START_ELEMENT_STATE) { + QName name = getAttributeName(i); + if (name == null) { + return null; + } else { + return name.getLocalPart(); + } + } else { + throw new IllegalStateException(); + } + } + + public String getAttributePrefix(int i) { + if (state == DELEGATED_STATE) { + return childReader.getAttributePrefix(i); + } else if (state == START_ELEMENT_STATE) { + QName name = getAttributeName(i); + if (name == null) { + return null; + } else { + return name.getPrefix(); + } + } else { + throw new IllegalStateException(); + } + } + + public String getAttributeType(int i) { + return null; // not supported + } + + public String getAttributeValue(int i) { + if (state == DELEGATED_STATE) { + return childReader.getAttributeValue(i); + } else if (state == START_ELEMENT_STATE) { + if (attributes == null) { + return null; + } else { + if ((i >= (attributes.length)) || i < 0) { // out of range + return null; + } else { + // get the attribute pointer + Object attribPointer = attributes[i].getKey(); + Object omAttribObj = attributes[i].getValue(); + // case one - attrib name is null + // this should be the pointer to the OMAttribute then + if (attribPointer instanceof String) { + return (String) omAttribObj; + } else if (attribPointer instanceof QName) { + return (String) omAttribObj; + } else { + return null; + } + } + } + } else { + throw new IllegalStateException(); + } + + } + + public boolean isAttributeSpecified(int i) { + return false; // not supported + } + + // ///////////////////////////////////////////////////////////////////////// + // //////////// end of attribute handling + // ///////////////////////////////////////////////////////////////////////// + + // ////////////////////////////////////////////////////////////////////////// + // //////////// namespace handling + // ////////////////////////////////////////////////////////////////////////// + + public int getNamespaceCount() { + if (state == DELEGATED_STATE) { + return childReader.getNamespaceCount(); + } else { + return declaredNamespaceMap.size(); + } + } + + /** + * @param i + * @return + */ + public String getNamespacePrefix(int i) { + if (state == DELEGATED_STATE) { + return childReader.getNamespacePrefix(i); + } else if (state != TEXT_STATE) { + // order the prefixes + String[] prefixes = makePrefixArray(); + if ((i >= prefixes.length) || (i < 0)) { + return null; + } else { + return prefixes[i]; + } + + } else { + throw new IllegalStateException(); + } + + } + + /** + * Get the prefix list from the hastable and take that into an array + * + * @return + */ + private String[] makePrefixArray() { + String[] prefixes = (String[]) declaredNamespaceMap.keySet().toArray(new String[declaredNamespaceMap.size()]); + Arrays.sort(prefixes); + return prefixes; + } + + public String getNamespaceURI(int i) { + if (state == DELEGATED_STATE) { + return childReader.getNamespaceURI(i); + } else if (state != TEXT_STATE) { + String namespacePrefix = getNamespacePrefix(i); + return namespacePrefix == null ? null : (String) declaredNamespaceMap.get(namespacePrefix); + } else { + throw new IllegalStateException(); + } + + } + + public NamespaceContext getNamespaceContext() { + if (state == DELEGATED_STATE) { + return childReader.getNamespaceContext(); + } else { + return namespaceContext; + } + + } + + // ///////////////////////////////////////////////////////////////////////// + // /////// end of namespace handling + // ///////////////////////////////////////////////////////////////////////// + + public int getEventType() { + if (state == START_ELEMENT_STATE) { + return START_ELEMENT; + } else if (state == END_ELEMENT_STATE) { + return END_ELEMENT; + } else { // this is the delegated state + return childReader.getEventType(); + } + + } + + public String getText() { + if (state == DELEGATED_STATE) { + return childReader.getText(); + } else if (state == TEXT_STATE) { + return (String) properties[currentPropertyIndex - 1].getValue(); + } else { + throw new IllegalStateException(); + } + } + + public char[] getTextCharacters() { + if (state == DELEGATED_STATE) { + return childReader.getTextCharacters(); + } else if (state == TEXT_STATE) { + return properties[currentPropertyIndex - 1].getValue() == null ? new char[0] : ((String) properties[currentPropertyIndex - 1].getValue()) + .toCharArray(); + } else { + throw new IllegalStateException(); + } + } + + public int getTextCharacters(int i, char[] chars, int i1, int i2) throws XMLStreamException { + if (state == DELEGATED_STATE) { + return childReader.getTextCharacters(i, chars, i1, i2); + } else if (state == TEXT_STATE) { + // todo - implement this + return 0; + } else { + throw new IllegalStateException(); + } + } + + public int getTextStart() { + if (state == DELEGATED_STATE) { + return childReader.getTextStart(); + } else if (state == TEXT_STATE) { + return 0;// assume text always starts at 0 + } else { + throw new IllegalStateException(); + } + } + + public int getTextLength() { + if (state == DELEGATED_STATE) { + return childReader.getTextLength(); + } else if (state == TEXT_STATE) { + return 0;// assume text always starts at 0 + } else { + throw new IllegalStateException(); + } + } + + public String getEncoding() { + if (state == DELEGATED_STATE) { + return childReader.getEncoding(); + } else { + // we've no idea what the encoding is going to be in this case + // perhaps we ought to return some constant here, which the user might + // have access to change! + return null; + } + } + + /** + * check the validity of this implementation + * + * @return + */ + public boolean hasText() { + if (state == DELEGATED_STATE) { + return childReader.hasText(); + } else if (state == TEXT_STATE) { + return true; + } else { + return false; + } + + } + + /** + * @return + */ + public Location getLocation() { + // return a default location + return new Location() { + public int getLineNumber() { + return 0; + } + + public int getColumnNumber() { + return 0; + } + + public int getCharacterOffset() { + return 0; + } + + public String getPublicId() { + return null; + } + + public String getSystemId() { + return null; + } + }; + } + + public QName getName() { + if (state == DELEGATED_STATE) { + return childReader.getName(); + } else if (state != TEXT_STATE) { + return elementQName; + } else { + throw new IllegalStateException(); + } + + } + + public String getLocalName() { + if (state == DELEGATED_STATE) { + return childReader.getLocalName(); + } else if (state != TEXT_STATE) { + return elementQName.getLocalPart(); + } else { + throw new IllegalStateException(); + } + } + + public boolean hasName() { + // since this parser always has a name, the hasname + // has to return true if we are still navigating this element + // if not we should ask the child reader for it. + if (state == DELEGATED_STATE) { + return childReader.hasName(); + } else if (state != TEXT_STATE) { + return true; + } else { + return false; + } + } + + public String getNamespaceURI() { + if (state == DELEGATED_STATE) { + return childReader.getNamespaceURI(); + } else if (state == TEXT_STATE) { + return null; + } else { + return elementQName.getNamespaceURI(); + } + } + + public String getPrefix() { + if (state == DELEGATED_STATE) { + return childReader.getPrefix(); + } else if (state == TEXT_STATE) { + return null; + } else { + return elementQName.getPrefix(); + } + } + + public String getVersion() { + return null; + } + + public boolean isStandalone() { + return true; + } + + public boolean standaloneSet() { + return true; + } + + public String getCharacterEncodingScheme() { + return null; // todo - should we return something for this ? + } + + public String getPITarget() { + throw new UnsupportedOperationException("Yet to be implemented !!"); + } + + public String getPIData() { + throw new UnsupportedOperationException("Yet to be implemented !!"); + } + + // ///////////////////////////////////////////////////////////////////////// + // / Other utility methods + // //////////////////////////////////////////////////////////////////////// + + /** + * Populates a namespace context + */ + private void populateNamespaceContext() { + + // first add the current element namespace to the namespace context + // declare it if not found + registerNamespace(elementQName.getPrefix(), elementQName.getNamespaceURI()); + + // traverse through the attributes and populate the namespace context + // the attrib list can be of many combinations + // the valid combinations are + // String - String + // QName - QName + // null - OMAttribute + + if (attributes != null) { + for (int i = 0; i < attributes.length; i++) { // jump in two + Object attribName = attributes[i].getKey(); + if (attribName instanceof String) { + // ignore this case - Nothing to do + } else if (attribName instanceof QName) { + QName attribQName = ((QName) attribName); + registerNamespace(attribQName.getPrefix(), attribQName.getNamespaceURI()); + + } + } + } + + } + + /** + * @param prefix + * @param uri + */ + private void registerNamespace(String prefix, String uri) { + if (!uri.equals(namespaceContext.getNamespaceURI(prefix))) { + namespaceContext.registerMapping(prefix, uri); + declaredNamespaceMap.put(prefix, uri); + } + } + + /** + * By far this should be the most important method in this class this method changes the state of the parser according to the change in the + */ + private int updateStatus() throws XMLStreamException { + int returnEvent = -1; // invalid state is the default state + switch (state) { + case START_ELEMENT_STATE: + // current element is start element. We should be looking at the + // property list and making a pullparser for the property value + if (properties == null || properties.length == 0) { + // no properties - move to the end element state straightaway + state = END_ELEMENT_STATE; + returnEvent = END_ELEMENT; + } else { + // there are properties. now we should delegate this task to a + // child reader depending on the property type + returnEvent = processProperties(); + + } + break; + case END_ELEMENT_STATE: + // we've reached the end element already. If the user tries to push + // further ahead then it is an exception + throw new XMLStreamException("Trying to go beyond the end of the pullparser"); + + case DELEGATED_STATE: + if (childReader.isEndOfFragment()) { + // we've reached the end! + if (currentPropertyIndex > (properties.length - 1)) { + state = END_ELEMENT_STATE; + returnEvent = END_ELEMENT; + } else { + returnEvent = processProperties(); + } + } else { + returnEvent = childReader.next(); + } + break; + + case TEXT_STATE: + // if there are any more event we should be delegating to + // processProperties. if not we just return an end element + if (currentPropertyIndex > (properties.length - 1)) { + state = END_ELEMENT_STATE; + returnEvent = END_ELEMENT; + } else { + returnEvent = processProperties(); + } + break; + } + return returnEvent; + } + + /** + * A convenient method to reuse the properties + * + * @return event to be thrown + * @throws XMLStreamException + */ + private int processProperties() throws XMLStreamException { + // move to the next property depending on the current property + // index + Object propPointer = properties[currentPropertyIndex].getKey(); + QName propertyQName = null; + boolean textFound = false; + if (propPointer == null) { + throw new XMLStreamException("property key cannot be null!"); + } else if (propPointer instanceof String) { + // propPointer being a String has a special case + // that is it can be a the special constant ELEMENT_TEXT that + // says this text event + if (ELEMENT_TEXT.equals(propPointer)) { + textFound = true; + } else { + propertyQName = new QName((String) propPointer); + } + } else if (propPointer instanceof QName) { + propertyQName = (QName) propPointer; + } else { + // oops - we've no idea what kind of key this is + throw new XMLStreamException("unidentified property key!!!" + propPointer); + } + + // ok! we got the key. Now look at the value + Object propertyValue = properties[currentPropertyIndex].getValue(); + // cater for the special case now + if (textFound) { + // no delegation here - make the parser null and immediately + // return with the event characters + childReader = null; + state = TEXT_STATE; + currentPropertyIndex++; + return CHARACTERS; + } else if (propertyValue == null || propertyValue instanceof String) { + // strings are handled by the NameValuePairStreamReader + childReader = new SimpleElementStreamReader(propertyQName, (String) propertyValue); + childReader.setParentNamespaceContext(this.namespaceContext); + childReader.init(); + } else if (propertyValue instanceof DataObjectXMLStreamReader) { + // ADBbean has it's own method to get a reader + XMLFragmentStreamReader reader = (DataObjectXMLStreamReader) propertyValue; + // we know for sure that this is an ADB XMLStreamreader. + // However we need to make sure that it is compatible + childReader = reader; + childReader.setParentNamespaceContext(this.namespaceContext); + childReader.init(); + } else { + // all special possiblilities has been tried! Let's treat + // the thing as a bean and try generating events from it + throw new UnsupportedOperationException("Not supported"); + // childReader = new WrappingXMLStreamReader(BeanUtil.getPullParser(propertyValue, propertyQName)); + // we cannot register the namespace context here + } + + // set the state here + state = DELEGATED_STATE; + // we are done with the delegation + // increment the property index + currentPropertyIndex++; + return childReader.getEventType(); + } + + /** + * are we done ? + * + * @return + */ + public boolean isEndOfFragment() { + return (state == END_ELEMENT_STATE); + } + + protected static class NameValuePair implements Map.Entry { + private Object key; + + private Object value; + + public NameValuePair(Object key, Object value) { + this.key = key; + this.value = value; + } + + public Object getKey() { + return key; + } + + public Object getValue() { + return value; + } + + public Object setValue(Object value) { + Object v = this.value; + this.value = value; + return v; + } + + } + + protected static class SimpleElementStreamReader implements XMLFragmentStreamReader { + + private static final int START_ELEMENT_STATE = 0; + + private static final int TEXT_STATE = 1; + + private static final int END_ELEMENT_STATE = 2; + + private static final int START_ELEMENT_STATE_WITH_NULL = 3; + + private static final QName XSI_NIL_QNAME = new QName("http://www.w3.org/2001/XMLSchema-instance", "nil", "xsi"); + + private DelegatingNamespaceContext namespaceContext = new DelegatingNamespaceContext(null); + + private QName name; + + private String value; + + private int state = START_ELEMENT_STATE; + + public SimpleElementStreamReader(QName name, String value) { + this.name = name; + this.value = value; + if (value == null) + state = START_ELEMENT_STATE_WITH_NULL; + } + + public Object getProperty(String key) throws IllegalArgumentException { + return null; + } + + public int next() throws XMLStreamException { + switch (state) { + case START_ELEMENT_STATE: + state = TEXT_STATE; + return CHARACTERS; + case START_ELEMENT_STATE_WITH_NULL: + state = END_ELEMENT_STATE; + return END_ELEMENT; + case END_ELEMENT_STATE: + // oops, not supposed to happen! + throw new XMLStreamException("end already reached!"); + case TEXT_STATE: + state = END_ELEMENT_STATE; + return END_ELEMENT; + default: + throw new XMLStreamException("unknown event type!"); + } + } + + public void require(int i, String string, String string1) throws XMLStreamException { + // not implemented + } + + public String getElementText() throws XMLStreamException { + if (state == START_ELEMENT) { + // move to the end state and return the value + state = END_ELEMENT_STATE; + return value; + } else { + throw new XMLStreamException(); + } + + } + + public int nextTag() throws XMLStreamException { + return 0;// todo + } + + public boolean hasNext() throws XMLStreamException { + return (state != END_ELEMENT_STATE); + } + + public void close() throws XMLStreamException { + // Do nothing - we've nothing to free here + } + + public String getNamespaceURI(String prefix) { + return namespaceContext.getNamespaceURI(prefix); + } + + public boolean isStartElement() { + return (state == START_ELEMENT_STATE || state == START_ELEMENT_STATE_WITH_NULL); + } + + public boolean isEndElement() { + return (state == END_ELEMENT_STATE); + } + + public boolean isCharacters() { + return (state == TEXT_STATE); + } + + public boolean isWhiteSpace() { + return false; // no whitespaces here + } + + public boolean isAttributeSpecified(int i) { + return false; // no attribs here + } + + public NamespaceContext getNamespaceContext() { + return this.namespaceContext; + } + + public int getEventType() { + switch (state) { + case START_ELEMENT_STATE: + case START_ELEMENT_STATE_WITH_NULL: + return START_ELEMENT; + case END_ELEMENT_STATE: + return END_ELEMENT; + case TEXT_STATE: + return CHARACTERS; + default: + throw new UnsupportedOperationException(); + // we've no idea what this is!!!!! + } + + } + + public String getText() { + if (state == TEXT_STATE) { + return value; + } else { + throw new IllegalStateException(); + } + } + + public char[] getTextCharacters() { + if (state == TEXT_STATE) { + return value.toCharArray(); + } else { + throw new IllegalStateException(); + } + } + + public int getTextCharacters(int i, char[] chars, int i1, int i2) throws XMLStreamException { + // not implemented + throw new UnsupportedOperationException(); + } + + public int getTextStart() { + if (state == TEXT_STATE) { + return 0; + } else { + throw new IllegalStateException(); + } + } + + public int getTextLength() { + if (state == TEXT_STATE) { + return value.length(); + } else { + throw new IllegalStateException(); + } + + } + + public String getEncoding() { + return "UTF-8"; + } + + public boolean hasText() { + return (state == TEXT_STATE); + } + + public Location getLocation() { + return new Location() { + public int getLineNumber() { + return 0; + } + + public int getColumnNumber() { + return 0; + } + + public int getCharacterOffset() { + return 0; + } + + public String getPublicId() { + return null; + } + + public String getSystemId() { + return null; + } + }; + } + + public QName getName() { + if (state != TEXT_STATE) { + return name; + } else { + return null; + } + } + + public String getLocalName() { + if (state != TEXT_STATE) { + return name.getLocalPart(); + } else { + return null; + } + } + + public boolean hasName() { + return (state != TEXT_STATE); + + } + + public String getNamespaceURI() { + if (state != TEXT_STATE) { + return name.getNamespaceURI(); + } else { + return null; + } + + } + + public String getPrefix() { + if (state != TEXT_STATE) { + return name.getPrefix(); + } else { + return null; + } + } + + public String getVersion() { + return null; // todo 1.0 ? + } + + public boolean isStandalone() { + return false; + } + + public boolean standaloneSet() { + return false; + } + + public String getCharacterEncodingScheme() { + return null; + } + + public String getPITarget() { + return null; + } + + public String getPIData() { + return null; + } + + public boolean isEndOfFragment() { + return (state == END_ELEMENT_STATE); + } + + public void setParentNamespaceContext(NamespaceContext nsContext) { + this.namespaceContext.setParent(nsContext); + } + + public void init() { + // just add the current elements namespace and prefix to the this + // elements nscontext + registerNamespace(name.getPrefix(), name.getNamespaceURI()); + + } + + /** + * @param prefix + * @param uri + */ + private void registerNamespace(String prefix, String uri) { + // todo - need to fix this up to cater for cases where + // namespaces are having no prefixes + if (!uri.equals(namespaceContext.getNamespaceURI(prefix))) { + // this namespace is not there. Need to declare it + namespaceContext.registerMapping(prefix, uri); + } + } + + public int getAttributeCount() { + if (state == START_ELEMENT_STATE_WITH_NULL) + return 1; + if (state == START_ELEMENT_STATE) { + return 0; + } else { + throw new IllegalStateException(); + } + + } + + public String getAttributeLocalName(int i) { + if (state == START_ELEMENT_STATE_WITH_NULL && i == 0) + return XSI_NIL_QNAME.getLocalPart(); + if (state == START_ELEMENT_STATE) { + return null; + } else { + throw new IllegalStateException(); + } + } + + public QName getAttributeName(int i) { + if (state == START_ELEMENT_STATE_WITH_NULL && i == 0) + return XSI_NIL_QNAME; + if (state == START_ELEMENT_STATE) { + return null; + } else { + throw new IllegalStateException(); + } + } + + public String getAttributeNamespace(int i) { + if (state == START_ELEMENT_STATE_WITH_NULL && i == 0) + return XSI_NIL_QNAME.getNamespaceURI(); + if (state == START_ELEMENT_STATE) { + return null; + } else { + throw new IllegalStateException(); + } + } + + public String getAttributePrefix(int i) { + if (state == START_ELEMENT_STATE_WITH_NULL && i == 0) + return XSI_NIL_QNAME.getPrefix(); + if (state == START_ELEMENT_STATE) { + return null; + } else { + throw new IllegalStateException(); + } + } + + public String getAttributeType(int i) { + return null; // not implemented + } + + public String getAttributeValue(int i) { + if (state == START_ELEMENT_STATE_WITH_NULL && i == 0) + return "true"; + if (state == START_ELEMENT_STATE) { + return null; + } else { + throw new IllegalStateException(); + } + } + + public String getAttributeValue(String string, String string1) { + if (state == TEXT_STATE) { + // todo something + return null; + } else { + return null; + } + + } + + public int getNamespaceCount() { + if (state == START_ELEMENT_STATE_WITH_NULL && isXsiNamespacePresent()) + return 1; + else + return 0; + + } + + public String getNamespacePrefix(int i) { + if (state == START_ELEMENT_STATE_WITH_NULL && isXsiNamespacePresent() && i == 0) + return XSI_NIL_QNAME.getPrefix(); + else + return null; + } + + public String getNamespaceURI(int i) { + if (state == START_ELEMENT_STATE_WITH_NULL && isXsiNamespacePresent() && i == 0) + return XSI_NIL_QNAME.getNamespaceURI(); + else + return null; + } + + /** + * Test whether the xsi namespace is present + * + * @return + */ + private boolean isXsiNamespacePresent() { + return (namespaceContext.getNamespaceURI(XSI_NIL_QNAME.getPrefix()) != null); + } + + } + + protected static class DelegatingNamespaceContext implements NamespaceContext { + private NamespaceContext parent; + + private Map prefixToNamespaceMapping = new HashMap(); + + public DelegatingNamespaceContext(NamespaceContext parent) { + super(); + this.parent = parent; + + prefixToNamespaceMapping.put("xml", "http://www.w3.org/XML/1998/namespace"); + prefixToNamespaceMapping.put("xmlns", "http://www.w3.org/2000/xmlns/"); + prefixToNamespaceMapping.put("xsi", "http://www.w3.org/2001/XMLSchema-instance"); + } + + public String getNamespaceURI(String prefix) { + if (prefix == null) + throw new IllegalArgumentException("Prefix is null"); + + String ns = (String) prefixToNamespaceMapping.get(prefix); + if (ns != null) + return ns; + else if (parent != null) + return parent.getNamespaceURI(prefix); + else + return null; + } + + public String getPrefix(String nsURI) { + if (nsURI == null) + throw new IllegalArgumentException("Namespace is null"); + for (Iterator i = prefixToNamespaceMapping.entrySet().iterator(); i.hasNext();) { + Map.Entry entry = (Map.Entry) i.next(); + if (entry.getValue().equals(nsURI)) { + return (String) entry.getKey(); + } + } + if (parent != null) + return parent.getPrefix(nsURI); + else + return null; + } + + public Iterator getPrefixes(String nsURI) { + List prefixList = new ArrayList(); + for (Iterator i = prefixToNamespaceMapping.entrySet().iterator(); i.hasNext();) { + Map.Entry entry = (Map.Entry) i.next(); + if (entry.getValue().equals(nsURI)) { + prefixList.add(entry.getKey()); + } + } + if (parent != null) { + for (Iterator i = parent.getPrefixes(nsURI); i.hasNext();) { + prefixList.add(i.next()); + } + } + return prefixList.iterator(); + } + + public void registerMapping(String prefix, String nsURI) { + prefixToNamespaceMapping.put(prefix, nsURI); + } + + private int counter = 0; + + public synchronized QName createQName(String nsURI, String name) { + String prefix = nsURI != null ? (String) getPrefix(nsURI) : null; + if (prefix == null && nsURI != null && !nsURI.equals("")) + prefix = "p" + (counter++); + if (prefix == null) + prefix = ""; + if (nsURI != null) + prefixToNamespaceMapping.put(prefix, nsURI); + return new QName(nsURI, name, prefix); + } + + public void removeMapping(String prefix) { + prefixToNamespaceMapping.remove(prefix); + } + + public void setParent(NamespaceContext parent) { + this.parent = parent; + } + } + +} diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDOXMLResourceFactoryImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDOXMLResourceFactoryImpl.java new file mode 100644 index 0000000000..c8189f9766 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDOXMLResourceFactoryImpl.java @@ -0,0 +1,47 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.util.resource; + + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl; + +/** + * This class creates SDOXMLResourceImpl objects. + */ +public class SDOXMLResourceFactoryImpl extends ResourceFactoryImpl +{ + /** + * Constructor for SDOXMLResourceFactoryImpl. + */ + public SDOXMLResourceFactoryImpl() + { + super(); + } + + /** + * Creates an XMLResourceImpl and returns it. + */ + public Resource createResource(URI uri) + { + return new SDOXMLResourceImpl(uri); + } +} diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDOXMLResourceImpl.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDOXMLResourceImpl.java new file mode 100644 index 0000000000..d08264a702 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDOXMLResourceImpl.java @@ -0,0 +1,184 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.util.resource; + +import java.io.IOException; +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import org.apache.tuscany.sdo.util.StAX2SAXAdapter; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.xmi.XMIException; +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.impl.XMLHelperImpl; +import org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl; +import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; +import org.xml.sax.ContentHandler; +import org.xml.sax.SAXException; + +public class SDOXMLResourceImpl extends XMLResourceImpl { + private XMLStreamReader reader; + + /** + * [rfeng] Override the XMLHelperImpl to replace the NamespaceSupport so that it's aware of the NamespaceContext from the XMLStreamReader + */ + public static class SDOXMLHelperImpl extends XMLHelperImpl { + + private static class StreamNamespaceSupport extends XMLHelperImpl.NamespaceSupport { + private XMLStreamReader reader; + + public String getPrefix(String uri) { + if (reader == null) + return super.getPrefix(uri); + String prefix = null; + try { + prefix = uri != null ? reader.getNamespaceContext().getPrefix(uri) : null; + } catch (Exception e) { + // HACK: + // java.lang.UnsupportedOperationException + // at org.apache.axiom.om.impl.llom.OMStAXWrapper.getNamespaceContext(OMStAXWrapper.java:984) + + prefix = null; + } + return prefix != null ? prefix : super.getPrefix(uri); + } + + public String getURI(String prefix) { + if (reader == null) + return super.getURI(prefix); + String uri; + try { + uri = prefix != null ? reader.getNamespaceContext().getNamespaceURI(prefix) : null; + } catch (Exception e) { + // HACK: + // java.lang.UnsupportedOperationException + // at org.apache.axiom.om.impl.llom.OMStAXWrapper.getNamespaceContext(OMStAXWrapper.java:984) + + uri = null; + } + return uri != null && uri.length()!=0 ? uri : super.getURI(prefix); + } + + public StreamNamespaceSupport(XMLStreamReader reader) { + super(); + this.reader = reader; + } + + } + + public SDOXMLHelperImpl(XMLResource resource, XMLStreamReader reader) { + this(reader); + setResource(resource); + } + + public SDOXMLHelperImpl(XMLStreamReader reader) { + super(); + this.namespaceSupport = new StreamNamespaceSupport(reader); + } + } + + /** + * An EMF XMLLoad that loads a model from a StAX stream + */ + public class SDOXMLLoadImpl extends XMLLoadImpl { + public SDOXMLLoadImpl(XMLHelper helper) { + super(helper); + } + + /** + * Start parsing an XMLReader with the default handler. + */ + public void load(XMLResource resource, final XMLStreamReader reader, Map options) throws IOException { + this.resource = resource; + Map mergedOptions = new HashMap(defaultLoadOptions); + if (options != null) + mergedOptions.putAll(options); + + this.options = mergedOptions; + + final ContentHandler handler = makeDefaultHandler(); + + if (errors != null) { + errors.clear(); + } + + final StAX2SAXAdapter adapter = new StAX2SAXAdapter(true); + // Parse the XMLReader and generate SAX events + try { + AccessController.doPrivileged(new PrivilegedExceptionAction() { + public Object run() throws XMLStreamException, SAXException { + adapter.parse(reader, handler); + return null; + } + }); + } catch (PrivilegedActionException e) { + throw new Resource.IOWrappedException(e.getException()); + } + + helper = null; + if (!resource.getErrors().isEmpty()) { + Exception error = (Exception) resource.getErrors().get(0); + if (error instanceof XMIException) { + XMIException exception = (XMIException) error; + if (exception.getWrappedException() != null) { + throw new Resource.IOWrappedException(exception.getWrappedException()); + } + } + throw new Resource.IOWrappedException(error); + } + } + } + + public SDOXMLResourceImpl(URI uri) { + super(uri); + } + + protected XMLHelper createXMLHelper() { + return new SDOXMLHelperImpl(this, reader); + } + + /** + * @see org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#createXMLLoad() + */ + protected XMLLoad createXMLLoad() { + return new SDOXMLLoadImpl(createXMLHelper()); + } + + /** + * Loads the resource from a StAX XMLStreamReader. + */ + public void load(XMLStreamReader reader, Map options) throws IOException { + this.reader = reader; + SDOXMLLoadImpl xmlLoad = (SDOXMLLoadImpl) createXMLLoad(); + Map mergedOptions = new HashMap(defaultLoadOptions); + if (options != null) + mergedOptions.putAll(options); + xmlLoad.load(this, reader, mergedOptions); + } +} diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/XMLDocumentStreamReader.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/XMLDocumentStreamReader.java new file mode 100644 index 0000000000..21a1f849d9 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/XMLDocumentStreamReader.java @@ -0,0 +1,442 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.util.resource; + +import java.util.NoSuchElementException; + +import javax.xml.namespace.NamespaceContext; +import javax.xml.namespace.QName; +import javax.xml.stream.Location; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +/** + * This class is derived from Apache Axis2 class <a + * href="http://svn.apache.org/repos/asf/webservices/axis2/trunk/java/modules/core/src/org/apache/axis2/util/StreamWrapper.java"> + * org.apache.axis2.util.StreamWrapper</a>. It's used wrap a XMLStreamReader to create a XMLStreamReader representing a document and it will produce + * START_DOCUMENT, END_DOCUMENT events. + * + */ +public class XMLDocumentStreamReader implements XMLStreamReader { + private static final int STATE_INIT = 0; // The wrapper will produce START_DOCUMENT + + private static final int STATE_SWITCHED = 1; // The real reader will produce events + + private static final int STATE_COMPLETE_AT_NEXT = 2; // The wrapper will produce END_DOCUMENT + + private static final int STATE_COMPLETED = 3; // Done + + private XMLStreamReader realReader = null; + + private int state = STATE_INIT; + + public XMLDocumentStreamReader(XMLStreamReader realReader) { + if (realReader == null) { + throw new UnsupportedOperationException("Reader cannot be null"); + } + + this.realReader = realReader; + + // If the real reader is positioned at START_DOCUMENT, always use the real reader + if (realReader.getEventType() == START_DOCUMENT) + state = STATE_SWITCHED; + } + + public void close() throws XMLStreamException { + realReader.close(); + } + + public int next() throws XMLStreamException { + int returnEvent = -1; + + switch (state) { + case STATE_SWITCHED: + returnEvent = realReader.next(); + if (returnEvent == END_DOCUMENT) { + state = STATE_COMPLETED; + } else if (!realReader.hasNext()) { + state = STATE_COMPLETE_AT_NEXT; + } + break; + case STATE_INIT: + state = STATE_SWITCHED; + returnEvent = realReader.getEventType(); + break; + case STATE_COMPLETE_AT_NEXT: + state = STATE_COMPLETED; + returnEvent = END_DOCUMENT; + break; + case STATE_COMPLETED: + // oops - no way we can go beyond this + throw new NoSuchElementException("End of stream has reached."); + default: + throw new UnsupportedOperationException(); + } + + return returnEvent; + } + + private boolean isDelegating() { + return state == STATE_SWITCHED || state == STATE_COMPLETE_AT_NEXT; + } + + public int nextTag() throws XMLStreamException { + if (isDelegating()) { + return realReader.nextTag(); + } else { + throw new XMLStreamException(); + } + } + + public void require(int i, String s, String s1) throws XMLStreamException { + if (isDelegating()) { + realReader.require(i, s, s1); + } + } + + public boolean standaloneSet() { + if (isDelegating()) { + return realReader.standaloneSet(); + } else { + return false; + } + } + + public int getAttributeCount() { + if (isDelegating()) { + return realReader.getAttributeCount(); + } else { + throw new IllegalStateException(); + } + } + + public String getAttributeLocalName(int i) { + if (isDelegating()) { + return realReader.getAttributeLocalName(i); + } else { + throw new IllegalStateException(); + } + } + + public QName getAttributeName(int i) { + if (isDelegating()) { + return realReader.getAttributeName(i); + } else { + throw new IllegalStateException(); + } + } + + public String getAttributeNamespace(int i) { + if (isDelegating()) { + return realReader.getAttributeNamespace(i); + } else { + throw new IllegalStateException(); + } + } + + public String getAttributePrefix(int i) { + if (isDelegating()) { + return realReader.getAttributePrefix(i); + } else { + throw new IllegalStateException(); + } + } + + public String getAttributeType(int i) { + if (isDelegating()) { + return realReader.getAttributeType(i); + } else { + throw new IllegalStateException(); + } + } + + public String getAttributeValue(int i) { + if (isDelegating()) { + return realReader.getAttributeValue(i); + } else { + throw new IllegalStateException(); + } + } + + public String getAttributeValue(String s, String s1) { + if (isDelegating()) { + return realReader.getAttributeValue(s, s1); + } else { + throw new IllegalStateException(); + } + } + + public String getCharacterEncodingScheme() { + return realReader.getCharacterEncodingScheme(); + } + + public String getElementText() throws XMLStreamException { + if (isDelegating()) { + return realReader.getElementText(); + } else { + throw new XMLStreamException(); + } + } + + public String getEncoding() { + return realReader.getEncoding(); + } + + public int getEventType() { + int event = -1; + switch (state) { + case STATE_SWITCHED: + case STATE_COMPLETE_AT_NEXT: + event = realReader.getEventType(); + break; + case STATE_INIT: + event = START_DOCUMENT; + break; + case STATE_COMPLETED: + event = END_DOCUMENT; + break; + } + return event; + } + + public Location getLocation() { + if (isDelegating()) { + return realReader.getLocation(); + } else { + return null; + } + } + + public QName getName() { + if (isDelegating()) { + return realReader.getName(); + } else { + throw new IllegalStateException(); + } + } + + public String getLocalName() { + if (isDelegating()) { + return realReader.getLocalName(); + } else { + throw new IllegalStateException(); + } + } + + public NamespaceContext getNamespaceContext() { + return realReader.getNamespaceContext(); + } + + public int getNamespaceCount() { + if (isDelegating()) { + return realReader.getNamespaceCount(); + } else { + throw new IllegalStateException(); + } + } + + public String getNamespacePrefix(int i) { + if (isDelegating()) { + return realReader.getNamespacePrefix(i); + } else { + throw new IllegalStateException(); + } + } + + public String getNamespaceURI() { + if (isDelegating()) { + return realReader.getNamespaceURI(); + } else { + throw new IllegalStateException(); + } + } + + public String getNamespaceURI(int i) { + if (isDelegating()) { + return realReader.getNamespaceURI(i); + } else { + throw new IllegalStateException(); + } + } + + public String getNamespaceURI(String s) { + if (isDelegating()) { + return realReader.getNamespaceURI(s); + } else { + throw new IllegalStateException(); + } + } + + public String getPIData() { + if (isDelegating()) { + return realReader.getPIData(); + } else { + throw new IllegalStateException(); + } + } + + public String getPITarget() { + if (isDelegating()) { + return realReader.getPITarget(); + } else { + throw new IllegalStateException(); + } + } + + public String getPrefix() { + if (isDelegating()) { + return realReader.getPrefix(); + } else { + throw new IllegalStateException(); + } + } + + public Object getProperty(String s) throws IllegalArgumentException { + if (isDelegating()) { + return realReader.getProperty(s); + } else { + throw new IllegalArgumentException(); + } + } + + public String getText() { + if (isDelegating()) { + return realReader.getText(); + } else { + throw new IllegalStateException(); + } + } + + public char[] getTextCharacters() { + if (isDelegating()) { + return realReader.getTextCharacters(); + } else { + throw new IllegalStateException(); + } + } + + public int getTextCharacters(int i, char[] chars, int i1, int i2) throws XMLStreamException { + if (isDelegating()) { + return realReader.getTextCharacters(i, chars, i1, i2); + } else { + throw new IllegalStateException(); + } + } + + public int getTextLength() { + if (isDelegating()) { + return realReader.getTextLength(); + } else { + throw new IllegalStateException(); + } + } + + public int getTextStart() { + if (isDelegating()) { + return realReader.getTextStart(); + } else { + throw new IllegalStateException(); + } + } + + public String getVersion() { + if (isDelegating()) { + return realReader.getVersion(); + } else { + return null; + } + } + + public boolean hasName() { + if (isDelegating()) { + return realReader.hasName(); + } else { + return false; + } + } + + public boolean hasNext() throws XMLStreamException { + if (state == STATE_COMPLETE_AT_NEXT) { + return true; + } else if (state == STATE_COMPLETED) { + return false; + } else if (state == STATE_SWITCHED) { + return realReader.hasNext(); + } else { + return true; + } + } + + public boolean hasText() { + if (isDelegating()) { + return realReader.hasText(); + } else { + return false; + } + } + + public boolean isAttributeSpecified(int i) { + if (isDelegating()) { + return realReader.isAttributeSpecified(i); + } else { + return false; + } + } + + public boolean isCharacters() { + if (isDelegating()) { + return realReader.isCharacters(); + } else { + return false; + } + } + + public boolean isEndElement() { + if (isDelegating()) { + return realReader.isEndElement(); + } else { + return false; + } + } + + public boolean isStandalone() { + if (isDelegating()) { + return realReader.isStandalone(); + } else { + return false; + } + } + + public boolean isStartElement() { + if (isDelegating()) { + return realReader.isStartElement(); + } else { + return false; + } + } + + public boolean isWhiteSpace() { + if (isDelegating()) { + return realReader.isWhiteSpace(); + } else { + return false; + } + } +}
\ No newline at end of file diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/XMLFragmentStreamReader.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/XMLFragmentStreamReader.java new file mode 100644 index 0000000000..68d5e201a3 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/XMLFragmentStreamReader.java @@ -0,0 +1,50 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.util.resource; + +import javax.xml.namespace.NamespaceContext; +import javax.xml.stream.XMLStreamReader; + +interface XMLFragmentStreamReader extends XMLStreamReader { + + // this will help to handle Text within the current element. + // user should pass the element text to the property list as this + // ELEMENT_TEXT as the key. This key deliberately has a space in it + // so that it is not a valid XML name + static final String ELEMENT_TEXT = "Element Text"; + + /** + * Extra method to query the state of the pullparser + * @return + */ + boolean isEndOfFragment(); + + /** + * add the parent namespace context to this parser + */ + void setParentNamespaceContext(NamespaceContext nsContext); + + /** + * Initiate the parser - this will do whatever the needed + * tasks to initiate the parser and must be called before + * attempting any specific parsing using this parser + */ + void init(); +} diff --git a/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/XMLStreamSerializer.java b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/XMLStreamSerializer.java new file mode 100644 index 0000000000..a0242905f6 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/XMLStreamSerializer.java @@ -0,0 +1,272 @@ +/* + * Copyright 2004,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.util.resource; + +import javax.xml.namespace.NamespaceContext; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +/** + * The XMLStreamSerializer pulls events from the XMLStreamReader and dumps into the XMLStreamWriter + */ +public class XMLStreamSerializer implements XMLStreamConstants { + + private static int namespaceSuffix = 0; + + public static final String NAMESPACE_PREFIX = "ns"; + + /* + * The behavior of the serializer is such that it returns when it encounters the starting element for the second time. The depth variable tracks + * the depth of the serilizer and tells it when to return. Note that it is assumed that this serialization starts on an Element. + */ + + /** + * Field depth + */ + private int depth = 0; + + /** + * Method serialize. + * + * @param node + * @param writer + * @throws XMLStreamException + */ + public void serialize(XMLStreamReader node, XMLStreamWriter writer) throws XMLStreamException { + serializeNode(node, writer); + } + + /** + * Method serializeNode. + * + * @param reader + * @param writer + * @throws XMLStreamException + */ + protected void serializeNode(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException { + // TODO We get the StAXWriter at this point and uses it hereafter assuming that this is the only entry point to this class. + // If there can be other classes calling methodes of this we might need to change methode signatures to OMOutputer + while (reader.hasNext()) { + int event = reader.next(); + if (event == START_ELEMENT) { + serializeElement(reader, writer); + depth++; + } else if (event == ATTRIBUTE) { + serializeAttributes(reader, writer); + } else if (event == CHARACTERS) { + serializeText(reader, writer); + } else if (event == COMMENT) { + serializeComment(reader, writer); + } else if (event == CDATA) { + serializeCData(reader, writer); + } else if (event == END_ELEMENT) { + serializeEndElement(writer); + depth--; + } else if (event == START_DOCUMENT) { + depth++; // if a start document is found then increment the depth + } else if (event == END_DOCUMENT) { + if (depth != 0) + depth--; // for the end document - reduce the depth + try { + serializeEndElement(writer); + } catch (Exception e) { + // TODO: log exceptions + } + } + if (depth == 0) { + break; + } + } + } + + /** + * @param reader + * @param writer + * @throws XMLStreamException + */ + protected void serializeElement(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException { + String prefix = reader.getPrefix(); + String nameSpaceName = reader.getNamespaceURI(); + if (nameSpaceName != null) { + String writer_prefix = writer.getPrefix(nameSpaceName); + if (writer_prefix != null) { + writer.writeStartElement(nameSpaceName, reader.getLocalName()); + } else { + if (prefix != null) { + writer.writeStartElement(prefix, reader.getLocalName(), nameSpaceName); + writer.writeNamespace(prefix, nameSpaceName); + writer.setPrefix(prefix, nameSpaceName); + } else { + writer.writeStartElement(nameSpaceName, reader.getLocalName()); + writer.writeDefaultNamespace(nameSpaceName); + writer.setDefaultNamespace(nameSpaceName); + } + } + } else { + writer.writeStartElement(reader.getLocalName()); + } + + // add the namespaces + int count = reader.getNamespaceCount(); + String namespacePrefix; + for (int i = 0; i < count; i++) { + namespacePrefix = reader.getNamespacePrefix(i); + if (namespacePrefix != null && namespacePrefix.length() == 0) + continue; + + serializeNamespace(namespacePrefix, reader.getNamespaceURI(i), writer); + } + + // add attributes + serializeAttributes(reader, writer); + + } + + /** + * Method serializeEndElement. + * + * @param writer + * @throws XMLStreamException + */ + protected void serializeEndElement(XMLStreamWriter writer) throws XMLStreamException { + writer.writeEndElement(); + } + + /** + * @param reader + * @param writer + * @throws XMLStreamException + */ + protected void serializeText(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException { + writer.writeCharacters(reader.getText()); + } + + /** + * Method serializeCData. + * + * @param reader + * @param writer + * @throws XMLStreamException + */ + protected void serializeCData(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException { + writer.writeCData(reader.getText()); + } + + /** + * Method serializeComment. + * + * @param reader + * @param writer + * @throws XMLStreamException + */ + protected void serializeComment(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException { + writer.writeComment(reader.getText()); + } + + /** + * @param reader + * @param writer + * @throws XMLStreamException + */ + protected void serializeAttributes(XMLStreamReader reader, XMLStreamWriter writer) + throws XMLStreamException { + int count = reader.getAttributeCount(); + String prefix = null; + String namespaceName = null; + String writerPrefix = null; + for (int i = 0; i < count; i++) { + prefix = reader.getAttributePrefix(i); + namespaceName = reader.getAttributeNamespace(i); + if (namespaceName != null) { + writerPrefix = writer.getNamespaceContext().getPrefix(namespaceName); + } + + if (!"".equals(namespaceName)) { + // prefix has already being declared but this particular attrib + // has a + // no prefix attached. So use the prefix provided by the writer + if (writerPrefix != null && (prefix == null || prefix.equals(""))) { + writer.writeAttribute(writerPrefix, + namespaceName, + reader.getAttributeLocalName(i), + reader.getAttributeValue(i)); + + // writer prefix is available but different from the current + // prefix of the attrib. We should be decalring the new + // prefix + // as a namespace declaration + } else if (prefix != null && !"".equals(prefix) && !prefix.equals(writerPrefix)) { + writer.writeNamespace(prefix, namespaceName); + writer.writeAttribute(prefix, namespaceName, reader.getAttributeLocalName(i), reader + .getAttributeValue(i)); + + // prefix is null (or empty), but the namespace name is + // valid! it has not + // being written previously also. So we need to generate a + // prefix + // here + } else if (prefix == null || prefix.equals("")) { + prefix = generateUniquePrefix(writer.getNamespaceContext()); + writer.writeNamespace(prefix, namespaceName); + writer.writeAttribute(prefix, namespaceName, reader.getAttributeLocalName(i), reader + .getAttributeValue(i)); + } else { + writer.writeAttribute(prefix, namespaceName, reader.getAttributeLocalName(i), reader + .getAttributeValue(i)); + } + } else { + // empty namespace is equal to no namespace! + writer.writeAttribute(reader.getAttributeLocalName(i), reader.getAttributeValue(i)); + } + + } + } + + /** + * Generates a unique namespace prefix that is not in the scope of the NamespaceContext + * + * @param nsCtxt + * @return string + */ + private String generateUniquePrefix(NamespaceContext nsCtxt) { + String prefix = NAMESPACE_PREFIX + namespaceSuffix++; + // null should be returned if the prefix is not bound! + while (nsCtxt.getNamespaceURI(prefix) != null) { + prefix = NAMESPACE_PREFIX + namespaceSuffix++; + } + + return prefix; + } + + /** + * Method serializeNamespace. + * + * @param prefix + * @param URI + * @param writer + * @throws XMLStreamException + */ + private void serializeNamespace(String prefix, String URI, XMLStreamWriter writer) throws XMLStreamException { + String prefix1 = writer.getPrefix(URI); + if (prefix1 == null) { + writer.writeNamespace(prefix, URI); + writer.setPrefix(prefix, URI); + } + } +} diff --git a/sandbox/jboynes/sdo/impl/src/main/resources/META-INF/LICENSE.txt b/sandbox/jboynes/sdo/impl/src/main/resources/META-INF/LICENSE.txt new file mode 100644 index 0000000000..30e4ab9e24 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/resources/META-INF/LICENSE.txt @@ -0,0 +1,446 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. + + +APACHE TUSCANY SUBCOMPONENTS: + +The Apache Tuscany distribution includes a number of subcomponents with +separate copyright notices and license terms. Your use of the source +code for the these subcomponents is subject to the terms and +conditions of the following licenses. + +=============================================================================== + +For the Eclipse Modeling Framework component: + +Eclipse Public License - v 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE +PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF +THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and +documentation distributed under this Agreement, and +b) in the case of each subsequent Contributor: + +i) changes to the Program, and + +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and +are distributed by that particular Contributor. A Contribution +'originates' from a Contributor if it was added to the Program by such +Contributor itself or anyone acting on such Contributor's behalf. +Contributions do not include additions to the Program which: (i) are +separate modules of software distributed in conjunction with the +Program under their own license agreement, and (ii) are not derivative +works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor +which are necessarily infringed by the use or sale of its Contribution +alone or when combined with the Program. + +"Program" means the Contributions distributed in accordance with this +Agreement. + +"Recipient" means anyone who receives the Program under this +Agreement, including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby +grants Recipient a non-exclusive, worldwide, royalty-free copyright +license to reproduce, prepare derivative works of, publicly display, +publicly perform, distribute and sublicense the Contribution of such +Contributor, if any, and such derivative works, in source code and +object code form. + +b) Subject to the terms of this Agreement, each Contributor hereby +grants Recipient a non-exclusive, worldwide, royalty-free patent +license under Licensed Patents to make, use, sell, offer to sell, +import and otherwise transfer the Contribution of such Contributor, if +any, in source code and object code form. This patent license shall +apply to the combination of the Contribution and the Program if, at +the time the Contribution is added by the Contributor, such addition +of the Contribution causes such combination to be covered by the +Licensed Patents. The patent license shall not apply to any other +combinations which include the Contribution. No hardware per se is +licensed hereunder. + +c) Recipient understands that although each Contributor grants the +licenses to its Contributions set forth herein, no assurances are +provided by any Contributor that the Program does not infringe the +patent or other intellectual property rights of any other entity. Each +Contributor disclaims any liability to Recipient for claims brought by +any other entity based on infringement of intellectual property rights +or otherwise. As a condition to exercising the rights and licenses +granted hereunder, each Recipient hereby assumes sole responsibility +to secure any other intellectual property rights needed, if any. For +example, if a third party patent license is required to allow +Recipient to distribute the Program, it is Recipient's responsibility +to acquire that license before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient +copyright rights in its Contribution, if any, to grant the copyright +license set forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form +under its own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and + +b) its license agreement: + +i) effectively disclaims on behalf of all Contributors all warranties +and conditions, express and implied, including warranties or +conditions of title and non-infringement, and implied warranties or +conditions of merchantability and fitness for a particular purpose; + +ii) effectively excludes on behalf of all Contributors all liability +for damages, including direct, indirect, special, incidental and +consequential damages, such as lost profits; + +iii) states that any provisions which differ from this Agreement are +offered by that Contributor alone and not by any other party; and + +iv) states that source code for the Program is available from such +Contributor, and informs licensees how to obtain it in a reasonable +manner on or through a medium customarily used for software exchange. + +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and + +b) a copy of this Agreement must be included with each copy of the +Program. + +Contributors may not remove or alter any copyright notices contained +within the Program. + +Each Contributor must identify itself as the originator of its +Contribution, if any, in a manner that reasonably allows subsequent +Recipients to identify the originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain +responsibilities with respect to end users, business partners and the +like. While this license is intended to facilitate the commercial use +of the Program, the Contributor who includes the Program in a +commercial product offering should do so in a manner which does not +create potential liability for other Contributors. Therefore, if a +Contributor includes the Program in a commercial product offering, +such Contributor ("Commercial Contributor") hereby agrees to defend +and indemnify every other Contributor ("Indemnified Contributor") +against any losses, damages and costs (collectively "Losses") arising +from claims, lawsuits and other legal actions brought by a third party +against the Indemnified Contributor to the extent caused by the acts +or omissions of such Commercial Contributor in connection with its +distribution of the Program in a commercial product offering. The +obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. +In order to qualify, an Indemnified Contributor must: a) promptly +notify the Commercial Contributor in writing of such claim, and b) +allow the Commercial Contributor to control, and cooperate with the +Commercial Contributor in, the defense and any related settlement +negotiations. The Indemnified Contributor may participate in any such +claim at its own expense. + +For example, a Contributor might include the Program in a commercial +product offering, Product X. That Contributor is then a Commercial +Contributor. If that Commercial Contributor then makes performance +claims, or offers warranties related to Product X, those performance +claims and warranties are such Commercial Contributor's responsibility +alone. Under this section, the Commercial Contributor would have to +defend claims against the other Contributors related to those +performance claims and warranties, and if a court requires any other +Contributor to pay any damages as a result, the Commercial Contributor +must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS +PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY +WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY +OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely +responsible for determining the appropriateness of using and +distributing the Program and assumes all risks associated with its +exercise of rights under this Agreement , including but not limited to +the risks and costs of program errors, compliance with applicable +laws, damage to or loss of data, programs or equipment, and +unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR +ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING +WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR +DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED +HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of +the remainder of the terms of this Agreement, and without further +action by the parties hereto, such provision shall be reformed to the +minimum extent necessary to make such provision valid and enforceable. + +If Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that +the Program itself (excluding combinations of the Program with other +software or hardware) infringes such Recipient's patent(s), then such +Recipient's rights granted under Section 2(b) shall terminate as of +the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it +fails to comply with any of the material terms or conditions of this +Agreement and does not cure such failure in a reasonable period of +time after becoming aware of such noncompliance. If all Recipient's +rights under this Agreement terminate, Recipient agrees to cease use +and distribution of the Program as soon as reasonably practicable. +However, Recipient's obligations under this Agreement and any licenses +granted by Recipient relating to the Program shall continue and +survive. + +Everyone is permitted to copy and distribute copies of this Agreement, +but in order to avoid inconsistency the Agreement is copyrighted and +may only be modified in the following manner. The Agreement Steward +reserves the right to publish new versions (including revisions) of +this Agreement from time to time. No one other than the Agreement +Steward has the right to modify this Agreement. The Eclipse Foundation +is the initial Agreement Steward. The Eclipse Foundation may assign +the responsibility to serve as the Agreement Steward to a suitable +separate entity. Each new version of the Agreement will be given a +distinguishing version number. The Program (including Contributions) +may always be distributed subject to the version of the Agreement +under which it was received. In addition, after a new version of the +Agreement is published, Contributor may elect to distribute the +Program (including its Contributions) under the new version. Except as +expressly stated in Sections 2(a) and 2(b) above, Recipient receives +no rights or licenses to the intellectual property of any Contributor +under this Agreement, whether expressly, by implication, estoppel or +otherwise. All rights in the Program not expressly granted under this +Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and +the intellectual property laws of the United States of America. No +party to this Agreement will bring a legal action under this Agreement +more than one year after the cause of action arose. Each party waives +its rights to a jury trial in any resulting litigation. + +=============================================================================== + + diff --git a/sandbox/jboynes/sdo/impl/src/main/resources/META-INF/MANIFEST.MF b/sandbox/jboynes/sdo/impl/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..6abece6be5 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/resources/META-INF/MANIFEST.MF @@ -0,0 +1,25 @@ +Manifest-Version: 1.0
+Extension-Name: tuscany-sdo-impl
+Specification-Title: Tuscany SDO Implementation
+Specification-Vendor: Apache Software Foundation
+Implementation-Vendor: Apache Software Foundation
+Implementation-Vendor-Id: org.apache
+Implementation-Title: tuscany-sdo-impl
+Implementation-Version: incubating-M1
+Bundle-ManifestVersion: 2
+Bundle-Name: Tuscany SDO Implementation
+Bundle-SymbolicName: org.apache.tuscany.sdo.impl
+Bundle-Version: 1.0.0
+Bundle-Vendor: Apache Software Foundation
+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/sandbox/jboynes/sdo/impl/src/main/resources/META-INF/NOTICE b/sandbox/jboynes/sdo/impl/src/main/resources/META-INF/NOTICE new file mode 100644 index 0000000000..322cf40f9f --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/resources/META-INF/NOTICE @@ -0,0 +1,29 @@ +Apache Tuscany SDO for Java +Copyright 2006 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + +Apache Tuscany is an effort undergoing incubation at The Apache Software Foundation (ASF), +sponsored by the Apache Web Services PMC. Incubation is required of all newly accepted +projects until a further review indicates that the infrastructure, communications, +and decision making process have stabilized in a manner consistent with other successful +ASF projects. While incubation status is not necessarily a reflection of the completeness +or stability of the code, it does indicate that the project has yet to be fully endorsed +by the ASF. + +Unless otherwise indicated, all distribution made available by the Apache Software Foundation +is provided to you under the terms and conditions of the Apache License Version 2.0 ("AL"). +A copy of the AL is provided with this distribution as the LICENSE.txt file present in the +root directory, and is also available at http://www.apache.org/licenses/. + +The terms and conditions governing the distribution may refer to the AL or other license +agreements, notices or terms and conditions. Some of these other license agreements may +include (but are not limited to): + + . Eclipse Public License Version 1.0 (available at http://www.eclipse.org/legal/epl-v10.html) + . Common Public License Version 1.0 (available at http://www.eclipse.org/legal/cpl-v10.html) + +It is your obligation to read and accept all such terms and conditions prior to use of the +distribution. If term or condition is provided, please contact the Apache Software Foundation +to determine what terms and conditions govern that particular distribution. diff --git a/sandbox/jboynes/sdo/impl/src/main/resources/META-INF/README.txt b/sandbox/jboynes/sdo/impl/src/main/resources/META-INF/README.txt new file mode 100644 index 0000000000..9b26d1690a --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/resources/META-INF/README.txt @@ -0,0 +1,35 @@ +Apache Tuscany M1 build (May, 2006) +=================================== + +http://incubator.apache.org/tuscany/ + +Tuscany is an effort undergoing incubation at the Apache Software Foundation +(ASF), sponsored by the Web Services PMC. + +Incubation is required of all newly accepted projects until a further review +indicates that the infrastructure, communications, and decision making process +have stabilized in a manner consistent with other successful ASF projects. + +While incubation status is not necessarily a reflection of the completeness or +stability of the code, it does indicate that the project has yet to be fully +endorsed by the ASF. + + +Support +------- + +Any problem with this release can be reported to the Tuscany mailing list +or in the JIRA issue tracker. + +Mailing list subscription: + tuscany-dev-subscribe@ws.apache.org + +Jira: + http://issues.apache.org/jira/browse/Tuscany + + +Thank you for using Tuscany! + + +The Tuscany Team. + diff --git a/sandbox/jboynes/sdo/impl/src/main/resources/META-INF/services/commonj.sdo.impl.HelperProvider b/sandbox/jboynes/sdo/impl/src/main/resources/META-INF/services/commonj.sdo.impl.HelperProvider new file mode 100644 index 0000000000..73693d6556 --- /dev/null +++ b/sandbox/jboynes/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/sandbox/jboynes/sdo/impl/src/main/resources/sdo-metadata.xsd b/sandbox/jboynes/sdo/impl/src/main/resources/sdo-metadata.xsd new file mode 100644 index 0000000000..6a5132ed56 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/main/resources/sdo-metadata.xsd @@ -0,0 +1,45 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + --> +<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="org.apache.tuscany.sdo/metadata" xmlns:metadata="org.apache.tuscany.sdo/metadata"> + + <element name="sdoMetaDataGroup" type="metadata:SDOMetaDataGroup"/> + + <complexType name="SDOMetaDataGroup"> + <sequence> + <element name="javaMetaData" type="metadata:JavaMetaData" maxOccurs="unbounded" minOccurs="0"/> + <element name="xsdMetaData" type="metadata:XSDMetaData" maxOccurs="unbounded" minOccurs="0"/> + <element name="typeMetaData" type="metadata:TypeMetaData" maxOccurs="unbounded" minOccurs="0"/> + </sequence> + </complexType> + + <complexType name="JavaMetaData"> + <attribute name="factoryInterface" type="string" use="optional"/> + <attribute name="typeInterface" type="string" use="optional"/> + </complexType> + + <complexType name="XSDMetaData"> + <attribute name="location" type="string" use="required"/> + </complexType> + + <complexType name="TypeMetaData"> + <attribute name="location" type="string" use="required"/> + </complexType> + +</schema> diff --git a/sandbox/jboynes/sdo/impl/src/test/java/com/example/simple/Quote.java b/sandbox/jboynes/sdo/impl/src/test/java/com/example/simple/Quote.java new file mode 100644 index 0000000000..2855d2a67c --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/com/example/simple/Quote.java @@ -0,0 +1,310 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.example.simple; + +import java.math.BigDecimal; + +import java.util.List; + +/** + * <!-- begin-user-doc --> + * A representation of the model object '<em><b>Quote</b></em>'. + * <!-- end-user-doc --> + * + * <p> + * The following features are supported: + * <ul> + * <li>{@link com.example.simple.Quote#getSymbol <em>Symbol</em>}</li> + * <li>{@link com.example.simple.Quote#getCompanyName <em>Company Name</em>}</li> + * <li>{@link com.example.simple.Quote#getPrice <em>Price</em>}</li> + * <li>{@link com.example.simple.Quote#getOpen1 <em>Open1</em>}</li> + * <li>{@link com.example.simple.Quote#getHigh <em>High</em>}</li> + * <li>{@link com.example.simple.Quote#getLow <em>Low</em>}</li> + * <li>{@link com.example.simple.Quote#getVolume <em>Volume</em>}</li> + * <li>{@link com.example.simple.Quote#getChange1 <em>Change1</em>}</li> + * <li>{@link com.example.simple.Quote#getQuotes <em>Quotes</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public interface Quote +{ + /** + * Returns the value of the '<em><b>Symbol</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Symbol</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Symbol</em>' attribute. + * @see #setSymbol(String) + * @generated + */ + String getSymbol(); + + /** + * Sets the value of the '{@link com.example.simple.Quote#getSymbol <em>Symbol</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Symbol</em>' attribute. + * @see #getSymbol() + * @generated + */ + void setSymbol(String value); + + /** + * Returns the value of the '<em><b>Company Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Company Name</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Company Name</em>' attribute. + * @see #setCompanyName(String) + * @generated + */ + String getCompanyName(); + + /** + * Sets the value of the '{@link com.example.simple.Quote#getCompanyName <em>Company Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Company Name</em>' attribute. + * @see #getCompanyName() + * @generated + */ + void setCompanyName(String value); + + /** + * Returns the value of the '<em><b>Price</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Price</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Price</em>' attribute. + * @see #setPrice(BigDecimal) + * @generated + */ + BigDecimal getPrice(); + + /** + * Sets the value of the '{@link com.example.simple.Quote#getPrice <em>Price</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Price</em>' attribute. + * @see #getPrice() + * @generated + */ + void setPrice(BigDecimal value); + + /** + * Returns the value of the '<em><b>Open1</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Open1</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Open1</em>' attribute. + * @see #setOpen1(BigDecimal) + * @generated + */ + BigDecimal getOpen1(); + + /** + * Sets the value of the '{@link com.example.simple.Quote#getOpen1 <em>Open1</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Open1</em>' attribute. + * @see #getOpen1() + * @generated + */ + void setOpen1(BigDecimal value); + + /** + * Returns the value of the '<em><b>High</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>High</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>High</em>' attribute. + * @see #setHigh(BigDecimal) + * @generated + */ + BigDecimal getHigh(); + + /** + * Sets the value of the '{@link com.example.simple.Quote#getHigh <em>High</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>High</em>' attribute. + * @see #getHigh() + * @generated + */ + void setHigh(BigDecimal value); + + /** + * Returns the value of the '<em><b>Low</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Low</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Low</em>' attribute. + * @see #setLow(BigDecimal) + * @generated + */ + BigDecimal getLow(); + + /** + * Sets the value of the '{@link com.example.simple.Quote#getLow <em>Low</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Low</em>' attribute. + * @see #getLow() + * @generated + */ + void setLow(BigDecimal value); + + /** + * Returns the value of the '<em><b>Volume</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Volume</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Volume</em>' attribute. + * @see #isSetVolume() + * @see #unsetVolume() + * @see #setVolume(double) + * @generated + */ + double getVolume(); + + /** + * Sets the value of the '{@link com.example.simple.Quote#getVolume <em>Volume</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Volume</em>' attribute. + * @see #isSetVolume() + * @see #unsetVolume() + * @see #getVolume() + * @generated + */ + void setVolume(double value); + + /** + * Unsets the value of the '{@link com.example.simple.Quote#getVolume <em>Volume</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isSetVolume() + * @see #getVolume() + * @see #setVolume(double) + * @generated + */ + void unsetVolume(); + + /** + * Returns whether the value of the '{@link com.example.simple.Quote#getVolume <em>Volume</em>}' attribute is set. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return whether the value of the '<em>Volume</em>' attribute is set. + * @see #unsetVolume() + * @see #getVolume() + * @see #setVolume(double) + * @generated + */ + boolean isSetVolume(); + + /** + * Returns the value of the '<em><b>Change1</b></em>' attribute. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Change1</em>' attribute isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Change1</em>' attribute. + * @see #isSetChange1() + * @see #unsetChange1() + * @see #setChange1(double) + * @generated + */ + double getChange1(); + + /** + * Sets the value of the '{@link com.example.simple.Quote#getChange1 <em>Change1</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @param value the new value of the '<em>Change1</em>' attribute. + * @see #isSetChange1() + * @see #unsetChange1() + * @see #getChange1() + * @generated + */ + void setChange1(double value); + + /** + * Unsets the value of the '{@link com.example.simple.Quote#getChange1 <em>Change1</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #isSetChange1() + * @see #getChange1() + * @see #setChange1(double) + * @generated + */ + void unsetChange1(); + + /** + * Returns whether the value of the '{@link com.example.simple.Quote#getChange1 <em>Change1</em>}' attribute is set. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return whether the value of the '<em>Change1</em>' attribute is set. + * @see #unsetChange1() + * @see #getChange1() + * @see #setChange1(double) + * @generated + */ + boolean isSetChange1(); + + /** + * Returns the value of the '<em><b>Quotes</b></em>' containment reference list. + * The list contents are of type {@link com.example.simple.Quote}. + * <!-- begin-user-doc --> + * <p> + * If the meaning of the '<em>Quotes</em>' containment reference list isn't clear, + * there really should be more of a description here... + * </p> + * <!-- end-user-doc --> + * @return the value of the '<em>Quotes</em>' containment reference list. + * @generated + */ + List getQuotes(); + +} // Quote diff --git a/sandbox/jboynes/sdo/impl/src/test/java/com/example/simple/SimpleFactory.java b/sandbox/jboynes/sdo/impl/src/test/java/com/example/simple/SimpleFactory.java new file mode 100644 index 0000000000..4f33a3e19f --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/com/example/simple/SimpleFactory.java @@ -0,0 +1,49 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.example.simple; + + +/** + * <!-- begin-user-doc --> + * The <b>Factory</b> for the model. + * It provides a create method for each non-abstract class of the model. + * <!-- end-user-doc --> + * @generated + */ +public interface SimpleFactory +{ + /** + * The singleton instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + SimpleFactory INSTANCE = com.example.simple.impl.SimpleFactoryImpl.eINSTANCE; + + /** + * Returns a new object of class '<em>Quote</em>'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return a new object of class '<em>Quote</em>'. + * @generated + */ + Quote createQuote(); + +} //SimpleFactory diff --git a/sandbox/jboynes/sdo/impl/src/test/java/com/example/simple/impl/QuoteImpl.java b/sandbox/jboynes/sdo/impl/src/test/java/com/example/simple/impl/QuoteImpl.java new file mode 100644 index 0000000000..18c63894af --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/com/example/simple/impl/QuoteImpl.java @@ -0,0 +1,715 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.example.simple.impl; + +import com.example.simple.Quote; + +import java.math.BigDecimal; + +import java.util.Collection; +import java.util.List; + +import org.apache.tuscany.sdo.impl.DataObjectImpl; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; + +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * <!-- begin-user-doc --> + * An implementation of the model object '<em><b>Quote</b></em>'. + * <!-- end-user-doc --> + * <p> + * The following features are implemented: + * <ul> + * <li>{@link com.example.simple.impl.QuoteImpl#getSymbol <em>Symbol</em>}</li> + * <li>{@link com.example.simple.impl.QuoteImpl#getCompanyName <em>Company Name</em>}</li> + * <li>{@link com.example.simple.impl.QuoteImpl#getPrice <em>Price</em>}</li> + * <li>{@link com.example.simple.impl.QuoteImpl#getOpen1 <em>Open1</em>}</li> + * <li>{@link com.example.simple.impl.QuoteImpl#getHigh <em>High</em>}</li> + * <li>{@link com.example.simple.impl.QuoteImpl#getLow <em>Low</em>}</li> + * <li>{@link com.example.simple.impl.QuoteImpl#getVolume <em>Volume</em>}</li> + * <li>{@link com.example.simple.impl.QuoteImpl#getChange1 <em>Change1</em>}</li> + * <li>{@link com.example.simple.impl.QuoteImpl#getQuotes <em>Quotes</em>}</li> + * </ul> + * </p> + * + * @generated + */ +public class QuoteImpl extends DataObjectImpl implements Quote +{ + /** + * The default value of the '{@link #getSymbol() <em>Symbol</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getSymbol() + * @generated + * @ordered + */ + protected static final String SYMBOL_EDEFAULT = null; + + /** + * The cached value of the '{@link #getSymbol() <em>Symbol</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getSymbol() + * @generated + * @ordered + */ + protected String symbol = SYMBOL_EDEFAULT; + + /** + * The default value of the '{@link #getCompanyName() <em>Company Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getCompanyName() + * @generated + * @ordered + */ + protected static final String COMPANY_NAME_EDEFAULT = null; + + /** + * The cached value of the '{@link #getCompanyName() <em>Company Name</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getCompanyName() + * @generated + * @ordered + */ + protected String companyName = COMPANY_NAME_EDEFAULT; + + /** + * The default value of the '{@link #getPrice() <em>Price</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getPrice() + * @generated + * @ordered + */ + protected static final BigDecimal PRICE_EDEFAULT = null; + + /** + * The cached value of the '{@link #getPrice() <em>Price</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getPrice() + * @generated + * @ordered + */ + protected BigDecimal price = PRICE_EDEFAULT; + + /** + * The default value of the '{@link #getOpen1() <em>Open1</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getOpen1() + * @generated + * @ordered + */ + protected static final BigDecimal OPEN1_EDEFAULT = null; + + /** + * The cached value of the '{@link #getOpen1() <em>Open1</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getOpen1() + * @generated + * @ordered + */ + protected BigDecimal open1 = OPEN1_EDEFAULT; + + /** + * The default value of the '{@link #getHigh() <em>High</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getHigh() + * @generated + * @ordered + */ + protected static final BigDecimal HIGH_EDEFAULT = null; + + /** + * The cached value of the '{@link #getHigh() <em>High</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getHigh() + * @generated + * @ordered + */ + protected BigDecimal high = HIGH_EDEFAULT; + + /** + * The default value of the '{@link #getLow() <em>Low</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getLow() + * @generated + * @ordered + */ + protected static final BigDecimal LOW_EDEFAULT = null; + + /** + * The cached value of the '{@link #getLow() <em>Low</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getLow() + * @generated + * @ordered + */ + protected BigDecimal low = LOW_EDEFAULT; + + /** + * The default value of the '{@link #getVolume() <em>Volume</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getVolume() + * @generated + * @ordered + */ + protected static final double VOLUME_EDEFAULT = 0.0; + + /** + * The cached value of the '{@link #getVolume() <em>Volume</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getVolume() + * @generated + * @ordered + */ + protected double volume = VOLUME_EDEFAULT; + + /** + * This is true if the Volume attribute has been set. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + protected boolean volumeESet = false; + + /** + * The default value of the '{@link #getChange1() <em>Change1</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getChange1() + * @generated + * @ordered + */ + protected static final double CHANGE1_EDEFAULT = 0.0; + + /** + * The cached value of the '{@link #getChange1() <em>Change1</em>}' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getChange1() + * @generated + * @ordered + */ + protected double change1 = CHANGE1_EDEFAULT; + + /** + * This is true if the Change1 attribute has been set. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + protected boolean change1ESet = false; + + /** + * The cached value of the '{@link #getQuotes() <em>Quotes</em>}' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #getQuotes() + * @generated + * @ordered + */ + protected EList quotes = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected QuoteImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected EClass eStaticClass() + { + return SimplePackageImpl.Literals.QUOTE; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getSymbol() + { + return symbol; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setSymbol(String newSymbol) + { + String oldSymbol = symbol; + symbol = newSymbol; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SimplePackageImpl.QUOTE__SYMBOL, oldSymbol, symbol)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String getCompanyName() + { + return companyName; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setCompanyName(String newCompanyName) + { + String oldCompanyName = companyName; + companyName = newCompanyName; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SimplePackageImpl.QUOTE__COMPANY_NAME, oldCompanyName, companyName)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public BigDecimal getPrice() + { + return price; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setPrice(BigDecimal newPrice) + { + BigDecimal oldPrice = price; + price = newPrice; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SimplePackageImpl.QUOTE__PRICE, oldPrice, price)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public BigDecimal getOpen1() + { + return open1; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setOpen1(BigDecimal newOpen1) + { + BigDecimal oldOpen1 = open1; + open1 = newOpen1; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SimplePackageImpl.QUOTE__OPEN1, oldOpen1, open1)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public BigDecimal getHigh() + { + return high; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setHigh(BigDecimal newHigh) + { + BigDecimal oldHigh = high; + high = newHigh; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SimplePackageImpl.QUOTE__HIGH, oldHigh, high)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public BigDecimal getLow() + { + return low; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setLow(BigDecimal newLow) + { + BigDecimal oldLow = low; + low = newLow; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SimplePackageImpl.QUOTE__LOW, oldLow, low)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public double getVolume() + { + return volume; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setVolume(double newVolume) + { + double oldVolume = volume; + volume = newVolume; + boolean oldVolumeESet = volumeESet; + volumeESet = true; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SimplePackageImpl.QUOTE__VOLUME, oldVolume, volume, !oldVolumeESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void unsetVolume() + { + double oldVolume = volume; + boolean oldVolumeESet = volumeESet; + volume = VOLUME_EDEFAULT; + volumeESet = false; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.UNSET, SimplePackageImpl.QUOTE__VOLUME, oldVolume, VOLUME_EDEFAULT, oldVolumeESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isSetVolume() + { + return volumeESet; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public double getChange1() + { + return change1; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void setChange1(double newChange1) + { + double oldChange1 = change1; + change1 = newChange1; + boolean oldChange1ESet = change1ESet; + change1ESet = true; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SimplePackageImpl.QUOTE__CHANGE1, oldChange1, change1, !oldChange1ESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void unsetChange1() + { + double oldChange1 = change1; + boolean oldChange1ESet = change1ESet; + change1 = CHANGE1_EDEFAULT; + change1ESet = false; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.UNSET, SimplePackageImpl.QUOTE__CHANGE1, oldChange1, CHANGE1_EDEFAULT, oldChange1ESet)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean isSetChange1() + { + return change1ESet; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public List getQuotes() + { + if (quotes == null) + { + quotes = new EObjectContainmentEList(Quote.class, this, SimplePackageImpl.QUOTE__QUOTES); + } + return quotes; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) + { + switch (featureID) + { + case SimplePackageImpl.QUOTE__QUOTES: + return ((InternalEList)getQuotes()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case SimplePackageImpl.QUOTE__SYMBOL: + return getSymbol(); + case SimplePackageImpl.QUOTE__COMPANY_NAME: + return getCompanyName(); + case SimplePackageImpl.QUOTE__PRICE: + return getPrice(); + case SimplePackageImpl.QUOTE__OPEN1: + return getOpen1(); + case SimplePackageImpl.QUOTE__HIGH: + return getHigh(); + case SimplePackageImpl.QUOTE__LOW: + return getLow(); + case SimplePackageImpl.QUOTE__VOLUME: + return new Double(getVolume()); + case SimplePackageImpl.QUOTE__CHANGE1: + return new Double(getChange1()); + case SimplePackageImpl.QUOTE__QUOTES: + return getQuotes(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case SimplePackageImpl.QUOTE__SYMBOL: + setSymbol((String)newValue); + return; + case SimplePackageImpl.QUOTE__COMPANY_NAME: + setCompanyName((String)newValue); + return; + case SimplePackageImpl.QUOTE__PRICE: + setPrice((BigDecimal)newValue); + return; + case SimplePackageImpl.QUOTE__OPEN1: + setOpen1((BigDecimal)newValue); + return; + case SimplePackageImpl.QUOTE__HIGH: + setHigh((BigDecimal)newValue); + return; + case SimplePackageImpl.QUOTE__LOW: + setLow((BigDecimal)newValue); + return; + case SimplePackageImpl.QUOTE__VOLUME: + setVolume(((Double)newValue).doubleValue()); + return; + case SimplePackageImpl.QUOTE__CHANGE1: + setChange1(((Double)newValue).doubleValue()); + return; + case SimplePackageImpl.QUOTE__QUOTES: + getQuotes().clear(); + getQuotes().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case SimplePackageImpl.QUOTE__SYMBOL: + setSymbol(SYMBOL_EDEFAULT); + return; + case SimplePackageImpl.QUOTE__COMPANY_NAME: + setCompanyName(COMPANY_NAME_EDEFAULT); + return; + case SimplePackageImpl.QUOTE__PRICE: + setPrice(PRICE_EDEFAULT); + return; + case SimplePackageImpl.QUOTE__OPEN1: + setOpen1(OPEN1_EDEFAULT); + return; + case SimplePackageImpl.QUOTE__HIGH: + setHigh(HIGH_EDEFAULT); + return; + case SimplePackageImpl.QUOTE__LOW: + setLow(LOW_EDEFAULT); + return; + case SimplePackageImpl.QUOTE__VOLUME: + unsetVolume(); + return; + case SimplePackageImpl.QUOTE__CHANGE1: + unsetChange1(); + return; + case SimplePackageImpl.QUOTE__QUOTES: + getQuotes().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case SimplePackageImpl.QUOTE__SYMBOL: + return SYMBOL_EDEFAULT == null ? symbol != null : !SYMBOL_EDEFAULT.equals(symbol); + case SimplePackageImpl.QUOTE__COMPANY_NAME: + return COMPANY_NAME_EDEFAULT == null ? companyName != null : !COMPANY_NAME_EDEFAULT.equals(companyName); + case SimplePackageImpl.QUOTE__PRICE: + return PRICE_EDEFAULT == null ? price != null : !PRICE_EDEFAULT.equals(price); + case SimplePackageImpl.QUOTE__OPEN1: + return OPEN1_EDEFAULT == null ? open1 != null : !OPEN1_EDEFAULT.equals(open1); + case SimplePackageImpl.QUOTE__HIGH: + return HIGH_EDEFAULT == null ? high != null : !HIGH_EDEFAULT.equals(high); + case SimplePackageImpl.QUOTE__LOW: + return LOW_EDEFAULT == null ? low != null : !LOW_EDEFAULT.equals(low); + case SimplePackageImpl.QUOTE__VOLUME: + return isSetVolume(); + case SimplePackageImpl.QUOTE__CHANGE1: + return isSetChange1(); + case SimplePackageImpl.QUOTE__QUOTES: + return quotes != null && !quotes.isEmpty(); + } + return super.eIsSet(featureID); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (symbol: "); + result.append(symbol); + result.append(", companyName: "); + result.append(companyName); + result.append(", price: "); + result.append(price); + result.append(", open1: "); + result.append(open1); + result.append(", high: "); + result.append(high); + result.append(", low: "); + result.append(low); + result.append(", volume: "); + if (volumeESet) result.append(volume); else result.append("<unset>"); + result.append(", change1: "); + if (change1ESet) result.append(change1); else result.append("<unset>"); + result.append(')'); + return result.toString(); + } + +} //QuoteImpl diff --git a/sandbox/jboynes/sdo/impl/src/test/java/com/example/simple/impl/SimpleFactoryImpl.java b/sandbox/jboynes/sdo/impl/src/test/java/com/example/simple/impl/SimpleFactoryImpl.java new file mode 100644 index 0000000000..5f275a94d4 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/com/example/simple/impl/SimpleFactoryImpl.java @@ -0,0 +1,141 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.example.simple.impl; + +import com.example.simple.*; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +/** + * <!-- begin-user-doc --> + * An implementation of the model <b>Factory</b>. + * <!-- end-user-doc --> + * @generated + */ +public class SimpleFactoryImpl extends EFactoryImpl implements SimpleFactory +{ + /** + * The singleton instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final SimpleFactoryImpl eINSTANCE = init(); + + /** + * Creates the default factory implementation. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static SimpleFactoryImpl init() + { + try + { + SimpleFactoryImpl theSimpleFactory = (SimpleFactoryImpl)EPackage.Registry.INSTANCE.getEFactory("http://www.example.com/simple"); + if (theSimpleFactory != null) + { + return theSimpleFactory; + } + } + catch (Exception exception) + { + EcorePlugin.INSTANCE.log(exception); + } + return new SimpleFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public SimpleFactoryImpl() + { + super(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EObject create(EClass eClass) + { + switch (eClass.getClassifierID()) + { + case SimplePackageImpl.DOCUMENT_ROOT: return (EObject)createDocumentRoot(); + case SimplePackageImpl.QUOTE: return (EObject)createQuote(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public EObject createDocumentRoot() + { + EObject documentRoot = super.create(SimplePackageImpl.Literals.DOCUMENT_ROOT); + return documentRoot; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public Quote createQuote() + { + QuoteImpl quote = new QuoteImpl(); + return quote; + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public SimplePackageImpl getSimplePackageImpl() + { + return (SimplePackageImpl)getEPackage(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @deprecated + * @generated + */ + public static SimplePackageImpl getPackage() + { + return SimplePackageImpl.eINSTANCE; + } + +} //SimpleFactoryImpl diff --git a/sandbox/jboynes/sdo/impl/src/test/java/com/example/simple/impl/SimplePackageImpl.java b/sandbox/jboynes/sdo/impl/src/test/java/com/example/simple/impl/SimplePackageImpl.java new file mode 100644 index 0000000000..50ad614fd7 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/com/example/simple/impl/SimplePackageImpl.java @@ -0,0 +1,911 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package com.example.simple.impl; + +import com.example.simple.Quote; +import com.example.simple.SimpleFactory; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EFactory; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +import org.eclipse.emf.ecore.xml.type.XMLTypePackage; + +/** + * <!-- begin-user-doc --> + * The <b>Package</b> for the model. + * It contains accessors for the meta objects to represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @see com.example.simple.SimpleFactory + * @generated + */ +public class SimplePackageImpl extends EPackageImpl +{ + /** + * The package name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final String eNAME = "simple"; + + /** + * The package namespace URI. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final String eNS_URI = "http://www.example.com/simple"; + + /** + * The package namespace name. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final String eNS_PREFIX = "simple"; + + /** + * The singleton instance of the package. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final SimplePackageImpl eINSTANCE = com.example.simple.impl.SimplePackageImpl.init(); + + /** + * The meta object id for the '{@link com.example.simple.impl.DocumentRootImpl <em>Document Root</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see com.example.simple.impl.DocumentRootImpl + * @see com.example.simple.impl.SimplePackageImpl#getDocumentRoot() + * @generated + */ + public static final int DOCUMENT_ROOT = 0; + + /** + * The feature id for the '<em><b>Mixed</b></em>' attribute list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__MIXED = 0; + + /** + * The feature id for the '<em><b>XMLNS Prefix Map</b></em>' map. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__XMLNS_PREFIX_MAP = 1; + + /** + * The feature id for the '<em><b>XSI Schema Location</b></em>' map. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__XSI_SCHEMA_LOCATION = 2; + + /** + * The feature id for the '<em><b>Stock Quote</b></em>' containment reference. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__STOCK_QUOTE = 3; + + /** + * The number of structural features of the '<em>Document Root</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT_FEATURE_COUNT = 4; + + /** + * The meta object id for the '{@link com.example.simple.impl.QuoteImpl <em>Quote</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see com.example.simple.impl.QuoteImpl + * @see com.example.simple.impl.SimplePackageImpl#getQuote() + * @generated + */ + public static final int QUOTE = 1; + + /** + * The feature id for the '<em><b>Symbol</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int QUOTE__SYMBOL = 0; + + /** + * The feature id for the '<em><b>Company Name</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int QUOTE__COMPANY_NAME = 1; + + /** + * The feature id for the '<em><b>Price</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int QUOTE__PRICE = 2; + + /** + * The feature id for the '<em><b>Open1</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int QUOTE__OPEN1 = 3; + + /** + * The feature id for the '<em><b>High</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int QUOTE__HIGH = 4; + + /** + * The feature id for the '<em><b>Low</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int QUOTE__LOW = 5; + + /** + * The feature id for the '<em><b>Volume</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int QUOTE__VOLUME = 6; + + /** + * The feature id for the '<em><b>Change1</b></em>' attribute. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int QUOTE__CHANGE1 = 7; + + /** + * The feature id for the '<em><b>Quotes</b></em>' containment reference list. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int QUOTE__QUOTES = 8; + + /** + * The number of structural features of the '<em>Quote</em>' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + * @ordered + */ + public static final int QUOTE_FEATURE_COUNT = 9; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass documentRootEClass = null; + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private EClass quoteEClass = null; + + /** + * Creates an instance of the model <b>Package</b>, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + * <p>Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see com.example.simple.impl.SimplePackageImpl#eNS_URI + * @see #init() + * @generated + */ + private SimplePackageImpl() + { + super(eNS_URI, ((EFactory)SimpleFactory.INSTANCE)); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the <b>Package</b> for this + * model, and for any others upon which it depends. Simple + * dependencies are satisfied by calling this method on all + * dependent packages before doing anything else. This method drives + * initialization for interdependent packages directly, in parallel + * with this package, itself. + * <p>Of this package and its interdependencies, all packages which + * have not yet been registered by their URI values are first created + * and registered. The packages are then initialized in two steps: + * meta-model objects for all of the packages are created before any + * are initialized, since one package's meta-model objects may refer to + * those of another. + * <p>Invocation of this method will not affect any packages that have + * already been initialized. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static SimplePackageImpl init() + { + if (isInited) return (SimplePackageImpl)EPackage.Registry.INSTANCE.getEPackage(SimplePackageImpl.eNS_URI); + + // Obtain or create and register package + SimplePackageImpl theSimplePackageImpl = (SimplePackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof SimplePackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new SimplePackageImpl()); + + isInited = true; + + // Initialize simple dependencies + XMLTypePackage.eINSTANCE.eClass(); + + // Create package meta-data objects + theSimplePackageImpl.createPackageContents(); + + // Initialize created meta-data + theSimplePackageImpl.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theSimplePackageImpl.freeze(); + + return theSimplePackageImpl; + } + + + /** + * Returns the meta object for class '{@link org.eclipse.emf.ecore.EObject <em>Document Root</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Document Root</em>'. + * @see org.eclipse.emf.ecore.EObject + * @generated + */ + public EClass getDocumentRoot() + { + return documentRootEClass; + } + + /** + * Returns the meta object for the attribute list '{@link org.eclipse.emf.ecore.EObject#getMixed <em>Mixed</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute list '<em>Mixed</em>'. + * @see org.eclipse.emf.ecore.EObject#getMixed() + * @see #getDocumentRoot() + * @generated + */ + public EAttribute getDocumentRoot_Mixed() + { + return (EAttribute)documentRootEClass.getEStructuralFeatures().get(0); + } + + /** + * Returns the meta object for the map '{@link org.eclipse.emf.ecore.EObject#getXMLNSPrefixMap <em>XMLNS Prefix Map</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the map '<em>XMLNS Prefix Map</em>'. + * @see org.eclipse.emf.ecore.EObject#getXMLNSPrefixMap() + * @see #getDocumentRoot() + * @generated + */ + public EReference getDocumentRoot_XMLNSPrefixMap() + { + return (EReference)documentRootEClass.getEStructuralFeatures().get(1); + } + + /** + * Returns the meta object for the map '{@link org.eclipse.emf.ecore.EObject#getXSISchemaLocation <em>XSI Schema Location</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the map '<em>XSI Schema Location</em>'. + * @see org.eclipse.emf.ecore.EObject#getXSISchemaLocation() + * @see #getDocumentRoot() + * @generated + */ + public EReference getDocumentRoot_XSISchemaLocation() + { + return (EReference)documentRootEClass.getEStructuralFeatures().get(2); + } + + /** + * Returns the meta object for the containment reference '{@link org.eclipse.emf.ecore.EObject#getStockQuote <em>Stock Quote</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the containment reference '<em>Stock Quote</em>'. + * @see org.eclipse.emf.ecore.EObject#getStockQuote() + * @see #getDocumentRoot() + * @generated + */ + public EReference getDocumentRoot_StockQuote() + { + return (EReference)documentRootEClass.getEStructuralFeatures().get(3); + } + + /** + * Returns the meta object for class '{@link com.example.simple.Quote <em>Quote</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for class '<em>Quote</em>'. + * @see com.example.simple.Quote + * @generated + */ + public EClass getQuote() + { + return quoteEClass; + } + + /** + * Returns the meta object for the attribute '{@link com.example.simple.Quote#getSymbol <em>Symbol</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Symbol</em>'. + * @see com.example.simple.Quote#getSymbol() + * @see #getQuote() + * @generated + */ + public EAttribute getQuote_Symbol() + { + return (EAttribute)quoteEClass.getEStructuralFeatures().get(0); + } + + /** + * Returns the meta object for the attribute '{@link com.example.simple.Quote#getCompanyName <em>Company Name</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Company Name</em>'. + * @see com.example.simple.Quote#getCompanyName() + * @see #getQuote() + * @generated + */ + public EAttribute getQuote_CompanyName() + { + return (EAttribute)quoteEClass.getEStructuralFeatures().get(1); + } + + /** + * Returns the meta object for the attribute '{@link com.example.simple.Quote#getPrice <em>Price</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Price</em>'. + * @see com.example.simple.Quote#getPrice() + * @see #getQuote() + * @generated + */ + public EAttribute getQuote_Price() + { + return (EAttribute)quoteEClass.getEStructuralFeatures().get(2); + } + + /** + * Returns the meta object for the attribute '{@link com.example.simple.Quote#getOpen1 <em>Open1</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Open1</em>'. + * @see com.example.simple.Quote#getOpen1() + * @see #getQuote() + * @generated + */ + public EAttribute getQuote_Open1() + { + return (EAttribute)quoteEClass.getEStructuralFeatures().get(3); + } + + /** + * Returns the meta object for the attribute '{@link com.example.simple.Quote#getHigh <em>High</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>High</em>'. + * @see com.example.simple.Quote#getHigh() + * @see #getQuote() + * @generated + */ + public EAttribute getQuote_High() + { + return (EAttribute)quoteEClass.getEStructuralFeatures().get(4); + } + + /** + * Returns the meta object for the attribute '{@link com.example.simple.Quote#getLow <em>Low</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Low</em>'. + * @see com.example.simple.Quote#getLow() + * @see #getQuote() + * @generated + */ + public EAttribute getQuote_Low() + { + return (EAttribute)quoteEClass.getEStructuralFeatures().get(5); + } + + /** + * Returns the meta object for the attribute '{@link com.example.simple.Quote#getVolume <em>Volume</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Volume</em>'. + * @see com.example.simple.Quote#getVolume() + * @see #getQuote() + * @generated + */ + public EAttribute getQuote_Volume() + { + return (EAttribute)quoteEClass.getEStructuralFeatures().get(6); + } + + /** + * Returns the meta object for the attribute '{@link com.example.simple.Quote#getChange1 <em>Change1</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the attribute '<em>Change1</em>'. + * @see com.example.simple.Quote#getChange1() + * @see #getQuote() + * @generated + */ + public EAttribute getQuote_Change1() + { + return (EAttribute)quoteEClass.getEStructuralFeatures().get(7); + } + + /** + * Returns the meta object for the containment reference list '{@link com.example.simple.Quote#getQuotes <em>Quotes</em>}'. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the meta object for the containment reference list '<em>Quotes</em>'. + * @see com.example.simple.Quote#getQuotes() + * @see #getQuote() + * @generated + */ + public EReference getQuote_Quotes() + { + return (EReference)quoteEClass.getEStructuralFeatures().get(8); + } + + /** + * Returns the factory that creates the instances of the model. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @return the factory that creates the instances of the model. + * @generated + */ + public SimpleFactory getSimpleFactory() + { + return (SimpleFactory)getEFactoryInstance(); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void createPackageContents() + { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + documentRootEClass = createEClass(DOCUMENT_ROOT); + createEAttribute(documentRootEClass, DOCUMENT_ROOT__MIXED); + createEReference(documentRootEClass, DOCUMENT_ROOT__XMLNS_PREFIX_MAP); + createEReference(documentRootEClass, DOCUMENT_ROOT__XSI_SCHEMA_LOCATION); + createEReference(documentRootEClass, DOCUMENT_ROOT__STOCK_QUOTE); + + quoteEClass = createEClass(QUOTE); + createEAttribute(quoteEClass, QUOTE__SYMBOL); + createEAttribute(quoteEClass, QUOTE__COMPANY_NAME); + createEAttribute(quoteEClass, QUOTE__PRICE); + createEAttribute(quoteEClass, QUOTE__OPEN1); + createEAttribute(quoteEClass, QUOTE__HIGH); + createEAttribute(quoteEClass, QUOTE__LOW); + createEAttribute(quoteEClass, QUOTE__VOLUME); + createEAttribute(quoteEClass, QUOTE__CHANGE1); + createEReference(quoteEClass, QUOTE__QUOTES); + } + + /** + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public void initializePackageContents() + { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Obtain other dependent packages + XMLTypePackage theXMLTypePackage = (XMLTypePackage)EPackage.Registry.INSTANCE.getEPackage(XMLTypePackage.eNS_URI); + + // Add supertypes to classes + + // Initialize classes and features; add operations and parameters + initEClass(documentRootEClass, null, "DocumentRoot", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getDocumentRoot_Mixed(), ecorePackage.getEFeatureMapEntry(), "mixed", null, 0, -1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getDocumentRoot_XMLNSPrefixMap(), ecorePackage.getEStringToStringMapEntry(), null, "xMLNSPrefixMap", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getDocumentRoot_XSISchemaLocation(), ecorePackage.getEStringToStringMapEntry(), null, "xSISchemaLocation", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getDocumentRoot_StockQuote(), this.getQuote(), null, "stockQuote", null, 0, -2, null, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + + initEClass(quoteEClass, Quote.class, "Quote", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getQuote_Symbol(), theXMLTypePackage.getString(), "symbol", null, 1, 1, Quote.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getQuote_CompanyName(), theXMLTypePackage.getString(), "companyName", null, 1, 1, Quote.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getQuote_Price(), theXMLTypePackage.getDecimal(), "price", null, 1, 1, Quote.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getQuote_Open1(), theXMLTypePackage.getDecimal(), "open1", null, 1, 1, Quote.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getQuote_High(), theXMLTypePackage.getDecimal(), "high", null, 1, 1, Quote.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getQuote_Low(), theXMLTypePackage.getDecimal(), "low", null, 1, 1, Quote.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getQuote_Volume(), theXMLTypePackage.getDouble(), "volume", null, 1, 1, Quote.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getQuote_Change1(), theXMLTypePackage.getDouble(), "change1", null, 1, 1, Quote.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getQuote_Quotes(), this.getQuote(), null, "quotes", null, 0, -1, Quote.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Create resource + createResource(eNS_URI); + + // Create annotations + // http:///org/eclipse/emf/ecore/util/ExtendedMetaData + createExtendedMetaDataAnnotations(); + } + + /** + * Initializes the annotations for <b>http:///org/eclipse/emf/ecore/util/ExtendedMetaData</b>. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + protected void createExtendedMetaDataAnnotations() + { + String source = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData"; + addAnnotation + (documentRootEClass, + source, + new String[] + { + "name", "", + "kind", "mixed" + }); + addAnnotation + (getDocumentRoot_Mixed(), + source, + new String[] + { + "kind", "elementWildcard", + "name", ":mixed" + }); + addAnnotation + (getDocumentRoot_XMLNSPrefixMap(), + source, + new String[] + { + "kind", "attribute", + "name", "xmlns:prefix" + }); + addAnnotation + (getDocumentRoot_XSISchemaLocation(), + source, + new String[] + { + "kind", "attribute", + "name", "xsi:schemaLocation" + }); + addAnnotation + (getDocumentRoot_StockQuote(), + source, + new String[] + { + "kind", "element", + "name", "stockQuote", + "namespace", "##targetNamespace" + }); + addAnnotation + (quoteEClass, + source, + new String[] + { + "name", "Quote", + "kind", "elementOnly" + }); + addAnnotation + (getQuote_Symbol(), + source, + new String[] + { + "kind", "element", + "name", "symbol" + }); + addAnnotation + (getQuote_CompanyName(), + source, + new String[] + { + "kind", "element", + "name", "companyName" + }); + addAnnotation + (getQuote_Price(), + source, + new String[] + { + "kind", "element", + "name", "price" + }); + addAnnotation + (getQuote_Open1(), + source, + new String[] + { + "kind", "element", + "name", "open1" + }); + addAnnotation + (getQuote_High(), + source, + new String[] + { + "kind", "element", + "name", "high" + }); + addAnnotation + (getQuote_Low(), + source, + new String[] + { + "kind", "element", + "name", "low" + }); + addAnnotation + (getQuote_Volume(), + source, + new String[] + { + "kind", "element", + "name", "volume" + }); + addAnnotation + (getQuote_Change1(), + source, + new String[] + { + "kind", "element", + "name", "change1" + }); + addAnnotation + (getQuote_Quotes(), + source, + new String[] + { + "kind", "element", + "name", "quotes" + }); + } + + /** + * <!-- begin-user-doc --> + * Defines literals for the meta objects that represent + * <ul> + * <li>each class,</li> + * <li>each feature of each class,</li> + * <li>each enum,</li> + * <li>and each data type</li> + * </ul> + * <!-- end-user-doc --> + * @generated + */ + public interface Literals + { + /** + * The meta object literal for the '{@link com.example.simple.impl.DocumentRootImpl <em>Document Root</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see com.example.simple.impl.DocumentRootImpl + * @see com.example.simple.impl.SimplePackageImpl#getDocumentRoot() + * @generated + */ + public static final EClass DOCUMENT_ROOT = eINSTANCE.getDocumentRoot(); + + /** + * The meta object literal for the '<em><b>Mixed</b></em>' attribute list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute DOCUMENT_ROOT__MIXED = eINSTANCE.getDocumentRoot_Mixed(); + + /** + * The meta object literal for the '<em><b>XMLNS Prefix Map</b></em>' map feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference DOCUMENT_ROOT__XMLNS_PREFIX_MAP = eINSTANCE.getDocumentRoot_XMLNSPrefixMap(); + + /** + * The meta object literal for the '<em><b>XSI Schema Location</b></em>' map feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference DOCUMENT_ROOT__XSI_SCHEMA_LOCATION = eINSTANCE.getDocumentRoot_XSISchemaLocation(); + + /** + * The meta object literal for the '<em><b>Stock Quote</b></em>' containment reference feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference DOCUMENT_ROOT__STOCK_QUOTE = eINSTANCE.getDocumentRoot_StockQuote(); + + /** + * The meta object literal for the '{@link com.example.simple.impl.QuoteImpl <em>Quote</em>}' class. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @see com.example.simple.impl.QuoteImpl + * @see com.example.simple.impl.SimplePackageImpl#getQuote() + * @generated + */ + public static final EClass QUOTE = eINSTANCE.getQuote(); + + /** + * The meta object literal for the '<em><b>Symbol</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute QUOTE__SYMBOL = eINSTANCE.getQuote_Symbol(); + + /** + * The meta object literal for the '<em><b>Company Name</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute QUOTE__COMPANY_NAME = eINSTANCE.getQuote_CompanyName(); + + /** + * The meta object literal for the '<em><b>Price</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute QUOTE__PRICE = eINSTANCE.getQuote_Price(); + + /** + * The meta object literal for the '<em><b>Open1</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute QUOTE__OPEN1 = eINSTANCE.getQuote_Open1(); + + /** + * The meta object literal for the '<em><b>High</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute QUOTE__HIGH = eINSTANCE.getQuote_High(); + + /** + * The meta object literal for the '<em><b>Low</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute QUOTE__LOW = eINSTANCE.getQuote_Low(); + + /** + * The meta object literal for the '<em><b>Volume</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute QUOTE__VOLUME = eINSTANCE.getQuote_Volume(); + + /** + * The meta object literal for the '<em><b>Change1</b></em>' attribute feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EAttribute QUOTE__CHANGE1 = eINSTANCE.getQuote_Change1(); + + /** + * The meta object literal for the '<em><b>Quotes</b></em>' containment reference list feature. + * <!-- begin-user-doc --> + * <!-- end-user-doc --> + * @generated + */ + public static final EReference QUOTE__QUOTES = eINSTANCE.getQuote_Quotes(); + + } + +} //SimplePackageImpl diff --git a/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java new file mode 100644 index 0000000000..4a51310cd0 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java @@ -0,0 +1,26 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.codegen; + +/** + * @version $Rev$ $Date$ + */ +public interface Bar1 { +} diff --git a/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java new file mode 100644 index 0000000000..e9151b9d46 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java @@ -0,0 +1,26 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.codegen; + +/** + * @version $Rev$ $Date$ + */ +public interface Bar2 { +} diff --git a/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java new file mode 100644 index 0000000000..218a725226 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java @@ -0,0 +1,167 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.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", new Class[0]); + assertEquals(boolean.class, getter.getReturnType()); + Method setter = c.getMethod("setTrue", new Class[] {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", new Class[0]); + assertEquals(byte[].class, getter.getReturnType()); + Method setter = c.getMethod("setBytes", new Class[] {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", new Class[0]); + assertEquals(Bar1.class, getter.getReturnType()); + Method setter = c.getMethod("setBar", new Class[] {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", new Class[0]); + 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", new Class[0]); + 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", new Class[0]); + assertEquals(boolean.class, getter.getReturnType()); + Method setter = c.getMethod("setTrue", new Class[] {boolean.class}); + assertEquals(void.class, setter.getReturnType()); + getter = c.getMethod("getInt", new Class[0]); + assertEquals(int.class, getter.getReturnType()); + setter = c.getMethod("setInt", new Class[] {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/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java new file mode 100644 index 0000000000..56bf6af9b4 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java @@ -0,0 +1,26 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.codegen; + +/** + * @version $Rev$ $Date$ + */ +public interface Foo { +} diff --git a/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java new file mode 100644 index 0000000000..6cc0529c5f --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java @@ -0,0 +1,129 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.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) { + StringBuffer b = new StringBuffer(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/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java new file mode 100644 index 0000000000..d7e70369c0 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java @@ -0,0 +1,78 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.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/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java new file mode 100644 index 0000000000..4d3ecf9799 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java @@ -0,0 +1,96 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.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/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/AnyTypeTest.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/AnyTypeTest.java new file mode 100644 index 0000000000..637abcfa0a --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/AnyTypeTest.java @@ -0,0 +1,81 @@ +package org.apache.tuscany.sdo.test; + +import java.io.InputStream; +import java.io.StringReader; +import java.io.StringWriter; +import java.net.URL; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import junit.framework.TestCase; + +import org.apache.tuscany.sdo.helper.XMLStreamHelper; +import org.apache.tuscany.sdo.util.SDOUtil; + +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.XMLDocument; +import commonj.sdo.helper.XSDHelper; + +public class AnyTypeTest extends TestCase { + private static TypeHelper typeHelper; + private static DataFactory dataFactory; + private static XMLStreamHelper streamHelper; + private static XSDHelper xsdHelper; + + private static final String TEST_MODEL = "/anytype.xsd"; + private static final String TEST_NAMESPACE = "http://www.example.com/anytype"; + + public void testAnySimpleType() throws Exception { + Property property = typeHelper.getOpenContentProperty(TEST_NAMESPACE, "globalElement"); + Type propertyType = property.getType(); + + DataObject dataObject = dataFactory.create(TEST_NAMESPACE, "Person"); + dataObject.set("firstName", "Fuhwei"); + + DataObject rootObject = dataFactory.create(propertyType); + rootObject.set("anyTypeElement", dataObject); + + dataObject = dataFactory.create(TEST_NAMESPACE, "Person"); + dataObject.set("firstName", "Mindy"); + rootObject.set("personElement", dataObject); + + // XMLStreamHelper.saveObject has a problem to serialize the any type + XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); + StringWriter writer = new StringWriter(); + XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(writer); + streamHelper.saveObject(rootObject, streamWriter); + streamWriter.flush(); + System.out.println(writer.toString()); + + XMLInputFactory inputFactory = XMLInputFactory.newInstance(); + StringReader reader = new StringReader(writer.toString()); + XMLStreamReader streamReader = inputFactory.createXMLStreamReader(reader); + XMLDocument doc = streamHelper.load(streamReader); + rootObject = doc.getRootObject(); + DataObject testObject = rootObject.getDataObject("anyTypeElement"); + System.out.println("anyTypeElement dataobject: " + testObject); + testObject = rootObject.getDataObject("personElement"); + System.out.println("personElement dataobject: " + testObject); + } + + protected void setUp() throws Exception { + typeHelper = SDOUtil.createTypeHelper(); + dataFactory = SDOUtil.createDataFactory(typeHelper); + streamHelper = SDOUtil.createXMLStreamHelper(typeHelper); + xsdHelper = SDOUtil.createXSDHelper(typeHelper); + + // Populate the meta data for the test (Stock Quote) model + URL url = getClass().getResource(TEST_MODEL); + InputStream inputStream = url.openStream(); + xsdHelper.define(inputStream, url.toString()); + inputStream.close(); + } + +} diff --git a/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java new file mode 100644 index 0000000000..e956720117 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java @@ -0,0 +1,92 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.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 junit.framework.TestCase; + +import org.apache.tuscany.sdo.util.SDOUtil; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.helper.XSDHelper; + + +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/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/CrossScopeCopyTestCase.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/CrossScopeCopyTestCase.java new file mode 100644 index 0000000000..41801685f5 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/CrossScopeCopyTestCase.java @@ -0,0 +1,469 @@ +/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Vector;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Type;
+import commonj.sdo.helper.CopyHelper;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.TypeHelper;
+
+public class CrossScopeCopyTestCase extends TestCase
+{
+ // Literals
+ private static final String TEST_NAMESPACE = "http://www.example.com/bank";
+ private static final String BANK_MODEL = "/bank.xsd";
+ private static final String BANK_TYPE = "bankType";
+ private static final String BRANCH_TYPE = "branchType";
+ private static final String SERVICE_TYPE = "serviceType";
+ private static final String ACCOUNT_TYPE = "accountType";
+ private static final String CUSTOMER_TYPE = "customerType";
+ private static final String ADDRESS_TYPE = "addressType";
+ private static final String DYNAMIC_TYPE = "dynamicType";
+
+ // SDO model objects
+ private TypeHelper scopeA;
+ private TypeHelper scopeB;
+
+ // SDO instance objects
+ private DataObject bankSDO;
+ private DataObject branchSDO1;
+ private DataObject branchSDO2;
+ private DataObject serviceSDO1;
+ private DataObject serviceSDO2;
+ private DataObject serviceSDO3;
+ private DataObject customerSDO1;
+ private DataObject customerSDO2;
+ private DataObject customerSDO3;
+ private DataObject customerSDO4;
+
+ private int indent = 0;
+
+ public void testCrossScopeCopy() throws IOException
+ {
+ CopyHelper copyHelperB = SDOUtil.createCrossScopeCopyHelper(scopeB);
+
+ // Perform Shallow Copy Test
+ DataObject copiedSDO = copyHelperB.copyShallow(bankSDO);
+ shallowCopyAssertions(bankSDO, copiedSDO);
+
+ // Perform Deep Copy Test
+ copiedSDO = copyHelperB.copy(bankSDO);
+ deepCopyAssertions(bankSDO, copiedSDO);
+
+ // Inter-Reference Copy
+ copiedSDO = copyHelperB.copy(customerSDO1);
+ DataObject prop = (DataObject)copiedSDO.get("HomeBranch");
+ assertTrue(prop==null);
+
+ // Perform invalid namespace test
+ DataObject sdo = SDOUtil.createDataFactory(scopeA).create(TEST_NAMESPACE, DYNAMIC_TYPE );
+ sdo.set("custNum", "099" );
+ sdo.set("firstName", "John");
+ sdo.set("lastName", "Doe");
+ boolean failed = false;
+ try
+ {
+ // In this case, we are copying an object to a scope
+ // where the object's type has not been defined. That
+ // will generate a null pointer exception what we will
+ // catch.
+ copyHelperB.copy(sdo);
+ }
+ catch(java.lang.NullPointerException ex)
+ {
+ failed = true;
+ }
+ assertTrue(failed);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ // Create Two Scopes
+ scopeA = SDOUtil.createTypeHelper();
+ scopeB = SDOUtil.createTypeHelper();
+
+ // Populate scopes with bank model now
+ URL url = getClass().getResource(BANK_MODEL);
+ InputStream inputStream = url.openStream();
+ SDOUtil.createXSDHelper(scopeA).define(inputStream, url.toString());
+ inputStream.close();
+ inputStream = url.openStream();
+ SDOUtil.createXSDHelper(scopeB).define(inputStream, url.toString());
+ inputStream.close();
+
+ // Now Populate scopeA with some dynamic models
+ populateScopeWithDynamicTypes(scopeA);
+
+ // Construct Source Tree
+ constructSourceTree(SDOUtil.createDataFactory(scopeA));
+ }
+
+ private void shallowCopyAssertions(DataObject sdo, DataObject copiedSdo)
+ {
+ assertEquals(sdo.getType().getName(), copiedSdo.getType().getName());
+ assertEquals(sdo.getType().getURI(), copiedSdo.getType().getURI());
+ assertNotSame(sdo.getType(), copiedSdo.getType());
+ assertEquals(sdo.getInstanceProperties().size(), copiedSdo
+ .getInstanceProperties().size());
+
+ for(Iterator it = sdo.getInstanceProperties().iterator(), it2 = copiedSdo
+ .getInstanceProperties().iterator(); it.hasNext();)
+ {
+ Property p1 = (Property) it.next(), p2 = (Property) it2.next();
+ assertEquals(p1.getName(), p2.getName());
+ Object o1 = sdo.get(p1), o2 = copiedSdo.get(p2);
+ if(p1.getType().isDataType())
+ {
+ assertEquals(o1, o2);
+ // TODO is there a way I can distinguish between mutable and
+ // immutable types
+ // so that I can do some "same object" tests
+ }
+ else
+ {
+ assertNotSame(p1, p2);
+ if(p2.isMany())
+ {
+ assertEquals(copiedSdo.getList(p2).size(), 0);
+ }
+ else
+ {
+ assertNull(copiedSdo.get(p2));
+ }
+ }
+ try
+ {
+ sdo.get(p2);
+ assertTrue(false);
+ }
+ catch(Exception e)
+ {
+ // expected route
+ }
+ try
+ {
+ copiedSdo.get(p1);
+ assertTrue(false);
+ }
+ catch(Exception e2)
+ {
+ // expected route
+ }
+ }
+ }
+
+ private void deepCopyAssertions(DataObject sdo, DataObject copiedSdo)
+ {
+ //indent();
+
+ //System.out.println("checking objects of types: "
+ // + sdo.getType().getName() + ", "
+ // + copiedSdo.getType().getName());
+ indent++;
+
+ assertEquals(sdo.getType().getName(), copiedSdo.getType().getName());
+ assertEquals(sdo.getType().getURI(), copiedSdo.getType().getURI());
+ assertNotSame(sdo.getType(), copiedSdo.getType());
+ assertEquals(sdo.getInstanceProperties().size(), copiedSdo
+ .getInstanceProperties().size());
+
+ for(Iterator it = sdo.getInstanceProperties().iterator(), it2 = copiedSdo
+ .getInstanceProperties().iterator(); it.hasNext();)
+ {
+ Property p1 = (Property) it.next(), p2 = (Property) it2.next();
+ assertEquals(p1.getName(), p2.getName());
+ Object o1 = sdo.get(p1), o2 = copiedSdo.get(p2);
+ if(p1.getType().isDataType())
+ {
+ assertEquals(o1, o2);
+ // TODO is there a way I can distinguish between mutable and
+ // immutable types
+ // so that I can do some "same object" tests
+ }
+ else
+ {
+ assertNotSame(p1, p2);
+ if(p2.isMany())
+ {
+ assertEquals(sdo.getList(p1).size(), copiedSdo.getList(p2)
+ .size());
+ for(Iterator it3 = sdo.getList(p1).iterator(), it4 = copiedSdo
+ .getList(p2).iterator(); it3.hasNext();)
+ {
+ deepCopyAssertions((DataObject) it3.next(),
+ (DataObject) it4.next());
+ }
+ }
+ else
+ {
+ deepCopyAssertions(sdo.getDataObject(p1), copiedSdo
+ .getDataObject(p2));
+ }
+ }
+ try
+ {
+ sdo.get(p2);
+ assertTrue(false);
+ }
+ catch(Exception e)
+ {
+ // expected route
+ }
+ try
+ {
+ copiedSdo.get(p1);
+ assertTrue(false);
+ }
+ catch(Exception e2)
+ {
+ // expected route
+ }
+ }
+
+ indent--;
+ }
+
+ /*
+ private void indent()
+ {
+ for(int i=0; i <indent; i++) System.out.print(" ");
+ }
+ */
+
+ protected void constructSourceTree(DataFactory df)
+ {
+ // Create Instances
+ bankSDO = df.create(TEST_NAMESPACE, BANK_TYPE );
+ branchSDO1 = df.create(TEST_NAMESPACE, BRANCH_TYPE );
+ branchSDO2 = df.create(TEST_NAMESPACE, BRANCH_TYPE );
+ serviceSDO1 = df.create(TEST_NAMESPACE, SERVICE_TYPE );
+ serviceSDO2 = df.create(TEST_NAMESPACE, SERVICE_TYPE );
+ serviceSDO3 = df.create(TEST_NAMESPACE, SERVICE_TYPE );
+ customerSDO1 = df.create(TEST_NAMESPACE, CUSTOMER_TYPE );
+ customerSDO2 = df.create(TEST_NAMESPACE, CUSTOMER_TYPE );
+ customerSDO3 = df.create(TEST_NAMESPACE, CUSTOMER_TYPE );
+ customerSDO4 = df.create(TEST_NAMESPACE, CUSTOMER_TYPE );
+
+ // Populate the Bank Instance
+ bankSDO.set("name", "Fourth National");
+ Vector v = new Vector();
+ v.add(branchSDO1);
+ v.add(branchSDO2);
+ bankSDO.set("Branch",v);
+ v.removeAllElements();
+ v.add(serviceSDO1);
+ v.add(serviceSDO2);
+ v.add(serviceSDO3);
+ bankSDO.set("Service",v);
+ v.removeAllElements();
+ v.add(customerSDO1);
+ v.add(customerSDO2);
+ v.add(customerSDO3);
+ v.add(customerSDO4);
+ bankSDO.set("Customer",v);
+ v.removeAllElements();
+
+ // Populate Branch Instances
+ // Branch 1
+ branchSDO1.set("ID", "BR100");
+ DataObject addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE );
+ addr.set("Street", "1302 Money Street");
+ addr.set("City", "Apex");
+ addr.set("State", "NC");
+ addr.set("Zip", "27502");
+ branchSDO1.set("Address", addr);
+ v.add("If you are north, head south");
+ v.add("If you are south, head north");
+ branchSDO1.set("Directions", v);
+ v.removeAllElements();
+ DataObject account1 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE );
+ account1.set("ID", "0000 1200 0001");
+ account1.set("Service", serviceSDO1 );
+ account1.setBigDecimal("Balance", new BigDecimal("3124.12"));
+ v.add(account1);
+ DataObject account2 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE );
+ account2.set("ID", "0000 8899 0001");
+ account2.set("Service", serviceSDO1 );
+ account2.setBigDecimal("Balance", new BigDecimal("20.00"));
+ v.add(account2);
+ DataObject account3 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE );
+ account3.set("ID", "0000 3110 0020");
+ account3.set("Service", serviceSDO3 );
+ account3.setBigDecimal("Balance", new BigDecimal("5000.00"));
+ v.add(account3);
+ branchSDO1.set("Account", v);
+ v.removeAllElements();
+ // Branch 2
+ branchSDO2.set("ID", "BR200");
+ addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE );
+ addr.set("Street", "1207 Cash Court");
+ addr.set("City", "Raleigh");
+ addr.set("State", "NC");
+ addr.set("Zip", "27701");
+ branchSDO2.set("Address", addr);
+ v.add("If you are east, head west");
+ v.add("If you are west, head east");
+ branchSDO2.set("Directions", v);
+ v.removeAllElements();
+ DataObject account4 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE );
+ account4.set("ID", "0000 0011 0001");
+ account4.set("Service", serviceSDO1 );
+ account4.setBigDecimal("Balance", new BigDecimal("99.12"));
+ v.add(account4);
+ DataObject account5 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE );
+ account5.set("ID", "0000 9911 0001");
+ account5.set("Service", serviceSDO2 );
+ account5.setBigDecimal("Balance", new BigDecimal("820.00"));
+ v.add(account5);
+ DataObject account6 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE );
+ account6.set("ID", "0000 0001 0020");
+ account6.set("Service", serviceSDO3 );
+ account6.setBigDecimal("Balance", new BigDecimal("9000.00"));
+ v.add(account6);
+ branchSDO2.set("Account", v);
+ v.removeAllElements();
+
+ // Populate Service Instances
+ serviceSDO1.set("ID", "SRV01");
+ serviceSDO1.set("Name", "Checking");
+ serviceSDO1.setBigDecimal("Fee", new BigDecimal("0.00"));
+ serviceSDO2.set("ID", "SRV02");
+ serviceSDO2.set("Name", "Savings");
+ serviceSDO2.setBigDecimal("Fee", new BigDecimal("0.00"));
+ serviceSDO3.set("ID", "SRV03");
+ serviceSDO3.set("Name", "Loan");
+ serviceSDO3.setBigDecimal("Fee", new BigDecimal("0.00"));
+
+ // Populate Customer Instances
+ // Customer 1
+ customerSDO1.set("ID", "CUST01");
+ customerSDO1.set("First", "James");
+ customerSDO1.set("Last", "Madison");
+ addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE );
+ addr.set("Street", "1234 Easy Street");
+ addr.set("City", "New York");
+ addr.set("State", "NY");
+ addr.set("Zip", "27511");
+ customerSDO1.set("Address", addr);
+ customerSDO1.set("HomeBranch", branchSDO1);
+ v.add(account1);
+ customerSDO1.set("Account", v);
+ v.removeAllElements();
+ v.add(customerSDO2);
+ v.add(customerSDO3);
+ customerSDO1.set("Related", v);
+ v.removeAllElements();
+ // Customer 2
+ customerSDO2.set("ID", "CUST02");
+ customerSDO2.set("First", "George");
+ customerSDO2.set("Last", "Washington");
+ addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE );
+ addr.set("Street", "1776 Potomac Avenue");
+ addr.set("City", "Washington");
+ addr.set("State", "DC");
+ addr.set("Zip", "50555");
+ customerSDO2.set("Address", addr);
+ customerSDO2.set("HomeBranch", branchSDO1);
+ v.add(account2);
+ v.add(account3);
+ customerSDO2.set("Account", v);
+ v.removeAllElements();
+ // Customer 3
+ customerSDO3.set("ID", "CUST03");
+ customerSDO3.set("First", "Thomas");
+ customerSDO3.set("Last", "Jefferson");
+ addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE );
+ addr.set("Street", "1492 Columbus Avenue");
+ addr.set("City", "Charlottesville");
+ addr.set("State", "VA");
+ addr.set("Zip", "20121");
+ customerSDO3.set("Address", addr);
+ customerSDO3.set("HomeBranch", branchSDO2);
+ v.add(account4);
+ customerSDO3.set("Account", v);
+ v.removeAllElements();
+ // Customer 4
+ customerSDO4.set("ID", "CUST04");
+ customerSDO4.set("First", "Benjamin");
+ customerSDO4.set("Last", "Franklin");
+ addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE );
+ addr.set("Street", "99 Light Street");
+ addr.set("City", "Philadelphia");
+ addr.set("State", "PA");
+ addr.set("Zip", "19251");
+ customerSDO4.set("Address", addr);
+ customerSDO4.set("HomeBranch", branchSDO2);
+ v.add(account5);
+ v.add(account6);
+ customerSDO4.set("Account", v);
+ v.removeAllElements();
+
+ }
+
+ private void populateScopeWithDynamicTypes(TypeHelper scope)
+ {
+ Type stringType = scope.getType("commonj.sdo", "String");
+ DataObject customerType = DataFactory.INSTANCE.create("commonj.sdo", "Type");
+ customerType.set("uri", TEST_NAMESPACE);
+ customerType.set("name", DYNAMIC_TYPE );
+ DataObject custNumProperty = customerType.createDataObject("property");
+ custNumProperty.set("name", "custNum");
+ custNumProperty.set("type", stringType);
+ DataObject firstNameProperty = customerType.createDataObject("property");
+ firstNameProperty.set("name", "firstName");
+ firstNameProperty.set("type", stringType);
+ DataObject lastNameProperty = customerType.createDataObject("property");
+ lastNameProperty.set("name", "lastName");
+ lastNameProperty.set("type", stringType);
+ scope.define(customerType);
+ }
+
+ /*
+ private void dumpObject(DataObject sdo, String node )
+ {
+ try
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ SDOUtil.createXMLHelper(scopeA).save(sdo, TEST_NAMESPACE,
+ node, baos);
+ System.out.println(baos.toString());
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ */
+}
diff --git a/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java new file mode 100644 index 0000000000..a49b165386 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java @@ -0,0 +1,68 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.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/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DateConversionTestCase.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DateConversionTestCase.java new file mode 100644 index 0000000000..ca345eb241 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DateConversionTestCase.java @@ -0,0 +1,366 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.test; + +import java.lang.reflect.Method; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +import junit.framework.TestCase; + +import commonj.sdo.helper.DataHelper; + +// DateConversionTestCase insures that the DataHelper conversions accurately +// retain the information in the specified fields (e.g. month, day or year). +// It also provides coverage for the DataHelper API. +// Note that toDate is called each time Test.initialize() is called. + +public class DateConversionTestCase extends TestCase +{ + private static Calendar test_calendar; + private static Date test_date; + private static DataHelper data_helper; + + private static final TestType TO_DATE_TIME = new TestType("toDateTime", new int [] {Calendar.YEAR, Calendar.MONTH, + Calendar.DAY_OF_MONTH, Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND}); + private static final TestType TO_DURATION = new TestType("toDuration", new int [] {Calendar.YEAR, Calendar.MONTH, + Calendar.DAY_OF_MONTH, Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND}); + private static final TestType TO_TIME = new TestType("toTime", new int [] {Calendar.HOUR_OF_DAY, Calendar.MINUTE, + Calendar.SECOND, Calendar.MILLISECOND}); + private static final TestType TO_DAY = new TestType("toDay", new int[] {Calendar.DAY_OF_MONTH}); + private static final TestType TO_MONTH = new TestType("toMonth", new int[] {Calendar.MONTH}); + private static final TestType TO_MONTH_DAY = new TestType("toMonthDay", new int[] {Calendar.MONTH, Calendar.DAY_OF_MONTH}); + private static final TestType TO_YEAR = new TestType("toYear", new int[] {Calendar.YEAR}); + private static final TestType TO_YEAR_MONTH= new TestType("toYearMonth", new int[] {Calendar.YEAR, Calendar.MONTH}); + private static final TestType TO_YEAR_MONTH_DAY = new TestType("toYearMonthDay", new int[] {Calendar.YEAR, + Calendar.MONTH, Calendar.DAY_OF_MONTH}); + + public DateConversionTestCase() throws Exception + { + data_helper = DataHelper.INSTANCE; + test_calendar = new GregorianCalendar(); + test_calendar.setTime(new Date(System.currentTimeMillis())); + test_date = test_calendar.getTime(); + } + + private static class TestType + { + private static final Class[] DATE_CLASS_ARRAY = {Date.class}; + private static final Class[] CALENDAR_CLASS_ARRAY = {Calendar.class}; + + Method date_method; + Method calendar_method; + int [] compare_fields; + + public TestType (String method_name, int [] compare_fields) + { + try + { + this.date_method = DataHelper.class.getMethod(method_name, DATE_CLASS_ARRAY); + } + catch (NoSuchMethodException e) + { + this.date_method = null; + } + + this.compare_fields = compare_fields; + try + { + this.calendar_method = DataHelper.class.getMethod(method_name, CALENDAR_CLASS_ARRAY); + } + catch (NoSuchMethodException e) + { + this.calendar_method = null; + } + + } + + public Method getDateMethod() + { + return this.date_method; + } + + public Method getCalendarMethod() + { + return this.calendar_method; + } + } + + private static class Test + { + String from_type; + Date from_date; + Calendar from_calendar; + Class expected_exception; + + public Test () + { + this.from_date = null; + this.from_calendar = null; + expected_exception = null; + } + + public void initialize (TestType from_type) + { + this.from_type = from_type.getDateMethod().getName(); + + try + { + String date_string = (String) from_type.getDateMethod().invoke(data_helper, new Object[] {test_date}); + this.from_date = data_helper.toDate(date_string); + date_string = (String) from_type.getCalendarMethod().invoke(data_helper, new Object[] {test_calendar}); + this.from_calendar = data_helper.toCalendar(date_string); + } + catch (Exception e) + { + this.from_date = null; + this.from_calendar = null; + } + + } + + // This method is needed because there is not a toDate(Date) method in DataHelper. + + public void initializeToDate() + { + this.from_calendar = test_calendar; + this.from_date = test_date; + this.from_type = "toDate"; + } + + public void attemptConversion (TestType to_type) throws Exception + { + executeConversion(to_type.getDateMethod(), new Object[] {this.from_date}, to_type.compare_fields); + executeConversion(to_type.getCalendarMethod(), new Object[] {this.from_calendar}, to_type.compare_fields); + } + + private void executeConversion (Method conversion, Object[] parm, int [] compare_fields) throws Exception + { + String result; + + try + { + result = (String) conversion.invoke(data_helper, parm); + } + catch (Exception e) + { + System.err.println("An unexpected exception was thrown while calling " + conversion.getName() + + " after initializing with " + this.from_type + "."); + throw e; + } + + assertTrue("The expected value did not result when calling " + conversion.getName() + + " after initializing with " + this.from_type + ".", compareFields(parm[0], result, compare_fields)); + } + + private boolean compareFields(Object compare_to, String output, int [] compare_fields) + { + Calendar result = data_helper.toCalendar(output); + Calendar expected; + + if (compare_to instanceof Calendar) + expected = (GregorianCalendar) test_calendar; + else + { + expected = new GregorianCalendar(); + expected.setTime((Date) test_date); + } + + for (int i = 0; i < compare_fields.length; i++) + { + if (expected.get(compare_fields[i]) != result.get(compare_fields[i])) + return false; + } + return true; + } + + } + + /* + public void testConversionsFromDay() throws Exception + { + Test FromDay = new Test(); + + FromDay.initialize(TO_DAY); + + FromDay.attemptConversion(TO_DAY); + } + + public void testConversionsFromDate() throws Exception + { + Test FromDate = new Test(); + + FromDate.initializeToDate(); + + FromDate.attemptConversion(TO_DATE_TIME); + FromDate.attemptConversion(TO_DURATION); + FromDate.attemptConversion(TO_TIME); + FromDate.attemptConversion(TO_DAY); + FromDate.attemptConversion(TO_MONTH); + FromDate.attemptConversion(TO_MONTH_DAY); + FromDate.attemptConversion(TO_YEAR); + FromDate.attemptConversion(TO_YEAR_MONTH); + FromDate.attemptConversion(TO_YEAR_MONTH_DAY); + } + + public void testConversionsFromDateTime() throws Exception + { + Test FromDateTime = new Test(); + + FromDateTime.initialize(TO_DATE_TIME); + + FromDateTime.attemptConversion(TO_DATE_TIME); + FromDateTime.attemptConversion(TO_DURATION); + FromDateTime.attemptConversion(TO_TIME); + FromDateTime.attemptConversion(TO_DAY); + FromDateTime.attemptConversion(TO_MONTH); + FromDateTime.attemptConversion(TO_MONTH_DAY); + FromDateTime.attemptConversion(TO_YEAR); + FromDateTime.attemptConversion(TO_YEAR_MONTH); + FromDateTime.attemptConversion(TO_YEAR_MONTH_DAY); + } + + public void testConversionsFromDuration() throws Exception + { + Test FromDuration = new Test(); + + FromDuration.initialize(TO_DURATION); + + FromDuration.attemptConversion(TO_DURATION); + FromDuration.attemptConversion(TO_DATE_TIME); + FromDuration.attemptConversion(TO_TIME); + FromDuration.attemptConversion(TO_DAY); + FromDuration.attemptConversion(TO_MONTH); + FromDuration.attemptConversion(TO_MONTH_DAY); + FromDuration.attemptConversion(TO_YEAR); + FromDuration.attemptConversion(TO_YEAR_MONTH); + FromDuration.attemptConversion(TO_YEAR_MONTH_DAY); + } + + public void testConversionsFromMonth() throws Exception + { + Test FromMonth = new Test(); + + FromMonth.initialize(TO_MONTH); + + FromMonth.attemptConversion(TO_MONTH); + } + + public void testConversionsFromMonthDay() throws Exception + { + Test FromMonthDay = new Test(); + + FromMonthDay.initialize(TO_MONTH_DAY); + FromMonthDay.attemptConversion(TO_MONTH_DAY); + FromMonthDay.attemptConversion(TO_MONTH); + FromMonthDay.attemptConversion(TO_DAY); + } + + public void testConversionsFromTime() throws Exception + { + Test FromTime = new Test(); + + FromTime.initialize(TO_TIME); + + FromTime.attemptConversion(TO_TIME); + } + + public void testConversionsFromYear() throws Exception + { + Test FromYear = new Test(); + + FromYear.initialize(TO_YEAR); + + FromYear.attemptConversion(TO_YEAR); + } + + public void testConversionsFromYearMonth() throws Exception + { + Test FromYearMonth = new Test(); + + FromYearMonth.initialize(TO_YEAR_MONTH); + + FromYearMonth.attemptConversion(TO_YEAR_MONTH); + FromYearMonth.attemptConversion(TO_MONTH); + FromYearMonth.attemptConversion(TO_YEAR); + } + + public void testConversionsFromYearMonthDay() throws Exception + { + Test FromYearMonthDay = new Test(); + + FromYearMonthDay.initialize(TO_YEAR_MONTH_DAY); + + FromYearMonthDay.attemptConversion(TO_YEAR_MONTH_DAY); + FromYearMonthDay.attemptConversion(TO_YEAR_MONTH); + FromYearMonthDay.attemptConversion(TO_MONTH_DAY); + FromYearMonthDay.attemptConversion(TO_YEAR); + FromYearMonthDay.attemptConversion(TO_MONTH); + FromYearMonthDay.attemptConversion(TO_DAY); + } + */ + + // Ensure that strings that should be recognized by toDate do not + // result in a null Date value. + + public void testToDateFormats() throws Exception + { + String[] validStrings = + { + "2006-03-31T03:30:45.123Z", + "-2006-03-31T03:30:45.1Z", + "2006-03-31T03:30:45Z", + "2006-03-31T03:30:45.123", + "2006-03-31T03:30:45.1", + "-2006-03-31T03:30:45", + "2006-03-31T03:30:45.123 EDT", + "2006-03-31T03:30:45.1 EDT", + "2006-03-31T03:30:45 EDT", + "---05 PST", + "---04", + "--12 GMT", + "--12", + "--08-08 EST", + "--08-08", + "1976-08-08 PDT", + "1976-08-08", + "88-12 CST", + "1988-12", + "2005 CDT", + "1999", + "P2006Y 08M 10D T 12H 24M 07S", + "P2006Y 10D T 12H", + "-P2006Y 08M 10D T 07S.2", + "P08M 10D T 07H", + "-P 04M 10DT12H 24S.88", + "PT12H" + }; + + for (int i = 0; i < validStrings.length; i++) + { + assertNotNull("DataHelper.toData() should not return null for '" + validStrings[i] + "'.", + data_helper.toDate(validStrings[i])); + } + + } + +} + diff --git a/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineOpenContentPropertyTestCase.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineOpenContentPropertyTestCase.java new file mode 100644 index 0000000000..b86555cb5c --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineOpenContentPropertyTestCase.java @@ -0,0 +1,122 @@ +/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.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 org.apache.tuscany.sdo.util.SDOUtil;
+
+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 DefineOpenContentPropertyTestCase extends TestCase {
+ private final String TEST_MODEL = "/open.xsd";
+ private final String TEST_NAMESPACE = "http://www.example.com/open";
+ private final String TEST_DATA = "/openContentProperty.xml";
+
+ private TypeHelper typeHelper;
+ private XSDHelper xsdHelper;
+ private XMLHelper xmlHelper;
+ private DataFactory dataFactory;
+
+ public void testDefineOpenContentProperty() throws IOException {
+ Type quoteType = typeHelper.getType(TEST_NAMESPACE, "OpenQuote");
+ DataObject quote = dataFactory.create(quoteType);
+
+ quote.setString("symbol", "s1");
+
+ Property companyProperty = typeHelper.getOpenContentProperty(TEST_NAMESPACE, "company");
+ DataObject company = quote.createDataObject(companyProperty);
+ company.setString("name", "FlyByNightTechnology");
+
+ Property priceProperty = typeHelper.getOpenContentProperty(TEST_NAMESPACE, "price");
+ quote.getList(priceProperty).add(new BigDecimal("1000.0"));
+
+ // Define a new SDO open content property with simple type
+ DataObject p = dataFactory.create("commonj.sdo", "Property");
+ p.set("type", typeHelper.getType("commonj.sdo", "Decimal"));
+ p.set("name", "highPrice");
+ Property highPrice = typeHelper.defineOpenContentProperty(TEST_NAMESPACE, p);
+
+ quote.setBigDecimal(highPrice, new BigDecimal("1100.0"));
+
+ // Define a new SDO open content property with complex type
+ DataObject mutualFundQuotePropertyDef = dataFactory.create("commonj.sdo", "Property");
+ mutualFundQuotePropertyDef.set("type", quoteType);
+ mutualFundQuotePropertyDef.set("name", "mutualFundQuote");
+ mutualFundQuotePropertyDef.setBoolean("containment", true);
+ Property mutualFundQuoteProperty = typeHelper.defineOpenContentProperty(TEST_NAMESPACE, mutualFundQuotePropertyDef);
+
+ DataObject mutualFundQuote = quote.createDataObject(mutualFundQuoteProperty);
+ mutualFundQuote.setString("symbol", "mutual-1");
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ xmlHelper.save(quote, TEST_NAMESPACE, "openStockQuote", baos);
+
+ assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(TEST_DATA)));
+
+ // validate existing property condition
+ Property duplicateProp = typeHelper.defineOpenContentProperty(TEST_NAMESPACE, p);
+ assertTrue(highPrice.equals(duplicateProp));
+
+ // validate error condition, where new property exists with different type
+ boolean errorCondition = false;
+ try
+ {
+ p = dataFactory.create("commonj.sdo", "Property");
+ p.set("type", typeHelper.getType("commonj.sdo", "String"));
+ p.set("name", "highPrice");
+ highPrice = typeHelper.defineOpenContentProperty(TEST_NAMESPACE, p);
+ }
+ catch( IllegalArgumentException ex )
+ {
+ errorCondition = true;
+ }
+ assertTrue(errorCondition);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ typeHelper = SDOUtil.createTypeHelper();
+ xsdHelper = SDOUtil.createXSDHelper(typeHelper);
+ xmlHelper = SDOUtil.createXMLHelper(typeHelper);
+ dataFactory = SDOUtil.createDataFactory(typeHelper);
+
+ // Populate the meta data for the test (Stock Quote) model
+ URL url = getClass().getResource(TEST_MODEL);
+ InputStream inputStream = url.openStream();
+ xsdHelper.define(inputStream, url.toString());
+ inputStream.close();
+ }
+}
diff --git a/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java new file mode 100644 index 0000000000..602aee98a5 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java @@ -0,0 +1,626 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.test; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.math.BigDecimal; + +import junit.framework.TestCase; + +import org.apache.tuscany.sdo.util.SDOUtil; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Sequence; +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; + +public class DefineTypeTestCase extends TestCase +{ + private static final String CUSTOMER1_XML = "/customer1.xml"; + private static final String CUSTOMER2_XML = "/customer2.xml"; + private static final String OPEN_XML = "/open2.xml"; + private static final String MIXED_XML = "/mixed2.xml"; + private static final String MIXEDOPEN_XML = "/mixedopen.xml"; + + public void testDefineTypeRoundTrip() throws Exception { + TypeHelper types = SDOUtil.createTypeHelper(); + DataFactory factory = SDOUtil.createDataFactory(types); + XMLHelper xmlHelper = SDOUtil.createXMLHelper(types); + + Type intType = types.getType("commonj.sdo", "Int"); + Type stringType = types.getType("commonj.sdo", "String"); + + // create a new Type for Customers + DataObject customerType = factory.create("commonj.sdo", + "Type"); + customerType.set("uri", "http://example.com/customer"); + customerType.set("name", "Customer"); + + // create a customer number property + DataObject custNumProperty = customerType.createDataObject("property"); + custNumProperty.set("name", "custNum"); + custNumProperty.set("type", intType); + + // create a first name property + DataObject firstNameProperty = + customerType.createDataObject("property"); + firstNameProperty.set("name", "firstName"); + firstNameProperty.set("type", stringType); + + // create a last name property + DataObject lastNameProperty = customerType.createDataObject("property"); + lastNameProperty.set("name", "lastName"); + lastNameProperty.set("type", stringType); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + xmlHelper.save(customerType, "commonj.sdo", "type", baos); + + ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); + XMLDocument xdoc = xmlHelper.load(bais); + + customerType = xdoc.getRootObject(); + + // now define the Customer type so that customers can be made + types.define(customerType); + + DataObject customer1 = factory.create("http://example.com/customer", + "Customer"); + + customer1.setInt("custNum", 1); + customer1.set("firstName", "John"); + customer1.set("lastName", "Adams"); + DataObject customer2 = factory.create("http://example.com/customer", + "Customer"); + customer2.setInt("custNum", 2); + customer2.set("firstName", "Jeremy"); + customer2.set("lastName", "Pavick"); + + assertNotNull(customer1); + Type type = customer1.getType(); + assertNotNull(type.getProperty("custNum")); + assertNotNull(type.getProperty("firstName")); + assertNotNull(type.getProperty("lastName")); + assertEquals(type.getProperty("custNum").getType(), intType); + assertEquals(type.getProperty("firstName").getType(), stringType); + assertEquals(type.getProperty("lastName").getType(), stringType); + + assertNotNull(customer2); + type = customer2.getType(); + assertNotNull(type.getProperty("custNum")); + assertNotNull(type.getProperty("firstName")); + assertNotNull(type.getProperty("lastName")); + assertEquals(type.getProperty("custNum").getType(), intType); + assertEquals(type.getProperty("firstName").getType(), stringType); + assertEquals(type.getProperty("lastName").getType(), stringType); + + baos = new ByteArrayOutputStream(); + xmlHelper.save( + customer1, + "http://example.com/customer", + "Customer", baos); + assertTrue( + TestUtil.equalXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(CUSTOMER1_XML))); + + baos = new ByteArrayOutputStream(); + xmlHelper.save( + customer2, + "http://example.com/customer", + "Customer", baos); + assertTrue( + TestUtil.equalXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(CUSTOMER2_XML))); + } + + public void testDefineType() throws Exception + { + TypeHelper types = SDOUtil.createTypeHelper(); + DataFactory factory = SDOUtil.createDataFactory(types); + XMLHelper xmlHelper = SDOUtil.createXMLHelper(types); + + Type intType = types.getType("commonj.sdo", "Int"); + Type stringType = types.getType("commonj.sdo", "String"); + + // create a new Type for Customers + DataObject customerType = factory.create("commonj.sdo", + "Type"); + customerType.set("uri", "http://example.com/customer"); + customerType.set("name", "Customer"); + + // create a customer number property + DataObject custNumProperty = customerType.createDataObject("property"); + custNumProperty.set("name", "custNum"); + custNumProperty.set("type", intType); + + // create a first name property + DataObject firstNameProperty = + customerType.createDataObject("property"); + firstNameProperty.set("name", "firstName"); + firstNameProperty.set("type", stringType); + + // create a last name property + DataObject lastNameProperty = customerType.createDataObject("property"); + lastNameProperty.set("name", "lastName"); + lastNameProperty.set("type", stringType); + + // now define the Customer type so that customers can be made + types.define(customerType); + + DataObject customer1 = factory.create("http://example.com/customer", + "Customer"); + customer1.setInt("custNum", 1); + customer1.set("firstName", "John"); + customer1.set("lastName", "Adams"); + DataObject customer2 = factory.create("http://example.com/customer", + "Customer"); + customer2.setInt("custNum", 2); + customer2.set("firstName", "Jeremy"); + customer2.set("lastName", "Pavick"); + + assertNotNull(customer1); + Type type = customer1.getType(); + assertNotNull(type.getProperty("custNum")); + assertNotNull(type.getProperty("firstName")); + assertNotNull(type.getProperty("lastName")); + assertEquals(type.getProperty("custNum").getType(), intType); + assertEquals(type.getProperty("firstName").getType(), stringType); + assertEquals(type.getProperty("lastName").getType(), stringType); + + assertNotNull(customer2); + type = customer2.getType(); + assertNotNull(type.getProperty("custNum")); + assertNotNull(type.getProperty("firstName")); + assertNotNull(type.getProperty("lastName")); + assertEquals(type.getProperty("custNum").getType(), intType); + assertEquals(type.getProperty("firstName").getType(), stringType); + assertEquals(type.getProperty("lastName").getType(), stringType); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + xmlHelper.save( + customer1, + "http://example.com/customer", + "Customer", baos); + assertTrue( + TestUtil.equalXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(CUSTOMER1_XML))); + + baos = new ByteArrayOutputStream(); + xmlHelper.save( + customer2, + "http://example.com/customer", + "Customer", baos); + assertTrue( + TestUtil.equalXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(CUSTOMER2_XML))); + } + + public void testDefineDataType() throws Exception + { + TypeHelper types = SDOUtil.createTypeHelper(); + DataFactory factory = SDOUtil.createDataFactory(types); + XSDHelper xsdHelper = SDOUtil.createXSDHelper(types); + XMLHelper xmlHelper = SDOUtil.createXMLHelper(types); + + Property javaClassProperty = xsdHelper.getGlobalProperty("commonj.sdo/java", "javaClass", false); + + // create a data types + DataObject intType = factory.create("commonj.sdo", "Type"); + intType.set("uri", "http://example.com/customer"); + intType.set("name", "MyIntType"); + intType.setBoolean("dataType", true); + intType.set(javaClassProperty, "int"); + + DataObject stringType = factory.create("commonj.sdo", "Type"); + stringType.set("uri", "http://example.com/customer"); + stringType.set("name", "MyStringType"); + stringType.setBoolean("dataType", true); + stringType.set(javaClassProperty, "java.lang.String"); + + // create a new Type for Customers + DataObject customerType = factory.create("commonj.sdo", + "Type"); + customerType.set("uri", "http://example.com/customer"); + customerType.set("name", "Customer"); + + // create a customer number property + DataObject custNumProperty = customerType.createDataObject("property"); + custNumProperty.set("name", "custNum"); + custNumProperty.set("type", intType); + + // create a first name property + DataObject firstNameProperty = + customerType.createDataObject("property"); + firstNameProperty.set("name", "firstName"); + firstNameProperty.set("type", stringType); + + // create a last name property + DataObject lastNameProperty = customerType.createDataObject("property"); + lastNameProperty.set("name", "lastName"); + lastNameProperty.set("type", stringType); + + // now define the Customer type so that customers can be made + types.define(customerType); + + DataObject customer1 = factory.create("http://example.com/customer", + "Customer"); + + customer1.setInt("custNum", 1); + customer1.set("firstName", "John"); + customer1.set("lastName", "Adams"); + DataObject customer2 = factory.create("http://example.com/customer", + "Customer"); + customer2.setInt("custNum", 2); + customer2.set("firstName", "Jeremy"); + customer2.set("lastName", "Pavick"); + + assertNotNull(customer1); + Type type = customer1.getType(); + assertNotNull(type.getProperty("custNum")); + assertNotNull(type.getProperty("firstName")); + assertNotNull(type.getProperty("lastName")); + assertNotNull(type.getProperty("custNum")); + assertNotNull(type.getProperty("firstName")); + assertNotNull(type.getProperty("lastName")); + + type = type.getProperty("custNum").getType(); + assertEquals(type.getURI(), "http://example.com/customer"); + assertEquals(type.getName(), "MyIntType"); + assertTrue(type.isDataType()); + + assertNotNull(customer2); + type = customer2.getType(); + assertNotNull(type.getProperty("custNum")); + assertNotNull(type.getProperty("firstName")); + assertNotNull(type.getProperty("lastName")); + assertNotNull(type.getProperty("custNum")); + assertNotNull(type.getProperty("firstName")); + assertNotNull(type.getProperty("lastName")); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + xmlHelper.save( + customer1, + "http://example.com/customer", + "Customer", baos); + assertTrue( + TestUtil.equalXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(CUSTOMER1_XML))); + + baos = new ByteArrayOutputStream(); + xmlHelper.save( + customer2, + "http://example.com/customer", + "Customer", baos); + assertTrue( + TestUtil.equalXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(CUSTOMER2_XML))); + } + + public void testFastDefineType() throws Exception + { + TypeHelper types = SDOUtil.createTypeHelper(); + DataFactory factory = SDOUtil.createDataFactory(types); + XMLHelper xmlHelper = SDOUtil.createXMLHelper(types); + + Type intType = types.getType("commonj.sdo", "Int"); + Type stringType = types.getType("commonj.sdo", "String"); + + // create a new Type for Customers + Type customerType = SDOUtil.createType(types, "http://example.com/customer", "Customer", false); + + // create a customer number property + SDOUtil.createProperty(customerType, "custNum", intType); + + // create a first name property + SDOUtil.createProperty(customerType, "firstName", stringType); + + // create a last name property + SDOUtil.createProperty(customerType, "lastName", stringType); + + DataObject customer1 = factory.create("http://example.com/customer", + "Customer"); + customer1.setInt("custNum", 1); + customer1.set("firstName", "John"); + customer1.set("lastName", "Adams"); + DataObject customer2 = factory.create("http://example.com/customer", + "Customer"); + customer2.setInt("custNum", 2); + customer2.set("firstName", "Jeremy"); + customer2.set("lastName", "Pavick"); + + assertNotNull(customer1); + Type type = customer1.getType(); + assertNotNull(type.getProperty("custNum")); + assertNotNull(type.getProperty("firstName")); + assertNotNull(type.getProperty("lastName")); + assertEquals(type.getProperty("custNum").getType(), intType); + assertEquals(type.getProperty("firstName").getType(), stringType); + assertEquals(type.getProperty("lastName").getType(), stringType); + + assertNotNull(customer2); + type = customer2.getType(); + assertNotNull(type.getProperty("custNum")); + assertNotNull(type.getProperty("firstName")); + assertNotNull(type.getProperty("lastName")); + assertEquals(type.getProperty("custNum").getType(), intType); + assertEquals(type.getProperty("firstName").getType(), stringType); + assertEquals(type.getProperty("lastName").getType(), stringType); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + xmlHelper.save( + customer1, + "http://example.com/customer", + "Customer", baos); + assertTrue( + TestUtil.equalXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(CUSTOMER1_XML))); + + baos = new ByteArrayOutputStream(); + xmlHelper.save( + customer2, + "http://example.com/customer", + "Customer", baos); + assertTrue( + TestUtil.equalXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(CUSTOMER2_XML))); + } + + public void testDefineSequencedType() throws Exception + { + + TypeHelper types = SDOUtil.createTypeHelper(); + DataFactory factory = SDOUtil.createDataFactory(types); + XMLHelper xmlHelper = SDOUtil.createXMLHelper(types); + + Type stringType = types.getType("commonj.sdo", "String"); + Type decimalType = types.getType("commonj.sdo", "Decimal"); + + // Define a new mixed type - MixedQuote + DataObject mixedQuoteType = factory.create("commonj.sdo", "Type"); + mixedQuoteType.set("uri", "http://www.example.com/mixed"); + mixedQuoteType.set("name", "MixedQuote"); + mixedQuoteType.set("sequenced", Boolean.TRUE); + + DataObject symbolProperty = mixedQuoteType.createDataObject("property"); + symbolProperty.set("name", "symbol"); + symbolProperty.set("type", stringType); + + DataObject companyNameProperty = mixedQuoteType.createDataObject("property"); + companyNameProperty.set("name", "companyName"); + companyNameProperty.set("type", stringType); + + DataObject priceProperty = mixedQuoteType.createDataObject("property"); + priceProperty.set("name", "price"); + priceProperty.set("type", decimalType); + + DataObject quotesProperty = mixedQuoteType.createDataObject("property"); + quotesProperty.set("name", "quotes"); + quotesProperty.set("type", mixedQuoteType); + quotesProperty.set("many", Boolean.TRUE); + quotesProperty.set("containment", Boolean.TRUE); + + types.define(mixedQuoteType); + + DataObject quote = factory.create("http://www.example.com/mixed", "MixedQuote"); + + assertTrue(quote.getType().isSequenced()); + + 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.save(quote, "http://www.example.com/mixed", "mixedStockQuote", baos); + assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(MIXED_XML))); + } + + public void testDefineSequencedOpenType() throws Exception + { + + TypeHelper types = SDOUtil.createTypeHelper(); + DataFactory factory = SDOUtil.createDataFactory(types); + XMLHelper xmlHelper = SDOUtil.createXMLHelper(types); + + Type stringType = types.getType("commonj.sdo", "String"); + Type decimalType = types.getType("commonj.sdo", "Decimal"); + + // Define a new mixed type - MixedQuote + DataObject mixedQuoteType = factory.create("commonj.sdo", "Type"); + mixedQuoteType.set("uri", "http://www.example.com/mixed"); + mixedQuoteType.set("name", "MixedOpenQuote"); + mixedQuoteType.set("sequenced", Boolean.TRUE); + mixedQuoteType.set("open", Boolean.TRUE); + +// DataObject symbolProperty = mixedQuoteType.createDataObject("property"); +// symbolProperty.set("name", "symbol"); +// symbolProperty.set("type", stringType); + + DataObject companyNameProperty = mixedQuoteType.createDataObject("property"); + companyNameProperty.set("name", "companyName"); + companyNameProperty.set("type", stringType); + + DataObject priceProperty = mixedQuoteType.createDataObject("property"); + priceProperty.set("name", "price"); + priceProperty.set("type", decimalType); + + DataObject quotesProperty = mixedQuoteType.createDataObject("property"); + quotesProperty.set("name", "quotes"); + quotesProperty.set("type", mixedQuoteType); + quotesProperty.set("many", Boolean.TRUE); + quotesProperty.set("containment", Boolean.TRUE); + + types.define(mixedQuoteType); + + // Define a global type + DataObject globalType = factory.create("commonj.sdo", "Type"); + globalType.set("uri", "http://www.example.com/open"); + // Don't set the type's name - null is used for types containing global properties. + + DataObject symbolProperty = globalType.createDataObject("property"); + symbolProperty.set("name", "symbol"); + symbolProperty.set("type", stringType); + symbolProperty.set("containment", Boolean.TRUE); + + types.define(globalType); + + DataObject quote = factory.create("http://www.example.com/mixed", "MixedOpenQuote"); + + assertTrue(quote.getType().isSequenced()); + + Sequence sequence = quote.getSequence(); + + sequence.add("\n "); + + Type definedGlobalType = types.getType("http://www.example.com/open", null); + + Property definedSymbolProperty = definedGlobalType.getProperty("symbol"); + quote.setString(definedSymbolProperty, "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.save(quote, "http://www.example.com/mixed", "mixedOpenStockQuote", baos); + assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(MIXEDOPEN_XML))); + } + + + public void testDefineOpenType() throws Exception + { + TypeHelper types = SDOUtil.createTypeHelper(); + DataFactory factory = SDOUtil.createDataFactory(types); + XMLHelper xmlHelper = SDOUtil.createXMLHelper(types); + + Type stringType = types.getType("commonj.sdo", "String"); + Type decimalType = types.getType("commonj.sdo", "Decimal"); + + // Define a new open type - OpenQuote + DataObject openQuoteType = factory.create("commonj.sdo", "Type"); + openQuoteType.set("uri", "http://www.example.com/open"); + openQuoteType.set("name", "OpenQuote"); + openQuoteType.set("open", Boolean.TRUE); + openQuoteType.setBoolean("open", true); + + types.define(openQuoteType); + + // Define new type - CompanyType + DataObject companyType = factory.create("commonj.sdo", "Type"); + companyType.set("uri", "http://www.example.com/open"); + companyType.set("name", "CompanyType"); + + // Create CompanyType property - "name" + DataObject nameProperty = companyType.createDataObject("property"); + nameProperty.set("name", "name"); + nameProperty.set("type", stringType); + nameProperty.set("containment", Boolean.TRUE); + + types.define(companyType); + + // Define open content property - company + DataObject symbolProperty = factory.create("commonj.sdo", "Property"); + symbolProperty.set("name", "symbol"); + symbolProperty.set("type", stringType); + types.defineOpenContentProperty("http://www.example.com/open", symbolProperty); + + // Define open content property - company + DataObject companyProperty = factory.create("commonj.sdo", "Property"); + companyProperty.set("name", "company"); + companyProperty.set("type", companyType); + companyProperty.set("containment", Boolean.TRUE); + types.defineOpenContentProperty("http://www.example.com/open", companyProperty); + + // Define open content property - price + DataObject priceProperty = factory.create("commonj.sdo", "Property"); + priceProperty.set("name", "price"); + priceProperty.set("type", decimalType); + types.defineOpenContentProperty("http://www.example.com/open", priceProperty); + + // Create DataObject instances + DataObject openQuote = factory.create("http://www.example.com/open", "OpenQuote"); + assertTrue(openQuote.getType().isOpen()); + + Property definedSymbolProperty = types.getOpenContentProperty("http://www.example.com/open", "symbol"); + openQuote.set(definedSymbolProperty, "s1"); + + Property definedCompanyProperty = types.getOpenContentProperty("http://www.example.com/open", "company"); + DataObject company = openQuote.createDataObject(definedCompanyProperty); + company.setString("name", "FlyByNightTechnology"); + + Property definedPriceProperty = types.getOpenContentProperty("http://www.example.com/open", "price"); + openQuote.setBigDecimal(definedPriceProperty, new BigDecimal("1000.0")); + + assertEquals(definedPriceProperty.getType(), decimalType); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + xmlHelper.save( + openQuote, + "http://www.example.com/open", + "openStockQuote", baos); + assertTrue( + TestUtil.equalXmlFiles( + new ByteArrayInputStream(baos.toByteArray()), + getClass().getResource(OPEN_XML))); + } + +} diff --git a/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/IsManyTestCase.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/IsManyTestCase.java new file mode 100644 index 0000000000..1eef4ea657 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/IsManyTestCase.java @@ -0,0 +1,65 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.test; + +import java.io.InputStream; +import java.net.URL; + +import org.apache.tuscany.sdo.util.SDOUtil; + +import junit.framework.TestCase; + +import commonj.sdo.*; +import commonj.sdo.helper.*; + +public class IsManyTestCase extends TestCase { + private final String TEST_MODEL = "/open.xsd"; + private final String TEST_MODEL1ANY = "/open1any.xsd"; + private final String TEST_NAMESPACE = "http://www.example.com/open"; + private final String TEST_NAMESPACE1ANY = "http://www.example.com/open1any"; + + public void testIsMany() { + Property priceProperty = XSDHelper.INSTANCE.getGlobalProperty(TEST_NAMESPACE, "price", true); + + Type quoteType = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "OpenQuote"); + DataObject quote = DataFactory.INSTANCE.create(quoteType); + assertTrue( SDOUtil.isMany(priceProperty, quote)); + + quoteType = TypeHelper.INSTANCE.getType(TEST_NAMESPACE1ANY, "OpenQuote"); + quote = DataFactory.INSTANCE.create(quoteType); + assertFalse( SDOUtil.isMany(priceProperty, quote)); + } + + 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(); + + // Populate the meta data for the test (Stock Quote) model with maxOccurs=1 <any> + url = getClass().getResource(TEST_MODEL1ANY); + inputStream = url.openStream(); + XSDHelper.INSTANCE.define(inputStream, url.toString()); + inputStream.close(); + } +}
\ No newline at end of file diff --git a/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/JiraTestCases.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/JiraTestCases.java new file mode 100644 index 0000000000..66138495ce --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/JiraTestCases.java @@ -0,0 +1,184 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ +package org.apache.tuscany.sdo.test; + +import java.util.List; + +import junit.framework.TestCase; +import commonj.sdo.*; +import commonj.sdo.helper.*; + +import org.apache.tuscany.sdo.util.SDOUtil; +import java.util.HashMap; + +/** + * The follow test cases are based upon code snipets in the SDO specification. + * They are also implemented as working samples in the sample-sdo artifact + * + * @author Robbie Minshall + * + */ +public class JiraTestCases extends TestCase { + + /** + * Bogus company namespace + */ + public static final String COMPANY_NAMESPACE = "company.xsd"; + + /** + * previously defined XSD file used + */ + public static final String COMPANY_XSD = "/company.xsd"; + + /** + * XML file containing DataGraph representing a company. This xml file + * conforms to the company model defined in 'Complete DataGraph for Company + * Example' section of the SDO specification + */ + public static final String COMPANY_DATAGRAPH_XML = "/companyDataGraphGenerated.xml"; + + /** + * Generated DataGraph + * {@link org.apache.tuscany.samples.sdo.company.CreateCompany} + */ + public static final String COMPANY_DATAOBJECT_XML = "/companyGenerated.xml"; + + /** + * Defines xsd resource contained within jar file for PurchaseOrder + * DataObject + */ + public static final String PO_XSD_RESOURCE = "/po.xsd"; + + /** + * Defines xml resource contained within jar file that is used to populate + * PurchaseOrder DataObjects + */ + public static final String PO_XML_RESOURCE = "/po.xml"; + + /** + * previously created XSD file used + */ + public static final String LETTER_XSD = "/letter.xsd"; + + /** + * JIRA Details : Add a method to SDOUtil to return all Types associated + * with a specific URI + */ + public void test_TUSCANY583() { + + // define some types + try { + XSDHelper.INSTANCE.define(getClass().getResourceAsStream( + PO_XSD_RESOURCE), null); + + XSDHelper.INSTANCE.define(getClass().getResourceAsStream( + COMPANY_XSD), null); + + createDynamicType(); + + String[] expectedPoTypeNames = {"item", "Items", + "PurchaseOrderType", "quantity", "SKU", "USAddress"}; + + String[] expectedCompanyTypeNames = {"EmployeeType", "DepartmentType", "CompanyType"}; + + String[] expectedCustomerTypeNames = {"Customer"}; + + confirmTypes("http://www.example.com/PO", expectedPoTypeNames); + confirmTypes("company.xsd", expectedCompanyTypeNames); + confirmTypes("http://example.com/customer", + expectedCustomerTypeNames); + + } catch (Exception e) { + fail("Unexpected error " + e.toString()); + e.printStackTrace(); + } + + } + + /** + * Dynamically define customer Type + */ + public static void createDynamicType() { + // get an instance of the type helper + TypeHelper typeH = TypeHelper.INSTANCE; + Type intType = typeH.getType("commonj.sdo", "Int"); + Type stringType = typeH.getType("commonj.sdo", "String"); + + // create a new Type for Customers + DataObject customerType = DataFactory.INSTANCE.create("commonj.sdo", + "Type"); + + customerType.set("uri", "http://example.com/customer"); + customerType.set("name", "Customer"); + + // create a customer number property + DataObject custNumProperty = customerType.createDataObject("property"); + custNumProperty.set("name", "custNum"); + custNumProperty.set("type", intType); + + // create a last name property + DataObject lastNameProperty = customerType.createDataObject("property"); + lastNameProperty.set("name", "lastName"); + lastNameProperty.set("type", stringType); + + // create a first name property + DataObject firstNameProperty = customerType + .createDataObject("property"); + firstNameProperty.set("name", "firstName"); + firstNameProperty.set("type", stringType); + + // now define the Customer type so that customers can be made + typeH.define(customerType); + } + + private void confirmTypes(String uri, String[] expectedTypeNames) { + + try { + + List actualTypes = SDOUtil.getTypes(TypeHelper.INSTANCE, uri); + assertNotNull("Testing that list of types for " + uri + + " is not null", actualTypes); + + // test the number of Types + assertEquals("Testing number of types for " + uri, + expectedTypeNames.length, actualTypes.size()); + + // put into a HashMap for easy lookup + HashMap typeLookup = new HashMap(); + for (int i = 0; i < actualTypes.size(); i++) { + Type type = (Type) actualTypes.get(i); + typeLookup.put(type.getName(), type); + } + + // check that we have the same types + for (int i = 0; i < expectedTypeNames.length; i++) { + assertTrue("testing that type " + expectedTypeNames[i] + + "was returned for " + uri, typeLookup + .containsKey(expectedTypeNames[i])); + } + + } catch (Exception e) { + fail("Exception caught comparing expected types to actual types for uri " + + uri + ":" + e.toString()); + e.printStackTrace(); + } + } +} diff --git a/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java new file mode 100644 index 0000000000..806662a83c --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java @@ -0,0 +1,89 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.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/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java new file mode 100644 index 0000000000..833ab433f1 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java @@ -0,0 +1,85 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.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/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SerializeTypesTestCase.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SerializeTypesTestCase.java new file mode 100644 index 0000000000..3ffca96f5e --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SerializeTypesTestCase.java @@ -0,0 +1,133 @@ +/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.helper.TypeHelperImpl;
+import org.apache.tuscany.sdo.util.SDOUtil;
+import org.eclipse.emf.ecore.xmi.XMLResource;
+
+import commonj.sdo.DataGraph;
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.TypeHelper;
+
+public class SerializeTypesTestCase extends TestCase {
+
+ public void testSerializeTypesRoundTrip() throws Exception {
+ TypeHelper types = SDOUtil.createTypeHelper();
+ DataFactory factory = SDOUtil.createDataFactory(types);
+
+ Type intType = types.getType("commonj.sdo", "Int");
+ Type stringType = types.getType("commonj.sdo", "String");
+
+ // create a new Type for Addresses
+ DataObject addressType = factory.create("commonj.sdo", "Type");
+ addressType.set("uri", "http://example.com/address");
+ addressType.set("name", "Address");
+
+ // create a address street property
+ DataObject addrStProperty = addressType.createDataObject("property");
+ addrStProperty.set("name", "addrSt");
+ addrStProperty.set("type", stringType);
+
+ // create a new Type for Customers
+ DataObject customerType = factory.create("commonj.sdo", "Type");
+ customerType.set("uri", "http://example.com/customer");
+ customerType.set("name", "Customer");
+
+ // create a customer number property
+ DataObject custNumProperty = customerType.createDataObject("property");
+ custNumProperty.set("name", "custNum");
+ custNumProperty.set("type", intType);
+
+ // create a first name property
+ DataObject firstNameProperty = customerType.createDataObject("property");
+ firstNameProperty.set("name", "firstName");
+ firstNameProperty.set("type", stringType);
+
+ // create a last name property
+ DataObject lastNameProperty = customerType.createDataObject("property");
+ lastNameProperty.set("name", "lastName");
+ lastNameProperty.set("type", stringType);
+
+ // create an address property
+ DataObject addressProperty = customerType.createDataObject("property");
+ addressProperty.set("name", "address");
+ addressProperty.set("type", addressType);
+ addressProperty.setBoolean("containment", true);
+
+ // now define the Address and Customer type so that addresses and customers can be made
+ List types2define = new ArrayList();
+ types2define.add(addressType);
+ types2define.add(customerType);
+ List typesDefined = types.define(types2define);
+
+ // Create an empty data graph and add a root object, an instance of customerType
+ //
+
+ DataGraph dataGraph = SDOUtil.createDataGraph();
+ Type customerTypeDefined = (Type) typesDefined.get(1);
+ DataObject customer1 = dataGraph.createRootObject(customerTypeDefined);
+
+ customer1.setInt("custNum", 1);
+ customer1.set("firstName", "John");
+ customer1.set("lastName", "Adams");
+ DataObject address = customer1.createDataObject("address");
+ address.set("addrSt", "577 Airport Blvd");
+
+ SDOUtil.registerDataGraphTypes(dataGraph, typesDefined);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ SDOUtil.saveDataGraph(dataGraph, baos, null);
+ //SDOUtil.saveDataGraph(dataGraph, System.out, null);
+
+ TypeHelper deserializingTypeHelper = SDOUtil.createTypeHelper();
+
+ // The following is a kludge to force deserialization of metadata into a different TypeHelper (scope)
+ // TBD figure out a proper non-EMF way to do this.
+ Map options = new HashMap();
+ Object differentFromSerializing = ((TypeHelperImpl) deserializingTypeHelper).getExtendedMetaData();
+ options.put(XMLResource.OPTION_EXTENDED_META_DATA, differentFromSerializing);
+
+ byte[] serialized = baos.toByteArray();
+ ByteArrayInputStream bais = new ByteArrayInputStream(serialized);
+ DataGraph loadedDataGraph = SDOUtil.loadDataGraph(bais, options);
+
+ DataObject loadedRootObject = loadedDataGraph.getRootObject();
+ assertNotSame(loadedRootObject.getType(), customer1.getType());
+
+ // EqualityHelper requires same Type
+ assertEquals(loadedRootObject.getInt("custNum"), customer1.getInt("custNum"));
+ assertEquals(loadedRootObject.get("firstName"), customer1.get("firstName"));
+ assertEquals(loadedRootObject.get("lastName"), customer1.get("lastName"));
+ DataObject loadedAddress = loadedRootObject.getDataObject("address");
+ assertEquals(loadedAddress.get("addrSt"), address.get("addrSt"));
+ }
+}
\ No newline at end of file diff --git a/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java new file mode 100644 index 0000000000..36f038d779 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java @@ -0,0 +1,71 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.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/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java new file mode 100644 index 0000000000..8c4345be46 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java @@ -0,0 +1,81 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.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 junit.framework.TestCase; + +import commonj.sdo.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; + + +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/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java new file mode 100644 index 0000000000..c3fffa4f10 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java @@ -0,0 +1,63 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.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/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValuesTestCase.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValuesTestCase.java new file mode 100644 index 0000000000..b473503122 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValuesTestCase.java @@ -0,0 +1,47 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.test; + +import java.io.IOException; +import java.net.URL; + +import junit.framework.TestCase; + +import org.apache.tuscany.sdo.util.SDOUtil; + +import commonj.sdo.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.XSDHelper; + +public final class SubstitutionValuesTestCase extends TestCase +{ + public void test() throws IOException + { + URL url = getClass().getResource("/SubstitutionValues.xsd"); + XSDHelper.INSTANCE.define(url.openStream(), url.toString()); + + final DataObject object = DataFactory.INSTANCE.create("http://www.apache.org/tuscany/SubstitutionValues", "TestObject"); + final Type type = object.getType(); + + assertNotNull( SDOUtil.getSubstitutionValues(object, type.getProperty("groupHead"))); + assertNull( SDOUtil.getSubstitutionValues(object, type.getProperty("nonGroupHead"))); + } +}
\ No newline at end of file diff --git a/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java new file mode 100644 index 0000000000..a7ab3f954a --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java @@ -0,0 +1,285 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.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.DocumentType; +import org.w3c.dom.NamedNodeMap; +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<length; i++) + { + Node node = nodeList.item(i); + nodes.add(node); + getAllNodes(node.getChildNodes(), nodes); + } // for + } + + private static boolean equalNamedNodeMap(NamedNodeMap mapA, NamedNodeMap mapB) { + if (mapA == null) { + if (mapB == null) { + return true; + } + return false; + } + if (mapA.getLength() != mapB.getLength()) { + return false; + } + for (int i = 0; i < mapA.getLength(); i++) { + Node trialNode = mapA.item(i); + if (trialNode == null) { + return false; + } + Node checkNode = mapB.getNamedItem(trialNode.getNodeName()); + if (checkNode == null) { + return false; + } + if (!equalNode(trialNode, checkNode)) { + return false; + } + } + return true; + } + + private static boolean equalNode(Node nodeA, Node nodeB) { + if (nodeA == null) { + if (nodeB == null) { + return true; + } + return false; + } + // following is intended to provide same function as 1.5 isEqualNode() + if (nodeA.getNodeType() != nodeB.getNodeType()) { + return false; + } + if (!equalString(nodeA.getNodeName(), nodeB.getNodeName())) { + return false; + } + if (!equalString(nodeA.getLocalName(), nodeB.getLocalName())) { + return false; + } + if (!equalString(nodeA.getNamespaceURI(), nodeB.getNamespaceURI())) { + return false; + } + if (!equalString(nodeA.getNamespaceURI(), nodeB.getNamespaceURI())) { + return false; + } + if (!equalString(nodeA.getPrefix(), nodeB.getPrefix())) { + return false; + } + if (!equalString(nodeA.getNodeValue(), nodeB.getNodeValue())) { + return false; + } + if (!equalNamedNodeMap(nodeA.getAttributes(), nodeB.getAttributes())) { + return false; + } + if (!equalNodeList(nodeA.getChildNodes(), nodeB.getChildNodes())) { + return false; + } + if (nodeA.getNodeType() == Node.DOCUMENT_TYPE_NODE) { + DocumentType documentTypeA = (DocumentType) nodeA; + DocumentType documentTypeB = (DocumentType) nodeB; + if (!equalString(documentTypeA.getPublicId(), documentTypeB.getPublicId())) { + return false; + } + if (!equalString(documentTypeA.getSystemId(), documentTypeB.getSystemId())) { + return false; + } + if (!equalString(documentTypeA.getInternalSubset(), documentTypeB.getInternalSubset())) { + return false; + } + if (!equalNamedNodeMap(documentTypeA.getEntities(), documentTypeB.getEntities())) { + return false; + } + if (!equalNamedNodeMap(documentTypeA.getNotations(), documentTypeB.getNotations())) { + return false; + } + } + return true; + } + + private static boolean equalNodeList(NodeList nodeListA, NodeList nodeListB) { + if (nodeListA == null) { + if (nodeListB == null) { + return true; + } + return false; + } + return equalNodes(nodeListA, nodeListB); + } + + private static boolean equalString(String stringA, String stringB) { + if (stringA == null) { + if (stringB == null) { + return true; + } + return false; + } + return stringA.equals(stringB); + } + + private static boolean equalNodes(NodeList sourceNodeList, NodeList targetNodeList) + { + ArrayList 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<sourceLength; i++) + { + Node sourceNode = (Node)sourceNodes.get(i); + Node targetNode = (Node)targetNodes.get(i); + + /* remove comment when migrated to Java 1.5 + if (!sourceNode.isEqualNode(targetNode)) + { + return false; + } + */ + // following is intended as 1.4 equivalent of isEqualNode() + if (!equalNode(sourceNode, targetNode)) + { + return false; + } + } // for + + return true; + } + + public static boolean equalXmlFiles(URL source, URL target) + { + try { + return equalXmlFiles(source.openStream(), target.openStream()); + } + catch (IOException e) + { + return false; + } + } + + public static boolean equalXmlFiles(InputStream sourceStream, URL target) + { + try { + return equalXmlFiles(sourceStream, target.openStream()); + } + catch (IOException e) + { + return false; + } + } + + public static boolean equalXmlFiles(URL source, InputStream targetStream) + { + try { + return equalXmlFiles(source.openStream(), targetStream); + } + catch (IOException e) + { + return false; + } + } + + public static boolean equalXmlFiles(InputStream sourceStream, InputStream targetStream) + { + DocumentBuilder builder; + Document sourceDocument; + Document targetDocument; + + try { + builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + sourceDocument = builder.parse(sourceStream); + targetDocument = builder.parse(targetStream); + } + catch (FactoryConfigurationError fce) { + return false; + } + catch (ParserConfigurationException ce) { + return false; + } + catch (SAXException se) + { + return false; + } + catch (IOException ie) + { + return false; + } + + sourceDocument.normalize(); + targetDocument.normalize(); + + /* remove comment when migrated to Java 1.5 + if (!sourceDocument.getXmlVersion().equals(targetDocument.getXmlVersion())) + { + return false; + } + + String sourceXmlEncoding = sourceDocument.getXmlEncoding(); + String targetXmlEncoding = targetDocument.getXmlEncoding(); + + if (sourceXmlEncoding != null && targetXmlEncoding != null && + sourceXmlEncoding.equalsIgnoreCase(targetXmlEncoding)) + { + // continue + } + else + { + return false; + } + */ + + NodeList sourceNodes = sourceDocument.getChildNodes(); + NodeList targetNodes = targetDocument.getChildNodes(); + + return equalNodes(sourceNodes, targetNodes); + } +} diff --git a/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeConversionTestCase.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeConversionTestCase.java new file mode 100644 index 0000000000..278355bfd3 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeConversionTestCase.java @@ -0,0 +1,883 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.tuscany.sdo.test; + +import junit.framework.TestCase; + + +import java.io.InputStream; +import java.lang.reflect.Method; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.net.URL; +import java.text.SimpleDateFormat; +import java.util.Comparator; +import java.util.Date; +import java.util.TimeZone; + +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.XSDHelper; + +public class TypeConversionTestCase extends TestCase +{ + // The following constants are used to get Types from XSDs + + private static final String TEST_MODEL = "/api_test.xsd"; + private static final String TEST_NAMESPACE = "http://www.example.com/api_test"; + + // The following constants describe the index for the fields in api_test.xsd. + + private static final int STRING_VAL_INDEX = 1; + private static final int BOOLEAN_VAL_INDEX = 2; + private static final int BYTE_VAL_INDEX = 4; + private static final int DECIMAL_VAL_INDEX = 6; + private static final int INT_VAL_INDEX = 8; + private static final int FLOAT_VAL_INDEX = 9; + private static final int DOUBLE_VAL_INDEX = 10; + private static final int DATE_VAL_INDEX = 11; + private static final int SHORT_VAL_INDEX = 12; + private static final int LONG_VAL_INDEX = 13; + private static final int BYTES_VAL_INDEX = 15; + private static final int INTEGER_VAL_INDEX = 16; + private static final int CHAR_VAL_INDEX = 17; + + // The following variables are Method arrays. Each array refers to a specific get<Type>, but within + // the array exist the get<Type>(index), get<Type>(property), and get<Type>(path). Rather than + // referring to each of the three in every circumstance, the more compact array appears. + + private static ConversionType TO_BOOLEAN = new ConversionType("getBoolean"); + private static ConversionType TO_BYTE = new ConversionType("getByte"); + private static ConversionType TO_CHAR = new ConversionType("getChar"); + private static ConversionType TO_DOUBLE = new ConversionType("getDouble"); + private static ConversionType TO_FLOAT = new ConversionType("getFloat"); + private static ConversionType TO_INT = new ConversionType("getInt"); + private static ConversionType TO_LONG = new ConversionType("getLong"); + private static ConversionType TO_SHORT = new ConversionType("getShort"); + private static ConversionType TO_BYTES = new ConversionType("getBytes"); + private static ConversionType TO_BIGDECIMAL = new ConversionType("getBigDecimal"); + private static ConversionType TO_BIGINTEGER = new ConversionType("getBigInteger"); + private static ConversionType TO_DATAOBJECT = new ConversionType("getDataObject"); + private static ConversionType TO_DATE = new ConversionType("getDate"); + private static ConversionType TO_STRING = new ConversionType("getString"); + private static ConversionType TO_LIST = new ConversionType("getList"); + private static ConversionType TO_SEQUENCE = new ConversionType("getSequence"); + + private static GeneralComparator COMPARE_ANY; + + // There will be several instances where a Property must be passed as a parameter. Have available the Type + // to call getProperty() as needed. + + private static Type API_TEST_TYPE; + + // The default constructor establishes each of the Method and Method[] variables. + + public TypeConversionTestCase() throws Exception + { + COMPARE_ANY = new GeneralComparator(); + + // Populate the meta data for the test model + URL url = getClass().getResource(TEST_MODEL); + InputStream inputStream = url.openStream(); + XSDHelper.INSTANCE.define(inputStream, url.toString()); + inputStream.close(); + + API_TEST_TYPE = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "APITest"); + } + + private static class ConversionType + { + // The following constants are used because the getMethod function requires an Class + // array describing the parameters to the functions. + + private static final Class[] INT_CLASS_ARRAY = {int.class}; + private static final Class[] PROPERTY_CLASS_ARRAY = {Property.class}; + private static final Class[] STRING_CLASS_ARRAY = {String.class}; + + Method index_method; + Method property_method; + Method path_method; + + public ConversionType (String method_name) + { + try + { + this.index_method = DataObject.class.getMethod(method_name, INT_CLASS_ARRAY); + this.property_method = DataObject.class.getMethod(method_name, PROPERTY_CLASS_ARRAY); + this.path_method = DataObject.class.getMethod(method_name, STRING_CLASS_ARRAY); + } + catch (NoSuchMethodException e) + { + this.index_method = null; + this.property_method = null; + this.path_method = null; + } + } + + public Method getIndexMethod() + { + return this.index_method; + } + + public Method getPropertyMethod() + { + return this.property_method; + } + + public Method getPathMethod() + { + return this.path_method; + } + } + + // Each instance of Test describes a convert-from type. The index, property and path parms + // will refer to the same field, which is a field of the convert-from type. + + private static class Test + { + DataObject test_obj; + Object[] index_parm; + Object[] property_parm; + Object[] path_parm; + Object expected_value; + String from_type; + + // The constructor prepares a test DataObject and determines how to access the field + // in three different ways - index, property, and path. + + Test(String path, int index) + { + this.test_obj = DataFactory.INSTANCE.create(API_TEST_TYPE); + this.index_parm = new Object[] {new Integer(index)}; + this.property_parm = new Object[] {API_TEST_TYPE.getProperty(path)}; + this.path_parm = new Object[] {path}; + this.expected_value = null; + } + + // The initialize() function establishes the initial value of the test field. + + public void initialize(Class type, String type_name, Object initial_value) throws Exception + { + Class[] classArray = {int.class, type}; + Object[] initValueArray = new Object[] {this.index_parm[0], initial_value}; + + Method setter = DataObject.class.getMethod("set" + type_name, classArray); + setter.invoke(test_obj, initValueArray); + this.expected_value = initial_value; + this.from_type = type_name; + } + + // Attempts the conversion to the specified type, using DataObject.get____(). + // The get___() function can be called with an index, path, and property. attemptConversion() + // calls each of those three. + + public void attemptConversion(ConversionType to_type) throws Exception + { + performConversion(to_type.getIndexMethod(), this.index_parm); + performConversion(to_type.getPathMethod(), this.path_parm); + performConversion(to_type.getPropertyMethod(), this.property_parm); + } + + public void checkConversionException(ConversionType to_type, Class expected_exception) throws Exception + { + boolean index_err, path_err, property_err, consistency_err = false; + + index_err = executeExceptionCase(to_type.getIndexMethod(), this.index_parm, expected_exception); + path_err = executeExceptionCase(to_type.getPathMethod(), this.path_parm, expected_exception); + property_err = executeExceptionCase(to_type.getPropertyMethod(), this.property_parm, expected_exception); + + if (index_err != path_err || path_err != property_err) + consistency_err = true; + else if (index_err == false) + attemptConversion(to_type); + + assertFalse("An exception inconsistency exists for " + to_type.getPathMethod().getName() + " when called " + + "for a " + this.from_type + " property.", consistency_err); + } + + private void performConversion (Method convert, Object[] parm) throws Exception + { + try + { + assertTrue("Conversion did not yield expected value for " + convert.getName() + " on a " + this.from_type + " property.", + COMPARE_ANY.compare(convert.invoke(test_obj, parm), this.expected_value) == 0); + } + catch (Exception e) + { + Throwable cause = e.getCause(); + if (cause == null) + { + System.err.println("An exception of type " + e.getClass() + " occurred while performing " + convert.getName() + + " on a " + this.from_type + " property."); + } + else + { + System.err.println("An exception of type " + cause.getClass() + " occurred while performing " + convert.getName() + + " on a " + this.from_type + " property."); + } + + throw e; + } + + } + + private boolean executeExceptionCase (Method convert, Object[] parm, Class expected_exception) throws Exception + { + boolean exception_thrown = false; + try + { + convert.invoke(test_obj, parm); + } + catch (Exception e) + { + exception_thrown = true; + Throwable cause = e.getCause(); + if (cause == null) + { + assertEquals("An unexpected exception occurred while performing " + convert.getName() + + " on a " + this.from_type + " property.", expected_exception, e.getClass()); + } + else + { + assertEquals("An unexpected exception occurred while performing " + convert.getName() + + " on a " + this.from_type + " property.", expected_exception, cause.getClass()); + } + } + + return exception_thrown; + } + } + + private static class GeneralComparator implements Comparator + { + public int compare(Object obj1, Object obj2) + { + if (obj1.getClass() == obj2.getClass()) + { + if (obj1.equals(obj2)) + return 0; + else + return 1; + } + + else if (obj1.getClass() == Date.class) + { + if (obj2.getClass() == String.class) + { + try + { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy'-'MM'-'dd'T'H':'mm':'ss.S"); + + sdf.setTimeZone(TimeZone.getTimeZone("UTC")); + obj2 = sdf.parse((String) obj2); + + if (obj1.equals(obj2)) + return 0; + } + catch (Exception e) + { + System.out.println(e.getMessage()); + } + + return 1; + } + + else + { + Date temp = (Date) obj1; + + return compare(new Long(temp.getTime()), obj2); + } + + } + + else if (obj2.getClass() == Date.class) + { + return compare(obj2, obj1); + } + + else if (obj1.getClass() == Boolean.class) + { + Boolean temp = (Boolean) obj1; + + if (temp.booleanValue()) + { + if (obj2.toString().equalsIgnoreCase("true")) + return 0; + else + return 1; + } + + else + { + if (obj2.toString().equalsIgnoreCase("true")) + return 1; + else + return 0; + } + } + + else if (obj2.getClass() == Boolean.class) + return compare(obj2, obj1); + + else if (obj1.getClass() == Byte.class || obj2.getClass() == Byte.class) + { + byte b1 = (Double.valueOf(obj1.toString())).byteValue(); + byte b2 = (Double.valueOf(obj2.toString())).byteValue(); + + if (b1 == b2) + return 0; + else if (b1 < b2) + return -1; + else + return 1; + } + + else if (obj1.getClass().toString().charAt(6) == '[') + { + long result = 0; + long multiplier = 1; + + byte[] array = (byte[]) obj1; + for (int i = 0; i < array.length; i++) + { + result += array[array.length - i - 1] * multiplier; + multiplier *= 256; + } + + return compare(obj2, new Long(result)); + } + + else if (obj2.getClass().toString().charAt(6) == '[') + { + return compare(obj2, obj1); + } + + else if (obj1.getClass() == Short.class || obj2.getClass() == Short.class) + { + short s1 = (Double.valueOf(obj1.toString())).shortValue(); + short s2 = (Double.valueOf(obj2.toString())).shortValue(); + + if (s1 == s2) + return 0; + else if (s1 < s2) + return -1; + else + return 1; + } + + else if (obj1.getClass() == Integer.class || obj2.getClass() == Integer.class) + { + int i1 = (Double.valueOf(obj1.toString())).intValue(); + int i2 = (Double.valueOf(obj2.toString())).intValue(); + + if (i1 == i2) + return 0; + else if (i1 < i2) + return -1; + else + return 1; + } + + else if ( obj1.getClass() == Long.class || obj2.getClass() == Long.class + || obj1.getClass() == BigInteger.class || obj2.getClass() == BigInteger.class) + { + long l1 = (Double.valueOf(obj1.toString())).longValue(); + long l2 = (Double.valueOf(obj2.toString())).longValue(); + + if (l1 == l2) + return 0; + else if (l1 < l2) + return -1; + else + return 1; + } + + else if (obj1.getClass() == Float.class || obj2.getClass() == Float.class) + { + float f1 = (Double.valueOf(obj1.toString())).floatValue(); + float f2 = (Double.valueOf(obj2.toString())).floatValue(); + + if (f1 == f2) + return 0; + else if (f1 < f2) + return -1; + else + return 1; + } + + else if (obj1.getClass() == Double.class || obj2.getClass() == Double.class) + { + Double b1 = Double.valueOf(obj1.toString()); + Double b2 = Double.valueOf(obj2.toString()); + + return b1.compareTo(b2); + } + + else if (obj1.getClass() == BigDecimal.class || obj2.getClass() == BigDecimal.class) + { + BigDecimal b1 = new BigDecimal(obj1.toString()); + BigDecimal b2 = new BigDecimal(obj2.toString()); + + return b1.compareTo(b2); + } + + else + { + if (obj1.toString().equals(obj2.toString())) + return 0; + else + return 1; + } + } + + } + + /********************************************************** + * In the following test cases, several instances are commented out. + * For these cases, the test case currently fails. A JIRA issue (TUSCANY-581) has + * been opened to either correct the behavior (then uncomment the lines) or to + * alter the specification against which the test cases were designed (and then + * remove the lines - assuming the alteration is to remove stating the + * nature of the exception). + */ + + public void testBooleanConversion() throws Exception + { + Test FromBoolean = new Test("booleanVal", BOOLEAN_VAL_INDEX); + + FromBoolean.initialize(boolean.class, "Boolean", Boolean.valueOf(true)); + + FromBoolean.attemptConversion(TO_BOOLEAN); + FromBoolean.attemptConversion(TO_STRING); + } + + public void testBooleanExceptions() throws Exception + { + Test FromBoolean = new Test("booleanVal", BOOLEAN_VAL_INDEX); + + FromBoolean.initialize(boolean.class, "Boolean", Boolean.valueOf(true)); + +// FromBoolean.checkConversionException(TO_BYTE, ClassCastException.class); +// FromBoolean.checkConversionException(TO_CHAR, ClassCastException.class); +// FromBoolean.checkConversionException(TO_DOUBLE, ClassCastException.class); +// FromBoolean.checkConversionException(TO_FLOAT, ClassCastException.class); +// FromBoolean.checkConversionException(TO_INT, ClassCastException.class); +// FromBoolean.checkConversionException(TO_LONG, ClassCastException.class); +// FromBoolean.checkConversionException(TO_SHORT, ClassCastException.class); +// FromBoolean.checkConversionException(TO_BYTES, ClassCastException.class); +// FromBoolean.checkConversionException(TO_BIGDECIMAL, ClassCastException.class); +// FromBoolean.checkConversionException(TO_BIGINTEGER, ClassCastException.class); + FromBoolean.checkConversionException(TO_DATAOBJECT, ClassCastException.class); +// FromBoolean.checkConversionException(TO_DATE, ClassCastException.class); + FromBoolean.checkConversionException(TO_LIST, ClassCastException.class); + FromBoolean.checkConversionException(TO_SEQUENCE, ClassCastException.class); + } + + public void testByteConversion() throws Exception + { + Test FromByte = new Test("byteVal", BYTE_VAL_INDEX); + + FromByte.initialize(byte.class, "Byte", Byte.valueOf("-127")); + + FromByte.attemptConversion(TO_BYTE); + FromByte.attemptConversion(TO_DOUBLE); + FromByte.attemptConversion(TO_FLOAT); + FromByte.attemptConversion(TO_INT); + FromByte.attemptConversion(TO_LONG); + FromByte.attemptConversion(TO_SHORT); + FromByte.attemptConversion(TO_STRING); + } + + public void testByteExceptions() throws Exception + { + Test FromByte = new Test("byteVal", BYTE_VAL_INDEX); + + FromByte.initialize(byte.class, "Byte", Byte.valueOf("-127")); + +// FromByte.checkConversionException(TO_BOOLEAN, ClassCastException.class); +// FromByte.checkConversionException(TO_CHAR, ClassCastException.class); +// FromByte.checkConversionException(TO_BYTES, ClassCastException.class); + FromByte.checkConversionException(TO_BIGDECIMAL, ClassCastException.class); + FromByte.checkConversionException(TO_BIGINTEGER, ClassCastException.class); + FromByte.checkConversionException(TO_DATAOBJECT, ClassCastException.class); +// FromByte.checkConversionException(TO_DATE, ClassCastException.class); + FromByte.checkConversionException(TO_LIST, ClassCastException.class); + FromByte.checkConversionException(TO_SEQUENCE, ClassCastException.class); + } + + public void testCharConversion() throws Exception + { + Test FromChar = new Test("charVal", CHAR_VAL_INDEX); + + FromChar.initialize(char.class, "Char", new Character('?')); + + FromChar.attemptConversion(TO_CHAR); + FromChar.attemptConversion(TO_STRING); + } + + public void testCharExceptions() throws Exception + { + Test FromChar = new Test("charVal", CHAR_VAL_INDEX); + + FromChar.initialize(char.class, "Char", new Character('?')); + +// FromChar.checkConversionException(TO_BOOLEAN, ClassCastException.class); +// FromChar.checkConversionException(TO_BYTE, ClassCastException.class); +// FromChar.checkConversionException(TO_DOUBLE, ClassCastException.class); +// FromChar.checkConversionException(TO_FLOAT, ClassCastException.class); +// FromChar.checkConversionException(TO_INT, ClassCastException.class); +// FromChar.checkConversionException(TO_LONG, ClassCastException.class); +// FromChar.checkConversionException(TO_SHORT, ClassCastException.class); +// FromChar.checkConversionException(TO_BYTES, ClassCastException.class); +// FromChar.checkConversionException(TO_BIGDECIMAL, ClassCastException.class); +// FromChar.checkConversionException(TO_BIGINTEGER, ClassCastException.class); + FromChar.checkConversionException(TO_DATAOBJECT, ClassCastException.class); +// FromChar.checkConversionException(TO_DATE, ClassCastException.class); + FromChar.checkConversionException(TO_LIST, ClassCastException.class); + FromChar.checkConversionException(TO_SEQUENCE, ClassCastException.class); + } + + public void testDoubleConversion() throws Exception + { + Test FromDouble = new Test("doubleVal", DOUBLE_VAL_INDEX); + + FromDouble.initialize(double.class, "Double", new Double(Double.MAX_VALUE)); + + FromDouble.attemptConversion(TO_BYTE); + FromDouble.attemptConversion(TO_DOUBLE); + FromDouble.attemptConversion(TO_FLOAT); + FromDouble.attemptConversion(TO_INT); + FromDouble.attemptConversion(TO_LONG); + FromDouble.attemptConversion(TO_SHORT); + FromDouble.attemptConversion(TO_BIGDECIMAL); + FromDouble.attemptConversion(TO_BIGINTEGER); + FromDouble.attemptConversion(TO_STRING); + } + + public void testDoubleExceptions() throws Exception + { + Test FromDouble = new Test("doubleVal", DOUBLE_VAL_INDEX); + + FromDouble.initialize(double.class, "Double", new Double(Double.MAX_VALUE)); + +// FromDouble.checkConversionException(TO_BOOLEAN, ClassCastException.class); +// FromDouble.checkConversionException(TO_CHAR, ClassCastException.class); +// FromDouble.checkConversionException(TO_BYTES, ClassCastException.class); + FromDouble.checkConversionException(TO_DATAOBJECT, ClassCastException.class); +// FromDouble.checkConversionException(TO_DATE, ClassCastException.class); + FromDouble.checkConversionException(TO_LIST, ClassCastException.class); + FromDouble.checkConversionException(TO_SEQUENCE, ClassCastException.class); + } + + public void testFloatConversion() throws Exception + { + Test FromFloat = new Test("floatVal", FLOAT_VAL_INDEX); + + FromFloat.initialize(float.class, "Float", new Float(Float.MIN_VALUE)); + + FromFloat.attemptConversion(TO_BYTE); + FromFloat.attemptConversion(TO_DOUBLE); + FromFloat.attemptConversion(TO_FLOAT); + FromFloat.attemptConversion(TO_INT); + FromFloat.attemptConversion(TO_LONG); + FromFloat.attemptConversion(TO_SHORT); + FromFloat.attemptConversion(TO_BIGDECIMAL); + FromFloat.attemptConversion(TO_BIGINTEGER); + FromFloat.attemptConversion(TO_STRING); + } + + public void testFloatExceptions() throws Exception + { + Test FromFloat = new Test("floatVal", FLOAT_VAL_INDEX); + + FromFloat.initialize(float.class, "Float", new Float(Float.MIN_VALUE)); + +// FromFloat.checkConversionException(TO_BOOLEAN, ClassCastException.class); +// FromFloat.checkConversionException(TO_CHAR, ClassCastException.class); +// FromFloat.checkConversionException(TO_BYTES, ClassCastException.class); + FromFloat.checkConversionException(TO_DATAOBJECT, ClassCastException.class); +// FromFloat.checkConversionException(TO_DATE, ClassCastException.class); + FromFloat.checkConversionException(TO_LIST, ClassCastException.class); + FromFloat.checkConversionException(TO_SEQUENCE, ClassCastException.class); + } + + public void testIntConversion() throws Exception + { + Test FromInt = new Test("intVal", INT_VAL_INDEX); + + FromInt.initialize(int.class, "Int", new Integer(5)); + + FromInt.attemptConversion(TO_BYTE); + FromInt.attemptConversion(TO_DOUBLE); + FromInt.attemptConversion(TO_FLOAT); + FromInt.attemptConversion(TO_INT); + FromInt.attemptConversion(TO_LONG); + FromInt.attemptConversion(TO_SHORT); + FromInt.attemptConversion(TO_BIGDECIMAL); + FromInt.attemptConversion(TO_BIGINTEGER); + FromInt.attemptConversion(TO_STRING); + } + + public void testIntExceptions() throws Exception + { + Test FromInt = new Test("intVal", INT_VAL_INDEX); + + FromInt.initialize(int.class, "Int", new Integer(5)); + +// FromInt.checkConversionException(TO_BOOLEAN, ClassCastException.class); +// FromInt.checkConversionException(TO_CHAR, ClassCastException.class); +// FromInt.checkConversionException(TO_BYTES, ClassCastException.class); + FromInt.checkConversionException(TO_DATAOBJECT, ClassCastException.class); +// FromInt.checkConversionException(TO_DATE, ClassCastException.class); + FromInt.checkConversionException(TO_LIST, ClassCastException.class); + FromInt.checkConversionException(TO_SEQUENCE, ClassCastException.class); + } + + public void testLongConversion() throws Exception + { + Test FromLong = new Test("longVal", LONG_VAL_INDEX); + + FromLong.initialize(long.class, "Long", new Long(7000L)); + + FromLong.attemptConversion(TO_BYTE); + FromLong.attemptConversion(TO_DOUBLE); + FromLong.attemptConversion(TO_FLOAT); + FromLong.attemptConversion(TO_INT); + FromLong.attemptConversion(TO_LONG); + FromLong.attemptConversion(TO_SHORT); + FromLong.attemptConversion(TO_BIGDECIMAL); + FromLong.attemptConversion(TO_BIGINTEGER); + FromLong.attemptConversion(TO_DATE); + FromLong.attemptConversion(TO_STRING); + } + + public void testLongExceptions() throws Exception + { + Test FromLong = new Test("longVal", LONG_VAL_INDEX); + + FromLong.initialize(long.class, "Long", new Long(7000L)); + +// FromLong.checkConversionException(TO_BOOLEAN, ClassCastException.class); +// FromLong.checkConversionException(TO_CHAR, ClassCastException.class); +// FromLong.checkConversionException(TO_BYTES, ClassCastException.class); + FromLong.checkConversionException(TO_DATAOBJECT, ClassCastException.class); + FromLong.checkConversionException(TO_LIST, ClassCastException.class); + FromLong.checkConversionException(TO_SEQUENCE, ClassCastException.class); + } + + public void testShortConversion() throws Exception + { + Test FromShort = new Test("shortVal", SHORT_VAL_INDEX); + + FromShort.initialize(short.class, "Short", new Short("-8000")); + + FromShort.attemptConversion(TO_BYTE); + FromShort.attemptConversion(TO_DOUBLE); + FromShort.attemptConversion(TO_FLOAT); + FromShort.attemptConversion(TO_INT); + FromShort.attemptConversion(TO_LONG); + FromShort.attemptConversion(TO_SHORT); + FromShort.attemptConversion(TO_STRING); + } + + public void testShortExceptions() throws Exception + { + Test FromShort = new Test("shortVal", SHORT_VAL_INDEX); + + FromShort.initialize(short.class, "Short", new Short("-8000")); + +// FromShort.checkConversionException(TO_BOOLEAN, ClassCastException.class); +// FromShort.checkConversionException(TO_CHAR, ClassCastException.class); +// FromShort.checkConversionException(TO_BYTES, ClassCastException.class); + FromShort.checkConversionException(TO_BIGDECIMAL, ClassCastException.class); + FromShort.checkConversionException(TO_BIGINTEGER, ClassCastException.class); + FromShort.checkConversionException(TO_DATAOBJECT, ClassCastException.class); +// FromShort.checkConversionException(TO_DATE, ClassCastException.class); + FromShort.checkConversionException(TO_LIST, ClassCastException.class); + FromShort.checkConversionException(TO_SEQUENCE, ClassCastException.class); + } + + public void testStringConversion() throws Exception + { + Test FromString = new Test("stringVal", STRING_VAL_INDEX); + + FromString.initialize(String.class, "String", "5"); + + FromString.attemptConversion(TO_BOOLEAN); + FromString.attemptConversion(TO_BYTE); + FromString.attemptConversion(TO_CHAR); + FromString.attemptConversion(TO_DOUBLE); + FromString.attemptConversion(TO_FLOAT); + FromString.attemptConversion(TO_INT); + FromString.attemptConversion(TO_LONG); + FromString.attemptConversion(TO_SHORT); + FromString.attemptConversion(TO_BIGDECIMAL); + FromString.attemptConversion(TO_BIGINTEGER); + FromString.attemptConversion(TO_STRING); + + FromString.initialize(String.class, "String", "1999-07-25T8:50:14.33Z"); + FromString.attemptConversion(TO_DATE); + } + + public void testStringExceptions() throws Exception + { + Test FromString = new Test("stringVal", STRING_VAL_INDEX); + + FromString.initialize(String.class, "String", "5"); + +// FromString.checkConversionException(TO_BYTES, ClassCastException.class); + FromString.checkConversionException(TO_DATAOBJECT, ClassCastException.class); + FromString.checkConversionException(TO_LIST, ClassCastException.class); + FromString.checkConversionException(TO_SEQUENCE, ClassCastException.class); + } + + public void testBytesConversion() throws Exception + { + Test FromBytes = new Test("bytesVal", BYTES_VAL_INDEX); + + FromBytes.initialize(byte[].class, "Bytes", new byte[] {10,100}); + + FromBytes.attemptConversion(TO_BYTES); + FromBytes.attemptConversion(TO_BIGINTEGER); + } + + public void testBytesExceptions() throws Exception + { + Test FromBytes = new Test("bytesVal", BYTES_VAL_INDEX); + + FromBytes.initialize(byte[].class, "Bytes", new byte[] {10,100}); + +// FromBytes.checkConversionException(TO_BOOLEAN, ClassCastException.class); +// FromBytes.checkConversionException(TO_BYTE, ClassCastException.class); +// FromBytes.checkConversionException(TO_CHAR, ClassCastException.class); +// FromBytes.checkConversionException(TO_DOUBLE, ClassCastException.class); +// FromBytes.checkConversionException(TO_FLOAT, ClassCastException.class); +// FromBytes.checkConversionException(TO_INT, ClassCastException.class); +// FromBytes.checkConversionException(TO_LONG, ClassCastException.class); +// FromBytes.checkConversionException(TO_SHORT, ClassCastException.class); +// FromBytes.checkConversionException(TO_BIGDECIMAL, ClassCastException.class); + FromBytes.checkConversionException(TO_DATAOBJECT, ClassCastException.class); +// FromBytes.checkConversionException(TO_DATE, ClassCastException.class); +// FromBytes.checkConversionException(TO_STRING, ClassCastException.class); + FromBytes.checkConversionException(TO_LIST, ClassCastException.class); + FromBytes.checkConversionException(TO_SEQUENCE, ClassCastException.class); + } + + public void testBigDecimalConversion() throws Exception + { + Test FromBigDecimal = new Test("decimalVal", DECIMAL_VAL_INDEX); + + FromBigDecimal.initialize(BigDecimal.class, "BigDecimal", new BigDecimal("-3")); + + FromBigDecimal.attemptConversion(TO_DOUBLE); + FromBigDecimal.attemptConversion(TO_FLOAT); + FromBigDecimal.attemptConversion(TO_INT); + FromBigDecimal.attemptConversion(TO_LONG); + FromBigDecimal.attemptConversion(TO_BIGDECIMAL); + FromBigDecimal.attemptConversion(TO_BIGINTEGER); + FromBigDecimal.attemptConversion(TO_STRING); + } + + public void testBigDecimalExceptions() throws Exception + { + Test FromBigDecimal = new Test("decimalVal", DECIMAL_VAL_INDEX); + + FromBigDecimal.initialize(BigDecimal.class, "BigDecimal", new BigDecimal("-3")); + +// FromBigDecimal.checkConversionException(TO_BOOLEAN, ClassCastException.class); +// FromBigDecimal.checkConversionException(TO_BYTE, ClassCastException.class); +// FromBigDecimal.checkConversionException(TO_CHAR, ClassCastException.class); +// FromBigDecimal.checkConversionException(TO_SHORT, ClassCastException.class); +// FromBigDecimal.checkConversionException(TO_BYTES, ClassCastException.class); + FromBigDecimal.checkConversionException(TO_DATAOBJECT, ClassCastException.class); +// FromBigDecimal.checkConversionException(TO_DATE, ClassCastException.class); + FromBigDecimal.checkConversionException(TO_LIST, ClassCastException.class); + FromBigDecimal.checkConversionException(TO_SEQUENCE, ClassCastException.class); + } + + public void testBigIntegerConversion() throws Exception + { + Test FromBigInteger = new Test("integerVal", INTEGER_VAL_INDEX); + + FromBigInteger.initialize(BigInteger.class, "BigInteger", new BigInteger("31500")); + + FromBigInteger.attemptConversion(TO_DOUBLE); + FromBigInteger.attemptConversion(TO_FLOAT); + FromBigInteger.attemptConversion(TO_INT); + FromBigInteger.attemptConversion(TO_LONG); + FromBigInteger.attemptConversion(TO_SHORT); + FromBigInteger.attemptConversion(TO_BYTES); + FromBigInteger.attemptConversion(TO_BIGDECIMAL); + FromBigInteger.attemptConversion(TO_BIGINTEGER); + FromBigInteger.attemptConversion(TO_STRING); + } + + public void testBigIntegerExceptions() throws Exception + { + Test FromBigInteger = new Test("integerVal", INTEGER_VAL_INDEX); + + FromBigInteger.initialize(BigInteger.class, "BigInteger", new BigInteger("31500")); + +// FromBigInteger.checkConversionException(TO_BOOLEAN, ClassCastException.class); +// FromBigInteger.checkConversionException(TO_BYTE, ClassCastException.class); +// FromBigInteger.checkConversionException(TO_CHAR, ClassCastException.class); + FromBigInteger.checkConversionException(TO_DATAOBJECT, ClassCastException.class); +// FromBigInteger.checkConversionException(TO_DATE, ClassCastException.class); + FromBigInteger.checkConversionException(TO_LIST, ClassCastException.class); + FromBigInteger.checkConversionException(TO_SEQUENCE, ClassCastException.class); + } + + public void testDateConversion() throws Exception + { + Test FromDate = new Test("dateVal", DATE_VAL_INDEX); + + FromDate.initialize(Date.class, "Date", new Date(System.currentTimeMillis())); + + FromDate.attemptConversion(TO_LONG); + FromDate.attemptConversion(TO_DATE); + FromDate.attemptConversion(TO_STRING); + } + + public void testDateExceptions() throws Exception + { + Test FromDate = new Test("dateVal", DATE_VAL_INDEX); + + FromDate.initialize(Date.class, "Date", new Date(System.currentTimeMillis())); + +// FromDate.checkConversionException(TO_BOOLEAN, ClassCastException.class); +// FromDate.checkConversionException(TO_BYTE, ClassCastException.class); +// FromDate.checkConversionException(TO_CHAR, ClassCastException.class); +// FromDate.checkConversionException(TO_DOUBLE, ClassCastException.class); +// FromDate.checkConversionException(TO_FLOAT, ClassCastException.class); +// FromDate.checkConversionException(TO_INT, ClassCastException.class); +// FromDate.checkConversionException(TO_SHORT, ClassCastException.class); +// FromDate.checkConversionException(TO_BYTES, ClassCastException.class); +// FromDate.checkConversionException(TO_BIGDECIMAL, ClassCastException.class); +// FromDate.checkConversionException(TO_BIGINTEGER, ClassCastException.class); + FromDate.checkConversionException(TO_DATAOBJECT, ClassCastException.class); + FromDate.checkConversionException(TO_LIST, ClassCastException.class); + FromDate.checkConversionException(TO_SEQUENCE, ClassCastException.class); + } +}
\ No newline at end of file diff --git a/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeRoundTripTestCase.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeRoundTripTestCase.java new file mode 100644 index 0000000000..f718a3f330 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeRoundTripTestCase.java @@ -0,0 +1,147 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.test; + +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; + +import junit.framework.TestCase; + +import org.apache.tuscany.sdo.util.SDOUtil; + +import commonj.sdo.Type; +import commonj.sdo.helper.DataHelper; +import commonj.sdo.helper.TypeHelper; + +public class TypeRoundTripTestCase extends TestCase { + + private static class Test { + Type type; + String value; + Object obj; + Comparator comp; + + Test(Type type, String value, Object obj) { + this.type = type; + this.value = value; + this.obj = obj; + } + + Test(Type type, String value, Object obj, Comparator comp) { + this.type = type; + this.value = value; + this.obj = obj; + this.comp = comp; + } + } + + private static class ListComparator implements Comparator { + public int compare(Object list1, Object list2) { + int answer = 1; + if (list1 instanceof List && list2 instanceof List) { + List l1 = (List) list1; + List l2 = (List) list2; + if (l1.size() == l2.size()) { + for (int n = 0; n < l1.size(); n++) { + if (!l1.get(n).equals(l2.get(n))) { + answer = 0; + break; + } + } + } else { + answer = 0; + } + } else { + answer = 0; + } + return answer; + } + } + + private static class BytesComparator implements Comparator { + public int compare(Object o1, Object o2) { + o2 = new String((byte[])o2); + if (o1.equals(o2)) return 1; + else return 0; + } + } + + public void testTypeRoundTrips() throws Exception { + String URI = "commonj.sdo"; + TypeHelper types = TypeHelper.INSTANCE; + + List list = new ArrayList(); + list.add("foo"); + list.add("bar"); + list.add("test"); + Test[] tests = { + new Test(types.getType(URI, "Boolean"), "true", new Boolean(true)), + new Test(types.getType(URI, "Byte"), "49", new Byte((byte)49)), + new Test(types.getType(URI, "Bytes"), "666F6F", "foo", new BytesComparator()), + new Test(types.getType(URI, "Character"), "a", new Character('a')), + new Test(types.getType(URI, "Date"), "2005-12-12T12:12:12.012Z", DataHelper.INSTANCE.toDate("2005-12-12T12:12:12.012Z")), + new Test(types.getType(URI, "DateTime"), "2005-12-12T12:12:12zz", "2005-12-12T12:12:12zz"), + new Test(types.getType(URI, "Day"), "---12", "---12"), + new Test(types.getType(URI, "Decimal"), "12.12", new BigDecimal("12.12")), + new Test(types.getType(URI, "Double"), "12.12", new Double(12.12)), + new Test(types.getType(URI, "Duration"), "P5Y2M10D", "P5Y2M10D"), + new Test(types.getType(URI, "Float"), "12.12", new Float(12.12f)), + new Test(types.getType(URI, "Int"), "12", new Integer(12)), + new Test(types.getType(URI, "Integer"), "12", new BigInteger("12")), + new Test(types.getType(URI, "Long"), "12", new Long(12l)), + new Test(types.getType(URI, "Month"), "--12", "--12"), + new Test(types.getType(URI, "MonthDay"), "--12-12", "--12-12"), + new Test(types.getType(URI, "Object"), "test", "test"), + new Test(types.getType(URI, "Short"), "12", new Short((short)12)), + new Test(types.getType(URI, "String"), "test", "test"), + new Test(types.getType(URI, "Strings"), "foo bar test", list, new ListComparator()), + new Test(types.getType(URI, "Time"), "12:12:12.12", "12:12:12.12"), + new Test(types.getType(URI, "URI"), "http://example.org", "http://example.org"), + new Test(types.getType(URI, "Year"), "2005", "2005"), + new Test(types.getType(URI, "YearMonth"), "2005-12", "2005-12"), + new Test(types.getType(URI, "YearMonthDay"), "2005-12-12", "2005-12-12") + }; + + for (int n = 0; n < tests.length; n++) { + assertEquals( + SDOUtil.convertToString(tests[n].type, SDOUtil.createFromString(tests[n].type, tests[n].value)), + tests[n].value + ); + + //System.out.print("."); + + if (tests[n].comp == null) { + assertEquals( + SDOUtil.createFromString(tests[n].type, SDOUtil.convertToString(tests[n].type, tests[n].obj)), + tests[n].obj + ); + } else { + String o1 = SDOUtil.convertToString(tests[n].type, tests[n].obj); + Object o2 = SDOUtil.createFromString(tests[n].type, o1); + assertEquals(tests[n].comp.compare(tests[n].obj, o2), 1); + } + } + + } + +} diff --git a/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLDocumentTestCase.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLDocumentTestCase.java new file mode 100644 index 0000000000..1cf59757ef --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLDocumentTestCase.java @@ -0,0 +1,110 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.test; + + +import java.io.IOException; + +import junit.framework.TestCase; + +import commonj.sdo.helper.XMLDocument; +import commonj.sdo.helper.XMLHelper; + + +public class XMLDocumentTestCase extends TestCase +{ + private final String TEST_XML_DOCUMENT = "/XMLDocumentTestCase.xml"; + + // remember that NS1... and NS2... items are expected in sorted order by name + private final String NS1_SCHEMA_NAME = "http://www.example.com/open"; + + private final String NS1_SCHEMA_LOCATION = "/open.xsd"; + + private final String NS2_SCHEMA_NAME = "http://www.example.com/xmlDocumentSchemaLocation"; + + private final String NS2_SCHEMA_LOCATION = "/XMLDocumentSchemaLocation.xsd"; + + private final String NS_SET_NAME_LOCATION = "namespace schemaLocation"; + + //private final String NNS_SCHEMA_LOCATION = "http://www.example.com/XMLDocumentNoNamespaceSchemaLocation.xsd"; + private final String NNS_SCHEMA_LOCATION = "/XMLDocumentNoNamespaceSchemaLocation.xsd"; + + private final String NNS_SET_LOCATION = "noNamespaceSchemaLocation"; + + /** + * This method will load an xml document consisting of a xsi:schemaLocation and + * xsi:noNamespaceSchemaLocation defined. It will then use the XMLDocument API to get and + * set the schemaLocation property. + * + * @throws IOException + */ + public void testSchemaLocation() throws IOException + { + // load the xml document which has xsi:noNamespaceSchemaLocation and xsi:schemaLocation defined + XMLDocument doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(TEST_XML_DOCUMENT)); + + // get the schemaLocation + assertEquals(NS1_SCHEMA_NAME + " " + NS1_SCHEMA_LOCATION + " " + NS2_SCHEMA_NAME + " " + NS2_SCHEMA_LOCATION, doc.getSchemaLocation()); + + // set the schemaLocation to another value and test to see if the value was set + doc.setSchemaLocation(NS_SET_NAME_LOCATION); + assertEquals(NS_SET_NAME_LOCATION, doc.getSchemaLocation()); + + // remove the schemaLocation and ensure it returns null + doc.setSchemaLocation(null); + assertNull(doc.getSchemaLocation()); + + // ensure changes to schemaLocation have not changed noNamespaceSchemaLocation + assertEquals(NNS_SCHEMA_LOCATION, doc.getNoNamespaceSchemaLocation()); + } + + /** + * This method will load an xml document consisting of a xsi:schemaLocation and + * xsi:noNamespaceSchemaLocation defined. It will then use the XMLDocument API to get and + * set the noNamespaceSchemaLocation property. + * + * @throws IOException + */ + public void testNoNamespaceSchemaLocation() throws IOException + { + // load the xml document which has xsi:noNamespaceSchemaLocation and xsi:schemaLocation defined + XMLDocument doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(TEST_XML_DOCUMENT)); + + // get the noNamespaceSchemaLocation + assertEquals(NNS_SCHEMA_LOCATION, doc.getNoNamespaceSchemaLocation()); + + // set the noNameSpaceSchemaLocation to another value and test to see if the value was set + doc.setNoNamespaceSchemaLocation(NNS_SET_LOCATION); + assertEquals(NNS_SET_LOCATION, doc.getNoNamespaceSchemaLocation()); + + // remove the noNameSpaceSchemaLocation and ensure it returns null + doc.setNoNamespaceSchemaLocation(null); + assertNull(doc.getNoNamespaceSchemaLocation()); + + // ensure changes to noNameSpaceSchemaLocation have not changed schemaLocation + assertEquals(NS1_SCHEMA_NAME + " " + NS1_SCHEMA_LOCATION + " " + NS2_SCHEMA_NAME + " " + NS2_SCHEMA_LOCATION, doc.getSchemaLocation()); + } + + protected void setUp() throws Exception + { + super.setUp(); + } + +} diff --git a/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperTestCase.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperTestCase.java new file mode 100644 index 0000000000..4afbbf6137 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperTestCase.java @@ -0,0 +1,144 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.test; + +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.StringReader; +import java.io.StringWriter; +import java.net.URL; +import java.util.List; + +import javax.xml.namespace.QName; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.apache.tuscany.sdo.helper.XMLStreamHelper; +import org.apache.tuscany.sdo.util.SDOUtil; + +import commonj.sdo.DataObject; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XMLDocument; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; + +public class XMLStreamHelperTestCase extends TestCase { + + private XSDHelper xsdHelper = XSDHelper.INSTANCE; + + private TypeHelper typeHelper = TypeHelper.INSTANCE; + + private XMLStreamHelper streamHelper; + + private XMLInputFactory inputFactory; + + private XMLOutputFactory outputFactory; + + private QName module = new QName("http://foo", "module"); + + private QName name = new QName("http://bar", "implementation.mock"); + + private String testName = "foo-ext"; + // private String testName = "complex"; + + private String xml; + + // = "<module name=\"m\" xmlns=\"http://foo\" xmlns:bar=\"http://bar\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" + // xsi:schemaLocation=\"http://bar foo-ext.xsd http://foo foo.xsd \"><component name=\"c\"><bar:implementation.mock + // myAttr=\"helloworld.HelloWorldImpl\" listAttr=\"1 2\">1<bar:myElement>Dummy</bar:myElement>2</bar:implementation.mock></component></module>"; + + protected void setUp() throws Exception { + super.setUp(); + streamHelper = SDOUtil.createXMLStreamHelper(typeHelper); + URL url = getClass().getClassLoader().getResource(testName + ".xsd"); + xsdHelper.define(url.openStream(), url.toExternalForm()); + inputFactory = XMLInputFactory.newInstance(); + outputFactory = XMLOutputFactory.newInstance(); + url = getClass().getClassLoader().getResource(testName + ".xml"); + InputStreamReader reader = new InputStreamReader(url.openStream()); + StringBuffer stringBuffer = new StringBuffer(); + char buf[] = new char[1024]; + int size; + while ((size = reader.read(buf)) != -1) + stringBuffer.append(buf, 0, size); + xml = stringBuffer.toString(); + reader.close(); + } + + public void testLoadObject() throws Exception { + XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(xml)); + int event = reader.getEventType(); + while (!(event == XMLStreamConstants.START_ELEMENT && reader.getName().equals(name)) && reader.hasNext()) { + event = reader.next(); + } + DataObject dataObject = streamHelper.loadObject(reader); + Assert.assertNotNull(dataObject); + Assert.assertTrue(dataObject.getString("myAttr").equals("helloworld.HelloWorldImpl")); + } + + public void testLoad() throws Exception { + XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(xml)); + XMLDocument document = streamHelper.load(reader); + Assert.assertNotNull(document); + Assert.assertEquals(document.getRootElementURI(), module.getNamespaceURI()); + Assert.assertEquals(document.getRootElementName(), module.getLocalPart()); + DataObject moduleObject = document.getRootObject(); + List components = moduleObject.getList("component"); + DataObject componentObject = (DataObject) components.get(0); + // componentObject.getDataObject("implementation.mock"); + DataObject implObject = (DataObject) componentObject.getSequence(0).getValue(0); + Assert.assertTrue(implObject.getString("myAttr").equals("helloworld.HelloWorldImpl")); + } + + public void testSave() throws XMLStreamException { + XMLDocument document = XMLHelper.INSTANCE.load(xml); + StringWriter writer = new StringWriter(); + XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(writer); + streamHelper.save(document, streamWriter); + streamWriter.flush(); + String xmlStr = writer.toString(); + // System.out.println(xmlStr); + Assert.assertTrue(xmlStr.indexOf("myAttr=\"helloworld.HelloWorldImpl\"")!=-1); + } + + public void testSaveObject() throws XMLStreamException { + XMLDocument document = XMLHelper.INSTANCE.load(xml); + DataObject moduleObject = document.getRootObject(); + List components = moduleObject.getList("component"); + DataObject componentObject = (DataObject) components.get(0); + StringWriter writer = new StringWriter(); + XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(writer); + streamHelper.saveObject(componentObject, streamWriter); + streamWriter.flush(); + Assert.assertTrue(writer.toString().indexOf("myAttr=\"helloworld.HelloWorldImpl\"")!=-1); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + +} diff --git a/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java new file mode 100644 index 0000000000..4012ee7d3f --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java @@ -0,0 +1,128 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.test; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; + +import org.apache.tuscany.sdo.util.SDOUtil; + +import junit.framework.TestCase; + +import commonj.sdo.DataObject; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XMLDocument; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; + +public class XPathTestCase extends TestCase { + + private final String TEST_MODEL = "/xpath.xsd"; + private final String XPATH_XML = "/xpath.xml"; + + /** + * The presence or absence of the @ sign in a path has no meaning. + * Properties are always matched by name independent of their XML representation. + * @throws IOException + */ + public void testAtSignProperty() throws IOException { + TypeHelper typeHelper = SDOUtil.createTypeHelper(); + XSDHelper xsdHelper = SDOUtil.createXSDHelper(typeHelper); + XMLHelper xmlHelper = SDOUtil.createXMLHelper(typeHelper); + + URL url = getClass().getResource(TEST_MODEL); + InputStream inputStream = url.openStream(); + xsdHelper.define(inputStream, url.toString()); + + inputStream.close(); + + XMLDocument doc = xmlHelper.load(getClass().getResourceAsStream(XPATH_XML)); + + DataObject drive = doc.getRootObject(); + DataObject folder1 = (DataObject) drive.get("Folder.1"); + String value = folder1.getString("@creation_date"); + + assertEquals(value, "2000-03-23"); + } + + public void testListIndexing() throws Exception { + TypeHelper typeHelper = SDOUtil.createTypeHelper(); + XSDHelper xsdHelper = SDOUtil.createXSDHelper(typeHelper); + XMLHelper xmlHelper = SDOUtil.createXMLHelper(typeHelper); + + URL url = getClass().getResource(TEST_MODEL); + InputStream inputStream = url.openStream(); + xsdHelper.define(inputStream, url.toString()); + + inputStream.close(); + + XMLDocument doc = xmlHelper.load(getClass().getResourceAsStream(XPATH_XML)); + + DataObject root = doc.getRootObject(); + DataObject folder1 = root.getDataObject("Folder[1]"); + assertNotNull(folder1); + DataObject folder1a = root.getDataObject("Folder.0"); + assertEquals(folder1, folder1a); + folder1a = root.getDataObject("Folder[FolderName=Folder00000000000]"); + assertEquals(folder1, folder1a); + + DataObject noFolder = null; + + try { + noFolder = root.getDataObject("Folder[3]"); + assertFalse("bad indexing passed", true); + } catch (IndexOutOfBoundsException iobe) { + // as expected + } catch (Exception e) { + assertFalse("bad indexing generated wrong exception" + e, true); + } + + try { + noFolder = root.getDataObject("Folder[0]"); + assertFalse("bad indexing passed", true); + } catch (IndexOutOfBoundsException iobe) { + // as expected + } catch (Exception e) { + assertFalse("bad indexing generated wrong exception" + e, true); + } + + try { + noFolder = root.getDataObject("Folder.2"); + assertFalse("bad indexing passed", true); + } catch (IndexOutOfBoundsException iobe) { + // as expected + } catch (Exception e) { + assertFalse("bad indexing generated wrong exception" + e, true); + } + + try { + noFolder = root.getDataObject("Folder.-1"); + assertFalse("bad indexing passed", true); + } catch (IndexOutOfBoundsException iobe) { + // as expected + } catch (Exception e) { + assertFalse("bad indexing generated wrong exception" + e, true); + } + + noFolder = root.getDataObject("Folder[FolderName=foo]"); + assertNull(noFolder); + } +} diff --git a/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java new file mode 100644 index 0000000000..557fa12d87 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java @@ -0,0 +1,192 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.test; + +import java.io.IOException; +import java.net.URL; +import java.util.Hashtable; +import java.util.List; +import java.util.Vector; + +import junit.framework.TestCase; + +import org.apache.tuscany.sdo.util.SDOUtil; + +import com.example.simple.impl.SimpleFactoryImpl; +import commonj.sdo.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XSDHelper; + +/** + * @version $Rev$ $Date$ + */ +public class XSDHelperTestCase extends TestCase { + private static final String TEST_MODEL = "/simple.xsd"; + private URL modelURL; + + public void testDefineWithLocation() throws IOException { + XSDHelper xsdHelper = SDOUtil.createXSDHelper(SDOUtil.createTypeHelper()); + List types = xsdHelper.define(modelURL.openStream(), modelURL.toString()); + assertEquals(2, types.size()); + } + + public void testDefineWithNoLocation() { + XSDHelper xsdHelper = SDOUtil.createXSDHelper(SDOUtil.createTypeHelper()); + List types = xsdHelper.define(getClass().getResourceAsStream(TEST_MODEL), null); + assertEquals(2, types.size()); + } + + public void testDuplicateDefineWithLocation() throws IOException { + XSDHelper xsdHelper = SDOUtil.createXSDHelper(SDOUtil.createTypeHelper()); + List types = xsdHelper.define(modelURL.openStream(), modelURL.toString()); + assertEquals(2, types.size()); + + List types2 = xsdHelper.define(modelURL.openStream(), modelURL.toString()); + assertEquals(0, types2.size()); + } + + public void testXSDGeneration_staticSDOType() throws IOException + { + //test for static sdo type. The test succeeds if the IllegalArgumentException is thrown + //by XSDHelper.generate method in which case the string xsd must be null; + XSDHelper xsdHelper = SDOUtil.createXSDHelper(SDOUtil.createTypeHelper()); + DataObject quoteSDO = (DataObject)SimpleFactoryImpl.INSTANCE.createQuote(); + List typeList = new Vector(); + typeList.add(quoteSDO.getType()); + String xsd = null; + + try + { + xsd = xsdHelper.generate(typeList); + xsd = ""; + } + catch ( IllegalArgumentException e ) + { + } + assertNull(xsd); + } + + public void testXSDGeneration_DynamicSDOType() throws IOException + { + //test for dynamic SDOs that have no XSD model. Here the testcase succeeds only if the + //xsd is generated by XSDHelper in which case xsd must not be null + XSDHelper xsdHelper = SDOUtil.createXSDHelper(SDOUtil.createTypeHelper()); + DataObject quoteType = DataFactory.INSTANCE.create("commonj.sdo", "Type"); + quoteType.set("uri", "http://www.example.com/dynamic"); + quoteType.set("name", "DynamicQuote"); + + DataObject aProperty = quoteType.createDataObject("property"); + aProperty.set("name", "symbol"); + aProperty.set("type", TypeHelper.INSTANCE.getType("commonj.sdo", "String")); + + aProperty = quoteType.createDataObject("property"); + aProperty.set("name", "price"); + aProperty.set("type", TypeHelper.INSTANCE.getType("commonj.sdo", "Decimal")); + + aProperty = quoteType.createDataObject("property"); + aProperty.set("name", "volume"); + aProperty.set("type", TypeHelper.INSTANCE.getType("commonj.sdo", "Double")); + + TypeHelper.INSTANCE.define(quoteType); + + Type dynamicQuoteType = + TypeHelper.INSTANCE.getType("http://www.example.com/dynamic", "DynamicQuote"); + + Vector types = new Vector(); + types.add(dynamicQuoteType); + String xsd = null; + + try + { + xsd = xsdHelper.generate(types); + //System.out.println(xsd); + } + catch ( IllegalArgumentException e ) + { + } + assertNotNull(xsd); + + } + + public void testXSDGeneration_DynamicWithNestedStaticSDOType() throws IOException + { + //testing static SDO with XSD Model being contained in a Dynamic SDO not having an XSD Model. + //the schema must be generated with imports / includes for the XSD corresponding to the static + //sdo types. + TypeHelper typeHelper = SDOUtil.createTypeHelper(); + XSDHelper xsdHelper = SDOUtil.createXSDHelper(typeHelper); + + DataObject quoteSDO = (DataObject)SimpleFactoryImpl.INSTANCE.createQuote(); + + + DataObject quoteType = DataFactory.INSTANCE.create("commonj.sdo", "Type"); + quoteType.set("uri", "http://www.example.com/dynamic"); + quoteType.set("name", "DynamicQuote"); + + DataObject aProperty = quoteType.createDataObject("property"); + aProperty.set("name", "symbol"); + aProperty.set("type", typeHelper.getType("commonj.sdo", "String")); + + aProperty = quoteType.createDataObject("property"); + aProperty.set("name", "price"); + aProperty.set("type", typeHelper.getType("commonj.sdo", "Decimal")); + + aProperty = quoteType.createDataObject("property"); + aProperty.set("name", "volume"); + aProperty.set("type", typeHelper.getType("commonj.sdo", "Double")); + + aProperty = quoteType.createDataObject("property"); + aProperty.set("name", "containedQuotes"); + aProperty.set("type", typeHelper.getType(quoteSDO.getType().getURI(), quoteSDO.getType().getName())); + aProperty.set("containment", new Boolean(true)); + + aProperty = quoteType.createDataObject("property"); + aProperty.set("name", "referredQuotes"); + aProperty.set("type", typeHelper.getType(quoteSDO.getType().getURI(), quoteSDO.getType().getName())); + + typeHelper.define(quoteType); + + Type dynamicQuoteType = + typeHelper.getType("http://www.example.com/dynamic", "DynamicQuote"); + Vector types = new Vector(); + types.add(dynamicQuoteType); + String xsd = null; + + try + { + Hashtable schemaLocationMap = new Hashtable(); + schemaLocationMap.put("http://www.example.com/simple", "http://www.example.com/simple/xsd"); + xsd = xsdHelper.generate(types, schemaLocationMap); + //System.out.println(xsd); + } + catch ( IllegalArgumentException e ) + { + } + assertNotNull(xsd); + + } + + protected void setUp() throws Exception { + super.setUp(); + modelURL = getClass().getResource(TEST_MODEL); + } +} diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/SubstitutionValues.xsd b/sandbox/jboynes/sdo/impl/src/test/resources/SubstitutionValues.xsd new file mode 100644 index 0000000000..7aee02c032 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/SubstitutionValues.xsd @@ -0,0 +1,30 @@ +<schema xmlns="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.apache.org/tuscany/SubstitutionValues" + xmlns:sv="http://www.apache.org/tuscany/SubstitutionValues"> + <!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> + <element name="groupHead" type="string"/> + <complexType name="TestObject"> + <sequence> + <element ref="sv:groupHead"/> + <element name="nonGroupHead" type="string"/> + </sequence> + </complexType> + <element name="groupMember" type="string" substitutionGroup="sv:groupHead"/> +</schema>
\ No newline at end of file diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/XMLDocumentNoNamespaceSchemaLocation.xsd b/sandbox/jboynes/sdo/impl/src/test/resources/XMLDocumentNoNamespaceSchemaLocation.xsd new file mode 100644 index 0000000000..cd9469a4bb --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/XMLDocumentNoNamespaceSchemaLocation.xsd @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Copyright (c) 2005-2006 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. + --> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + + <xsd:element name="aNoNamespaceSchemaLocationElement"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="anElement" type="xsd:string" minOccurs="1" maxOccurs="unbounded"/> + </xsd:sequence> + <xsd:attribute name="date" type="xsd:date"/> + </xsd:complexType> + </xsd:element> + +</xsd:schema> diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/XMLDocumentSchemaLocation.xsd b/sandbox/jboynes/sdo/impl/src/test/resources/XMLDocumentSchemaLocation.xsd new file mode 100644 index 0000000000..2e04125cb8 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/XMLDocumentSchemaLocation.xsd @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Copyright (c) 2005-2006 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. + --> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.example.com/xmlDocumentSchemaLocation" + xmlns:sl="http://www.example.com/xmlDocumentSchemaLocation"> + + <xsd:element name="schemaLocationElement" type="xsd:string" /> + + <xsd:element name="purchaseReport"> + <xsd:complexType> + <xsd:sequence> + <xsd:any minOccurs="1" maxOccurs="unbounded"/> + </xsd:sequence> + <xsd:attribute name="periodEnding" type="xsd:date"/> + </xsd:complexType> + </xsd:element> + +</xsd:schema> diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/XMLDocumentTestCase.xml b/sandbox/jboynes/sdo/impl/src/test/resources/XMLDocumentTestCase.xml new file mode 100644 index 0000000000..88160e0b2f --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/XMLDocumentTestCase.xml @@ -0,0 +1,14 @@ +<sl:purchaseReport + xmlns:sl="http://www.example.com/xmlDocumentSchemaLocation" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.example.com/xmlDocumentSchemaLocation + /XMLDocumentSchemaLocation.xsd + http://www.example.com/open + /open.xsd" + xsi:noNamespaceSchemaLocation="/XMLDocumentNoNamespaceSchemaLocation.xsd" + periodEnding="2007-12-31"> + <sl:schemaLocationElement>some string</sl:schemaLocationElement> + <aNoNamespaceSchemaLocationElement date="2006-04-01"> + <anElement>another string</anElement> + </aNoNamespaceSchemaLocationElement> +</sl:purchaseReport> diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/anytype.xsd b/sandbox/jboynes/sdo/impl/src/test/resources/anytype.xsd new file mode 100644 index 0000000000..880b54dc0d --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/anytype.xsd @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!-- + * Copyright (c) 2005-2006 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. + -->
+<xsd:schema xmlns:sdot="http://www.example.com/anytype" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/anytype">
+
+ <xsd:element name="globalElement">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="anyTypeElement" type="xsd:anyType"/>
+ <xsd:element name="personElement" type="sdot:Person"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <xsd:complexType name="Person">
+ <xsd:sequence>
+ <xsd:element name="firstName" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+</xsd:schema>
diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/api_test.xsd b/sandbox/jboynes/sdo/impl/src/test/resources/api_test.xsd new file mode 100644 index 0000000000..e4c441ab84 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/api_test.xsd @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!-- + * Copyright (c) 2005-2006 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. + -->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sdo="commonj.sdo" xmlns:simple="http://www.example.com/api_test" targetNamespace="http://www.example.com/api_test">
+ <xsd:import namespace="commonj.sdo" schemaLocation="sdoModel.xsd"/>
+ <xsd:element name="apiTestElem" type="simple:APITest"/>
+
+ <xsd:complexType mixed="true" name="APITest">
+ <xsd:sequence>
+ <xsd:element name="stringVal" type="sdo:String"/>
+ <xsd:element name="booleanVal" type="sdo:Boolean"/>
+ <xsd:element name="booleanVal2" type="sdo:Boolean"/>
+ <xsd:element name="byteVal" type="sdo:Byte"/>
+ <xsd:element name="stringVal2" type="sdo:String"/>
+ <xsd:element name="decimalVal" type="sdo:Decimal"/>
+ <xsd:element name="decimalVal2" type="sdo:Decimal"/>
+ <xsd:element name="intVal" type="sdo:Int"/>
+ <xsd:element name="floatVal" type="sdo:Float"/>
+ <xsd:element name="doubleVal" type="sdo:Double"/>
+ <xsd:element name="dateVal" type="sdo:Date"/>
+ <xsd:element name="shortVal" type="sdo:Short"/>
+ <xsd:element name="longVal" type="sdo:Long"/>
+ <xsd:element maxOccurs="unbounded" minOccurs="0" name="children" type="simple:APITest"/>
+ <xsd:element name="bytesVal" type="sdo:Bytes"/>
+ <xsd:element name="integerVal" type="sdo:Integer"/>
+ <xsd:element name="charVal" type="sdo:Character"/>
+ <xsd:element name="xsdDate" type="xsd:date"/>
+ </xsd:sequence>
+ </xsd:complexType>
+</xsd:schema>
diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/bank.xsd b/sandbox/jboynes/sdo/impl/src/test/resources/bank.xsd new file mode 100644 index 0000000000..9a6ac82402 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/bank.xsd @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<!-- + * Copyright (c) 2005-2006 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. + -->
+<xsd:schema targetNamespace="http://www.example.com/bank"
+ xmlns:bank="http://www.example.com/bank"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:sdoXML="commonj.sdo/xml">
+
+ <xsd:element name="bank" type="bank:bankType"/>
+
+ <xsd:complexType name="bankType">
+ <xsd:sequence>
+ <xsd:element name="Branch" type="bank:branchType" maxOccurs="unbounded" />
+ <xsd:element name="Service" type="bank:serviceType" maxOccurs="unbounded" />
+ <xsd:element name="Customer" type="bank:customerType" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="branchType">
+ <xsd:sequence>
+ <xsd:element name="Address" type="bank:addressType"/>
+ <xsd:element name="Directions" type="xsd:string" maxOccurs="unbounded" />
+ <xsd:element name="Account" type="bank:accountType" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="ID" type="xsd:ID"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="serviceType">
+ <xsd:attribute name="ID" type="xsd:ID"/>
+ <xsd:attribute name="Name" type="xsd:string"/>
+ <xsd:attribute name="Fee" type="xsd:decimal"/>
+ </xsd:complexType>
+
+ <xsd:complexType name="accountType">
+ <xsd:attribute name="ID" type="xsd:ID"/>
+ <xsd:attribute name="Service" type="xsd:IDREF" sdoXML:propertyType="bank:serviceType" />
+ <xsd:attribute name="Balance" type="xsd:decimal" />
+ </xsd:complexType>
+
+ <xsd:complexType name="customerType">
+ <xsd:sequence>
+ <xsd:element name="First" type="xsd:string" />
+ <xsd:element name="Last" type="xsd:string" />
+ <xsd:element name="Address" type="bank:addressType"/>
+ <xsd:element name="HomeBranch" type="xsd:IDREF" sdoXML:propertyType="bank:branchType" />
+ <xsd:element name="Account" type="xsd:IDREF" sdoXML:propertyType="bank:accountType" maxOccurs="unbounded" />
+ </xsd:sequence>
+ <xsd:attribute name="ID" type="xsd:ID"/>
+ <xsd:attribute name="Related" type="xsd:IDREFS" sdoXML:propertyType="bank:customerType" />
+ </xsd:complexType>
+
+ <xsd:complexType name="addressType">
+ <xsd:sequence>
+ <xsd:element name="Street" type="xsd:string"/>
+ <xsd:element name="City" type="xsd:string"/>
+ <xsd:element name="State" type="xsd:string"/>
+ <xsd:element name="Zip" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ </xsd:schema>
diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/company.xsd b/sandbox/jboynes/sdo/impl/src/test/resources/company.xsd new file mode 100644 index 0000000000..18e99352be --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/company.xsd @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> + <!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> + <xsd:schema xmlns:company="company.xsd" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="company.xsd"> + <xsd:element name="company" type="company:CompanyType"/> + <xsd:complexType name="CompanyType"> + <xsd:sequence> + <xsd:element name="departments" type="company:DepartmentType" maxOccurs="unbounded"/> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string"/> + <xsd:attribute name="employeeOfTheMonth" type="xsd:string"/> + </xsd:complexType> + <xsd:complexType name="DepartmentType"> + <xsd:sequence> + <xsd:element name="employees" type="company:EmployeeType" maxOccurs="unbounded"/> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string"/> + <xsd:attribute name="location" type="xsd:string"/> + <xsd:attribute name="number" type="xsd:int"/> + </xsd:complexType> + <xsd:complexType name="EmployeeType"> + <xsd:attribute name="name" type="xsd:string"/> + <xsd:attribute name="SN" type="xsd:ID"/> + <xsd:attribute name="manager" type="xsd:boolean"/> + </xsd:complexType> + </xsd:schema> diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/customer1.xml b/sandbox/jboynes/sdo/impl/src/test/resources/customer1.xml new file mode 100644 index 0000000000..5a29e30a3c --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/customer1.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="ASCII"?> +<customer:Customer + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:customer="http://example.com/customer" + xsi:type="customer:Customer" + custNum="1" + firstName="John" + lastName="Adams"/>
\ No newline at end of file diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/customer2.xml b/sandbox/jboynes/sdo/impl/src/test/resources/customer2.xml new file mode 100644 index 0000000000..e9ebb92677 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/customer2.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="ASCII"?> +<customer:Customer + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:customer="http://example.com/customer" + xsi:type="customer:Customer" + custNum="2" + firstName="Jeremy" + lastName="Pavick"/>
\ No newline at end of file diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/datatype.xsd b/sandbox/jboynes/sdo/impl/src/test/resources/datatype.xsd new file mode 100644 index 0000000000..df6708bd39 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/datatype.xsd @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Copyright (c) 2005-2006 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. + --> +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:datatype="http://www.example.com/datatype" xmlns:sdoJava="commonj.sdo/java" targetNamespace="http://www.example.com/datatype"> + + <xsd:simpleType name="SimpleSDOType"> + <xsd:restriction base="xsd:string"/> + </xsd:simpleType> + + <xsd:simpleType name="SimpleSDOTypeInstanceClass" sdoJava:instanceClass="java.lang.Integer"> + <xsd:restriction base="xsd:string"/> + </xsd:simpleType> + + <xsd:simpleType name="SimpleSDOTypeExtendedInstanceClass" sdoJava:extendedInstanceClass="java.lang.String"> + <xsd:restriction base="xsd:string"/> + </xsd:simpleType> + +</xsd:schema> diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/foo-ext.xml b/sandbox/jboynes/sdo/impl/src/test/resources/foo-ext.xml new file mode 100644 index 0000000000..000909a52e --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/foo-ext.xml @@ -0,0 +1,9 @@ +<module name="m" xmlns="http://foo" xmlns:bar="http://bar" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://bar foo-ext.xsd http://foo foo.xsd "> + <component name="c"> + <bar:implementation.mock myAttr="helloworld.HelloWorldImpl" + listAttr="1 2">1<bar:myElement>Dummy</bar:myElement>2 + </bar:implementation.mock> + </component> +</module>
\ No newline at end of file diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/foo-ext.xsd b/sandbox/jboynes/sdo/impl/src/test/resources/foo-ext.xsd new file mode 100644 index 0000000000..cb74df8fa3 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/foo-ext.xsd @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (c) 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. +--> +<schema xmlns="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://bar" + elementFormDefault="qualified" + xmlns:foo="http://foo" xmlns:bar="http://bar"> + + <import namespace="http://foo" + schemaLocation="foo.xsd" /> + + <element name="implementation.mock" type="bar:MockImplementation" + substitutionGroup="foo:implementation" /> + <complexType name="MockImplementation" mixed="true"> + <complexContent> + <extension base="foo:Implementation"> + <sequence> + <element name="myElement" type="string"/> + <any namespace="##other" processContents="lax" + minOccurs="0" maxOccurs="unbounded" /> + </sequence> + <attribute name="myAttr" type="NCName" use="required" /> + <attribute name="listAttr" type="NMTOKENS" use="optional" /> + <anyAttribute namespace="##any" processContents="lax" /> + </extension> + </complexContent> + </complexType> +</schema> diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/foo.xsd b/sandbox/jboynes/sdo/impl/src/test/resources/foo.xsd new file mode 100644 index 0000000000..fec090de71 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/foo.xsd @@ -0,0 +1,229 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Copyright (c) 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. + --> +<schema xmlns="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://foo" + elementFormDefault="qualified" xmlns:foo="http://foo"> + + <element name="componentType" type="foo:ComponentType"/> + <complexType name="ComponentType"> + <sequence> + <element minOccurs="0" maxOccurs="unbounded" name="service" type="foo:Service"/> + <element minOccurs="0" maxOccurs="unbounded" name="reference" type="foo:Reference"/> + <element minOccurs="0" maxOccurs="unbounded" name="property" type="foo:Property"/> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + + <complexType name="Service"> + <sequence> + <element minOccurs="1" maxOccurs="1" ref="foo:interface"/> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="name" type="NCName" use="required"/> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + + <element name="interface" type="foo:Interface"/> + <complexType name="Interface"/> + + <complexType name="Reference"> + <sequence> + <element minOccurs="1" maxOccurs="1" ref="foo:interface"/> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="name" type="NCName" use="required"/> + <attribute name="multiplicity" type="foo:Multiplicity" use="optional" default="1..1"/> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + + <complexType name="Property"> + <sequence> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="name" type="NCName" use="required"/> + <attribute name="type" type="QName" use="required"/> + <attribute name="many" type="boolean" default="false" use="optional"/> + <attribute name="required" type="boolean" default="false" use="optional"/> + <attribute name="default" type="string" use="optional"/> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + + + <element name="moduleFragment" type="foo:ModuleFragment"/> + <complexType name="ModuleFragment"> + <sequence> + <element minOccurs="0" maxOccurs="unbounded" name="entryPoint" type="foo:EntryPoint"/> + <element minOccurs="0" maxOccurs="unbounded" name="component" type="foo:Component"/> + <element minOccurs="0" maxOccurs="unbounded" name="externalService" type="foo:ExternalService"/> + <element minOccurs="0" maxOccurs="unbounded" name="wire" type="foo:ModuleWire"/> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="name" type="NCName" use="required"/> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + + <element name="module" type="foo:Module"/> + <complexType name="Module"> + <complexContent> + <extension base="foo:ModuleFragment"/> + </complexContent> + </complexType> + + <complexType name="EntryPoint"> + <sequence> + <element minOccurs="0" maxOccurs="1" ref="foo:interface"/> + <element minOccurs="1" maxOccurs="unbounded" ref="foo:binding"/> + <element minOccurs="1" maxOccurs="unbounded" name="reference" type="anyURI"/> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="name" type="NCName" use="required"/> + <attribute name="multiplicity" type="foo:Multiplicity" use="optional" default="1..1"/> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + <!-- a multiplicity 1..1 or 0..n sample + <reference>StockQuoteComponent</reference> - type must be URI + a multiplicity 1..n or 0..n sample + <reference>StockQuoteComponent1</reference> - type must be URI + <reference>StockQuoteComponent2</reference> + --> + + <element name="binding" type="foo:Binding"/> + <complexType name="Binding"> + <attribute name="uri" type="anyURI" use="optional"/> + </complexType> + + <complexType name="Component"> + <sequence> + <element minOccurs="1" maxOccurs="1" ref="foo:implementation"/> + <element minOccurs="0" maxOccurs="1" name="properties" type="foo:PropertyValues"/> + <element minOccurs="0" maxOccurs="1" name="references" type="foo:ReferenceValues"/> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="name" type="NCName" use="required"/> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + <!-- a multiplicity 1..1 or 0..1 sample + <references> + <v:stockQuote>StockQuoteComponent</v:stockquote> - type must be URI + </references> + a multiplicity 1..n or 0..n sample + <references> + <v:stockQuote>StockQuoteComponent1</v:stockQuote> - type must be URI + <v:stockQuote>StockQuoteComponent2</v:stockQuote> + </references> + --> + + <element name="implementation" type="foo:Implementation"/> + <complexType name="Implementation"/> + + <complexType name="PropertyValues"> + <sequence> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + + <complexType name="ReferenceValues"> + <sequence> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + + + <complexType name="ExternalService"> + <sequence> + <element minOccurs="1" maxOccurs="1" ref="foo:interface"/> + <element minOccurs="0" maxOccurs="unbounded" ref="foo:binding"/> + </sequence> + <attribute name="name" type="NCName" use="required"/> + <attribute name="overridable" type="foo:OverrideOptions" default="may" use="optional"/> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + + + <complexType name="ModuleWire"> + <sequence> + <element minOccurs="1" maxOccurs="1" ref="foo:source.uri"/> + <element minOccurs="1" maxOccurs="1" ref="foo:target.uri"/> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + + <element name="source"/> + <element name="target"/> + + <element name="source.uri" type="anyURI" substitutionGroup="foo:source"/> + <element name="target.uri" type="anyURI" substitutionGroup="foo:target"/> + + <element name="subsystem" type="foo:Subsystem"/> + <complexType name="Subsystem"> + <sequence> + <element minOccurs="0" maxOccurs="unbounded" name="entryPoint" type="foo:EntryPoint"/> + <element minOccurs="0" maxOccurs="unbounded" name="moduleComponent" type="foo:ModuleComponent"/> + <element minOccurs="0" maxOccurs="unbounded" name="externalService" type="foo:ExternalService"/> + <element minOccurs="0" maxOccurs="unbounded" name="wire" type="foo:SystemWire"/> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="name" type="NCName" use="required"/> + <attribute name="uri" type="anyURI" use="optional"/> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + + <complexType name="ModuleComponent"> + <sequence> + <element minOccurs="0" maxOccurs="1" name="properties" type="foo:PropertyValues"/> + <element minOccurs="0" maxOccurs="1" name="references" type="foo:ReferenceValues"/> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + <attribute name="name" type="NCName" use="required"/> + <attribute name="module" type="NCName" use="required"/> + <attribute name="uri" type="anyURI" use="optional"/> + <anyAttribute namespace="##any" processContents="lax"/> + </complexType> + + <complexType name="SystemWire"> + <sequence> + <element minOccurs="1" maxOccurs="1" ref="foo:source"/> + <element minOccurs="1" maxOccurs="1" ref="foo:target"/> + <any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"/> + </sequence> + </complexType> + + <element name="source.epr" substitutionGroup="foo:source"/> + <element name="target.epr" substitutionGroup="foo:target"/> + + <simpleType name="Multiplicity"> + <restriction base="string"> + <enumeration value="0..1"/> + <enumeration value="1..1"/> + <enumeration value="0..n"/> + <enumeration value="1..n"/> + </restriction> + </simpleType> + + <simpleType name="OverrideOptions"> + <restriction base="string"> + <enumeration value="no"/> + <enumeration value="may"/> + <enumeration value="must"/> + </restriction> + </simpleType> + +</schema> diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/mixed.xml b/sandbox/jboynes/sdo/impl/src/test/resources/mixed.xml new file mode 100644 index 0000000000..42ff3a3a5b --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/mixed.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="ASCII"?> +<mixed:mixedStockQuote xmlns:mixed="http://www.example.com/mixed"> + <symbol>fbnt</symbol> + <companyName>FlyByNightTechnology</companyName> + some text + <quotes><price>2000.0</price></quotes> + more text + <price>1000.0</price> +</mixed:mixedStockQuote>
\ No newline at end of file diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/mixed.xsd b/sandbox/jboynes/sdo/impl/src/test/resources/mixed.xsd new file mode 100644 index 0000000000..c45fc87de2 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/mixed.xsd @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Copyright (c) 2005-2006 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. + --> +<xsd:schema + targetNamespace="http://www.example.com/mixed" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:simple="http://www.example.com/mixed"> + + <xsd:element name="mixedStockQuote" type="simple:MixedQuote"/> + + <xsd:complexType name="MixedQuote" mixed="true"> + <xsd:sequence> + <xsd:element name="symbol" type="xsd:string"/> + <xsd:element name="companyName" type="xsd:string"/> + <xsd:element name="price" type="xsd:decimal"/> + <xsd:element name="open1" type="xsd:decimal"/> + <xsd:element name="high" type="xsd:decimal"/> + <xsd:element name="low" type="xsd:decimal"/> + <xsd:element name="volume" type="xsd:double"/> + <xsd:element name="change1" type="xsd:double"/> + <xsd:element name="quotes" type="simple:MixedQuote" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:complexType> + +</xsd:schema> diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/mixed2.xml b/sandbox/jboynes/sdo/impl/src/test/resources/mixed2.xml new file mode 100644 index 0000000000..d95d179478 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/mixed2.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="ASCII"?> +<mixed:mixedStockQuote + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:mixed="http://www.example.com/mixed" + xsi:type="mixed:MixedQuote"> + <symbol>fbnt</symbol> + <companyName>FlyByNightTechnology</companyName> + some text + <quotes><price>2000.0</price></quotes> + more text + <price>1000.0</price> +</mixed:mixedStockQuote>
\ No newline at end of file diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/mixedopen.xml b/sandbox/jboynes/sdo/impl/src/test/resources/mixedopen.xml new file mode 100644 index 0000000000..21a62ef2d0 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/mixedopen.xml @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="ASCII"?> +<mixed:mixedOpenStockQuote + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:mixed="http://www.example.com/mixed" + xmlns:open="http://www.example.com/open" + xsi:type="mixed:MixedOpenQuote"> + <open:symbol>fbnt</open:symbol> + <companyName>FlyByNightTechnology</companyName> + some text + <quotes><price>2000.0</price></quotes> + more text + <price>1000.0</price> +</mixed:mixedOpenStockQuote> diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/names.xsd b/sandbox/jboynes/sdo/impl/src/test/resources/names.xsd new file mode 100644 index 0000000000..9e0ce42efb --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/names.xsd @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Copyright (c) 2005-2006 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. + --> +<xsd:schema + targetNamespace="http://www.example.com/names" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:names="http://www.example.com/names"> + + <xsd:element name="class" type="names:class"/> + <xsd:element name="test.element" type="names:test.element" /> + <xsd:element name="void" type="names:void" /> + + <xsd:complexType name="class" /> + <xsd:complexType name="test.element" /> + <xsd:complexType name="void" /> + +</xsd:schema> diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/open.xml b/sandbox/jboynes/sdo/impl/src/test/resources/open.xml new file mode 100644 index 0000000000..d4a5b92e0c --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/open.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="ASCII"?> +<open:openStockQuote xmlns:open="http://www.example.com/open"> + <symbol>s1</symbol> + <open:company> + <name>FlyByNightTechnology</name> + </open:company> + <open:price>1000.0</open:price> +</open:openStockQuote>
\ No newline at end of file diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/open.xsd b/sandbox/jboynes/sdo/impl/src/test/resources/open.xsd new file mode 100644 index 0000000000..06881e3f05 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/open.xsd @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Copyright (c) 2005-2006 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. + --> +<xsd:schema + xmlns:simple="http://www.example.com/open" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.example.com/open"> + + <xsd:element name="openStockQuote" type="simple:OpenQuote"/> + + <xsd:element name="price" type="xsd:decimal"/> + + <xsd:element name="company"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="name" type="xsd:string"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + + <xsd:complexType name="OpenQuote"> + <xsd:sequence> + <xsd:element name="symbol" type="xsd:string"/> + <xsd:any maxOccurs="unbounded" namespace="##any"/> + </xsd:sequence> + </xsd:complexType> + +</xsd:schema> diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/open1any.xsd b/sandbox/jboynes/sdo/impl/src/test/resources/open1any.xsd new file mode 100644 index 0000000000..00efaef5e0 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/open1any.xsd @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> +<xsd:schema + xmlns:simple="http://www.example.com/open1any" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + targetNamespace="http://www.example.com/open1any"> + + <xsd:element name="openStockQuote" type="simple:OpenQuote"/> + + <xsd:element name="price" type="xsd:decimal"/> + + <xsd:element name="company"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="name" type="xsd:string"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + + <xsd:complexType name="OpenQuote"> + <xsd:sequence> + <xsd:element name="symbol" type="xsd:string"/> + <xsd:any namespace="##any"/> + </xsd:sequence> + </xsd:complexType> + +</xsd:schema> diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/open2.xml b/sandbox/jboynes/sdo/impl/src/test/resources/open2.xml new file mode 100644 index 0000000000..ab992ccf74 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/open2.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="ASCII"?> +<open:openStockQuote + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:open="http://www.example.com/open" + xsi:type="open:OpenQuote"> + <open:symbol>s1</open:symbol> + <open:company name="FlyByNightTechnology"/> + <open:price>1000.0</open:price> +</open:openStockQuote> diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/openContentProperty.xml b/sandbox/jboynes/sdo/impl/src/test/resources/openContentProperty.xml new file mode 100644 index 0000000000..03608365c0 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/openContentProperty.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="ASCII"?>
+<open:openStockQuote xmlns:open="http://www.example.com/open">
+ <symbol>s1</symbol>
+ <open:company>
+ <name>FlyByNightTechnology</name>
+ </open:company>
+ <open:price>1000.0</open:price>
+ <open:highPrice>1100.0</open:highPrice>
+ <open:mutualFundQuote>
+ <symbol>mutual-1</symbol>
+ </open:mutualFundQuote>
+</open:openStockQuote>
\ No newline at end of file diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/po.xsd b/sandbox/jboynes/sdo/impl/src/test/resources/po.xsd new file mode 100644 index 0000000000..5c53ac1905 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/po.xsd @@ -0,0 +1,62 @@ +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns="http://www.example.com/PO" targetNamespace="http://www.example.com/PO"> + + <xsd:element name="purchaseOrder" type="PurchaseOrderType"/> + <xsd:element name="comment" type="xsd:string"/> + + <xsd:complexType name="PurchaseOrderType"> + <xsd:sequence> + <xsd:element name="shipTo" type="USAddress"/> + <xsd:element name="billTo" type="USAddress"/> + <xsd:element ref="comment" minOccurs="0"/> + <xsd:element name="items" type="Items"/> + + </xsd:sequence> + <xsd:attribute name="orderDate" type="xsd:date"/> + </xsd:complexType> + + <xsd:complexType name="USAddress"> + <xsd:sequence> + <xsd:element name="name" type="xsd:string"/> + + <xsd:element name="street" type="xsd:string"/> + <xsd:element name="city" type="xsd:string"/> + <xsd:element name="state" type="xsd:string"/> + <xsd:element name="zip" type="xsd:decimal"/> + </xsd:sequence> + <xsd:attribute name="country" type="xsd:NMTOKEN" fixed="US"/> + + </xsd:complexType> + + <xsd:complexType name="Items"> + <xsd:sequence> + <xsd:element name="item" minOccurs="0" maxOccurs="unbounded"> + <xsd:complexType> + <xsd:sequence> + + <xsd:element name="productName" type="xsd:string"/> + <xsd:element name="price" type="xsd:decimal"/> + <xsd:element name="quantity"> + <xsd:simpleType> + <xsd:restriction base="xsd:positiveInteger"> + <xsd:maxExclusive value="100"/> + </xsd:restriction> + + </xsd:simpleType> + </xsd:element> + <xsd:element ref="comment" minOccurs="0"/> + <xsd:element name="shipDate" type="xsd:date" minOccurs="0"/> + </xsd:sequence> + + <xsd:attribute name="partNum" type="SKU" use="required"/> + </xsd:complexType> + </xsd:element> + </xsd:sequence> + </xsd:complexType> + <xsd:simpleType name="SKU"> + + <xsd:restriction base="xsd:string"> + <xsd:pattern value="\d{3}-[A-Z]{2}"/> + </xsd:restriction> + </xsd:simpleType> + </xsd:schema> diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/quote.xml b/sandbox/jboynes/sdo/impl/src/test/resources/quote.xml new file mode 100644 index 0000000000..d7b5969e23 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/quote.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="ASCII"?> +<simple:stockQuote xmlns:simple="http://www.example.com/simple"> + <symbol>fbnt</symbol> + <companyName>FlyByNightTechnology</companyName> + <price>1000.0</price> + <open1>1000.0</open1> + <high>1000.0</high> + <low>1000.0</low> + <volume>1000.0</volume> + <change1>1000.0</change1> + <quotes> + <price>2000.0</price> + </quotes> +</simple:stockQuote>
\ No newline at end of file diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/sdoannotations.xsd b/sandbox/jboynes/sdo/impl/src/test/resources/sdoannotations.xsd new file mode 100644 index 0000000000..87c1991eba --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/sdoannotations.xsd @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Copyright (c) 2005-2006 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. + --> +<xsd:schema + targetNamespace="http://www.example.com/sdoannotations" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:sdoa="http://www.example.com/sdoannotations" + xmlns:sdo="commonj.sdo/xml" + xmlns:sdoj="commonj.sdo/java"> + + <!-- simple element with no annotations --> + <xsd:element name="foo0" type="xsd:string" /> + + <!-- simple element with sdo:name --> + <xsd:element name="foo1" type="xsd:string" sdo:name="foo2" /> + + <!-- simple element with sdo:type --> + <xsd:element + name="foo3" type="xsd:int" + sdo:dataType="xsd:string" + sdo:aliasName="foo4" + sdo:readOnly="true" /> + + <xsd:element + name="foo5" type="sdoa:foo6" /> + + <!-- complex type with no annotations --> + <xsd:complexType name="foo6"> + <xsd:sequence> + <xsd:element name="bar1" type="xsd:int" /> + </xsd:sequence> + <xsd:attribute name="bar2" type="xsd:int" /> + </xsd:complexType> + + <xsd:element + name="foo7" type="sdoa:foo8" /> + + <xsd:complexType name="foo8" sdo:name="foo9" sdoj:instanceClass="org.apache.tuscany.sdo.test.XSDHelperTestCase"> + <xsd:sequence> + <xsd:element name="bar3" type="xsd:int" sdo:string="true" /> + </xsd:sequence> + </xsd:complexType> + +</xsd:schema> diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/sdotypes.xsd b/sandbox/jboynes/sdo/impl/src/test/resources/sdotypes.xsd new file mode 100644 index 0000000000..668cf8f6ad --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/sdotypes.xsd @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Copyright (c) 2005-2006 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. + --> +<xsd:schema + targetNamespace="http://www.example.com/sdotypes" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:sdot="http://www.example.com/sdotypes"> + + <xsd:element name="foo0" type="xsd:anySimpleType"/> + <xsd:element name="foo2" type="xsd:anyURI"/> + <xsd:element name="foo3" type="xsd:base64Binary"/> + <xsd:element name="foo4" type="xsd:boolean"/> + <xsd:element name="foo5" type="xsd:byte"/> + <xsd:element name="foo6" type="xsd:date"/> + <xsd:element name="foo7" type="xsd:dateTime"/> + <xsd:element name="foo8" type="xsd:decimal"/> + <xsd:element name="foo9" type="xsd:double"/> + <xsd:element name="foo10" type="xsd:duration"/> + <xsd:element name="foo11" type="xsd:ENTITIES"/> + <xsd:element name="foo12" type="xsd:ENTITY"/> + <xsd:element name="foo13" type="xsd:float"/> + <xsd:element name="foo14" type="xsd:gDay"/> + <xsd:element name="foo15" type="xsd:gMonth"/> + <xsd:element name="foo16" type="xsd:gMonthDay"/> + <xsd:element name="foo17" type="xsd:gYear"/> + <xsd:element name="foo18" type="xsd:gYearMonth"/> + <xsd:element name="foo19" type="xsd:hexBinary"/> + <xsd:element name="foo20" type="xsd:ID"/> + <xsd:element name="foo21" type="xsd:IDREF"/> + <xsd:element name="foo22" type="xsd:IDREFS"/> + <xsd:element name="foo23" type="xsd:int"/> + <xsd:element name="foo24" type="xsd:integer"/> + <xsd:element name="foo25" type="xsd:language"/> + <xsd:element name="foo26" type="xsd:long"/> + <xsd:element name="foo27" type="xsd:Name"/> + <xsd:element name="foo28" type="xsd:NCName"/> + <xsd:element name="foo29" type="xsd:negativeInteger"/> + <xsd:element name="foo30" type="xsd:NMTOKEN"/> + <xsd:element name="foo31" type="xsd:NMTOKENS"/> + <xsd:element name="foo32" type="xsd:nonNegativeInteger"/> + <xsd:element name="foo33" type="xsd:nonPositiveInteger"/> + <xsd:element name="foo34" type="xsd:normalizedString"/> + <xsd:element name="foo35" type="xsd:NOTATION"/> + <xsd:element name="foo36" type="xsd:positiveInteger"/> + <xsd:element name="foo37" type="xsd:QName"/> + <xsd:element name="foo38" type="xsd:short"/> + <xsd:element name="foo39" type="xsd:string"/> + <xsd:element name="foo40" type="xsd:time"/> + <xsd:element name="foo41" type="xsd:token"/> + <xsd:element name="foo42" type="xsd:unsignedByte"/> + <xsd:element name="foo43" type="xsd:unsignedInt"/> + <xsd:element name="foo44" type="xsd:unsignedLong"/> + <xsd:element name="foo45" type="xsd:unsignedShort"/> + +</xsd:schema> diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/shallowquote.xml b/sandbox/jboynes/sdo/impl/src/test/resources/shallowquote.xml new file mode 100644 index 0000000000..a56f2fe2b7 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/shallowquote.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="ASCII"?> +<simple:stockQuote xmlns:simple="http://www.example.com/simple"> + <symbol>fbnt</symbol> + <companyName>FlyByNightTechnology</companyName> + <price>1000.0</price> + <open1>1000.0</open1> + <high>1000.0</high> + <low>1000.0</low> + <volume>1000.0</volume> + <change1>1000.0</change1> +</simple:stockQuote>
\ No newline at end of file diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/simple.xsd b/sandbox/jboynes/sdo/impl/src/test/resources/simple.xsd new file mode 100644 index 0000000000..5310f7e1f3 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/simple.xsd @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * Copyright (c) 2005-2006 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. + --> +<xsd:schema + targetNamespace="http://www.example.com/simple" + xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns:simple="http://www.example.com/simple"> + + <xsd:element name="stockQuote" type="simple:Quote"/> + + <xsd:complexType name="Quote"> + <xsd:sequence> + <xsd:element name="symbol" type="xsd:string"/> + <xsd:element name="companyName" type="xsd:string"/> + <xsd:element name="price" type="xsd:decimal"/> + <xsd:element name="open1" type="xsd:decimal"/> + <xsd:element name="high" type="xsd:decimal"/> + <xsd:element name="low" type="xsd:decimal"/> + <xsd:element name="volume" type="xsd:double"/> + <xsd:element name="change1" type="xsd:double"/> + <xsd:element name="quotes" type="simple:Quote" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + </xsd:complexType> + +</xsd:schema> diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/simplechangesummary.xml b/sandbox/jboynes/sdo/impl/src/test/resources/simplechangesummary.xml new file mode 100644 index 0000000000..1a34e0bf80 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/simplechangesummary.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="ASCII"?> +<sdo:datagraph xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sdo="commonj.sdo" + xmlns:sdo_1="http://www.apache.org/tuscany/2005/SDO" xmlns:simple="http://www.example.com/simple"> + <changeSummary xmlns="" + logging="false"> + <objectChanges key="#//@eRootObject"> + <value xsi:type="sdo_1:ChangeSummarySetting" featureName="symbol" set="false"/> + <value xsi:type="sdo_1:ChangeSummarySetting" featureName="companyName" set="false"/> + <value xsi:type="sdo_1:ChangeSummarySetting" featureName="price" set="false"/> + <value xsi:type="sdo_1:ChangeSummarySetting" featureName="open1" set="false"/> + <value xsi:type="sdo_1:ChangeSummarySetting" featureName="high" set="false"/> + <value xsi:type="sdo_1:ChangeSummarySetting" featureName="low" set="false"/> + <value xsi:type="sdo_1:ChangeSummarySetting" featureName="volume" dataValue="0.0" + set="false"/> + <value xsi:type="sdo_1:ChangeSummarySetting" featureName="change1" dataValue="0.0" + set="false"/> + <value xsi:type="sdo_1:ChangeSummarySetting" featureName="quotes" set="false"/> + </objectChanges> + <objectChanges key="#//@eRootObject/@quotes.0"> + <value xsi:type="sdo_1:ChangeSummarySetting" featureName="price" set="false"/> + </objectChanges> + </changeSummary> + <simple:Quote> + <symbol>fbnt</symbol> + <companyName>FlyByNightTechnology</companyName> + <price>1000.0</price> + <open1>1000.0</open1> + <high>1000.0</high> + <low>1000.0</low> + <volume>1000.0</volume> + <change1>1000.0</change1> + <quotes> + <price>2000.0</price> + </quotes> + </simple:Quote> +</sdo:datagraph> diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/xpath.xml b/sandbox/jboynes/sdo/impl/src/test/resources/xpath.xml new file mode 100644 index 0000000000..3b3e2ffbb4 --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/xpath.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="ASCII"?> +<xpath:drive xmlns:xpath="http://www.example.com/xpath" id="0"> + <Folder creation_date="1999-10-20" creator="Hasan" type="FolderType"> + <FolderName>Folder00000000000</FolderName> + <description>marries inflamed apprehended beseeming bustle</description> + <SecurityObject name="secure1"> + <Allows> + <Allow> + <User>Brian</User> + <Permissions>rw</Permissions> + </Allow> + <Allow> + <User>Fuhwei</User> + <Permissions>r</Permissions> + </Allow> + </Allows> + <Denies> + <Deny> + <User>Hasan</User> + </Deny> + <Deny> + <User>Frank</User> + </Deny> + </Denies> + </SecurityObject> + </Folder> + <Folder creation_date="2000-03-23" creator="Kapil" type="FileType"> + <FolderName>Folder00000000011</FolderName> + <description>Mumbling Jumblin Pink Panther goofs it up</description> + <SecurityObject name="secure2"> + <Allows> + <Allow> + <User>Imad</User> + <Permissions>x</Permissions> + </Allow> + <Allow> + <User>Robbie</User> + <Permissions>rwx</Permissions> + </Allow> + </Allows> + <Denies> + <Deny> + <User>Yang</User> + </Deny> + <Deny> + <User>Art</User> + </Deny> + </Denies> + </SecurityObject> + </Folder> +</xpath:drive>
\ No newline at end of file diff --git a/sandbox/jboynes/sdo/impl/src/test/resources/xpath.xsd b/sandbox/jboynes/sdo/impl/src/test/resources/xpath.xsd new file mode 100644 index 0000000000..0b817d425d --- /dev/null +++ b/sandbox/jboynes/sdo/impl/src/test/resources/xpath.xsd @@ -0,0 +1,75 @@ +<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" + xmlns="http://www.example.com/xpath" targetNamespace="http://www.example.com/xpath"> + <!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. + --> + <xsd:element name="drive" type="DriveType"/> + + <xsd:complexType name="DriveType"> + <xsd:sequence> + <xsd:element name="Folder" type="FolderType" minOccurs="0" maxOccurs="unbounded"/> + </xsd:sequence> + <xsd:attribute name="id" type="xsd:int"/> + </xsd:complexType> + + <xsd:complexType name="FolderType"> + <xsd:sequence> + <xsd:element name="FolderName" type="xsd:string"/> + <xsd:element name="description" type="xsd:string"/> + <xsd:element name="SecurityObject" type="SecurityObjectType"/> + </xsd:sequence> + <xsd:attribute name="creation_date" type="xsd:date" minOccurs="0"/> + <xsd:attribute name="creator" type="xsd:string" minOccurs="0"/> + <xsd:attribute name="type" type="xsd:string" minOccurs="0"/> + + </xsd:complexType> + + <xsd:complexType name="AllowsObjectType"> + <xsd:sequence> + <xsd:element name="Allow" minOccurs="0" maxOccurs="unbounded"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="User" type="xsd:string"/> + <xsd:element name="Permissions" type="xsd:string"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType name="DeniesObjectType"> + <xsd:sequence> + <xsd:element name="Deny" minOccurs="0" maxOccurs="unbounded"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="User" type="xsd:string"/> + </xsd:sequence> + </xsd:complexType> + </xsd:element> + </xsd:sequence> + </xsd:complexType> + + <xsd:complexType name="SecurityObjectType"> + <xsd:sequence> + <xsd:element name="Allows" type="AllowsObjectType"/> + <xsd:element name="Denies" type="DeniesObjectType"/> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string"/> + </xsd:complexType> + +</xsd:schema> |