From bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a Mon Sep 17 00:00:00 2001 From: dims Date: Tue, 17 Jun 2008 00:23:01 +0000 Subject: Move Tuscany from Incubator to top level. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68 --- sandbox/kgoodson/events/impl/model/SDO.ecore | 982 +++ sandbox/kgoodson/events/impl/model/SDO.genmodel | 583 ++ sandbox/kgoodson/events/impl/model/SDO.mdl | 7670 ++++++++++++++++++++ sandbox/kgoodson/events/impl/pom.xml | 165 + .../org/apache/tuscany/sdo/AnyTypeDataObject.java | 37 + .../apache/tuscany/sdo/SDOExtendedMetaData.java | 39 + .../java/org/apache/tuscany/sdo/SDOFactory.java | 185 + .../java/org/apache/tuscany/sdo/SDOPackage.java | 1657 +++++ .../org/apache/tuscany/sdo/SDOTypeVisitor.java | 49 + .../tuscany/sdo/SimpleAnyTypeDataObject.java | 35 + .../org/apache/tuscany/sdo/api/ListenerBase.java | 13 + .../sdo/codegen/BytecodeInterfaceGenerator.java | 98 + .../tuscany/sdo/codegen/GenerationException.java | 42 + .../sdo/codegen/JavaInterfaceGenerator.java | 179 + .../sdo/codegen/NoJavaImplementationException.java | 61 + .../sdo/helper/BaseSDOExtendedMetaDataImpl.java | 167 + .../tuscany/sdo/helper/BaseSDOXSDEcoreBuilder.java | 1614 ++++ .../apache/tuscany/sdo/helper/CopyHelperImpl.java | 84 + .../sdo/helper/CrossScopeCopyHelperImpl.java | 255 + .../apache/tuscany/sdo/helper/DataFactoryImpl.java | 59 + .../apache/tuscany/sdo/helper/DataHelperImpl.java | 616 ++ .../sdo/helper/DefaultHelperContextImpl.java | 72 + .../tuscany/sdo/helper/EqualityHelperImpl.java | 81 + .../tuscany/sdo/helper/HelperContextImpl.java | 193 + .../tuscany/sdo/helper/HelperProviderImpl.java | 50 + .../apache/tuscany/sdo/helper/SDOAnnotations.java | 51 + .../sdo/helper/SDOExtendedMetaDataImpl.java | 285 + .../apache/tuscany/sdo/helper/SDOHelperImpl.java | 489 ++ .../tuscany/sdo/helper/SDOXSDEcoreBuilder.java | 831 +++ .../apache/tuscany/sdo/helper/SchemaBuilder.java | 786 ++ .../apache/tuscany/sdo/helper/TypeHelperImpl.java | 317 + .../org/apache/tuscany/sdo/helper/TypeTable.java | 254 + .../apache/tuscany/sdo/helper/XMLDocumentImpl.java | 574 ++ .../apache/tuscany/sdo/helper/XMLHelperImpl.java | 191 + .../apache/tuscany/sdo/helper/XMLStreamHelper.java | 26 + .../tuscany/sdo/helper/XMLStreamHelperImpl.java | 152 + .../apache/tuscany/sdo/helper/XSDHelperImpl.java | 327 + .../tuscany/sdo/impl/AnyTypeDataObjectImpl.java | 299 + .../org/apache/tuscany/sdo/impl/AttributeImpl.java | 836 +++ .../apache/tuscany/sdo/impl/ChangeSummaryImpl.java | 876 +++ .../tuscany/sdo/impl/ChangeSummarySettingImpl.java | 113 + .../org/apache/tuscany/sdo/impl/ClassImpl.java | 1127 +++ .../org/apache/tuscany/sdo/impl/DataGraphImpl.java | 852 +++ .../apache/tuscany/sdo/impl/DataObjectBase.java | 477 ++ .../apache/tuscany/sdo/impl/DataObjectImpl.java | 1551 ++++ .../org/apache/tuscany/sdo/impl/DataTypeImpl.java | 781 ++ .../tuscany/sdo/impl/DynamicDataObjectImpl.java | 216 + .../sdo/impl/DynamicStoreDataObjectImpl.java | 91 + .../java/org/apache/tuscany/sdo/impl/EnumImpl.java | 183 + .../org/apache/tuscany/sdo/impl/EventImpl.java | 142 + .../tuscany/sdo/impl/ExtensibleDataObjectImpl.java | 267 + .../org/apache/tuscany/sdo/impl/FactoryBase.java | 368 + .../org/apache/tuscany/sdo/impl/ReferenceImpl.java | 785 ++ .../apache/tuscany/sdo/impl/SDOFactoryImpl.java | 337 + .../apache/tuscany/sdo/impl/SDOPackageImpl.java | 2207 ++++++ .../sdo/impl/SimpleAnyTypeDataObjectImpl.java | 333 + .../tuscany/sdo/impl/StoreDataObjectImpl.java | 314 + .../tuscany/sdo/model/BaseDataGraphType.java | 213 + .../apache/tuscany/sdo/model/DataGraphType.java | 53 + .../org/apache/tuscany/sdo/model/DataObject.java | 35 + .../org/apache/tuscany/sdo/model/ModelFactory.java | 106 + .../org/apache/tuscany/sdo/model/ModelsType.java | 62 + .../org/apache/tuscany/sdo/model/Property.java | 503 ++ .../org/apache/tuscany/sdo/model/TextType.java | 57 + .../java/org/apache/tuscany/sdo/model/Type.java | 431 ++ .../java/org/apache/tuscany/sdo/model/Types.java | 59 + .../java/org/apache/tuscany/sdo/model/XSDType.java | 62 + .../sdo/model/impl/BaseDataGraphTypeImpl.java | 625 ++ .../tuscany/sdo/model/impl/DataGraphTypeImpl.java | 258 + .../tuscany/sdo/model/impl/DataObjectImpl.java | 84 + .../tuscany/sdo/model/impl/ModelFactoryImpl.java | 2401 ++++++ .../tuscany/sdo/model/impl/ModelsTypeImpl.java | 220 + .../tuscany/sdo/model/impl/PropertyImpl.java | 1170 +++ .../tuscany/sdo/model/impl/TextTypeImpl.java | 206 + .../apache/tuscany/sdo/model/impl/TypeImpl.java | 1068 +++ .../apache/tuscany/sdo/model/impl/TypesImpl.java | 210 + .../apache/tuscany/sdo/model/impl/XSDTypeImpl.java | 220 + .../sdo/model/internal/InternalFactory.java | 52 + .../model/internal/impl/InternalFactoryImpl.java | 296 + .../apache/tuscany/sdo/model/java/JavaFactory.java | 61 + .../apache/tuscany/sdo/model/java/JavaInfo.java | 92 + .../sdo/model/java/impl/JavaFactoryImpl.java | 659 ++ .../tuscany/sdo/model/java/impl/JavaInfoImpl.java | 256 + .../apache/tuscany/sdo/model/xml/XMLFactory.java | 61 + .../org/apache/tuscany/sdo/model/xml/XMLInfo.java | 92 + .../tuscany/sdo/model/xml/impl/XMLFactoryImpl.java | 341 + .../tuscany/sdo/model/xml/impl/XMLInfoImpl.java | 256 + .../org/apache/tuscany/sdo/util/BasicSequence.java | 176 + .../sdo/util/DataGraphResourceFactoryImpl.java | 705 ++ .../apache/tuscany/sdo/util/DataObjectUtil.java | 2998 ++++++++ .../java/org/apache/tuscany/sdo/util/SDOUtil.java | 593 ++ .../apache/tuscany/sdo/util/StAX2SAXAdapter.java | 250 + .../tuscany/sdo/util/StreamDeserializer.java | 92 + .../apache/tuscany/sdo/util/VirtualSequence.java | 780 ++ .../tuscany/sdo/util/metadata/JavaMetaData.java | 90 + .../tuscany/sdo/util/metadata/MetadataFactory.java | 77 + .../sdo/util/metadata/SDOMetaDataGroup.java | 87 + .../tuscany/sdo/util/metadata/TypeMetaData.java | 65 + .../tuscany/sdo/util/metadata/XSDMetaData.java | 66 + .../sdo/util/metadata/impl/JavaMetaDataImpl.java | 267 + .../util/metadata/impl/MetadataFactoryImpl.java | 367 + .../util/metadata/impl/SDOMetaDataGroupImpl.java | 285 + .../sdo/util/metadata/impl/TypeMetaDataImpl.java | 203 + .../sdo/util/metadata/impl/XSDMetaDataImpl.java | 203 + .../resource/ChangeSummaryStreamDeserializer.java | 663 ++ .../resource/ChangeSummaryStreamSerializer.java | 690 ++ .../util/resource/DataObjectXMLStreamReader.java | 1577 ++++ .../resource/RecordedEventXMLStreamReader.java | 868 +++ .../tuscany/sdo/util/resource/SDODeserializer.java | 340 + .../sdo/util/resource/SDOURIConverterImpl.java | 55 + .../util/resource/SDOXMLResourceFactoryImpl.java | 47 + .../sdo/util/resource/SDOXMLResourceImpl.java | 1005 +++ .../sdo/util/resource/XMLDocumentStreamReader.java | 438 ++ .../sdo/util/resource/XMLFragmentStreamReader.java | 44 + .../sdo/util/resource/XMLStreamSerializer.java | 414 ++ .../impl/src/main/resources/META-INF/DISCLAIMER | 7 + .../impl/src/main/resources/META-INF/LICENSE.txt | 207 + .../impl/src/main/resources/META-INF/MANIFEST.MF | 25 + .../events/impl/src/main/resources/META-INF/NOTICE | 14 + .../impl/src/main/resources/META-INF/README.txt | 23 + .../services/commonj.sdo.impl.HelperProvider | 1 + .../impl/src/main/resources/sdo-metadata.xsd | 45 + .../impl/src/main/resources/xml/sdoInternal.xsd | 33 + .../main/resources/xml/sdoModelChangeSummary.xsd | 28 + .../ExpectedExceptionFactory.java | 70 + .../ExpectedException/ExpectedExceptionType.java | 786 ++ .../ExpectedException/SequenceReadOnlyType.java | 158 + .../impl/ExpectedExceptionFactoryImpl.java | 579 ++ .../impl/ExpectedExceptionTypeImpl.java | 1682 +++++ .../impl/SequenceReadOnlyTypeImpl.java | 354 + .../src/test/java/com/example/simple/Quote.java | 475 ++ .../java/com/example/simple/SimpleFactory.java | 61 + .../java/com/example/simple/impl/QuoteImpl.java | 1045 +++ .../com/example/simple/impl/SimpleFactoryImpl.java | 330 + .../test/Containment/ContainmentFactory.java | 61 + .../example/test/Containment/ContainmentTest.java | 177 + .../Containment/impl/ContainmentFactoryImpl.java | 270 + .../test/Containment/impl/ContainmentTestImpl.java | 409 ++ .../test/java/org/apache/tuscany/sdo/AllTests.java | 41 + .../org/apache/tuscany/sdo/codegen/AllTests.java | 47 + .../java/org/apache/tuscany/sdo/codegen/Bar1.java | 26 + .../java/org/apache/tuscany/sdo/codegen/Bar2.java | 26 + .../BytecodeInterfaceGeneratorTestCase.java | 167 + .../java/org/apache/tuscany/sdo/codegen/Foo.java | 26 + .../codegen/JavaInterfaceGeneratorTestCase.java | 129 + .../apache/tuscany/sdo/codegen/MockProperty.java | 94 + .../org/apache/tuscany/sdo/codegen/MockType.java | 104 + .../java/org/apache/tuscany/sdo/test/AllTests.java | 84 + .../org/apache/tuscany/sdo/test/AnyTypeTest.java | 112 + .../test/ChangeSummaryOnDataObjectTestCase.java | 216 + .../sdo/test/ChangeSummaryPropertyTestCase.java | 219 + .../tuscany/sdo/test/ChangeSummaryTestCase.java | 92 + .../tuscany/sdo/test/ContainmentCycleTestCase.java | 866 +++ .../tuscany/sdo/test/ContainmentTypeUtil.java | 86 + .../tuscany/sdo/test/CrossScopeCopyTestCase.java | 474 ++ .../apache/tuscany/sdo/test/DataGraphTestCase.java | 270 + .../tuscany/sdo/test/DataTypeBaseTypeTestCase.java | 68 + .../tuscany/sdo/test/DateConversionTestCase.java | 374 + .../test/DefineOpenContentPropertyTestCase.java | 133 + .../tuscany/sdo/test/DefineTypeTestCase.java | 704 ++ .../sdo/test/DeserializationNoSchemaTestCase.java | 124 + .../org/apache/tuscany/sdo/test/DotNameTest.java | 78 + .../sdo/test/DynamicTypesComparisonTestCase.java | 256 + .../sdo/test/ExpectedExceptionsTestCase.java | 1878 +++++ .../org/apache/tuscany/sdo/test/FormTestCase.java | 112 + .../tuscany/sdo/test/HelperContextTestCase.java | 75 + .../apache/tuscany/sdo/test/IsManyTestCase.java | 65 + .../sdo/test/JavaSerializeDeserializeTestCase.java | 297 + .../org/apache/tuscany/sdo/test/JiraTestCases.java | 184 + .../test/MetadataInstancePropertiesTestCase.java | 220 + .../apache/tuscany/sdo/test/MixedTypeTestCase.java | 89 + .../sdo/test/NeverStaleChangeSummaryTestCase.java | 76 + .../apache/tuscany/sdo/test/OpenTypeTestCase.java | 139 + .../tuscany/sdo/test/SchemaLocationTestCase.java | 48 + .../apache/tuscany/sdo/test/SequenceTestCase.java | 100 + .../tuscany/sdo/test/SerializeTypesTestCase.java | 190 + .../tuscany/sdo/test/SimpleCopyTestCase.java | 71 + .../tuscany/sdo/test/SimpleDynamicTestCase.java | 123 + .../tuscany/sdo/test/SimpleEqualityTestCase.java | 63 + .../sdo/test/SubstitutionValuesTestCase.java | 83 + .../java/org/apache/tuscany/sdo/test/TestUtil.java | 285 + .../tuscany/sdo/test/TypeConversionTestCase.java | 892 +++ .../tuscany/sdo/test/TypeHelperTestCase.java | 45 + .../tuscany/sdo/test/TypeRoundTripTestCase.java | 147 + .../tuscany/sdo/test/XMLDocumentTestCase.java | 110 + .../apache/tuscany/sdo/test/XMLHelperTestCase.java | 286 + .../tuscany/sdo/test/XMLLoadOptionsTestCase.java | 192 + .../tuscany/sdo/test/XMLSaveOptionsTestCase.java | 147 + .../test/XMLStreamHelperPerformanceTestCase.java | 91 + .../tuscany/sdo/test/XMLStreamHelperTestCase.java | 169 + .../sdo/test/XMLUnknownPropertiesTestCase.java | 132 + .../org/apache/tuscany/sdo/test/XPathTestCase.java | 125 + .../apache/tuscany/sdo/test/XSDHelperTestCase.java | 224 + .../apache/tuscany/sdo/test/XSDQNameTestCase.java | 123 + .../src/test/resources/SchemaLocationTestCase.xml | 33 + .../src/test/resources/SequenceChangeSummary.xsd | 48 + .../impl/src/test/resources/SubstitutionValues.xsd | 31 + .../test/resources/TypePropertyMetadataInfo.xsd | 96 + .../XMLDocumentNoNamespaceSchemaLocation.xsd | 31 + .../test/resources/XMLDocumentSchemaLocation.xsd | 35 + .../src/test/resources/XMLDocumentTestCase.xml | 14 + .../impl/src/test/resources/XMLStreamHelper.xsd | 41 + .../events/impl/src/test/resources/anytype.xsd | 36 + .../events/impl/src/test/resources/api_test.xsd | 46 + .../events/impl/src/test/resources/bank.xsd | 78 + .../events/impl/src/test/resources/company.xsd | 44 + .../impl/src/test/resources/containmenttest.xsd | 31 + .../events/impl/src/test/resources/customer1.xml | 8 + .../events/impl/src/test/resources/customer2.xml | 8 + .../events/impl/src/test/resources/datatype.xsd | 34 + .../events/impl/src/test/resources/dotNames.xsd | 30 + .../impl/src/test/resources/expectedExceptions.xsd | 67 + .../events/impl/src/test/resources/foo-ext.xml | 9 + .../events/impl/src/test/resources/foo-ext.xsd | 44 + .../events/impl/src/test/resources/foo.xsd | 232 + .../events/impl/src/test/resources/mixed.xml | 9 + .../events/impl/src/test/resources/mixed.xsd | 41 + .../events/impl/src/test/resources/mixed2.xml | 12 + .../impl/src/test/resources/mixedChangeSummary.xml | 11 + .../test/resources/mixedChangeSummaryUndone.xml | 2 + .../events/impl/src/test/resources/mixedopen.xml | 13 + .../events/impl/src/test/resources/names.xsd | 33 + .../events/impl/src/test/resources/open.xml | 8 + .../events/impl/src/test/resources/open.xsd | 51 + .../events/impl/src/test/resources/open1any.xsd | 44 + .../events/impl/src/test/resources/open2.xml | 9 + .../impl/src/test/resources/openChangeSummary.xml | 24 + .../src/test/resources/openChangeSummaryUndone.xml | 17 + .../src/test/resources/openContentProperty.xml | 12 + .../kgoodson/events/impl/src/test/resources/po.xsd | 62 + .../events/impl/src/test/resources/prefix.xsd | 24 + .../events/impl/src/test/resources/quote.xml | 14 + .../events/impl/src/test/resources/quoteInSOAP.xml | 19 + .../events/impl/src/test/resources/sdoModel.xsd | 28 + .../impl/src/test/resources/sdoannotations.xsd | 60 + .../events/impl/src/test/resources/sdotypes.xsd | 71 + .../impl/src/test/resources/shallowquote.xml | 11 + .../impl/src/test/resources/shallowquote1.xml | 11 + .../events/impl/src/test/resources/simple.xsd | 41 + .../events/impl/src/test/resources/simple2.xsd | 41 + .../events/impl/src/test/resources/simple3.xsd | 34 + .../src/test/resources/simpleWithChangeSummary.xml | 28 + .../src/test/resources/simpleWithChangeSummary.xsd | 49 + .../resources/simpleWithChangeSummaryUndone.xml | 19 + .../src/test/resources/simplechangesummary.xml | 33 + .../src/test/resources/substitutionValues1.xml | 5 + .../src/test/resources/substitutionValues2.xml | 5 + .../events/impl/src/test/resources/xpath.xml | 51 + .../events/impl/src/test/resources/xpath.xsd | 75 + .../events/impl/src/test/resources/xsdCorners.xsd | 34 + sandbox/kgoodson/events/lib/pom.xml | 96 + .../java/org/apache/tuscany/sdo/api/Event.java | 61 + .../org/apache/tuscany/sdo/api/EventListener.java | 8 + .../java/org/apache/tuscany/sdo/api/SDOHelper.java | 413 ++ .../java/org/apache/tuscany/sdo/api/SDOUtil.java | 412 ++ .../apache/tuscany/sdo/api/XMLStreamHelper.java | 125 + .../java/org/apache/tuscany/sdo/api/overview.html | 38 + .../tuscany/sdo/lib/SDOObjectInputStream.java | 49 + .../tuscany/sdo/lib/SDOObjectOutputStream.java | 49 + .../apache/tuscany/sdo/spi/HelperProviderBase.java | 245 + .../org/apache/tuscany/sdo/spi/SDOHelperBase.java | 176 + .../lib/src/main/resources/META-INF/DISCLAIMER | 7 + .../lib/src/main/resources/META-INF/LICENSE.txt | 207 + .../lib/src/main/resources/META-INF/MANIFEST.MF | 16 + .../events/lib/src/main/resources/META-INF/NOTICE | 14 + .../lib/src/main/resources/META-INF/README.txt | 23 + sandbox/kgoodson/events/play/pom.xml | 33 + .../main/java/com/example/ComExampleObserver.java | 13 + .../src/test/java/com/example/TestChanges.java | 41 + .../events/play/src/test/resources/simple.xsd | 41 + 270 files changed, 77579 insertions(+) create mode 100644 sandbox/kgoodson/events/impl/model/SDO.ecore create mode 100644 sandbox/kgoodson/events/impl/model/SDO.genmodel create mode 100644 sandbox/kgoodson/events/impl/model/SDO.mdl create mode 100644 sandbox/kgoodson/events/impl/pom.xml create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/AnyTypeDataObject.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/SDOExtendedMetaData.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/SDOFactory.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/SDOPackage.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/SDOTypeVisitor.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/SimpleAnyTypeDataObject.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/api/ListenerBase.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGenerator.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/codegen/GenerationException.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGenerator.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/codegen/NoJavaImplementationException.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/BaseSDOExtendedMetaDataImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/BaseSDOXSDEcoreBuilder.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/CopyHelperImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/CrossScopeCopyHelperImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/DataFactoryImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/DataHelperImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/DefaultHelperContextImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/EqualityHelperImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/HelperContextImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/HelperProviderImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOAnnotations.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOExtendedMetaDataImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOHelperImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOXSDEcoreBuilder.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/SchemaBuilder.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeTable.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLDocumentImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLHelperImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLStreamHelper.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLStreamHelperImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/XSDHelperImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/AnyTypeDataObjectImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/AttributeImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummaryImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummarySettingImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ClassImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DataGraphImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectBase.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DataTypeImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicDataObjectImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicStoreDataObjectImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/EnumImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/EventImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ExtensibleDataObjectImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/FactoryBase.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ReferenceImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOFactoryImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOPackageImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/SimpleAnyTypeDataObjectImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/StoreDataObjectImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/BaseDataGraphType.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/DataGraphType.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/DataObject.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/ModelFactory.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/ModelsType.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/Property.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/TextType.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/Type.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/Types.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/XSDType.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/BaseDataGraphTypeImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/DataGraphTypeImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/DataObjectImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ModelFactoryImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ModelsTypeImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/PropertyImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/TextTypeImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/TypeImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/TypesImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/XSDTypeImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/internal/InternalFactory.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/internal/impl/InternalFactoryImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/java/JavaFactory.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/java/JavaInfo.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/java/impl/JavaFactoryImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/java/impl/JavaInfoImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/xml/XMLFactory.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/xml/XMLInfo.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/xml/impl/XMLFactoryImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/xml/impl/XMLInfoImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/BasicSequence.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/DataGraphResourceFactoryImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/SDOUtil.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/StAX2SAXAdapter.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/StreamDeserializer.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/VirtualSequence.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/JavaMetaData.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/MetadataFactory.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/SDOMetaDataGroup.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/TypeMetaData.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/XSDMetaData.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/JavaMetaDataImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/MetadataFactoryImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/SDOMetaDataGroupImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/TypeMetaDataImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/XSDMetaDataImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/ChangeSummaryStreamDeserializer.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/ChangeSummaryStreamSerializer.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/DataObjectXMLStreamReader.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/RecordedEventXMLStreamReader.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDODeserializer.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDOURIConverterImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDOXMLResourceFactoryImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDOXMLResourceImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/XMLDocumentStreamReader.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/XMLFragmentStreamReader.java create mode 100644 sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/XMLStreamSerializer.java create mode 100644 sandbox/kgoodson/events/impl/src/main/resources/META-INF/DISCLAIMER create mode 100644 sandbox/kgoodson/events/impl/src/main/resources/META-INF/LICENSE.txt create mode 100644 sandbox/kgoodson/events/impl/src/main/resources/META-INF/MANIFEST.MF create mode 100644 sandbox/kgoodson/events/impl/src/main/resources/META-INF/NOTICE create mode 100644 sandbox/kgoodson/events/impl/src/main/resources/META-INF/README.txt create mode 100644 sandbox/kgoodson/events/impl/src/main/resources/META-INF/services/commonj.sdo.impl.HelperProvider create mode 100644 sandbox/kgoodson/events/impl/src/main/resources/sdo-metadata.xsd create mode 100644 sandbox/kgoodson/events/impl/src/main/resources/xml/sdoInternal.xsd create mode 100644 sandbox/kgoodson/events/impl/src/main/resources/xml/sdoModelChangeSummary.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionFactory.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionType.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/SequenceReadOnlyType.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionFactoryImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionTypeImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/impl/SequenceReadOnlyTypeImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/com/example/simple/Quote.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/com/example/simple/SimpleFactory.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/com/example/simple/impl/QuoteImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/com/example/simple/impl/SimpleFactoryImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/com/example/test/Containment/ContainmentFactory.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/com/example/test/Containment/ContainmentTest.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/com/example/test/Containment/impl/ContainmentFactoryImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/com/example/test/Containment/impl/ContainmentTestImpl.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/AllTests.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/AllTests.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/AllTests.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/AnyTypeTest.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryOnDataObjectTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryPropertyTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentCycleTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentTypeUtil.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/CrossScopeCopyTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/DataGraphTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/DataTypeBaseTypeTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/DateConversionTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/DefineOpenContentPropertyTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/DefineTypeTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/DeserializationNoSchemaTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/DotNameTest.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/DynamicTypesComparisonTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ExpectedExceptionsTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/FormTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/HelperContextTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/IsManyTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/JavaSerializeDeserializeTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/JiraTestCases.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/MetadataInstancePropertiesTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/NeverStaleChangeSummaryTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SchemaLocationTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SequenceTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SerializeTypesTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValuesTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/TypeConversionTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/TypeHelperTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/TypeRoundTripTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLDocumentTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLHelperTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLLoadOptionsTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLSaveOptionsTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperPerformanceTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLUnknownPropertiesTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XSDQNameTestCase.java create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/SchemaLocationTestCase.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/SequenceChangeSummary.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/SubstitutionValues.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/TypePropertyMetadataInfo.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/XMLDocumentNoNamespaceSchemaLocation.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/XMLDocumentSchemaLocation.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/XMLDocumentTestCase.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/XMLStreamHelper.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/anytype.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/api_test.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/bank.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/company.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/containmenttest.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/customer1.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/customer2.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/datatype.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/dotNames.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/expectedExceptions.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/foo-ext.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/foo-ext.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/foo.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/mixed.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/mixed.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/mixed2.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/mixedChangeSummary.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/mixedChangeSummaryUndone.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/mixedopen.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/names.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/open.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/open.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/open1any.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/open2.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/openChangeSummary.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/openChangeSummaryUndone.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/openContentProperty.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/po.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/prefix.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/quote.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/quoteInSOAP.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/sdoModel.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/sdoannotations.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/sdotypes.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/shallowquote.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/shallowquote1.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/simple.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/simple2.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/simple3.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/simpleWithChangeSummary.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/simpleWithChangeSummary.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/simpleWithChangeSummaryUndone.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/simplechangesummary.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/substitutionValues1.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/substitutionValues2.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/xpath.xml create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/xpath.xsd create mode 100644 sandbox/kgoodson/events/impl/src/test/resources/xsdCorners.xsd create mode 100644 sandbox/kgoodson/events/lib/pom.xml create mode 100644 sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/Event.java create mode 100644 sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/EventListener.java create mode 100644 sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/SDOHelper.java create mode 100644 sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/SDOUtil.java create mode 100644 sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/XMLStreamHelper.java create mode 100644 sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/overview.html create mode 100644 sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectInputStream.java create mode 100644 sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectOutputStream.java create mode 100644 sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/spi/HelperProviderBase.java create mode 100644 sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/spi/SDOHelperBase.java create mode 100644 sandbox/kgoodson/events/lib/src/main/resources/META-INF/DISCLAIMER create mode 100644 sandbox/kgoodson/events/lib/src/main/resources/META-INF/LICENSE.txt create mode 100644 sandbox/kgoodson/events/lib/src/main/resources/META-INF/MANIFEST.MF create mode 100644 sandbox/kgoodson/events/lib/src/main/resources/META-INF/NOTICE create mode 100644 sandbox/kgoodson/events/lib/src/main/resources/META-INF/README.txt create mode 100644 sandbox/kgoodson/events/play/pom.xml create mode 100644 sandbox/kgoodson/events/play/src/main/java/com/example/ComExampleObserver.java create mode 100644 sandbox/kgoodson/events/play/src/test/java/com/example/TestChanges.java create mode 100644 sandbox/kgoodson/events/play/src/test/resources/simple.xsd (limited to 'sandbox/kgoodson/events') diff --git a/sandbox/kgoodson/events/impl/model/SDO.ecore b/sandbox/kgoodson/events/impl/model/SDO.ecore new file mode 100644 index 0000000000..0dff575474 --- /dev/null +++ b/sandbox/kgoodson/events/impl/model/SDO.ecore @@ -0,0 +1,982 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + + +
+ + + + + +
+ + + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + + +
+ + + + + +
+ + + + + +
+ + + + + +
+ + + + + + + +
+ + + + + + + +
+ + + + + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + + +
+ + + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + +
+ + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/model/SDO.genmodel b/sandbox/kgoodson/events/impl/model/SDO.genmodel new file mode 100644 index 0000000000..2005e8f042 --- /dev/null +++ b/sandbox/kgoodson/events/impl/model/SDO.genmodel @@ -0,0 +1,583 @@ + + + + SDO.mdl + VABASE_PLUGINS_PATH + ../.. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/model/SDO.mdl b/sandbox/kgoodson/events/impl/model/SDO.mdl new file mode 100644 index 0000000000..2288766bab --- /dev/null +++ b/sandbox/kgoodson/events/impl/model/SDO.mdl @@ -0,0 +1,7670 @@ + +(object Petal + version 42 + _written "Rose 4.5.8163.3" + charSet 0) + +(object Design "Logical View" + is_unit TRUE + is_loaded TRUE + defaults (object defaults + rightMargin 0.250000 + leftMargin 0.250000 + topMargin 0.250000 + bottomMargin 0.500000 + pageOverlap 0.250000 + clipIconLabels TRUE + autoResize FALSE + snapToGrid TRUE + gridX 16 + gridY 16 + defaultFont (object Font + size 10 + face "Arial" + bold FALSE + italics FALSE + underline FALSE + strike FALSE + color 0 + default_color TRUE) + showMessageNum 1 + showClassOfObject TRUE + notation "Unified") + root_usecase_package (object Class_Category "Use Case View" + quid "3FAA8E8700BE" + exportControl "Public" + global TRUE + logical_models (list unit_reference_list) + logical_presentations (list unit_reference_list + (object UseCaseDiagram "Main" + quid "3FAA8E8700EF" + title "Main" + zoom 100 + max_height 28350 + max_width 21600 + origin_x 0 + origin_y 0 + items (list diagram_item_list)))) + root_category (object Class_Category "Logical View" + quid "3FAA8E8700BD" + exportControl "Public" + global TRUE + subsystem "Component View" + quidu "3FAA8E8700BF" + logical_models (list unit_reference_list + (object Class_Category "sdo" + attributes (list Attribute_Set + (object Attribute + tool "Ecore" + name "nsPrefix" + value "sdo") + (object Attribute + tool "Ecore" + name "nsURI" + value "http://www.apache.org/tuscany/2005/SDO") + (object Attribute + tool "Ecore" + name "basePackage" + value "org.apache.tuscany") + (object Attribute + tool "Ecore" + name "prefix" + value "SDO")) + quid "3FAA8E8B0306" + exportControl "Public" + logical_models (list unit_reference_list + (object Class "ChangeSummary" + quid "3FAB7C360208" + superclasses (list inheritance_relationship_list + (object Inheritance_Relationship + quid "4361480602D8" + supplier "Logical View::change::ChangeDescription" + quidu "4FAB6F110198")) + operations (list Operations + (object Operation "beginLogging" + quid "3FAB8899003B" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "endLogging" + quid "3FAB88AB0145" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "isCreated" + quid "3FAB89650125" + parameters (list Parameters + (object Parameter "dataObject" + type "DataObject")) + result "boolean" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "isDeleted" + quid "3FAB896F0314" + parameters (list Parameters + (object Parameter "dataObject" + type "DataObject")) + result "boolean" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getOldValues" + quid "3FAB89A4039C" + parameters (list Parameters + (object Parameter "dataObject" + type "DataObject")) + result "EJavaList" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "isModified" + quid "435500FB024C" + parameters (list Parameters + (object Parameter "dataObject" + type "DataObject")) + result "boolean" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getOldValue" + quid "435501180185" + parameters (list Parameters + (object Parameter "dataObject" + type "DataObject") + (object Parameter "property" + type "Property")) + result "ChangeSummarySetting" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getOldContainer" + quid "43550265035B" + parameters (list Parameters + (object Parameter "dataObject" + type "DataObject")) + result "DataObject" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getOldContainmentProperty" + quid "4355027F01D2" + parameters (list Parameters + (object Parameter "dataObject" + type "DataObject")) + result "Property" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getOldSequence" + quid "4355029E03A3" + parameters (list Parameters + (object Parameter "dataObject" + type "DataObject")) + result "Sequence" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "undoChanges" + quid "435502B303D5" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "isLogging" + quid "435D2CB50354" + result "boolean" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getDataGraph" + quid "435D2CC200A0" + result "DataGraph" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getChangedDataObjects" + quid "435D2D2B001F" + result "EJavaList" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getRootObject" + quid "435D2D360151" + result "DataObject" + concurrency "Sequential" + opExportControl "Public" + uid 0)) + class_attributes (list class_attribute_list + (object ClassAttribute "commonj.sdo.ChangeSummary" + quid "3FAB7C4D0373" + stereotype "javaclass" + exportControl "Public"))) + (object Class "ChangeSummarySetting" + quid "3FAB8BF8005A" + superclasses (list inheritance_relationship_list + (object Inheritance_Relationship + quid "436134F001A6" + supplier "Logical View::change::FeatureChange" + quidu "4FC39D6D0177")) + operations (list Operations + (object Operation "isSet" + quid "3FD14B5800BD" + result "boolean" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getValue" + quid "3FDEF80600EA" + result "EJavaObject" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getProperty" + quid "435D2C440045" + result "Property" + concurrency "Sequential" + opExportControl "Public" + uid 0)) + class_attributes (list class_attribute_list + (object ClassAttribute "commonj.sdo.ChangeSummary$Setting" + quid "3FAB8C05003A" + stereotype "javaclass" + exportControl "Public"))) + (object Class "DataGraph" + quid "3FAB7BFE03C0" + superclasses (list inheritance_relationship_list + (object Inheritance_Relationship + quid "43612C7B0243" + supplier "Logical View::ecore::EObject" + quidu "3C4F1C860123")) + operations (list Operations + (object Operation "createRootObject" + quid "3FAB86D40102" + parameters (list Parameters + (object Parameter "namespaceURI" + type "String") + (object Parameter "typeName" + type "String")) + result "DataObject" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "createRootObject" + quid "3FAB87520135" + parameters (list Parameters + (object Parameter "type" + type "Type")) + result "DataObject" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getType" + quid "3FAB87E20024" + parameters (list Parameters + (object Parameter "namespaceURI" + type "String") + (object Parameter "typeName" + type "String")) + result "Type" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getRootObject" + quid "435D2C900120" + result "DataObject" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getChangeSummary" + quid "435D2C9B039D" + result "ChangeSummary" + concurrency "Sequential" + opExportControl "Public" + uid 0)) + class_attributes (list class_attribute_list + (object ClassAttribute "commonj.sdo.DataGraph" + quid "3FAB7C1A0171" + stereotype "javaclass" + exportControl "Public") + (object ClassAttribute "resourceSet" + attributes (list Attribute_Set + (object Attribute + tool "Ecore" + name "isTransient" + value TRUE)) + quid "436129AF0208" + type "EResourceSet" + exportControl "Public") + (object ClassAttribute "rootResource" + attributes (list Attribute_Set + (object Attribute + tool "Ecore" + name "isTransient" + value TRUE) + (object Attribute + tool "Ecore" + name "isVolatile" + value TRUE) + (object Attribute + tool "Ecore" + name "isChangeable" + value FALSE)) + quid "436129BF0016" + type "EResource" + exportControl "Public" + derived TRUE))) + (object Class "DataObject" + quid "3FAB6F7501C4" + operations (list Operations + (object Operation "get" + quid "3FAB8EF201A0" + parameters (list Parameters + (object Parameter "path" + type "String")) + result "EJavaObject" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.get(this, path);") + opExportControl "Public" + uid 0) + (object Operation "set" + quid "3FAB8FE502FE" + parameters (list Parameters + (object Parameter "path" + type "String") + (object Parameter "value" + type "EJavaObject")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.set(this, path, value);") + opExportControl "Public" + uid 0) + (object Operation "isSet" + quid "3FAB901001BF" + parameters (list Parameters + (object Parameter "path" + type "String")) + result "boolean" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.isSet(this, path);") + opExportControl "Public" + uid 0) + (object Operation "unset" + quid "3FAB901803B6" + parameters (list Parameters + (object Parameter "path" + type "String")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.unset(this, path);") + opExportControl "Public" + uid 0) + (object Operation "get" + quid "01EDEDEDEDED" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int")) + result "EJavaObject" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.get(this, propertyIndex);") + opExportControl "Public" + uid 0) + (object Operation "set" + quid "02EDEDEDEDED" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int") + (object Parameter "value" + type "EJavaObject")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.set(this, propertyIndex, value);") + opExportControl "Public" + uid 0) + (object Operation "isSet" + quid "03EDEDEDEDED" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int")) + result "boolean" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.isSet(this, propertyIndex);") + opExportControl "Public" + uid 0) + (object Operation "unset" + quid "04EDEDEDEDED" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.unset(this, propertyIndex);") + opExportControl "Public" + uid 0) + (object Operation "get" + quid "01ADEDEDEDED" + parameters (list Parameters + (object Parameter "property" + type "Property")) + result "EJavaObject" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.get(this, property);") + opExportControl "Public" + uid 0) + (object Operation "set" + quid "02ADEDEDEDED" + parameters (list Parameters + (object Parameter "property" + type "Property") + (object Parameter "value" + type "EJavaObject")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.set(this, property, value);") + opExportControl "Public" + uid 0) + (object Operation "isSet" + quid "03ADEDEDEDED" + parameters (list Parameters + (object Parameter "property" + type "Property")) + result "boolean" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.isSet(this, property);") + opExportControl "Public" + uid 0) + (object Operation "unset" + quid "04ADEDEDEDED" + parameters (list Parameters + (object Parameter "property" + type "Property")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.unset(this, property);") + opExportControl "Public" + uid 0) + (object Operation "getContainer" + quid "AAEDEDEDEDE0" + result "DataObject" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getContainer(this);") + opExportControl "Public" + uid 0) + (object Operation "getContainmentProperty" + quid "AAEDEDEDEDE2" + result "Property" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getContainmentProperty(this);") + opExportControl "Public" + uid 0) + (object Operation "getDataGraph" + quid "AAEDEDEDEDE3" + result "DataGraph" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getDataGraph(this);") + opExportControl "Public" + uid 0) + (object Operation "getType" + quid "AAEDEDEDEDE1" + result "Type" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getType(this);") + opExportControl "Public" + uid 0) + (object Operation "getBigDecimal" + quid "EDEDEDED0000" + parameters (list Parameters + (object Parameter "path" + type "String")) + result "EBigDecimal" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getBigDecimal(this, path);") + opExportControl "Public" + uid 0) + (object Operation "getBigInteger" + quid "EDEDEDED0001" + parameters (list Parameters + (object Parameter "path" + type "String")) + result "EBigInteger" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getBigInteger(this, path);") + opExportControl "Public" + uid 0) + (object Operation "getBoolean" + quid "EDEDEDED0002" + parameters (list Parameters + (object Parameter "path" + type "String")) + result "boolean" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getBoolean(this, path);") + opExportControl "Public" + uid 0) + (object Operation "getByte" + quid "EDEDEDED0003" + parameters (list Parameters + (object Parameter "path" + type "String")) + result "byte" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getByte(this, path);") + opExportControl "Public" + uid 0) + (object Operation "getBytes" + quid "EDEDEDED0004" + parameters (list Parameters + (object Parameter "path" + type "String")) + result "EByteArray" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getBytes(this, path);") + opExportControl "Public" + uid 0) + (object Operation "getChar" + quid "EDEDEDED0005" + parameters (list Parameters + (object Parameter "path" + type "String")) + result "char" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getChar(this, path);") + opExportControl "Public" + uid 0) + (object Operation "getDataObject" + quid "EDEDEDED0006" + parameters (list Parameters + (object Parameter "path" + type "String")) + result "DataObject" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getDataObject(this, path);") + opExportControl "Public" + uid 0) + (object Operation "getDate" + quid "EDEDEDED0007" + parameters (list Parameters + (object Parameter "path" + type "String")) + result "EDate" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getDate(this, path);") + opExportControl "Public" + uid 0) + (object Operation "getDouble" + quid "EDEDEDED0008" + parameters (list Parameters + (object Parameter "path" + type "String")) + result "double" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getDouble(this, path);") + opExportControl "Public" + uid 0) + (object Operation "getFloat" + quid "EDEDEDED0009" + parameters (list Parameters + (object Parameter "path" + type "String")) + result "float" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getFloat(this, path);") + opExportControl "Public" + uid 0) + (object Operation "getInt" + quid "EDEDEDED000A" + parameters (list Parameters + (object Parameter "path" + type "String")) + result "int" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getInt(this, path);") + opExportControl "Public" + uid 0) + (object Operation "getList" + quid "EDEDEDED000B" + parameters (list Parameters + (object Parameter "path" + type "String")) + result "EJavaList" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getList(this, path);") + opExportControl "Public" + uid 0) + (object Operation "getLong" + quid "EDEDEDED000C" + parameters (list Parameters + (object Parameter "path" + type "String")) + result "long" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getLong(this, path);") + opExportControl "Public" + uid 0) + (object Operation "getSequence" + quid "EDEDEDED000D" + parameters (list Parameters + (object Parameter "path" + type "String")) + result "Sequence" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getSequence(this, path);") + opExportControl "Public" + uid 0) + (object Operation "getShort" + quid "EDEDEDED000E" + parameters (list Parameters + (object Parameter "path" + type "String")) + result "short" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getShort(this, path);") + opExportControl "Public" + uid 0) + (object Operation "getString" + quid "EDEDEDED000F" + parameters (list Parameters + (object Parameter "path" + type "String")) + result "String" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getString(this, path);") + opExportControl "Public" + uid 0) + (object Operation "setBigDecimal" + quid "EDEDEDED1000" + parameters (list Parameters + (object Parameter "path" + type "String") + (object Parameter "value" + type "EBigDecimal")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setBigDecimal(this, path, value);") + opExportControl "Public" + uid 0) + (object Operation "setBigInteger" + quid "EDEDEDED1001" + parameters (list Parameters + (object Parameter "path" + type "String") + (object Parameter "value" + type "EBigInteger")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setBigInteger(this, path, value);") + opExportControl "Public" + uid 0) + (object Operation "setBoolean" + quid "EDEDEDED1002" + parameters (list Parameters + (object Parameter "path" + type "String") + (object Parameter "value" + type "boolean")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setBoolean(this, path, value);") + opExportControl "Public" + uid 0) + (object Operation "setByte" + quid "EDEDEDED1003" + parameters (list Parameters + (object Parameter "path" + type "String") + (object Parameter "value" + type "byte")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setByte(this, path, value);") + opExportControl "Public" + uid 0) + (object Operation "setBytes" + quid "EDEDEDED1004" + parameters (list Parameters + (object Parameter "path" + type "String") + (object Parameter "value" + type "EByteArray")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setBytes(this, path, value);") + opExportControl "Public" + uid 0) + (object Operation "setChar" + quid "EDEDEDED1005" + parameters (list Parameters + (object Parameter "path" + type "String") + (object Parameter "value" + type "char")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setChar(this, path, value);") + opExportControl "Public" + uid 0) + (object Operation "setDataObject" + quid "EDEDEDED1006" + parameters (list Parameters + (object Parameter "path" + type "String") + (object Parameter "value" + type "DataObject")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setDataObject(this, path, value);") + opExportControl "Public" + uid 0) + (object Operation "setDate" + quid "EDEDEDED1007" + parameters (list Parameters + (object Parameter "path" + type "String") + (object Parameter "value" + type "EDate")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setDate(this, path, value);") + opExportControl "Public" + uid 0) + (object Operation "setDouble" + quid "EDEDEDED1008" + parameters (list Parameters + (object Parameter "path" + type "String") + (object Parameter "value" + type "double")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setDouble(this, path, value);") + opExportControl "Public" + uid 0) + (object Operation "setFloat" + quid "EDEDEDED1009" + parameters (list Parameters + (object Parameter "path" + type "String") + (object Parameter "value" + type "float")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setFloat(this, path, value);") + opExportControl "Public" + uid 0) + (object Operation "setInt" + quid "EDEDEDED100A" + parameters (list Parameters + (object Parameter "path" + type "String") + (object Parameter "value" + type "int")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setInt(this, path, value);") + opExportControl "Public" + uid 0) + (object Operation "setList" + quid "EDEDEDED100B" + parameters (list Parameters + (object Parameter "path" + type "String") + (object Parameter "value" + type "EJavaList")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setList(this, path, value);") + opExportControl "Public" + uid 0) + (object Operation "setLong" + quid "EDEDEDED100C" + parameters (list Parameters + (object Parameter "path" + type "String") + (object Parameter "value" + type "long")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setLong(this, path, value);") + opExportControl "Public" + uid 0) + (object Operation "setShort" + quid "EDEDEDED100E" + parameters (list Parameters + (object Parameter "path" + type "String") + (object Parameter "value" + type "short")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setShort(this, path, value);") + opExportControl "Public" + uid 0) + (object Operation "setString" + quid "EDEDEDED100F" + parameters (list Parameters + (object Parameter "path" + type "String") + (object Parameter "value" + type "String")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setString(this, path, value);") + opExportControl "Public" + uid 0) + (object Operation "getBigDecimal" + quid "EDEDEDED2000" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int")) + result "EBigDecimal" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getBigDecimal(this, propertyIndex);") + opExportControl "Public" + uid 0) + (object Operation "getBigInteger" + quid "EDEDEDED2001" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int")) + result "EBigInteger" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getBigInteger(this, propertyIndex);") + opExportControl "Public" + uid 0) + (object Operation "getBoolean" + quid "EDEDEDED2002" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int")) + result "boolean" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getBoolean(this, propertyIndex);") + opExportControl "Public" + uid 0) + (object Operation "getByte" + quid "EDEDEDED2003" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int")) + result "byte" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getByte(this, propertyIndex);") + opExportControl "Public" + uid 0) + (object Operation "getBytes" + quid "EDEDEDED2004" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int")) + result "EByteArray" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getBytes(this, propertyIndex);") + opExportControl "Public" + uid 0) + (object Operation "getChar" + quid "EDEDEDED2005" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int")) + result "char" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getChar(this, propertyIndex);") + opExportControl "Public" + uid 0) + (object Operation "getDataObject" + quid "EDEDEDED2006" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int")) + result "DataObject" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getDataObject(this, propertyIndex);") + opExportControl "Public" + uid 0) + (object Operation "getDate" + quid "EDEDEDED2007" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int")) + result "EDate" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getDate(this, propertyIndex);") + opExportControl "Public" + uid 0) + (object Operation "getDouble" + quid "EDEDEDED2008" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int")) + result "double" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getDouble(this, propertyIndex);") + opExportControl "Public" + uid 0) + (object Operation "getFloat" + quid "EDEDEDED2009" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int")) + result "float" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getFloat(this, propertyIndex);") + opExportControl "Public" + uid 0) + (object Operation "getInt" + quid "EDEDEDED200A" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int")) + result "int" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getInt(this, propertyIndex);") + opExportControl "Public" + uid 0) + (object Operation "getList" + quid "EDEDEDED200B" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int")) + result "EJavaList" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getList(this, propertyIndex);") + opExportControl "Public" + uid 0) + (object Operation "getLong" + quid "EDEDEDED200C" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int")) + result "long" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getLong(this, propertyIndex);") + opExportControl "Public" + uid 0) + (object Operation "getSequence" + quid "EDEDEDED200D" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int")) + result "Sequence" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getSequence(this, propertyIndex);") + opExportControl "Public" + uid 0) + (object Operation "getShort" + quid "EDEDEDED200E" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int")) + result "short" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getShort(this, propertyIndex);") + opExportControl "Public" + uid 0) + (object Operation "getString" + quid "EDEDEDED200F" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int")) + result "String" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getString(this, propertyIndex);") + opExportControl "Public" + uid 0) + (object Operation "setBigDecimal" + quid "EDEDEDED3000" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int") + (object Parameter "value" + type "EBigDecimal")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setBigDecimal(this, propertyIndex, value);") + opExportControl "Public" + uid 0) + (object Operation "setBigInteger" + quid "EDEDEDED3001" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int") + (object Parameter "value" + type "EBigInteger")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setBigInteger(this, propertyIndex, value);") + opExportControl "Public" + uid 0) + (object Operation "setBoolean" + quid "EDEDEDED3002" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int") + (object Parameter "value" + type "boolean")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setBoolean(this, propertyIndex, value);") + opExportControl "Public" + uid 0) + (object Operation "setByte" + quid "EDEDEDED3003" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int") + (object Parameter "value" + type "byte")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setByte(this, propertyIndex, value);") + opExportControl "Public" + uid 0) + (object Operation "setBytes" + quid "EDEDEDED3004" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int") + (object Parameter "value" + type "EByteArray")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setBytes(this, propertyIndex, value);") + opExportControl "Public" + uid 0) + (object Operation "setChar" + quid "EDEDEDED3005" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int") + (object Parameter "value" + type "char")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setChar(this, propertyIndex, value);") + opExportControl "Public" + uid 0) + (object Operation "setDataObject" + quid "EDEDEDED3006" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int") + (object Parameter "value" + type "DataObject")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setDataObject(this, propertyIndex, value);") + opExportControl "Public" + uid 0) + (object Operation "setDate" + quid "EDEDEDED3007" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int") + (object Parameter "value" + type "EDate")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setDate(this, propertyIndex, value);") + opExportControl "Public" + uid 0) + (object Operation "setDouble" + quid "EDEDEDED3008" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int") + (object Parameter "value" + type "double")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setDouble(this, propertyIndex, value);") + opExportControl "Public" + uid 0) + (object Operation "setFloat" + quid "EDEDEDED3009" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int") + (object Parameter "value" + type "float")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setFloat(this, propertyIndex, value);") + opExportControl "Public" + uid 0) + (object Operation "setInt" + quid "EDEDEDED300A" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int") + (object Parameter "value" + type "int")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setInt(this, propertyIndex, value);") + opExportControl "Public" + uid 0) + (object Operation "setList" + quid "EDEDEDED300B" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int") + (object Parameter "value" + type "EJavaList")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setList(this, propertyIndex, value);") + opExportControl "Public" + uid 0) + (object Operation "setLong" + quid "EDEDEDED300C" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int") + (object Parameter "value" + type "long")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setLong(this, propertyIndex, value);") + opExportControl "Public" + uid 0) + (object Operation "setShort" + quid "EDEDEDED300E" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int") + (object Parameter "value" + type "short")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setShort(this, propertyIndex, value);") + opExportControl "Public" + uid 0) + (object Operation "setString" + quid "EDEDEDED300F" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int") + (object Parameter "value" + type "String")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setString(this, propertyIndex, value);") + opExportControl "Public" + uid 0) + (object Operation "getBigDecimal" + quid "EDEDEEEE2000" + parameters (list Parameters + (object Parameter "property" + type "Property")) + result "EBigDecimal" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getBigDecimal(this, property);") + opExportControl "Public" + uid 0) + (object Operation "getBigInteger" + quid "EDEDEEEE2001" + parameters (list Parameters + (object Parameter "property" + type "Property")) + result "EBigInteger" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getBigInteger(this, property);") + opExportControl "Public" + uid 0) + (object Operation "getBoolean" + quid "EDEDEEEE2002" + parameters (list Parameters + (object Parameter "property" + type "Property")) + result "boolean" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getBoolean(this, property);") + opExportControl "Public" + uid 0) + (object Operation "getByte" + quid "EDEDEEEE2003" + parameters (list Parameters + (object Parameter "property" + type "Property")) + result "byte" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getByte(this, property);") + opExportControl "Public" + uid 0) + (object Operation "getBytes" + quid "EDEDEEEE2004" + parameters (list Parameters + (object Parameter "property" + type "Property")) + result "EByteArray" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getBytes(this, property);") + opExportControl "Public" + uid 0) + (object Operation "getChar" + quid "EDEDEEEE2005" + parameters (list Parameters + (object Parameter "property" + type "Property")) + result "char" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getChar(this, property);") + opExportControl "Public" + uid 0) + (object Operation "getDataObject" + quid "EDEDEEEE2006" + parameters (list Parameters + (object Parameter "property" + type "Property")) + result "DataObject" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getDataObject(this, property);") + opExportControl "Public" + uid 0) + (object Operation "getDate" + quid "EDEDEEEE2007" + parameters (list Parameters + (object Parameter "property" + type "Property")) + result "EDate" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getDate(this, property);") + opExportControl "Public" + uid 0) + (object Operation "getDouble" + quid "EDEDEEEE2008" + parameters (list Parameters + (object Parameter "property" + type "Property")) + result "double" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getDouble(this, property);") + opExportControl "Public" + uid 0) + (object Operation "getFloat" + quid "EDEDEEEE2009" + parameters (list Parameters + (object Parameter "property" + type "Property")) + result "float" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getFloat(this, property);") + opExportControl "Public" + uid 0) + (object Operation "getInt" + quid "EDEDEEEE200A" + parameters (list Parameters + (object Parameter "property" + type "Property")) + result "int" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getInt(this, property);") + opExportControl "Public" + uid 0) + (object Operation "getList" + quid "EDEDEEEE200B" + parameters (list Parameters + (object Parameter "property" + type "Property")) + result "EJavaList" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getList(this, property);") + opExportControl "Public" + uid 0) + (object Operation "getLong" + quid "EDEDEEEE200C" + parameters (list Parameters + (object Parameter "property" + type "Property")) + result "long" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getLong(this, property);") + opExportControl "Public" + uid 0) + (object Operation "getSequence" + quid "EDEDEEEE200D" + parameters (list Parameters + (object Parameter "property" + type "Property")) + result "Sequence" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getSequence(this, property);") + opExportControl "Public" + uid 0) + (object Operation "getShort" + quid "EDEDEEEE200E" + parameters (list Parameters + (object Parameter "property" + type "Property")) + result "short" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getShort(this, property);") + opExportControl "Public" + uid 0) + (object Operation "getString" + quid "EDEDEEEE200F" + parameters (list Parameters + (object Parameter "property" + type "Property")) + result "String" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getString(this, property);") + opExportControl "Public" + uid 0) + (object Operation "setBigDecimal" + quid "EDEDEEEE3000" + parameters (list Parameters + (object Parameter "property" + type "Property") + (object Parameter "value" + type "EBigDecimal")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setBigDecimal(this, property, value);") + opExportControl "Public" + uid 0) + (object Operation "setBigInteger" + quid "EDEDEEEE3001" + parameters (list Parameters + (object Parameter "property" + type "Property") + (object Parameter "value" + type "EBigInteger")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setBigInteger(this, property, value);") + opExportControl "Public" + uid 0) + (object Operation "setBoolean" + quid "EDEDEEEE3002" + parameters (list Parameters + (object Parameter "property" + type "Property") + (object Parameter "value" + type "boolean")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setBoolean(this, property, value);") + opExportControl "Public" + uid 0) + (object Operation "setByte" + quid "EDEDEEEE3003" + parameters (list Parameters + (object Parameter "property" + type "Property") + (object Parameter "value" + type "byte")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setByte(this, property, value);") + opExportControl "Public" + uid 0) + (object Operation "setBytes" + quid "EDEDEEEE3004" + parameters (list Parameters + (object Parameter "property" + type "Property") + (object Parameter "value" + type "EByteArray")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setBytes(this, property, value);") + opExportControl "Public" + uid 0) + (object Operation "setChar" + quid "EDEDEEEE3005" + parameters (list Parameters + (object Parameter "property" + type "Property") + (object Parameter "value" + type "char")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setChar(this, property, value);") + opExportControl "Public" + uid 0) + (object Operation "setDataObject" + quid "EDEDEEEE3006" + parameters (list Parameters + (object Parameter "property" + type "Property") + (object Parameter "value" + type "DataObject")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setDataObject(this, property, value);") + opExportControl "Public" + uid 0) + (object Operation "setDate" + quid "EDEDEEEE3007" + parameters (list Parameters + (object Parameter "property" + type "Property") + (object Parameter "value" + type "EDate")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setDate(this, property, value);") + opExportControl "Public" + uid 0) + (object Operation "setDouble" + quid "EDEDEEEE3008" + parameters (list Parameters + (object Parameter "property" + type "Property") + (object Parameter "value" + type "double")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setDouble(this, property, value);") + opExportControl "Public" + uid 0) + (object Operation "setFloat" + quid "EDEDEEEE3009" + parameters (list Parameters + (object Parameter "property" + type "Property") + (object Parameter "value" + type "float")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setFloat(this, property, value);") + opExportControl "Public" + uid 0) + (object Operation "setInt" + quid "EDEDEEEE300A" + parameters (list Parameters + (object Parameter "property" + type "Property") + (object Parameter "value" + type "int")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setInt(this, property, value);") + opExportControl "Public" + uid 0) + (object Operation "setList" + quid "EDEDEEEE300B" + parameters (list Parameters + (object Parameter "property" + type "Property") + (object Parameter "value" + type "EJavaList")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setList(this, property, value);") + opExportControl "Public" + uid 0) + (object Operation "setLong" + quid "EDEDEEEE300C" + parameters (list Parameters + (object Parameter "property" + type "Property") + (object Parameter "value" + type "long")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setLong(this, property, value);") + opExportControl "Public" + uid 0) + (object Operation "setShort" + quid "EDEDEEEE300E" + parameters (list Parameters + (object Parameter "property" + type "Property") + (object Parameter "value" + type "short")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setShort(this, property, value);") + opExportControl "Public" + uid 0) + (object Operation "setString" + quid "EDEDEEEE300F" + parameters (list Parameters + (object Parameter "property" + type "Property") + (object Parameter "value" + type "String")) + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.setString(this, property, value);") + opExportControl "Public" + uid 0) + (object Operation "createDataObject" + quid "EDEDEEEEEEE0" + parameters (list Parameters + (object Parameter "propertyName" + type "String")) + result "DataObject" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, propertyName);") + opExportControl "Public" + uid 0) + (object Operation "createDataObject" + quid "EDEDEEEEEEE1" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int")) + result "DataObject" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, propertyIndex);") + opExportControl "Public" + uid 0) + (object Operation "createDataObject" + quid "EDEDEEEEEEE2" + parameters (list Parameters + (object Parameter "property" + type "Property")) + result "DataObject" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, property);") + opExportControl "Public" + uid 0) + (object Operation "createDataObject" + quid "EDEDEEEEEEE3" + parameters (list Parameters + (object Parameter "propertyName" + type "String") + (object Parameter "namespaceURI" + type "String") + (object Parameter "typeName" + type "String")) + result "DataObject" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, propertyName, namespaceURI, typeName);") + opExportControl "Public" + uid 0) + (object Operation "createDataObject" + quid "EDEDEEEEEEE4" + parameters (list Parameters + (object Parameter "propertyIndex" + type "int") + (object Parameter "namespaceURI" + type "String") + (object Parameter "typeName" + type "String")) + result "DataObject" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, propertyIndex, namespaceURI, typeName);") + opExportControl "Public" + uid 0) + (object Operation "createDataObject" + quid "EDEDEEEEEEE5" + parameters (list Parameters + (object Parameter "property" + type "Property") + (object Parameter "type" + type "Type")) + result "DataObject" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, property, type);") + opExportControl "Public" + uid 0) + (object Operation "delete" + quid "EDEDEEEEEEE6" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.delete(this);") + opExportControl "Public" + uid 0) + (object Operation "getSequence" + quid "4354FB2702D3" + result "Sequence" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getSequence(this);") + opExportControl "Public" + uid 0) + (object Operation "getInstanceProperties" + quid "4354FB9F00CC" + result "EJavaList" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getInstanceProperties(this);") + opExportControl "Public" + uid 0) + (object Operation "getProperty" + quid "4354FBB20369" + parameters (list Parameters + (object Parameter "propertyName" + type "String")) + result "Property" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getProperty(this, propertyName);") + opExportControl "Public" + uid 0) + (object Operation "getRootObject" + quid "4354FBDD01B2" + result "DataObject" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getRootObject(this);") + opExportControl "Public" + uid 0) + (object Operation "getChangeSummary" + quid "4354FC0400F0" + result "ChangeSummary" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "return <%org.apache.sdo.util.SDOUtil%>.getChangeSummary(this);") + opExportControl "Public" + uid 0) + (object Operation "detach" + quid "4354FC150068" + concurrency "Sequential" + semantics (object Semantic_Info + PDL "<%org.apache.sdo.util.SDOUtil%>.detach(this);") + opExportControl "Public" + uid 0)) + class_attributes (list class_attribute_list + (object ClassAttribute "commonj.sdo.DataObject" + quid "3FAB6F8B0284" + stereotype "javaclass" + exportControl "Public")) + abstract TRUE) + (object Class "Property" + quid "3FAB7CA1031A" + stereotype "Interface" + operations (list Operations + (object Operation "getName" + quid "4357B5A1009C" + result "String" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getType" + quid "4358FF1A0291" + result "Type" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "isMany" + quid "4357B64B019A" + result "boolean" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "isContainment" + quid "4357B76501FA" + result "boolean" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "isReadOnly" + quid "4358FF3501DC" + result "boolean" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getContainingType" + quid "4358FF3C03D1" + result "Type" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getAliasNames" + quid "4358FF4D02EF" + result "EJavaList" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getOpposite" + quid "4358FF59013D" + result "Property" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getDefault" + quid "4358FF66029B" + result "EJavaObject" + concurrency "Sequential" + opExportControl "Public" + uid 0)) + class_attributes (list class_attribute_list + (object ClassAttribute "commonj.sdo.Property" + quid "3FAB7CAB00E4" + stereotype "javaclass" + exportControl "Public"))) + (object Class "Sequence" + quid "3FAB7CC302B5" + stereotype "Interface" + operations (list Operations + (object Operation "size" + quid "3FD1F958017D" + result "int" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getProperty" + quid "3FAC32F4028D" + parameters (list Parameters + (object Parameter "index" + type "int")) + result "Property" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getValue" + quid "3FAC3318010E" + parameters (list Parameters + (object Parameter "index" + type "int")) + result "EJavaObject" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "setValue" + quid "3FAC33270259" + parameters (list Parameters + (object Parameter "index" + type "int") + (object Parameter "value" + type "EJavaObject")) + result "EJavaObject" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "add" + quid "3FAC333D017C" + parameters (list Parameters + (object Parameter "propertyName" + type "String") + (object Parameter "value" + type "EJavaObject")) + result "boolean" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "add" + quid "3FAC3371009F" + parameters (list Parameters + (object Parameter "propertIndex" + type "int") + (object Parameter "value" + type "EJavaObject")) + result "boolean" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "add" + quid "3FAC338C00CE" + parameters (list Parameters + (object Parameter "property" + type "Property") + (object Parameter "value" + type "EJavaObject")) + result "boolean" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "add" + quid "3FAC33AD02C6" + parameters (list Parameters + (object Parameter "index" + type "int") + (object Parameter "propertyName" + type "String") + (object Parameter "value" + type "EJavaObject")) + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "add" + quid "3FAC33C40263" + parameters (list Parameters + (object Parameter "index" + type "int") + (object Parameter "propertyIndex" + type "int") + (object Parameter "value" + type "EJavaObject")) + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "add" + quid "3FAC33C70375" + parameters (list Parameters + (object Parameter "index" + type "int") + (object Parameter "property" + type "Property") + (object Parameter "value" + type "EJavaObject")) + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "add" + quid "43550F7D01DE" + parameters (list Parameters + (object Parameter "text" + type "String")) + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "add" + quid "43550F930352" + parameters (list Parameters + (object Parameter "index" + type "int") + (object Parameter "text" + type "String")) + concurrency "Sequential" + opExportControl "Public" + uid 0)) + class_attributes (list class_attribute_list + (object ClassAttribute "commonj.sdo.Sequence" + quid "3FAB7CEB00D2" + stereotype "javaclass" + exportControl "Public"))) + (object Class "Type" + quid "3FAB7C7C0349" + stereotype "Interface" + operations (list Operations + (object Operation "getName" + quid "4357B56E012E" + result "String" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getURI" + quid "4358FE18013C" + result "String" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getInstanceClass" + quid "4357B6380265" + result "EJavaClass" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "isInstance" + quid "3FAB82AD0027" + parameters (list Parameters + (object Parameter "object" + type "EJavaObject")) + result "boolean" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "isDataType" + quid "4358FE26031D" + result "boolean" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "isSequenced" + quid "4358FE33020D" + result "boolean" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "isOpen" + quid "4358FE4000F3" + result "boolean" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "isAbstract" + quid "4357B7440365" + result "boolean" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getBaseTypes" + quid "4358FE4B0316" + result "EJavaList" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getAliasNames" + quid "4358FE740351" + result "EJavaList" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getProperties" + quid "4358FE8D0248" + result "EJavaList" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getDeclaredProperties" + quid "4358FE9C02A4" + result "EJavaList" + concurrency "Sequential" + opExportControl "Public" + uid 0) + (object Operation "getProperty" + quid "3FAB831701D8" + parameters (list Parameters + (object Parameter "propertyName" + type "String")) + result "Property" + concurrency "Sequential" + opExportControl "Public" + uid 0)) + class_attributes (list class_attribute_list + (object ClassAttribute "commonj.sdo.Type" + quid "3FAB7C8B0015" + stereotype "javaclass" + exportControl "Public"))) + (object Class "EJavaList" + quid "3FAB8A010237" + stereotype "datatype" + class_attributes (list class_attribute_list + (object ClassAttribute "java.util.List" + quid "3FAB8A0F01F1" + stereotype "javaclass" + exportControl "Public")) + abstract TRUE) + (object Class "EObjectStreamException" + quid "3FC352DE038F" + stereotype "datatype" + class_attributes (list class_attribute_list + (object ClassAttribute "java.io.ObjectStreamException" + quid "3FC352F90171" + stereotype "javaclass" + exportControl "Public")) + abstract TRUE) + (object Class "AnyTypeDataObject" + attributes (list Attribute_Set + (object Attribute + tool "Ecore" + name "xmlContentKind" + value ("ContentKind" 3))) + quid "4069645E0146" + superclasses (list inheritance_relationship_list + (object Inheritance_Relationship + quid "406964870375" + supplier "Logical View::type::AnyType" + quidu "40695FE40332") + (object Inheritance_Relationship + quid "436141F003E7" + stereotype "extend" + supplier "Logical View::sdo::DataObject" + quidu "3FAB6F7501C4"))) + (object Class "SimpleAnyTypeDataObject" + attributes (list Attribute_Set + (object Attribute + tool "Ecore" + name "xmlContentKind" + value ("ContentKind" 2))) + quid "406964710189" + superclasses (list inheritance_relationship_list + (object Inheritance_Relationship + quid "4069648302E3" + stereotype "extend" + supplier "Logical View::sdo::AnyTypeDataObject" + quidu "4069645E0146") + (object Inheritance_Relationship + quid "4069648D02E8" + supplier "Logical View::type::SimpleAnyType" + quidu "406961210099"))) + (object Class "Class" + quid "43559BB702E7" + superclasses (list inheritance_relationship_list + (object Inheritance_Relationship + quid "43559D3A01A3" + supplier "Logical View::ecore::EClass" + quidu "3903D5BF000A") + (object Inheritance_Relationship + quid "435901C600DC" + supplier "Logical View::sdo::Type" + quidu "3FAB7C7C0349")) + class_attributes (list class_attribute_list + (object ClassAttribute "commonj.sdo.Type" + quid "435900CF00F5" + stereotype "javaclass" + exportControl "Public"))) + (object Class "DataType" + quid "43559BE502F7" + superclasses (list inheritance_relationship_list + (object Inheritance_Relationship + quid "43590C6F016D" + supplier "Logical View::sdo::Type" + quidu "3FAB7C7C0349") + (object Inheritance_Relationship + quid "43590C73038F" + supplier "Logical View::ecore::EDataType" + quidu "3903D525033E")) + class_attributes (list class_attribute_list + (object ClassAttribute "commonj.sdo.Type" + quid "4358FFE30331" + stereotype "javaclass" + exportControl "Public"))) + (object Class "Attribute" + quid "43559E690004" + superclasses (list inheritance_relationship_list + (object Inheritance_Relationship + quid "43559ED801E4" + supplier "Logical View::ecore::EAttribute" + quidu "39238472039D") + (object Inheritance_Relationship + quid "43567DFD03B6" + supplier "Logical View::sdo::Property" + quidu "3FAB7CA1031A")) + class_attributes (list class_attribute_list + (object ClassAttribute "commonj.sdo.Property" + quid "4359014A0246" + stereotype "javaclass" + exportControl "Public"))) + (object Class "Reference" + quid "43559E86025E" + superclasses (list inheritance_relationship_list + (object Inheritance_Relationship + quid "43559EE0011D" + supplier "Logical View::ecore::EReference" + quidu "39238479039D") + (object Inheritance_Relationship + quid "43567DF9022A" + supplier "Logical View::sdo::Property" + quidu "3FAB7CA1031A")) + class_attributes (list class_attribute_list + (object ClassAttribute "commonj.sdo.Property" + quid "4359018E0226" + stereotype "javaclass" + exportControl "Public"))) + (object Class "Enum" + quid "4357B1010017" + superclasses (list inheritance_relationship_list + (object Inheritance_Relationship + quid "4357B1410218" + supplier "Logical View::sdo::Type" + quidu "3FAB7C7C0349") + (object Inheritance_Relationship + quid "4357B14701DA" + supplier "Logical View::ecore::EEnum" + quidu "39A473E901D4")) + class_attributes (list class_attribute_list + (object ClassAttribute "commonj.sdo.Type" + quid "4359006102CE" + stereotype "javaclass" + exportControl "Public"))) + (object Class "DynamicDataObject" + quid "435E94210124" + superclasses (list inheritance_relationship_list + (object Inheritance_Relationship + quid "435E9435008D" + supplier "Logical View::sdo::DataObject" + quidu "3FAB6F7501C4")) + class_attributes (list class_attribute_list + (object ClassAttribute "commonj.sdo.DataObject" + quid "435E9459021F" + stereotype "javaclass" + exportControl "Public"))) + (object Class "StoreDataObject" + quid "43621EBA03B4" + superclasses (list inheritance_relationship_list + (object Inheritance_Relationship + quid "43621F0B03A6" + supplier "Logical View::sdo::DataObject" + quidu "3FAB6F7501C4")) + class_attributes (list class_attribute_list + (object ClassAttribute "commonj.sdo.DataObject" + quid "43621EDF015E" + stereotype "javaclass" + exportControl "Public"))) + (object Class "DynamicStoreDataObject" + quid "43621F4203CD" + superclasses (list inheritance_relationship_list + (object Inheritance_Relationship + quid "43621F920242" + supplier "Logical View::sdo::StoreDataObject" + quidu "43621EBA03B4")) + class_attributes (list class_attribute_list + (object ClassAttribute "commonj.sdo.DataObject" + quid "43621F5701ED" + stereotype "javaclass" + exportControl "Public"))) + (object Association "$UNNAMED$0" + quid "3FAD10CA01D5" + roles (list role_list + (object Role "eDataGraph" + attributes (list Attribute_Set + (object Attribute + tool "Ecore" + name "isResolveProxies" + value FALSE) + (object Attribute + tool "Ecore" + name "isTransient" + value TRUE)) + quid "3FAD10CC001F" + label "eDataGraph" + supplier "Logical View::sdo::DataGraph" + quidu "3FAB7BFE03C0" + client_cardinality (value cardinality "1") + is_navigable TRUE) + (object Role "eChangeSummary" + attributes (list Attribute_Set + (object Attribute + tool "Ecore" + name "isResolveProxies" + value FALSE)) + quid "3FAD10CC0020" + label "eChangeSummary" + supplier "Logical View::sdo::ChangeSummary" + quidu "3FAB7C360208" + client_cardinality (value cardinality "1") + Containment "By Value" + is_navigable TRUE))) + (object Association "$UNNAMED$1" + quid "3FAD26E802F5" + roles (list role_list + (object Role "$UNNAMED$2" + quid "3FAD26ED00E9" + supplier "Logical View::sdo::DataGraph" + quidu "3FAB7BFE03C0") + (object Role "eRootObject" + attributes (list Attribute_Set + (object Attribute + tool "Ecore" + name "isResolveProxies" + value FALSE)) + quid "3FAD26ED00F3" + label "eRootObject" + supplier "Logical View::ecore::EObject" + quidu "3C4F1C860123" + client_cardinality (value cardinality "1") + is_navigable TRUE))) + (object Association "$UNNAMED$3" + quid "406962A200CF" + roles (list role_list + (object Role "$UNNAMED$4" + quid "406962A30076" + supplier "Logical View::type::SimpleAnyType" + quidu "406961210099") + (object Role "instanceType" + attributes (list Attribute_Set + (object Attribute + tool "Ecore" + name "isResolveProxies" + value FALSE)) + quid "406962A30077" + label "instanceType" + supplier "Logical View::ecore::EDataType" + quidu "3903D525033E" + client_cardinality (value cardinality "1") + is_navigable TRUE)))) + logical_presentations (list unit_reference_list + (object ClassDiagram "SDO Interfaces" + quid "3FAB8BAA0329" + title "SDO Interfaces" + zoom 100 + max_height 28350 + max_width 21600 + origin_x 764 + origin_y 0 + items (list diagram_item_list + (object ClassView "Class" "Logical View::sdo::Sequence" @1 + ShowCompartmentStereotypes TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + ShowOperationSignature TRUE + location (2560, 2032) + label (object ItemLabel + Parent_View @1 + location (1999, 1673) + fill_color 13434879 + nlines 1 + max_width 1122 + justify 0 + label "Sequence") + stereotype (object ItemLabel + Parent_View @1 + location (1999, 1623) + fill_color 13434879 + anchor 10 + nlines 1 + max_width 1122 + justify 0 + label "<>") + icon "Interface" + icon_style "Label" + line_color 3342489 + fill_color 13434879 + quidu "3FAB7CC302B5" + compartment (object Compartment + Parent_View @1 + location (1999, 1733) + icon_style "Icon" + fill_color 16777215 + anchor 2 + nlines 14 + max_width 1128) + width 1140 + height 842 + annotation 8 + autoResize TRUE) + (object ClassView "Class" "Logical View::sdo::DataGraph" @2 + ShowCompartmentStereotypes TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + ShowOperationSignature TRUE + location (768, 304) + label (object ItemLabel + Parent_View @2 + location (65, 48) + fill_color 13434879 + nlines 1 + max_width 1406 + justify 0 + label "DataGraph") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "3FAB7BFE03C0" + compartment (object Compartment + Parent_View @2 + location (65, 108) + icon_style "Icon" + fill_color 16777215 + anchor 2 + nlines 9 + max_width 1412) + width 1424 + height 536 + annotation 8 + autoResize TRUE) + (object ClassView "Class" "Logical View::sdo::DataObject" @3 + ShowCompartmentStereotypes TRUE + IncludeAttribute TRUE + ShowOperationSignature TRUE + location (976, 1280) + font (object Font + italics TRUE) + label (object ItemLabel + Parent_View @3 + location (62, 674) + fill_color 13434879 + nlines 1 + max_width 1828 + justify 0 + label "DataObject") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "3FAB6F7501C4" + compartment (object Compartment + Parent_View @3 + location (62, 734) + icon_style "Icon" + fill_color 13434879 + anchor 2 + nlines 23 + max_width 1834 + compartmentItems (list Compartment + "+ get(property : Property) : EJavaObject" + "+ set(property : Property, value : EJavaObject)" + "+ isSet(property : Property) : boolean" + "+ unset(property : Property)" + "+ getContainer() : DataObject" + "+ getContainmentProperty() : Property" + "+ getDataGraph() : DataGraph" + "+ getType() : Type" + "+ createDataObject(propertyName : String) : DataObject" + "+ createDataObject(propertyIndex : int) : DataObject" + "+ createDataObject(property : Property) : DataObject" + "+ createDataObject(propertyName : String, namespaceURI : String, typeName : String) : DataObject" + "+ createDataObject(propertyIndex : int, namespaceURI : String, typeName : String) : DataObject" + "+ createDataObject(property : Property, type : Type) : DataObject" + "+ delete()" + "+ getSequence() : Sequence" + "+ getInstanceProperties() : EJavaList" + "+ getProperty(propertyName : String) : Property" + "+ getRootObject() : DataObject" + "+ getChangeSummary() : ChangeSummary" + "+ detach()")) + width 1846 + height 1236 + annotation 8 + autoResize TRUE) + (object ClassView "Class" "Logical View::sdo::ChangeSummary" @4 + ShowCompartmentStereotypes TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + ShowOperationSignature TRUE + location (2768, 528) + label (object ItemLabel + Parent_View @4 + location (1979, 72) + fill_color 13434879 + nlines 1 + max_width 1578 + justify 0 + label "ChangeSummary") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "3FAB7C360208" + compartment (object Compartment + Parent_View @4 + location (1979, 132) + icon_style "Icon" + fill_color 16777215 + anchor 2 + nlines 17 + max_width 1575) + width 1596 + height 936 + annotation 8 + autoResize TRUE) + (object ClassView "Class" "Logical View::sdo::Type" @5 + ShowCompartmentStereotypes TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + ShowOperationSignature TRUE + location (512, 2448) + label (object ItemLabel + Parent_View @5 + location (75, 2064) + fill_color 13434879 + nlines 1 + max_width 874 + justify 0 + label "Type") + stereotype (object ItemLabel + Parent_View @5 + location (75, 2014) + fill_color 13434879 + anchor 10 + nlines 1 + max_width 874 + justify 0 + label "<>") + icon "Interface" + icon_style "Label" + line_color 3342489 + fill_color 13434879 + quidu "3FAB7C7C0349" + compartment (object Compartment + Parent_View @5 + location (75, 2124) + icon_style "Icon" + fill_color 16777215 + anchor 2 + nlines 15 + max_width 881) + width 892 + height 892 + annotation 8 + autoResize TRUE) + (object ClassView "Class" "Logical View::sdo::Property" @6 + ShowCompartmentStereotypes TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + ShowOperationSignature TRUE + location (1424, 2352) + label (object ItemLabel + Parent_View @6 + location (1054, 2068) + fill_color 13434879 + nlines 1 + max_width 740 + justify 0 + label "Property") + stereotype (object ItemLabel + Parent_View @6 + location (1054, 2018) + fill_color 13434879 + anchor 10 + nlines 1 + max_width 740 + justify 0 + label "<>") + icon "Interface" + icon_style "Label" + line_color 3342489 + fill_color 13434879 + quidu "3FAB7CA1031A" + compartment (object Compartment + Parent_View @6 + location (1054, 2128) + icon_style "Icon" + fill_color 16777215 + anchor 2 + nlines 11 + max_width 746) + width 758 + height 692 + annotation 8 + autoResize TRUE) + (object ClassView "Class" "Logical View::sdo::ChangeSummarySetting" @7 + ShowCompartmentStereotypes TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + ShowOperationSignature TRUE + location (2528, 1328) + label (object ItemLabel + Parent_View @7 + location (2003, 1144) + fill_color 13434879 + nlines 1 + max_width 1050 + justify 0 + label "ChangeSummarySetting") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "3FAB8BF8005A" + compartment (object Compartment + Parent_View @7 + location (2003, 1204) + icon_style "Icon" + fill_color 16777215 + anchor 2 + nlines 5 + max_width 1056) + width 1068 + height 392 + annotation 8 + autoResize TRUE))) + (object ClassDiagram "SDO DataObject Access" + quid "3FAC2D8D008D" + title "SDO DataObject Access" + zoom 100 + max_height 28350 + max_width 21600 + origin_x 0 + origin_y 0 + items (list diagram_item_list + (object ClassView "Class" "Logical View::sdo::DataObject" @8 + ShowCompartmentStereotypes TRUE + IncludeAttribute TRUE + ShowOperationSignature TRUE + location (528, 1360) + font (object Font + italics TRUE) + label (object ItemLabel + Parent_View @8 + location (53, 79) + fill_color 13434879 + nlines 1 + max_width 950 + justify 0 + label "DataObject") + icon_style "Icon" + line_color 3342489 + fill_color 16316638 + quidu "3FAB6F7501C4" + compartment (object Compartment + Parent_View @8 + location (53, 139) + icon_style "Icon" + fill_color 13434879 + anchor 2 + nlines 50 + max_width 0 + compartmentItems (list Compartment + "+ getBigDecimal(path : String) : EBigDecimal" + "+ getBigInteger(path : String) : EBigInteger" + "+ getBoolean(path : String) : boolean" + "+ getByte(path : String) : byte" + "+ getBytes(path : String) : EByteArray" + "+ getChar(path : String) : char" + "+ getDataObject(path : String) : DataObject" + "+ getDate(path : String) : EDate" + "+ getDouble(path : String) : double" + "+ getFloat(path : String) : float" + "+ getInt(path : String) : int" + "+ getList(path : String) : EJavaList" + "+ getLong(path : String) : long" + "+ getSequence(path : String) : Sequence" + "+ getShort(path : String) : short" + "+ getString(path : String) : String" + "+ getBigDecimal(propertyIndex : int) : EBigDecimal" + "+ getBigInteger(propertyIndex : int) : EBigInteger" + "+ getBoolean(propertyIndex : int) : boolean" + "+ getByte(propertyIndex : int) : byte" + "+ getBytes(propertyIndex : int) : EByteArray" + "+ getChar(propertyIndex : int) : char" + "+ getDataObject(propertyIndex : int) : DataObject" + "+ getDate(propertyIndex : int) : EDate" + "+ getDouble(propertyIndex : int) : double" + "+ getFloat(propertyIndex : int) : float" + "+ getInt(propertyIndex : int) : int" + "+ getList(propertyIndex : int) : EJavaList" + "+ getLong(propertyIndex : int) : long" + "+ getSequence(propertyIndex : int) : Sequence" + "+ getShort(propertyIndex : int) : short" + "+ getString(propertyIndex : int) : String" + "+ getBigDecimal(property : Property) : EBigDecimal" + "+ getBigInteger(property : Property) : EBigInteger" + "+ getBoolean(property : Property) : boolean" + "+ getByte(property : Property) : byte" + "+ getBytes(property : Property) : EByteArray" + "+ getChar(property : Property) : char" + "+ getDataObject(property : Property) : DataObject" + "+ getDate(property : Property) : EDate" + "+ getDouble(property : Property) : double" + "+ getFloat(property : Property) : float" + "+ getInt(property : Property) : int" + "+ getList(property : Property) : EJavaList" + "+ getLong(property : Property) : long" + "+ getSequence(property : Property) : Sequence" + "+ getShort(property : Property) : short" + "+ getString(property : Property) : String" + "<> + commonj.sdo.DataObject")) + width 968 + height 2586 + annotation 8 + autoResize TRUE) + (object ClassView "Class" "Logical View::sdo::DataObject" @9 + ShowCompartmentStereotypes TRUE + IncludeAttribute TRUE + ShowOperationSignature TRUE + location (1664, 1280) + font (object Font + italics TRUE) + label (object ItemLabel + Parent_View @9 + location (1131, 74) + fill_color 13434879 + nlines 1 + max_width 1066 + justify 0 + label "DataObject") + icon_style "Icon" + line_color 3342489 + fill_color 16316638 + quidu "3FAB6F7501C4" + compartment (object Compartment + Parent_View @9 + location (1131, 134) + icon_style "Icon" + fill_color 13434879 + anchor 2 + nlines 47 + max_width 0 + compartmentItems (list Compartment + "+ setBigDecimal(path : String, value : EBigDecimal)" + "+ setBigInteger(path : String, value : EBigInteger)" + "+ setBoolean(path : String, value : boolean)" + "+ setByte(path : String, value : byte)" + "+ setBytes(path : String, value : EByteArray)" + "+ setChar(path : String, value : char)" + "+ setDataObject(path : String, value : DataObject)" + "+ setDate(path : String, value : EDate)" + "+ setDouble(path : String, value : double)" + "+ setFloat(path : String, value : float)" + "+ setInt(path : String, value : int)" + "+ setList(path : String, value : EJavaList)" + "+ setLong(path : String, value : long)" + "+ setShort(path : String, value : short)" + "+ setString(path : String, value : String)" + "+ setBigDecimal(propertyIndex : int, value : EBigDecimal)" + "+ setBigInteger(propertyIndex : int, value : EBigInteger)" + "+ setBoolean(propertyIndex : int, value : boolean)" + "+ setByte(propertyIndex : int, value : byte)" + "+ setBytes(propertyIndex : int, value : EByteArray)" + "+ setChar(propertyIndex : int, value : char)" + "+ setDataObject(propertyIndex : int, value : DataObject)" + "+ setDate(propertyIndex : int, value : EDate)" + "+ setDouble(propertyIndex : int, value : double)" + "+ setFloat(propertyIndex : int, value : float)" + "+ setInt(propertyIndex : int, value : int)" + "+ setList(propertyIndex : int, value : EJavaList)" + "+ setLong(propertyIndex : int, value : long)" + "+ setShort(propertyIndex : int, value : short)" + "+ setString(propertyIndex : int, value : String)" + "+ setBigDecimal(property : Property, value : EBigDecimal)" + "+ setBigInteger(property : Property, value : EBigInteger)" + "+ setBoolean(property : Property, value : boolean)" + "+ setByte(property : Property, value : byte)" + "+ setBytes(property : Property, value : EByteArray)" + "+ setChar(property : Property, value : char)" + "+ setDataObject(property : Property, value : DataObject)" + "+ setDate(property : Property, value : EDate)" + "+ setDouble(property : Property, value : double)" + "+ setFloat(property : Property, value : float)" + "+ setInt(property : Property, value : int)" + "+ setList(property : Property, value : EJavaList)" + "+ setLong(property : Property, value : long)" + "+ setShort(property : Property, value : short)" + "+ setString(property : Property, value : String)" + "<> + commonj.sdo.DataObject")) + width 1084 + height 2436 + annotation 8 + autoResize TRUE))) + (object ClassDiagram "Ecore SDO" + quid "3FAC379A02D5" + title "Ecore SDO" + zoom 100 + max_height 28350 + max_width 21600 + origin_x 0 + origin_y 0 + items (list diagram_item_list + (object ClassView "Class" "Logical View::sdo::DataGraph" @10 + ShowCompartmentStereotypes TRUE + SuppressOperation TRUE + location (464, 160) + label (object ItemLabel + Parent_View @10 + location (74, 104) + fill_color 13434879 + nlines 1 + max_width 780 + justify 0 + label "DataGraph") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "3FAB7BFE03C0" + compartment (object Compartment + Parent_View @10 + location (74, 164) + icon_style "Icon" + fill_color 13434879 + anchor 2 + nlines 1 + max_width 0 + compartmentItems (list Compartment + "<> + commonj.sdo.DataGraph")) + width 798 + height 136 + annotation 8 + autoResize TRUE) + (object ClassView "Class" "Logical View::sdo::ChangeSummary" @11 + ShowCompartmentStereotypes TRUE + SuppressOperation TRUE + location (528, 400) + label (object ItemLabel + Parent_View @11 + location (78, 344) + fill_color 13434879 + nlines 1 + max_width 900 + justify 0 + label "ChangeSummary") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "3FAB7C360208" + compartment (object Compartment + Parent_View @11 + location (78, 404) + icon_style "Icon" + fill_color 13434879 + anchor 2 + nlines 1 + max_width 0 + compartmentItems (list Compartment + "<> + commonj.sdo.ChangeSummary")) + width 918 + height 136 + annotation 8 + autoResize TRUE) + (object ClassView "Class" "Logical View::sdo::Type" @12 + ShowCompartmentStereotypes TRUE + SuppressOperation TRUE + location (416, 1088) + label (object ItemLabel + Parent_View @12 + location (79, 1054) + fill_color 13434879 + nlines 1 + max_width 674 + justify 0 + label "Type") + stereotype (object ItemLabel + Parent_View @12 + location (79, 1004) + fill_color 13434879 + anchor 10 + nlines 1 + max_width 674 + justify 0 + label "<>") + icon "Interface" + icon_style "Label" + line_color 3342489 + fill_color 13434879 + quidu "3FAB7C7C0349" + compartment (object Compartment + Parent_View @12 + location (79, 1114) + icon_style "Icon" + fill_color 13434879 + anchor 2 + nlines 1 + max_width 0 + compartmentItems (list Compartment + "<> + commonj.sdo.Type")) + width 692 + height 192 + annotation 8 + autoResize TRUE) + (object ClassView "Class" "Logical View::sdo::Property" @13 + ShowCompartmentStereotypes TRUE + SuppressOperation TRUE + location (448, 1648) + label (object ItemLabel + Parent_View @13 + location (78, 1614) + fill_color 13434879 + nlines 1 + max_width 740 + justify 0 + label "Property") + stereotype (object ItemLabel + Parent_View @13 + location (78, 1564) + fill_color 13434879 + anchor 10 + nlines 1 + max_width 740 + justify 0 + label "<>") + icon "Interface" + icon_style "Label" + line_color 3342489 + fill_color 13434879 + quidu "3FAB7CA1031A" + compartment (object Compartment + Parent_View @13 + location (78, 1674) + icon_style "Icon" + fill_color 13434879 + anchor 2 + nlines 1 + max_width 0 + compartmentItems (list Compartment + "<> + commonj.sdo.Property")) + width 758 + height 192 + annotation 8 + autoResize TRUE) + (object ClassView "Class" "Logical View::sdo::ChangeSummarySetting" @14 + ShowCompartmentStereotypes TRUE + SuppressOperation TRUE + IncludeOperation TRUE + location (608, 640) + label (object ItemLabel + Parent_View @14 + location (83, 584) + fill_color 13434879 + nlines 1 + max_width 1050 + justify 0 + label "ChangeSummarySetting") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "3FAB8BF8005A" + compartment (object Compartment + Parent_View @14 + location (83, 644) + icon_style "Icon" + fill_color 13434879 + anchor 2 + nlines 1 + max_width 0 + compartmentItems (list Compartment + "<> + commonj.sdo.ChangeSummary$Setting")) + width 1068 + height 136 + annotation 8 + autoResize TRUE) + (object ClassView "Class" "Logical View::change::ChangeDescription" @15 + ShowCompartmentStereotypes TRUE + SuppressAttribute TRUE + SuppressOperation TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + location (2496, 400) + label (object ItemLabel + Parent_View @15 + location (2311, 350) + fill_color 13434879 + nlines 1 + max_width 370 + justify 0 + label "ChangeDescription") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "4FAB6F110198" + width 388 + height 124 + annotation 8 + autoResize TRUE) + (object ClassView "Class" "Logical View::ecore::EObject" @16 + ShowCompartmentStereotypes TRUE + SuppressAttribute TRUE + SuppressOperation TRUE + location (2592, 160) + label (object ItemLabel + Parent_View @16 + location (2503, 110) + fill_color 13434879 + nlines 1 + max_width 178 + justify 0 + label "EObject") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "3C4F1C860123" + width 196 + height 124 + annotation 8 + autoResize TRUE) + (object ClassView "Class" "Logical View::change::FeatureChange" @17 + ShowCompartmentStereotypes TRUE + SuppressAttribute TRUE + SuppressOperation TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + location (2528, 640) + label (object ItemLabel + Parent_View @17 + location (2374, 590) + fill_color 13434879 + nlines 1 + max_width 308 + justify 0 + label "FeatureChange") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "4FC39D6D0177" + width 326 + height 124 + annotation 8 + autoResize TRUE) + (object ClassView "Class" "Logical View::sdo::Class" @18 + ShowCompartmentStereotypes TRUE + SuppressOperation TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + location (1648, 1296) + label (object ItemLabel + Parent_View @18 + location (1311, 1241) + fill_color 13434879 + nlines 1 + max_width 674 + justify 0 + label "Class") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "43559BB702E7" + width 692 + height 134 + annotation 8) + (object ClassView "Class" "Logical View::sdo::DataType" @19 + ShowCompartmentStereotypes TRUE + SuppressOperation TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + location (1648, 880) + label (object ItemLabel + Parent_View @19 + location (1311, 825) + fill_color 13434879 + nlines 1 + max_width 674 + justify 0 + label "DataType") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "43559BE502F7" + width 692 + height 134 + annotation 8) + (object ClassView "Class" "Logical View::ecore::EClass" @20 + ShowCompartmentStereotypes TRUE + SuppressAttribute TRUE + SuppressOperation TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + location (2592, 1296) + label (object ItemLabel + Parent_View @20 + location (2502, 1246) + fill_color 13434879 + nlines 1 + max_width 181 + justify 0 + label "EClass") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "3903D5BF000A" + width 199 + height 124 + annotation 8) + (object ClassView "Class" "Logical View::ecore::EDataType" @21 + ShowCompartmentStereotypes TRUE + SuppressAttribute TRUE + SuppressOperation TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + location (2560, 880) + label (object ItemLabel + Parent_View @21 + location (2444, 830) + fill_color 13434879 + nlines 1 + max_width 232 + justify 0 + label "EDataType") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "3903D525033E" + width 250 + height 124 + annotation 8) + (object ClassView "Class" "Logical View::sdo::Attribute" @22 + ShowCompartmentStereotypes TRUE + SuppressOperation TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + location (1664, 1536) + label (object ItemLabel + Parent_View @22 + location (1294, 1481) + fill_color 13434879 + nlines 1 + max_width 740 + justify 0 + label "Attribute") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "43559E690004" + width 758 + height 134 + annotation 8) + (object ClassView "Class" "Logical View::sdo::Reference" @23 + ShowCompartmentStereotypes TRUE + SuppressOperation TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + location (1664, 1760) + label (object ItemLabel + Parent_View @23 + location (1294, 1705) + fill_color 13434879 + nlines 1 + max_width 740 + justify 0 + label "Reference") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "43559E86025E" + width 758 + height 134 + annotation 8) + (object ClassView "Class" "Logical View::ecore::EAttribute" @24 + ShowCompartmentStereotypes TRUE + SuppressAttribute TRUE + SuppressOperation TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + location (2576, 1536) + label (object ItemLabel + Parent_View @24 + location (2470, 1486) + fill_color 13434879 + nlines 1 + max_width 212 + justify 0 + label "EAttribute") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "39238472039D" + width 230 + height 124 + annotation 8) + (object ClassView "Class" "Logical View::ecore::EReference" @25 + ShowCompartmentStereotypes TRUE + SuppressAttribute TRUE + SuppressOperation TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + location (2576, 1760) + label (object ItemLabel + Parent_View @25 + location (2458, 1710) + fill_color 13434879 + nlines 1 + max_width 236 + justify 0 + label "EReference") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "39238479039D" + width 254 + height 124 + annotation 8) + (object InheritView "" @26 + stereotype TRUE + line_color 3342489 + quidu "43559ED801E4" + client @22 + supplier @24 + line_style 0) + (object InheritView "" @27 + stereotype TRUE + line_color 3342489 + quidu "43559EE0011D" + client @23 + supplier @25 + line_style 0) + (object InheritView "" @28 + stereotype TRUE + line_color 3342489 + quidu "43567DF9022A" + client @23 + supplier @13 + line_style 0) + (object InheritView "" @29 + stereotype TRUE + line_color 3342489 + quidu "43567DFD03B6" + client @22 + supplier @13 + line_style 0) + (object ClassView "Class" "Logical View::sdo::Enum" @30 + ShowCompartmentStereotypes TRUE + SuppressOperation TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + location (1648, 1088) + label (object ItemLabel + Parent_View @30 + location (1311, 1033) + fill_color 13434879 + nlines 1 + max_width 674 + justify 0 + label "Enum") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "4357B1010017" + width 692 + height 134 + annotation 8) + (object ClassView "Class" "Logical View::ecore::EEnum" @31 + ShowCompartmentStereotypes TRUE + SuppressAttribute TRUE + SuppressOperation TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + location (2592, 1088) + label (object ItemLabel + Parent_View @31 + location (2502, 1038) + fill_color 13434879 + nlines 1 + max_width 181 + justify 0 + label "EEnum") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "39A473E901D4" + width 199 + height 124 + annotation 8) + (object InheritView "" @32 + stereotype TRUE + line_color 3342489 + quidu "4357B1410218" + client @30 + supplier @12 + line_style 0) + (object InheritView "" @33 + stereotype TRUE + line_color 3342489 + quidu "4357B14701DA" + client @30 + supplier @31 + line_style 0) + (object InheritView "" @34 + stereotype TRUE + line_color 3342489 + quidu "43559D3A01A3" + client @18 + supplier @20 + line_style 0) + (object InheritView "" @35 + stereotype TRUE + line_color 3342489 + quidu "435901C600DC" + client @18 + supplier @12 + line_style 0) + (object InheritView "" @36 + stereotype TRUE + line_color 3342489 + quidu "43590C6F016D" + client @19 + supplier @12 + line_style 0) + (object InheritView "" @37 + stereotype TRUE + line_color 3342489 + quidu "43590C73038F" + client @19 + supplier @21 + line_style 0) + (object InheritView "" @38 + stereotype TRUE + line_color 3342489 + quidu "43612C7B0243" + client @10 + supplier @16 + line_style 0) + (object InheritView "" @39 + stereotype TRUE + line_color 3342489 + quidu "436134F001A6" + client @14 + supplier @17 + line_style 0) + (object InheritView "" @40 + stereotype TRUE + line_color 3342489 + quidu "4361480602D8" + client @11 + supplier @15 + line_style 0))) + (object ClassDiagram "Ecore Data Graph" + quid "3FAD029E0142" + title "Ecore Data Graph" + zoom 100 + max_height 28350 + max_width 21600 + origin_x 0 + origin_y 0 + items (list diagram_item_list + (object ClassView "Class" "Logical View::ecore::EObject" @41 + ShowCompartmentStereotypes TRUE + SuppressAttribute TRUE + SuppressOperation TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + location (464, 832) + label (object ItemLabel + Parent_View @41 + location (375, 782) + fill_color 13434879 + nlines 1 + max_width 178 + justify 0 + label "EObject") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "3C4F1C860123" + width 196 + height 124 + annotation 8 + autoResize TRUE) + (object ClassView "Class" "Logical View::sdo::DataGraph" @42 + ShowCompartmentStereotypes TRUE + SuppressOperation TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + location (768, 256) + label (object ItemLabel + Parent_View @42 + location (378, 150) + fill_color 13434879 + nlines 1 + max_width 780 + justify 0 + label "DataGraph") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "3FAB7BFE03C0" + width 798 + height 236 + annotation 8) + (object AssociationViewNew "$UNNAMED$1" @43 + location (469, 572) + stereotype TRUE + quidu "3FAD26E802F5" + roleview_list (list RoleViews + (object RoleView "$UNNAMED$2" @44 + Parent_View @43 + location (-1067, -932) + stereotype TRUE + line_color 3342489 + quidu "3FAD26ED00E9" + client @43 + supplier @42 + line_style 3 + origin_attachment (469, 572) + terminal_attachment (469, 374)) + (object RoleView "eRootObject" @45 + Parent_View @43 + location (-1067, -932) + label (object SegLabel @46 + Parent_View @45 + location (324, 683) + anchor 1 + anchor_loc 1 + nlines 1 + max_width 252 + justify 0 + label "+eRootObject" + pctDist 0.567708 + height 146 + orientation 1) + stereotype TRUE + line_color 3342489 + quidu "3FAD26ED00F3" + client @43 + supplier @41 + line_style 3 + origin_attachment (469, 572) + terminal_attachment (469, 770) + label (object SegLabel @47 + Parent_View @45 + location (512, 690) + anchor 2 + anchor_loc 1 + nlines 1 + max_width 15 + justify 0 + label "1" + pctDist 0.598958 + height 43 + orientation 0)))) + (object ClassView "Class" "Logical View::sdo::ChangeSummary" @48 + ShowCompartmentStereotypes TRUE + SuppressAttribute TRUE + SuppressOperation TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + location (1072, 832) + label (object ItemLabel + Parent_View @48 + location (881, 782) + fill_color 13434879 + nlines 1 + max_width 382 + justify 0 + label "ChangeSummary") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "3FAB7C360208" + width 400 + height 125 + annotation 8) + (object AssociationViewNew "$UNNAMED$0" @49 + location (1078, 572) + stereotype TRUE + quidu "3FAD10CA01D5" + roleview_list (list RoleViews + (object RoleView "eDataGraph" @50 + Parent_View @49 + location (662, -692) + label (object SegLabel @51 + Parent_View @50 + location (929, 437) + anchor 1 + anchor_loc 1 + nlines 1 + max_width 240 + justify 0 + label "+eDataGraph" + pctDist 0.686170 + height 150 + orientation 0) + stereotype TRUE + line_color 3342489 + quidu "3FAD10CC001F" + client @49 + supplier @42 + line_style 3 + origin_attachment (1078, 572) + terminal_attachment (1078, 374) + label (object SegLabel @52 + Parent_View @50 + location (1115, 437) + anchor 2 + anchor_loc 1 + nlines 1 + max_width 15 + justify 0 + label "1" + pctDist 0.686170 + height 37 + orientation 1)) + (object RoleView "eChangeSummary" @53 + Parent_View @49 + location (662, -692) + label (object SegLabel @54 + Parent_View @53 + location (876, 692) + anchor 1 + anchor_loc 1 + nlines 1 + max_width 360 + justify 0 + label "+eChangeSummary" + pctDist 0.611702 + height 203 + orientation 1) + stereotype TRUE + line_color 3342489 + quidu "3FAD10CC0020" + client @49 + supplier @48 + line_style 3 + origin_attachment (1078, 572) + terminal_attachment (1078, 770) + label (object SegLabel @55 + Parent_View @53 + location (1114, 692) + anchor 2 + anchor_loc 1 + nlines 1 + max_width 15 + justify 0 + label "1" + pctDist 0.611702 + height 36 + orientation 0)))))) + (object ClassDiagram "External Types" + quid "3FAB907F00F7" + title "External Types" + zoom 100 + max_height 28350 + max_width 21600 + origin_x 0 + origin_y 0 + items (list diagram_item_list + (object ClassView "Class" "Logical View::sdo::EObjectStreamException" @56 + ShowCompartmentStereotypes TRUE + SuppressOperation TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + ShowOperationSignature TRUE + location (1184, 176) + font (object Font + italics TRUE) + label (object ItemLabel + Parent_View @56 + location (741, 142) + fill_color 13434879 + nlines 1 + max_width 886 + justify 0 + label "EObjectStreamException") + stereotype (object ItemLabel + Parent_View @56 + location (741, 92) + fill_color 13434879 + anchor 10 + nlines 1 + max_width 886 + justify 0 + label "<>") + icon_style "Icon" + line_color 3342489 + fill_color 12303359 + quidu "3FC352DE038F" + width 904 + height 192 + annotation 8 + autoResize TRUE) + (object ClassView "Class" "Logical View::sdo::EJavaList" @57 + ShowCompartmentStereotypes TRUE + SuppressOperation TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + ShowOperationSignature TRUE + location (352, 176) + font (object Font + italics TRUE) + label (object ItemLabel + Parent_View @57 + location (80, 142) + fill_color 13434879 + nlines 1 + max_width 544 + justify 0 + label "EJavaList") + stereotype (object ItemLabel + Parent_View @57 + location (80, 92) + fill_color 13434879 + anchor 10 + nlines 1 + max_width 544 + justify 0 + label "<>") + icon_style "Icon" + line_color 3342489 + fill_color 8963327 + quidu "3FAB8A010237" + width 562 + height 192 + annotation 8))) + (object ClassDiagram "SDO XML Type" + quid "406964270056" + title "SDO XML Type" + zoom 100 + max_height 28350 + max_width 21600 + origin_x 0 + origin_y 0 + items (list diagram_item_list + (object ClassView "Class" "Logical View::type::AnyType" @58 + ShowCompartmentStereotypes TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + ShowOperationSignature TRUE + location (1488, 576) + label (object ItemLabel + Parent_View @58 + location (1075, 421) + fill_color 13434879 + nlines 1 + max_width 826 + justify 0 + label "AnyType") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "40695FE40332" + width 844 + height 334 + annotation 8) + (object ClassView "Class" "Logical View::type::SimpleAnyType" @59 + ShowCompartmentStereotypes TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + ShowOperationSignature TRUE + location (1488, 1040) + label (object ItemLabel + Parent_View @59 + location (1272, 910) + fill_color 13434879 + nlines 1 + max_width 432 + justify 0 + label "SimpleAnyType") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "406961210099" + width 450 + height 284 + annotation 8) + (object ClassView "Class" "Logical View::sdo::AnyTypeDataObject" @60 + ShowCompartmentStereotypes TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + ShowOperationSignature TRUE + location (448, 560) + label (object ItemLabel + Parent_View @60 + location (250, 509) + fill_color 13434879 + nlines 1 + max_width 396 + justify 0 + label "AnyTypeDataObject") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "4069645E0146" + width 414 + height 126 + annotation 8 + autoResize TRUE) + (object ClassView "Class" "Logical View::sdo::SimpleAnyTypeDataObject" @61 + ShowCompartmentStereotypes TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + ShowOperationSignature TRUE + location (464, 1024) + label (object ItemLabel + Parent_View @61 + location (201, 973) + fill_color 13434879 + nlines 1 + max_width 526 + justify 0 + label "SimpleAnyTypeDataObject") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "406964710189" + width 544 + height 126 + annotation 8 + autoResize TRUE) + (object ClassView "Class" "Logical View::sdo::DataObject" @62 + ShowCompartmentStereotypes TRUE + SuppressAttribute TRUE + SuppressOperation TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + location (448, 208) + font (object Font + italics TRUE) + label (object ItemLabel + Parent_View @62 + location (328, 165) + fill_color 13434879 + nlines 1 + max_width 240 + justify 0 + label "DataObject") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "3FAB6F7501C4" + width 258 + height 110 + annotation 8) + (object InheritView "" @63 + stereotype (object SegLabel @64 + Parent_View @63 + location (298, 791) + anchor 10 + anchor_loc 1 + nlines 1 + max_width 450 + justify 0 + label "<>" + pctDist 0.502959 + height 150 + orientation 0) + line_color 3342489 + quidu "4069648302E3" + client @61 + supplier @60 + line_style 3 + origin_attachment (448, 961) + terminal_attachment (448, 623)) + (object InheritView "" @65 + stereotype TRUE + line_color 3342489 + quidu "4069648D02E8" + client @61 + supplier @59 + line_style 3 + origin_attachment (736, 1002) + terminal_attachment (1263, 1002)) + (object InheritView "" @66 + stereotype TRUE + line_color 3342489 + quidu "40696143020B" + client @59 + supplier @58 + line_style 3 + origin_attachment (1479, 898) + terminal_attachment (1479, 743)) + (object InheritView "" @67 + stereotype TRUE + line_color 3342489 + quidu "406964870375" + client @60 + supplier @58 + line_style 3 + origin_attachment (655, 561) + terminal_attachment (1066, 561)) + (object InheritView "" @68 + stereotype (object SegLabel @69 + Parent_View @68 + location (294, 403) + anchor 10 + anchor_loc 1 + nlines 1 + max_width 450 + justify 0 + label "<>" + pctDist 0.405229 + height 155 + orientation 0) + line_color 3342489 + quidu "436141F003E7" + client @60 + supplier @62 + line_style 0))) + (object ClassDiagram "SDO DataObject Implementations" + quid "43621DF90149" + title "SDO DataObject Implementations" + zoom 100 + max_height 28350 + max_width 21600 + origin_x 0 + origin_y 0 + items (list diagram_item_list + (object ClassView "Class" "Logical View::sdo::DataObject" @70 + ShowCompartmentStereotypes TRUE + SuppressOperation TRUE + location (1056, 368) + font (object Font + italics TRUE) + label (object ItemLabel + Parent_View @70 + location (661, 312) + fill_color 13434879 + nlines 1 + max_width 790 + justify 0 + label "DataObject") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "3FAB6F7501C4" + compartment (object Compartment + Parent_View @70 + location (661, 372) + icon_style "Icon" + fill_color 13434879 + anchor 2 + nlines 1 + max_width 0 + compartmentItems (list Compartment + "<> + commonj.sdo.DataObject")) + width 808 + height 136 + annotation 8 + autoResize TRUE) + (object ClassView "Class" "Logical View::sdo::DynamicDataObject" @71 + ShowCompartmentStereotypes TRUE + SuppressOperation TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + location (576, 720) + label (object ItemLabel + Parent_View @71 + location (181, 664) + fill_color 13434879 + nlines 1 + max_width 790 + justify 0 + label "DynamicDataObject") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "435E94210124" + width 808 + height 136 + annotation 8) + (object ClassView "Class" "Logical View::sdo::StoreDataObject" @72 + ShowCompartmentStereotypes TRUE + SuppressOperation TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + location (1680, 720) + label (object ItemLabel + Parent_View @72 + location (1285, 664) + fill_color 13434879 + nlines 1 + max_width 790 + justify 0 + label "StoreDataObject") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "43621EBA03B4" + width 808 + height 136 + annotation 8) + (object InheritTreeView "" @73 + location (1053, 559) + line_color 3342489 + fill_color 13434879 + supplier @70 + vertices (list Points + (1053, 559) + (1053, 436))) + (object InheritView "" @74 + stereotype TRUE + line_color 3342489 + quidu "435E9435008D" + client @71 + supplier @70 + line_style 3 + origin_attachment (562, 652) + terminal_attachment (562, 559) + drawSupplier @73) + (object ClassView "Class" "Logical View::sdo::DynamicStoreDataObject" @75 + ShowCompartmentStereotypes TRUE + SuppressOperation TRUE + IncludeAttribute TRUE + IncludeOperation TRUE + location (1680, 1056) + label (object ItemLabel + Parent_View @75 + location (1285, 1000) + fill_color 13434879 + nlines 1 + max_width 790 + justify 0 + label "DynamicStoreDataObject") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "43621F4203CD" + width 808 + height 136 + annotation 8) + (object InheritView "" @76 + stereotype TRUE + line_color 3342489 + quidu "43621F920242" + client @75 + supplier @72 + line_style 0) + (object InheritView "" @77 + stereotype TRUE + line_color 3342489 + quidu "43621F0B03A6" + client @72 + supplier @70 + line_style 3 + origin_attachment (1681, 652) + terminal_attachment (1681, 559) + drawSupplier @73))))) + (object Class_Category "ecore" + is_unit TRUE + is_loaded FALSE + file_name "$VABASE_PLUGINS_PATH\\org.eclipse.emf.ecore\\model\\org.eclipse.emf.Ecore.cat" + quid "39A5ED04004E") + (object Class_Category "change" + is_unit TRUE + is_loaded FALSE + file_name "$VABASE_PLUGINS_PATH\\org.eclipse.emf.ecore.change\\model\\org.eclipse.emf.ecore.Change.cat" + quid "4FAA8E8B0306") + (object Class_Category "type" + attributes (list Attribute_Set + (object Attribute + tool "Ecore" + name "packageName" + value "type") + (object Attribute + tool "Ecore" + name "nsPrefix" + value "xml.type") + (object Attribute + tool "Ecore" + name "nsURI" + value "http://www.eclipse.org/emf/2003/XMLType") + (object Attribute + tool "Ecore" + name "basePackage" + value "org.eclipse.emf.ecore.xml") + (object Attribute + tool "Ecore" + name "prefix" + value "XMLType")) + quid "40696924000C" + exportControl "Public" + logical_models (list unit_reference_list + (object Class "AnyType" + attributes (list Attribute_Set + (object Attribute + tool "Ecore" + name "xmlContentKind" + value ("ContentKind" 3))) + quid "40695FE40332" + class_attributes (list class_attribute_list + (object ClassAttribute "mixed" + attributes (list Attribute_Set + (object Attribute + tool "Ecore" + name "isUnique" + value FALSE)) + quid "40696039001D" + stereotype "0..*" + type "EFeatureMapEntry" + exportControl "Public") + (object ClassAttribute "any" + attributes (list Attribute_Set + (object Attribute + tool "Ecore" + name "isTransient" + value TRUE) + (object Attribute + tool "Ecore" + name "isVolatile" + value TRUE) + (object Attribute + tool "Ecore" + name "isUnique" + value FALSE)) + quid "40696084002F" + stereotype "0..*" + type "EFeatureMapEntry" + exportControl "Public" + derived TRUE) + (object ClassAttribute "anyAttribute" + attributes (list Attribute_Set + (object Attribute + tool "Ecore" + name "isUnique" + value FALSE)) + quid "4069609A0153" + stereotype "0..*" + type "EFeatureMapEntry" + exportControl "Public"))) + (object Class "SimpleAnyType" + attributes (list Attribute_Set + (object Attribute + tool "Ecore" + name "xmlContentKind" + value ("ContentKind" 2))) + quid "406961210099" + superclasses (list inheritance_relationship_list + (object Inheritance_Relationship + quid "40696143020B" + supplier "Logical View::type::AnyType" + quidu "40695FE40332")) + class_attributes (list class_attribute_list + (object ClassAttribute "rawValue" + attributes (list Attribute_Set + (object Attribute + tool "Ecore" + name "isTransient" + value TRUE) + (object Attribute + tool "Ecore" + name "isVolatile" + value TRUE) + (object Attribute + tool "Ecore" + name "isUnique" + value FALSE)) + quid "4069612E0391" + type "String" + exportControl "Public" + derived TRUE) + (object ClassAttribute "value" + attributes (list Attribute_Set + (object Attribute + tool "Ecore" + name "isTransient" + value TRUE) + (object Attribute + tool "Ecore" + name "isVolatile" + value TRUE) + (object Attribute + tool "Ecore" + name "isUnique" + value FALSE)) + quid "406961A40106" + type "EJavaObject" + exportControl "Public" + derived TRUE)))) + logical_presentations (list unit_reference_list))) + logical_presentations (list unit_reference_list + (object ClassDiagram "Main" + quid "3FAA8E8700D0" + title "Main" + zoom 100 + max_height 28350 + max_width 21600 + origin_x 0 + origin_y 0 + items (list diagram_item_list + (object CategoryView "Logical View::ecore" @78 + location (912, 272) + label (object ItemLabel + Parent_View @78 + location (768, 188) + fill_color 13434879 + nlines 2 + max_width 288 + justify 0 + label "ecore") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "39A5ED04004E" + width 300 + height 180) + (object CategoryView "Logical View::sdo" @79 + location (368, 272) + label (object ItemLabel + Parent_View @79 + location (224, 188) + fill_color 13434879 + nlines 2 + max_width 288 + justify 0 + label "sdo") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "3FAA8E8B0306" + width 300 + height 180) + (object CategoryView "Logical View::change" @80 + location (1440, 272) + label (object ItemLabel + Parent_View @80 + location (1296, 188) + fill_color 13434879 + nlines 2 + max_width 288 + justify 0 + label "change") + icon_style "Icon" + line_color 3342489 + fill_color 13434879 + quidu "4FAA8E8B0306" + width 300 + height 180))))) + root_subsystem (object SubSystem "Component View" + quid "3FAA8E8700BF" + physical_models (list unit_reference_list) + physical_presentations (list unit_reference_list + (object Module_Diagram "Main" + quid "3FAA8E8700EE" + title "Main" + zoom 100 + max_height 28350 + max_width 21600 + origin_x 0 + origin_y 0 + items (list diagram_item_list)))) + process_structure (object Processes + quid "3FAA8E8700C0" + ProcsNDevs (list + (object Process_Diagram "Deployment View" + quid "3FAA8E8700C2" + title "Deployment View" + zoom 100 + max_height 28350 + max_width 21600 + origin_x 0 + origin_y 0 + items (list diagram_item_list)))) + properties (object Properties + attributes (list Attribute_Set + (object Attribute + tool "DDL" + name "propertyId" + value "809135966") + (object Attribute + tool "DDL" + name "default__Project" + value (list Attribute_Set + (object Attribute + tool "DDL" + name "Directory" + value "AUTO GENERATE") + (object Attribute + tool "DDL" + name "DataBase" + value ("DataBaseSet" 800)) + (object Attribute + tool "DDL" + name "DataBaseSet" + value (list Attribute_Set + (object Attribute + tool "DDL" + name "ANSI" + value 800) + (object Attribute + tool "DDL" + name "Oracle" + value 801) + (object Attribute + tool "DDL" + name "SQLServer" + value 802) + (object Attribute + tool "DDL" + name "Sybase" + value 803) + (object Attribute + tool "DDL" + name "Watcom" + value 804))) + (object Attribute + tool "DDL" + name "PrimaryKeyColumnName" + value "Id") + (object Attribute + tool "DDL" + name "PrimaryKeyColumnType" + value "NUMBER(5)") + (object Attribute + tool "DDL" + name "ViewName" + value "V_") + (object Attribute + tool "DDL" + name "TableName" + value "T_") + (object Attribute + tool "DDL" + name "InheritSuffix" + value "_V") + (object Attribute + tool "DDL" + name "DropClause" + value FALSE) + (object Attribute + tool "DDL" + name "BaseViews" + value FALSE) + (object Attribute + tool "DDL" + name "DDLScriptFilename" + value "DDL1.SQL"))) + (object Attribute + tool "DDL" + name "default__Attribute" + value (list Attribute_Set + (object Attribute + tool "DDL" + name "ColumnType" + value "VARCHAR") + (object Attribute + tool "DDL" + name "Length" + value "") + (object Attribute + tool "DDL" + name "NullsOK" + value TRUE) + (object Attribute + tool "DDL" + name "PrimaryKey" + value FALSE) + (object Attribute + tool "DDL" + name "Unique" + value FALSE) + (object Attribute + tool "DDL" + name "CompositeUnique" + value FALSE) + (object Attribute + tool "DDL" + name "CheckConstraint" + value ""))) + (object Attribute + tool "DDL" + name "HiddenTool" + value FALSE) + (object Attribute + tool "IDL" + name "propertyId" + value "809135966") + (object Attribute + tool "IDL" + name "default__Project" + value (list Attribute_Set + (object Attribute + tool "IDL" + name "CreateMissingDirectories" + value TRUE) + (object Attribute + tool "IDL" + name "StopOnError" + value TRUE) + (object Attribute + tool "IDL" + name "Directory" + value "AUTO GENERATE") + (object Attribute + tool "IDL" + name "GeneratePreserveRegions" + value TRUE))) + (object Attribute + tool "IDL" + name "default__Class" + value (list Attribute_Set + (object Attribute + tool "IDL" + name "ImplementationType" + value "") + (object Attribute + tool "IDL" + name "ConstValue" + value "") + (object Attribute + tool "IDL" + name "GenerateDefaultSpecifier" + value FALSE) + (object Attribute + tool "IDL" + name "DefaultSpecifier" + value "") + (object Attribute + tool "IDL" + name "IDLElement" + value TRUE) + (object Attribute + tool "IDL" + name "IDLSpecificationType" + value ("IDLSpecSet" 22)) + (object Attribute + tool "IDL" + name "IDLSpecSet" + value (list Attribute_Set + (object Attribute + tool "IDL" + name "Interface" + value 22) + (object Attribute + tool "IDL" + name "Typedef" + value 54) + (object Attribute + tool "IDL" + name "Enumeration" + value 8) + (object Attribute + tool "IDL" + name "Const" + value 71) + (object Attribute + tool "IDL" + name "Exception" + value 61) + (object Attribute + tool "IDL" + name "Struct" + value 51) + (object Attribute + tool "IDL" + name "Union" + value 81))))) + (object Attribute + tool "IDL" + name "default__Module-Spec" + value (list Attribute_Set + (object Attribute + tool "IDL" + name "Generate" + value TRUE) + (object Attribute + tool "IDL" + name "CmIdentification" + value (value Text " %X% @(#) plugins/org.eclipse.emf.ecore.sdo/model/SDO.mdl, emf.ecore.sdo, org.eclipse.dev")) + (object Attribute + tool "IDL" + name "CopyrightNotice" + value (value Text "")) + (object Attribute + tool "IDL" + name "FileName" + value "AUTO GENERATE") + (object Attribute + tool "IDL" + name "GenerateIDLModule" + value FALSE) + (object Attribute + tool "IDL" + name "InclusionProtectionSymbol" + value "AUTO GENERATE") + (object Attribute + tool "IDL" + name "AdditionalIncludes" + value (value Text "")) + (object Attribute + tool "IDL" + name "IncludeBySimpleName" + value FALSE))) + (object Attribute + tool "IDL" + name "default__Module-Body" + value (list Attribute_Set + (object Attribute + tool "IDL" + name "CmIdentification" + value (value Text " %X% @(#) plugins/org.eclipse.emf.ecore.sdo/model/SDO.mdl, emf.ecore.sdo, org.eclipse.dev")) + (object Attribute + tool "IDL" + name "CopyrightNotice" + value (value Text "")) + (object Attribute + tool "IDL" + name "FileName" + value "AUTO GENERATE") + (object Attribute + tool "IDL" + name "AdditionalIncludes" + value (value Text "")) + (object Attribute + tool "IDL" + name "IncludeBySimpleName" + value FALSE))) + (object Attribute + tool "IDL" + name "default__Operation" + value (list Attribute_Set + (object Attribute + tool "IDL" + name "OperationIsOneWay" + value FALSE) + (object Attribute + tool "IDL" + name "Context" + value "") + (object Attribute + tool "IDL" + name "Raises" + value ""))) + (object Attribute + tool "IDL" + name "default__Attribute" + value (list Attribute_Set + (object Attribute + tool "IDL" + name "CaseSpecifier" + value "") + (object Attribute + tool "IDL" + name "GenerateDataMember" + value TRUE) + (object Attribute + tool "IDL" + name "DataMemberName" + value "$relationship") + (object Attribute + tool "IDL" + name "IsReadOnly" + value FALSE) + (object Attribute + tool "IDL" + name "IsConst" + value FALSE) + (object Attribute + tool "IDL" + name "ConstValue" + value ""))) + (object Attribute + tool "IDL" + name "default__Has" + value (list Attribute_Set + (object Attribute + tool "IDL" + name "NameIfUnlabeled" + value "the_$supplier") + (object Attribute + tool "IDL" + name "GenerateDataMember" + value TRUE) + (object Attribute + tool "IDL" + name "DataMemberName" + value "$relationship") + (object Attribute + tool "IDL" + name "GenerateForwardReference" + value FALSE) + (object Attribute + tool "IDL" + name "IsReadOnly" + value FALSE) + (object Attribute + tool "IDL" + name "BoundedHasRelType" + value ("HasRelTypeSet" 47)) + (object Attribute + tool "IDL" + name "HasRelTypeSet" + value (list Attribute_Set + (object Attribute + tool "IDL" + name "Array" + value 24) + (object Attribute + tool "IDL" + name "Sequence" + value 47))))) + (object Attribute + tool "IDL" + name "default__Role" + value (list Attribute_Set + (object Attribute + tool "IDL" + name "NameIfUnlabeled" + value "the_$supplier") + (object Attribute + tool "IDL" + name "GenerateDataMember" + value TRUE) + (object Attribute + tool "IDL" + name "DataMemberName" + value "$relationship") + (object Attribute + tool "IDL" + name "GenerateForwardReference" + value FALSE) + (object Attribute + tool "IDL" + name "IsReadOnly" + value FALSE) + (object Attribute + tool "IDL" + name "BoundedRoleType" + value ("AssocTypeSet" 47)) + (object Attribute + tool "IDL" + name "AssocTypeSet" + value (list Attribute_Set + (object Attribute + tool "IDL" + name "Array" + value 24) + (object Attribute + tool "IDL" + name "Sequence" + value 47))))) + (object Attribute + tool "IDL" + name "default__Uses" + value (list Attribute_Set + (object Attribute + tool "IDL" + name "GenerateForwardReference" + value FALSE))) + (object Attribute + tool "IDL" + name "default__Subsystem" + value (list Attribute_Set + (object Attribute + tool "IDL" + name "Directory" + value "AUTO GENERATE"))) + (object Attribute + tool "IDL" + name "HiddenTool" + value FALSE) + (object Attribute + tool "SCC" + name "HiddenTool" + value FALSE) + (object Attribute + tool "Ecore" + name "propertyId" + value "809135969") + (object Attribute + tool "Ecore" + name "default__Category" + value (list Attribute_Set + (object Attribute + tool "Ecore" + name "packageName" + value "") + (object Attribute + tool "Ecore" + name "nsPrefix" + value "") + (object Attribute + tool "Ecore" + name "nsURI" + value "") + (object Attribute + tool "Ecore" + name "basePackage" + value "") + (object Attribute + tool "Ecore" + name "prefix" + value "") + (object Attribute + tool "Ecore" + name "annotation" + value ""))) + (object Attribute + tool "Ecore" + name "default__Class" + value (list Attribute_Set + (object Attribute + tool "Ecore" + name "classifierName" + value "") + (object Attribute + tool "Ecore" + name "xmlName" + value "") + (object Attribute + tool "Ecore" + name "xmlContentKind" + value ("ContentKind" 0)) + (object Attribute + tool "Ecore" + name "ContentKind" + value (list Attribute_Set + (object Attribute + tool "Ecore" + name "Unspecified" + value 0) + (object Attribute + tool "Ecore" + name "Empty" + value 1) + (object Attribute + tool "Ecore" + name "Simple" + value 2) + (object Attribute + tool "Ecore" + name "Mixed" + value 3) + (object Attribute + tool "Ecore" + name "ElementOnly" + value 4))) + (object Attribute + tool "Ecore" + name "annotation" + value ""))) + (object Attribute + tool "Ecore" + name "default__Operation" + value (list Attribute_Set + (object Attribute + tool "Ecore" + name "operationName" + value "") + (object Attribute + tool "Ecore" + name "annotation" + value ""))) + (object Attribute + tool "Ecore" + name "default__Attribute" + value (list Attribute_Set + (object Attribute + tool "Ecore" + name "attributeName" + value "") + (object Attribute + tool "Ecore" + name "isTransient" + value FALSE) + (object Attribute + tool "Ecore" + name "isVolatile" + value FALSE) + (object Attribute + tool "Ecore" + name "isChangeable" + value TRUE) + (object Attribute + tool "Ecore" + name "isUnsettable" + value FALSE) + (object Attribute + tool "Ecore" + name "isUnique" + value TRUE) + (object Attribute + tool "Ecore" + name "isID" + value FALSE) + (object Attribute + tool "Ecore" + name "xmlName" + value "") + (object Attribute + tool "Ecore" + name "xmlNamespace" + value "") + (object Attribute + tool "Ecore" + name "xmlFeatureKind" + value ("FeatureKind" 0)) + (object Attribute + tool "Ecore" + name "FeatureKind" + value (list Attribute_Set + (object Attribute + tool "Ecore" + name "Unspecified" + value 0) + (object Attribute + tool "Ecore" + name "Simple" + value 1) + (object Attribute + tool "Ecore" + name "Attribute" + value 2) + (object Attribute + tool "Ecore" + name "Element" + value 4))) + (object Attribute + tool "Ecore" + name "annotation" + value ""))) + (object Attribute + tool "Ecore" + name "default__Role" + value (list Attribute_Set + (object Attribute + tool "Ecore" + name "referenceName" + value "") + (object Attribute + tool "Ecore" + name "isTransient" + value FALSE) + (object Attribute + tool "Ecore" + name "isVolatile" + value FALSE) + (object Attribute + tool "Ecore" + name "isChangeable" + value TRUE) + (object Attribute + tool "Ecore" + name "isUnsettable" + value FALSE) + (object Attribute + tool "Ecore" + name "isResolveProxies" + value TRUE) + (object Attribute + tool "Ecore" + name "xmlName" + value "") + (object Attribute + tool "Ecore" + name "xmlNamespace" + value "") + (object Attribute + tool "Ecore" + name "xmlFeatureKind" + value ("FeatureKind" 0)) + (object Attribute + tool "Ecore" + name "FeatureKind" + value (list Attribute_Set + (object Attribute + tool "Ecore" + name "Unspecified" + value 0) + (object Attribute + tool "Ecore" + name "Simple" + value 1) + (object Attribute + tool "Ecore" + name "Attribute" + value 2) + (object Attribute + tool "Ecore" + name "Element" + value 4))) + (object Attribute + tool "Ecore" + name "annotation" + value ""))) + (object Attribute + tool "framework" + name "HiddenTool" + value FALSE) + (object Attribute + tool "Java" + name "propertyId" + value "809135966") + (object Attribute + tool "Java" + name "default__Project" + value (list Attribute_Set + (object Attribute + tool "Java" + name "CreateMissingDirectories" + value TRUE) + (object Attribute + tool "Java" + name "StopOnError" + value FALSE) + (object Attribute + tool "Java" + name "Directory" + value "AUTO GENERATE") + (object Attribute + tool "Java" + name "UsePrefixes" + value FALSE) + (object Attribute + tool "Java" + name "InstanceVariablePrefix" + value "m_") + (object Attribute + tool "Java" + name "ClassVariablePrefix" + value "s_") + (object Attribute + tool "Java" + name "DefaultAttributeDataType" + value "int") + (object Attribute + tool "Java" + name "DefaultOperationReturnType" + value "void"))) + (object Attribute + tool "Java" + name "default__Class" + value (list Attribute_Set + (object Attribute + tool "Java" + name "Final" + value FALSE) + (object Attribute + tool "Java" + name "GenerateDefaultConstructor" + value TRUE) + (object Attribute + tool "Java" + name "ConstructorIs" + value ("Ctor_Set" 62)) + (object Attribute + tool "Java" + name "Ctor_Set" + value (list Attribute_Set + (object Attribute + tool "Java" + name "Public" + value 62) + (object Attribute + tool "Java" + name "Protected" + value 63) + (object Attribute + tool "Java" + name "Private" + value 64))) + (object Attribute + tool "Java" + name "GenerateFinalizer" + value FALSE) + (object Attribute + tool "Java" + name "GenerateStaticInitializer" + value FALSE) + (object Attribute + tool "Java" + name "GenerateInstanceInitializer" + value FALSE))) + (object Attribute + tool "Java" + name "default__Module-Spec" + value (list Attribute_Set + (object Attribute + tool "Java" + name "Generate" + value TRUE) + (object Attribute + tool "Java" + name "CmIdentification" + value (value Text "")) + (object Attribute + tool "Java" + name "CopyrightNotice" + value (value Text "")) + (object Attribute + tool "Java" + name "AdditionalImports" + value (value Text "")))) + (object Attribute + tool "Java" + name "default__Module-Body" + value (list Attribute_Set + (object Attribute + tool "Java" + name "Generate" + value TRUE) + (object Attribute + tool "Java" + name "CmIdentification" + value (value Text "")) + (object Attribute + tool "Java" + name "CopyrightNotice" + value (value Text "")) + (object Attribute + tool "Java" + name "AdditionalImports" + value (value Text "")))) + (object Attribute + tool "Java" + name "default__Operation" + value (list Attribute_Set + (object Attribute + tool "Java" + name "Abstract" + value FALSE) + (object Attribute + tool "Java" + name "Static" + value FALSE) + (object Attribute + tool "Java" + name "Final" + value FALSE) + (object Attribute + tool "Java" + name "Native" + value FALSE) + (object Attribute + tool "Java" + name "Synchronized" + value FALSE))) + (object Attribute + tool "Java" + name "default__Attribute" + value (list Attribute_Set + (object Attribute + tool "Java" + name "GenerateDataMember" + value TRUE) + (object Attribute + tool "Java" + name "Final" + value FALSE) + (object Attribute + tool "Java" + name "Transient" + value FALSE) + (object Attribute + tool "Java" + name "Volatile" + value FALSE))) + (object Attribute + tool "Java" + name "default__Role" + value (list Attribute_Set + (object Attribute + tool "Java" + name "GenerateDataMember" + value TRUE) + (object Attribute + tool "Java" + name "ContainerClass" + value "") + (object Attribute + tool "Java" + name "InitialValue" + value "") + (object Attribute + tool "Java" + name "Final" + value FALSE) + (object Attribute + tool "Java" + name "Transient" + value FALSE) + (object Attribute + tool "Java" + name "Volatile" + value FALSE))) + (object Attribute + tool "Java" + name "HiddenTool" + value FALSE) + (object Attribute + tool "Oracle8" + name "propertyId" + value "360000002") + (object Attribute + tool "Oracle8" + name "default__Project" + value (list Attribute_Set + (object Attribute + tool "Oracle8" + name "DDLScriptFilename" + value "DDL1.SQL") + (object Attribute + tool "Oracle8" + name "DropClause" + value FALSE) + (object Attribute + tool "Oracle8" + name "PrimaryKeyColumnName" + value "_ID") + (object Attribute + tool "Oracle8" + name "PrimaryKeyColumnType" + value "NUMBER(5,0)") + (object Attribute + tool "Oracle8" + name "SchemaNamePrefix" + value "") + (object Attribute + tool "Oracle8" + name "SchemaNameSuffix" + value "") + (object Attribute + tool "Oracle8" + name "TableNamePrefix" + value "") + (object Attribute + tool "Oracle8" + name "TableNameSuffix" + value "") + (object Attribute + tool "Oracle8" + name "TypeNamePrefix" + value "") + (object Attribute + tool "Oracle8" + name "TypeNameSuffix" + value "") + (object Attribute + tool "Oracle8" + name "ViewNamePrefix" + value "") + (object Attribute + tool "Oracle8" + name "ViewNameSuffix" + value "") + (object Attribute + tool "Oracle8" + name "VarrayNamePrefix" + value "") + (object Attribute + tool "Oracle8" + name "VarrayNameSuffix" + value "") + (object Attribute + tool "Oracle8" + name "NestedTableNamePrefix" + value "") + (object Attribute + tool "Oracle8" + name "NestedTableNameSuffix" + value "") + (object Attribute + tool "Oracle8" + name "ObjectTableNamePrefix" + value "") + (object Attribute + tool "Oracle8" + name "ObjectTableNameSuffix" + value ""))) + (object Attribute + tool "Oracle8" + name "default__Module-Spec" + value (list Attribute_Set + (object Attribute + tool "Oracle8" + name "IsSchema" + value FALSE))) + (object Attribute + tool "Oracle8" + name "default__Class" + value (list Attribute_Set + (object Attribute + tool "Oracle8" + name "OID" + value "") + (object Attribute + tool "Oracle8" + name "WhereClause" + value "") + (object Attribute + tool "Oracle8" + name "CheckConstraint" + value "") + (object Attribute + tool "Oracle8" + name "CollectionTypeLength" + value "") + (object Attribute + tool "Oracle8" + name "CollectionTypePrecision" + value "") + (object Attribute + tool "Oracle8" + name "CollectionTypeScale" + value "") + (object Attribute + tool "Oracle8" + name "CollectionOfREFS" + value FALSE))) + (object Attribute + tool "Oracle8" + name "default__Operation" + value (list Attribute_Set + (object Attribute + tool "Oracle8" + name "MethodKind" + value ("MethodKindSet" 1903)) + (object Attribute + tool "Oracle8" + name "OverloadID" + value "") + (object Attribute + tool "Oracle8" + name "OrderNumber" + value "") + (object Attribute + tool "Oracle8" + name "IsReadNoDataState" + value FALSE) + (object Attribute + tool "Oracle8" + name "IsReadNoProcessState" + value FALSE) + (object Attribute + tool "Oracle8" + name "IsWriteNoDataState" + value FALSE) + (object Attribute + tool "Oracle8" + name "IsWriteNoProcessState" + value FALSE) + (object Attribute + tool "Oracle8" + name "IsSelfish" + value FALSE) + (object Attribute + tool "Oracle8" + name "TriggerType" + value ("TriggerTypeSet" 1801)) + (object Attribute + tool "Oracle8" + name "TriggerEvent" + value ("TriggerEventSet" 1601)) + (object Attribute + tool "Oracle8" + name "TriggerText" + value "") + (object Attribute + tool "Oracle8" + name "TriggerReferencingNames" + value "") + (object Attribute + tool "Oracle8" + name "TriggerForEach" + value ("TriggerForEachSet" 1701)) + (object Attribute + tool "Oracle8" + name "TriggerWhenClause" + value "") + (object Attribute + tool "Oracle8" + name "MethodKindSet" + value (list Attribute_Set + (object Attribute + tool "Oracle8" + name "MapMethod" + value 1901) + (object Attribute + tool "Oracle8" + name "OrderMethod" + value 1902) + (object Attribute + tool "Oracle8" + name "Function" + value 1903) + (object Attribute + tool "Oracle8" + name "Procedure" + value 1904) + (object Attribute + tool "Oracle8" + name "Operator" + value 1905) + (object Attribute + tool "Oracle8" + name "Constructor" + value 1906) + (object Attribute + tool "Oracle8" + name "Destructor" + value 1907) + (object Attribute + tool "Oracle8" + name "Trigger" + value 1908) + (object Attribute + tool "Oracle8" + name "Calculated" + value 1909))) + (object Attribute + tool "Oracle8" + name "TriggerTypeSet" + value (list Attribute_Set + (object Attribute + tool "Oracle8" + name "AFTER" + value 1801) + (object Attribute + tool "Oracle8" + name "BEFORE" + value 1802) + (object Attribute + tool "Oracle8" + name "INSTEAD OF" + value 1803))) + (object Attribute + tool "Oracle8" + name "TriggerForEachSet" + value (list Attribute_Set + (object Attribute + tool "Oracle8" + name "ROW" + value 1701) + (object Attribute + tool "Oracle8" + name "STATEMENT" + value 1702))) + (object Attribute + tool "Oracle8" + name "TriggerEventSet" + value (list Attribute_Set + (object Attribute + tool "Oracle8" + name "INSERT" + value 1601) + (object Attribute + tool "Oracle8" + name "UPDATE" + value 1602) + (object Attribute + tool "Oracle8" + name "DELETE" + value 1603) + (object Attribute + tool "Oracle8" + name "INSERT OR UPDATE" + value 1604) + (object Attribute + tool "Oracle8" + name "INSERT OR DELETE" + value 1605) + (object Attribute + tool "Oracle8" + name "UPDATE OR DELETE" + value 1606) + (object Attribute + tool "Oracle8" + name "INSERT OR UPDATE OR DELETE" + value 1607))))) + (object Attribute + tool "Oracle8" + name "default__Role" + value (list Attribute_Set + (object Attribute + tool "Oracle8" + name "OrderNumber" + value ""))) + (object Attribute + tool "Oracle8" + name "default__Attribute" + value (list Attribute_Set + (object Attribute + tool "Oracle8" + name "OrderNumber" + value "") + (object Attribute + tool "Oracle8" + name "IsUnique" + value FALSE) + (object Attribute + tool "Oracle8" + name "NullsAllowed" + value TRUE) + (object Attribute + tool "Oracle8" + name "Length" + value "") + (object Attribute + tool "Oracle8" + name "Precision" + value "2") + (object Attribute + tool "Oracle8" + name "Scale" + value "6") + (object Attribute + tool "Oracle8" + name "IsIndex" + value FALSE) + (object Attribute + tool "Oracle8" + name "IsPrimaryKey" + value FALSE) + (object Attribute + tool "Oracle8" + name "CompositeUnique" + value FALSE) + (object Attribute + tool "Oracle8" + name "CheckConstraint" + value ""))) + (object Attribute + tool "Oracle8" + name "HiddenTool" + value FALSE) + (object Attribute + tool "Repository" + name "HiddenTool" + value FALSE) + (object Attribute + tool "cg" + name "propertyId" + value "809135966") + (object Attribute + tool "cg" + name "default__Project" + value (list Attribute_Set + (object Attribute + tool "cg" + name "UseMSVC" + value FALSE) + (object Attribute + tool "cg" + name "HeaderFileExtension" + value "h") + (object Attribute + tool "cg" + name "HeaderFileBackupExtension" + value "h~") + (object Attribute + tool "cg" + name "HeaderFileTemporaryExtension" + value "h#") + (object Attribute + tool "cg" + name "CodeFileExtension" + value "cpp") + (object Attribute + tool "cg" + name "CodeFileBackupExtension" + value "cp~") + (object Attribute + tool "cg" + name "CodeFileTemporaryExtension" + value "cp#") + (object Attribute + tool "cg" + name "CreateMissingDirectories" + value TRUE) + (object Attribute + tool "cg" + name "StopOnError" + value FALSE) + (object Attribute + tool "cg" + name "ErrorLimit" + value 30) + (object Attribute + tool "cg" + name "Directory" + value "$ROSECPP_SOURCE") + (object Attribute + tool "cg" + name "PathSeparator" + value "") + (object Attribute + tool "cg" + name "FileNameFormat" + value "128vx_b") + (object Attribute + tool "cg" + name "BooleanType" + value "int") + (object Attribute + tool "cg" + name "AllowTemplates" + value TRUE) + (object Attribute + tool "cg" + name "AllowExplicitInstantiations" + value TRUE) + (object Attribute + tool "cg" + name "AllowProtectedInheritance" + value TRUE) + (object Attribute + tool "cg" + name "CommentWidth" + value 60) + (object Attribute + tool "cg" + name "OneByValueContainer" + value "$targetClass") + (object Attribute + tool "cg" + name "OneByReferenceContainer" + value "$targetClass *") + (object Attribute + tool "cg" + name "OptionalByValueContainer" + value "OptionalByValue<$targetClass>") + (object Attribute + tool "cg" + name "OptionalByReferenceContainer" + value "$targetClass *") + (object Attribute + tool "cg" + name "FixedByValueContainer" + value "$targetClass[$limit]") + (object Attribute + tool "cg" + name "UnorderedFixedByValueContainer" + value "$targetClass[$limit]") + (object Attribute + tool "cg" + name "FixedByReferenceContainer" + value "$targetClass *[$limit]") + (object Attribute + tool "cg" + name "UnorderedFixedByReferenceContainer" + value "$targetClass *[$limit]") + (object Attribute + tool "cg" + name "BoundedByValueContainer" + value "BoundedListByValue<$targetClass,$limit>") + (object Attribute + tool "cg" + name "UnorderedBoundedByValueContainer" + value "BoundedSetByValue<$targetClass,$limit>") + (object Attribute + tool "cg" + name "BoundedByReferenceContainer" + value "BoundedListByReference<$targetClass,$limit>") + (object Attribute + tool "cg" + name "UnorderedBoundedByReferenceContainer" + value "BoundedSetByReference<$targetClass,$limit>") + (object Attribute + tool "cg" + name "UnboundedByValueContainer" + value "UnboundedListByValue<$targetClass>") + (object Attribute + tool "cg" + name "UnorderedUnboundedByValueContainer" + value "UnboundedSetByValue<$targetClass>") + (object Attribute + tool "cg" + name "UnboundedByReferenceContainer" + value "UnboundedListByReference<$targetClass>") + (object Attribute + tool "cg" + name "UnorderedUnboundedByReferenceContainer" + value "UnboundedSetByReference<$targetClass>") + (object Attribute + tool "cg" + name "QualifiedByValueContainer" + value "AssociationByValue<$qualtype, $qualcont>") + (object Attribute + tool "cg" + name "UnorderedQualifiedByValueContainer" + value "DictionaryByValue<$qualtype, $qualcont>") + (object Attribute + tool "cg" + name "QualifiedByReferenceContainer" + value "AssociationByReference<$qualtype, $qualcont>") + (object Attribute + tool "cg" + name "UnorderedQualifiedByReferenceContainer" + value "DictionaryByReference<$qualtype, $qualcont>") + (object Attribute + tool "cg" + name "GeneratePreserveRegions" + value TRUE))) + (object Attribute + tool "cg" + name "default__Class" + value (list Attribute_Set + (object Attribute + tool "cg" + name "CodeName" + value "") + (object Attribute + tool "cg" + name "ImplementationType" + value "") + (object Attribute + tool "cg" + name "ClassKey" + value "class") + (object Attribute + tool "cg" + name "GenerateEmptyRegions" + value ("GenerateEmptyRegionSet" 3)) + (object Attribute + tool "cg" + name "GenerateEmptyRegionSet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "None" + value 0) + (object Attribute + tool "cg" + name "Preserved" + value 1) + (object Attribute + tool "cg" + name "Unpreserved" + value 2) + (object Attribute + tool "cg" + name "All" + value 3))) + (object Attribute + tool "cg" + name "PutBodiesInSpec" + value FALSE) + (object Attribute + tool "cg" + name "GenerateDefaultConstructor" + value ("GenerateSet" 199)) + (object Attribute + tool "cg" + name "DefaultConstructorVisibility" + value ("VisibilitySet" 45)) + (object Attribute + tool "cg" + name "InlineDefaultConstructor" + value FALSE) + (object Attribute + tool "cg" + name "ExplicitDefaultConstructor" + value FALSE) + (object Attribute + tool "cg" + name "GenerateCopyConstructor" + value ("GenerateSet" 199)) + (object Attribute + tool "cg" + name "CopyConstructorVisibility" + value ("VisibilitySet" 45)) + (object Attribute + tool "cg" + name "InlineCopyConstructor" + value FALSE) + (object Attribute + tool "cg" + name "ExplicitCopyConstructor" + value FALSE) + (object Attribute + tool "cg" + name "GenerateDestructor" + value TRUE) + (object Attribute + tool "cg" + name "DestructorVisibility" + value ("VisibilitySet" 45)) + (object Attribute + tool "cg" + name "DestructorKind" + value ("ThreeKindSet" 200)) + (object Attribute + tool "cg" + name "InlineDestructor" + value FALSE) + (object Attribute + tool "cg" + name "GenerateAssignmentOperation" + value ("GenerateSet" 199)) + (object Attribute + tool "cg" + name "AssignmentVisibility" + value ("VisibilitySet" 45)) + (object Attribute + tool "cg" + name "AssignmentKind" + value ("ThreeKindSet" 200)) + (object Attribute + tool "cg" + name "InlineAssignmentOperation" + value FALSE) + (object Attribute + tool "cg" + name "GenerateEqualityOperations" + value ("GenerateSet" 199)) + (object Attribute + tool "cg" + name "EqualityVisibility" + value ("VisibilitySet" 45)) + (object Attribute + tool "cg" + name "EqualityKind" + value ("FriendKindSet" 200)) + (object Attribute + tool "cg" + name "InlineEqualityOperations" + value FALSE) + (object Attribute + tool "cg" + name "GenerateRelationalOperations" + value FALSE) + (object Attribute + tool "cg" + name "RelationalVisibility" + value ("VisibilitySet" 45)) + (object Attribute + tool "cg" + name "RelationalKind" + value ("FriendKindSet" 200)) + (object Attribute + tool "cg" + name "InlineRelationalOperations" + value FALSE) + (object Attribute + tool "cg" + name "GenerateStorageMgmtOperations" + value FALSE) + (object Attribute + tool "cg" + name "StorageMgmtVisibility" + value ("VisibilitySet" 45)) + (object Attribute + tool "cg" + name "InlineStorageMgmtOperations" + value FALSE) + (object Attribute + tool "cg" + name "GenerateSubscriptOperation" + value FALSE) + (object Attribute + tool "cg" + name "SubscriptVisibility" + value ("VisibilitySet" 45)) + (object Attribute + tool "cg" + name "SubscriptKind" + value ("ThreeKindSet" 200)) + (object Attribute + tool "cg" + name "SubscriptResultType" + value "") + (object Attribute + tool "cg" + name "InlineSubscriptOperation" + value FALSE) + (object Attribute + tool "cg" + name "GenerateDereferenceOperation" + value FALSE) + (object Attribute + tool "cg" + name "DereferenceVisibility" + value ("VisibilitySet" 45)) + (object Attribute + tool "cg" + name "DereferenceKind" + value ("ThreeKindSet" 200)) + (object Attribute + tool "cg" + name "DereferenceResultType" + value "") + (object Attribute + tool "cg" + name "InlineDereferenceOperation" + value FALSE) + (object Attribute + tool "cg" + name "GenerateIndirectionOperation" + value FALSE) + (object Attribute + tool "cg" + name "IndirectionVisibility" + value ("VisibilitySet" 45)) + (object Attribute + tool "cg" + name "IndirectionKind" + value ("ThreeKindSet" 200)) + (object Attribute + tool "cg" + name "IndirectionResultType" + value "") + (object Attribute + tool "cg" + name "InlineIndirectionOperation" + value FALSE) + (object Attribute + tool "cg" + name "GenerateStreamOperations" + value FALSE) + (object Attribute + tool "cg" + name "StreamVisibility" + value ("VisibilitySet" 45)) + (object Attribute + tool "cg" + name "InlineStreamOperations" + value FALSE) + (object Attribute + tool "cg" + name "ThreeKindSet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "Common" + value 200) + (object Attribute + tool "cg" + name "Virtual" + value 201) + (object Attribute + tool "cg" + name "Abstract" + value 202))) + (object Attribute + tool "cg" + name "KindSet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "Common" + value 200) + (object Attribute + tool "cg" + name "Virtual" + value 201) + (object Attribute + tool "cg" + name "Abstract" + value 202) + (object Attribute + tool "cg" + name "Static" + value 203))) + (object Attribute + tool "cg" + name "FriendKindSet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "Common" + value 200) + (object Attribute + tool "cg" + name "Virtual" + value 201) + (object Attribute + tool "cg" + name "Abstract" + value 202) + (object Attribute + tool "cg" + name "Friend" + value 204))) + (object Attribute + tool "cg" + name "GenerateSet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "DeclareAndDefine" + value 199) + (object Attribute + tool "cg" + name "DeclareOnly" + value 205) + (object Attribute + tool "cg" + name "DoNotDeclare" + value 206))) + (object Attribute + tool "cg" + name "VisibilitySet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "Public" + value 45) + (object Attribute + tool "cg" + name "Protected" + value 44) + (object Attribute + tool "cg" + name "Private" + value 43) + (object Attribute + tool "cg" + name "Implementation" + value 14))) + (object Attribute + tool "cg" + name "ConstValue" + value "") + (object Attribute + tool "cg" + name "GenerateDefaultSpecifier" + value FALSE) + (object Attribute + tool "cg" + name "DefaultSpecifier" + value ""))) + (object Attribute + tool "cg" + name "default__Module-Spec" + value (list Attribute_Set + (object Attribute + tool "cg" + name "Generate" + value TRUE) + (object Attribute + tool "cg" + name "GenerateEmptyRegions" + value ("GenerateEmptyRegionSet" 3)) + (object Attribute + tool "cg" + name "GenerateEmptyRegionSet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "None" + value 0) + (object Attribute + tool "cg" + name "Preserved" + value 1) + (object Attribute + tool "cg" + name "Unpreserved" + value 2) + (object Attribute + tool "cg" + name "All" + value 3))) + (object Attribute + tool "cg" + name "CmIdentification" + value (value Text " %X% %Q% %Z% %W%")) + (object Attribute + tool "cg" + name "CopyrightNotice" + value (value Text "")) + (object Attribute + tool "cg" + name "FileName" + value "AUTO GENERATE") + (object Attribute + tool "cg" + name "AllowExtensionlessFileName" + value FALSE) + (object Attribute + tool "cg" + name "InclusionProtectionSymbol" + value "AUTO GENERATE") + (object Attribute + tool "cg" + name "IncludeFormat" + value (value Text +|// $package +|#include "$file" +| + )) + (object Attribute + tool "cg" + name "IncludeBySimpleName" + value FALSE) + (object Attribute + tool "cg" + name "IncludePrecompiledHeader" + value FALSE) + (object Attribute + tool "cg" + name "IncludeOrder" + value "AMIR") + (object Attribute + tool "cg" + name "AdditionalIncludes" + value (value Text "")) + (object Attribute + tool "cg" + name "InliningStyle" + value ("InliningStyleSet" 207)) + (object Attribute + tool "cg" + name "InliningStyleSet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "InClassDeclaration" + value 208) + (object Attribute + tool "cg" + name "FollowingClassDeclaration" + value 207))) + (object Attribute + tool "cg" + name "TypesDefined" + value (value Text "")) + (object Attribute + tool "cg" + name "IncludeClosure" + value (value Text "")))) + (object Attribute + tool "cg" + name "default__Module-Body" + value (list Attribute_Set + (object Attribute + tool "cg" + name "Generate" + value TRUE) + (object Attribute + tool "cg" + name "GenerateEmptyRegions" + value ("GenerateEmptyRegionSet" 3)) + (object Attribute + tool "cg" + name "GenerateEmptyRegionSet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "None" + value 0) + (object Attribute + tool "cg" + name "Preserved" + value 1) + (object Attribute + tool "cg" + name "Unpreserved" + value 2) + (object Attribute + tool "cg" + name "All" + value 3))) + (object Attribute + tool "cg" + name "CmIdentification" + value (value Text " %X% %Q% %Z% %W%")) + (object Attribute + tool "cg" + name "CopyrightNotice" + value (value Text "")) + (object Attribute + tool "cg" + name "FileName" + value "AUTO GENERATE") + (object Attribute + tool "cg" + name "AllowExtensionlessFileName" + value FALSE) + (object Attribute + tool "cg" + name "IncludeFormat" + value (value Text +|// $package +|#include "$file" +| + )) + (object Attribute + tool "cg" + name "IncludeBySimpleName" + value FALSE) + (object Attribute + tool "cg" + name "IncludePrecompiledHeader" + value TRUE) + (object Attribute + tool "cg" + name "IncludeOrder" + value "AMIR") + (object Attribute + tool "cg" + name "AdditionalIncludes" + value (value Text "")) + (object Attribute + tool "cg" + name "InliningStyle" + value ("InliningStyleSet" 207)) + (object Attribute + tool "cg" + name "InliningStyleSet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "InClassDeclaration" + value 208) + (object Attribute + tool "cg" + name "FollowingClassDeclaration" + value 207))) + (object Attribute + tool "cg" + name "TypesDefined" + value (value Text "")) + (object Attribute + tool "cg" + name "IncludeClosure" + value (value Text "")))) + (object Attribute + tool "cg" + name "default__Operation" + value (list Attribute_Set + (object Attribute + tool "cg" + name "CodeName" + value "") + (object Attribute + tool "cg" + name "OperationKind" + value ("OperationKindSet" 200)) + (object Attribute + tool "cg" + name "OperationKindSet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "Common" + value 200) + (object Attribute + tool "cg" + name "Virtual" + value 201) + (object Attribute + tool "cg" + name "Abstract" + value 202) + (object Attribute + tool "cg" + name "Static" + value 203) + (object Attribute + tool "cg" + name "Friend" + value 204))) + (object Attribute + tool "cg" + name "OperationIsConst" + value FALSE) + (object Attribute + tool "cg" + name "OperationIsExplicit" + value FALSE) + (object Attribute + tool "cg" + name "Inline" + value FALSE) + (object Attribute + tool "cg" + name "EntryCode" + value (value Text "")) + (object Attribute + tool "cg" + name "ExitCode" + value (value Text "")) + (object Attribute + tool "cg" + name "GenerateEmptyRegions" + value ("GenerateEmptyRegionSet" 3)) + (object Attribute + tool "cg" + name "GenerateEmptyRegionSet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "None" + value 0) + (object Attribute + tool "cg" + name "Preserved" + value 1) + (object Attribute + tool "cg" + name "Unpreserved" + value 2) + (object Attribute + tool "cg" + name "All" + value 3))) + (object Attribute + tool "cg" + name "BodyAnnotations" + value "") + (object Attribute + tool "cg" + name "OperationIsOneWay" + value FALSE) + (object Attribute + tool "cg" + name "Context" + value "") + (object Attribute + tool "cg" + name "Raises" + value ""))) + (object Attribute + tool "cg" + name "default__Has" + value (list Attribute_Set + (object Attribute + tool "cg" + name "CodeName" + value "") + (object Attribute + tool "cg" + name "Ordered" + value TRUE) + (object Attribute + tool "cg" + name "NameIfUnlabeled" + value "the_$supplier") + (object Attribute + tool "cg" + name "GenerateDataMember" + value TRUE) + (object Attribute + tool "cg" + name "DataMemberName" + value "$relationship") + (object Attribute + tool "cg" + name "DataMemberVisibility" + value ("DataMemberVisibilitySet" 14)) + (object Attribute + tool "cg" + name "DataMemberVisibilitySet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "Public" + value 45) + (object Attribute + tool "cg" + name "Protected" + value 44) + (object Attribute + tool "cg" + name "Private" + value 43) + (object Attribute + tool "cg" + name "Implementation" + value 14) + (object Attribute + tool "cg" + name "AtRelationshipVisibility" + value 210))) + (object Attribute + tool "cg" + name "DataMemberMutability" + value ("DataMemberMutabilitySet" 0)) + (object Attribute + tool "cg" + name "DataMemberMutabilitySet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "Unrestricted" + value 0) + (object Attribute + tool "cg" + name "Mutable" + value 1) + (object Attribute + tool "cg" + name "Const" + value 2))) + (object Attribute + tool "cg" + name "DataMemberIsVolatile" + value FALSE) + (object Attribute + tool "cg" + name "DataMemberFieldSize" + value "") + (object Attribute + tool "cg" + name "InitialValue" + value (value Text "")) + (object Attribute + tool "cg" + name "GenerateGetOperation" + value TRUE) + (object Attribute + tool "cg" + name "GenerateSetOperation" + value TRUE) + (object Attribute + tool "cg" + name "GetName" + value "get_$relationship") + (object Attribute + tool "cg" + name "SetName" + value "set_$relationship") + (object Attribute + tool "cg" + name "GetSetKinds" + value ("GetSetKindsSet" 200)) + (object Attribute + tool "cg" + name "GetSetKindsSet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "Common" + value 200) + (object Attribute + tool "cg" + name "Virtual" + value 201) + (object Attribute + tool "cg" + name "Abstract" + value 202) + (object Attribute + tool "cg" + name "Static" + value 203) + (object Attribute + tool "cg" + name "Friend" + value 204))) + (object Attribute + tool "cg" + name "ContainerClass" + value "") + (object Attribute + tool "cg" + name "SelectorName" + value "") + (object Attribute + tool "cg" + name "SelectorType" + value "") + (object Attribute + tool "cg" + name "GetIsConst" + value TRUE) + (object Attribute + tool "cg" + name "GetResultIsConst" + value ("GetResultIsConstSet" 2)) + (object Attribute + tool "cg" + name "GetResultIsConstSet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "False" + value 0) + (object Attribute + tool "cg" + name "True" + value 1) + (object Attribute + tool "cg" + name "Same_As_Function" + value 2))) + (object Attribute + tool "cg" + name "GetSetByReference" + value FALSE) + (object Attribute + tool "cg" + name "InlineGet" + value TRUE) + (object Attribute + tool "cg" + name "SetReturnsValue" + value FALSE) + (object Attribute + tool "cg" + name "InlineSet" + value TRUE) + (object Attribute + tool "cg" + name "ForwardReferenceOnly" + value FALSE) + (object Attribute + tool "cg" + name "GenerateForwardReference" + value FALSE) + (object Attribute + tool "cg" + name "IsReadOnly" + value FALSE) + (object Attribute + tool "cg" + name "BoundedHasRelType" + value ("HasRelTypeSet" 47)) + (object Attribute + tool "cg" + name "HasRelTypeSet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "Array" + value 24) + (object Attribute + tool "cg" + name "Sequence" + value 47))))) + (object Attribute + tool "cg" + name "default__Association" + value (list Attribute_Set + (object Attribute + tool "cg" + name "NameIfUnlabeled" + value "the_$targetClass"))) + (object Attribute + tool "cg" + name "default__Inherit" + value (list Attribute_Set + (object Attribute + tool "cg" + name "InstanceArguments" + value ""))) + (object Attribute + tool "cg" + name "default__Role" + value (list Attribute_Set + (object Attribute + tool "cg" + name "CodeName" + value "") + (object Attribute + tool "cg" + name "ForwardReferenceOnly" + value FALSE) + (object Attribute + tool "cg" + name "NameIfUnlabeled" + value "the_$targetClass") + (object Attribute + tool "cg" + name "GenerateDataMember" + value TRUE) + (object Attribute + tool "cg" + name "DataMemberName" + value "$target") + (object Attribute + tool "cg" + name "DataMemberVisibility" + value ("DataMemberVisibilitySet" 14)) + (object Attribute + tool "cg" + name "DataMemberVisibilitySet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "Public" + value 45) + (object Attribute + tool "cg" + name "Protected" + value 44) + (object Attribute + tool "cg" + name "Private" + value 43) + (object Attribute + tool "cg" + name "Implementation" + value 14) + (object Attribute + tool "cg" + name "AtRelationshipVisibility" + value 210))) + (object Attribute + tool "cg" + name "DataMemberMutability" + value ("DataMemberMutabilitySet" 0)) + (object Attribute + tool "cg" + name "DataMemberMutabilitySet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "Unrestricted" + value 0) + (object Attribute + tool "cg" + name "Mutable" + value 1) + (object Attribute + tool "cg" + name "Const" + value 2))) + (object Attribute + tool "cg" + name "DataMemberIsVolatile" + value FALSE) + (object Attribute + tool "cg" + name "DataMemberFieldSize" + value "") + (object Attribute + tool "cg" + name "InitialValue" + value (value Text "")) + (object Attribute + tool "cg" + name "ContainerClass" + value "") + (object Attribute + tool "cg" + name "ContainerGet" + value "$data.get($keys)") + (object Attribute + tool "cg" + name "ContainerSet" + value "$data.set($keys,$value)") + (object Attribute + tool "cg" + name "QualifiedContainer" + value "") + (object Attribute + tool "cg" + name "AssocClassContainer" + value "$supplier *") + (object Attribute + tool "cg" + name "AssocClassInitialValue" + value (value Text "")) + (object Attribute + tool "cg" + name "GetSetKinds" + value ("GetSetKindsSet" 200)) + (object Attribute + tool "cg" + name "GetSetKindsSet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "Common" + value 200) + (object Attribute + tool "cg" + name "Virtual" + value 201) + (object Attribute + tool "cg" + name "Abstract" + value 202) + (object Attribute + tool "cg" + name "Static" + value 203) + (object Attribute + tool "cg" + name "Friend" + value 204))) + (object Attribute + tool "cg" + name "GetSetByReference" + value FALSE) + (object Attribute + tool "cg" + name "GenerateGetOperation" + value TRUE) + (object Attribute + tool "cg" + name "GetName" + value "get_$target") + (object Attribute + tool "cg" + name "GetIsConst" + value TRUE) + (object Attribute + tool "cg" + name "GetResultIsConst" + value ("GetResultIsConstSet" 2)) + (object Attribute + tool "cg" + name "GetResultIsConstSet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "False" + value 0) + (object Attribute + tool "cg" + name "True" + value 1) + (object Attribute + tool "cg" + name "Same_As_Function" + value 2))) + (object Attribute + tool "cg" + name "InlineGet" + value TRUE) + (object Attribute + tool "cg" + name "GenerateSetOperation" + value TRUE) + (object Attribute + tool "cg" + name "SetName" + value "set_$target") + (object Attribute + tool "cg" + name "SetReturnsValue" + value FALSE) + (object Attribute + tool "cg" + name "InlineSet" + value TRUE) + (object Attribute + tool "cg" + name "QualifiedGetSetByReference" + value ("QualifiedGetSetByReferenceSet" 2)) + (object Attribute + tool "cg" + name "QualifiedGetSetByReferenceSet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "False" + value 0) + (object Attribute + tool "cg" + name "True" + value 1) + (object Attribute + tool "cg" + name "Same_As_GetSetByReference" + value 2))) + (object Attribute + tool "cg" + name "GenerateQualifiedGetOperation" + value TRUE) + (object Attribute + tool "cg" + name "QualifiedGetName" + value "get_$target") + (object Attribute + tool "cg" + name "QualifiedGetIsConst" + value TRUE) + (object Attribute + tool "cg" + name "QualifiedGetResultIsConst" + value ("GetResultIsConstSet" 2)) + (object Attribute + tool "cg" + name "InlineQualifiedGet" + value TRUE) + (object Attribute + tool "cg" + name "GenerateQualifiedSetOperation" + value TRUE) + (object Attribute + tool "cg" + name "QualifiedSetName" + value "set_$target") + (object Attribute + tool "cg" + name "QualifiedSetReturnsValue" + value FALSE) + (object Attribute + tool "cg" + name "InlineQualifiedSet" + value TRUE) + (object Attribute + tool "cg" + name "GenerateAssocClassDataMember" + value TRUE) + (object Attribute + tool "cg" + name "AssocClassDataMemberName" + value "$target") + (object Attribute + tool "cg" + name "AssocClassDataMemberVisibility" + value ("DataMemberVisibilitySet" 14)) + (object Attribute + tool "cg" + name "DataMemberVisibilitySet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "Public" + value 45) + (object Attribute + tool "cg" + name "Protected" + value 44) + (object Attribute + tool "cg" + name "Private" + value 43) + (object Attribute + tool "cg" + name "Implementation" + value 14) + (object Attribute + tool "cg" + name "AtRelationshipVisibility" + value 210))) + (object Attribute + tool "cg" + name "AssocClassDataMemberMutability" + value ("DataMemberMutabilitySet" 0)) + (object Attribute + tool "cg" + name "DataMemberMutabilitySet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "Unrestricted" + value 0) + (object Attribute + tool "cg" + name "Mutable" + value 1) + (object Attribute + tool "cg" + name "Const" + value 2))) + (object Attribute + tool "cg" + name "AssocClassDataMemberIsVolatile" + value FALSE) + (object Attribute + tool "cg" + name "AssocClassGetSetKinds" + value ("GetSetKindsSet" 200)) + (object Attribute + tool "cg" + name "GenerateAssocClassGetOperation" + value TRUE) + (object Attribute + tool "cg" + name "AssocClassGetName" + value "get_$target") + (object Attribute + tool "cg" + name "AssocClassGetIsConst" + value TRUE) + (object Attribute + tool "cg" + name "AssocClassGetResultIsConst" + value ("GetResultIsConstSet" 2)) + (object Attribute + tool "cg" + name "InlineAssocClassGet" + value TRUE) + (object Attribute + tool "cg" + name "GenerateAssocClassSetOperation" + value TRUE) + (object Attribute + tool "cg" + name "AssocClassSetName" + value "set_$target") + (object Attribute + tool "cg" + name "AssocClassSetReturnsValue" + value FALSE) + (object Attribute + tool "cg" + name "InlineAssocClassSet" + value TRUE) + (object Attribute + tool "cg" + name "AssocClassForwardReferenceOnly" + value TRUE) + (object Attribute + tool "cg" + name "GenerateForwardReference" + value FALSE) + (object Attribute + tool "cg" + name "IsReadOnly" + value FALSE) + (object Attribute + tool "cg" + name "BoundedRoleType" + value ("AssocTypeSet" 47)) + (object Attribute + tool "cg" + name "AssocTypeSet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "Array" + value 24) + (object Attribute + tool "cg" + name "Sequence" + value 47))))) + (object Attribute + tool "cg" + name "default__Attribute" + value (list Attribute_Set + (object Attribute + tool "cg" + name "CodeName" + value "") + (object Attribute + tool "cg" + name "GenerateDataMember" + value TRUE) + (object Attribute + tool "cg" + name "DataMemberName" + value "$attribute") + (object Attribute + tool "cg" + name "DataMemberVisibility" + value ("DataMemberVisibilitySet" 14)) + (object Attribute + tool "cg" + name "DataMemberVisibilitySet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "Public" + value 45) + (object Attribute + tool "cg" + name "Protected" + value 44) + (object Attribute + tool "cg" + name "Private" + value 43) + (object Attribute + tool "cg" + name "Implementation" + value 14) + (object Attribute + tool "cg" + name "AtAttributeVisibility" + value 211))) + (object Attribute + tool "cg" + name "DataMemberMutability" + value ("DataMemberMutabilitySet" 0)) + (object Attribute + tool "cg" + name "DataMemberMutabilitySet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "Unrestricted" + value 0) + (object Attribute + tool "cg" + name "Mutable" + value 1) + (object Attribute + tool "cg" + name "Const" + value 2))) + (object Attribute + tool "cg" + name "DataMemberIsVolatile" + value FALSE) + (object Attribute + tool "cg" + name "DataMemberFieldSize" + value "") + (object Attribute + tool "cg" + name "GenerateGetOperation" + value TRUE) + (object Attribute + tool "cg" + name "GenerateSetOperation" + value TRUE) + (object Attribute + tool "cg" + name "GetName" + value "get_$attribute") + (object Attribute + tool "cg" + name "SetName" + value "set_$attribute") + (object Attribute + tool "cg" + name "GetSetKinds" + value ("GetSetKindsSet" 200)) + (object Attribute + tool "cg" + name "GetSetKindsSet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "Common" + value 200) + (object Attribute + tool "cg" + name "Virtual" + value 201) + (object Attribute + tool "cg" + name "Abstract" + value 202) + (object Attribute + tool "cg" + name "Static" + value 203) + (object Attribute + tool "cg" + name "Friend" + value 204))) + (object Attribute + tool "cg" + name "GetIsConst" + value TRUE) + (object Attribute + tool "cg" + name "GetResultIsConst" + value ("GetResultIsConstSet" 2)) + (object Attribute + tool "cg" + name "GetResultIsConstSet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "False" + value 0) + (object Attribute + tool "cg" + name "True" + value 1) + (object Attribute + tool "cg" + name "Same_As_Function" + value 2))) + (object Attribute + tool "cg" + name "GetSetByReference" + value FALSE) + (object Attribute + tool "cg" + name "InlineGet" + value TRUE) + (object Attribute + tool "cg" + name "SetReturnsValue" + value FALSE) + (object Attribute + tool "cg" + name "InlineSet" + value TRUE) + (object Attribute + tool "cg" + name "CaseSpecifier" + value "") + (object Attribute + tool "cg" + name "IsReadOnly" + value FALSE))) + (object Attribute + tool "cg" + name "default__Uses" + value (list Attribute_Set + (object Attribute + tool "cg" + name "ForwardReferenceOnly" + value FALSE) + (object Attribute + tool "cg" + name "BodyReferenceOnly" + value FALSE) + (object Attribute + tool "cg" + name "GenerateForwardReference" + value FALSE))) + (object Attribute + tool "cg" + name "default__Subsystem" + value (list Attribute_Set + (object Attribute + tool "cg" + name "Directory" + value "AUTO GENERATE") + (object Attribute + tool "cg" + name "DirectoryIsOnSearchList" + value FALSE) + (object Attribute + tool "cg" + name "PrecompiledHeader" + value ""))) + (object Attribute + tool "cg" + name "default__Category" + value (list Attribute_Set + (object Attribute + tool "cg" + name "IsNamespace" + value FALSE) + (object Attribute + tool "cg" + name "Indent" + value 2) + (object Attribute + tool "cg" + name "CodeName" + value "") + (object Attribute + tool "cg" + name "GenerateEmptyRegions" + value ("GenerateEmptyRegionSet" 3)) + (object Attribute + tool "cg" + name "GenerateEmptyRegionSet" + value (list Attribute_Set + (object Attribute + tool "cg" + name "None" + value 0) + (object Attribute + tool "cg" + name "Preserved" + value 1) + (object Attribute + tool "cg" + name "Unpreserved" + value 2) + (object Attribute + tool "cg" + name "All" + value 3))))) + (object Attribute + tool "MSVC" + name "propertyId" + value "809135966") + (object Attribute + tool "MSVC" + name "default__Project" + value (list Attribute_Set + (object Attribute + tool "MSVC" + name "Version" + value "5.0"))) + (object Attribute + tool "MSVC" + name "default__Class" + value (list Attribute_Set + (object Attribute + tool "MSVC" + name "Type" + value ("MSVCClassTypeSet" 0)) + (object Attribute + tool "MSVC" + name "MSVCClassTypeSet" + value (list Attribute_Set + (object Attribute + tool "MSVC" + name "Normal" + value 0) + (object Attribute + tool "MSVC" + name "Interface_Part" + value 1) + (object Attribute + tool "MSVC" + name "Connection_Part" + value 2) + (object Attribute + tool "MSVC" + name "Class_Factory" + value 3))) + (object Attribute + tool "MSVC" + name "CObjectFunctionality" + value ("CObjectFunctionalitySet" 0)) + (object Attribute + tool "MSVC" + name "CObjectFunctionalitySet" + value (list Attribute_Set + (object Attribute + tool "MSVC" + name "None" + value 0) + (object Attribute + tool "MSVC" + name "Dynamic" + value 1) + (object Attribute + tool "MSVC" + name "Dyncreate" + value 2) + (object Attribute + tool "MSVC" + name "Serial" + value 3))) + (object Attribute + tool "MSVC" + name "GenerateOverrideGroup" + value FALSE) + (object Attribute + tool "MSVC" + name "GenerateDataGroup" + value FALSE) + (object Attribute + tool "MSVC" + name "AFX_DATA_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "GenerateFieldGroup" + value FALSE) + (object Attribute + tool "MSVC" + name "AFX_FIELD_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "GenerateMessageGroup" + value FALSE) + (object Attribute + tool "MSVC" + name "GenerateMessageMap" + value FALSE) + (object Attribute + tool "MSVC" + name "AFX_MSG_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "MESSAGE_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "OLEFactory" + value ("OLEFactorySet" 0)) + (object Attribute + tool "MSVC" + name "OLEFactorySet" + value (list Attribute_Set + (object Attribute + tool "MSVC" + name "None" + value 0) + (object Attribute + tool "MSVC" + name "Built_in" + value 1) + (object Attribute + tool "MSVC" + name "Simple" + value 2) + (object Attribute + tool "MSVC" + name "Licensed" + value 3))) + (object Attribute + tool "MSVC" + name "OLEName" + value "") + (object Attribute + tool "MSVC" + name "OLEClassID" + value "") + (object Attribute + tool "MSVC" + name "GenerateOLECtlType" + value FALSE) + (object Attribute + tool "MSVC" + name "OLECtlType" + value "") + (object Attribute + tool "MSVC" + name "GenerateOLETypeLib" + value FALSE) + (object Attribute + tool "MSVC" + name "OLETypeLibID" + value "") + (object Attribute + tool "MSVC" + name "OLETypeLibMajor" + value "") + (object Attribute + tool "MSVC" + name "OLETypeLibMinor" + value "") + (object Attribute + tool "MSVC" + name "GeneratePropPageIDs" + value FALSE) + (object Attribute + tool "MSVC" + name "OLEPropPageIDs" + value (value Text "")) + (object Attribute + tool "MSVC" + name "GenerateDispatchMap" + value FALSE) + (object Attribute + tool "MSVC" + name "AFX_DISPATCH_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "AFX_DISPATCH_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "DISPATCH_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "StockProperties" + value (value Text "")) + (object Attribute + tool "MSVC" + name "StockFunctions" + value (value Text "")) + (object Attribute + tool "MSVC" + name "DispatchDefValue" + value "") + (object Attribute + tool "MSVC" + name "GenerateDispIdEnum" + value FALSE) + (object Attribute + tool "MSVC" + name "AFX_DISP_ID_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "GenerateInterfaceMap" + value FALSE) + (object Attribute + tool "MSVC" + name "INTERFACE_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "InitInterface" + value "") + (object Attribute + tool "MSVC" + name "GenerateEventMap" + value FALSE) + (object Attribute + tool "MSVC" + name "AFX_EVENT_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "AFX_EVENT_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "EVENT_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "StockEvents" + value (value Text "")) + (object Attribute + tool "MSVC" + name "GenerateEventSinkMap" + value FALSE) + (object Attribute + tool "MSVC" + name "AFX_EVENTSINK_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "AFX_EVENTSINK_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "EVENTSINK_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "PropNotifySinks" + value (value Text "")) + (object Attribute + tool "MSVC" + name "GenerateConnectionMap" + value FALSE) + (object Attribute + tool "MSVC" + name "CONNECTION_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "ConnectionPointIID" + value "") + (object Attribute + tool "MSVC" + name "InheritanceType" + value "") + (object Attribute + tool "MSVC" + name "DeclSpec" + value "") + (object Attribute + tool "MSVC" + name "OLECommands" + value (value Text "")) + (object Attribute + tool "MSVC" + name "MFCDeclares" + value (value Text "")) + (object Attribute + tool "MSVC" + name "MFCImplements" + value (value Text "")) + (object Attribute + tool "MSVC" + name "ATL_Declares" + value (value Text "")) + (object Attribute + tool "MSVC" + name "GenerateCOMMap" + value FALSE) + (object Attribute + tool "MSVC" + name "COM_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "GenerateConnectionPointMap" + value FALSE) + (object Attribute + tool "MSVC" + name "CONNECTION_POINT_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "GenerateMsgMap" + value FALSE) + (object Attribute + tool "MSVC" + name "MSG_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "GeneratePropertyMap" + value FALSE) + (object Attribute + tool "MSVC" + name "PROPERTY_MAP_Entries" + value (value Text "")))) + (object Attribute + tool "MSVC" + name "default__Operation" + value (list Attribute_Set + (object Attribute + tool "MSVC" + name "Type" + value ("MSVCOperationTypeSet" 0)) + (object Attribute + tool "MSVC" + name "MSVCOperationTypeSet" + value (list Attribute_Set + (object Attribute + tool "MSVC" + name "Normal" + value 0) + (object Attribute + tool "MSVC" + name "Virtual_Override" + value 1) + (object Attribute + tool "MSVC" + name "Message_Handler" + value 2) + (object Attribute + tool "MSVC" + name "Dispatch_Handler" + value 3) + (object Attribute + tool "MSVC" + name "Event_Firing_Function" + value 4) + (object Attribute + tool "MSVC" + name "Event_Sink_Handler" + value 5) + (object Attribute + tool "MSVC" + name "Std_OLE_Method" + value 6) + (object Attribute + tool "MSVC" + name "Command_Parser" + value 7) + (object Attribute + tool "MSVC" + name "Property_Get_Function" + value 8) + (object Attribute + tool "MSVC" + name "Property_Set_Function" + value 9) + (object Attribute + tool "MSVC" + name "Property_Notify_Function" + value 10) + (object Attribute + tool "MSVC" + name "Macro_Generated_Function" + value 11))) + (object Attribute + tool "MSVC" + name "AFX_MSG_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "MESSAGE_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "AFX_DISPATCH_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "DISPATCH_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "AFX_EVENT_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "EVENT_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "AFX_EVENTSINK_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "EVENTSINK_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "CallType" + value "") + (object Attribute + tool "MSVC" + name "DeclSpec" + value "") + (object Attribute + tool "MSVC" + name "BodyImage" + value (value Text "")))) + (object Attribute + tool "MSVC" + name "default__Role" + value (list Attribute_Set + (object Attribute + tool "MSVC" + name "Type" + value ("MSVCAttributeTypeSet" 0)) + (object Attribute + tool "MSVC" + name "MSVCAttributeTypeSet" + value (list Attribute_Set + (object Attribute + tool "MSVC" + name "Normal" + value 0) + (object Attribute + tool "MSVC" + name "Member_Property" + value 1) + (object Attribute + tool "MSVC" + name "Get_Set_Property" + value 2) + (object Attribute + tool "MSVC" + name "Dialog_Data" + value 3) + (object Attribute + tool "MSVC" + name "Field_Data" + value 4) + (object Attribute + tool "MSVC" + name "Stock_Property" + value 5))) + (object Attribute + tool "MSVC" + name "AFX_DISPATCH_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "DISPATCH_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "DeclSpec" + value "") + (object Attribute + tool "MSVC" + name "PointerBase" + value "") + (object Attribute + tool "MSVC" + name "CallType" + value "") + (object Attribute + tool "MSVC" + name "StockPropertyImplementation" + value ""))) + (object Attribute + tool "MSVC" + name "default__Has" + value (list Attribute_Set + (object Attribute + tool "MSVC" + name "Type" + value ("MSVCAttributeTypeSet" 0)) + (object Attribute + tool "MSVC" + name "MSVCAttributeTypeSet" + value (list Attribute_Set + (object Attribute + tool "MSVC" + name "Normal" + value 0) + (object Attribute + tool "MSVC" + name "Member_Property" + value 1) + (object Attribute + tool "MSVC" + name "Get_Set_Property" + value 2) + (object Attribute + tool "MSVC" + name "Dialog_Data" + value 3) + (object Attribute + tool "MSVC" + name "Field_Data" + value 4) + (object Attribute + tool "MSVC" + name "Stock_Property" + value 5))) + (object Attribute + tool "MSVC" + name "AFX_DISPATCH_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "DISPATCH_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "DeclSpec" + value "") + (object Attribute + tool "MSVC" + name "PointerBase" + value "") + (object Attribute + tool "MSVC" + name "CallType" + value "") + (object Attribute + tool "MSVC" + name "StockPropertyImplementation" + value ""))) + (object Attribute + tool "MSVC" + name "default__Attribute" + value (list Attribute_Set + (object Attribute + tool "MSVC" + name "Type" + value ("MSVCAttributeTypeSet" 0)) + (object Attribute + tool "MSVC" + name "MSVCAttributeTypeSet" + value (list Attribute_Set + (object Attribute + tool "MSVC" + name "Normal" + value 0) + (object Attribute + tool "MSVC" + name "Member_Property" + value 1) + (object Attribute + tool "MSVC" + name "Get_Set_Property" + value 2) + (object Attribute + tool "MSVC" + name "Dialog_Data" + value 3) + (object Attribute + tool "MSVC" + name "Field_Data" + value 4) + (object Attribute + tool "MSVC" + name "Stock_Property" + value 5))) + (object Attribute + tool "MSVC" + name "AFX_DISPATCH_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "DISPATCH_MAP_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "DeclSpec" + value "") + (object Attribute + tool "MSVC" + name "PointerBase" + value "") + (object Attribute + tool "MSVC" + name "CallType" + value "") + (object Attribute + tool "MSVC" + name "StockPropertyImplementation" + value ""))) + (object Attribute + tool "MSVC" + name "default__Module-Spec" + value (list Attribute_Set + (object Attribute + tool "MSVC" + name "GenerateIncludesGroup" + value FALSE) + (object Attribute + tool "MSVC" + name "AFX_INCLUDES_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "GenerateInsertLocation" + value FALSE))) + (object Attribute + tool "MSVC" + name "default__Module-Body" + value (list Attribute_Set + (object Attribute + tool "MSVC" + name "GenerateIncludesGroup" + value FALSE) + (object Attribute + tool "MSVC" + name "AFX_INCLUDES_Entries" + value (value Text "")) + (object Attribute + tool "MSVC" + name "GenerateInsertLocation" + value FALSE))) + (object Attribute + tool "cg" + name "HiddenTool" + value FALSE) + (object Attribute + tool "TypeLibImporter" + name "HiddenTool" + value FALSE) + (object Attribute + tool "Visual Basic" + name "propertyId" + value "783606378") + (object Attribute + tool "Visual Basic" + name "default__Class" + value (list Attribute_Set + (object Attribute + tool "Visual Basic" + name "CreatableSet" + value (list Attribute_Set + (object Attribute + tool "Visual Basic" + name "Private" + value 221) + (object Attribute + tool "Visual Basic" + name "PublicNotCreatable" + value 213) + (object Attribute + tool "Visual Basic" + name "SingleUse" + value 214) + (object Attribute + tool "Visual Basic" + name "GlobalSingleUse" + value 215) + (object Attribute + tool "Visual Basic" + name "MultiUse" + value 219) + (object Attribute + tool "Visual Basic" + name "GlobalMultiUse" + value 220))) + (object Attribute + tool "Visual Basic" + name "OptionBase" + value "0") + (object Attribute + tool "Visual Basic" + name "OptionExplicit" + value TRUE) + (object Attribute + tool "Visual Basic" + name "OptionCompare" + value ("CompareSet" 202)) + (object Attribute + tool "Visual Basic" + name "Creatable" + value ("CreatableSet" 221)) + (object Attribute + tool "Visual Basic" + name "GenerateInitialization" + value FALSE) + (object Attribute + tool "Visual Basic" + name "GenerateTermination" + value FALSE) + (object Attribute + tool "Visual Basic" + name "CollectionClass" + value "Collection") + (object Attribute + tool "Visual Basic" + name "CompareSet" + value (list Attribute_Set + (object Attribute + tool "Visual Basic" + name "None" + value 202) + (object Attribute + tool "Visual Basic" + name "Binary" + value 203) + (object Attribute + tool "Visual Basic" + name "Text" + value 204))))) + (object Attribute + tool "Visual Basic" + name "default__Operation" + value (list Attribute_Set + (object Attribute + tool "Visual Basic" + name "OperationName" + value "$operation") + (object Attribute + tool "Visual Basic" + name "LibraryName" + value "") + (object Attribute + tool "Visual Basic" + name "AliasName" + value "") + (object Attribute + tool "Visual Basic" + name "IsStatic" + value FALSE) + (object Attribute + tool "Visual Basic" + name "EntryCode" + value (value Text "")) + (object Attribute + tool "Visual Basic" + name "ExitCode" + value (value Text "")))) + (object Attribute + tool "Visual Basic" + name "default__Attribute" + value (list Attribute_Set + (object Attribute + tool "Visual Basic" + name "IsConst" + value FALSE) + (object Attribute + tool "Visual Basic" + name "New" + value FALSE) + (object Attribute + tool "Visual Basic" + name "WithEvents" + value FALSE) + (object Attribute + tool "Visual Basic" + name "Subscript" + value "") + (object Attribute + tool "Visual Basic" + name "NameIfUnlabeled" + value "the$supplier") + (object Attribute + tool "Visual Basic" + name "GenerateDataMember" + value TRUE) + (object Attribute + tool "Visual Basic" + name "DataMemberName" + value "$relationship") + (object Attribute + tool "Visual Basic" + name "GenerateGetOperation" + value FALSE) + (object Attribute + tool "Visual Basic" + name "GenerateSetOperation" + value FALSE) + (object Attribute + tool "Visual Basic" + name "GenerateLetOperation" + value FALSE))) + (object Attribute + tool "Visual Basic" + name "default__Role" + value (list Attribute_Set + (object Attribute + tool "Visual Basic" + name "New" + value FALSE) + (object Attribute + tool "Visual Basic" + name "WithEvents" + value FALSE) + (object Attribute + tool "Visual Basic" + name "Subscript" + value "") + (object Attribute + tool "Visual Basic" + name "NameIfUnlabeled" + value "the$supplier") + (object Attribute + tool "Visual Basic" + name "GenerateDataMember" + value TRUE) + (object Attribute + tool "Visual Basic" + name "DataMemberName" + value "$relationship") + (object Attribute + tool "Visual Basic" + name "GenerateGetOperation" + value FALSE) + (object Attribute + tool "Visual Basic" + name "GenerateSetOperation" + value FALSE) + (object Attribute + tool "Visual Basic" + name "GenerateLetOperation" + value FALSE))) + (object Attribute + tool "Visual Basic" + name "default__Inherit" + value (list Attribute_Set + (object Attribute + tool "Visual Basic" + name "ImplementsDelegation" + value TRUE))) + (object Attribute + tool "Visual Basic" + name "default__Module-Spec" + value (list Attribute_Set + (object Attribute + tool "Visual Basic" + name "ProjectFile" + value ""))) + (object Attribute + tool "Visual Basic" + name "HiddenTool" + value FALSE) + (object Attribute + tool "VisualStudio" + name "HiddenTool" + value FALSE)) + quid "3FAA8E8700C1")) diff --git a/sandbox/kgoodson/events/impl/pom.xml b/sandbox/kgoodson/events/impl/pom.xml new file mode 100644 index 0000000000..6a7d7eb729 --- /dev/null +++ b/sandbox/kgoodson/events/impl/pom.xml @@ -0,0 +1,165 @@ + + + + + org.apache.tuscany.sdo + tuscany-sdo + 1.0-incubating-SNAPSHOT + + 4.0.0 + tuscany-sdo-impl + Tuscany SDO Implementation + Tuscany implementation of SDO API. + kgoodson-sandbox + + + + codehaus + Codehaus maven repository + http://repository.codehaus.org/ + + + + + + org.apache.tuscany.sdo + tuscany-sdo-lib + ${pom.version} + compile + + + + org.eclipse.emf + common + ${emfVersion} + compile + + + org.eclipse.emf + ecore + ${emfVersion} + compile + + + org.eclipse.emf + ecore-change + ${emfVersion} + compile + + + org.eclipse.emf + ecore-xmi + ${emfVersion} + compile + + + org.eclipse.xsd + xsd + ${emfVersion} + compile + + + + backport-util-concurrent + backport-util-concurrent + 3.0 + + + + + asm + asm + 2.2 + provided + true + + + + + stax + stax-api + 1.0.1 + + + org.codehaus.woodstox + wstx-asl + 3.2.1 + + + + + junit + junit + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.1 + + + + ${project.artifactId} + ${project.name} + ${project.organization.name} + ${version} + ${project.artifactId} + ${project.organization.name} + org.apache + ${project.version} + + 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 + 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 + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + ${basedir}/src/main/java/org/apache/tuscany/sdo/overview.html + 2.0 + 1.4 + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/AnyTypeDataObject.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/AnyTypeDataObject.java new file mode 100644 index 0000000000..79deec6d29 --- /dev/null +++ b/sandbox/kgoodson/events/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; + +/** + * + * A representation of the model object 'Any Type Data Object'. + * + * + * + * @see org.apache.tuscany.sdo.SDOPackage#getAnyTypeDataObject() + * @model extendedMetaData="kind='mixed'" + * @generated + */ +public interface AnyTypeDataObject extends DataObject, AnyType { +} // AnyTypeDataObject diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/SDOExtendedMetaData.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/SDOExtendedMetaData.java new file mode 100644 index 0000000000..ad546cc614 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/SDOExtendedMetaData.java @@ -0,0 +1,39 @@ +/** + * + * 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); + + void setFeatureNamespaceMatchingLax(boolean featureNamespaceMatchingLax); +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/SDOFactory.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/SDOFactory.java new file mode 100644 index 0000000000..04ef0d714a --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/SDOFactory.java @@ -0,0 +1,185 @@ +/** + * + * 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; + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @see org.apache.tuscany.sdo.SDOPackage + * @generated + */ +public interface SDOFactory extends EFactory{ + /** + * The singleton instance of the factory. + * + * + * @generated + */ + SDOFactory eINSTANCE = org.apache.tuscany.sdo.impl.SDOFactoryImpl.init(); + + /** + * Returns a new object of class 'Change Summary'. + * + * + * @return a new object of class 'Change Summary'. + * @generated + */ + ChangeSummary createChangeSummary(); + + /** + * Returns a new object of class 'Change Summary Setting'. + * + * + * @return a new object of class 'Change Summary Setting'. + * @generated + */ + ChangeSummary.Setting createChangeSummarySetting(); + + /** + * Returns a new object of class 'Data Graph'. + * + * + * @return a new object of class 'Data Graph'. + * @generated + */ + DataGraph createDataGraph(); + + /** + * Returns a new object of class 'Any Type Data Object'. + * + * + * @return a new object of class 'Any Type Data Object'. + * @generated + */ + AnyTypeDataObject createAnyTypeDataObject(); + + /** + * Returns a new object of class 'Simple Any Type Data Object'. + * + * + * @return a new object of class 'Simple Any Type Data Object'. + * @generated + */ + SimpleAnyTypeDataObject createSimpleAnyTypeDataObject(); + + /** + * Returns a new object of class 'Class'. + * + * + * @return a new object of class 'Class'. + * @generated + */ + Type createClass(); + + /** + * Returns a new object of class 'Data Type'. + * + * + * @return a new object of class 'Data Type'. + * @generated + */ + Type createDataType(); + + /** + * Returns a new object of class 'Attribute'. + * + * + * @return a new object of class 'Attribute'. + * @generated + */ + Property createAttribute(); + + /** + * Returns a new object of class 'Reference'. + * + * + * @return a new object of class 'Reference'. + * @generated + */ + Property createReference(); + + /** + * Returns a new object of class 'Enum'. + * + * + * @return a new object of class 'Enum'. + * @generated + */ + Type createEnum(); + + /** + * Returns a new object of class 'Dynamic Data Object'. + * + * + * @return a new object of class 'Dynamic Data Object'. + * @generated + */ + DataObject createDynamicDataObject(); + + /** + * Returns a new object of class 'Store Data Object'. + * + * + * @return a new object of class 'Store Data Object'. + * @generated + */ + DataObject createStoreDataObject(); + + /** + * Returns a new object of class 'Dynamic Store Data Object'. + * + * + * @return a new object of class 'Dynamic Store Data Object'. + * @generated + */ + DataObject createDynamicStoreDataObject(); + + /** + * Returns a new object of class 'Extensible Data Object'. + * + * + * @return a new object of class 'Extensible Data Object'. + * @generated + */ + DataObject createExtensibleDataObject(); + + /** + * Returns the package supported by this factory. + * + * + * @return the package supported by this factory. + * @generated + */ + SDOPackage getSDOPackage(); + + ChangeSummary.Setting createChangeSummarySetting(EStructuralFeature eStructuralFeature, Object value, boolean isSet); + +} //SDOFactory diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/SDOPackage.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/SDOPackage.java new file mode 100644 index 0000000000..a21f2308ab --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/SDOPackage.java @@ -0,0 +1,1657 @@ +/** + * + * 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; + +/** + * + * The Package for the model. + * It contains accessors for the meta objects to represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @see org.apache.tuscany.sdo.SDOFactory + * @model kind="package" + * @generated + */ +public interface SDOPackage extends EPackage{ + /** + * The package name. + * + * + * @generated + */ + String eNAME = "sdo"; + + /** + * The package namespace URI. + * + * + * @generated + */ + String eNS_URI = "http://www.apache.org/tuscany/2005/SDO"; + + /** + * The package namespace name. + * + * + * @generated + */ + String eNS_PREFIX = "sdo"; + + /** + * The singleton instance of the package. + * + * + * @generated + */ + SDOPackage eINSTANCE = org.apache.tuscany.sdo.impl.SDOPackageImpl.init(); + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.DataGraphImpl Data Graph}' class. + * + * + * @see org.apache.tuscany.sdo.impl.DataGraphImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getDataGraph() + * @generated + */ + int DATA_GRAPH = 2; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.ChangeSummaryImpl Change Summary}' class. + * + * + * @see org.apache.tuscany.sdo.impl.ChangeSummaryImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getChangeSummary() + * @generated + */ + int CHANGE_SUMMARY = 0; + + /** + * The feature id for the 'Object Changes' map. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY__OBJECT_CHANGES = ChangePackage.CHANGE_DESCRIPTION__OBJECT_CHANGES; + + /** + * The feature id for the 'Objects To Detach' reference list. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY__OBJECTS_TO_DETACH = ChangePackage.CHANGE_DESCRIPTION__OBJECTS_TO_DETACH; + + /** + * The feature id for the 'Objects To Attach' containment reference list. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY__OBJECTS_TO_ATTACH = ChangePackage.CHANGE_DESCRIPTION__OBJECTS_TO_ATTACH; + + /** + * The feature id for the 'Resource Changes' containment reference list. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY__RESOURCE_CHANGES = ChangePackage.CHANGE_DESCRIPTION__RESOURCE_CHANGES; + + /** + * The feature id for the 'EData Graph' reference. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY__EDATA_GRAPH = ChangePackage.CHANGE_DESCRIPTION_FEATURE_COUNT + 0; + +//TODO T-153 +// /** +// * The feature id for the 'EData Graph' reference. +// * +// * +// * *handcrafted but could be generated +// * @ordered +// */ +// int CHANGE_SUMMARY__EDATA_OBJECT = ChangePackage.CHANGE_DESCRIPTION_FEATURE_COUNT + 1; + + /** + * The number of structural features of the 'Change Summary' class. + * + * + * @generated NOT + * @ordered + */ +//TODO T-153 + int CHANGE_SUMMARY_FEATURE_COUNT = ChangePackage.CHANGE_DESCRIPTION_FEATURE_COUNT + 1; + //int CHANGE_SUMMARY_FEATURE_COUNT = ChangePackage.CHANGE_DESCRIPTION_FEATURE_COUNT + 2; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.ChangeSummarySettingImpl Change Summary Setting}' class. + * + * + * @see org.apache.tuscany.sdo.impl.ChangeSummarySettingImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getChangeSummarySetting() + * @generated + */ + int CHANGE_SUMMARY_SETTING = 1; + + /** + * The feature id for the 'Feature Name' attribute. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING__FEATURE_NAME = ChangePackage.FEATURE_CHANGE__FEATURE_NAME; + + /** + * The feature id for the 'Data Value' attribute. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING__DATA_VALUE = ChangePackage.FEATURE_CHANGE__DATA_VALUE; + + /** + * The feature id for the 'Set' attribute. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING__SET = ChangePackage.FEATURE_CHANGE__SET; + + /** + * The feature id for the 'Value' attribute. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING__VALUE = ChangePackage.FEATURE_CHANGE__VALUE; + + /** + * The feature id for the 'Feature' reference. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING__FEATURE = ChangePackage.FEATURE_CHANGE__FEATURE; + + /** + * The feature id for the 'Reference Value' reference. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING__REFERENCE_VALUE = ChangePackage.FEATURE_CHANGE__REFERENCE_VALUE; + + /** + * The feature id for the 'List Changes' containment reference list. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING__LIST_CHANGES = ChangePackage.FEATURE_CHANGE__LIST_CHANGES; + + /** + * The number of structural features of the 'Change Summary Setting' class. + * + * + * @generated + * @ordered + */ + int CHANGE_SUMMARY_SETTING_FEATURE_COUNT = ChangePackage.FEATURE_CHANGE_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Resource Set' attribute. + * + * + * @generated + * @ordered + */ + int DATA_GRAPH__RESOURCE_SET = EcorePackage.EOBJECT_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Root Resource' attribute. + * + * + * @generated + * @ordered + */ + int DATA_GRAPH__ROOT_RESOURCE = EcorePackage.EOBJECT_FEATURE_COUNT + 1; + + /** + * The feature id for the 'EChange Summary' reference. + * + * + * @generated + * @ordered + */ + int DATA_GRAPH__ECHANGE_SUMMARY = EcorePackage.EOBJECT_FEATURE_COUNT + 2; + + /** + * The feature id for the 'ERoot Object' reference. + * + * + * @generated + * @ordered + */ + int DATA_GRAPH__EROOT_OBJECT = EcorePackage.EOBJECT_FEATURE_COUNT + 3; + + /** + * The number of structural features of the 'Data Graph' class. + * + * + * @generated + * @ordered + */ + int DATA_GRAPH_FEATURE_COUNT = EcorePackage.EOBJECT_FEATURE_COUNT + 4; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.DataObjectImpl Data Object}' class. + * + * + * @see org.apache.tuscany.sdo.impl.DataObjectImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getDataObject() + * @generated + */ + int DATA_OBJECT = 3; + + /** + * The meta object id for the '{@link commonj.sdo.Property Property}' class. + * + * + * @see commonj.sdo.Property + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getProperty() + * @generated + */ + int PROPERTY = 4; + + /** + * The meta object id for the '{@link commonj.sdo.Sequence Sequence}' class. + * + * + * @see commonj.sdo.Sequence + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getSequence() + * @generated + */ + int SEQUENCE = 5; + + /** + * The meta object id for the '{@link commonj.sdo.Type Type}' class. + * + * + * @see commonj.sdo.Type + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getType() + * @generated + */ + int TYPE = 6; + + /** + * The number of structural features of the 'Data Object' class. + * + * + * @generated + * @ordered + */ + int DATA_OBJECT_FEATURE_COUNT = 0; + + /** + * The number of structural features of the 'Property' class. + * + * + * @generated + * @ordered + */ + int PROPERTY_FEATURE_COUNT = 0; + + /** + * The number of structural features of the 'Sequence' class. + * + * + * @generated + * @ordered + */ + int SEQUENCE_FEATURE_COUNT = 0; + + /** + * The number of structural features of the 'Type' class. + * + * + * @generated + * @ordered + */ + int TYPE_FEATURE_COUNT = 0; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.AnyTypeDataObjectImpl Any Type Data Object}' class. + * + * + * @see org.apache.tuscany.sdo.impl.AnyTypeDataObjectImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getAnyTypeDataObject() + * @generated + */ + int ANY_TYPE_DATA_OBJECT = 7; + + /** + * The feature id for the 'Mixed' attribute list. + * + * + * @generated + * @ordered + */ + int ANY_TYPE_DATA_OBJECT__MIXED = DATA_OBJECT_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Any' attribute list. + * + * + * @generated + * @ordered + */ + int ANY_TYPE_DATA_OBJECT__ANY = DATA_OBJECT_FEATURE_COUNT + 1; + + /** + * The feature id for the 'Any Attribute' attribute list. + * + * + * @generated + * @ordered + */ + int ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE = DATA_OBJECT_FEATURE_COUNT + 2; + + /** + * The number of structural features of the 'Any Type Data Object' class. + * + * + * @generated + * @ordered + */ + int ANY_TYPE_DATA_OBJECT_FEATURE_COUNT = DATA_OBJECT_FEATURE_COUNT + 3; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.SimpleAnyTypeDataObjectImpl Simple Any Type Data Object}' class. + * + * + * @see org.apache.tuscany.sdo.impl.SimpleAnyTypeDataObjectImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getSimpleAnyTypeDataObject() + * @generated + */ + int SIMPLE_ANY_TYPE_DATA_OBJECT = 8; + + /** + * The feature id for the 'Mixed' attribute list. + * + * + * @generated + * @ordered + */ + int SIMPLE_ANY_TYPE_DATA_OBJECT__MIXED = ANY_TYPE_DATA_OBJECT__MIXED; + + /** + * The feature id for the 'Any' attribute list. + * + * + * @generated + * @ordered + */ + int SIMPLE_ANY_TYPE_DATA_OBJECT__ANY = ANY_TYPE_DATA_OBJECT__ANY; + + /** + * The feature id for the 'Any Attribute' attribute list. + * + * + * @generated + * @ordered + */ + int SIMPLE_ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE = ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE; + + /** + * The feature id for the 'Raw Value' attribute. + * + * + * @generated + * @ordered + */ + int SIMPLE_ANY_TYPE_DATA_OBJECT__RAW_VALUE = ANY_TYPE_DATA_OBJECT_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Value' attribute. + * + * + * @generated + * @ordered + */ + int SIMPLE_ANY_TYPE_DATA_OBJECT__VALUE = ANY_TYPE_DATA_OBJECT_FEATURE_COUNT + 1; + + /** + * The feature id for the 'Instance Type' reference. + * + * + * @generated + * @ordered + */ + int SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE = ANY_TYPE_DATA_OBJECT_FEATURE_COUNT + 2; + + /** + * The number of structural features of the 'Simple Any Type Data Object' class. + * + * + * @generated + * @ordered + */ + int SIMPLE_ANY_TYPE_DATA_OBJECT_FEATURE_COUNT = ANY_TYPE_DATA_OBJECT_FEATURE_COUNT + 3; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.ClassImpl Class}' class. + * + * + * @see org.apache.tuscany.sdo.impl.ClassImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getClass_() + * @generated + */ + int CLASS = 9; + + /** + * The feature id for the 'EAnnotations' containment reference list. + * + * + * @generated + * @ordered + */ + int CLASS__EANNOTATIONS = EcorePackage.ECLASS__EANNOTATIONS; + + /** + * The feature id for the 'Name' attribute. + * + * + * @generated + * @ordered + */ + int CLASS__NAME = EcorePackage.ECLASS__NAME; + + /** + * The feature id for the 'Instance Class Name' attribute. + * + * + * @generated + * @ordered + */ + int CLASS__INSTANCE_CLASS_NAME = EcorePackage.ECLASS__INSTANCE_CLASS_NAME; + + /** + * The feature id for the 'Instance Class' attribute. + * + * + * @generated + * @ordered + */ + int CLASS__INSTANCE_CLASS = EcorePackage.ECLASS__INSTANCE_CLASS; + + /** + * The feature id for the 'Default Value' attribute. + * + * + * @generated + * @ordered + */ + int CLASS__DEFAULT_VALUE = EcorePackage.ECLASS__DEFAULT_VALUE; + + /** + * The feature id for the 'EPackage' container reference. + * + * + * @generated + * @ordered + */ + int CLASS__EPACKAGE = EcorePackage.ECLASS__EPACKAGE; + + /** + * The feature id for the 'Abstract' attribute. + * + * + * @generated + * @ordered + */ + int CLASS__ABSTRACT = EcorePackage.ECLASS__ABSTRACT; + + /** + * The feature id for the 'Interface' attribute. + * + * + * @generated + * @ordered + */ + int CLASS__INTERFACE = EcorePackage.ECLASS__INTERFACE; + + /** + * The feature id for the 'ESuper Types' reference list. + * + * + * @generated + * @ordered + */ + int CLASS__ESUPER_TYPES = EcorePackage.ECLASS__ESUPER_TYPES; + + /** + * The feature id for the 'EOperations' containment reference list. + * + * + * @generated + * @ordered + */ + int CLASS__EOPERATIONS = EcorePackage.ECLASS__EOPERATIONS; + + /** + * The feature id for the 'EAll Attributes' reference list. + * + * + * @generated + * @ordered + */ + int CLASS__EALL_ATTRIBUTES = EcorePackage.ECLASS__EALL_ATTRIBUTES; + + /** + * The feature id for the 'EAll References' reference list. + * + * + * @generated + * @ordered + */ + int CLASS__EALL_REFERENCES = EcorePackage.ECLASS__EALL_REFERENCES; + + /** + * The feature id for the 'EReferences' reference list. + * + * + * @generated + * @ordered + */ + int CLASS__EREFERENCES = EcorePackage.ECLASS__EREFERENCES; + + /** + * The feature id for the 'EAttributes' reference list. + * + * + * @generated + * @ordered + */ + int CLASS__EATTRIBUTES = EcorePackage.ECLASS__EATTRIBUTES; + + /** + * The feature id for the 'EAll Containments' reference list. + * + * + * @generated + * @ordered + */ + int CLASS__EALL_CONTAINMENTS = EcorePackage.ECLASS__EALL_CONTAINMENTS; + + /** + * The feature id for the 'EAll Operations' reference list. + * + * + * @generated + * @ordered + */ + int CLASS__EALL_OPERATIONS = EcorePackage.ECLASS__EALL_OPERATIONS; + + /** + * The feature id for the 'EAll Structural Features' reference list. + * + * + * @generated + * @ordered + */ + int CLASS__EALL_STRUCTURAL_FEATURES = EcorePackage.ECLASS__EALL_STRUCTURAL_FEATURES; + + /** + * The feature id for the 'EAll Super Types' reference list. + * + * + * @generated + * @ordered + */ + int CLASS__EALL_SUPER_TYPES = EcorePackage.ECLASS__EALL_SUPER_TYPES; + + /** + * The feature id for the 'EID Attribute' reference. + * + * + * @generated + * @ordered + */ + int CLASS__EID_ATTRIBUTE = EcorePackage.ECLASS__EID_ATTRIBUTE; + + /** + * The feature id for the 'EStructural Features' containment reference list. + * + * + * @generated + * @ordered + */ + int CLASS__ESTRUCTURAL_FEATURES = EcorePackage.ECLASS__ESTRUCTURAL_FEATURES; + + /** + * The number of structural features of the 'Class' class. + * + * + * @generated + * @ordered + */ + int CLASS_FEATURE_COUNT = EcorePackage.ECLASS_FEATURE_COUNT + 0; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.DataTypeImpl Data Type}' class. + * + * + * @see org.apache.tuscany.sdo.impl.DataTypeImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getDataType() + * @generated + */ + int DATA_TYPE = 10; + + /** + * The feature id for the 'EAnnotations' containment reference list. + * + * + * @generated + * @ordered + */ + int DATA_TYPE__EANNOTATIONS = EcorePackage.EDATA_TYPE__EANNOTATIONS; + + /** + * The feature id for the 'Name' attribute. + * + * + * @generated + * @ordered + */ + int DATA_TYPE__NAME = EcorePackage.EDATA_TYPE__NAME; + + /** + * The feature id for the 'Instance Class Name' attribute. + * + * + * @generated + * @ordered + */ + int DATA_TYPE__INSTANCE_CLASS_NAME = EcorePackage.EDATA_TYPE__INSTANCE_CLASS_NAME; + + /** + * The feature id for the 'Instance Class' attribute. + * + * + * @generated + * @ordered + */ + int DATA_TYPE__INSTANCE_CLASS = EcorePackage.EDATA_TYPE__INSTANCE_CLASS; + + /** + * The feature id for the 'Default Value' attribute. + * + * + * @generated + * @ordered + */ + int DATA_TYPE__DEFAULT_VALUE = EcorePackage.EDATA_TYPE__DEFAULT_VALUE; + + /** + * The feature id for the 'EPackage' container reference. + * + * + * @generated + * @ordered + */ + int DATA_TYPE__EPACKAGE = EcorePackage.EDATA_TYPE__EPACKAGE; + + /** + * The feature id for the 'Serializable' attribute. + * + * + * @generated + * @ordered + */ + int DATA_TYPE__SERIALIZABLE = EcorePackage.EDATA_TYPE__SERIALIZABLE; + + /** + * The number of structural features of the 'Data Type' class. + * + * + * @generated + * @ordered + */ + int DATA_TYPE_FEATURE_COUNT = EcorePackage.EDATA_TYPE_FEATURE_COUNT + 0; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.AttributeImpl Attribute}' class. + * + * + * @see org.apache.tuscany.sdo.impl.AttributeImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getAttribute() + * @generated + */ + int ATTRIBUTE = 11; + + /** + * The feature id for the 'EAnnotations' containment reference list. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__EANNOTATIONS = EcorePackage.EATTRIBUTE__EANNOTATIONS; + + /** + * The feature id for the 'Name' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__NAME = EcorePackage.EATTRIBUTE__NAME; + + /** + * The feature id for the 'Ordered' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__ORDERED = EcorePackage.EATTRIBUTE__ORDERED; + + /** + * The feature id for the 'Unique' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__UNIQUE = EcorePackage.EATTRIBUTE__UNIQUE; + + /** + * The feature id for the 'Lower Bound' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__LOWER_BOUND = EcorePackage.EATTRIBUTE__LOWER_BOUND; + + /** + * The feature id for the 'Upper Bound' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__UPPER_BOUND = EcorePackage.EATTRIBUTE__UPPER_BOUND; + + /** + * The feature id for the 'Many' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__MANY = EcorePackage.EATTRIBUTE__MANY; + + /** + * The feature id for the 'Required' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__REQUIRED = EcorePackage.EATTRIBUTE__REQUIRED; + + /** + * The feature id for the 'EType' reference. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__ETYPE = EcorePackage.EATTRIBUTE__ETYPE; + + /** + * The feature id for the 'Changeable' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__CHANGEABLE = EcorePackage.EATTRIBUTE__CHANGEABLE; + + /** + * The feature id for the 'Volatile' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__VOLATILE = EcorePackage.EATTRIBUTE__VOLATILE; + + /** + * The feature id for the 'Transient' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__TRANSIENT = EcorePackage.EATTRIBUTE__TRANSIENT; + + /** + * The feature id for the 'Default Value Literal' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__DEFAULT_VALUE_LITERAL = EcorePackage.EATTRIBUTE__DEFAULT_VALUE_LITERAL; + + /** + * The feature id for the 'Default Value' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__DEFAULT_VALUE = EcorePackage.EATTRIBUTE__DEFAULT_VALUE; + + /** + * The feature id for the 'Unsettable' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__UNSETTABLE = EcorePackage.EATTRIBUTE__UNSETTABLE; + + /** + * The feature id for the 'Derived' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__DERIVED = EcorePackage.EATTRIBUTE__DERIVED; + + /** + * The feature id for the 'EContaining Class' container reference. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__ECONTAINING_CLASS = EcorePackage.EATTRIBUTE__ECONTAINING_CLASS; + + /** + * The feature id for the 'ID' attribute. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__ID = EcorePackage.EATTRIBUTE__ID; + + /** + * The feature id for the 'EAttribute Type' reference. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE__EATTRIBUTE_TYPE = EcorePackage.EATTRIBUTE__EATTRIBUTE_TYPE; + + /** + * The number of structural features of the 'Attribute' class. + * + * + * @generated + * @ordered + */ + int ATTRIBUTE_FEATURE_COUNT = EcorePackage.EATTRIBUTE_FEATURE_COUNT + 0; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.ReferenceImpl Reference}' class. + * + * + * @see org.apache.tuscany.sdo.impl.ReferenceImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getReference() + * @generated + */ + int REFERENCE = 12; + + /** + * The feature id for the 'EAnnotations' containment reference list. + * + * + * @generated + * @ordered + */ + int REFERENCE__EANNOTATIONS = EcorePackage.EREFERENCE__EANNOTATIONS; + + /** + * The feature id for the 'Name' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__NAME = EcorePackage.EREFERENCE__NAME; + + /** + * The feature id for the 'Ordered' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__ORDERED = EcorePackage.EREFERENCE__ORDERED; + + /** + * The feature id for the 'Unique' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__UNIQUE = EcorePackage.EREFERENCE__UNIQUE; + + /** + * The feature id for the 'Lower Bound' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__LOWER_BOUND = EcorePackage.EREFERENCE__LOWER_BOUND; + + /** + * The feature id for the 'Upper Bound' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__UPPER_BOUND = EcorePackage.EREFERENCE__UPPER_BOUND; + + /** + * The feature id for the 'Many' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__MANY = EcorePackage.EREFERENCE__MANY; + + /** + * The feature id for the 'Required' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__REQUIRED = EcorePackage.EREFERENCE__REQUIRED; + + /** + * The feature id for the 'EType' reference. + * + * + * @generated + * @ordered + */ + int REFERENCE__ETYPE = EcorePackage.EREFERENCE__ETYPE; + + /** + * The feature id for the 'Changeable' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__CHANGEABLE = EcorePackage.EREFERENCE__CHANGEABLE; + + /** + * The feature id for the 'Volatile' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__VOLATILE = EcorePackage.EREFERENCE__VOLATILE; + + /** + * The feature id for the 'Transient' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__TRANSIENT = EcorePackage.EREFERENCE__TRANSIENT; + + /** + * The feature id for the 'Default Value Literal' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__DEFAULT_VALUE_LITERAL = EcorePackage.EREFERENCE__DEFAULT_VALUE_LITERAL; + + /** + * The feature id for the 'Default Value' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__DEFAULT_VALUE = EcorePackage.EREFERENCE__DEFAULT_VALUE; + + /** + * The feature id for the 'Unsettable' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__UNSETTABLE = EcorePackage.EREFERENCE__UNSETTABLE; + + /** + * The feature id for the 'Derived' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__DERIVED = EcorePackage.EREFERENCE__DERIVED; + + /** + * The feature id for the 'EContaining Class' container reference. + * + * + * @generated + * @ordered + */ + int REFERENCE__ECONTAINING_CLASS = EcorePackage.EREFERENCE__ECONTAINING_CLASS; + + /** + * The feature id for the 'Containment' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__CONTAINMENT = EcorePackage.EREFERENCE__CONTAINMENT; + + /** + * The feature id for the 'Container' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__CONTAINER = EcorePackage.EREFERENCE__CONTAINER; + + /** + * The feature id for the 'Resolve Proxies' attribute. + * + * + * @generated + * @ordered + */ + int REFERENCE__RESOLVE_PROXIES = EcorePackage.EREFERENCE__RESOLVE_PROXIES; + + /** + * The feature id for the 'EOpposite' reference. + * + * + * @generated + * @ordered + */ + int REFERENCE__EOPPOSITE = EcorePackage.EREFERENCE__EOPPOSITE; + + /** + * The feature id for the 'EReference Type' reference. + * + * + * @generated + * @ordered + */ + int REFERENCE__EREFERENCE_TYPE = EcorePackage.EREFERENCE__EREFERENCE_TYPE; + + /** + * The number of structural features of the 'Reference' class. + * + * + * @generated + * @ordered + */ + int REFERENCE_FEATURE_COUNT = EcorePackage.EREFERENCE_FEATURE_COUNT + 0; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.EnumImpl Enum}' class. + * + * + * @see org.apache.tuscany.sdo.impl.EnumImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getEnum() + * @generated + */ + int ENUM = 13; + + /** + * The feature id for the 'EAnnotations' containment reference list. + * + * + * @generated + * @ordered + */ + int ENUM__EANNOTATIONS = EcorePackage.EENUM__EANNOTATIONS; + + /** + * The feature id for the 'Name' attribute. + * + * + * @generated + * @ordered + */ + int ENUM__NAME = EcorePackage.EENUM__NAME; + + /** + * The feature id for the 'Instance Class Name' attribute. + * + * + * @generated + * @ordered + */ + int ENUM__INSTANCE_CLASS_NAME = EcorePackage.EENUM__INSTANCE_CLASS_NAME; + + /** + * The feature id for the 'Instance Class' attribute. + * + * + * @generated + * @ordered + */ + int ENUM__INSTANCE_CLASS = EcorePackage.EENUM__INSTANCE_CLASS; + + /** + * The feature id for the 'Default Value' attribute. + * + * + * @generated + * @ordered + */ + int ENUM__DEFAULT_VALUE = EcorePackage.EENUM__DEFAULT_VALUE; + + /** + * The feature id for the 'EPackage' container reference. + * + * + * @generated + * @ordered + */ + int ENUM__EPACKAGE = EcorePackage.EENUM__EPACKAGE; + + /** + * The feature id for the 'Serializable' attribute. + * + * + * @generated + * @ordered + */ + int ENUM__SERIALIZABLE = EcorePackage.EENUM__SERIALIZABLE; + + /** + * The feature id for the 'ELiterals' containment reference list. + * + * + * @generated + * @ordered + */ + int ENUM__ELITERALS = EcorePackage.EENUM__ELITERALS; + + /** + * The number of structural features of the 'Enum' class. + * + * + * @generated + * @ordered + */ + int ENUM_FEATURE_COUNT = EcorePackage.EENUM_FEATURE_COUNT + 0; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.DynamicDataObjectImpl Dynamic Data Object}' class. + * + * + * @see org.apache.tuscany.sdo.impl.DynamicDataObjectImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getDynamicDataObject() + * @generated + */ + int DYNAMIC_DATA_OBJECT = 14; + + /** + * The number of structural features of the 'Dynamic Data Object' class. + * + * + * @generated + * @ordered + */ + int DYNAMIC_DATA_OBJECT_FEATURE_COUNT = DATA_OBJECT_FEATURE_COUNT + 0; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.StoreDataObjectImpl Store Data Object}' class. + * + * + * @see org.apache.tuscany.sdo.impl.StoreDataObjectImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getStoreDataObject() + * @generated + */ + int STORE_DATA_OBJECT = 15; + + /** + * The number of structural features of the 'Store Data Object' class. + * + * + * @generated + * @ordered + */ + int STORE_DATA_OBJECT_FEATURE_COUNT = DATA_OBJECT_FEATURE_COUNT + 0; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.DynamicStoreDataObjectImpl Dynamic Store Data Object}' class. + * + * + * @see org.apache.tuscany.sdo.impl.DynamicStoreDataObjectImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getDynamicStoreDataObject() + * @generated + */ + int DYNAMIC_STORE_DATA_OBJECT = 16; + + /** + * The number of structural features of the 'Dynamic Store Data Object' class. + * + * + * @generated + * @ordered + */ + int DYNAMIC_STORE_DATA_OBJECT_FEATURE_COUNT = STORE_DATA_OBJECT_FEATURE_COUNT + 0; + + /** + * The meta object id for the '{@link org.apache.tuscany.sdo.impl.ExtensibleDataObjectImpl Extensible Data Object}' class. + * + * + * @see org.apache.tuscany.sdo.impl.ExtensibleDataObjectImpl + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getExtensibleDataObject() + * @generated + */ + int EXTENSIBLE_DATA_OBJECT = 17; + + /** + * The number of structural features of the 'Extensible Data Object' class. + * + * + * @generated + * @ordered + */ + int EXTENSIBLE_DATA_OBJECT_FEATURE_COUNT = DATA_OBJECT_FEATURE_COUNT + 0; + + /** + * The meta object id for the 'EJava List' data type. + * + * + * @see java.util.List + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getEJavaList() + * @generated + */ + int EJAVA_LIST = 18; + + /** + * The meta object id for the 'EObject Stream Exception' data type. + * + * + * @see java.io.ObjectStreamException + * @see org.apache.tuscany.sdo.impl.SDOPackageImpl#getEObjectStreamException() + * @generated + */ + int EOBJECT_STREAM_EXCEPTION = 19; + + + /** + * Returns the meta object for class '{@link commonj.sdo.ChangeSummary Change Summary}'. + * + * + * @return the meta object for class 'Change Summary'. + * @see commonj.sdo.ChangeSummary + * @model instanceClass="commonj.sdo.ChangeSummary" + * @generated + */ + EClass getChangeSummary(); + + /** + * Returns the meta object for the reference '{@link commonj.sdo.ChangeSummary#getEDataGraph EData Graph}'. + * + * + * @return the meta object for the reference 'EData Graph'. + * @see commonj.sdo.ChangeSummary#getEDataGraph() + * @see #getChangeSummary() + * @generated + */ + EReference getChangeSummary_EDataGraph(); + +// TODO T-153 +// /** +// * Returns the meta object for the reference '{@link commonj.sdo.ChangeSummary#getEDataGraph EData Graph}'. +// * +// * +// * @return the meta object for the reference 'EData Graph'. +// * @see commonj.sdo.ChangeSummary#getEDataGraph() +// * @see #getChangeSummary() +// * *handcrafted but could be generated +// */ +// EReference getChangeSummary_EDataObject(); + + + /** + * Returns the meta object for class '{@link commonj.sdo.ChangeSummary.Setting Change Summary Setting}'. + * + * + * @return the meta object for class 'Change Summary Setting'. + * @see commonj.sdo.ChangeSummary.Setting + * @model instanceClass="commonj.sdo.ChangeSummary$Setting" + * @generated + */ + EClass getChangeSummarySetting(); + + /** + * Returns the meta object for class '{@link commonj.sdo.DataGraph Data Graph}'. + * + * + * @return the meta object for class 'Data Graph'. + * @see commonj.sdo.DataGraph + * @model instanceClass="commonj.sdo.DataGraph" + * @generated + */ + EClass getDataGraph(); + + /** + * Returns the meta object for the attribute '{@link commonj.sdo.DataGraph#getResourceSet Resource Set}'. + * + * + * @return the meta object for the attribute 'Resource Set'. + * @see commonj.sdo.DataGraph#getResourceSet() + * @see #getDataGraph() + * @generated + */ + EAttribute getDataGraph_ResourceSet(); + + /** + * Returns the meta object for the attribute '{@link commonj.sdo.DataGraph#getRootResource Root Resource}'. + * + * + * @return the meta object for the attribute 'Root Resource'. + * @see commonj.sdo.DataGraph#getRootResource() + * @see #getDataGraph() + * @generated + */ + EAttribute getDataGraph_RootResource(); + + /** + * Returns the meta object for the reference '{@link commonj.sdo.DataGraph#getEChangeSummary EChange Summary}'. + * + * + * @return the meta object for the reference 'EChange Summary'. + * @see commonj.sdo.DataGraph#getEChangeSummary() + * @see #getDataGraph() + * @generated + */ + EReference getDataGraph_EChangeSummary(); + + /** + * Returns the meta object for the reference '{@link commonj.sdo.DataGraph#getERootObject ERoot Object}'. + * + * + * @return the meta object for the reference 'ERoot Object'. + * @see commonj.sdo.DataGraph#getERootObject() + * @see #getDataGraph() + * @generated + */ + EReference getDataGraph_ERootObject(); + + /** + * Returns the meta object for class '{@link commonj.sdo.DataObject Data Object}'. + * + * + * @return the meta object for class 'Data Object'. + * @see commonj.sdo.DataObject + * @model instanceClass="commonj.sdo.DataObject" + * @generated + */ + EClass getDataObject(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Property Property}'. + * + * + * @return the meta object for class 'Property'. + * @see commonj.sdo.Property + * @model instanceClass="commonj.sdo.Property" + * @generated + */ + EClass getProperty(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Sequence Sequence}'. + * + * + * @return the meta object for class 'Sequence'. + * @see commonj.sdo.Sequence + * @model instanceClass="commonj.sdo.Sequence" + * @generated + */ + EClass getSequence(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Type Type}'. + * + * + * @return the meta object for class 'Type'. + * @see commonj.sdo.Type + * @model instanceClass="commonj.sdo.Type" + * @generated + */ + EClass getType(); + + /** + * Returns the meta object for class '{@link org.apache.tuscany.sdo.AnyTypeDataObject Any Type Data Object}'. + * + * + * @return the meta object for class 'Any Type Data Object'. + * @see org.apache.tuscany.sdo.AnyTypeDataObject + * @generated + */ + EClass getAnyTypeDataObject(); + + /** + * Returns the meta object for class '{@link org.apache.tuscany.sdo.SimpleAnyTypeDataObject Simple Any Type Data Object}'. + * + * + * @return the meta object for class 'Simple Any Type Data Object'. + * @see org.apache.tuscany.sdo.SimpleAnyTypeDataObject + * @generated + */ + EClass getSimpleAnyTypeDataObject(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Type Class}'. + * + * + * @return the meta object for class 'Class'. + * @see commonj.sdo.Type + * @model instanceClass="commonj.sdo.Type" + * @generated + */ + EClass getClass_(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Type Data Type}'. + * + * + * @return the meta object for class 'Data Type'. + * @see commonj.sdo.Type + * @model instanceClass="commonj.sdo.Type" + * @generated + */ + EClass getDataType(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Property Attribute}'. + * + * + * @return the meta object for class 'Attribute'. + * @see commonj.sdo.Property + * @model instanceClass="commonj.sdo.Property" + * @generated + */ + EClass getAttribute(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Property Reference}'. + * + * + * @return the meta object for class 'Reference'. + * @see commonj.sdo.Property + * @model instanceClass="commonj.sdo.Property" + * @generated + */ + EClass getReference(); + + /** + * Returns the meta object for class '{@link commonj.sdo.Type Enum}'. + * + * + * @return the meta object for class 'Enum'. + * @see commonj.sdo.Type + * @model instanceClass="commonj.sdo.Type" + * @generated + */ + EClass getEnum(); + + /** + * Returns the meta object for class '{@link commonj.sdo.DataObject Dynamic Data Object}'. + * + * + * @return the meta object for class 'Dynamic Data Object'. + * @see commonj.sdo.DataObject + * @model instanceClass="commonj.sdo.DataObject" + * @generated + */ + EClass getDynamicDataObject(); + + /** + * Returns the meta object for class '{@link commonj.sdo.DataObject Store Data Object}'. + * + * + * @return the meta object for class 'Store Data Object'. + * @see commonj.sdo.DataObject + * @model instanceClass="commonj.sdo.DataObject" + * @generated + */ + EClass getStoreDataObject(); + + /** + * Returns the meta object for class '{@link commonj.sdo.DataObject Dynamic Store Data Object}'. + * + * + * @return the meta object for class 'Dynamic Store Data Object'. + * @see commonj.sdo.DataObject + * @model instanceClass="commonj.sdo.DataObject" + * @generated + */ + EClass getDynamicStoreDataObject(); + + /** + * Returns the meta object for class '{@link commonj.sdo.DataObject Extensible Data Object}'. + * + * + * @return the meta object for class 'Extensible Data Object'. + * @see commonj.sdo.DataObject + * @model instanceClass="commonj.sdo.DataObject" + * @generated + */ + EClass getExtensibleDataObject(); + + /** + * Returns the meta object for data type '{@link java.util.List EJava List}'. + * + * + * @return the meta object for data type 'EJava List'. + * @see java.util.List + * @model instanceClass="java.util.List" serializable="false" + * @generated + */ + EDataType getEJavaList(); + + /** + * Returns the meta object for data type '{@link java.io.ObjectStreamException EObject Stream Exception}'. + * + * + * @return the meta object for data type 'EObject Stream Exception'. + * @see java.io.ObjectStreamException + * @model instanceClass="java.io.ObjectStreamException" serializable="false" + * @generated + */ + EDataType getEObjectStreamException(); + + /** + * Returns the factory that creates the instances of the model. + * + * + * @return the factory that creates the instances of the model. + * @generated + */ + SDOFactory getSDOFactory(); + +} //SDOPackage diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/SDOTypeVisitor.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/SDOTypeVisitor.java new file mode 100644 index 0000000000..5d3640100c --- /dev/null +++ b/sandbox/kgoodson/events/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/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/SimpleAnyTypeDataObject.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/SimpleAnyTypeDataObject.java new file mode 100644 index 0000000000..93ff2ebf14 --- /dev/null +++ b/sandbox/kgoodson/events/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; + +/** + * + * A representation of the model object 'Simple Any Type Data Object'. + * + * + * + * @see org.apache.tuscany.sdo.SDOPackage#getSimpleAnyTypeDataObject() + * @model extendedMetaData="kind='simple'" + * @generated + */ +public interface SimpleAnyTypeDataObject extends AnyTypeDataObject, SimpleAnyType { +} // SimpleAnyTypeDataObject diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/api/ListenerBase.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/api/ListenerBase.java new file mode 100644 index 0000000000..f523a587c0 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/api/ListenerBase.java @@ -0,0 +1,13 @@ +package org.apache.tuscany.sdo.api; + +import org.apache.tuscany.sdo.impl.EventImpl; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.impl.AdapterImpl; + +public abstract class ListenerBase extends AdapterImpl implements EventListener { + + public void notifyChanged(Notification msg) { + Event e = new EventImpl(msg); + eventNotification(e); + } +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGenerator.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGenerator.java new file mode 100644 index 0000000000..3fe2cd952e --- /dev/null +++ b/sandbox/kgoodson/events/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/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/codegen/GenerationException.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/codegen/GenerationException.java new file mode 100644 index 0000000000..3d645be1da --- /dev/null +++ b/sandbox/kgoodson/events/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/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGenerator.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGenerator.java new file mode 100644 index 0000000000..dc88a0d60d --- /dev/null +++ b/sandbox/kgoodson/events/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 1)) + { + if (groupName == null) + { + groupName = name + "Group"; + } + eStructuralFeature = + createFeature + (eClass, + groupName, + ecorePackage.getEFeatureMapEntry(), + xsdParticle, + effectiveOccurrence.minOccurs, + effectiveOccurrence.maxOccurs); + + eStructuralFeature.setChangeable(true); + + extendedMetaData.setFeatureKind(eStructuralFeature, ExtendedMetaData.GROUP_FEATURE); + extendedMetaData.setName(eStructuralFeature, xsdElementDeclaration.getName() + ":group"); + + if (group != null) + { + extendedMetaData.setGroup(eStructuralFeature, group); + eStructuralFeature.setDerived(true); + eStructuralFeature.setTransient(true); + eStructuralFeature.setVolatile(true); + } + else if (isMixed) + { + eStructuralFeature.setDerived(true); + eStructuralFeature.setTransient(true); + eStructuralFeature.setVolatile(true); + } + else if (globalGroup != null) + { + extendedMetaData.setGroup(eStructuralFeature, globalGroup); + eStructuralFeature.setDerived(true); + eStructuralFeature.setTransient(true); + eStructuralFeature.setVolatile(true); + } + + group = eStructuralFeature; + } + + eStructuralFeature = + createFeature(eClass, xsdElementDeclaration, name, xsdParticle, effectiveOccurrence.minOccurs, effectiveOccurrence.maxOccurs); + // 51210 + // particleMap.put(xsdParticle, eStructuralFeature); + + // If the group is turned off, we better make the feature changeable. + // + if (!eStructuralFeature.isChangeable() && group == null && getEcoreAttribute(xsdParticle, xsdElementDeclaration, "changeable") == null) + { + eStructuralFeature.setChangeable(true); + } + } + } + + if (eStructuralFeature != null) + { + if (group != null) + { + extendedMetaData.setGroup(eStructuralFeature, group); + eStructuralFeature.setDerived(true); + eStructuralFeature.setTransient(true); + eStructuralFeature.setVolatile(true); + } + else if (isMixed) + { + eStructuralFeature.setDerived(true); + eStructuralFeature.setTransient(true); + eStructuralFeature.setVolatile(true); + } + else if (globalGroup != null) + { + extendedMetaData.setGroup(eStructuralFeature, globalGroup); + eStructuralFeature.setDerived(true); + eStructuralFeature.setTransient(true); + eStructuralFeature.setVolatile(true); + } + } + } + + // 51210 + // contentParticle = computeParticleConstraints(eClass, particleMap, (XSDParticle)xsdComplexTypeDefinition.getContent()); + } + } + + // 51210 + // EAnnotation attributeParticle = null; + // if (isRestriction) + // { + // attributeParticle = ecoreFactory.createEAnnotation(); + // attributeParticle.setSource("attributes"); + // } + + XSDWildcard baseXSDWildcard = null; + Collection baseAttributeUses = Collections.EMPTY_LIST; + Map baseAttributeURIs = new HashMap(); + if (baseTypeDefinition instanceof XSDComplexTypeDefinition) + { + XSDComplexTypeDefinition complexBaseTypeDefinition = (XSDComplexTypeDefinition)baseTypeDefinition; + baseXSDWildcard = complexBaseTypeDefinition.getAttributeWildcard(); + baseAttributeUses = complexBaseTypeDefinition.getAttributeUses(); + for (Iterator i = baseAttributeUses.iterator(); i.hasNext(); ) + { + XSDAttributeUse xsdAttributeUse = (XSDAttributeUse)i.next(); + baseAttributeURIs.put(xsdAttributeUse.getAttributeDeclaration().getURI(), xsdAttributeUse); + } + } + + for (Iterator i = getAttributeUses(xsdComplexTypeDefinition).iterator(); i.hasNext(); ) + { + XSDAttributeUse xsdAttributeUse = (XSDAttributeUse)i.next(); + XSDAttributeDeclaration xsdAttributeDeclaration = xsdAttributeUse.getAttributeDeclaration(); + if (baseAttributeURIs.remove(xsdAttributeDeclaration.getURI()) == null) + { + String name = getEcoreAttribute(xsdAttributeUse, "name"); + if (name == null) + { + name = getEcoreAttribute(xsdAttributeDeclaration, "name"); + } + if (name == null) + { + name = validName(xsdAttributeDeclaration.getName(), true); + } + + EStructuralFeature eStructuralFeature = + createFeature(eClass, xsdAttributeDeclaration, name, xsdAttributeUse, xsdAttributeUse.isRequired()); + + if (isRestriction) + { + EStructuralFeature attributeWildcardEStructuralFeature = + extendedMetaData.getAttributeWildcardAffiliation + (baseClass, xsdAttributeDeclaration.getTargetNamespace(), xsdAttributeDeclaration.getName()); + if (attributeWildcardEStructuralFeature != null) + { + extendedMetaData.setGroup(eStructuralFeature, attributeWildcardEStructuralFeature); + eStructuralFeature.setDerived(true); + eStructuralFeature.setTransient(true); + eStructuralFeature.setVolatile(true); + } + } + } + /* 51210 + else if (isRestriction && !baseAttributeUses.contains(xsdAttributeUse)) + { + EStructuralFeature eStructuralFeature = + extendedMetaData.getAttribute(eClass, xsdAttributeDeclaration.getTargetNamespace(), xsdAttributeDeclaration.getName()); + if (eStructuralFeature != null) + { + EAnnotation attributeEAnnotation = ecoreFactory.createEAnnotation(); + if (xsdAttributeUse.isRequired()) + { + attributeEAnnotation.getDetails().put("minOccurs", "1"); + } + attributeEAnnotation.getReferences().add(eStructuralFeature); + + if (xsdAttributeDeclaration.getTypeDefinition() != null) + { + EClassifier type = getEClassifier(xsdAttributeDeclaration.getTypeDefinition()); + if (type != eStructuralFeature.getEType() && type != null) + { + attributeEAnnotation.getReferences().add(type); + } + } + + attributeParticle.getContents().add(attributeEAnnotation); + } + } + */ + } + + /* 51210 + if (isRestriction && !baseAttributeURIs.isEmpty()) + { + for (Iterator i = baseAttributeURIs.values().iterator(); i.hasNext(); ) + { + XSDAttributeUse xsdAttributeUse = (XSDAttributeUse)i.next(); + XSDAttributeDeclaration xsdAttributeDeclaration = xsdAttributeUse.getAttributeDeclaration(); + EStructuralFeature eStructuralFeature = + extendedMetaData.getAttribute(eClass, xsdAttributeDeclaration.getTargetNamespace(), xsdAttributeDeclaration.getName()); + if (eStructuralFeature != null) + { + EAnnotation attributeEAnnotation = ecoreFactory.createEAnnotation(); + attributeEAnnotation.getReferences().add(eStructuralFeature); + attributeEAnnotation.getDetails().put("maxOccurs", "0"); + attributeParticle.getContents().add(attributeEAnnotation); + } + } + } + */ + + XSDWildcard xsdWildcard = xsdComplexTypeDefinition.getAttributeWildcard(); + if (xsdWildcard != null && baseXSDWildcard != xsdWildcard || XSDConstants.isURType(xsdComplexTypeDefinition)) + { + if (isRestriction && !XSDConstants.isURType(xsdComplexTypeDefinition)) + { + // 51210 + // attributeParticle.getDetails().put + // ("wildcard", BasicExtendedMetaData.getEncodedWildcards(xsdComplexTypeDefinition.getTargetNamespace(), getWildcards(xsdWildcard))); + } + else + { + String name = getEcoreAttribute(xsdWildcard, "name"); + if (name == null) + { + name = "anyAttribute"; + } + createFeature + (eClass, + name, + ecorePackage.getEFeatureMapEntry(), + xsdWildcard, + 0, + -1); + } + } + + if (isRestriction) + { + // 51210 + // EAnnotation restrictionParticle = ecoreFactory.createEAnnotation(); + // restrictionParticle.setSource("restriction"); + // if (contentParticle != null) + // { + // restrictionParticle.getContents().add(contentParticle); + // } + // if (!attributeParticle.getContents().isEmpty() || !attributeParticle.getDetails().isEmpty()) + // { + // restrictionParticle.getContents().add(attributeParticle); + // } + // contentParticle = restrictionParticle; + + int baseContentKind = extendedMetaData.getContentKind((EClass)eClass.getESuperTypes().get(0)); + if (baseContentKind == ExtendedMetaData.MIXED_CONTENT && + xsdComplexTypeDefinition.getContentTypeCategory() == XSDContentTypeCategory.SIMPLE_LITERAL) + { + extendedMetaData.setContentKind(eClass, ExtendedMetaData.SIMPLE_CONTENT); + EStructuralFeature eStructuralFeature = + createFeature + (eClass, + "rawValue", + getBuiltInEClassifier(xsdComplexTypeDefinition.getSchema().getSchemaForSchemaNamespace(), "string"), + null, + 0, + 1); + eStructuralFeature.setDerived(true); + eStructuralFeature.setTransient(true); + eStructuralFeature.setVolatile(true); + + eStructuralFeature = + createFeature + (eClass, + "value", + getBuiltInEClassifier(xsdComplexTypeDefinition.getSchema().getSchemaForSchemaNamespace(), "anySimpleType"), + null, + 0, + 1); + eStructuralFeature.setDerived(true); + eStructuralFeature.setTransient(true); + eStructuralFeature.setVolatile(true); + + if ("SimpleAnyType".equals(eClass.getName()) && XMLTypePackage.eNS_URI.equals(eClass.getEPackage().getNsURI())) + { + eStructuralFeature = + createFeature + (eClass, + "instanceType", + ecorePackage.getEDataType(), + null, + 1, + 1); + + ((EReference)eStructuralFeature).setResolveProxies(false); + } + } + else + { + extendedMetaData.setContentKind(eClass, baseContentKind); + } + } + + // 51210 + // extendedMetaData.setContent(eClass, contentParticle); + + XSDAnnotation xsdAnnotation = xsdComplexTypeDefinition.getAnnotation(); + if (xsdAnnotation != null) + { + List applicationInformationList = xsdAnnotation.getApplicationInformation(EcorePackage.eNS_URI); + for (Iterator i = applicationInformationList.iterator(); i.hasNext(); ) + { + Element applicationInformation = (Element)i.next(); + if ("operations".equals(applicationInformation.getAttributeNS(EcorePackage.eNS_URI, "key"))) + { + for (Iterator j = getElements(applicationInformation, "operation").iterator(); j.hasNext(); ) + { + EOperation eOperation = ecoreFactory.createEOperation(); + Element operation = (Element)j.next(); + String operationName = operation.getAttributeNS(null, "name"); + eOperation.setName(operationName); + XSDTypeDefinition returnType = getEcoreTypeQNameAttribute(xsdComplexTypeDefinition, operation, null, "type"); + if (returnType != null) + { + EClassifier returnEType = getEClassifier(returnType); + eOperation.setEType(returnEType); + } + + List exceptions = getEcoreTypeQNamesAttribute(xsdComplexTypeDefinition, operation, null, "exceptions"); + for (Iterator k = exceptions.iterator(); k.hasNext(); ) + { + XSDTypeDefinition exceptionTypeDefinition = (XSDTypeDefinition)k.next(); + eOperation.getEExceptions().add(getEClassifier(exceptionTypeDefinition)); + } + + for (Iterator k = getElements(operation, "parameter").iterator(); k.hasNext(); ) + { + EParameter eParameter = ecoreFactory.createEParameter(); + Element parameter = (Element)k.next(); + String paramaterName = parameter.getAttributeNS(null, "name"); + XSDTypeDefinition parameterType = getEcoreTypeQNameAttribute(xsdComplexTypeDefinition, parameter, null, "type"); + EClassifier parameterEType = getEClassifier(parameterType); + eParameter.setName(paramaterName); + eParameter.setEType(parameterEType); + + populateETypedElement(eParameter, parameter); + eOperation.getEParameters().add(eParameter); + } + + List body = getElements(operation, "body"); + if (!body.isEmpty()) + { + EcoreUtil.setAnnotation(eOperation, "http://www.eclipse.org/emf/2002/GenModel", "body", getText((Element)body.get(0))); + } + + populateETypedElement(eOperation, operation); + eClass.getEOperations().add(eOperation); + } + } + } + } + return eClass; + } + + private String getText(Element element) + { + StringBuffer text = new StringBuffer(); + for (Node node = element.getFirstChild(); node != null; node = node.getNextSibling()) + { + switch (node.getNodeType()) + { + case Node.TEXT_NODE: + case Node.CDATA_SECTION_NODE: + { + text.append(node.getNodeValue()); + } + } + } + return text.toString(); + } + + private List getElements(Element element, String localName) + { + List result = new ArrayList(); + for (Node node = element.getFirstChild(); node != null; node = node.getNextSibling()) + { + if (node.getNodeType() == Node.ELEMENT_NODE) + { + Element child = (Element)node; + if (localName.equals(child.getLocalName()) && child.getNamespaceURI() == null) + { + result.add(child); + } + } + } + return result; + } + + protected EStructuralFeature createFeature + (EClass eClass, String name, EClassifier type, XSDComponent xsdComponent, int minOccurs, int maxOccurs) + { + if (xsdComponent != null) + { + XSDSchema containingXSDSchema = xsdComponent.getSchema(); + if (containingXSDSchema != null && !xsdSchemas.contains(containingXSDSchema)) + { + xsdSchemas.add(containingXSDSchema); + addInput(containingXSDSchema); + validate(containingXSDSchema); + } + } + else if (extendedMetaData.getContentKind(eClass) == ExtendedMetaData.MIXED_CONTENT) + { + if (type == ecorePackage.getEFeatureMapEntry()) + { + EAttribute eAttribute = ecoreFactory.createEAttribute(); + setAnnotations(eAttribute, xsdComponent); + eAttribute.setName(Character.toLowerCase(name.charAt(0)) + name.substring(1)); + eAttribute.setUnique(false); + eAttribute.setEType(type); + eAttribute.setLowerBound(minOccurs); + eAttribute.setUpperBound(maxOccurs); + eClass.getEStructuralFeatures().add(eAttribute); + extendedMetaData.setFeatureKind(eAttribute, ExtendedMetaData.ELEMENT_WILDCARD_FEATURE); + extendedMetaData.setName(eAttribute, ":" + eAttribute.getName()); + return eAttribute; + } + else + { + EReference eReference = ecoreFactory.createEReference(); + setAnnotations(eReference, xsdComponent); + eReference.setName(name); + eReference.setEType(ecorePackage.getEStringToStringMapEntry()); + eReference.setLowerBound(0); + eReference.setUpperBound(-1); + eReference.setContainment(true); + eReference.setResolveProxies(false); + eReference.setTransient(true); + eClass.getEStructuralFeatures().add(eReference); + extendedMetaData.setFeatureKind(eReference, ExtendedMetaData.ATTRIBUTE_FEATURE); + return eReference; + } + } + + if (type instanceof EClass) + { + EReference eReference = ecoreFactory.createEReference(); + setAnnotations(eReference, xsdComponent); + eReference.setName(Character.toLowerCase(name.charAt(0)) + name.substring(1)); + eReference.setEType(type); + eReference.setLowerBound(minOccurs); + eReference.setUpperBound(maxOccurs); + + eClass.getEStructuralFeatures().add(eReference); + if (xsdComponent == null) + { + extendedMetaData.setName(eReference, ":" + eClass.getEAllStructuralFeatures().indexOf(eReference)); + extendedMetaData.setFeatureKind(eReference, ExtendedMetaData.SIMPLE_FEATURE); + } + else + { + map(xsdComponent, eReference); + if (xsdComponent instanceof XSDParticle) + { + eReference.setContainment(true); + eReference.setResolveProxies(false); + + XSDParticle xsdParticle = (XSDParticle)xsdComponent; + + XSDTerm xsdTerm = ((XSDParticle)xsdComponent).getTerm(); + if (xsdTerm instanceof XSDElementDeclaration) + { + XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration)xsdTerm; + extendedMetaData.setFeatureKind(eReference, ExtendedMetaData.ELEMENT_FEATURE); + extendedMetaData.setName(eReference, xsdElementDeclaration.getName()); + extendedMetaData.setNamespace(eReference, xsdElementDeclaration.getTargetNamespace()); + + XSDTypeDefinition xsdType = getEffectiveTypeDefinition(xsdParticle, xsdElementDeclaration); + if (xsdType instanceof XSDSimpleTypeDefinition) + { + eReference.setContainment(false); + eReference.setResolveProxies(!isLocalReferenceType((XSDSimpleTypeDefinition)xsdType)); + } + + if (maxOccurs == 1 && xsdElementDeclaration.isNillable()) + { + eReference.setUnsettable(true); + } + + if (xsdElementDeclaration.isAbstract()) + { + eReference.setChangeable(false); + } + + String opposite = getEcoreAttribute(xsdParticle, "opposite"); + if (opposite != null) + { + eReferenceToOppositeNameMap.put(eReference, opposite); + } + } + else if (xsdTerm instanceof XSDWildcard) + { + // EATM shouldn't happen + XSDWildcard xsdWildcard = (XSDWildcard)xsdTerm; + extendedMetaData.setFeatureKind(eReference, ExtendedMetaData.ELEMENT_WILDCARD_FEATURE); + extendedMetaData.setWildcards(eReference, getWildcards(xsdWildcard)); + extendedMetaData.setProcessingKind(eReference, xsdWildcard.getProcessContents().getValue() + 1); + extendedMetaData.setName(eReference, ":" + eClass.getEAllStructuralFeatures().indexOf(eReference)); + } + else + { + extendedMetaData.setFeatureKind(eReference, ExtendedMetaData.GROUP_FEATURE); + extendedMetaData.setName(eReference, ":" + eClass.getEAllStructuralFeatures().indexOf(eReference)); + } + } + else if (xsdComponent instanceof XSDElementDeclaration) + { + XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration)xsdComponent; + eReference.setContainment(true); + eReference.setResolveProxies(false); + extendedMetaData.setFeatureKind(eReference, ExtendedMetaData.ELEMENT_FEATURE); + extendedMetaData.setName(eReference, xsdElementDeclaration.getName()); + extendedMetaData.setNamespace(eReference, xsdElementDeclaration.getTargetNamespace()); + + XSDElementDeclaration substitutionGroupAffiliation = xsdElementDeclaration.getSubstitutionGroupAffiliation(); + if (substitutionGroupAffiliation != null) + { + EStructuralFeature affiliation = getEStructuralFeature(substitutionGroupAffiliation); + extendedMetaData.setAffiliation(eReference, affiliation); + } + XSDTypeDefinition xsdType = getEffectiveTypeDefinition(null, xsdElementDeclaration); + if (xsdType instanceof XSDSimpleTypeDefinition) + { + eReference.setResolveProxies(!isLocalReferenceType((XSDSimpleTypeDefinition)xsdType)); + } + + if (maxOccurs == 1 && xsdElementDeclaration.isNillable()) + { + eReference.setUnsettable(true); + } + + if (xsdElementDeclaration.isAbstract()) + { + eReference.setChangeable(false); + } + } + else if (xsdComponent instanceof XSDAttributeUse) + { + String opposite = getEcoreAttribute(xsdComponent, "opposite"); + if (opposite != null) + { + eReferenceToOppositeNameMap.put(eReference, opposite); + } + + XSDAttributeUse xsdAttributeUse = (XSDAttributeUse)xsdComponent; + XSDAttributeDeclaration xsdAttributeDeclaration = xsdAttributeUse.getAttributeDeclaration(); + extendedMetaData.setFeatureKind(eReference, ExtendedMetaData.ATTRIBUTE_FEATURE); + extendedMetaData.setName(eReference, xsdAttributeDeclaration.getName()); + extendedMetaData.setNamespace(eReference, xsdAttributeDeclaration.getTargetNamespace()); + eReference.setResolveProxies + (!isLocalReferenceType((XSDSimpleTypeDefinition)getEffectiveTypeDefinition(xsdAttributeUse, xsdAttributeDeclaration))); + } + else if (xsdComponent instanceof XSDAttributeDeclaration) + { + XSDAttributeDeclaration xsdAttributeDeclaration = (XSDAttributeDeclaration)xsdComponent; + extendedMetaData.setFeatureKind(eReference, ExtendedMetaData.ATTRIBUTE_FEATURE); + extendedMetaData.setName(eReference, xsdAttributeDeclaration.getName()); + extendedMetaData.setNamespace(eReference, xsdAttributeDeclaration.getTargetNamespace()); + eReference.setResolveProxies + (!isLocalReferenceType((XSDSimpleTypeDefinition)getEffectiveTypeDefinition(null, xsdAttributeDeclaration))); + } + } + + return eReference; + } + else + { + EAttribute eAttribute = ecoreFactory.createEAttribute(); + setAnnotations(eAttribute, xsdComponent); + eAttribute.setName(Character.toLowerCase(name.charAt(0)) + name.substring(1)); + eAttribute.setUnique(false); + eAttribute.setEType(type); + eAttribute.setLowerBound(minOccurs); + eAttribute.setUpperBound(maxOccurs); + eClass.getEStructuralFeatures().add(eAttribute); + + if (xsdComponent == null) + { + extendedMetaData.setName(eAttribute, ":" + eClass.getEAllStructuralFeatures().indexOf(eAttribute)); + extendedMetaData.setFeatureKind(eAttribute, ExtendedMetaData.SIMPLE_FEATURE); + } + else + { + map(xsdComponent, eAttribute); + if (xsdComponent instanceof XSDAttributeUse) + { + XSDAttributeUse xsdAttributeUse = (XSDAttributeUse)xsdComponent; + XSDAttributeDeclaration xsdAttributeDeclaration = xsdAttributeUse.getAttributeDeclaration(); + extendedMetaData.setFeatureKind(eAttribute, ExtendedMetaData.ATTRIBUTE_FEATURE); + extendedMetaData.setName(eAttribute, xsdAttributeDeclaration.getName()); + extendedMetaData.setNamespace(eAttribute, xsdAttributeDeclaration.getTargetNamespace()); + + String defaultValue = getEcoreAttribute(xsdComponent, "default"); + if (defaultValue == null) + { + defaultValue = xsdAttributeUse.getLexicalValue(); + } + eAttribute.setDefaultValueLiteral(defaultValue); + initialize(eAttribute, (XSDSimpleTypeDefinition)getEffectiveTypeDefinition(xsdAttributeUse, xsdAttributeDeclaration)); + } + else if (xsdComponent instanceof XSDAttributeDeclaration) + { + XSDAttributeDeclaration xsdAttributeDeclaration = (XSDAttributeDeclaration)xsdComponent; + extendedMetaData.setFeatureKind(eAttribute, ExtendedMetaData.ATTRIBUTE_FEATURE); + extendedMetaData.setName(eAttribute, xsdAttributeDeclaration.getName()); + extendedMetaData.setNamespace(eAttribute, xsdAttributeDeclaration.getTargetNamespace()); + + eAttribute.setDefaultValueLiteral(xsdAttributeDeclaration.getLexicalValue()); + initialize(eAttribute, (XSDSimpleTypeDefinition)getEffectiveTypeDefinition(null, xsdAttributeDeclaration)); + } + else if (xsdComponent instanceof XSDParticle) + { + XSDTerm xsdTerm = ((XSDParticle)xsdComponent).getTerm(); + if (xsdTerm instanceof XSDElementDeclaration) + { + XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration)xsdTerm; + extendedMetaData.setFeatureKind(eAttribute, ExtendedMetaData.ELEMENT_FEATURE); + extendedMetaData.setName(eAttribute, xsdElementDeclaration.getName()); + extendedMetaData.setNamespace(eAttribute, xsdElementDeclaration.getTargetNamespace()); + + eAttribute.setDefaultValueLiteral(xsdElementDeclaration.getLexicalValue()); + XSDTypeDefinition xsdType = getEffectiveTypeDefinition(xsdComponent, xsdElementDeclaration); + if (xsdType instanceof XSDSimpleTypeDefinition) + { + initialize(eAttribute, (XSDSimpleTypeDefinition)xsdType); + } + + if (xsdElementDeclaration.isNillable()) + { + if (!canSupportNull((EDataType)type)) + { + eAttribute.setEType(type = (EDataType)typeToTypeObjectMap.get(type)); + } + if (maxOccurs == 1) + { + eAttribute.setUnsettable(true); + } + } + + if (xsdElementDeclaration.isAbstract()) + { + eAttribute.setChangeable(false); + } + } + else if (xsdTerm instanceof XSDWildcard) + { + XSDWildcard xsdWildcard = (XSDWildcard)xsdTerm; + extendedMetaData.setFeatureKind(eAttribute, ExtendedMetaData.ELEMENT_WILDCARD_FEATURE); + extendedMetaData.setWildcards(eAttribute, getWildcards(xsdWildcard)); + extendedMetaData.setProcessingKind(eAttribute, xsdWildcard.getProcessContents().getValue() + 1); + extendedMetaData.setName(eAttribute, ":" + eClass.getEAllStructuralFeatures().indexOf(eAttribute)); + } + else + { + extendedMetaData.setFeatureKind(eAttribute, ExtendedMetaData.GROUP_FEATURE); + } + } + else if (xsdComponent instanceof XSDWildcard) + { + XSDWildcard xsdWildcard = (XSDWildcard)xsdComponent; + extendedMetaData.setFeatureKind(eAttribute, ExtendedMetaData.ATTRIBUTE_WILDCARD_FEATURE); + extendedMetaData.setWildcards(eAttribute, getWildcards(xsdWildcard)); + extendedMetaData.setProcessingKind(eAttribute, xsdWildcard.getProcessContents().getValue() + 1); + extendedMetaData.setName(eAttribute, ":" + eClass.getEAllStructuralFeatures().indexOf(eAttribute)); + } + else if (xsdComponent instanceof XSDElementDeclaration) + { + XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration)xsdComponent; + extendedMetaData.setFeatureKind(eAttribute, ExtendedMetaData.ELEMENT_FEATURE); + extendedMetaData.setName(eAttribute, xsdElementDeclaration.getName()); + extendedMetaData.setNamespace(eAttribute, xsdElementDeclaration.getTargetNamespace()); + + eAttribute.setDefaultValueLiteral(xsdElementDeclaration.getLexicalValue()); + XSDTypeDefinition xsdType = getEffectiveTypeDefinition(null, xsdElementDeclaration); + if (xsdType instanceof XSDSimpleTypeDefinition) + { + initialize(eAttribute, (XSDSimpleTypeDefinition)xsdType); + } + + XSDElementDeclaration substitutionGroupAffiliation = xsdElementDeclaration.getSubstitutionGroupAffiliation(); + if (substitutionGroupAffiliation != null) + { + EStructuralFeature affiliation = getEStructuralFeature(substitutionGroupAffiliation); + extendedMetaData.setAffiliation(eAttribute, affiliation); + } + + if (xsdElementDeclaration.isNillable() && !canSupportNull((EDataType)type)) + { + eAttribute.setEType(type = (EDataType)typeToTypeObjectMap.get(type)); + if (maxOccurs == 1) + { + eAttribute.setUnsettable(true); + } + } + + if (xsdElementDeclaration.isAbstract()) + { + eAttribute.setChangeable(false); + } + } + } + + if (maxOccurs == 1 && (type.getDefaultValue() != null || eAttribute.getDefaultValueLiteral() != null)) + { + eAttribute.setUnsettable(true); + } + + return eAttribute; + } + } + + protected EStructuralFeature createFeature + (EClass eClass, XSDElementDeclaration xsdElementDeclaration, String name, XSDComponent xsdComponent, int minOccurs, int maxOccurs) + { + XSDTypeDefinition elementTypeDefinition = getEffectiveTypeDefinition(xsdComponent, xsdElementDeclaration); + EClassifier eClassifier = getEClassifier(elementTypeDefinition); + + XSDTypeDefinition referenceType = getEcoreTypeQNameAttribute(xsdComponent, "reference"); + if (referenceType == null) + { + referenceType = getEcoreTypeQNameAttribute(xsdElementDeclaration, "reference"); + } + if (referenceType != null) + { + EClassifier referenceClassifier = getEClassifier(referenceType); + boolean needsHolder = false; + if (elementTypeDefinition instanceof XSDSimpleTypeDefinition) + { + XSDSimpleTypeDefinition xsdSimpleTypeDefinition = (XSDSimpleTypeDefinition)elementTypeDefinition; + if (xsdSimpleTypeDefinition.getVariety() == XSDVariety.LIST_LITERAL) + { + needsHolder = true; + + EPackage holderPackage = getEPackage(xsdElementDeclaration); + String holderName = xsdElementDeclaration.getName() + ":holder"; + EClass holderClass = (EClass)extendedMetaData.getType(holderPackage, holderName); + if (holderClass == null) + { + // Create a holder class like an anonymous complex type. + // + holderClass = ecoreFactory.createEClass(); + setAnnotations(holderClass, xsdElementDeclaration); + holderClass.setName(validName(holderName, true)); + extendedMetaData.setName(holderClass, holderName); + extendedMetaData.setContentKind(holderClass, ExtendedMetaData.SIMPLE_CONTENT); + + addToSortedList(holderPackage.getEClassifiers(), holderClass); + + EReference holderReference = + (EReference)createFeature + (holderClass, + "value", + referenceClassifier, + null, + 0, + -1); + + holderReference.setResolveProxies(!isLocalReferenceType(xsdSimpleTypeDefinition)); + } + referenceClassifier = holderClass; + } + } + EStructuralFeature result = + createFeature + (eClass, + name, + referenceClassifier, + xsdComponent, + minOccurs, + maxOccurs); + ((EReference)result).setContainment(needsHolder); + if (needsHolder) + { + ((EReference)result).setUnsettable(false); + ((EReference)result).setResolveProxies(false); + } + initialize(result, xsdElementDeclaration, xsdComponent); + return result; + } + else + { + EStructuralFeature result = + createFeature + (eClass, + name, + eClassifier, + xsdComponent, + minOccurs, + maxOccurs); + initialize(result, xsdElementDeclaration, xsdComponent); + return result; + } + } + + public EStructuralFeature getEStructuralFeature(XSDFeature xsdFeature) + { + if ("true".equals(getEcoreAttribute(xsdFeature, "ignore"))) return null; + EStructuralFeature eStructuralFeature = (EStructuralFeature)xsdComponentToEModelElementMap.get(xsdFeature); + if (eStructuralFeature == null) + { + EPackage ePackage = getEPackage(xsdFeature); + EClass documentEClass = extendedMetaData.getDocumentRoot(ePackage); + if (documentEClass == null) + { + createDocumentRoot(xsdFeature.getSchema(), ePackage); + } + + String name = getEcoreAttribute(xsdFeature, "name"); + if (name == null) + { + name= validName(xsdFeature.getName(), true); + } + + if (xsdFeature instanceof XSDElementDeclaration) + { + // Mark the bound as unspecified so that it won't be considered many + // but can nevertheless be recognized as being unspecified and perhaps still be treat as many. + // + EStructuralFeature result = + createFeature(documentEClass, (XSDElementDeclaration)xsdFeature, name, xsdFeature, 0, ETypedElement.UNSPECIFIED_MULTIPLICITY); + + result.setDerived(true); + result.setTransient(true); + result.setVolatile(true); + return result; + } + else + { + EStructuralFeature result = + createFeature(documentEClass, (XSDAttributeDeclaration)xsdFeature, name, xsdFeature, false); + return result; + } + } + + return eStructuralFeature; + } + + public void generate(XSDSchema xsdSchema) + { + this.rootSchema = xsdSchema; + if (xsdSchemas.add(xsdSchema)) + { + addInput(xsdSchema); + validate(xsdSchema); + } + + Collection visitedElementDeclarations = new ArrayList(); + Collection elementDeclarations = new ArrayList(xsdSchema.getElementDeclarations()); + + Collection visitedAttributeDeclarations = new ArrayList(); + Collection attributeDeclarations = new ArrayList(xsdSchema.getAttributeDeclarations()); + + Collection visitedTypeDefinitions = new ArrayList(); + Collection typeDefinitions = new ArrayList(xsdSchema.getTypeDefinitions()); + + while (!elementDeclarations.isEmpty() || !attributeDeclarations.isEmpty() || !typeDefinitions.isEmpty()) + { + for (Iterator i = elementDeclarations.iterator(); i.hasNext(); ) + { + XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration)i.next(); + getEStructuralFeature(xsdElementDeclaration); + } + visitedElementDeclarations.addAll(elementDeclarations); + elementDeclarations = new ArrayList(xsdSchema.getElementDeclarations()); + elementDeclarations.removeAll(visitedElementDeclarations); + + for (Iterator i = attributeDeclarations.iterator(); i.hasNext(); ) + { + XSDAttributeDeclaration xsdAttributeDeclaration = (XSDAttributeDeclaration)i.next(); + if (!XSDConstants.isSchemaInstanceNamespace(xsdAttributeDeclaration.getTargetNamespace())) + { + getEStructuralFeature(xsdAttributeDeclaration); + } + } + visitedAttributeDeclarations.addAll(attributeDeclarations); + attributeDeclarations = new ArrayList(xsdSchema.getAttributeDeclarations()); + attributeDeclarations.removeAll(visitedAttributeDeclarations); + + for (Iterator i = typeDefinitions.iterator(); i.hasNext(); ) + { + XSDTypeDefinition xsdTypeDefinition = (XSDTypeDefinition)i.next(); + getEClassifier(xsdTypeDefinition); + } + visitedTypeDefinitions.addAll(typeDefinitions); + typeDefinitions = new ArrayList(xsdSchema.getTypeDefinitions()); + typeDefinitions.removeAll(visitedTypeDefinitions); + } + + resolveNameConflicts(); + + for (Iterator i = xsdSchemas.iterator(); i.hasNext(); ) + { + XSDSchema generatedXSDSchema = (XSDSchema)i.next(); + EPackage ePackage = (EPackage)targetNamespaceToEPackageMap.get(generatedXSDSchema.getTargetNamespace()); + if (ePackage != null) + { + String packageName= getEcoreAttribute(generatedXSDSchema, "package"); + if (packageName != null) + { + ePackage.setName(packageName); + } + String packageNsPrefix= getEcoreAttribute(generatedXSDSchema, "nsPrefix"); + if (packageNsPrefix != null) + { + ePackage.setNsPrefix(packageNsPrefix); + } + } + } + + for (Iterator i = eReferenceToOppositeNameMap.entrySet().iterator(); i.hasNext(); ) + { + Map.Entry entry = (Map.Entry)i.next(); + EReference eReference = (EReference)entry.getKey(); + String opposite = (String)entry.getValue(); + EClass oppositeEClass = eReference.getEReferenceType(); + if (eReference.getEOpposite() == null) + { + EStructuralFeature eOppositeFeature = oppositeEClass.getEStructuralFeature(opposite); + + // Match by XML name if this fails. + if (eOppositeFeature == null) + { + for (Iterator j = oppositeEClass.getEAllStructuralFeatures().iterator(); j.hasNext(); ) + { + EStructuralFeature feature = (EStructuralFeature)j.next(); + if (opposite.equals(extendedMetaData.getName(feature))) + { + eOppositeFeature = feature; + break; + } + } + } + + if (eOppositeFeature instanceof EReference) + { + EReference eOpposite = (EReference)eOppositeFeature; + eOpposite.setEOpposite(eReference); + eReference.setEOpposite(eOpposite); + } + } + + if (eReference.getEOpposite() == null && eReference.isContainment()) + { + EReference eOpposite = ecoreFactory.createEReference(); + eOpposite.setName(opposite); + eOpposite.setEType(eReference.getEContainingClass()); + eOpposite.setLowerBound(0); + eOpposite.setEOpposite(eReference); + eReference.setEOpposite(eOpposite); + eOpposite.setTransient(true); + oppositeEClass.getEStructuralFeatures().add(eOpposite); + } + } + + eReferenceToOppositeNameMap.clear(); + } + +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/CopyHelperImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/CopyHelperImpl.java new file mode 100644 index 0000000000..d768076ecb --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/CopyHelperImpl.java @@ -0,0 +1,84 @@ +/** + * + * 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.EReference; +import org.eclipse.emf.ecore.util.EcoreUtil.Copier; + +import commonj.sdo.ChangeSummary; +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) + { + } + + protected void copyAttribute(EAttribute eAttribute, EObject eObject, EObject copyEObject) { + if(("ChangeSummaryType".equals(eAttribute.getEType().getName()) && "commonj.sdo".equals(eAttribute.getEType().getEPackage().getNsURI()))) { + boolean isLogging = ((ChangeSummary)eObject.eGet(eAttribute)).isLogging(); + ChangeSummary destSum = (ChangeSummary)copyEObject.eGet(eAttribute); + if(isLogging) { + if(!destSum.isLogging()) destSum.beginLogging(); + } else { + if(destSum.isLogging()) destSum.endLogging(); + } + } else { + super.copyAttribute(eAttribute, eObject, copyEObject); + } + } + }; + EObject result = copier.copy((EObject)dataObject); + copier.copyReferences(); + return (DataObject)result; + } + + public DataObject copy(DataObject dataObject) + { + Copier copier = new Copier() + { + + protected void copyAttribute(EAttribute eAttribute, EObject eObject, EObject copyEObject) { + if(("ChangeSummaryType".equals(eAttribute.getEType().getName()) && "commonj.sdo".equals(eAttribute.getEType().getEPackage().getNsURI()))) { + throw new UnsupportedOperationException("This will be implemented when change summary serialization/deserialization is in place"); + } else { + super.copyAttribute(eAttribute, eObject, copyEObject); + } + } + }; + EObject result = copier.copy((EObject)dataObject); + copier.copyReferences(); + return (DataObject)result; + } + + +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/CrossScopeCopyHelperImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/CrossScopeCopyHelperImpl.java new file mode 100644 index 0000000000..b7a5534800 --- /dev/null +++ b/sandbox/kgoodson/events/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/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/DataFactoryImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/DataFactoryImpl.java new file mode 100644 index 0000000000..774d296eae --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/DataFactoryImpl.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.helper; + +import org.apache.tuscany.sdo.util.DataObjectUtil; + +import commonj.sdo.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.HelperContext; + +/** + * A Factory for creating DataObjects. The created DataObjects are not connected + * to any other DataObjects. + */ +public class DataFactoryImpl implements DataFactory { + protected HelperContext helperContext; + + public DataFactoryImpl(HelperContext hc) { + this.helperContext = hc; + } + + public DataObject create(String uri, String typeName) { + Type type = helperContext.getTypeHelper().getType(uri, typeName); + return create(type); + } + + public DataObject create(Class interfaceClass) { + // TODO more efficient implementation ... this is a really bad one! + Type type = helperContext.getTypeHelper().getType(interfaceClass); + return create(type); + } + + public DataObject create(Type type) { + return DataObjectUtil.create(type); + } + + public HelperContext getHelperContext() { + return helperContext; + } + +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/DataHelperImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/DataHelperImpl.java new file mode 100644 index 0000000000..eafa78214d --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/DataHelperImpl.java @@ -0,0 +1,616 @@ +/** + * + * 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.math.BigDecimal; +import java.math.BigInteger; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.TimeZone; + +import org.apache.tuscany.sdo.util.DataObjectUtil; + +import commonj.sdo.Property; +import commonj.sdo.Type; +import commonj.sdo.helper.DataHelper; + +/** + * Data helper methods. + */ +public class DataHelperImpl implements DataHelper +{ + /** + * @param dateString - Must comply to the pattern of yyyy-MM-dd'T'HH:mm:ss'.'SSS'Z' + * @return null if dataString couldn't be parsed + */ + public synchronized Date toDate(String dateString) + { + if (dateString == null) + { + return null; + } + + SimpleDateFormat format; + Date result = null; + boolean negative = false; + String formatString; + dateString = dateString.trim(); + + // 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")) + { + if (dateString.indexOf('.') != -1) + formatString = new String("yyyy-MM-dd'T'HH:mm:ss'.'S'Z'"); + else + formatString = new String ("yyyy-MM-dd'T'HH:mm:ss'Z'"); + + format = new SimpleDateFormat(formatString); + format.setTimeZone(TimeZone.getTimeZone("UTC")); + + result = checkFormat(dateString, format); + + // 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(" ", ""); + + // Build the formatString based on the contents of dateString + + formatString = obtainDurationFormats(durationString); + format = new SimpleDateFormat(formatString); + result = checkFormat(durationString, format); + if (result != null) + { + if (negative) + return handleNegative(result); + else + return result; + } + } + + formatString = obtainSpecificFormat(dateString); + + if (formatString != null) + { + format = new SimpleDateFormat(formatString); + result = checkFormat(dateString, format); + + if (result != null) + { + if (negative) + return handleBCE(result); + else + return result; + } + } + + return null; + } + + private synchronized Date checkFormat(String dateString, SimpleDateFormat format) + { + String formatPattern = format.toPattern(); + StringBuffer addedFields = new StringBuffer(); + String fieldsString, parseString; + SimpleDateFormat compositeFormat; + Date dateValue; + + // For certain permissable input strings (e.g. those resulting from toYear + // toDay, toTime), there are fields missing which when converted to Date have + // default values. (e.g. Year -> 1970). Because of this, there can be great + // variation in how daylight savings time is accounted for. (e.g. In 1970 Britain + // was on DST year round, and during the summer of 1944 was on double daylight time.) + // Because these possible variations exist, it is assumed that the user would prefer + // the current handling of daylight savings time. As such, the year, month and day + // will default to their current values when absent. (The user should not be checking + // for Year=1970 (etc.) as evidence of taking the default, as explicitly setting a + // year to 1970 is valid and would then not be an instance of a default taken.) + + if (!(formatPattern.startsWith("P"))) + { + if (formatPattern.indexOf('y') == -1) + addedFields.append("yyyy "); + + if (formatPattern.indexOf('M') == -1) + addedFields.append("MM "); + + if (formatPattern.indexOf('d') == -1) + addedFields.append("dd "); + } + + fieldsString = addedFields.toString(); + + if (fieldsString.length() == 0) + { + parseString = dateString; + compositeFormat = format; + } + + else + { + compositeFormat = new SimpleDateFormat(fieldsString); + dateValue = new Date(System.currentTimeMillis()); + parseString = compositeFormat.format(dateValue) + dateString; + compositeFormat.applyPattern(fieldsString + formatPattern); + } + + try + { + return compositeFormat.parse(parseString); + } + + catch (ParseException parseException) + { + } + + return null; + } + + public synchronized String obtainSpecificFormat(String dateString) + { + StringBuffer formatBuffer = new StringBuffer(); + int colonIndex = dateString.indexOf(':'); + int hyphenIndex = dateString.indexOf('-'); + + if (dateString.startsWith("--")) + { + if (dateString.charAt(2) == '-') // starts with --- + formatBuffer.append("'---'dd"); + else if (dateString.substring(2).indexOf('-') == -1) + formatBuffer.append("'--'MM"); + else + formatBuffer.append("'--'MM'-'dd"); + } + + else if (colonIndex == 1 || colonIndex == 2) + { + if (dateString.indexOf('.') != -1) + formatBuffer.append("HH:mm:ss'.'S"); + else if (dateString.substring(colonIndex + 1).indexOf(':') != -1) + formatBuffer.append("HH:mm:ss"); + else + formatBuffer.append("HH:mm"); + } + + else if (hyphenIndex != -1) + { + if (dateString.substring(hyphenIndex + 1).indexOf('-') == -1) + formatBuffer.append("yyyy-MM"); + else if (colonIndex != -1) + { + if (dateString.indexOf('.') != -1) + formatBuffer.append("yyyy-MM-dd'T'HH:mm:ss'.'S"); + else if (dateString.substring(colonIndex + 1).indexOf(':') != -1) + formatBuffer.append("yyyy-MM-dd'T'HH:mm:ss"); + else + formatBuffer.append("yyyy-MM-dd'T'HH:mm"); + } + else + formatBuffer.append ("yyyy-MM-dd"); + } + else if (colonIndex == -1) // indexOf('-') == -1 + { + formatBuffer.append("yyyy"); + } + else + return null; + + // Determine if a Time Zone is included and needs to be parsed. + // --------------------------------- + // The only letter allowed in the above formats is 'T'. + // All times zones include at least one letter other than 'T'. + + int i = 0; + boolean letterFound = false; + char currentChar; + while (i < dateString.length() && !letterFound) + { + currentChar = dateString.charAt(i); + if (Character.isLetter(currentChar) && currentChar != 'T') + letterFound = true;; + i++; + } + + if (letterFound) + formatBuffer.append(" z"); + + return formatBuffer.toString(); + } + + public synchronized String obtainDurationFormats(String dateString) + { + String firstPart, secondPart; + StringBuffer formatBuffer = 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) + { + firstPart = dateString.substring(0, time_index + 1); + secondPart = dateString.substring(time_index); + } + else + { + firstPart = dateString; + secondPart = null; + } + + if (firstPart.indexOf('Y') != -1) + formatBuffer.append("yyyy'Y'"); + if (firstPart.indexOf('M') != -1) + formatBuffer.append("MM'M'"); + if (firstPart.indexOf('D') != -1) + formatBuffer.append("dd'D'"); + if (time_index != -1) + { + formatBuffer.append("'T'"); + + if (secondPart.indexOf('H') != -1) + formatBuffer.append("HH'H'"); + if (secondPart.indexOf('M') != -1) + formatBuffer.append("mm'M'"); + if (secondPart.indexOf("S.") != -1) + formatBuffer.append("ss'S'.S"); + else if (secondPart.indexOf('S') != -1) + formatBuffer.append("ss'S'"); + } + + return formatBuffer.toString().replaceAll("''", ""); + } + + // 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) + { + return toCalendar(dateString, null); + } + + public synchronized Calendar toCalendar(String dateString, Locale locale) + { + if (dateString == null) + { + return null; + } + + Date date = toDate(dateString); + if (date == null) + { + return null; + } + + Calendar calendar = locale != null ? new GregorianCalendar(locale) : new GregorianCalendar(); + 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'Z'"); + f.setTimeZone(TimeZone.getTimeZone("UTC")); + + 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()); + } + + public Object convert(Type type, Object value) + { + Class typeClass = type.getInstanceClass(); + if (typeClass.isInstance(value)) + return value; + + if (typeClass == BigDecimal.class) { + return DataObjectUtil.getBigDecimal(value); + } + else if (typeClass == BigInteger.class) { + return DataObjectUtil.getBigInteger(value); + } + else if (typeClass == boolean.class || typeClass == Boolean.class) { + return new Boolean(DataObjectUtil.getBoolean(value)); + } + else if (typeClass == byte.class || typeClass == Byte.class) { + return new Byte(DataObjectUtil.getByte(value)); + } + else if (typeClass == byte[].class) { + return DataObjectUtil.getBytes(value); + } + else if (typeClass == char.class || typeClass == Character.class) { + return new Character(DataObjectUtil.getChar(value)); + } + else if (typeClass == Date.class) { + return DataObjectUtil.getDate(value); + } + else if (typeClass == double.class || typeClass == Double.class) { + return new Double(DataObjectUtil.getDouble(value)); + } + else if (typeClass == float.class || typeClass == Float.class) { + return new Float(DataObjectUtil.getFloat(value)); + } + else if (typeClass == int.class || typeClass == Integer.class) { + return new Integer(DataObjectUtil.getInt(value)); + } + else if (typeClass == long.class || typeClass == Long.class) { + return new Long(DataObjectUtil.getLong(value)); + } + else if (typeClass == short.class || typeClass == Short.class) { + return new Short(DataObjectUtil.getShort(value)); + } + else if (typeClass == String.class) { + return DataObjectUtil.getString(value); + } + + throw new IllegalArgumentException(); + } + + public Object convert(Property property, Object value) + { + Type type = property.getType(); + if (!property.isMany()) + { + return convert(type, value); + } + else + { + List listValue = (List)value; + List listResult = new ArrayList(); + for (Iterator iter = listValue.iterator(); iter.hasNext(); ) { + listResult.add(convert(type, iter.next())); + } + return listResult; + } + } + +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/DefaultHelperContextImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/DefaultHelperContextImpl.java new file mode 100644 index 0000000000..a8804e9e5d --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/DefaultHelperContextImpl.java @@ -0,0 +1,72 @@ +/** + * + * 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.Map; +import java.util.WeakHashMap; + +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.impl.EPackageRegistryImpl; + +public class DefaultHelperContextImpl extends HelperContextImpl { + public DefaultHelperContextImpl(final boolean extensibleNamespaces) { + super(new SDOExtendedMetaDataImpl(new SDOPackageRegistryDelegator()), extensibleNamespaces); + } + + public DefaultHelperContextImpl(final boolean extensibleNamespaces, final Map options) { + super(new SDOExtendedMetaDataImpl(new SDOPackageRegistryDelegator()), extensibleNamespaces, options); + } + + protected static class SDOPackageRegistryDelegator extends EPackageRegistryImpl.Delegator { + /** + * A map from class loader to its associated registry. + */ + protected Map classLoaderToRegistryMap = new WeakHashMap(); + + /** + * Returns the package registry associated with the given class loader. + * @param classLoader the class loader. + * @return the package registry associated with the given class loader. + */ + public synchronized EPackage.Registry getRegistry(final ClassLoader classLoader) + { + EPackage.Registry result = (EPackage.Registry)classLoaderToRegistryMap.get(classLoader); + if (result == null) + { + if (classLoader == null) + { + result = HelperContextImpl.getBuiltInModelRegistry(); + } + else + { + result = new EPackageRegistryImpl(getRegistry(classLoader.getParent())); + classLoaderToRegistryMap.put(classLoader, result); + } + } + return result; + } + + protected EPackage.Registry delegateRegistry(final ClassLoader classLoader) + { + return getRegistry(classLoader); + } + } +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/EqualityHelperImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/EqualityHelperImpl.java new file mode 100644 index 0000000000..d64c58dea2 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/EqualityHelperImpl.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.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) + { + if(!("ChangeSummaryType".equals(feature.getEType().getName()) && "commonj.sdo".equals(feature.getEType().getEPackage().getNsURI()))) { + 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) + { + EcoreUtil.EqualityHelper equalityHelper = new EcoreUtil.EqualityHelper() + { + protected boolean haveEqualAttribute(EObject eObject1, EObject eObject2, EAttribute attribute) { + if(("ChangeSummaryType".equals(attribute.getEType().getName()) && "commonj.sdo".equals(attribute.getEType().getEPackage().getNsURI()))) { + throw new UnsupportedOperationException("This will be implemented when change summary serialzation/deserialization is in place"); + } else { + return super.haveEqualAttribute(eObject1, eObject2, attribute); + } + } + }; + return equalityHelper.equals((EObject)dataObject1, (EObject)dataObject2); } +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/HelperContextImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/HelperContextImpl.java new file mode 100644 index 0000000000..64ee628693 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/HelperContextImpl.java @@ -0,0 +1,193 @@ +/** + * + * 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.HashMap; +import java.util.Iterator; +import java.util.Map; + +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.change.ChangePackage; +import org.eclipse.emf.ecore.impl.EPackageRegistryImpl; +import org.eclipse.emf.ecore.util.ExtendedMetaData; +import org.eclipse.emf.ecore.xml.namespace.XMLNamespacePackage; +import org.eclipse.emf.ecore.xml.type.XMLTypePackage; + +import commonj.sdo.helper.CopyHelper; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.DataHelper; +import commonj.sdo.helper.EqualityHelper; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; + +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.api.XMLStreamHelper; + +public class HelperContextImpl implements HelperContext { + /* + * Relationship: HelperContext*Impl* ---1:1---> ExtendedMetaData ---1:1---> + * Map (:defaultOption) <---1:1---> TypeHelper <---1:1---> XMLHelper + * <---1:1---> XMLStreamHelper <---1:1---> XSDHelper <---1:1---> DataFactory + */ + + protected ExtendedMetaData extendedMetaData; + protected DataFactory dataFactory; + protected TypeHelper typeHelper; + protected XMLHelper xmlHelper; + protected XSDHelper xsdHelper; + protected XMLStreamHelper xmlStreamHelper; + protected Map defaultOptions = null; + + public HelperContextImpl(ExtendedMetaData extendedMetaData, boolean extensibleNamespaces) { + this.defaultOptions = null; + this.extendedMetaData = extendedMetaData; + typeHelper = new TypeHelperImpl(this); + dataFactory = new DataFactoryImpl(this); + xmlHelper = new XMLHelperImpl(this); + xsdHelper = new XSDHelperImpl(this, null, extensibleNamespaces); + xmlStreamHelper = new XMLStreamHelperImpl(this); + } + + + public HelperContextImpl(ExtendedMetaData extendedMetaData, boolean extensibleNamespaces, Map options) { + this.defaultOptions = options; + this.extendedMetaData = extendedMetaData; + typeHelper = new TypeHelperImpl(this); + dataFactory = new DataFactoryImpl(this); + xmlHelper = new XMLHelperImpl(this); + xsdHelper = new XSDHelperImpl(this, null, extensibleNamespaces); + xmlStreamHelper = new XMLStreamHelperImpl(this); + } + + // many places this is called in existing code + // This is used for supporting the deprecated util - + // org.apache.tuscany.sdo.util.SDOUtil + // Once we conpletely remove this deprecated util, we can remove the below + // constructor + public HelperContextImpl(TypeHelper scope) { + this(scope, null); + } + + + public HelperContextImpl(TypeHelper scope, Map options) { + this.defaultOptions = options; + typeHelper = scope; + this.extendedMetaData = ((TypeHelperImpl)scope).getExtendedMetaData(); + dataFactory = new DataFactoryImpl(this); + xmlHelper = new XMLHelperImpl(this); + xsdHelper = new XSDHelperImpl(this); + xmlStreamHelper = new XMLStreamHelperImpl(this); + } + + public HelperContextImpl(boolean extensibleNamespaces) { + this(new SDOExtendedMetaDataImpl(new EPackageRegistryImpl(getBuiltInModelRegistry())), extensibleNamespaces); + } + + + public HelperContextImpl(boolean extensibleNamespaces, Map options) { + this(new SDOExtendedMetaDataImpl(new EPackageRegistryImpl(getBuiltInModelRegistry())), extensibleNamespaces, + options); + } + + static protected EPackage.Registry builtInModelRegistry = null; + + static public EPackage.Registry getBuiltInModelRegistry() { + if (builtInModelRegistry == null) { + EPackageRegistryImpl registry = new EPackageRegistryImpl(); + for (Iterator iter = TypeHelperImpl.getBuiltInModels().iterator(); iter.hasNext();) { + EPackage ePackage = (EPackage)iter.next(); + registry.put(ePackage.getNsURI(), ePackage); + } + + registry.put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE); + registry.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE); + registry.put(ChangePackage.eNS_URI, ChangePackage.eINSTANCE); + registry.put(XMLNamespacePackage.eNS_URI, XMLNamespacePackage.eINSTANCE); + registry.put(SDOPackage.eNS_URI, SDOPackage.eINSTANCE); + + builtInModelRegistry = registry; + } + return builtInModelRegistry; + } + + public CopyHelper getCopyHelper() { + return CopyHelper.INSTANCE; + } + + public DataFactory getDataFactory() { + return dataFactory; + } + + public DataHelper getDataHelper() { + return DataHelper.INSTANCE; + } + + public EqualityHelper getEqualityHelper() { + return EqualityHelper.INSTANCE; + } + + public TypeHelper getTypeHelper() { + return typeHelper; + } + + public XMLHelper getXMLHelper() { + return xmlHelper; + } + + public XMLStreamHelper getXMLStreamHelper() { + return xmlStreamHelper; + } + + public XSDHelper getXSDHelper() { + return xsdHelper; + } + + public void setOptions(Map options) { + this.defaultOptions = options; + } + + public Map getOptions() { + return this.defaultOptions; + } + + public Map getMergedOption(Map options) { + Map mergedOptions = null;// copy to be used for merge + + if (defaultOptions == null) { + return options; + } + + mergedOptions = new HashMap(defaultOptions); + if (options == null) { + return mergedOptions; + } + mergedOptions.putAll(options); + + return mergedOptions; + } + + public ExtendedMetaData getExtendedMetaData() { + return extendedMetaData; + } +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/HelperProviderImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/HelperProviderImpl.java new file mode 100644 index 0000000000..360617bd20 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/HelperProviderImpl.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.helper; + + +import org.apache.tuscany.sdo.spi.HelperProviderBase; + +import commonj.sdo.helper.HelperContext; + +/** + * Create and manage all the default helper INSTANCEs + */ +public class HelperProviderImpl extends HelperProviderBase +{ + public HelperContext createDefaultHelpers() + { + //FB HelperContext hc = SDOUtil.createHelperContext(); + //FB The defulat HelperContext must use EMF's ClassLoader-delegating EPackage.Registry.INSTANCE, until we provide + //FB another way to get (ClassLoader scope) support for HelperContext. + HelperContext hc = new DefaultHelperContextImpl(false); + typeHelper = hc.getTypeHelper(); + dataFactory = hc.getDataFactory(); + xmlHelper = hc.getXMLHelper(); + xsdHelper = hc.getXSDHelper(); + copyHelper = new CopyHelperImpl(); + equalityHelper = new EqualityHelperImpl(); + dataHelper = new DataHelperImpl(); + sdoHelper = new SDOHelperImpl(); + xmlStreamHelper = ((HelperContextImpl)hc).getXMLStreamHelper(); + + return hc; + } +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOAnnotations.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOAnnotations.java new file mode 100644 index 0000000000..816fb3bf9f --- /dev/null +++ b/sandbox/kgoodson/events/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/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOExtendedMetaDataImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOExtendedMetaDataImpl.java new file mode 100644 index 0000000000..d48979b0e6 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOExtendedMetaDataImpl.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.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import org.apache.tuscany.sdo.SDOExtendedMetaData; +import org.apache.tuscany.sdo.impl.SDOFactoryImpl.SDOEcoreFactory; +import org.apache.tuscany.sdo.model.ModelFactory; +import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl; +import org.eclipse.emf.ecore.EAnnotation; +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.EPackage.Registry; + +/** + * TODO make demand() methods synchronous? + */ +public class SDOExtendedMetaDataImpl + extends BaseSDOExtendedMetaDataImpl + implements SDOExtendedMetaData +{ + + public SDOExtendedMetaDataImpl() { + this(HelperContextImpl.getBuiltInModelRegistry()); + } + + public SDOExtendedMetaDataImpl(Registry registry) { + super(registry); + ecoreFactory = new SDOEcoreFactory(); + demandMetaData = new SDODemandMetaData(); + } + + public static class SDODemandMetaData extends DemandMetaData { + EClassifier getEObject() { return (EClassifier)((ModelFactoryImpl)ModelFactory.INSTANCE).getDataObject(); } + EClassifier getAnySimpleType() { return (EClassifier)((ModelFactoryImpl)ModelFactory.INSTANCE).getObject(); } + } + + public EPackage getPackage(String namespace) + { + if ("".equals(namespace)) namespace = null; //FB + EPackage result = registry.getEPackage(namespace); + return result == null ? super.getPackage(namespace) : result; + } + + /** + * 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); + } + + public EPackage.Registry getRegistry() + { + return registry; + } + + boolean featureNamespaceMatchingLax = true; + + public void setFeatureNamespaceMatchingLax(boolean b) { + featureNamespaceMatchingLax = b; + } + + protected boolean isFeatureNamespaceMatchingLax() { + return featureNamespaceMatchingLax; + } + + + /****************************************************************************************************** + * Following methods, getLocalAttribute & getLocalElement, ARE TEMPORARY COPIES FROM THE BASE CLASS. + * One line (the last line)in each method is changed to support lax namespace matching. + * DO NOT EDIT THESE METHODS. THEY WILL BE REMOVED WHEN WE MOVE TO EMF 2.3, WHICH FIXES THE PROBLEM. + ******************************************************************************************************/ + + public EStructuralFeature getLocalAttribute(EClass eClass, String namespace, String name) + { + EStructuralFeature result = null; + if (isFeatureKindSpecific()) + { + List allAttributes = getAllAttributes(eClass); + for (int i = 0, size = allAttributes.size(); i < size; ++i) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature) allAttributes.get(i); + if (name.equals(getName(eStructuralFeature))) + { + String featureNamespace = getNamespace(eStructuralFeature); + if (namespace == null) + { + if (featureNamespace == null) + { + return eStructuralFeature; + } + else if (result == null) + { + result = eStructuralFeature; + } + } + else if (namespace.equals(featureNamespace)) + { + return eStructuralFeature; + } + else if (featureNamespace == null && result == null) + { + result = eStructuralFeature; + } + } + } + } + else + { + for (int i = 0, size = eClass.getFeatureCount(); i < size; ++i) + { + EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature(i); + switch (getFeatureKind(eStructuralFeature)) + { + case UNSPECIFIED_FEATURE: + case ATTRIBUTE_FEATURE: + { + if (name.equals(getName(eStructuralFeature))) + { + String featureNamespace = getNamespace(eStructuralFeature); + if (namespace == null) + { + if (featureNamespace == null) + { + return eStructuralFeature; + } + else if (result == null) + { + result = eStructuralFeature; + } + } + else if (namespace.equals(featureNamespace)) + { + return eStructuralFeature; + } + else if (featureNamespace == null && result == null) + { + result = eStructuralFeature; + } + } + break; + } + } + } + } + + return isFeatureNamespaceMatchingLax() ? result : null; + } + + protected EStructuralFeature getLocalElement(EClass eClass, String namespace, String name) + { + EStructuralFeature result = null; + if (isFeatureKindSpecific()) + { + List allElements = getAllElements(eClass); + for (int i = 0, size = allElements.size(); i < size; ++i) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature) allElements.get(i); + if (name.equals(getName(eStructuralFeature))) + { + String featureNamespace = getNamespace(eStructuralFeature); + if (namespace == null) + { + if (featureNamespace == null) + { + return eStructuralFeature; + } + else if (result == null) + { + result = eStructuralFeature; + } + } + else if (namespace.equals(featureNamespace)) + { + return eStructuralFeature; + } + else if (featureNamespace == null && result == null) + { + result = eStructuralFeature; + } + } + } + } + else + { + for (int i = 0, size = eClass.getFeatureCount(); i < size; ++i) + { + EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature(i); + switch (getFeatureKind(eStructuralFeature)) + { + case UNSPECIFIED_FEATURE: + case ELEMENT_FEATURE: + { + if (name.equals(getName(eStructuralFeature))) + { + String featureNamespace = getNamespace(eStructuralFeature); + if (namespace == null) + { + if (featureNamespace == null) + { + return eStructuralFeature; + } + else if (result == null) + { + result = eStructuralFeature; + } + } + else if (namespace.equals(featureNamespace)) + { + return eStructuralFeature; + } + else if (featureNamespace == null && result == null) + { + result = eStructuralFeature; + } + } + break; + } + } + } + } + + return isFeatureNamespaceMatchingLax() ? result : null; + } +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOHelperImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOHelperImpl.java new file mode 100644 index 0000000000..02e8c47688 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOHelperImpl.java @@ -0,0 +1,489 @@ +/** + * + * 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.util.ArrayList; +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.SDOExtendedMetaData; +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.SimpleAnyTypeDataObject; +import org.apache.tuscany.sdo.api.EventListener; +import org.apache.tuscany.sdo.api.SDOHelper; +import org.apache.tuscany.sdo.api.XMLStreamHelper; +import org.apache.tuscany.sdo.impl.ClassImpl; +import org.apache.tuscany.sdo.impl.DataGraphImpl; +import org.apache.tuscany.sdo.impl.DynamicDataObjectImpl; +import org.apache.tuscany.sdo.model.ModelFactory; +import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl; +import org.apache.tuscany.sdo.spi.SDOHelperBase; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.common.util.UniqueEList; +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.EModelElement; +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.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.xmi.XMLResource; + +import commonj.sdo.impl.HelperProvider; +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.HelperContext; +import commonj.sdo.helper.TypeHelper; + +public class SDOHelperImpl extends SDOHelperBase implements SDOHelper, SDOHelper.MetaDataBuilder { + public DataObject createDataTypeWrapper(Type dataType, Object value) { + SimpleAnyTypeDataObject simpleAnyType = SDOFactory.eINSTANCE.createSimpleAnyTypeDataObject(); + simpleAnyType.setInstanceType((EDataType)dataType); + simpleAnyType.setValue(value); + return simpleAnyType; + } + + public Object createFromString(Type dataType, String literal) { + return EcoreUtil.createFromString((EDataType)dataType, literal); + } + + public String convertToString(Type dataType, Object value) { + return EcoreUtil.convertToString((EDataType)dataType, value); + } + + public Type getXSDSDOType(String xsdType) { + Type type = null; + String name = (String)xsdToSdoMappings.get(xsdType); + if (name != null) + type = (Type)((ModelFactoryImpl)ModelFactory.INSTANCE).getEClassifier(name); + return type; + } + + public 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(); + } + + public Type getJavaSDOType(Class javaClass) { + String name = (String)javaToSdoMappings.get(javaClass); + if (name != null) { + return (Type)((ModelFactoryImpl)ModelFactory.INSTANCE).getEClassifier(name); + } + return null; + } + + public boolean isRequired(Property property) { + return ((EStructuralFeature)property).isRequired(); + } + + public int getUpperBound(Property property) { + return ((EStructuralFeature)property).getUpperBound(); + } + + public boolean isMany(Property property, DataObject context) { + return FeatureMapUtil.isMany((EObject)context, (EStructuralFeature)property); + } + + public DataGraph createDataGraph() { + return SDOFactory.eINSTANCE.createDataGraph(); + } + + public void setRootObject(DataGraph dataGraph, DataObject rootObject) { + ((DataGraphImpl)dataGraph).setERootObject((EObject)rootObject); + } + + 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); + } + + static final Object LOADING_SCOPE = XMLResource.OPTION_EXTENDED_META_DATA; + + protected void registerLoadingScope(Map options, TypeHelper scope) { + Object extendedMetaData = ((TypeHelperImpl)scope).getExtendedMetaData(); + options.put(LOADING_SCOPE, extendedMetaData); + } + + public DataGraph loadDataGraph(InputStream inputStream, Map options, HelperContext scope) throws IOException { + if (scope == null) { + scope = HelperProvider.getDefaultContext(); + } + TypeHelper th = scope.getTypeHelper(); + DataGraph result = null; + if (th == null || th == TypeHelper.INSTANCE) { + result = loadDataGraph(inputStream, options); + } else if (options == null) { + options = new HashMap(); + registerLoadingScope(options, th); + result = loadDataGraph(inputStream, options); + } else if (options.containsKey(LOADING_SCOPE)) { + Object restore = options.get(LOADING_SCOPE); + registerLoadingScope(options, th); + try { + result = loadDataGraph(inputStream, options); + } finally { + options.put(LOADING_SCOPE, restore); + } + } else { + registerLoadingScope(options, th); + try { + result = loadDataGraph(inputStream, options); + } finally { + options.remove(LOADING_SCOPE); + } + } + return result; + } + + public void saveDataGraph(DataGraph dataGraph, OutputStream outputStream, Map options) throws IOException { + ((DataGraphImpl)dataGraph).getDataGraphResource().save(outputStream, options); + } + + public 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); + } + } + + public HelperContext createHelperContext() { + return new HelperContextImpl(false, null); + } + + public HelperContext createHelperContext(boolean extensibleNamespaces) { + return new HelperContextImpl(extensibleNamespaces); + } + + public HelperContext createHelperContext(Map options) { + return new HelperContextImpl(false, options); + } + + public HelperContext createHelperContext(boolean extensibleNamespaces, Map options) { + return new HelperContextImpl(extensibleNamespaces, options); + } + + + public CopyHelper createCrossScopeCopyHelper(HelperContext hc) { + return new CrossScopeCopyHelperImpl(hc.getTypeHelper()); + } + + + public XMLStreamHelper createXMLStreamHelper(HelperContext hc) { + return ((HelperContextImpl)hc).getXMLStreamHelper(); + } + + + public List getTypes(HelperContext hc, String uri) { + + EPackage ePackage = ((HelperContextImpl)hc).getExtendedMetaData().getPackage(uri); + if (ePackage != null) { + return new ArrayList(ePackage.getEClassifiers()); + } + return null; + } + + public List getOpenContentProperties(DataObject dataObject) { + List result = new UniqueEList(); + ((ClassImpl)dataObject.getType()).addOpenProperties((EObject)dataObject, result); + return result; + } + + public boolean isDocumentRoot(Type type) { + return "".equals(SDOExtendedMetaData.INSTANCE.getName((EClassifier)type)); + } + + + public Type createType(HelperContext hc, String uri, String name, boolean isDataType) { + ExtendedMetaData extendedMetaData = ((HelperContextImpl)hc).getExtendedMetaData(); + if ("".equals(uri)) + uri = null; // FB + + EPackage ePackage = extendedMetaData.getPackage(uri); + if (ePackage == null) { + ePackage = EcoreFactory.eINSTANCE.createEPackage(); + ePackage.setEFactoryInstance(new DynamicDataObjectImpl.FactoryImpl()); + ePackage.setNsURI(uri); + String packagePrefix = uri != null ? URI.createURI(uri).trimFileExtension().lastSegment() : ""; // FB + 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 void addBaseType(Type type, Type baseType) { + ((EClass)type).getESuperTypes().add(baseType); + } + + public void addAliasName(Type type, String aliasName) { + throw new UnsupportedOperationException(); // TODO: implement this + // method properly + // type.getAliasNames().add(aliasName); + } + + public void setOpen(Type type, boolean isOpen) { + if (isOpen == type.isOpen()) + return; + + if (isOpen) { + EAttribute eAttribute = (EAttribute)SDOFactory.eINSTANCE.createAttribute(); + ((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 (ExtendedMetaData.INSTANCE.getMixedFeature((EClass)type) != null) { + 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 void setSequenced(Type type, boolean isSequenced) { + // 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() != "DocumentRoot") // document root is a + // special case + throw new IllegalArgumentException(); + } + + if (isSequenced) { + EClass eClass = (EClass)type; + ExtendedMetaData.INSTANCE.setContentKind(eClass, ExtendedMetaData.MIXED_CONTENT); + EAttribute mixedFeature = (EAttribute)SDOFactory.eINSTANCE.createAttribute(); + mixedFeature.setName("mixed"); + mixedFeature.setUnique(false); + mixedFeature.setEType(EcorePackage.eINSTANCE.getEFeatureMapEntry()); + mixedFeature.setLowerBound(0); + mixedFeature.setUpperBound(-1); + // eClass.getEStructuralFeatures().add(mixedFeature); + ((ClassImpl)eClass).setSequenceFeature(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 void setAbstract(Type type, boolean isAbstract) { + ((EClass)type).setAbstract(isAbstract); + } + + public void setJavaClassName(Type type, String javaClassName) { + ((EClassifier)type).setInstanceClassName(javaClassName); + } + + public 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 ("".equals(ExtendedMetaData.INSTANCE.getName((EClass)containingType))) // DocumentRoot + // containingType? + { + ExtendedMetaData.INSTANCE.setNamespace(eStructuralFeature, containingType.getURI()); + //FB???eStructuralFeature.setUnique(false); + //FB???eStructuralFeature.setUpperBound(ETypedElement.UNSPECIFIED_MULTIPLICITY); + } + + if (ExtendedMetaData.INSTANCE.getMixedFeature((EClass)containingType) != null) { + eStructuralFeature.setDerived(true); + eStructuralFeature.setTransient(true); + eStructuralFeature.setVolatile(true); + ExtendedMetaData.INSTANCE.setFeatureKind(eStructuralFeature, ExtendedMetaData.ELEMENT_FEATURE); + } else { + // By default, a SDO property is an XSD element + ExtendedMetaData.INSTANCE.setFeatureKind(eStructuralFeature, ExtendedMetaData.ELEMENT_FEATURE); + } + + return (Property)eStructuralFeature; + } + + public void setPropertyXMLKind(Property property, boolean isXmlElement) { + if (isXmlElement) { + ExtendedMetaData.INSTANCE.setFeatureKind((EStructuralFeature)property, ExtendedMetaData.ELEMENT_FEATURE); + } + else { + ExtendedMetaData.INSTANCE.setFeatureKind((EStructuralFeature)property, ExtendedMetaData.ATTRIBUTE_FEATURE); + } + } + + + public Property createOpenContentProperty(HelperContext hc, String uri, String name, Type type) + { + ExtendedMetaData extendedMetaData = ((HelperContextImpl)hc).getExtendedMetaData(); + + // get/create document root + EPackage ePackage = extendedMetaData.getPackage(uri); + Type documentRoot = ePackage != null ? (Type)extendedMetaData.getType(ePackage, "") : null; + if (documentRoot == null) { + documentRoot = createType(hc, uri, null, false); + } + + // Determine if property already exists + Property newProperty = documentRoot.getProperty(name); + if (newProperty == null) { + // Create the new property 'under' the document root..... + newProperty = createProperty(documentRoot, name, type); + } else { + // if property already exists, validate the expected type + if (!newProperty.getType().equals(type)) + throw new IllegalArgumentException(); + } + return newProperty; + } + + + public void addAliasName(Property property, String aliasName) { + throw new UnsupportedOperationException(); // TODO: implement this + // method properly + // property.getAliasNames().add(aliasName); + } + + public void setMany(Property property, boolean isMany) { + ((EStructuralFeature)property).setUpperBound(isMany ? EStructuralFeature.UNBOUNDED_MULTIPLICITY : 1); + } + + public void setContainment(Property property, boolean isContainment) { + ((EReference)property).setContainment(isContainment); + } + + public void setDefault(Property property, String defaultValue) { + ((EStructuralFeature)property).setDefaultValueLiteral(defaultValue); + } + + public void setReadOnly(Property property, boolean isReadOnly) { + ((EStructuralFeature)property).setChangeable(!isReadOnly); + } + + public void setOpposite(Property property, Property opposite) { + ((EReference)property).setEOpposite((EReference)opposite); + } + + public void addTypeInstanceProperty(Type definedType, Property instanceProperty, Object value) { + addInstanceProperty((EModelElement)definedType, instanceProperty, value); + } + + public void addPropertyInstanceProperty(Property definedProperty, Property instanceProperty, Object value) { + addInstanceProperty((EModelElement)definedProperty, instanceProperty, value); + } + + protected void addInstanceProperty(EModelElement metaObject, Property property, Object value) { + String uri = property.getContainingType().getURI(); + EAnnotation eAnnotation = metaObject.getEAnnotation(uri); + if (eAnnotation == null) { + eAnnotation = EcoreFactory.eINSTANCE.createEAnnotation(); + eAnnotation.setSource(uri); + metaObject.getEAnnotations().add(eAnnotation); + } + // TODO if (property.isMany()) ... // convert list of values + String stringValue = convertToString(property.getType(), value); + eAnnotation.getDetails().put(property.getName(), stringValue); + } + + public void addChangeListener(DataObject quote, EventListener listener) { + Adapter l = (Adapter)listener; + ((Notifier)quote).eAdapters().add(listener); + } + +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOXSDEcoreBuilder.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOXSDEcoreBuilder.java new file mode 100644 index 0000000000..906a35a4c8 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOXSDEcoreBuilder.java @@ -0,0 +1,831 @@ +/** + * + * 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.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import javax.xml.XMLConstants; + +import org.apache.tuscany.sdo.SDOExtendedMetaData; +import org.apache.tuscany.sdo.impl.AttributeImpl; +import org.apache.tuscany.sdo.impl.SDOFactoryImpl.SDOEcoreFactory; +import org.apache.tuscany.sdo.model.ModelFactory; +import org.apache.tuscany.sdo.api.SDOUtil; +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +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.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.EcoreUtil.UsageCrossReferencer; +import org.eclipse.xsd.XSDComplexTypeDefinition; +import org.eclipse.xsd.XSDComponent; +import org.eclipse.xsd.XSDConcreteComponent; +import org.eclipse.xsd.XSDElementDeclaration; +import org.eclipse.xsd.XSDFeature; +import org.eclipse.xsd.XSDNamedComponent; +import org.eclipse.xsd.XSDParticle; +import org.eclipse.xsd.XSDSchema; +import org.eclipse.xsd.XSDSimpleTypeDefinition; +import org.eclipse.xsd.XSDTerm; +import org.eclipse.xsd.XSDTypeDefinition; +import org.eclipse.xsd.ecore.EcoreXMLSchemaBuilder; +import org.eclipse.xsd.util.XSDResourceFactoryImpl; +import org.eclipse.xsd.util.XSDResourceImpl; +import org.eclipse.xsd.util.XSDSchemaLocator; +import org.w3c.dom.Element; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; + +public class SDOXSDEcoreBuilder extends BaseSDOXSDEcoreBuilder +{ + protected boolean replaceConflictingTypes = false; + + public SDOXSDEcoreBuilder(ExtendedMetaData extendedMetaData, boolean replaceConflictingTypes) + { + super(extendedMetaData); + ecoreFactory = new SDOEcoreFactory(); + this.replaceConflictingTypes = replaceConflictingTypes; + populateTypeToTypeObjectMap((EPackage)ModelFactory.INSTANCE); + } + + /** + * 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; + } + + /* + * Required for Java 1.4.2 support + * Node#lookupPrefix is only available since DOM Level 3 (Java 5) + * and it doesn't return rebound prefix. + * XSDConstants.lookupQualifier isn't supposed to return rebound prefix either. + * This lookupPrefix returns any bound prefix no matter rebound to other NameSpace or not, for {@link #getEPackage}. + */ + static protected String lookupPrefix(Node element, String namespaceURI) { + String prefix = element.getPrefix(); + if (prefix != null && namespaceURI != null && namespaceURI.equals(element.getNamespaceURI())) + return prefix; + NamedNodeMap attributes = element.getAttributes(); + if (attributes != null) + for (int index = attributes.getLength(); index != 0;) { + Node attribute = attributes.item(--index); + if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(attribute.getNamespaceURI()) && attribute.getNodeValue().equals(namespaceURI) + && XMLConstants.XMLNS_ATTRIBUTE.equals(attribute.getPrefix())) + return attribute.getLocalName(); + } + for (Node parent; (parent = element.getParentNode()) != null; element = parent) + if (parent.getNodeType() == Node.ELEMENT_NODE) + return lookupPrefix(parent, namespaceURI); + return null; + } + + public EPackage getEPackage(XSDNamedComponent xsdNamedComponent) { + XSDSchema containingXSDSchema = xsdNamedComponent.getSchema(); + String targetNamespace = containingXSDSchema == null ? + xsdNamedComponent.getTargetNamespace() : containingXSDSchema.getTargetNamespace(); + EPackage ePackage = (EPackage) targetNamespaceToEPackageMap.get(targetNamespace); + if (ePackage != null) + return ePackage; + ePackage = super.getEPackage(xsdNamedComponent); + String nsPrefix = lookupPrefix(xsdNamedComponent.getElement(), targetNamespace); + if (nsPrefix != null) + ePackage.setNsPrefix(nsPrefix); + return ePackage; + } + + public EClassifier getEClassifier(XSDTypeDefinition xsdTypeDefinition) { + EClassifier eClassifier = null; + if (xsdTypeDefinition != null) + { + if (rootSchema.getSchemaForSchemaNamespace().equals(xsdTypeDefinition.getTargetNamespace())) { + eClassifier = + getBuiltInEClassifier(xsdTypeDefinition.getURI(), xsdTypeDefinition.getName()); + } + else if (xsdTypeDefinition.getContainer() == null) { + EPackage pkg = extendedMetaData.getPackage(xsdTypeDefinition.getTargetNamespace()); + if(pkg != null) { + eClassifier = pkg.getEClassifier(xsdTypeDefinition.getName()); + } + } + } + if (eClassifier == null) { + eClassifier = super.getEClassifier(xsdTypeDefinition); + } + return eClassifier; + } + + public EDataType getEDataType(XSDSimpleTypeDefinition xsdSimpleTypeDefinition) { + EDataType eClassifier = null; + if (xsdSimpleTypeDefinition != null && rootSchema.getSchemaForSchemaNamespace().equals(xsdSimpleTypeDefinition.getTargetNamespace())) { + eClassifier = + (EDataType)getBuiltInEClassifier( + xsdSimpleTypeDefinition.getURI(), + xsdSimpleTypeDefinition.getName()); + } else { + eClassifier = super.getEDataType(xsdSimpleTypeDefinition); + } + return (EDataType)eClassifier; + } + + + /* (non-Javadoc) + * @see org.eclipse.xsd.ecore.XSDEcoreBuilder#createResourceSet() + */ + protected ResourceSet createResourceSet() { + ResourceSet result = super.createResourceSet(); + result.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", new XSDResourceFactoryImpl()); + result.getAdapterFactories().add(new XSDSchemaAdapterFactoryImpl()); + + EList resources = result.getResources(); + for (Iterator iter = targetNamespaceToEPackageMap.entrySet().iterator(); iter.hasNext();) { + Map.Entry mapEntry = (Map.Entry)iter.next(); + EPackage ePackage = (EPackage)mapEntry.getValue(); + Resource resource = ePackage.eResource(); + if (resource != null) { + resources.add(resource); + } + } + return result; + } + + protected EClassifier getBuiltInEClassifier(String namespace, String name) + { + EClassifier eClassifier = null; + if ("base64Binary".equals(name)) { + eClassifier = (EClassifier)AttributeImpl.INTERNAL_BASE64_BYTES; + } + else if ("QName".equals(name)) { + eClassifier = (EClassifier)AttributeImpl.INTERNAL_QNAME; + } + else { + eClassifier = (EClassifier)SDOUtil.getXSDSDOType(name); + } + + if (eClassifier == null) + eClassifier = super.getBuiltInEClassifier(namespace, name); + return eClassifier; + } + + private void updateReferences(EObject oldEObject, EObject newEObject) + { + Collection usages = UsageCrossReferencer.find(oldEObject, targetNamespaceToEPackageMap.values()); + for (Iterator iter = usages.iterator(); iter.hasNext(); ) + { + EStructuralFeature.Setting setting = (EStructuralFeature.Setting)iter.next(); + EObject referencingEObject = setting.getEObject(); + EStructuralFeature eStructuralFeature = setting.getEStructuralFeature(); + if (eStructuralFeature.isChangeable()) + { + if (eStructuralFeature.isMany()) + { + List refList = (List)referencingEObject.eGet(eStructuralFeature); + int refIndex = refList.indexOf(oldEObject); + if (refIndex != -1) refList.set(refIndex, newEObject); + } + else + { + referencingEObject.eSet(eStructuralFeature, newEObject); + } + } + } + } + + private XSDTypeDefinition getXSDTypeDefinition(EClassifier eClassifier) + { + //TODO Maybe we should create a reverse (eModelElementToXSDComponentMap) for better performance. + // Use a HashMap subclass for xsdComponentToEModelElementMap that overrides put() to also add the + // reverse mapping in eModelElementToXSDComponentMap + XSDTypeDefinition xsdTypeDefinition = null; + for (Iterator i = xsdComponentToEModelElementMap.entrySet().iterator(); i.hasNext(); ) + { + Entry e = (Entry) i.next(); + if (eClassifier == e.getValue()) + { + xsdTypeDefinition = (XSDTypeDefinition)e.getKey(); + break; + } + } + return xsdTypeDefinition; + } + + private boolean sameType(XSDTypeDefinition t1, XSDTypeDefinition t2) + { + XSDConcreteComponent n1 = t1, n2 = t2; + while (n1 != null && n2 != null) + { + if (n1.eClass() != n2.eClass()) break; + if (n1 instanceof XSDNamedComponent /*&& n2 instanceof XSDNamedComponent*/) + { + String s1 = ((XSDNamedComponent)n1).getName(); + String s2 = ((XSDNamedComponent)n2).getName(); + if (s1 == null ? s1 != s2 : !s1.equals(s2)) break; + } + n1 = n1.getContainer(); + n2 = n2.getContainer(); + } + return n1 == null && n2 == null; + } + + protected void removeDuplicateEClassifier(EClassifier eClassifier, XSDTypeDefinition xsdTypeDefinition) + { + EPackage ePackage = eClassifier.getEPackage(); + List eClassifiers = ePackage.getEClassifiers(); + String name = eClassifier.getName(); + int size = eClassifiers.size(); + for (int index = eClassifiers.indexOf(eClassifier); ++index < size; ) + { + EClassifier nextEClassifier = (EClassifier)eClassifiers.get(index); + if (!name.equals(nextEClassifier.getName())) break; + if (extendedMetaData.getName(eClassifier).equals(extendedMetaData.getName(nextEClassifier))) + { + XSDTypeDefinition nextXSDTypeDefinition = getXSDTypeDefinition(nextEClassifier); + if (!sameType(nextXSDTypeDefinition, xsdTypeDefinition)) + { + //System.out.println("###EClassifier mismatch: "); + //System.out.println(" old: " + extendedMetaData.getName(nextEClassifier)); + //System.out.println(" new: " + extendedMetaData.getName(eClassifier)); + continue; + } + eClassifiers.remove(index); + updateReferences(nextEClassifier, eClassifier); + break; + } + } + } + + protected void removeDuplicateDocumentRootFeature(EClass eClass, EStructuralFeature eStructuralFeature) + { + List eStructuralFeatures = eClass.getEStructuralFeatures(); + int last = eStructuralFeatures.size() - 1; + String name = extendedMetaData.getName(eStructuralFeature); + for (int index = 0; index < last; index++) + { + EStructuralFeature otherEStructuralFeature = (EStructuralFeature)eStructuralFeatures.get(index); + if (name.equals(extendedMetaData.getName(otherEStructuralFeature))) + { + if (otherEStructuralFeature.eClass() != eStructuralFeature.eClass()) + { + //System.out.println("###EStructuralFeature mismatch: "); + //System.out.println(" old: " + extendedMetaData.getName(otherEStructuralFeature)); + //System.out.println(" new: " + extendedMetaData.getName(eStructuralFeature)); + continue; + } + eStructuralFeatures.remove(index); + updateReferences(otherEStructuralFeature, eStructuralFeature); + break; + } + } + } + + public EClass computeEClass(XSDComplexTypeDefinition xsdComplexTypeDefinition) { + if (xsdComplexTypeDefinition == null) return super.computeEClass(xsdComplexTypeDefinition); + EPackage ePackage = (EPackage)targetNamespaceToEPackageMap.get(xsdComplexTypeDefinition.getTargetNamespace()); + if (ePackage != null && TypeHelperImpl.getBuiltInModels().contains(ePackage)) { + EClassifier eclassifier = ePackage.getEClassifier(xsdComplexTypeDefinition.getName()); + if (eclassifier != null) return (EClass)eclassifier; + } + EClass eClass = super.computeEClass(xsdComplexTypeDefinition); + if (replaceConflictingTypes) removeDuplicateEClassifier(eClass, xsdComplexTypeDefinition); + String aliasNames = getEcoreAttribute(xsdComplexTypeDefinition.getElement(), "aliasName"); + if (aliasNames != null) { + SDOExtendedMetaData.INSTANCE.setAliasNames(eClass, aliasNames); + } + return eClass; + } + + protected EClassifier computeEClassifier(XSDTypeDefinition xsdTypeDefinition) { + if (xsdTypeDefinition == null) return super.computeEClassifier(xsdTypeDefinition); + EPackage ePackage = (EPackage)targetNamespaceToEPackageMap.get(xsdTypeDefinition.getTargetNamespace()); + if (ePackage != null && TypeHelperImpl.getBuiltInModels().contains(ePackage)) { + EClassifier eclassifier = ePackage.getEClassifier(xsdTypeDefinition.getName()); + if (eclassifier != null) return eclassifier; + } + 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) { + if (xsdSimpleTypeDefinition == null) return super.computeEDataType(xsdSimpleTypeDefinition); + EPackage ePackage = (EPackage)targetNamespaceToEPackageMap.get(xsdSimpleTypeDefinition.getTargetNamespace()); + if (ePackage != null && TypeHelperImpl.getBuiltInModels().contains(ePackage)) { + EClassifier eclassifier = ePackage.getEClassifier(xsdSimpleTypeDefinition.getName()); + if (eclassifier != null) return (EDataType)eclassifier; + } + EDataType eDataType = super.computeEDataType(xsdSimpleTypeDefinition); + if (replaceConflictingTypes) removeDuplicateEClassifier(eDataType, 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); + + if (xsdComponent instanceof XSDParticle) { + XSDTerm xsdTerm = ((XSDParticle)xsdComponent).getTerm(); + if (xsdTerm instanceof XSDElementDeclaration && ((XSDElementDeclaration)xsdTerm).isNillable()) + EcoreUtil.setAnnotation(feature, ExtendedMetaData.ANNOTATION_URI, "nillable", "true"); + } + + //FB What is the following for? + if (feature instanceof EReference) + { + EReference eReference = (EReference)feature; + if (xsdComponent != null && xsdComponent instanceof XSDParticle) + { + XSDTerm xsdTerm = ((XSDParticle)xsdComponent).getTerm(); + if (xsdTerm instanceof XSDElementDeclaration) + { + XSDTypeDefinition elementTypeDefinition = getEffectiveTypeDefinition(xsdComponent, (XSDElementDeclaration)xsdTerm); + EClassifier eClassifier = getEClassifier(elementTypeDefinition); + if (elementTypeDefinition instanceof XSDSimpleTypeDefinition && eClassifier instanceof EClass) + { + eReference.setContainment(true); + } + } + } + } + + feature.setName(name); // this is needed because super.createFeature() does EMF name mangling (toLower) + + if (replaceConflictingTypes && "".equals(extendedMetaData.getName(eClass))) + removeDuplicateDocumentRootFeature(eClass, feature); + + 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. + } + + private XSDSchema loadEPackage(EPackage ePackage) + { + XSDSchema ePackageXSDSchema = null; + XSDEcoreXMLSchemaBuilder xmlSchemaBuilder = new XSDEcoreXMLSchemaBuilder(); + Collection xmlSchemas = xmlSchemaBuilder.generate(ePackage); + xsdComponentToEModelElementMap.putAll(xmlSchemaBuilder.getXSDComponentToEModelElementMap()); + for (Iterator iter = xmlSchemas.iterator(); iter.hasNext();) { + Object xmlSchema = (Object)iter.next(); + if (xmlSchema instanceof XSDSchema) + { + EPackage xmlSchemaEPackage = (EPackage) xsdComponentToEModelElementMap.get(xmlSchema); + addEPackageToXSDSchemaMapEntry(xmlSchemaEPackage, (XSDSchema) xmlSchema); + if (xmlSchemaEPackage.equals(ePackage)) + { + ePackageXSDSchema = (XSDSchema) xmlSchema; + } + } + } + Map ePackageToXSDSchemaMap = xmlSchemaBuilder.getEPackageToXSDSchemaMap(); + for (Iterator iter = ePackageToXSDSchemaMap.entrySet().iterator(); iter.hasNext();) { + Map.Entry mapEntry = (Map.Entry)iter.next(); + EPackage xmlSchemaEPackage = (EPackage) mapEntry.getKey(); + XSDSchema xmlSchema = (XSDSchema) mapEntry.getValue(); + addEPackageToXSDSchemaMapEntry(xmlSchemaEPackage, xmlSchema); + } + return ePackageXSDSchema; + } + + private void addEPackageToXSDSchemaMapEntry(EPackage ePackage, XSDSchema xsdSchema) + { + targetNamespaceToEPackageMap.put(ePackage.getNsURI(), ePackage); + populateTypeToTypeObjectMap(ePackage); + xsdSchemas.add(xsdSchema); + } + + private static class XSDEcoreXMLSchemaBuilder extends EcoreXMLSchemaBuilder + { + public XSDEcoreXMLSchemaBuilder() + { + super(); + } + + public Map getXSDComponentToEModelElementMap() + { + return xsdComponentToEModelElementMap; + } + + public Map getEPackageToXSDSchemaMap() + { + return ePackageToXSDSchemaMap; + } + + protected void additionalProcessing(EClass cls, XSDComplexTypeDefinition xsdCTDComplexTypeDefinition) + { + // remove element definition + for(Iterator iter = xsdComponentToEModelElementMap.entrySet().iterator(); iter.hasNext();) + { + Map.Entry mapEntry = (Map.Entry)iter.next(); + if (mapEntry.getValue().equals(cls) && + mapEntry.getKey() instanceof XSDElementDeclaration) + { + xsdComponentToEModelElementMap.remove(mapEntry.getKey()); + break; + } + } + } + } + + class XSDSchemaAdapterFactoryImpl extends AdapterFactoryImpl + { + protected SchemaLocator schemaLocator = new SchemaLocator(); + + public boolean isFactoryForType(Object type) + { + return type == XSDSchemaLocator.class; + } + + public Adapter adaptNew(Notifier target, Object type) + { + return schemaLocator; + } + + class SchemaLocator extends XSDResourceImpl.SchemaLocator + { + public XSDSchema locateSchema(XSDSchema xsdSchema, String namespaceURI, + String rawSchemaLocationURI, String resolvedSchemaLocation) + { + if (targetNamespaceToEPackageMap.containsKey(namespaceURI)) + { + for (Iterator iter = xsdSchemas.iterator(); iter.hasNext();) { + XSDSchema schema = (XSDSchema)iter.next(); + String targetNamespace = schema.getTargetNamespace(); + if (targetNamespace != null && targetNamespace.equals(namespaceURI)) + { + return schema; + } + } + } + if (namespaceURI != null && !namespaceURI.equals(xsdSchema.getTargetNamespace())) + { + EPackage ePackage = extendedMetaData.getPackage(namespaceURI); + if (ePackage != null) + { + XSDSchema schema = loadEPackage(ePackage); + return schema; + } + } + return super.locateSchema(xsdSchema, namespaceURI, rawSchemaLocationURI, resolvedSchemaLocation); + } + } + } + +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/SchemaBuilder.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/SchemaBuilder.java new file mode 100644 index 0000000000..8ff7769041 --- /dev/null +++ b/sandbox/kgoodson/events/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 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.createHelperContext().getXSDHelper(); + + 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/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java new file mode 100644 index 0000000000..1aa2ae466b --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/TypeHelperImpl.java @@ -0,0 +1,317 @@ +/** + * + * 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.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +import org.apache.tuscany.sdo.api.SDOUtil; +import org.apache.tuscany.sdo.model.ModelFactory; +import org.apache.tuscany.sdo.model.internal.InternalFactory; +import org.apache.tuscany.sdo.model.java.JavaFactory; +import org.apache.tuscany.sdo.model.xml.XMLFactory; +import org.apache.tuscany.sdo.model.xml.impl.XMLFactoryImpl; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.eclipse.emf.ecore.EClass; +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.Sequence; +import commonj.sdo.Type; +import commonj.sdo.helper.HelperContext; +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 HelperContext helperContext; + private ExtendedMetaData extendedMetaData; + + static protected Set builtInModels = null; + + static public Set getBuiltInModels() { + if (builtInModels == null) { + builtInModels = new HashSet(); + builtInModels.add(ModelFactory.INSTANCE); + builtInModels.add(JavaFactory.INSTANCE); + builtInModels.add(XMLFactory.INSTANCE); + builtInModels.add(InternalFactory.INSTANCE); + } + return TypeHelperImpl.builtInModels; + } + + public ExtendedMetaData getExtendedMetaData() { + return extendedMetaData; + } + + // JIRA-helperContext + public TypeHelperImpl(HelperContext hc) { + this.helperContext = hc; + this.extendedMetaData = ((HelperContextImpl)hc).extendedMetaData; + + // Register the standard (predefined) SDO types + getBuiltInModels(); // Simply accessing EMF packages causes auto + // registration in global registry + + // MetadataFactoryImpl.init(); //FB do we want to preregister this? + } + + + 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; + } + + private Method getGetStaticTypeMethod(Class classObj) { + try { + Method method = classObj.getMethod("getStaticType", null); + return method; + } + catch (Exception e) { + return null; + } + } + + public Type getType(Class interfaceClass) { + Type type = SDOUtil.getJavaSDOType(interfaceClass); + if (type != null) { + return type; + } + + Class sdoTypeImplClass = interfaceClass; + Method getStaticTypeMethod = getGetStaticTypeMethod(interfaceClass); + if (getStaticTypeMethod == null) { + String sdoTypeImplClassName = interfaceClass.getName(); + if (sdoTypeImplClassName.endsWith("Impl") == false) { + sdoTypeImplClass = DataObjectUtil.getImplementationClass(interfaceClass, false); + if (sdoTypeImplClass == null) { + return null; + } + + getStaticTypeMethod = getGetStaticTypeMethod(sdoTypeImplClass); + if (getStaticTypeMethod == null) { + return null; + } + } + else { + return null; + } + } + + try { + Object implInstance = sdoTypeImplClass.newInstance(); + return (Type)getStaticTypeMethod.invoke(implInstance, null); + } + catch (Exception e) { + 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(helperContext, modeledType.getUri(), modeledType.getName(), isDataType); + if (definedType == null) { + // If type already defined, return 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); + + initializeProperty(definedProperty, modeledProperty); + } + + // define a global property to accompany the type definition + if (!SDOUtil.isDocumentRoot(definedType)) { + String propertyName = definedType.getName(); + if (!Character.isLowerCase(propertyName.charAt(0))) { + propertyName = propertyName.substring(0, 1).toLowerCase() + propertyName.substring(1); + } + Property globalProperty = + SDOUtil.createOpenContentProperty(helperContext, definedType.getURI(), propertyName, definedType); + SDOUtil.setContainment(globalProperty, true); + } + } // if (!isDataType) + + addTypeInstanceProperties(definedType, (DataObject)modeledType); + + return definedType; + } + + protected void addTypeInstanceProperties(Type definedType, DataObject modeledType) { + List instanceProperties = SDOUtil.getOpenContentProperties(modeledType); + for (Iterator iter = instanceProperties.iterator(); iter.hasNext();) { + Property property = (Property)iter.next(); + SDOUtil.addTypeInstanceProperty(definedType, property, modeledType.get(property)); + } + } + + protected void addPropertyInstanceProperties(Property definedProperty, DataObject modeledProperty) { + List instanceProperties = SDOUtil.getOpenContentProperties(modeledProperty); + for (Iterator iter = instanceProperties.iterator(); iter.hasNext();) { + Property property = (Property)iter.next(); + SDOUtil.addPropertyInstanceProperty(definedProperty, property, modeledProperty.get(property)); + } + } + + 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); + } + } + + protected void initializeProperty(Property newProperty, org.apache.tuscany.sdo.model.Property modeledProperty) { + 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 (newProperty.getType().isDataType()) { + // Setting xmlElement to FALSE only makes sense here + Boolean isXmlElement = Boolean.TRUE; // By default, a SDO property is an XSD element + Sequence anyAttr = modeledProperty.getAnyAttribute(); + for (int i=0; i + * + * + * created from this XML Schema fragment: + * + * + * + * + * Upon loading this XMLDocument: + * DataObject is an instance of Type PurchaseOrderType. + * RootElementURI is null because the XSD has no targetNamespace URI. + * RootElementName is purchaseOrder. + * Encoding is null because the document did not specify an encoding. + * XMLDeclaration is true because the document contained an XML declaration. + * XMLVersion is 1.0 + * SchemaLocation and noNamespaceSchemaLocation are null because they are + * not specified in the document. + * + * When saving the root element, if the type of the root dataObject is not the + * type of global element specified by rootElementURI and rootElementName, + * or if a global element does not exist for rootElementURI and rootElementName, + * then an xsi:type declaration is written to record the root DataObject's Type. + * + * When loading the root element and an xsi:type declaration is found + * it is used as the type of the root DataObject. In this case, + * if validation is not being performed, it is not an error if the + * rootElementName is not a global element. + */ +public class XMLDocumentImpl implements XMLDocument +{ + protected ExtendedMetaData extendedMetaData; + + protected EObject rootObject; + + protected XMLResource resource; + + protected EStructuralFeature rootElement; + + protected EObject documentRoot; + + protected 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 + { + save(outputStream, null, options); + } + + 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 save(Node node, Object options) throws IOException + { + save(null, (Document)node, options); + } + + protected void save(OutputStream outputStream, Document document, Object options) throws IOException + { + EObject oldContainer = null; + Resource oldResource = null; + EReference oldContainmentReference = null; + int oldContainmentIndex = -1; + + if (documentRoot != null) + { + oldContainer = rootObject.eContainer(); + if (oldContainer != null) + oldContainmentReference = rootObject.eContainmentFeature(); + else + oldResource = rootObject.eResource(); + if (oldContainer != documentRoot || oldContainmentReference != rootElement) + { + if (oldResource != null) + { + oldContainmentIndex = oldResource.getContents().indexOf(rootObject); + oldResource.getContents().remove(oldContainmentIndex); + } + else if (oldContainmentReference != null && FeatureMapUtil.isMany(oldContainer, oldContainmentReference)) + oldContainmentIndex = ((List)oldContainer.eGet(oldContainmentReference)).indexOf(rootObject); + + Object rootValue = + rootElement instanceof EAttribute && rootObject instanceof SimpleAnyTypeDataObject ? + ((SimpleAnyTypeDataObject)rootObject).getValue() : rootObject; + + documentRoot.eSet(rootElement, rootValue); + } + } + + if (outputStream != null) + resource.save(outputStream, (Map)options); + else // if (document != null) + resource.save(document, (Map)options, null); + + if (oldResource != null) + { + oldResource.getContents().add(oldContainmentIndex, rootObject); + } + if (rootElement instanceof EReference) + { + if (oldContainer != null) + { + if (oldContainer != documentRoot || oldContainmentReference != rootElement) + { + if (FeatureMapUtil.isMany(oldContainer, oldContainmentReference)) + ((List)oldContainer.eGet(oldContainmentReference)).add(oldContainmentIndex, rootObject); + else + oldContainer.eSet(oldContainmentReference, rootObject); + } + } + else if (documentRoot != null) + { + documentRoot.eSet(rootElement, null); + } + } + } + + 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 final void load(Node node, Object options) throws IOException { + resource.load(node, (Map)options); + initLoadedRoot(); + } + + protected final void load(XMLStreamReader reader, Map options) throws IOException + { + ((SDOXMLResourceImpl)resource).load(reader, options); + 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(); + } + + /** + * @return a Map object with key-value pair where key is the DataObject and value contains the info + * about the unknown properties for the DataObject + */ + public Map getUnknownProperties(){ + return resource.getEObjectToExtensionMap(); + } + + 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 + if (rootObject == null) + rootObject = ((SDOXMLResourceImpl) resource).root; + } + 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/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLHelperImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLHelperImpl.java new file mode 100644 index 0000000000..1909a350f2 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLHelperImpl.java @@ -0,0 +1,191 @@ +/** + * + * 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 java.util.Map; + +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.dom.DOMResult; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.sax.SAXResult; +import javax.xml.transform.sax.SAXSource; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; + +import org.eclipse.emf.ecore.util.ExtendedMetaData; +import org.xml.sax.InputSource; + +import commonj.sdo.DataObject; +import commonj.sdo.helper.HelperContext; +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 { + protected HelperContext helperContext; + private ExtendedMetaData extendedMetaData; + + + public XMLHelperImpl(HelperContext hc) { + this.helperContext = hc; + this.extendedMetaData = ((HelperContextImpl)hc).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(String inputString, Object options) { + try { + return load(new StringReader(inputString), null, options); + } catch (IOException e) { + throw new RuntimeException(e); // should never happen + } + } + + public XMLDocument load(InputStream inputStream) throws IOException { + return load(inputStream, null, null); + } + + private Object checkSetOptions(Object options) throws IOException { + if (options != null && !(options instanceof Map)) { + throw new IOException("Invalid load options!"); + } + + if (helperContext != null) { + return ((HelperContextImpl)helperContext).getMergedOption((Map)options); + } else {// null is acceptable as it will be ignored + return options; + } + } + + public XMLDocument load(InputStream inputStream, String locationURI, Object options) throws IOException { + options = checkSetOptions(options); + 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); + options = checkSetOptions(options); + document.load(inputReader, locationURI, options); + return document; + } + + public XMLDocument load(Source source, String locationURI, Object options) throws IOException { + options = checkSetOptions(options); + if (source instanceof DOMSource) { + DOMSource domSource = (DOMSource)source; + XMLDocumentImpl document = new XMLDocumentImpl(extendedMetaData, options); + document.load(domSource.getNode(), options); + return document; + } else if (source instanceof SAXSource) { + XMLDocumentImpl document = new XMLDocumentImpl(extendedMetaData, options); + InputSource inputSource = SAXSource.sourceToInputSource(source); + document.load(inputSource, locationURI, options); + return document; + } else if (source instanceof StreamSource) { + return load(((StreamSource)source).getInputStream(), locationURI, options); + } else { + throw new UnsupportedOperationException(); + } + } + + 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 String save(DataObject dataObject, String rootElementURI, String rootElementName, Object options) { + StringWriter stringWriter = new StringWriter(); + try { + save(createDocument(dataObject, rootElementURI, rootElementName), stringWriter, options); + 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(DataObject dataObject, + String rootElementURI, + String rootElementName, + OutputStream outputStream, + Object options) throws IOException { + save(createDocument(dataObject, rootElementURI, rootElementName), outputStream, null); + } + + public void save(XMLDocument xmlDocument, OutputStream outputStream, Object options) throws IOException { + options = checkSetOptions(options); + ((XMLDocumentImpl)xmlDocument).save(outputStream, options); + } + + public void save(XMLDocument xmlDocument, Writer outputWriter, Object options) throws IOException { + options = checkSetOptions(options); + ((XMLDocumentImpl)xmlDocument).save(outputWriter, options); + } + + public void save(XMLDocument xmlDocument, Result outputResult, Object options) throws IOException { + options = checkSetOptions(options); + if (outputResult instanceof DOMResult) { + ((XMLDocumentImpl)xmlDocument).save(((DOMResult)outputResult).getNode(), options); + } else if (outputResult instanceof SAXResult) { + throw new UnsupportedOperationException(); + } else if (outputResult instanceof StreamResult) { + save(xmlDocument, ((StreamResult)outputResult).getOutputStream(), options); + } else { + throw new UnsupportedOperationException(); + } + } + + public XMLDocument createDocument(DataObject dataObject, String rootElementURI, String rootElementName) { + return new XMLDocumentImpl(extendedMetaData, dataObject, rootElementURI, rootElementName); + } + + public HelperContext getHelperContext() { + return helperContext; + } +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLStreamHelper.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLStreamHelper.java new file mode 100644 index 0000000000..851c7d93dd --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLStreamHelper.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.helper; + +/** + * @deprecated + */ +public interface XMLStreamHelper extends org.apache.tuscany.sdo.api.XMLStreamHelper { +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLStreamHelperImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLStreamHelperImpl.java new file mode 100644 index 0000000000..7b0c2fc597 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/XMLStreamHelperImpl.java @@ -0,0 +1,152 @@ +/** + * + * 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.util.Iterator; +import java.util.Map; +import java.util.Set; +import javax.xml.namespace.QName; +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.apache.tuscany.sdo.api.XMLStreamHelper; +import org.eclipse.emf.ecore.resource.Resource; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.XMLDocument; + +/** + * @version $Rev$ $Date$ + */ +public class XMLStreamHelperImpl implements XMLStreamHelper { + protected HelperContext helperContext; + + public XMLStreamHelperImpl(HelperContext hc) { + this.helperContext = hc; + } + + private Map checkSetOptions(Map options) { + if (helperContext != null) { + return ((HelperContextImpl)helperContext).getMergedOption(options); + } else {// null is acceptable as it will be ignored + return options; + } + } + + public XMLDocument load(XMLStreamReader reader) throws XMLStreamException, IllegalStateException { + if (reader.getEventType() != XMLStreamConstants.START_DOCUMENT) + throw new IllegalStateException(); + + return loadDocument(reader, null); + } + + public void save(XMLDocument document, XMLStreamWriter writer) throws XMLStreamException { + XMLStreamReader reader = createXMLStreamReader(document); + new XMLStreamSerializer().serialize(reader, writer); + } + + public void save(XMLDocument document, XMLStreamWriter writer, Map options) throws XMLStreamException { + XMLStreamReader reader = createXMLStreamReader(document); + options = checkSetOptions(options); + new XMLStreamSerializer().serialize(reader, writer, options); + } + + public XMLStreamReader createXMLStreamReader(XMLDocument document) throws XMLStreamException { + XMLStreamReader reader = + new DataObjectXMLStreamReader(document.getRootObject(), document.getRootElementURI(), document + .getRootElementName(), helperContext.getTypeHelper()); + // Wrap the reader so that its position will be START_ELEMENT + return new XMLDocumentStreamReader(reader); + + } + + public final DataObject loadObject(XMLStreamReader reader, Map options) 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, options).getRootObject(); + } + + public DataObject loadObject(XMLStreamReader reader) throws XMLStreamException, IllegalStateException { + return loadObject(reader, null); + } + + public void saveObject(DataObject sdo, XMLStreamWriter writer) throws XMLStreamException { + XMLStreamReader reader = createXMLStreamReader(sdo); + new XMLStreamSerializer().serialize(new XMLDocumentStreamReader(reader), writer); + } + + public void saveObject(DataObject sdo, XMLStreamWriter writer, Map options) throws XMLStreamException { + XMLStreamReader reader = createXMLStreamReader(sdo); + options = checkSetOptions(options); + new XMLStreamSerializer().serialize(new XMLDocumentStreamReader(reader), writer, options); + } + + 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, helperContext.getTypeHelper()); + } + + protected XMLDocument loadDocument(XMLStreamReader reader, Map options) throws XMLStreamException { + try { + XMLDocumentImpl document = new XMLDocumentImpl(((HelperContextImpl)helperContext).extendedMetaData, null); + options = checkSetOptions(options); + document.load(reader, options); + 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); // ???? + } + } + + public HelperContext getHelperContext() { + return helperContext; + } +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/XSDHelperImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/XSDHelperImpl.java new file mode 100644 index 0000000000..829acd38f4 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/helper/XSDHelperImpl.java @@ -0,0 +1,327 @@ +/** + * + * 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.HashMap; +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.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.xsd.XSDSchema; +import org.eclipse.xsd.ecore.XSDEcoreBuilder; +import org.eclipse.xsd.util.XSDResourceFactoryImpl; +import org.eclipse.xsd.util.XSDResourceImpl; +import org.xml.sax.InputSource; + +import commonj.sdo.Property; +import commonj.sdo.Type; +import commonj.sdo.helper.HelperContext; +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 { + protected boolean extensibleNamespaces = false; + protected HelperContext helperContext; + protected SDOXSDEcoreBuilder nondelegatingEcoreBuilder = null; + protected HashMap tcclToEcoreBuilderMap = null; + private ExtendedMetaData extendedMetaData; + + public XSDHelperImpl(HelperContext hc, String redefineBuiltIn, boolean extensibleNamespaces) { + this.helperContext = hc; + this.extensibleNamespaces = extensibleNamespaces; + extendedMetaData = ((HelperContextImpl)helperContext).extendedMetaData; + + SDOXSDEcoreBuilder ecoreBuilder = createEcoreBuilder(); + + if (extendedMetaData instanceof SDOExtendedMetaDataImpl && ((SDOExtendedMetaDataImpl)extendedMetaData) + .getRegistry() instanceof EPackageRegistryImpl.Delegator) { + tcclToEcoreBuilderMap = new HashMap(); + putTCCLEcoreBuilder(ecoreBuilder); + } else { + nondelegatingEcoreBuilder = ecoreBuilder; + } + + if (redefineBuiltIn != null) { // Redefining/regenerating this built-in + // model + ecoreBuilder.getTargetNamespaceToEPackageMap().remove(redefineBuiltIn); + } + } + + public XSDHelperImpl(HelperContext hc) { + this(hc, null, false); + } + + /** + * Redefine/regenerating the built-in model + * @param redefineBuiltIn + */ + public void setRedefineBuiltIn(String redefineBuiltIn) { + if (redefineBuiltIn != null) { + getEcoreBuilder().getTargetNamespaceToEPackageMap().remove(redefineBuiltIn); + } + } + + public void setExtensibleNamespaces(boolean extensibleNamespaces) { + this.extensibleNamespaces = extensibleNamespaces; + } + + protected SDOXSDEcoreBuilder createEcoreBuilder() { + SDOXSDEcoreBuilder ecoreBuilder = new SDOXSDEcoreBuilder(extendedMetaData, extensibleNamespaces); + + // Add the built-in models to the targetNamespaceToEPackageMap so they + // can't be (re)defined/overridden + for (Iterator iter = TypeHelperImpl.getBuiltInModels().iterator(); iter.hasNext();) { + EPackage ePackage = (EPackage)iter.next(); + ecoreBuilder.getTargetNamespaceToEPackageMap().put(ePackage.getNsURI(), ePackage); + } + + return ecoreBuilder; + } + + protected void putTCCLEcoreBuilder(XSDEcoreBuilder ecoreBuilder) { + ClassLoader tccl = Thread.currentThread().getContextClassLoader(); + if (tcclToEcoreBuilderMap.get(tccl) == null) { + tcclToEcoreBuilderMap.put(tccl, ecoreBuilder); + } + } + + protected SDOXSDEcoreBuilder getEcoreBuilder() { + if (nondelegatingEcoreBuilder != null) + return nondelegatingEcoreBuilder; + + SDOXSDEcoreBuilder result = null; + try { + for (ClassLoader tccl = Thread.currentThread().getContextClassLoader(); tccl != null; tccl = + tccl.getParent()) { + result = (SDOXSDEcoreBuilder)tcclToEcoreBuilderMap.get(tccl); + if (result != null) + return result; + } // for + } catch (SecurityException exception) { + // exception.printStackTrace(); + } + + result = createEcoreBuilder(); + putTCCLEcoreBuilder(result); + + return result; + } + + 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 { + SDOXSDEcoreBuilder ecoreBuilder = getEcoreBuilder(); + ResourceSet resourceSet = ecoreBuilder.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(); + + String targetNamespace = schema.getTargetNamespace(); + EPackage ePackage = extendedMetaData.getPackage(targetNamespace); + if (extensibleNamespaces || ePackage == null || TypeHelperImpl.getBuiltInModels().contains(ePackage)) { + Map targetNamespaceToEPackageMap = ecoreBuilder.getTargetNamespaceToEPackageMap(); + targetNamespaceToEPackageMap.remove(targetNamespace); + + Collection originalEPackages = new HashSet(targetNamespaceToEPackageMap.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 ""; + } + } + + public HelperContext getHelperContext() { + return helperContext; + } +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/AnyTypeDataObjectImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/AnyTypeDataObjectImpl.java new file mode 100644 index 0000000000..b7d22c3be0 --- /dev/null +++ b/sandbox/kgoodson/events/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; + +/** + * + * An implementation of the model object 'EData Object Any Type'. + * + *

+ * The following features are implemented: + *

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

+ * + * @generated + */ +public class AnyTypeDataObjectImpl extends DataObjectImpl implements AnyTypeDataObject +{ + /** + * The cached value of the '{@link #getMixed() Mixed}' attribute list. + * + * + * @see #getMixed() + * @generated + * @ordered + */ + protected FeatureMap mixed = null; + + /** + * The cached value of the '{@link #getAnyAttribute() Any Attribute}' attribute list. + * + * + * @see #getAnyAttribute() + * @generated + * @ordered + */ + protected FeatureMap anyAttribute = null; + + /** + * + * + * @generated + */ + protected AnyTypeDataObjectImpl() + { + super(); + } + + /** + * + * + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getAnyTypeDataObject(); + } + + /** + * + * + * @generated NOT + */ + public FeatureMap getMixed() + { + if (mixed == null) + { + //mixed = new BasicFeatureMap(this, SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED); + mixed = new BasicSequence(new BasicFeatureMap(this, SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED)).featureMap(); + } + return mixed; + } + + /** + * + * + * @generated NOT + */ + public FeatureMap getAny() + { + //return (FeatureMap)((FeatureMap)getMixed()).list(XMLTypePackage.eINSTANCE.getAnyType_Any()); + return new BasicSequence((FeatureMap.Internal)((FeatureMap)getMixed()).list(XMLTypePackage.eINSTANCE.getAnyType_Any())).featureMap(); + } + + /** + * + * + * @generated NOT + */ + public FeatureMap getAnyAttribute() + { + if (anyAttribute == null) + { + //anyAttribute = new BasicFeatureMap(this, SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE); + anyAttribute = new BasicSequence(new BasicFeatureMap(this, SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE)).featureMap(); + } + return anyAttribute; + } + + /** + * + * + * @generated + */ + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) + { + if (featureID >= 0) + { + switch (eDerivedStructuralFeatureID(featureID, baseClass)) + { + case SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED: + return ((InternalEList)getMixed()).basicRemove(otherEnd, msgs); + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY: + return ((InternalEList)getAny()).basicRemove(otherEnd, msgs); + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + return ((InternalEList)getAnyAttribute()).basicRemove(otherEnd, msgs); + default: + return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs); + } + } + return eBasicSetContainer(null, featureID, msgs); + } + + /** + * + * + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED: + if (coreType) return getMixed(); + return ((FeatureMap.Internal)getMixed()).getWrapper(); + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY: + if (coreType) return getAny(); + return ((FeatureMap.Internal)getAny()).getWrapper(); + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + if (coreType) return getAnyAttribute(); + return ((FeatureMap.Internal)getAnyAttribute()).getWrapper(); + } + return eDynamicGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED: + ((FeatureMap.Internal)getMixed()).set(newValue); + return; + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY: + ((FeatureMap.Internal)getAny()).set(newValue); + return; + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + ((FeatureMap.Internal)getAnyAttribute()).set(newValue); + return; + } + eDynamicSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED: + getMixed().clear(); + return; + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY: + getAny().clear(); + return; + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + getAnyAttribute().clear(); + return; + } + eDynamicUnset(featureID); + } + + /** + * + * + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED: + return mixed != null && !mixed.isEmpty(); + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY: + return !getAny().isEmpty(); + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + return anyAttribute != null && !anyAttribute.isEmpty(); + } + return eDynamicIsSet(featureID); + } + + /** + * + * + * @generated + */ + public int eBaseStructuralFeatureID(int derivedFeatureID, Class baseClass) + { + if (baseClass == AnyType.class) + { + switch (derivedFeatureID) + { + case SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED: return XMLTypePackage.ANY_TYPE__MIXED; + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY: return XMLTypePackage.ANY_TYPE__ANY; + case SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: return XMLTypePackage.ANY_TYPE__ANY_ATTRIBUTE; + default: return -1; + } + } + return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); + } + + /** + * + * + * @generated + */ + public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) + { + if (baseClass == AnyType.class) + { + switch (baseFeatureID) + { + case XMLTypePackage.ANY_TYPE__MIXED: return SDOPackage.ANY_TYPE_DATA_OBJECT__MIXED; + case XMLTypePackage.ANY_TYPE__ANY: return SDOPackage.ANY_TYPE_DATA_OBJECT__ANY; + case XMLTypePackage.ANY_TYPE__ANY_ATTRIBUTE: return SDOPackage.ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE; + default: return -1; + } + } + return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); + } + + /** + * + * + * @generated + */ + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (mixed: "); + result.append(mixed); + result.append(", anyAttribute: "); + result.append(anyAttribute); + result.append(')'); + return result.toString(); + } + +} //EDataObjectAnyTypeImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/AttributeImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/AttributeImpl.java new file mode 100644 index 0000000000..e02977e0e8 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/AttributeImpl.java @@ -0,0 +1,836 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + +import java.util.List; + +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.model.ModelFactory; +import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl; +import org.apache.tuscany.sdo.model.internal.InternalFactory; +import org.apache.tuscany.sdo.model.internal.impl.InternalFactoryImpl; +import org.apache.tuscany.sdo.util.BasicSequence; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.apache.tuscany.sdo.util.SDOUtil; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.EAttributeImpl; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.ExtendedMetaData; +import org.eclipse.emf.ecore.util.FeatureMap; + +import commonj.sdo.Property; +import commonj.sdo.Sequence; +import commonj.sdo.Type; + +/** + * + * An implementation of the model object 'Attribute'. + * + *

+ *

+ * + * @generated + */ +public class AttributeImpl extends EAttributeImpl implements Property, org.apache.tuscany.sdo.model.Property/*, DataObject*/ +{ + /** + * + * + * @generated + */ + protected AttributeImpl() + { + super(); + } + + /** + * + * + * @generated NOT + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getAttribute(); + } + + /** + * + * + * @generated NOT + */ + public Object getDefault() + { + return getDefaultValue(); + } + + /** + * + * + * @generated NOT + */ + public boolean isReadOnly() + { + //return "true".equals(EcoreUtil.getAnnotation(this, "commonj.sdo", "readOnly")); + return !isChangeable(); //TODO semantics don't exactly match? + } + + /** + * Single-valued SDO properties behave as EMF unsettable, multi-valued properties as EMF !unsettable + */ + public boolean isUnsettable() + { + return !isMany(); + } + + public boolean isUnique() + { + return false; + } + + protected List aliasNames = null; + + /** + * + * + * @generated NOT + */ + public List getAliasNames() + { + if (aliasNames == null) + { + aliasNames = DataObjectUtil.getAliasNames(this); + } + return aliasNames; + } + + public static Type INTERNAL_BASE64_BYTES = ((InternalFactoryImpl)InternalFactory.INSTANCE).getBase64Bytes(); + public static Type INTERNAL_QNAME = ((InternalFactoryImpl)InternalFactory.INSTANCE).getQName(); + + /** + * + * + * @generated NOT + */ + public Type getType() + { + EClassifier eType = getEType(); + if (eType == INTERNAL_BASE64_BYTES) + return ((ModelFactoryImpl)ModelFactory.INSTANCE).getBytes(); + else if (eType == INTERNAL_QNAME) + return ((ModelFactoryImpl)ModelFactory.INSTANCE).getURI(); + return (Type)eType; + } + + /** + * + * + * @generated NOT + */ + public Type getContainingType() + { + return (Type)getEContainingClass(); + } + + /** + * + * + * @generated NOT + */ + public Property getOpposite() + { + return null; + } + + /** + * + * + * @generated NOT + */ + public boolean isContainment() + { + return false; + } + + protected EStructuralFeature.Internal.SettingDelegate createFeatureMapSettingDelegate() + { + return new InternalSettingDelegateSequence(this); + } + + public static class InternalSettingDelegateSequence extends InternalSettingDelegateMany + { + InternalSettingDelegateSequence(EStructuralFeature feature) + { + super(InternalSettingDelegateMany.FEATURE_MAP, feature); + } + + protected EStructuralFeature.Setting createDynamicSetting(InternalEObject owner) + { + FeatureMap.Internal featureMap = (FeatureMap.Internal)super.createDynamicSetting(owner); + new BasicSequence(featureMap); + return featureMap; + } + } + + public boolean isNullable() + { + String isNillable = EcoreUtil.getAnnotation(this, ExtendedMetaData.ANNOTATION_URI, "nillable"); + return isNillable != null && "true".equals(isNillable); + } + + public boolean isOpenContent() + { + return SDOUtil.isDocumentRoot(getContainingType()); + } + + public List getInstanceProperties() { + return DataObjectUtil.getMetaObjectInstanceProperties(this); + } + + public Object get(Property property) { + return DataObjectUtil.getMetaObjectInstanceProperty(this, property); + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // org.apache.tuscany.sdo.model.Property methods + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + + public List getAliasName() { + return this.getAliasNames(); + } + + public Sequence getAny() { + throw new UnsupportedOperationException(); + } + + public void unsetContainment() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetContainment() { + return false; + } + + public void setMany(boolean value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void unsetMany() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetMany() { + return isMany(); + } + + public void setReadOnly(boolean value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void unsetReadOnly() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetReadOnly() { + return isReadOnly(); + } + + public org.apache.tuscany.sdo.model.Type getType_() { + return (org.apache.tuscany.sdo.model.Type)getType(); + } + + public void setType(org.apache.tuscany.sdo.model.Type value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public Sequence getAnyAttribute() { + throw new UnsupportedOperationException(); + } + + public String getDefault_() { + return (String) this.getDefault(); + } + + public void setDefault_(String value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public org.apache.tuscany.sdo.model.Property getOpposite_() { + return (org.apache.tuscany.sdo.model.Property) getOpposite(); + } + + public void setOpposite_(org.apache.tuscany.sdo.model.Property value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void setContainment(boolean value) { + throw new UnsupportedOperationException(); + } + + public void setNullable(boolean value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void unsetNullable() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetNullable() { + return isUnsettable(); + } + + public void unsetName() + { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetName() + { + return true; + } + + public void unsetOpposite() + { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetOpposite() + { + return getOpposite() != null; + } + + public void unsetType() + { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetType() + { + return true; + } + + public void unsetDefault() + { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetDefault() + { + return getDefault() != null; + } + + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // DataObject method implementations + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + /* + public Object get(int propertyIndex) { + return DataObjectUtil.get(this, propertyIndex); + } + + public void set(int propertyIndex, Object value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSet(int propertyIndex) { + return DataObjectUtil.isSet(this, propertyIndex); + } + + public void unset(int propertyIndex) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public Object get(Property property) { + return DataObjectUtil.get(this, ((EStructuralFeature)property).getFeatureID()); + } + + public void set(Property property, Object value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSet(Property property) { + return DataObjectUtil.isSet(this, ((EStructuralFeature)property).getFeatureID()); + } + + public void unset(Property property) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject getContainer() { + return (DataObject)eContainer(); + } + + public Property getContainmentProperty() { + return (Property)eContainmentFeature(); + } + + // Remaining DataObject methods are (will be) implemented as straight delegation to DataObjectUtil + + public Object get(String path) { + return DataObjectUtil.get(this, path); + } + + public void set(String path, Object value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSet(String path) { + return DataObjectUtil.isSet(this, path); + } + + public void unset(String path) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean getBoolean(String path) { + return DataObjectUtil.getBoolean(get(path)); + } + + public byte getByte(String path) { + return DataObjectUtil.getByte(get(path)); + } + + public char getChar(String path) { + return DataObjectUtil.getChar(get(path)); + } + + public double getDouble(String path) { + return DataObjectUtil.getDouble(get(path)); + } + + public float getFloat(String path) { + return DataObjectUtil.getFloat(get(path)); + } + + public int getInt(String path) { + return DataObjectUtil.getInt(get(path)); + } + + public long getLong(String path) { + return DataObjectUtil.getLong(get(path)); + } + + public short getShort(String path) { + return DataObjectUtil.getShort(get(path)); + } + + public byte[] getBytes(String path) { + return DataObjectUtil.getBytes(get(path)); + } + + public BigDecimal getBigDecimal(String path) { + return DataObjectUtil.getBigDecimal(get(path)); + } + + public BigInteger getBigInteger(String path) { + return DataObjectUtil.getBigInteger(get(path)); + } + + public DataObject getDataObject(String path) { + return (DataObject)get(path); + } + + public Date getDate(String path) { + return DataObjectUtil.getDate(get(path)); + } + + public String getString(String path) { + return DataObjectUtil.getString(get(path)); + } + + public List getList(String path) { + return (List)get(path); + } + + public Sequence getSequence(String path) { + return (Sequence)get(path); + } + + public void setBoolean(String path, boolean value) { + set(path, new Boolean(value)); + } + + public void setByte(String path, byte value) { + set(path, new Byte(value)); + } + + public void setChar(String path, char value) { + set(path, new Character(value)); + } + + public void setDouble(String path, double value) { + set(path, new Double(value)); + } + + public void setFloat(String path, float value) { + set(path, new Float(value)); + } + + public void setInt(String path, int value) { + set(path, new Integer(value)); + } + + public void setLong(String path, long value) { + set(path, new Long(value)); + } + + public void setShort(String path, short value) { + set(path, new Short(value)); + } + + public void setBytes(String path, byte[] value) { + set(path, value); + } + + public void setBigDecimal(String path, BigDecimal value) { + set(path, value); + } + + public void setBigInteger(String path, BigInteger value) { + set(path, value); + } + + public void setDataObject(String path, DataObject value) { + set(path, value); + } + + public void setDate(String path, Date value) { + set(path, value); + } + + public void setString(String path, String value) { + set(path, value); + } + + public void setList(String path, List value) { + set(path, value); + } + + public boolean getBoolean(int propertyIndex) { + return DataObjectUtil.getBoolean(this, propertyIndex); + } + + public byte getByte(int propertyIndex) { + return DataObjectUtil.getByte(this, propertyIndex); + } + + public char getChar(int propertyIndex) { + return DataObjectUtil.getChar(this, propertyIndex); + } + + public double getDouble(int propertyIndex) { + return DataObjectUtil.getDouble(this, propertyIndex); + } + + public float getFloat(int propertyIndex) { + return DataObjectUtil.getFloat(this, propertyIndex); + } + + public int getInt(int propertyIndex) { + return DataObjectUtil.getInt(this, propertyIndex); + } + + public long getLong(int propertyIndex) { + return DataObjectUtil.getLong(this, propertyIndex); + } + + public short getShort(int propertyIndex) { + return DataObjectUtil.getShort(this, propertyIndex); + } + + public byte[] getBytes(int propertyIndex) { + return DataObjectUtil.getBytes(this, propertyIndex); + } + + public BigDecimal getBigDecimal(int propertyIndex) { + return DataObjectUtil.getBigDecimal(this, propertyIndex); + } + + public BigInteger getBigInteger(int propertyIndex) { + return DataObjectUtil.getBigInteger(this, propertyIndex); + } + + public DataObject getDataObject(int propertyIndex) { + return DataObjectUtil.getDataObject(this, propertyIndex); + } + + public Date getDate(int propertyIndex) { + return DataObjectUtil.getDate(this, propertyIndex); + } + + public String getString(int propertyIndex) { + return DataObjectUtil.getString(this, propertyIndex); + } + + public List getList(int propertyIndex) { + return DataObjectUtil.getList(this, propertyIndex); + } + + public Sequence getSequence(int propertyIndex) { + return DataObjectUtil.getSequence(this, propertyIndex); + } + + public void setBoolean(int propertyIndex, boolean value) { + set(propertyIndex, new Boolean(value)); + } + + public void setByte(int propertyIndex, byte value) { + set(propertyIndex, new Byte(value)); + } + + public void setChar(int propertyIndex, char value) { + set(propertyIndex, new Character(value)); + } + + public void setDouble(int propertyIndex, double value) { + set(propertyIndex, new Double(value)); + } + + public void setFloat(int propertyIndex, float value) { + set(propertyIndex, new Float(value)); + } + + public void setInt(int propertyIndex, int value) { + set(propertyIndex, new Integer(value)); + } + + public void setLong(int propertyIndex, long value) { + set(propertyIndex, new Long(value)); + } + + public void setShort(int propertyIndex, short value) { + set(propertyIndex, new Short(value)); + } + + public void setBytes(int propertyIndex, byte[] value) { + set(propertyIndex, value); + } + + public void setBigDecimal(int propertyIndex, BigDecimal value) { + set(propertyIndex, value); + } + + public void setBigInteger(int propertyIndex, BigInteger value) { + set(propertyIndex, value); + } + + public void setDataObject(int propertyIndex, DataObject value) { + set(propertyIndex, value); + } + + public void setDate(int propertyIndex, Date value) { + set(propertyIndex, value); + } + + public void setString(int propertyIndex, String value) { + set(propertyIndex, value); + } + + public void setList(int propertyIndex, List value) { + set(propertyIndex, value); + } + + public boolean getBoolean(Property property) { + return DataObjectUtil.getBoolean(this, property); + } + + public byte getByte(Property property) { + return DataObjectUtil.getByte(this, property); + } + + public char getChar(Property property) { + return DataObjectUtil.getChar(this, property); + } + + public double getDouble(Property property) { + return DataObjectUtil.getDouble(this, property); + } + + public float getFloat(Property property) { + return DataObjectUtil.getFloat(this, property); + } + + public int getInt(Property property) { + return DataObjectUtil.getInt(this, property); + } + + public long getLong(Property property) { + return DataObjectUtil.getLong(this, property); + } + + public short getShort(Property property) { + return DataObjectUtil.getShort(this, property); + } + + public byte[] getBytes(Property property) { + return DataObjectUtil.getBytes(this, property); + } + + public BigDecimal getBigDecimal(Property property) { + return DataObjectUtil.getBigDecimal(this, property); + } + + public BigInteger getBigInteger(Property property) { + return DataObjectUtil.getBigInteger(this, property); + } + + public DataObject getDataObject(Property property) { + return DataObjectUtil.getDataObject(this, property); + } + + public Date getDate(Property property) { + return DataObjectUtil.getDate(this, property); + } + + public String getString(Property property) { + return DataObjectUtil.getString(this, property); + } + + public List getList(Property property) { + return DataObjectUtil.getList(this, property); + } + + public Sequence getSequence(Property property) { + return DataObjectUtil.getSequence(this, property); + } + + public void setBoolean(Property property, boolean value) { + set(property, new Boolean(value)); + } + + public void setByte(Property property, byte value) { + set(property, new Byte(value)); + } + + public void setChar(Property property, char value) { + set(property, new Character(value)); + } + + public void setDouble(Property property, double value) { + set(property, new Double(value)); + } + + public void setFloat(Property property, float value) { + set(property, new Float(value)); + } + + public void setInt(Property property, int value) { + set(property, new Integer(value)); + } + + public void setLong(Property property, long value) { + set(property, new Long(value)); + } + + public void setShort(Property property, short value) { + set(property, new Short(value)); + } + + public void setBytes(Property property, byte[] value) { + set(property, value); + } + + public void setBigDecimal(Property property, BigDecimal value) { + set(property, value); + } + + public void setBigInteger(Property property, BigInteger value) { + set(property, value); + } + + public void setDataObject(Property property, DataObject value) { + set(property, value); + } + + public void setDate(Property property, Date value) { + set(property, value); + } + + public void setString(Property property, String value) { + set(property, value); + } + + public void setList(Property property, List value) { + set(property, value); + } + + public DataObject createDataObject(String propertyName) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(String propertyName, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property, Type type) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void delete() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataGraph getDataGraph() { + return DataObjectUtil.getDataGraph(this); + } + + public Sequence getSequence() { + EAttribute mixedFeature = BasicExtendedMetaData.INSTANCE.getMixedFeature(eClass()); + return mixedFeature != null ? (Sequence)eGet(mixedFeature, true, false) : null; + } + + public List getInstanceProperties() { + return DataObjectUtil.getInstanceProperties(this); + } + + public DataObject getRootObject() { + return DataObjectUtil.getRootObject(this); + } + + public ChangeSummary getChangeSummary() { + // TODO: implement this method + throw new UnsupportedOperationException(); + } + + public void detach() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + //DataObjectUtil.detach(this); + } + + public Property getProperty(String propertyName) { + return DataObjectUtil.getProperty(this, propertyName); + } + */ + +} //AttributeImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummaryImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummaryImpl.java new file mode 100644 index 0000000000..55f3d5449d --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummaryImpl.java @@ -0,0 +1,876 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + + +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.util.BasicSequence; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.UniqueEList; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.change.ChangeDescription; +import org.eclipse.emf.ecore.change.FeatureChange; +import org.eclipse.emf.ecore.change.impl.ChangeDescriptionImpl; +import org.eclipse.emf.ecore.change.util.ChangeRecorder; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.util.BasicExtendedMetaData; +import org.eclipse.emf.ecore.util.DelegatingFeatureMap; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.ecore.util.FeatureMapUtil; +import org.eclipse.emf.ecore.util.InternalEList; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Sequence; + + +/** + * + * An implementation of the model object 'EChange Summary'. + * + *

+ * The following features are implemented: + *

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

+ * + * @generated + */ +public class ChangeSummaryImpl extends ChangeDescriptionImpl implements ChangeSummary +{ + /** + * The cached value of the '{@link #getEDataGraph() EData Graph}' reference. + * + * + * @see #getEDataGraph() + * @generated + * @ordered + */ + protected DataGraph eDataGraph = null; + + protected DataObject dataObject = null; + protected SDOChangeRecorder changeRecorder = null; + + protected Set cachedDeletedObjects = null; + protected List cachedCreatedObjects = null; + protected Map cachedSDOObjectChanges = null; + protected boolean isStale = false; + + /** + * + * + * @generated + */ + protected ChangeSummaryImpl() + { + super(); + cachedSDOObjectChanges = createThreadSafeMap(); + } + + /** + * + * + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getChangeSummary(); + } + + /** + * + * + * @generated NOT + */ + public boolean isLogging() + { + return changeRecorder != null; + } + + /** + * + * + * @generated + */ + public DataGraph getEDataGraph() + { + return eDataGraph; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetEDataGraph(DataGraph newEDataGraph, NotificationChain msgs) + { + DataGraph oldEDataGraph = eDataGraph; + eDataGraph = newEDataGraph; + if (eNotificationRequired()) + { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH, oldEDataGraph, newEDataGraph); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + public void setEDataGraph(DataGraph newEDataGraph) + { + if (newEDataGraph != eDataGraph) + { + NotificationChain msgs = null; + if (eDataGraph != null) + msgs = ((InternalEObject)eDataGraph).eInverseRemove(this, SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY, DataGraph.class, msgs); + if (newEDataGraph != null) + msgs = ((InternalEObject)newEDataGraph).eInverseAdd(this, SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY, DataGraph.class, msgs); + msgs = basicSetEDataGraph(newEDataGraph, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH, newEDataGraph, newEDataGraph)); + } + + public DataObject getDataObject() + { + return dataObject; + } + + public void setDataObject(DataObject newDataObject) + { + dataObject = newDataObject; + } + + /** + * + * + * @generated NOT + */ + public void beginLogging() + { + if (isLogging()) + { + throw new IllegalStateException("Already logging"); + } + + getObjectsToAttach().clear(); + getObjectChanges().clear(); + getResourceChanges().clear(); + oldContainmentInformation = null; + + beginRecording(); +// if (eNotificationRequired()) +// eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.ECHANGE_SUMMARY__LOGGING, false, true)); + } + + /** + * + */ + private void beginRecording() { + changeRecorder = new SDOChangeRecorder(); + if (eDataGraph != null) + { + changeRecorder.beginRecording(Collections.singleton(((DataGraphImpl)eDataGraph).getRootResource())); + } + else if (dataObject != null) + { + changeRecorder.beginRecording(Collections.singleton(dataObject)); + } + else + { + throw new IllegalStateException("ChangeSummary not attached to any data objects"); + } + } + + /** + * + * + * @generated NOT + */ + public void resumeLogging() + { + if (isLogging()) + { + throw new IllegalStateException("Already logging"); + } + + oldContainmentInformation = null; + + beginRecording(); +// if (eNotificationRequired()) +// eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.ECHANGE_SUMMARY__LOGGING, false, true)); + } + + /** + * + * + * @generated + */ + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) + { + if (featureID >= 0) + { + switch (eDerivedStructuralFeatureID(featureID, baseClass)) + { + case SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH: + if (eDataGraph != null) + msgs = ((InternalEObject)eDataGraph).eInverseRemove(this, SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY, DataGraph.class, msgs); + return basicSetEDataGraph((DataGraph)otherEnd, msgs); + default: + return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs); + } + } + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + return eBasicSetContainer(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) + { + if (featureID >= 0) + { + switch (eDerivedStructuralFeatureID(featureID, baseClass)) + { + case SDOPackage.CHANGE_SUMMARY__OBJECT_CHANGES: + return ((InternalEList)getObjectChanges()).basicRemove(otherEnd, msgs); + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_ATTACH: + return ((InternalEList)getObjectsToAttach()).basicRemove(otherEnd, msgs); + case SDOPackage.CHANGE_SUMMARY__RESOURCE_CHANGES: + return ((InternalEList)getResourceChanges()).basicRemove(otherEnd, msgs); + case SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH: + return basicSetEDataGraph(null, msgs); + default: + return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs); + } + } + return eBasicSetContainer(null, featureID, msgs); + } + + /** + * + * + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case SDOPackage.CHANGE_SUMMARY__OBJECT_CHANGES: + if (coreType) return getObjectChanges(); + else return getObjectChanges().map(); + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_DETACH: + return getObjectsToDetach(); + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_ATTACH: + return getObjectsToAttach(); + case SDOPackage.CHANGE_SUMMARY__RESOURCE_CHANGES: + return getResourceChanges(); + case SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH: + return getEDataGraph(); +// case SDOPackage.CHANGE_SUMMARY__EDATA_OBJECT: +// return getEDataObject(); + } + return eDynamicGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case SDOPackage.CHANGE_SUMMARY__OBJECT_CHANGES: + ((EStructuralFeature.Setting)getObjectChanges()).set(newValue); + return; + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_DETACH: + getObjectsToDetach().clear(); + getObjectsToDetach().addAll((Collection)newValue); + return; + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_ATTACH: + getObjectsToAttach().clear(); + getObjectsToAttach().addAll((Collection)newValue); + return; + case SDOPackage.CHANGE_SUMMARY__RESOURCE_CHANGES: + getResourceChanges().clear(); + getResourceChanges().addAll((Collection)newValue); + return; + case SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH: + setEDataGraph((DataGraph)newValue); + return; + } + eDynamicSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case SDOPackage.CHANGE_SUMMARY__OBJECT_CHANGES: + getObjectChanges().clear(); + return; + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_DETACH: + getObjectsToDetach().clear(); + return; + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_ATTACH: + getObjectsToAttach().clear(); + return; + case SDOPackage.CHANGE_SUMMARY__RESOURCE_CHANGES: + getResourceChanges().clear(); + return; + case SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH: + setEDataGraph((DataGraph)null); + return; + } + eDynamicUnset(featureID); + } + + /** + * + * + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case SDOPackage.CHANGE_SUMMARY__OBJECT_CHANGES: + return objectChanges != null && !objectChanges.isEmpty(); + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_DETACH: + return objectsToDetach != null && !objectsToDetach.isEmpty(); + case SDOPackage.CHANGE_SUMMARY__OBJECTS_TO_ATTACH: + return objectsToAttach != null && !objectsToAttach.isEmpty(); + case SDOPackage.CHANGE_SUMMARY__RESOURCE_CHANGES: + return resourceChanges != null && !resourceChanges.isEmpty(); + case SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH: + return eDataGraph != null; + } + return eDynamicIsSet(featureID); + } + + protected void uncache() + { + cachedDeletedObjects = null; + cachedCreatedObjects = null; + cachedSDOObjectChanges.clear(); + } + + protected class SDOChangeRecorder extends ChangeRecorder + { + public SDOChangeRecorder() + { + super(); + } + + public void beginRecording(ChangeDescription changeDescription, Collection rootObjects) + { + uncache(); + super.beginRecording(changeDescription, rootObjects); + } + + protected ChangeDescription createChangeDescription() + { + return ChangeSummaryImpl.this; + } + + protected FeatureChange createFeatureChange(EObject eObject, EStructuralFeature eStructuralFeature, Object value, boolean isSet) + { + Property property = (Property)eStructuralFeature; + if (property.isReadOnly()) + { + if (((DataObject)eObject).getDataGraph() != null) + { + throw + new IllegalStateException + ("The property '" + property.getName() + "' of type '" + + property.getContainingType().getName() + "' is read only"); + } + } + return (FeatureChange)SDOFactory.eINSTANCE.createChangeSummarySetting(eStructuralFeature, value, isSet); + } + + protected void consolidateChanges() + { + uncache(); + isStale = false; + + // TODO remove this fixup when https://bugs.eclipse.org/bugs/show_bug.cgi?id=177235 is + // available to us (i.e. we update to EMF 2.3) -- see Tuscany-1164 + boolean isUncontainedRoot = dataObject != null + && ((EObject)dataObject).eContainer() == null + && ((EObject)dataObject).eResource() == null; + + super.consolidateChanges(); + + if(isUncontainedRoot && changeDescription.getObjectsToAttach().contains(dataObject)) { + changeDescription.getObjectsToAttach().remove(dataObject); + } + + } + + protected void addAdapter(Notifier notifier) + { + if (!loadingTargets) return; // Optimize ChangeSummary to not record changes in newly created DOs + + if (notifier instanceof DataObjectImpl) + ((DataObjectImpl)notifier).setChangeRecorder(this); + else + super.addAdapter(notifier); + } + + protected void removeAdapter(Notifier notifier) + { + if (notifier instanceof DataObjectImpl) + ((DataObjectImpl)notifier).setChangeRecorder(null); + else + super.removeAdapter(notifier); + } + + public void notifyChanged(Notification notification) + { + super.notifyChanged(notification); + + Object notifier = notification.getNotifier(); + if (notifier instanceof EObject) + { + cachedSDOObjectChanges.remove(notifier); + Object feature = notification.getFeature(); + if (feature instanceof Property && ((Property)feature).isContainment()) + { + cachedCreatedObjects = null; + cachedDeletedObjects = null; + oldContainmentInformation = null; + } + isStale = true; + } + } + + } + + /** + * + * + * @generated NOT + */ + public void endLogging() + { + if (!isLogging()) + { + throw new IllegalStateException("Not currently logging"); + } + + changeRecorder.endRecording(); + changeRecorder.dispose(); + changeRecorder = null; +// if (eNotificationRequired()) +// eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.ECHANGE_SUMMARY__LOGGING, true, false)); + } + + /** + * + * + * @generated NOT + */ + public boolean isCreated(DataObject dataObject) + { + return getCachedCreatedObjects().contains(dataObject); + } + + /** + * + * + * @generated NOT + */ + public boolean isDeleted(DataObject dataObject) + { + return getCachedDeletedObjects().contains(dataObject); + } + + protected Set getCachedDeletedObjects() + { + if (cachedDeletedObjects == null) + { + if (isStale()) changeRecorder.consolidateChanges(); + cachedDeletedObjects = new HashSet(); + for (Iterator i = EcoreUtil.getAllContents(getObjectsToAttach()); i.hasNext(); ) + { + cachedDeletedObjects.add(i.next()); + } + } + return cachedDeletedObjects; + } + + protected List getCachedCreatedObjects() + { + if (cachedCreatedObjects == null) + { + if (isStale()) changeRecorder.consolidateChanges(); + cachedCreatedObjects = super.getObjectsToDetach(); + } + return cachedCreatedObjects; + } + + /** + * + * + * @generated NOT + */ + public List getChangedDataObjects() + { + EList result = new UniqueEList.FastCompare(getCachedDeletedObjects()); + result.addAll(getCachedCreatedObjects()); + for (Iterator i = getObjectChanges().iterator(); i.hasNext(); ) + { + Map.Entry entry = (Map.Entry)i.next(); + result.add(entry.getKey()); + } + return result; + } + + /** + * + * + * @generated NOT + */ + public List getOldValues(DataObject dataObject) + { + List sdoSettings = (List)cachedSDOObjectChanges.get(dataObject); + if (sdoSettings != null) + { + return sdoSettings; + } + + if (isStale()) changeRecorder.consolidateChanges(); + List settings = (List)getObjectChanges().get(dataObject); + if (settings == null) + { + settings = Collections.EMPTY_LIST; + } + else + { + for (int i = 0; i < settings.size(); i++) + { + FeatureChange change = (FeatureChange)settings.get(i); + EStructuralFeature feature = change.getFeature(); + if (FeatureMapUtil.isFeatureMap(feature)) + { + final List values = (List)change.getValue(); + if (sdoSettings == null) + { + sdoSettings = new BasicEList(settings); + } + DelegatingFeatureMap featureMap = new DelegatingFeatureMap(((InternalEObject)dataObject), feature) + { + protected final List theList = values; + + protected List delegateList() + { + return theList; + } + }; + + // create new settings and replace the setting for mixed feature + sdoSettings.set(i, SDOFactory.eINSTANCE.createChangeSummarySetting(feature, new BasicSequence(featureMap), change.isSet())); + // add all derived features + for (int k = 0; k < featureMap.size(); k++) + { + EStructuralFeature f = featureMap.getEStructuralFeature(k); + sdoSettings.add(SDOFactory.eINSTANCE.createChangeSummarySetting(f, featureMap.get(f, false), true)); + } + } + } + } + sdoSettings = (sdoSettings != null) ? sdoSettings : settings; + cachedSDOObjectChanges.put(dataObject, sdoSettings); + return sdoSettings; + } + + /** + * + * + * @generated NOT + */ + public boolean isModified(DataObject dataObject) + { + return getObjectChanges().containsKey(dataObject) && !isDeleted(dataObject) && !isCreated(dataObject); + } + + /** + * + * + * @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); + } + + /** + * + * + * @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; + } + + /** + * + * + * @generated NOT + */ + public void undoChanges() + { + if (isLogging()) + { + changeRecorder.summarize(); + } + else + { + uncache(); + } + apply(); + } + + /** + * + * + * @generated NOT + */ + public DataGraph getDataGraph() + { + return getEDataGraph(); + } + + protected Map getOldContainmentInformation() + { + if (oldContainmentInformation == null) + { + if (isStale()) changeRecorder.consolidateChanges(); + super.getOldContainmentInformation(); + } + return oldContainmentInformation; + } + + protected boolean isStale() + { + return isLogging() && isStale; + } + + /** + * + * + * @generated NOT + */ + public DataObject getRootObject() + { + if (eDataGraph != null) + { + return eDataGraph.getRootObject(); + } + if (dataObject != null) + { + return dataObject; + } + return null; + } + + static protected boolean isContainmentReference(Object feature) + { + return feature instanceof EReference && ((EReference) feature).isContainment(); + } + + public DataObject getOldDataObject(DataObject dataObject) + { + //TODO: Fix this method. Currently, it has the side effect of undoing the unset of contained children references + // of root deleted objects - i.e., when featureChange.apply(oldDataObject) is called. + // + List changes = (List) getObjectChanges().get(dataObject); + if (changes == null) + return dataObject; + EObject oldDataObject = EcoreUtil.copy((EObject)dataObject); + for (Iterator fIter = changes.iterator(); fIter.hasNext(); ) + { + FeatureChange featureChange = (FeatureChange)fIter.next(); + featureChange.apply(oldDataObject); + EStructuralFeature feature = featureChange.getFeature(); + if (FeatureMapUtil.isFeatureMap(feature)) + { + FeatureMap featureMap = (FeatureMap) oldDataObject.eGet(feature); + for (int index = featureMap.size(); index != 0;) + if (isContainmentReference(featureMap.getEStructuralFeature(--index))) + featureMap.setValue(index, getOldDataObject((DataObject) featureMap.getValue(index))); + } + else if (isContainmentReference(feature)) + { + Object value = oldDataObject.eGet(feature); + if (feature.isMany()) + { + changes = (List) value; + for (int index = changes.size(); index != 0;) + changes.set(--index, getOldDataObject((DataObject) changes.get(index))); // Java pushes stack from left to right + } + else + oldDataObject.eSet(feature, getOldDataObject((DataObject) value)); + } + } + + return (DataObject)oldDataObject; + } + + private static Class concurrentHashMapClazz = null; + private static boolean isThreadSafeMapClazzIdentified = false; + + private Map createThreadSafeMap() + { + if (!isThreadSafeMapClazzIdentified) + { + concurrentHashMapClazz = loadConcurrentHashMapClazz(); + isThreadSafeMapClazzIdentified = true; + } + Map threadSafeMap = null; + if (concurrentHashMapClazz == null) + { + threadSafeMap = Collections.synchronizedMap(new HashMap()); + } + else + { + try + { + threadSafeMap = (Map)concurrentHashMapClazz.newInstance(); + } + catch (InstantiationException e) + { + throw new RuntimeException(e); + } + catch (IllegalAccessException e) + { + throw new RuntimeException(e); + } + } + return threadSafeMap; + } + + private static String[] concurrentHashMapClazzNames = new String[] { + "java.util.concurrent.ConcurrentHashMap", + "edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap"}; + + private static Class loadConcurrentHashMapClazz() + { + Class mapClazz = null; + for (int i = 0; i < concurrentHashMapClazzNames.length; i++) + { + String concurrentHashMapClazzName = concurrentHashMapClazzNames[i]; + try + { + mapClazz = Class.forName(concurrentHashMapClazzName, true, Thread.currentThread().getContextClassLoader()); + } + catch (Exception ignored) {} + if (mapClazz != null) + { + break; + } + try + { + mapClazz = Class.forName(concurrentHashMapClazzName); + } + catch (Exception ignored) {} + if (mapClazz != null) + { + break; + } + } + return mapClazz; + } + +} //ChangeSummaryImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummarySettingImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ChangeSummarySettingImpl.java new file mode 100644 index 0000000000..d1cd1d3e05 --- /dev/null +++ b/sandbox/kgoodson/events/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; +/** + * + * An implementation of the model object 'EChange Summary Setting'. + * + *

+ *

+ * + * @generated + */ +public class ChangeSummarySettingImpl extends FeatureChangeImpl implements ChangeSummary.Setting +{ + /** + * + * + * @generated + */ + protected ChangeSummarySettingImpl() + { + super(); + } + + protected ChangeSummarySettingImpl(EStructuralFeature feature, Object value, boolean isSet) + { + super(feature, value, isSet); + } + + /** + * + * + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getChangeSummarySetting(); + } + + /** + * + * + * @generated NOT + */ + public Object getValue() + { + EStructuralFeature feature = getFeature(); + if (feature.isMany()) + { + if (value == null) + { + EObject eObject = (EObject)((Map.Entry)eContainer()).getKey(); + value = getListValue((EList)eObject.eGet(feature)); + } + return value; + } + else + { + return super.getValue(); + } + } + + /** + * + * + * @generated NOT + */ + public Property getProperty() + { + return (Property)getFeature(); + } + + /** + * + * + * @generated NOT + */ + public boolean isSet() + { + return super.isSet(); + } + +} //EChangeSummarySettingImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ClassImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ClassImpl.java new file mode 100644 index 0000000000..cd37620f4c --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ClassImpl.java @@ -0,0 +1,1127 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.model.ModelFactory; +import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl; +import org.apache.tuscany.sdo.util.BasicSequence; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.UniqueEList; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.impl.EClassImpl; +import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; +import org.eclipse.emf.ecore.util.ExtendedMetaData; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.ecore.util.FeatureMapUtil; + +import commonj.sdo.Property; +import commonj.sdo.Sequence; +import commonj.sdo.Type; + +/** + * + * An implementation of the model object 'Class'. + * + *

+ *

+ * + * @generated + */ +public class ClassImpl extends EClassImpl implements Type, org.apache.tuscany.sdo.model.Type/*, DataObject*/ +{ + private static final long serialVersionUID = 1L; + + private static final Property UNINITIALIZED_PROPERTY = SDOFactory.eINSTANCE.createAttribute(); + + private Property changeSummaryPropertyCache = UNINITIALIZED_PROPERTY; + + /** + * + * + * @generated + */ + protected ClassImpl() + { + super(); + } + + /** + * + * + * @generated NOT + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getClass_(); + } + + /** + * + * + * @generated NOT + */ + public String getURI() + { + return getEPackage().getNsURI(); + } + + /** + * + * + * @generated NOT + */ + public boolean isDataType() + { + return false; + } + + /** + * + * + * @generated NOT + */ + public boolean isOpen() + { + final List properties = getExtendedProperties(); + if (properties != Collections.EMPTY_LIST) + { + for (int i = 0, count = properties.size(); i < count; ++i) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)properties.get(i); + if (isOpenFeatureMap(eStructuralFeature)) + return true; + } + } + + for (final Iterator iterator = getBaseTypes().iterator() ; iterator.hasNext(); ) + { + Type baseType = (Type)iterator.next(); + if (baseType.isOpen()) + return true; + } + + return false; + } + + private static final EStructuralFeature UNINITIALIZED_SEQUENCE_FEATURE = (EAttribute)SDOFactory.eINSTANCE.createAttribute(); + protected static final EStructuralFeature VIRTUAL_SEQUENCE_FEATURE = (EAttribute)SDOFactory.eINSTANCE.createAttribute(); + + private EStructuralFeature sequenceFeature = UNINITIALIZED_SEQUENCE_FEATURE; + + public EStructuralFeature getSequenceFeature() + { + if (sequenceFeature == UNINITIALIZED_SEQUENCE_FEATURE) + { + EStructuralFeature sequenceFeatureCandidate = null; + boolean hasNonDerivedFeatures = false; + + for (Iterator iterator = getEAllStructuralFeatures().iterator(); iterator.hasNext(); ) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)iterator.next(); + if (!eStructuralFeature.isDerived()) { + if (sequenceFeatureCandidate == null && isSequenceFeatureMap(eStructuralFeature)) + sequenceFeatureCandidate = eStructuralFeature; + else if (isElementFeature(eStructuralFeature) && !DataObjectUtil.isInternalProperty(eStructuralFeature)) + hasNonDerivedFeatures = true; + } + } + + sequenceFeature = + sequenceFeatureCandidate != null && hasNonDerivedFeatures ? + VIRTUAL_SEQUENCE_FEATURE : + sequenceFeatureCandidate; + } + + return sequenceFeature; + } + + protected boolean isSequenceFeatureMap(EStructuralFeature eStructuralFeature) + { + switch (ExtendedMetaData.INSTANCE.getFeatureKind(eStructuralFeature)) + { + case ExtendedMetaData.ELEMENT_WILDCARD_FEATURE: + return eStructuralFeature.getUpperBound() != 1; + case ExtendedMetaData.GROUP_FEATURE: + return true; + } + return false; + } + + protected boolean isElementFeature(EStructuralFeature eStructuralFeature) + { + switch (ExtendedMetaData.INSTANCE.getFeatureKind(eStructuralFeature)) + { + case ExtendedMetaData.ATTRIBUTE_FEATURE: + case ExtendedMetaData.ATTRIBUTE_WILDCARD_FEATURE: + return false; + } + return true; + } + + public List getVirtualSequenceProperties() + { + List result = new ArrayList(); + for (Iterator iterator = getEAllStructuralFeatures().iterator(); iterator.hasNext(); ) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)iterator.next(); + if (!eStructuralFeature.isDerived() && isElementFeature(eStructuralFeature)) + result.add(eStructuralFeature); + } + return result; + } + + public void setSequenceFeature(EAttribute sequenceFeature) + { + getEStructuralFeatures().add(sequenceFeature); + this.sequenceFeature = sequenceFeature; + } + + /** + * + * + * @generated NOT + */ + public boolean isSequenced() + { + return getSequenceFeature() != null; + } + + protected List aliasNames = null; + + /** + * + * + * @generated NOT + */ + public List getAliasNames() + { + if (aliasNames == null) + { + aliasNames = DataObjectUtil.getAliasNames(this); + } + return aliasNames; + } + + protected List declaredProperties = null; + + public List getDeclaredProperties() + { + if (declaredProperties == null) { + initPropertyLists(); + } + return declaredProperties; + } + + protected List extendedProperties = null; + + public List getExtendedProperties() + { + if (extendedProperties == null) { + initPropertyLists(); + } + return extendedProperties; + } + + protected List getTypeFeatures() + { + return getEStructuralFeatures(); + } + + protected void initPropertyLists() + { + List declaredProperties = new ArrayList(); + List extendedProperties = Collections.EMPTY_LIST; + + for (Iterator i = getTypeFeatures().iterator(); i.hasNext(); ) { + EStructuralFeature eStructuralFeature = (EStructuralFeature)i.next(); + boolean isExtendedProperty = DataObjectUtil.isInternalProperty(eStructuralFeature); + if (isExtendedProperty) { + if (extendedProperties == Collections.EMPTY_LIST) + extendedProperties = new ArrayList(); + extendedProperties.add(eStructuralFeature); + } + else + declaredProperties.add(eStructuralFeature); + } + this.declaredProperties = declaredProperties; + this.extendedProperties = extendedProperties; + } + + public EList getEStructuralFeatures() + { + if (eStructuralFeatures == null) + { + eStructuralFeatures = + new EObjectContainmentWithInverseEList(EStructuralFeature.class, this, EcorePackage.ECLASS__ESTRUCTURAL_FEATURES, EcorePackage.ESTRUCTURAL_FEATURE__ECONTAINING_CLASS) + { + protected void didChange() + { + declaredProperties = extendedProperties = null; + } + }; + } + return eStructuralFeatures; + } + + protected List allProperties = null; + protected List allExtendedProperties = null; + protected EList allFeaturesCache = null; + + /** + * + * + * @generated NOT + */ + public List getProperties() + { + final EList allFeatures = getEAllStructuralFeatures(); + if (allFeatures != allFeaturesCache) + { + allFeaturesCache = allFeatures; + allProperties = allExtendedProperties = null; + } + if (allProperties == null) + { + List allProperties = new UniqueEList(); + for (final Iterator iterator = getBaseTypes().iterator(); iterator.hasNext(); ) + { + Type baseType = (Type)iterator.next(); + allProperties.addAll(baseType.getProperties()); + } + allProperties.addAll(getDeclaredProperties()); + this.allProperties = allProperties; + } + return allProperties; + } + + public List getAllExtendedProperties() + { + final EList allFeatures = getEAllStructuralFeatures(); + if (allFeatures != allFeaturesCache) + { + allFeaturesCache = allFeatures; + allProperties = allExtendedProperties = null; + } + if (allExtendedProperties == null) + { + List allExtendedProperties = new UniqueEList(); + for (final Iterator iterator = getBaseTypes().iterator(); iterator.hasNext(); ) + { + Type baseType = (Type)iterator.next(); + allExtendedProperties.addAll(((ClassImpl)baseType).getAllExtendedProperties()); + } + allExtendedProperties.addAll(getExtendedProperties()); + this.allExtendedProperties = allExtendedProperties; + } + return allExtendedProperties; + } + + protected boolean isOpenFeatureMap(EStructuralFeature eStructuralFeature) + { + switch (ExtendedMetaData.INSTANCE.getFeatureKind(eStructuralFeature)) + { + case ExtendedMetaData.ELEMENT_WILDCARD_FEATURE: + return eStructuralFeature != ExtendedMetaData.INSTANCE.getMixedFeature(this); + case ExtendedMetaData.ATTRIBUTE_WILDCARD_FEATURE: + //FB I think this is wrong ... case ExtendedMetaData.GROUP_FEATURE: + return true; + } + return false; + } + + public void addOpenProperties(EObject dataObject, Collection propertyList) + { + for (final Iterator iterator = getBaseTypes().iterator(); iterator.hasNext(); ) + { + ClassImpl baseType = (ClassImpl)iterator.next(); + baseType.addOpenProperties(dataObject, propertyList); + } + + for (final Iterator iter = getExtendedProperties().iterator(); iter.hasNext(); ) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)iter.next(); + if (isOpenFeatureMap(eStructuralFeature)) + { + List features = (List)dataObject.eGet(eStructuralFeature); + for (int j = 0, size = features.size(); j < size; ++j) + { + FeatureMap.Entry entry = (FeatureMap.Entry)features.get(j); + EStructuralFeature entryFeature = entry.getEStructuralFeature(); + Property property = BasicSequence.getFeatureProperty(entryFeature); + if (property != null) propertyList.add(entryFeature); + } + } + } + } + + public Property getOpenProperty(EObject dataObject, String featureName) + { + for (final Iterator iterator = getBaseTypes().iterator(); iterator.hasNext(); ) + { + ClassImpl baseType = (ClassImpl)iterator.next(); + Property result = baseType.getOpenProperty(dataObject, featureName); + if (result != null) return result; + } + + Set openFeatureSet = new HashSet(); + for (final Iterator iter = getExtendedProperties().iterator(); iter.hasNext(); ) + { + EStructuralFeature eStructuralFeature = (EStructuralFeature)iter.next(); + //if (isOpenFeatureMap(eStructuralFeature)) + //FB The above check excludes subsitition groups - i.e., doesn't support dObj.get("element.substitution") + if (FeatureMapUtil.isFeatureMap(eStructuralFeature)) + { + List features = (List)dataObject.eGet(eStructuralFeature); + for (int j = 0, size = features.size(); j < size; ++j) + { + FeatureMap.Entry entry = (FeatureMap.Entry)features.get(j); + EStructuralFeature entryFeature = entry.getEStructuralFeature(); + if (openFeatureSet.add(entryFeature)) + { + Property property = BasicSequence.getFeatureProperty(entryFeature); + if (property != null) + { + if (property.getName().equals(featureName)) return (Property)entryFeature; + List aliasNames = property.getAliasNames(); + for (int aliasCount = aliasNames.size(); aliasCount > 0; ) + { + if (aliasNames.get(--aliasCount).equals(featureName)) return (Property)entryFeature; + } + } + } + } + } + } + + return null; + } + + /* + public Property getOpenProperty(DataObject dataObject, String featureName) + { + EObject eObject = (EObject)dataObject; + EClass eClass = eObject.eClass(); + Set openFeatureSet = new HashSet(); + for (int i = 0, count = eClass.getEAllStructuralFeatures().size(); i < count; ++i) + { + EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature(i); + if (FeatureMapUtil.isFeatureMap(eStructuralFeature)) + { + List features = (List)eObject.eGet(eStructuralFeature); + for (int j = 0, size = features.size(); j < size; ++j) + { + FeatureMap.Entry entry = (FeatureMap.Entry)features.get(j); + EStructuralFeature entryFeature = entry.getEStructuralFeature(); + if (openFeatureSet.add(entryFeature)) + { + Property property = (Property)entryFeature; + if (property.getName().equals(featureName)) return (Property)entryFeature; + + List aliasNames = property.getAliasNames(); + for (int aliasCount = aliasNames.size(); aliasCount > 0; ) + { + if (aliasNames.get(--aliasCount).equals(featureName)) return (Property)entryFeature; + } + } + } + } + } + return null; + } + */ + + /** + * + * + * @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; + } + + /** + * + * + * @generated NOT + */ + public Property getProperty(String propertyName) + { + if (propertyNameToPropertyMap == null) initAliasNames(); + Property property = (Property)propertyNameToPropertyMap.get(propertyName); + if (property == null && !isOpen()) { + initAliasNames(); + property = (Property)propertyNameToPropertyMap.get(propertyName); + } + return property; + } + + protected Map propertyNameToPropertyMap; + + public List getInstanceProperties() { + return DataObjectUtil.getMetaObjectInstanceProperties(this); + } + + public Object get(Property property) { + return DataObjectUtil.getMetaObjectInstanceProperty(this, property); + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // org.apache.tuscany.sdo.model.Type method implementations + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + + public List getBaseType() { + return this.getBaseTypes(); + } + + public List getProperty() { + return this.getProperties(); + } + + public List getAliasName() { + return this.getAliasNames(); + } + + public void unsetAbstract() { + eUnset(EcorePackage.eINSTANCE.getEClass_Abstract()); + } + + public boolean isSetAbstract() { + return eIsSet(EcorePackage.eINSTANCE.getEClass_Abstract()); + } + + public Sequence getAny() { + throw new UnsupportedOperationException(); + } + + public Sequence getAnyAttribute() { + throw new UnsupportedOperationException(); + } + + public void setDataType(boolean value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void unsetDataType() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetDataType() { + return false; + } + + public void setOpen(boolean value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void unsetOpen() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetOpen() { + return isOpen(); + } + + public void setSequenced(boolean value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void unsetSequenced() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetSequenced() { + return isSequenced(); + } + + public void unsetName() + { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetName() + { + return true; + } + + public void unsetUri() + { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetUri() + { + return true; + } + + public void setUri(String value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public String getUri() { + return getURI(); + } + + public Property getChangeSummaryProperty() { + if (changeSummaryPropertyCache == UNINITIALIZED_PROPERTY) { + changeSummaryPropertyCache = null; + + // Find property of type ChangeSummaryType, if one exists + Type csType = ((ModelFactoryImpl)ModelFactory.INSTANCE).getChangeSummaryType(); + for (Iterator props = getProperties().iterator(); props.hasNext(); ) { + Property p = (Property)props.next(); + if(csType == p.getType()) { + changeSummaryPropertyCache = p; + break; + } + } + } + + return changeSummaryPropertyCache; + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // DataObject method implementations + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + /* + public Object get(int propertyIndex) { + return DataObjectUtil.get(this, propertyIndex); + } + + public void set(int propertyIndex, Object value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSet(int propertyIndex) { + return DataObjectUtil.isSet(this, propertyIndex); + } + + public void unset(int propertyIndex) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public Object get(Property property) { + return DataObjectUtil.get(this, ((EStructuralFeature)property).getFeatureID()); + } + + public void set(Property property, Object value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSet(Property property) { + return DataObjectUtil.isSet(this, ((EStructuralFeature)property).getFeatureID()); + } + + public void unset(Property property) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject getContainer() { + return (DataObject)eContainer(); + } + + public Property getContainmentProperty() { + return (Property)eContainmentFeature(); + } + + public Type getType() { + return (Type)ModelPackageImpl.eINSTANCE.getType(); + } + + // Remaining DataObject methods are (will be) implemented as straight delegation to DataObjectUtil + + public Object get(String path) { + return DataObjectUtil.get(this, path); + } + + public void set(String path, Object value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSet(String path) { + return DataObjectUtil.isSet(this, path); + } + + public void unset(String path) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean getBoolean(String path) { + return DataObjectUtil.getBoolean(get(path)); + } + + public byte getByte(String path) { + return DataObjectUtil.getByte(get(path)); + } + + public char getChar(String path) { + return DataObjectUtil.getChar(get(path)); + } + + public double getDouble(String path) { + return DataObjectUtil.getDouble(get(path)); + } + + public float getFloat(String path) { + return DataObjectUtil.getFloat(get(path)); + } + + public int getInt(String path) { + return DataObjectUtil.getInt(get(path)); + } + + public long getLong(String path) { + return DataObjectUtil.getLong(get(path)); + } + + public short getShort(String path) { + return DataObjectUtil.getShort(get(path)); + } + + public byte[] getBytes(String path) { + return DataObjectUtil.getBytes(get(path)); + } + + public BigDecimal getBigDecimal(String path) { + return DataObjectUtil.getBigDecimal(get(path)); + } + + public BigInteger getBigInteger(String path) { + return DataObjectUtil.getBigInteger(get(path)); + } + + public DataObject getDataObject(String path) { + return (DataObject)get(path); + } + + public Date getDate(String path) { + return DataObjectUtil.getDate(get(path)); + } + + public String getString(String path) { + return DataObjectUtil.getString(get(path)); + } + + public List getList(String path) { + return (List)get(path); + } + + public Sequence getSequence(String path) { + return (Sequence)get(path); + } + + public void setBoolean(String path, boolean value) { + set(path, new Boolean(value)); + } + + public void setByte(String path, byte value) { + set(path, new Byte(value)); + } + + public void setChar(String path, char value) { + set(path, new Character(value)); + } + + public void setDouble(String path, double value) { + set(path, new Double(value)); + } + + public void setFloat(String path, float value) { + set(path, new Float(value)); + } + + public void setInt(String path, int value) { + set(path, new Integer(value)); + } + + public void setLong(String path, long value) { + set(path, new Long(value)); + } + + public void setShort(String path, short value) { + set(path, new Short(value)); + } + + public void setBytes(String path, byte[] value) { + set(path, value); + } + + public void setBigDecimal(String path, BigDecimal value) { + set(path, value); + } + + public void setBigInteger(String path, BigInteger value) { + set(path, value); + } + + public void setDataObject(String path, DataObject value) { + set(path, value); + } + + public void setDate(String path, Date value) { + set(path, value); + } + + public void setString(String path, String value) { + set(path, value); + } + + public void setList(String path, List value) { + set(path, value); + } + + public boolean getBoolean(int propertyIndex) { + return DataObjectUtil.getBoolean(this, propertyIndex); + } + + public byte getByte(int propertyIndex) { + return DataObjectUtil.getByte(this, propertyIndex); + } + + public char getChar(int propertyIndex) { + return DataObjectUtil.getChar(this, propertyIndex); + } + + public double getDouble(int propertyIndex) { + return DataObjectUtil.getDouble(this, propertyIndex); + } + + public float getFloat(int propertyIndex) { + return DataObjectUtil.getFloat(this, propertyIndex); + } + + public int getInt(int propertyIndex) { + return DataObjectUtil.getInt(this, propertyIndex); + } + + public long getLong(int propertyIndex) { + return DataObjectUtil.getLong(this, propertyIndex); + } + + public short getShort(int propertyIndex) { + return DataObjectUtil.getShort(this, propertyIndex); + } + + public byte[] getBytes(int propertyIndex) { + return DataObjectUtil.getBytes(this, propertyIndex); + } + + public BigDecimal getBigDecimal(int propertyIndex) { + return DataObjectUtil.getBigDecimal(this, propertyIndex); + } + + public BigInteger getBigInteger(int propertyIndex) { + return DataObjectUtil.getBigInteger(this, propertyIndex); + } + + public DataObject getDataObject(int propertyIndex) { + return DataObjectUtil.getDataObject(this, propertyIndex); + } + + public Date getDate(int propertyIndex) { + return DataObjectUtil.getDate(this, propertyIndex); + } + + public String getString(int propertyIndex) { + return DataObjectUtil.getString(this, propertyIndex); + } + + public List getList(int propertyIndex) { + return DataObjectUtil.getList(this, propertyIndex); + } + + public Sequence getSequence(int propertyIndex) { + return DataObjectUtil.getSequence(this, propertyIndex); + } + + public void setBoolean(int propertyIndex, boolean value) { + set(propertyIndex, new Boolean(value)); + } + + public void setByte(int propertyIndex, byte value) { + set(propertyIndex, new Byte(value)); + } + + public void setChar(int propertyIndex, char value) { + set(propertyIndex, new Character(value)); + } + + public void setDouble(int propertyIndex, double value) { + set(propertyIndex, new Double(value)); + } + + public void setFloat(int propertyIndex, float value) { + set(propertyIndex, new Float(value)); + } + + public void setInt(int propertyIndex, int value) { + set(propertyIndex, new Integer(value)); + } + + public void setLong(int propertyIndex, long value) { + set(propertyIndex, new Long(value)); + } + + public void setShort(int propertyIndex, short value) { + set(propertyIndex, new Short(value)); + } + + public void setBytes(int propertyIndex, byte[] value) { + set(propertyIndex, value); + } + + public void setBigDecimal(int propertyIndex, BigDecimal value) { + set(propertyIndex, value); + } + + public void setBigInteger(int propertyIndex, BigInteger value) { + set(propertyIndex, value); + } + + public void setDataObject(int propertyIndex, DataObject value) { + set(propertyIndex, value); + } + + public void setDate(int propertyIndex, Date value) { + set(propertyIndex, value); + } + + public void setString(int propertyIndex, String value) { + set(propertyIndex, value); + } + + public void setList(int propertyIndex, List value) { + set(propertyIndex, value); + } + + public boolean getBoolean(Property property) { + return DataObjectUtil.getBoolean(this, property); + } + + public byte getByte(Property property) { + return DataObjectUtil.getByte(this, property); + } + + public char getChar(Property property) { + return DataObjectUtil.getChar(this, property); + } + + public double getDouble(Property property) { + return DataObjectUtil.getDouble(this, property); + } + + public float getFloat(Property property) { + return DataObjectUtil.getFloat(this, property); + } + + public int getInt(Property property) { + return DataObjectUtil.getInt(this, property); + } + + public long getLong(Property property) { + return DataObjectUtil.getLong(this, property); + } + + public short getShort(Property property) { + return DataObjectUtil.getShort(this, property); + } + + public byte[] getBytes(Property property) { + return DataObjectUtil.getBytes(this, property); + } + + public BigDecimal getBigDecimal(Property property) { + return DataObjectUtil.getBigDecimal(this, property); + } + + public BigInteger getBigInteger(Property property) { + return DataObjectUtil.getBigInteger(this, property); + } + + public DataObject getDataObject(Property property) { + return DataObjectUtil.getDataObject(this, property); + } + + public Date getDate(Property property) { + return DataObjectUtil.getDate(this, property); + } + + public String getString(Property property) { + return DataObjectUtil.getString(this, property); + } + + public List getList(Property property) { + return DataObjectUtil.getList(this, property); + } + + public Sequence getSequence(Property property) { + return DataObjectUtil.getSequence(this, property); + } + + public void setBoolean(Property property, boolean value) { + set(property, new Boolean(value)); + } + + public void setByte(Property property, byte value) { + set(property, new Byte(value)); + } + + public void setChar(Property property, char value) { + set(property, new Character(value)); + } + + public void setDouble(Property property, double value) { + set(property, new Double(value)); + } + + public void setFloat(Property property, float value) { + set(property, new Float(value)); + } + + public void setInt(Property property, int value) { + set(property, new Integer(value)); + } + + public void setLong(Property property, long value) { + set(property, new Long(value)); + } + + public void setShort(Property property, short value) { + set(property, new Short(value)); + } + + public void setBytes(Property property, byte[] value) { + set(property, value); + } + + public void setBigDecimal(Property property, BigDecimal value) { + set(property, value); + } + + public void setBigInteger(Property property, BigInteger value) { + set(property, value); + } + + public void setDataObject(Property property, DataObject value) { + set(property, value); + } + + public void setDate(Property property, Date value) { + set(property, value); + } + + public void setString(Property property, String value) { + set(property, value); + } + + public void setList(Property property, List value) { + set(property, value); + } + + public DataObject createDataObject(String propertyName) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(String propertyName, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property, Type type) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void delete() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataGraph getDataGraph() { + return DataObjectUtil.getDataGraph(this); + } + + public Sequence getSequence() { + EAttribute mixedFeature = BasicExtendedMetaData.INSTANCE.getMixedFeature(eClass()); + return mixedFeature != null ? (Sequence)eGet(mixedFeature, true, false) : null; + } + + public List getInstanceProperties() { + return DataObjectUtil.getInstanceProperties(this); + } + + public DataObject getRootObject() { + return DataObjectUtil.getRootObject(this); + } + + public ChangeSummary getChangeSummary() { + // TODO: implement this method + throw new UnsupportedOperationException(); + } + + public void detach() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + //DataObjectUtil.detach(this); + } + */ + +} //ClassTypeImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DataGraphImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DataGraphImpl.java new file mode 100644 index 0000000000..d61b7fd05e --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DataGraphImpl.java @@ -0,0 +1,852 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.io.Serializable; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; + +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.helper.TypeHelperImpl; +import org.apache.tuscany.sdo.lib.SDOObjectInputStream; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.EObjectImpl; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.util.BasicExtendedMetaData; +import org.eclipse.emf.ecore.util.ExtendedMetaData; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.TypeHelper; + + +/** + * + * An implementation of the model object 'EData Graph'. + * @extends DataGraph, Adapter, Serializable + * + *

+ * The following features are implemented: + *

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

+ * + * @generated + */ +public class DataGraphImpl extends EObjectImpl implements DataGraph, Adapter, Serializable +{ + /** + * The default value of the '{@link #getResourceSet() Resource Set}' attribute. + * + * + * @see #getResourceSet() + * @generated + * @ordered + */ + protected static final ResourceSet RESOURCE_SET_EDEFAULT = null; + + /** + * The cached value of the '{@link #getResourceSet() Resource Set}' attribute. + * + * + * @see #getResourceSet() + * @generated + * @ordered + */ + protected ResourceSet resourceSet = RESOURCE_SET_EDEFAULT; + + /** + * The default value of the '{@link #getRootResource() Root Resource}' attribute. + * + * + * @see #getRootResource() + * @generated + * @ordered + */ + protected static final Resource ROOT_RESOURCE_EDEFAULT = null; + + /** + * The cached value of the '{@link #getEChangeSummary() EChange Summary}' reference. + * + * + * @see #getEChangeSummary() + * @generated + * @ordered + */ + protected ChangeSummary eChangeSummary = null; + + /** + * The cached value of the '{@link #getERootObject() ERoot Object}' reference. + * + * + * @see #getERootObject() + * @generated + * @ordered + */ + protected EObject eRootObject = null; + + /** + * The cached extended metadata to wrap the resource set's package registry. + */ + protected ExtendedMetaData extendedMetaData; + + /** + * + * + * @generated + */ + protected DataGraphImpl() + { + super(); + } + + /** + * + * + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getDataGraph(); + } + + public boolean isAdapterForType(Object type) + { + return type == DataGraph.class; + } + + public void notifyChanged(Notification msg) + { + } + + public Notifier getTarget() + { + return getResourceSet(); + } + + public void setTarget(Notifier newTarget) + { + } + + protected ExtendedMetaData getExtendedMetaData() + { + if (extendedMetaData == null) + { + getResourceSet(); + } + return extendedMetaData; + } + + /** + * + * + * @generated NOT + */ + public ResourceSet getResourceSet() + { + if (resourceSet == null) + { + if (eResource() != null) + { + resourceSet = eResource().getResourceSet(); + } + if (resourceSet == null) + { + resourceSet = createResourceSet(); + } + initializeResourceSet(resourceSet); + } + return resourceSet; + } + + protected ResourceSet createResourceSet() + { + return DataObjectUtil.createResourceSet(); + } + + protected Resource createRootResource() + { + Resource result = resourceSet.createResource(URI.createURI("root.xml")); + result.getContents().clear(); + return result; + } + + protected Resource createChangeSummaryResource() + { + Resource result = resourceSet.createResource(URI.createURI("change-summary.xml")); + result.getContents().clear(); + return result; + } + + protected void initializeResourceSet(ResourceSet resourceSet) + { + if (resourceSet == null) + { + extendedMetaData = null; + } + else + { + extendedMetaData = new BasicExtendedMetaData(resourceSet.getPackageRegistry()); + resourceSet.eAdapters().add(this); + } + } + + /** + * + * + * @generated + */ + public void setResourceSetGen(ResourceSet newResourceSet) + { + ResourceSet oldResourceSet = resourceSet; + resourceSet = newResourceSet; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.DATA_GRAPH__RESOURCE_SET, oldResourceSet, resourceSet)); + } + + public void setResourceSet(ResourceSet newResourceSet) + { + if (resourceSet != null) + { + resourceSet.eAdapters().remove(this); + } + setResourceSetGen(newResourceSet); + initializeResourceSet(newResourceSet); + } + + /** + * + * + * @generated NOT + */ + public Resource getRootResource() + { + if (eRootObject == null) + { + Resource result = getResourceSet().getResource(URI.createURI("root.xml"), false); + if (result == null) + { + result = createRootResource(); + } + + return result; + } + else + { + return eRootObject.eResource(); + } + } + + public Resource getDataGraphResource() + { + Resource result = eResource(); + if (result == null) + { + result = getResourceSet().createResource(URI.createURI("all.datagraph")); + result.getContents().add(this); + } + return result; + } + + /** + * + * + * @generated + */ + public ChangeSummary getEChangeSummary() + { + return eChangeSummary; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetEChangeSummary(ChangeSummary newEChangeSummary, NotificationChain msgs) + { + ChangeSummary oldEChangeSummary = eChangeSummary; + eChangeSummary = newEChangeSummary; + if (eNotificationRequired()) + { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY, oldEChangeSummary, newEChangeSummary); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + public void setEChangeSummary(ChangeSummary newEChangeSummary) + { + if (newEChangeSummary != eChangeSummary) + { + NotificationChain msgs = null; + if (eChangeSummary != null) + msgs = ((InternalEObject)eChangeSummary).eInverseRemove(this, SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH, ChangeSummary.class, msgs); + if (newEChangeSummary != null) + msgs = ((InternalEObject)newEChangeSummary).eInverseAdd(this, SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH, ChangeSummary.class, msgs); + msgs = basicSetEChangeSummary(newEChangeSummary, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY, newEChangeSummary, newEChangeSummary)); + } + + /** + * + * + * @generated + */ + public EObject getERootObject() + { + return eRootObject; + } + + /** + * + * + * @generated + */ + public void setERootObjectGen(EObject newERootObject) + { + EObject oldERootObject = eRootObject; + eRootObject = newERootObject; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.DATA_GRAPH__EROOT_OBJECT, oldERootObject, eRootObject)); + } + + public void setERootObject(EObject newERootObject) + { + // If there is a resource set already... + // + if (resourceSet != null) + { + // Get the root resource and if there's a root object in it already, clear it. + // Then set the root object and add it to the root resource. + // + List contents = getRootResource().getContents(); + if (eRootObject != null) + { + contents.clear(); + } + setERootObjectGen(newERootObject); + if (newERootObject != null) + { + contents.add(newERootObject); + } + } + else + { + // Set the root object and see if it has a resource we can reuse. + // + setERootObjectGen(newERootObject); + Resource rootResource = newERootObject.eResource(); + if (rootResource != null) + { + // If there is no resource set + // + if (rootResource.getResourceSet() == null) + { + // Demand create one and add this resource to it. + // + getResourceSet().getResources().add(rootResource); + } + else + { + // Reuse the existing resource set. + // + setResourceSet(rootResource.getResourceSet()); + } + } + else + { + // Demand create the resource set and the root resource, and add to it's contents. + // + getResourceSet(); + createRootResource().getContents().add(newERootObject); + } + } + } + + /** + * + * + * @generated NOT + */ + public EClassifier getEClassifier(String namespaceURI, String typeName) + { + ExtendedMetaData extendedMetaData = getExtendedMetaData(); + EPackage ePackage = extendedMetaData.getPackage(namespaceURI); + if (ePackage != null) + { + EClassifier eClassifier = ePackage.getEClassifier(typeName); + if (eClassifier == null) + { + eClassifier = extendedMetaData.getType(ePackage, typeName); + } + return eClassifier; + } + else + { + return null; + } + } + + /** + * + * + * @generated NOT + */ + public Type getType(String namespaceURI, String typeName) + { + return TypeHelper.INSTANCE.getType(namespaceURI, typeName); + //EClassifier eClassifier = getEClassifier(namespaceURI, typeName); + //return eClassifier == null ? null : SDOUtil.getType(eClassifier); + } + + /** + * + * + * @generated + */ + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) + { + if (featureID >= 0) + { + switch (eDerivedStructuralFeatureID(featureID, baseClass)) + { + case SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY: + if (eChangeSummary != null) + msgs = ((InternalEObject)eChangeSummary).eInverseRemove(this, SDOPackage.CHANGE_SUMMARY__EDATA_GRAPH, ChangeSummary.class, msgs); + return basicSetEChangeSummary((ChangeSummary)otherEnd, msgs); + default: + return eDynamicInverseAdd(otherEnd, featureID, baseClass, msgs); + } + } + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + return eBasicSetContainer(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, Class baseClass, NotificationChain msgs) + { + if (featureID >= 0) + { + switch (eDerivedStructuralFeatureID(featureID, baseClass)) + { + case SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY: + return basicSetEChangeSummary(null, msgs); + default: + return eDynamicInverseRemove(otherEnd, featureID, baseClass, msgs); + } + } + return eBasicSetContainer(null, featureID, msgs); + } + + /** + * + * + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case SDOPackage.DATA_GRAPH__RESOURCE_SET: + return getResourceSet(); + case SDOPackage.DATA_GRAPH__ROOT_RESOURCE: + return getRootResource(); + case SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY: + return getEChangeSummary(); + case SDOPackage.DATA_GRAPH__EROOT_OBJECT: + return getERootObject(); + } + return eDynamicGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case SDOPackage.DATA_GRAPH__RESOURCE_SET: + setResourceSet((ResourceSet)newValue); + return; + case SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY: + setEChangeSummary((ChangeSummary)newValue); + return; + case SDOPackage.DATA_GRAPH__EROOT_OBJECT: + setERootObject((EObject)newValue); + return; + } + eDynamicSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case SDOPackage.DATA_GRAPH__RESOURCE_SET: + setResourceSet(RESOURCE_SET_EDEFAULT); + return; + case SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY: + setEChangeSummary((ChangeSummary)null); + return; + case SDOPackage.DATA_GRAPH__EROOT_OBJECT: + setERootObject((EObject)null); + return; + } + eDynamicUnset(featureID); + } + + /** + * + * + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case SDOPackage.DATA_GRAPH__RESOURCE_SET: + return RESOURCE_SET_EDEFAULT == null ? resourceSet != null : !RESOURCE_SET_EDEFAULT.equals(resourceSet); + case SDOPackage.DATA_GRAPH__ROOT_RESOURCE: + return ROOT_RESOURCE_EDEFAULT == null ? getRootResource() != null : !ROOT_RESOURCE_EDEFAULT.equals(getRootResource()); + case SDOPackage.DATA_GRAPH__ECHANGE_SUMMARY: + return eChangeSummary != null; + case SDOPackage.DATA_GRAPH__EROOT_OBJECT: + return eRootObject != null; + } + return eDynamicIsSet(featureID); + } + + public DataObject createEDataObject(Type type) + { + return DataObjectUtil.create(type); + } + + public DataObject getRootObject() + { + return (DataObject)getERootObject(); + } + + public DataObject createRootObject(String namespaceURI, String typeName) + { + Type type = getType(namespaceURI, typeName); + if (type == null) { + throw new IllegalArgumentException( + "createRootObject given invalid parameters: getType("+ + namespaceURI+", "+typeName+") returned null type"); + } + if (getERootObject() != null) { + throw new IllegalStateException( + "createRootObject was called when a root object already exists"); + } + DataObject dataObject = DataObjectUtil.create(type); + setERootObject((EObject)dataObject); + return dataObject; + } + + public DataObject createRootObject(Type type) + { + if (type == null) { + throw new IllegalArgumentException( + "createRootObject must be provided a non-null type"); + } + if (getERootObject() != null) { + throw new IllegalStateException( + "createRootObject was called when a root object already exists"); + } + DataObject dataObject = DataObjectUtil.create(type); + setERootObject((EObject)dataObject); + return dataObject; + } + + public ChangeSummary getChangeSummary() + { + //FB is this the right place to create the resources? + ChangeSummary changeSummary = getEChangeSummary(); + if (changeSummary == null) + { + getRootResource(); + changeSummary = createEChangeSummary(); + setEChangeSummary(changeSummary); + } + + if (((ChangeSummaryImpl)changeSummary).eResource() == null) + { + Resource changeSummaryResource = createChangeSummaryResource(); + changeSummaryResource.getContents().add(changeSummary); + } + + return changeSummary; + } + + protected ChangeSummaryImpl createEChangeSummary() + { + return (ChangeSummaryImpl)SDOFactory.eINSTANCE.createChangeSummary(); + } + + public static class EDataGraphExternalizable implements Externalizable + { + protected DataGraphImpl eDataGraph; + //protected Map writeReplacements = new HashMap(); + + public EDataGraphExternalizable() + { + } + + public EDataGraphExternalizable(DataGraphImpl eDataGraph) + { + this.eDataGraph = eDataGraph; + } + + public void writeExternal(ObjectOutput objectOutput) throws IOException + { + ByteArrayOutputStream byteArrayOutputStream = + new ByteArrayOutputStream() + { + public byte [] toByteArray() + { + return super.toByteArray(); + } + }; + + eDataGraph.getDataGraphResource().save(byteArrayOutputStream, null); + objectOutput.writeInt(byteArrayOutputStream.toByteArray().length); + objectOutput.write(byteArrayOutputStream.toByteArray()); + } + + public void readExternal(ObjectInput objectInput) throws IOException + { + int length = objectInput.readInt(); + byte [] bytes = new byte [length]; + objectInput.readFully(bytes); + + ResourceSet resourceSet = createResourceSet(); + Resource resource = resourceSet.createResource(URI.createURI("all.datagraph")); + + HashMap map = null; + if(objectInput instanceof SDOObjectInputStream) + { + TypeHelperImpl th = (TypeHelperImpl)((SDOObjectInputStream)objectInput).getHelperContext().getTypeHelper(); + map = new HashMap(); + map.put("EXTENDED_META_DATA", th.getExtendedMetaData()); + } + resource.load(new ByteArrayInputStream(bytes), map); + eDataGraph = (DataGraphImpl)resource.getContents().get(0); + } + + protected ResourceSet createResourceSet() + { + return DataObjectUtil.createResourceSet(); + } + + /* + public Object getWriteReplacement(EObject eObject) + { + Object result = writeReplacements.get(eObject); + if (result == null) + { + result = new EDataObjectExternalizable(eDataGraph, eObject); + writeReplacements.put(eObject, result); + } + return result; + } + */ + + protected Object readResolve() + { + return eDataGraph; + } + } + + /* + public static class EDataObjectExternalizable implements Externalizable + { + protected EObject eObject; + protected DataGraphImpl eDataGraph; + + public EDataObjectExternalizable() + { + } + + public EDataObjectExternalizable(DataGraphImpl eDataGraph, EObject eObject) + { + this.eDataGraph = eDataGraph; + this.eObject = eObject; + } + + public void writeExternal(ObjectOutput objectOutput) throws IOException + { + // Write the data object reference too. + String uri = eObject.eResource().getURIFragment(eObject); + objectOutput.writeUTF(uri); + objectOutput.writeObject(eDataGraph.getWriteReplacement()); + } + + public void readExternal(ObjectInput objectInput) throws IOException, ClassNotFoundException + { + String uri = objectInput.readUTF(); + eDataGraph = (DataGraphImpl)objectInput.readObject(); + eObject = eDataGraph.getRootResource().getEObject(uri); + } + + protected Object readResolve() + { + return eObject; + } + } + */ + + protected EDataGraphExternalizable eDataGraphExternalizable; + //protected Adapter modificationTracker; + + public Object getWriteReplacement() + { + if (eDataGraphExternalizable == null) + { + eDataGraphExternalizable = createEDataGraphExternalizable(); + /* + getRootResource().setTrackingModification(true); + modificationTracker = + new AdapterImpl() + { + public void notifyChanged(Notification notification) + { + if (notification.getFeatureID(Resource.class) == Resource.RESOURCE__IS_MODIFIED && notification.getNewBooleanValue()) + { + eDataGraphExternalizable = null; + modificationTracker = null; + ((Resource)target).eAdapters().remove(this); + } + } + }; + getRootResource().eAdapters().add(modificationTracker); + */ + } + return eDataGraphExternalizable; + } + + protected EDataGraphExternalizable createEDataGraphExternalizable() + { + return new EDataGraphExternalizable(this); + } + + /* + public Object getWriteReplacement(EObject eObject) + { + return ((EDataGraphExternalizable)getWriteReplacement()).getWriteReplacement(eObject); + } + */ + + public Object writeReplace() + { + return getWriteReplacement(); + } + + public EObject eObjectForURIFragmentSegment(String uriFragmentSegment) + { + if (uriFragmentSegment.startsWith("@models.")) + { + if (resourceSet != null) + { + int count = Integer.parseInt(uriFragmentSegment.substring(8)); + for (Iterator i = resourceSet.getResources().iterator(); i.hasNext(); ) + { + Resource ePackageResource = (Resource)i.next(); + List resourceContents = ePackageResource.getContents(); + if (resourceContents.size() == 1 && resourceContents.get(0) instanceof EPackage && count-- == 0) + { + return (EObject)resourceContents.get(0); + } + } + } + + return null; + } + else + { + return super.eObjectForURIFragmentSegment(uriFragmentSegment); + } + } + + /** + * + * + * @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/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectBase.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectBase.java new file mode 100644 index 0000000000..36d1fa9fa8 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectBase.java @@ -0,0 +1,477 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + + +import java.util.List; + +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.helper.HelperContextImpl; +import org.apache.tuscany.sdo.util.BasicSequence; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.util.BasicFeatureMap; +import org.eclipse.emf.ecore.util.EDataTypeEList; +import org.eclipse.emf.ecore.util.EDataTypeUniqueEList; +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; +import org.eclipse.emf.ecore.util.EObjectEList; +import org.eclipse.emf.ecore.util.EObjectResolvingEList; +import org.eclipse.emf.ecore.util.EObjectWithInverseEList; +import org.eclipse.emf.ecore.util.EObjectWithInverseResolvingEList; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.ecore.util.InternalEList; + +import commonj.sdo.Sequence; +import commonj.sdo.Type; + + +/** + * Base implementation of the SDO DataObject interface. Used as base class for generated (static) SDO classes + */ +public abstract class DataObjectBase extends ExtensibleDataObjectImpl +{ + + protected int OPPOSITE_FEATURE_BASE = EOPPOSITE_FEATURE_BASE; + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Following methods should be proposed SPI for generated subclasses to use + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + protected boolean isNotifying() + { + return changeRecorder != null; + } + + protected interface ChangeKind + { + int SET = Notification.SET; + int UNSET = Notification.UNSET; + int RESOLVE = Notification.RESOLVE; + } + + 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, int oldIntValue, int newIntValue) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldIntValue, newIntValue)); + } + + protected void notify(int changeKind, int property, int oldIntValue, int newIntValue, boolean isSetChange) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldIntValue, newIntValue, isSetChange)); + } + + protected void notify(int changeKind, int property, double oldDoubleValue, double newDoubleValue) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldDoubleValue, newDoubleValue)); + } + + protected void notify(int changeKind, int property, double oldDoubleValue, double newDoubleValue, boolean isSetChange) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldDoubleValue, newDoubleValue, isSetChange)); + } + + protected void notify(int changeKind, int property, boolean oldBooleanValue, boolean newBooleanValue) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldBooleanValue, newBooleanValue)); + } + + protected void notify(int changeKind, int property, boolean oldBooleanValue, boolean newBooleanValue, boolean isSetChange) + { + eNotify(new ENotificationImpl(this, Notification.SET, property, oldBooleanValue, newBooleanValue, isSetChange)); + } + + public interface ListKind + { + int CONTAINMENT = 0; + int CONTAINMENT_UNSETTABLE = 1; + int CONTAINMENT_RESOLVING = 2; + int CONTAINMENT_RESOLVING_UNSETTABLE = 3; + int CONTAINMENT_INVERSE = 4; + int CONTAINMENT_INVERSE_UNSETTABLE = 5; + int CONTAINMENT_INVERSE_RESOLVING = 6; + int CONTAINMENT_INVERSE_RESOLVING_UNSETTABLE = 7; + + int NONCONTAINMENT = 8; + int NONCONTAINMENT_UNSETTABLE = 9; + int NONCONTAINMENT_RESOLVING = 10; + int NONCONTAINMENT_RESOLVING_UNSETTABLE = 11; + int NONCONTAINMENT_INVERSE = 12; + int NONCONTAINMENT_INVERSE_UNSETTABLE = 13; + int NONCONTAINMENT_MANYINVERSE = 14; + int NONCONTAINMENT_MANYINVERSE_UNSETTABLE = 15; + int NONCONTAINMENT_INVERSE_RESOLVING = 16; + int NONCONTAINMENT_INVERSE_RESOLVING_UNSETTABLE = 17; + int NONCONTAINMENT_MANYINVERSE_RESOLVING = 18; + int NONCONTAINMENT_MANYINVERSE_RESOLVING_UNSETTABLE = 19; + + int DATATYPE = 20; + int DATATYPE_UNSETTABLE = 21; + int DATATYPE_UNIQUE = 22; + int DATATYPE_UNIQUE_UNSETTABLE = 23; + + int BASIC = 24; + } + + /** + * @deprecated + */ + protected List createPropertyList(int listKind, Class dataClass, int property) + { + return createPropertyList(listKind, dataClass, property, 0); + } + + protected List createPropertyList(int listKind, Class dataClass, int property, int reverseProperty) + { + switch (listKind) + { + case ListKind.CONTAINMENT: + return new EObjectContainmentEList(dataClass, this, property); + case ListKind.CONTAINMENT_INVERSE_RESOLVING_UNSETTABLE: + return new EObjectContainmentWithInverseEList.Unsettable.Resolving(dataClass, this, property, reverseProperty); + case ListKind.CONTAINMENT_INVERSE_RESOLVING: + return new EObjectContainmentWithInverseEList.Resolving(dataClass, this, property, reverseProperty); + case ListKind.CONTAINMENT_INVERSE_UNSETTABLE: + return new EObjectContainmentWithInverseEList.Unsettable(dataClass, this, property, reverseProperty); + case ListKind.CONTAINMENT_INVERSE: + return new EObjectContainmentWithInverseEList(dataClass, this, property, reverseProperty); + case ListKind.CONTAINMENT_RESOLVING_UNSETTABLE: + return new EObjectContainmentEList.Unsettable.Resolving(dataClass, this, property); + case ListKind.CONTAINMENT_RESOLVING: + return new EObjectContainmentEList.Resolving(dataClass, this, property); + case ListKind.CONTAINMENT_UNSETTABLE: + return new EObjectContainmentEList.Unsettable(dataClass, this, property); + case ListKind.NONCONTAINMENT_MANYINVERSE_RESOLVING_UNSETTABLE: + return new EObjectWithInverseResolvingEList.Unsettable.ManyInverse(dataClass, this, property, reverseProperty); + case ListKind.NONCONTAINMENT_MANYINVERSE_RESOLVING: + return new EObjectWithInverseResolvingEList.ManyInverse(dataClass, this, property, reverseProperty); + case ListKind.NONCONTAINMENT_INVERSE_RESOLVING_UNSETTABLE: + return new EObjectWithInverseResolvingEList.Unsettable(dataClass, this, property, reverseProperty); + case ListKind.NONCONTAINMENT_INVERSE_RESOLVING: + return new EObjectWithInverseResolvingEList(dataClass, this, property, reverseProperty); + case ListKind.NONCONTAINMENT_MANYINVERSE_UNSETTABLE: + return new EObjectWithInverseEList.Unsettable.ManyInverse(dataClass, this, property, reverseProperty); + case ListKind.NONCONTAINMENT_MANYINVERSE: + return new EObjectWithInverseEList.ManyInverse(dataClass, this, property, reverseProperty); + case ListKind.NONCONTAINMENT_INVERSE_UNSETTABLE: + return new EObjectWithInverseEList.Unsettable(dataClass, this, property, reverseProperty); + case ListKind.NONCONTAINMENT_INVERSE: + return new EObjectWithInverseEList(dataClass, this, property, reverseProperty); + case ListKind.NONCONTAINMENT_RESOLVING_UNSETTABLE: + return new EObjectResolvingEList.Unsettable(dataClass, this, property); + case ListKind.NONCONTAINMENT_RESOLVING: + return new EObjectResolvingEList(dataClass, this, property); + case ListKind.NONCONTAINMENT_UNSETTABLE: + return new EObjectEList.Unsettable(dataClass, this, property); + case ListKind.NONCONTAINMENT: + return new EObjectEList(dataClass, this, property); + case ListKind.DATATYPE_UNIQUE_UNSETTABLE: + return new EDataTypeUniqueEList.Unsettable(dataClass, this, property); + case ListKind.DATATYPE_UNIQUE: + return new EDataTypeUniqueEList(dataClass, this, property); + case ListKind.DATATYPE_UNSETTABLE: + return new EDataTypeEList.Unsettable(dataClass, this, property); + case ListKind.DATATYPE: + return new EDataTypeEList(dataClass, this, property); + } + return null; + } + + protected BasicSequence createSequence(int property) { + return new BasicSequence(new BasicFeatureMap(this, property)); + } + + protected Sequence createSequence(Sequence sequence, Type type, int propertyIndex) { + return new BasicSequence((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)sequence).featureMap().list(((EClass)type).getEStructuralFeature(propertyIndex))); + } + + protected void createChangeSummary(int property) { + ChangeSummaryImpl changeSummary = (ChangeSummaryImpl)SDOFactory.eINSTANCE.createChangeSummary(); + set(property, changeSummary); + changeSummary.setDataObject(this); + } + + /* + * get the value of the type's property at propertyIndex via the sequence + * @param seq + * @param type + * @param propertyIndex + * @return + */ + protected Object get(Sequence seq, Type type, int propertyIndex) { + return ((FeatureMap.Internal.Wrapper)seq).featureMap().get(((EClass)type).getEStructuralFeature(propertyIndex), true); + } + + protected List getList(Sequence seq, Type type, int propertyIndex) { + return ((FeatureMap.Internal.Wrapper)seq).featureMap().list(((EClass)type).getEStructuralFeature(propertyIndex)); + } + + protected void set(Sequence seq, Type type, int propertyIndex, Object newValue) { + ((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)seq).featureMap()).set(((EClass)type).getEStructuralFeature(propertyIndex), newValue); + } + + protected void unset(Sequence seq, Type type, int propertyIndex) { + ((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)seq).featureMap()).clear(((EClass)type).getEStructuralFeature(propertyIndex)); + + } + protected boolean isSet(Sequence seq, Type type, int propertyIndex) { + return !((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)seq).featureMap()).isEmpty(((EClass)type).getEStructuralFeature(propertyIndex)); + } + + protected boolean isSequenceEmpty(Sequence sequence) { + return ((FeatureMap.Internal.Wrapper)sequence).featureMap().isEmpty(); + } + + protected void setSequence(Sequence seq, Object newValue) { + ((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)seq).featureMap()).set(newValue); + } + + protected void unsetSequence(Sequence seq) { + ((FeatureMap.Internal.Wrapper)seq).featureMap().clear(); + } + + protected ChangeContext basicAdd(Sequence seq, Type type, int propertyIndex, Object newValue, ChangeContext changeContext) { + ChangeContextImpl changeContextImpl = (ChangeContextImpl)changeContext; + changeContextImpl.notificationChain = ((FeatureMap.Internal)((FeatureMap.Internal.Wrapper)seq).featureMap()).basicAdd(((EClass)type).getEStructuralFeature(propertyIndex), newValue, changeContextImpl.notificationChain); + return changeContextImpl; + } + + private ChangeContextImpl initializeChangeContext(ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl; + if (changeContext == null) + { + changeContextImpl = new ChangeContextImpl(null); + } else + { + changeContextImpl = (ChangeContextImpl)changeContext; + } + return changeContextImpl; + } + + protected interface ChangeContext {} + + + protected ChangeContext inverseRemove(Object otherEnd, int propertyIndex, ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + changeContextImpl.notificationChain = super.eInverseRemove((InternalEObject)otherEnd, propertyIndex, changeContextImpl.notificationChain); + return changeContextImpl; + } + + protected ChangeContext inverseAdd(Object otherEnd, int propertyIndex, ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + changeContextImpl.notificationChain = super.eInverseAdd((InternalEObject)otherEnd, propertyIndex, changeContextImpl.notificationChain); + return changeContextImpl; + } + + protected ChangeContext inverseRemove(Object thisEnd, Object otherEnd, int propertyIndex, Class baseClass, ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + changeContextImpl.notificationChain = ((InternalEObject)thisEnd).eInverseRemove((InternalEObject)otherEnd, propertyIndex, baseClass, changeContextImpl.notificationChain); + return changeContextImpl; + } + + protected ChangeContext inverseAdd(Object thisEnd, Object otherEnd, int propertyIndex, Class baseClass, ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + changeContextImpl.notificationChain = ((InternalEObject)thisEnd).eInverseAdd((InternalEObject)otherEnd, propertyIndex, baseClass, changeContextImpl.notificationChain); + return changeContextImpl; + } + + protected ChangeContext addNotification(Object notifier, int eventType, int featureID, Object oldValue, Object newValue, boolean isSetChanged, ChangeContext changeContext) + { + ENotificationImpl notification = new ENotificationImpl((InternalEObject)notifier, eventType, featureID, oldValue, newValue, isSetChanged ); + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + if (changeContextImpl.notificationChain == null) changeContextImpl.notificationChain = notification; else changeContextImpl.notificationChain.add(notification); + return changeContextImpl; + } + + protected ChangeContext addNotification(Object notifier, int eventType, int featureID, Object oldValue, Object newValue, ChangeContext changeContext) + { + ENotificationImpl notification = new ENotificationImpl((InternalEObject)notifier, eventType, featureID, oldValue, newValue); + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + if (changeContextImpl.notificationChain == null) changeContextImpl.notificationChain = notification; else changeContextImpl.notificationChain.add(notification); + return changeContextImpl; + } + + protected ChangeContext removeFromList(List propertyList, Object objectToRemove, ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + changeContextImpl.notificationChain = ((InternalEList)propertyList).basicRemove(objectToRemove, changeContextImpl.notificationChain); + return changeContextImpl; + } + + protected ChangeContext removeFromSequence(Sequence sequence, Object otherEnd, ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + changeContextImpl.notificationChain = ((InternalEList)((FeatureMap.Internal.Wrapper)sequence).featureMap()).basicRemove(otherEnd, changeContextImpl.notificationChain); + return changeContextImpl; + } + + protected void dispatch(ChangeContext changeContext) + { + ChangeContextImpl changeContextImpl = initializeChangeContext(changeContext); + if (changeContextImpl.notificationChain != null) + { + changeContextImpl.notificationChain.dispatch(); + } + } + + protected boolean isProxy() // FB TODO : regen models and then remove this method + { + return eIsProxy(); + } + + protected boolean isProxy(Object object) + { + return ((EObject)object).eIsProxy(); + } + + protected Object resolveProxy(Object proxy) + { + Resource resource = this.eResource(); + ResourceSet resourceSet = resource != null ? resource.getResourceSet() : null; + if (resourceSet != null) return EcoreUtil.resolve((EObject)proxy, resourceSet); + + URI proxyURI = ((InternalEObject)proxy).eProxyURI(); + if (proxyURI != null) + { + EPackage ePackage = HelperContextImpl.getBuiltInModelRegistry().getEPackage(proxyURI.trimFragment().toString()); + if (ePackage != null) + { + resource = ePackage.eResource(); + if (resource != null) + { + return resource.getEObject(proxyURI.fragment().toString()); + } + } + } + return null; + } + + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Following methods override EMF methods to work with pure SDO generated subclasses + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + public EClass eStaticClass() + { + return (EClass)getStaticType(); + } + + public Type getStaticType() // must be overridden in subclasses + { + throw new UnsupportedOperationException(); + } + + public int eStaticFeatureCount() + { + return getStaticPropertyCount(); + } + + public int getStaticPropertyCount() // must be overridden in subclasses + { + throw new UnsupportedOperationException(); + } + + protected int internalConvertIndex(int internalIndex) + { + return internalIndex; + } + + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + Object result = get(internalConvertIndex(featureID), resolve); + if (coreType) + { + if (result instanceof FeatureMap.Internal.Wrapper) result = ((FeatureMap.Internal.Wrapper)result).featureMap(); + } + return result; + } + + public void eSet(int featureID, Object newValue) + { + set(internalConvertIndex(featureID), newValue); + } + + public void eUnset(int featureID) + { + unset(internalConvertIndex(featureID)); + } + + public boolean eIsSet(int featureID) + { + return isSet(internalConvertIndex(featureID)); + } + + private class ChangeContextImpl implements ChangeContext + { + protected NotificationChain notificationChain; + public ChangeContextImpl(NotificationChain notificationChain) { + this.notificationChain = notificationChain; + } + } + + //FB TODO ... review this? ... what about eInverseAdd? + public NotificationChain eInverseRemove(InternalEObject otherEnd, int internalIndex, NotificationChain msgs) + { + return ((ChangeContextImpl)inverseRemove(otherEnd, internalConvertIndex(internalIndex), new ChangeContextImpl(msgs))).notificationChain; + } + + public String toString() + { + StringBuffer result = new StringBuffer(getClass().getName()); + result.append('@'); + result.append(Integer.toHexString(hashCode())); + if (eIsProxy()) + { + result.append(" (proxyURI: "); + result.append(eProxyURI()); + result.append(')'); + } + return result.toString(); + } + +} //DataObjectBase + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectImpl.java new file mode 100644 index 0000000000..e2e3cf649b --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DataObjectImpl.java @@ -0,0 +1,1551 @@ +/** + * + * 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.apache.tuscany.sdo.util.VirtualSequence; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.impl.BasicNotifierImpl.EAdapterList; +import org.eclipse.emf.common.util.BasicEList; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.InternalEObject; +import org.eclipse.emf.ecore.EStructuralFeature.Internal.DynamicValueHolder; +import org.eclipse.emf.ecore.impl.BasicEObjectImpl; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.util.EContentsEList; +import org.eclipse.emf.ecore.util.ECrossReferenceEList; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Sequence; +import commonj.sdo.Type; +import commonj.sdo.impl.ExternalizableDelegator; + + +/** + * + * Base implementation of the SDO DataObject interface. This implementation allocates the minimum storage + * overhead needed for SDO. It provides a complete implementation of the API, but does not, however, allocate + * any storage for the actual properties of the data object. It instead requires subclasses for this purpose. + * The subclass, DynamicDataObjectImpl serves as a concrete implementation class for dynamic data objects. + * Static data object storage is provided by generated classes, which also directly or indirectly derive from + * this class. + * + *

+ *

+ * + * @generated + */ +public abstract class DataObjectImpl extends BasicEObjectImpl implements DataObject +{ + protected InternalEObject eContainer; + protected int eContainerFeatureID; + protected SDOChangeRecorder changeRecorder; + protected Object location; // Resource.Internal (if object is directly contained in a resource) or URI (if it is a proxy) + protected BasicEList eAdapters; + + /** + * + * + * @generated + */ + protected DataObjectImpl() + { + super(); + } + + /** + * + * + * @generated NOT + */ + public Object get(int propertyIndex) + { + return get(DataObjectUtil.getProperty(this, propertyIndex)); + } + + /** + * + * + * @generated NOT + */ + public void set(int propertyIndex, Object value) + { + set(DataObjectUtil.getProperty(this, propertyIndex), value); + } + + /** + * + * + * @generated NOT + */ + public boolean isSet(int propertyIndex) + { + return isSet(DataObjectUtil.getProperty(this, propertyIndex)); + } + + /** + * + * + * @generated NOT + */ + public void unset(int propertyIndex) + { + unset(DataObjectUtil.getProperty(this, propertyIndex)); + } + + /** + * + * + * @generated NOT + */ + public Object get(Property property) + { + return eGet((EStructuralFeature)property, true, false); + } + + /** + * + * + * @generated NOT + */ + public void set(Property property, Object value) + { + eSet((EStructuralFeature)property, value); + } + + /** + * + * + * @generated NOT + */ + public boolean isSet(Property property) + { + return eIsSet((EStructuralFeature)property); + } + + /** + * + * + * @generated NOT + */ + public void unset(Property property) + { + eUnset((EStructuralFeature)property); + } + + /** + * + * + * @generated NOT + */ + public DataObject getContainer() + { + return (DataObject)eContainer(); + } + + /** + * + * + * @generated NOT + */ + public Property getContainmentProperty() + { + return (Property)eContainmentFeature(); + } + + /** + * + * + * @generated NOT + */ + public Type getType() + { + return (Type)eClass(); + } + + /** + * + * + * @generated NOT + */ + public Object writeReplace() throws ObjectStreamException + { + return new ExternalizableDelegator(this); + } + + + // Remaining DataObject methods are implemented as straight delegation to DataObjectUtil + + /** + * + * + * @generated NOT + */ + public Object get(String path) + { + return DataObjectUtil.get(this, path); + } + + /** + * + * + * @generated NOT + */ + public void set(String path, Object value) + { + DataObjectUtil.set(this, path, value); + } + + /** + * + * + * @generated NOT + */ + public boolean isSet(String path) + { + return DataObjectUtil.isSet(this, path); + } + + /** + * + * + * @generated NOT + */ + public void unset(String path) + { + DataObjectUtil.unset(this, path); + } + + /** + * + * + * @generated NOT + */ + public DataGraph getDataGraph() + { + return DataObjectUtil.getDataGraph(this); + } + + /** + * + * + * @generated NOT + */ + public BigDecimal getBigDecimal(String path) + { + return DataObjectUtil.getBigDecimal(get(path)); + } + + /** + * + * + * @generated NOT + */ + public BigInteger getBigInteger(String path) + { + return DataObjectUtil.getBigInteger(get(path)); + } + + /** + * + * + * @generated NOT + */ + public boolean getBoolean(String path) + { + return DataObjectUtil.getBoolean(get(path)); + } + + /** + * + * + * @generated NOT + */ + public byte getByte(String path) + { + return DataObjectUtil.getByte(get(path)); + } + + /** + * + * + * @generated NOT + */ + public byte[] getBytes(String path) + { + return DataObjectUtil.getBytes(get(path)); + } + + /** + * + * + * @generated NOT + */ + public char getChar(String path) + { + return DataObjectUtil.getChar(get(path)); + } + + /** + * + * + * @generated NOT + */ + public DataObject getDataObject(String path) + { + return (DataObject)get(path); + } + + /** + * + * + * @generated NOT + */ + public Date getDate(String path) + { + return DataObjectUtil.getDate(get(path)); + } + + /** + * + * + * @generated NOT + */ + public double getDouble(String path) + { + return DataObjectUtil.getDouble(get(path)); + } + + /** + * + * + * @generated NOT + */ + public float getFloat(String path) + { + return DataObjectUtil.getFloat(get(path)); + } + + /** + * + * + * @generated NOT + */ + public int getInt(String path) + { + return DataObjectUtil.getInt(get(path)); + } + + /** + * + * + * @generated NOT + */ + public List getList(String path) + { + return (List)get(path); + } + + /** + * + * + * @generated NOT + */ + public long getLong(String path) + { + return DataObjectUtil.getLong(get(path)); + } + + /** + * + * + * @generated NOT + */ + public Sequence getSequence(String path) + { + return (Sequence)get(path); + } + + /** + * + * + * @generated NOT + */ + public short getShort(String path) + { + return DataObjectUtil.getShort(get(path)); + } + + /** + * + * + * @generated NOT + */ + public String getString(String path) + { + return DataObjectUtil.getString(get(path)); + } + + /** + * + * + * @generated NOT + */ + public void setBigDecimal(String path, BigDecimal value) + { + DataObjectUtil.setBigDecimal(this, path, value); + } + + /** + * + * + * @generated NOT + */ + public void setBigInteger(String path, BigInteger value) + { + DataObjectUtil.setBigInteger(this, path, value); + } + + /** + * + * + * @generated NOT + */ + public void setBoolean(String path, boolean value) + { + DataObjectUtil.setBoolean(this, path, value); + } + + /** + * + * + * @generated NOT + */ + public void setByte(String path, byte value) + { + DataObjectUtil.setByte(this, path, value); + } + + /** + * + * + * @generated NOT + */ + public void setBytes(String path, byte[] value) + { + DataObjectUtil.setBytes(this, path, value); + } + + /** + * + * + * @generated NOT + */ + public void setChar(String path, char value) + { + DataObjectUtil.setChar(this, path, value); + } + + /** + * + * + * @generated NOT + */ + public void setDataObject(String path, DataObject value) + { + DataObjectUtil.set(this, path, value); + } + + /** + * + * + * @generated NOT + */ + public void setDate(String path, Date value) + { + DataObjectUtil.setDate(this,path,value); + } + + /** + * + * + * @generated NOT + */ + public void setDouble(String path, double value) + { + DataObjectUtil.setDouble(this, path, value); + } + + /** + * + * + * @generated NOT + */ + public void setFloat(String path, float value) + { + DataObjectUtil.setFloat(this, path, value); + } + + /** + * + * + * @generated NOT + */ + public void setInt(String path, int value) + { + DataObjectUtil.setInt(this, path, value); + } + + /** + * + * + * @generated NOT + */ + public void setList(String path, List value) + { + DataObjectUtil.set(this, path, value); + } + + /** + * + * + * @generated NOT + */ + public void setLong(String path, long value) + { + DataObjectUtil.setLong(this, path, value); + } + + /** + * + * + * @generated NOT + */ + public void setShort(String path, short value) + { + DataObjectUtil.setShort(this, path, value); + } + + /** + * + * + * @generated NOT + */ + public void setString(String path, String value) + { + DataObjectUtil.setString(this, path, value); + } + + /** + * + * + * @generated NOT + */ + public BigDecimal getBigDecimal(int propertyIndex) + { + return DataObjectUtil.getBigDecimal(this, propertyIndex); + } + + /** + * + * + * @generated NOT + */ + public BigInteger getBigInteger(int propertyIndex) + { + return DataObjectUtil.getBigInteger(this,propertyIndex); + } + + /** + * + * + * @generated NOT + */ + public boolean getBoolean(int propertyIndex) + { + return DataObjectUtil.getBoolean(this, propertyIndex); + } + + /** + * + * + * @generated NOT + */ + public byte getByte(int propertyIndex) + { + return DataObjectUtil.getByte(this, propertyIndex); + } + + /** + * + * + * @generated NOT + */ + public byte[] getBytes(int propertyIndex) + { + return DataObjectUtil.getBytes(this, propertyIndex); + } + + /** + * + * + * @generated NOT + */ + public char getChar(int propertyIndex) + { + return DataObjectUtil.getChar(this, propertyIndex); + } + + /** + * + * + * @generated NOT + */ + public DataObject getDataObject(int propertyIndex) + { + return DataObjectUtil.getDataObject(this, propertyIndex); + } + + /** + * + * + * @generated NOT + */ + public Date getDate(int propertyIndex) + { + return DataObjectUtil.getDate(this,propertyIndex); + } + + /** + * + * + * @generated NOT + */ + public double getDouble(int propertyIndex) + { + return DataObjectUtil.getDouble(this, propertyIndex); + } + + /** + * + * + * @generated NOT + */ + public float getFloat(int propertyIndex) + { + return DataObjectUtil.getFloat(this,propertyIndex); + } + + /** + * + * + * @generated NOT + */ + public int getInt(int propertyIndex) + { + return DataObjectUtil.getInt(this,propertyIndex); + } + + /** + * + * + * @generated NOT + */ + public List getList(int propertyIndex) + { + return DataObjectUtil.getList(this, propertyIndex); + } + + /** + * + * + * @generated NOT + */ + public long getLong(int propertyIndex) + { + return DataObjectUtil.getLong(this,propertyIndex); + } + + /** + * + * + * @generated NOT + */ + public Sequence getSequence(int propertyIndex) + { + return DataObjectUtil.getSequence(this, propertyIndex); + } + + /** + * + * + * @generated NOT + */ + public short getShort(int propertyIndex) + { + return DataObjectUtil.getShort(this,propertyIndex); + } + + /** + * + * + * @generated NOT + */ + public String getString(int propertyIndex) + { + return DataObjectUtil.getString(this,propertyIndex); + } + + /** + * + * + * @generated NOT + */ + public void setBigDecimal(int propertyIndex, BigDecimal value) + { + DataObjectUtil.setBigDecimal(this, propertyIndex, value); + } + + /** + * + * + * @generated NOT + */ + public void setBigInteger(int propertyIndex, BigInteger value) + { + DataObjectUtil.setBigInteger(this, propertyIndex, value); + } + + /** + * + * + * @generated NOT + */ + public void setBoolean(int propertyIndex, boolean value) + { + DataObjectUtil.setBoolean(this, propertyIndex, value); + } + + /** + * + * + * @generated NOT + */ + public void setByte(int propertyIndex, byte value) + { + DataObjectUtil.setByte(this, propertyIndex, value); + } + + /** + * + * + * @generated NOT + */ + public void setBytes(int propertyIndex, byte[] value) + { + DataObjectUtil.setBytes(this, propertyIndex, value); + } + + /** + * + * + * @generated NOT + */ + public void setChar(int propertyIndex, char value) + { + DataObjectUtil.setChar(this, propertyIndex, value); + } + + /** + * + * + * @generated NOT + */ + public void setDataObject(int propertyIndex, DataObject value) + { + DataObjectUtil.setDataObject(this, propertyIndex, value); + } + + /** + * + * + * @generated NOT + */ + public void setDate(int propertyIndex, Date value) + { + DataObjectUtil.setDate(this, propertyIndex, value); + } + + /** + * + * + * @generated NOT + */ + public void setDouble(int propertyIndex, double value) + { + DataObjectUtil.setDouble(this, propertyIndex, value); + } + + /** + * + * + * @generated NOT + */ + public void setFloat(int propertyIndex, float value) + { + DataObjectUtil.setFloat(this, propertyIndex, value); + } + + /** + * + * + * @generated NOT + */ + public void setInt(int propertyIndex, int value) + { + DataObjectUtil.setInt(this, propertyIndex, value); + } + + /** + * + * + * @generated NOT + */ + public void setList(int propertyIndex, List value) + { + DataObjectUtil.setList(this, propertyIndex, value); + } + + /** + * + * + * @generated NOT + */ + public void setLong(int propertyIndex, long value) + { + DataObjectUtil.setLong(this, propertyIndex, value); + } + + /** + * + * + * @generated NOT + */ + public void setShort(int propertyIndex, short value) + { + DataObjectUtil.setShort(this, propertyIndex, value); + } + + /** + * + * + * @generated NOT + */ + public void setString(int propertyIndex, String value) + { + DataObjectUtil.setString(this, propertyIndex, value); + } + + /** + * + * + * @generated NOT + */ + public BigDecimal getBigDecimal(Property property) + { + return DataObjectUtil.getBigDecimal(this, property); + } + + /** + * + * + * @generated NOT + */ + public BigInteger getBigInteger(Property property) + { + return DataObjectUtil.getBigInteger(this, property); + } + + /** + * + * + * @generated NOT + */ + public boolean getBoolean(Property property) + { + return DataObjectUtil.getBoolean(this, property); + } + + /** + * + * + * @generated NOT + */ + public byte getByte(Property property) + { + return DataObjectUtil.getByte(this, property); + } + + /** + * + * + * @generated NOT + */ + public byte[] getBytes(Property property) + { + return DataObjectUtil.getBytes(this, property); + } + + /** + * + * + * @generated NOT + */ + public char getChar(Property property) + { + return DataObjectUtil.getChar(this, property); + } + + /** + * + * + * @generated NOT + */ + public DataObject getDataObject(Property property) + { + return (DataObject)DataObjectUtil.getDataObject(this,property); + } + + /** + * + * + * @generated NOT + */ + public Date getDate(Property property) + { + return DataObjectUtil.getDate(this, property); + } + + /** + * + * + * @generated NOT + */ + public double getDouble(Property property) + { + return DataObjectUtil.getDouble(this, property); + } + + /** + * + * + * @generated NOT + */ + public float getFloat(Property property) + { + return DataObjectUtil.getFloat(this, property); + } + + /** + * + * + * @generated NOT + */ + public int getInt(Property property) + { + return DataObjectUtil.getInt(this, property); + } + + /** + * + * + * @generated NOT + */ + public List getList(Property property) + { + return (List)DataObjectUtil.getList(this, property); + } + + /** + * + * + * @generated NOT + */ + public long getLong(Property property) + { + return DataObjectUtil.getLong(this, property); + } + + /** + * + * + * @generated NOT + */ + public Sequence getSequence(Property property) + { + return (Sequence)DataObjectUtil.getSequence(this, property); + } + + /** + * + * + * @generated NOT + */ + public short getShort(Property property) + { + return DataObjectUtil.getShort(this, property); + } + + /** + * + * + * @generated NOT + */ + public String getString(Property property) + { + return DataObjectUtil.getString(this, property); + } + + /** + * + * + * @generated NOT + */ + public void setBigDecimal(Property property, BigDecimal value) + { + DataObjectUtil.setBigDecimal(this,property, value); + } + + /** + * + * + * @generated NOT + */ + public void setBigInteger(Property property, BigInteger value) + { + DataObjectUtil.setBigInteger(this,property, value); + } + + /** + * + * + * @generated NOT + */ + public void setBoolean(Property property, boolean value) + { + DataObjectUtil.setBoolean(this,property, value); + } + + /** + * + * + * @generated NOT + */ + public void setByte(Property property, byte value) + { + DataObjectUtil.setByte(this,property, value); + } + + /** + * + * + * @generated NOT + */ + public void setBytes(Property property, byte[] value) + { + DataObjectUtil.setBytes(this,property, value); + } + + /** + * + * + * @generated NOT + */ + public void setChar(Property property, char value) + { + DataObjectUtil.setChar(this,property, value); + } + + /** + * + * + * @generated NOT + */ + public void setDataObject(Property property, DataObject value) + { + DataObjectUtil.setDataObject(this,property, value); + } + + /** + * + * + * @generated NOT + */ + public void setDate(Property property, Date value) + { + DataObjectUtil.setDate(this,property, value); + } + + /** + * + * + * @generated NOT + */ + public void setDouble(Property property, double value) + { + DataObjectUtil.setDouble(this,property, value); + } + + /** + * + * + * @generated NOT + */ + public void setFloat(Property property, float value) + { + DataObjectUtil.setFloat(this,property, value); + } + + /** + * + * + * @generated NOT + */ + public void setInt(Property property, int value) + { + DataObjectUtil.setInt(this,property, value); + } + + /** + * + * + * @generated NOT + */ + public void setList(Property property, List value) + { + DataObjectUtil.setList(this,property, value); + } + + /** + * + * + * @generated NOT + */ + public void setLong(Property property, long value) + { + DataObjectUtil.setLong(this,property, value); + } + + /** + * + * + * @generated NOT + */ + public void setShort(Property property, short value) + { + DataObjectUtil.setShort(this,property, value); + } + + /** + * + * + * @generated NOT + */ + public void setString(Property property, String value) + { + DataObjectUtil.setString(this,property, value); + } + + /** + * + * + * @generated NOT + */ + public DataObject createDataObject(String propertyName) + { + return DataObjectUtil.createDataObject(this, propertyName); + } + + /** + * + * + * @generated NOT + */ + public DataObject createDataObject(int propertyIndex) + { + return DataObjectUtil.createDataObject(this, propertyIndex); + } + + /** + * + * + * @generated NOT + */ + public DataObject createDataObject(Property property) + { + return DataObjectUtil.createDataObject(this,property); + } + + /** + * + * + * @generated NOT + */ + public DataObject createDataObject(String propertyName, String namespaceURI, String typeName) + { + return DataObjectUtil.createDataObject(this, propertyName, namespaceURI, typeName); + } + + /** + * + * + * @generated NOT + */ + public DataObject createDataObject(int propertyIndex, String namespaceURI, String typeName) + { + return DataObjectUtil.createDataObject(this, propertyIndex, namespaceURI, typeName); + } + + /** + * + * + * @generated NOT + */ + public DataObject createDataObject(Property property, Type type) + { + return DataObjectUtil.createDataObject(this, property, type); + } + + /** + * + * + * @generated NOT + */ + public void delete() + { + DataObjectUtil.delete(this); + } + + protected Sequence sequence = null; + + /** + * + * + * @generated NOT + */ + public Sequence getSequence() + { + if (sequence == null) + { + EStructuralFeature sequenceFeature = ((ClassImpl)eClass()).getSequenceFeature(); + if (sequenceFeature == null) return null; + if (sequenceFeature == ClassImpl.VIRTUAL_SEQUENCE_FEATURE) + sequence = new VirtualSequence(this); + else + sequence = (Sequence)eGet(sequenceFeature, true, false); + } + return sequence; + } + + /** + * + * + * @generated NOT + */ + public List getInstanceProperties() + { + return DataObjectUtil.getInstanceProperties(this); + } + + /** + * + * + * @generated NOT + */ + public Property getInstanceProperty(String propertyName) + { + return DataObjectUtil.getInstanceProperty(this, propertyName); + } + + /** + * @deprecated + */ + public Property getProperty(String propertyName) + { + return DataObjectUtil.getInstanceProperty(this, propertyName); + } + + /** + * + * + * @generated NOT + */ + public DataObject getRootObject() + { + return DataObjectUtil.getRootObject(this); + } + + /** + * + * + * @generated NOT + */ + public ChangeSummary getChangeSummary() + { + return DataObjectUtil.getChangeSummary(this); + } + + /** + * + * + * @generated NOT + */ + public void detach() + { + DataObjectUtil.detach(this); + } + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // Following methods customize BasicEObjectImpl, optimized for SDO + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + /** + * + * + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getDataObject(); + } + + public boolean eNotificationRequired() + { + return changeRecorder != null || super.eNotificationRequired(); + } + + public boolean eDeliver() + { + return true; + } + + public void eNotify(Notification notification) + { + if(changeRecorder != null) changeRecorder.notifyChanged(notification); + super.eNotify(notification); + } + + public void setChangeRecorder(SDOChangeRecorder changeRecorder) + { + if (this.changeRecorder != null) + { + this.changeRecorder.unsetTarget(this); + } + + if (changeRecorder != null) + { + changeRecorder.setTarget(this); + } + + this.changeRecorder = changeRecorder; + } + + public InternalEObject eInternalContainer() + { + return eContainer; + } + + public int eContainerFeatureID() + { + return eContainerFeatureID; + } + + protected void eBasicSetContainer(InternalEObject newContainer, int newContainerFeatureID) + { + eContainer = newContainer; + eContainerFeatureID = newContainerFeatureID; + } + + public EClass eClass() + { + return eStaticClass(); + } + + public EList eContents() + { + return new EContentsEList(this); + } + + public EList eCrossReferences() + { + return new ECrossReferenceEList(this); + } + + public Resource.Internal eDirectResource() + { + return location instanceof Resource.Internal ? (Resource.Internal)location : null; + } + + protected EClass eDynamicClass() + { + return null; + } + + protected boolean eHasSettings() + { + return false; + } + + public boolean eIsProxy() + { + return location instanceof URI; + } + + public URI eProxyURI() + { + return location instanceof URI ? (URI)location : null; + } + + public void eSetClass(EClass eClass) + { + throw new UnsupportedOperationException(); + } + + protected void eSetDirectResource(Resource.Internal resource) + { + location = resource; + } + + public void eSetProxyURI(URI uri) + { + location = uri; + } + + protected DynamicValueHolder eSettings() + { + return null; + } + + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + return eDynamicGet(featureID, resolve, coreType); + } + + public void eSet(int featureID, Object newValue) + { + eDynamicSet(featureID, newValue); + } + + public void eUnset(int featureID) + { + eDynamicUnset(featureID); + } + + public boolean eIsSet(int featureID) + { + return eDynamicIsSet(featureID); + } + + public Object eDynamicGet(int featureID, boolean resolve, boolean coreType) + { + return eOpenGet(DataObjectUtil.getOpenFeature(this, featureID), resolve); + } + + public void eDynamicSet(int featureID, Object newValue) + { + eOpenSet(DataObjectUtil.getOpenFeature(this, featureID), newValue); + } + + public void eDynamicUnset(int featureID) + { + eOpenUnset(DataObjectUtil.getOpenFeature(this, featureID)); + } + + public boolean eDynamicIsSet(int featureID) + { + return eOpenIsSet(DataObjectUtil.getOpenFeature(this, featureID)); + } + + public EList eAdapters() + { + if (eAdapters == null) + { + eAdapters = new EAdapterList(this); + } + return eAdapters; + } + + public BasicEList eBasicAdapters() + { + return eAdapters; + } + + /* + public int eDerivedStructuralFeatureID(EStructuralFeature eStructuralFeature) + { + Class containerClass = eStructuralFeature.getContainerClass(); + return + containerClass == null ? + eClass().getFeatureID(eStructuralFeature) : + containerClass.isInstance(this) ? + eDerivedStructuralFeatureID(eStructuralFeature.getFeatureID(), containerClass) : + -1; + } + + public void eOpenSet(EStructuralFeature eFeature, Object newValue) + { + EStructuralFeature openFeature = ExtendedMetaData.INSTANCE.getAffiliation(eClass(), eFeature); + if (openFeature == null) + { + openFeature = (EStructuralFeature)eClass().getEStructuralFeature("any"); + } + if (openFeature != null) + { + if (!FeatureMapUtil.isFeatureMap(openFeature)) + { + openFeature = ExtendedMetaData.INSTANCE.getGroup(openFeature); + } + FeatureMap featureMap = (FeatureMap)eGet(openFeature); + ((FeatureMap.Internal)featureMap).set(eFeature, newValue); + } + else + { + throw new IllegalArgumentException("The feature '" + eFeature.getName() + "' is not a valid changeable feature"); + } + } + */ + +} //DataObjectImpl + diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DataTypeImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DataTypeImpl.java new file mode 100644 index 0000000000..dee124429f --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DataTypeImpl.java @@ -0,0 +1,781 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + +import java.util.Collections; +import java.util.List; + +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.impl.EDataTypeImpl; +import org.eclipse.emf.ecore.util.ExtendedMetaData; + +import commonj.sdo.Property; +import commonj.sdo.Sequence; +import commonj.sdo.Type; + +/** + * + * An implementation of the model object 'Data Type'. + * + *

+ *

+ * + * @generated + */ +public class DataTypeImpl extends EDataTypeImpl implements Type, org.apache.tuscany.sdo.model.Type/*, DataObject*/ +{ + /** + * + * + * @generated + */ + protected DataTypeImpl() + { + super(); + } + + /** + * + * + * @generated NOT + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getDataType(); + } + + /** + * + * + * @generated NOT + */ + public String getURI() + { + return getEPackage().getNsURI(); + } + + /** + * + * + * @generated NOT + */ + public boolean isDataType() + { + return true; + } + + /** + * + * + * @generated NOT + */ + public boolean isOpen() + { + return false; + } + + /** + * + * + * @generated NOT + */ + public boolean isSequenced() + { + return false; + } + + protected List aliasNames = null; + + /** + * + * + * @generated NOT + */ + public List getAliasNames() + { + if (aliasNames == null) + { + aliasNames = DataObjectUtil.getAliasNames(this); + } + return aliasNames; + } + + /** + * + * + * @generated NOT + */ + public List getDeclaredProperties() + { + return Collections.EMPTY_LIST; + } + + /** + * + * + * @generated NOT + */ + public List getProperties() + { + return Collections.EMPTY_LIST; + } + + /** + * + * + * @generated NOT + */ + public List getBaseTypes() + { + EDataType dataType = ExtendedMetaData.INSTANCE.getBaseType(this); + if (dataType == null) + { + return Collections.EMPTY_LIST; + } + else + { + return Collections.singletonList(dataType); + } + } + + /** + * + * + * @generated NOT + */ + public Property getProperty(String propertyName) + { + return null; + } + + public List getInstanceProperties() { + return DataObjectUtil.getMetaObjectInstanceProperties(this); + } + + public Object get(Property property) { + return DataObjectUtil.getMetaObjectInstanceProperty(this, property); + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // org.apache.tuscany.sdo.model.Type method implementations + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + + public List getBaseType() { + return this.getBaseTypes(); + } + + public List getProperty() { + return this.getProperties(); + } + + public List getAliasName() { + return this.getAliasNames(); + } + + public Sequence getAny() { + throw new UnsupportedOperationException(); + } + + public Sequence getAnyAttribute() { + throw new UnsupportedOperationException(); + } + + public boolean isAbstract() + { + return false; + } + + public void setAbstract(boolean value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetAbstract() { + return false; + } + + public void unsetAbstract() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void setDataType(boolean value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void unsetDataType() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetDataType() { + return true; + } + + public void setOpen(boolean value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void unsetOpen() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetOpen() { + return false; + } + + public void setSequenced(boolean value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void unsetSequenced() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetSequenced() { + return false; + } + + public void unsetName() + { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetName() + { + return true; + } + + public void unsetUri() + { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSetUri() + { + return true; + } + + public void setUri(String value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public String getUri() { + return getURI(); + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // DataObject method implementations + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + /* + public Object get(int propertyIndex) { + Object ret = DataObjectUtil.get(this, propertyIndex); + return (ret != null) ? + ret : eGet(propertyIndex, true, false); + } + + public void set(int propertyIndex, Object value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSet(int propertyIndex) { + return eIsSet(propertyIndex); + } + + public void unset(int propertyIndex) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public Object get(Property property) { + Object ret = DataObjectUtil.get(this, ((EStructuralFeature)property).getFeatureID()); + return (ret != null) ? + ret : eGet((EStructuralFeature)property, true, false); + } + + public void set(Property property, Object value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSet(Property property) { + return eIsSet((EStructuralFeature)property); + } + + public void unset(Property property) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject getContainer() { + return (DataObject)eContainer(); + } + + public Property getContainmentProperty() { + return (Property)eContainmentFeature(); + } + + public Type getType() { + return (Type)ModelPackageImpl.eINSTANCE.getType(); + } + + // Remaining DataObject methods are (will be) implemented as straight delegation to DataObjectUtil + + public Object get(String path) { + return DataObjectUtil.get(this, path); + } + + public void set(String path, Object value) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean isSet(String path) { + return DataObjectUtil.isSet(this, path); + } + + public void unset(String path) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public boolean getBoolean(String path) { + return DataObjectUtil.getBoolean(get(path)); + } + + public byte getByte(String path) { + return DataObjectUtil.getByte(get(path)); + } + + public char getChar(String path) { + return DataObjectUtil.getChar(get(path)); + } + + public double getDouble(String path) { + return DataObjectUtil.getDouble(get(path)); + } + + public float getFloat(String path) { + return DataObjectUtil.getFloat(get(path)); + } + + public int getInt(String path) { + return DataObjectUtil.getInt(get(path)); + } + + public long getLong(String path) { + return DataObjectUtil.getLong(get(path)); + } + + public short getShort(String path) { + return DataObjectUtil.getShort(get(path)); + } + + public byte[] getBytes(String path) { + return DataObjectUtil.getBytes(get(path)); + } + + public BigDecimal getBigDecimal(String path) { + return DataObjectUtil.getBigDecimal(get(path)); + } + + public BigInteger getBigInteger(String path) { + return DataObjectUtil.getBigInteger(get(path)); + } + + public DataObject getDataObject(String path) { + return (DataObject)get(path); + } + + public Date getDate(String path) { + return DataObjectUtil.getDate(get(path)); + } + + public String getString(String path) { + return DataObjectUtil.getString(get(path)); + } + + public List getList(String path) { + return (List)get(path); + } + + public Sequence getSequence(String path) { + return (Sequence)get(path); + } + + public void setBoolean(String path, boolean value) { + set(path, new Boolean(value)); + } + + public void setByte(String path, byte value) { + set(path, new Byte(value)); + } + + public void setChar(String path, char value) { + set(path, new Character(value)); + } + + public void setDouble(String path, double value) { + set(path, new Double(value)); + } + + public void setFloat(String path, float value) { + set(path, new Float(value)); + } + + public void setInt(String path, int value) { + set(path, new Integer(value)); + } + + public void setLong(String path, long value) { + set(path, new Long(value)); + } + + public void setShort(String path, short value) { + set(path, new Short(value)); + } + + public void setBytes(String path, byte[] value) { + set(path, value); + } + + public void setBigDecimal(String path, BigDecimal value) { + set(path, value); + } + + public void setBigInteger(String path, BigInteger value) { + set(path, value); + } + + public void setDataObject(String path, DataObject value) { + set(path, value); + } + + public void setDate(String path, Date value) { + set(path, value); + } + + public void setString(String path, String value) { + set(path, value); + } + + public void setList(String path, List value) { + set(path, value); + } + + public boolean getBoolean(int propertyIndex) { + return DataObjectUtil.getBoolean(this, propertyIndex); + } + + public byte getByte(int propertyIndex) { + return DataObjectUtil.getByte(this, propertyIndex); + } + + public char getChar(int propertyIndex) { + return DataObjectUtil.getChar(this, propertyIndex); + } + + public double getDouble(int propertyIndex) { + return DataObjectUtil.getDouble(this, propertyIndex); + } + + public float getFloat(int propertyIndex) { + return DataObjectUtil.getFloat(this, propertyIndex); + } + + public int getInt(int propertyIndex) { + return DataObjectUtil.getInt(this, propertyIndex); + } + + public long getLong(int propertyIndex) { + return DataObjectUtil.getLong(this, propertyIndex); + } + + public short getShort(int propertyIndex) { + return DataObjectUtil.getShort(this, propertyIndex); + } + + public byte[] getBytes(int propertyIndex) { + return DataObjectUtil.getBytes(this, propertyIndex); + } + + public BigDecimal getBigDecimal(int propertyIndex) { + return DataObjectUtil.getBigDecimal(this, propertyIndex); + } + + public BigInteger getBigInteger(int propertyIndex) { + return DataObjectUtil.getBigInteger(this, propertyIndex); + } + + public DataObject getDataObject(int propertyIndex) { + return DataObjectUtil.getDataObject(this, propertyIndex); + } + + public Date getDate(int propertyIndex) { + return DataObjectUtil.getDate(this, propertyIndex); + } + + public String getString(int propertyIndex) { + return DataObjectUtil.getString(this, propertyIndex); + } + + public List getList(int propertyIndex) { + return DataObjectUtil.getList(this, propertyIndex); + } + + public Sequence getSequence(int propertyIndex) { + return DataObjectUtil.getSequence(this, propertyIndex); + } + + public void setBoolean(int propertyIndex, boolean value) { + set(propertyIndex, new Boolean(value)); + } + + public void setByte(int propertyIndex, byte value) { + set(propertyIndex, new Byte(value)); + } + + public void setChar(int propertyIndex, char value) { + set(propertyIndex, new Character(value)); + } + + public void setDouble(int propertyIndex, double value) { + set(propertyIndex, new Double(value)); + } + + public void setFloat(int propertyIndex, float value) { + set(propertyIndex, new Float(value)); + } + + public void setInt(int propertyIndex, int value) { + set(propertyIndex, new Integer(value)); + } + + public void setLong(int propertyIndex, long value) { + set(propertyIndex, new Long(value)); + } + + public void setShort(int propertyIndex, short value) { + set(propertyIndex, new Short(value)); + } + + public void setBytes(int propertyIndex, byte[] value) { + set(propertyIndex, value); + } + + public void setBigDecimal(int propertyIndex, BigDecimal value) { + set(propertyIndex, value); + } + + public void setBigInteger(int propertyIndex, BigInteger value) { + set(propertyIndex, value); + } + + public void setDataObject(int propertyIndex, DataObject value) { + set(propertyIndex, value); + } + + public void setDate(int propertyIndex, Date value) { + set(propertyIndex, value); + } + + public void setString(int propertyIndex, String value) { + set(propertyIndex, value); + } + + public void setList(int propertyIndex, List value) { + set(propertyIndex, value); + } + + public boolean getBoolean(Property property) { + return DataObjectUtil.getBoolean(this, property); + } + + public byte getByte(Property property) { + return DataObjectUtil.getByte(this, property); + } + + public char getChar(Property property) { + return DataObjectUtil.getChar(this, property); + } + + public double getDouble(Property property) { + return DataObjectUtil.getDouble(this, property); + } + + public float getFloat(Property property) { + return DataObjectUtil.getFloat(this, property); + } + + public int getInt(Property property) { + return DataObjectUtil.getInt(this, property); + } + + public long getLong(Property property) { + return DataObjectUtil.getLong(this, property); + } + + public short getShort(Property property) { + return DataObjectUtil.getShort(this, property); + } + + public byte[] getBytes(Property property) { + return DataObjectUtil.getBytes(this, property); + } + + public BigDecimal getBigDecimal(Property property) { + return DataObjectUtil.getBigDecimal(this, property); + } + + public BigInteger getBigInteger(Property property) { + return DataObjectUtil.getBigInteger(this, property); + } + + public DataObject getDataObject(Property property) { + return DataObjectUtil.getDataObject(this, property); + } + + public Date getDate(Property property) { + return DataObjectUtil.getDate(this, property); + } + + public String getString(Property property) { + return DataObjectUtil.getString(this, property); + } + + public List getList(Property property) { + return DataObjectUtil.getList(this, property); + } + + public Sequence getSequence(Property property) { + return DataObjectUtil.getSequence(this, property); + } + + public void setBoolean(Property property, boolean value) { + set(property, new Boolean(value)); + } + + public void setByte(Property property, byte value) { + set(property, new Byte(value)); + } + + public void setChar(Property property, char value) { + set(property, new Character(value)); + } + + public void setDouble(Property property, double value) { + set(property, new Double(value)); + } + + public void setFloat(Property property, float value) { + set(property, new Float(value)); + } + + public void setInt(Property property, int value) { + set(property, new Integer(value)); + } + + public void setLong(Property property, long value) { + set(property, new Long(value)); + } + + public void setShort(Property property, short value) { + set(property, new Short(value)); + } + + public void setBytes(Property property, byte[] value) { + set(property, value); + } + + public void setBigDecimal(Property property, BigDecimal value) { + set(property, value); + } + + public void setBigInteger(Property property, BigInteger value) { + set(property, value); + } + + public void setDataObject(Property property, DataObject value) { + set(property, value); + } + + public void setDate(Property property, Date value) { + set(property, value); + } + + public void setString(Property property, String value) { + set(property, value); + } + + public void setList(Property property, List value) { + set(property, value); + } + + public DataObject createDataObject(String propertyName) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(String propertyName, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property, Type type) { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public void delete() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + + public DataGraph getDataGraph() { + return DataObjectUtil.getDataGraph(this); + } + + public Sequence getSequence() { + EAttribute mixedFeature = BasicExtendedMetaData.INSTANCE.getMixedFeature(eClass()); + return mixedFeature != null ? (Sequence)eGet(mixedFeature, true, false) : null; + } + + public List getInstanceProperties() { + return DataObjectUtil.getInstanceProperties(this); + } + + public DataObject getRootObject() { + return DataObjectUtil.getRootObject(this); + } + + public ChangeSummary getChangeSummary() { + // TODO: implement this method + throw new UnsupportedOperationException(); + } + + public void detach() { + throw new UnsupportedOperationException("Type is frozen and cannot be modified"); + } + */ + +} //DataTypeImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicDataObjectImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicDataObjectImpl.java new file mode 100644 index 0000000000..153ef18444 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicDataObjectImpl.java @@ -0,0 +1,216 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.SDOPackage; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; + +/** + * + * An implementation of the model object 'Dynamic Data Object'. + * @extends EStructuralFeature.Internal.DynamicValueHolder + * + *

+ *

+ * + * @generated + */ +public class DynamicDataObjectImpl extends DataObjectImpl implements DataObject, EStructuralFeature.Internal.DynamicValueHolder +{ + protected EClass eClass; + protected Object [] eSettings; + + protected static final Object [] ENO_SETTINGS = new Object [0]; + + /** + * + * + * @generated + */ + protected DynamicDataObjectImpl() + { + super(); + } + + /** + * Creates a dynamic DataObject. + */ + public DynamicDataObjectImpl(EClass eClass) + { + super(); + eSetClass(eClass); + Property csp = ((ClassImpl)eClass).getChangeSummaryProperty(); + if (csp != null) + { + ChangeSummaryImpl changeSummary = (ChangeSummaryImpl)SDOFactory.eINSTANCE.createChangeSummary(); + set(csp, changeSummary); + changeSummary.setDataObject(this); + } + } + + /** + * + * + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getDynamicDataObject(); + } + + protected int eStaticFeatureCount() + { + return 0; + } + + public int eDerivedStructuralFeatureID(EStructuralFeature eStructuralFeature) + { + return eClass().getFeatureID(eStructuralFeature); + } + + protected boolean eHasSettings() + { + return eSettings != null; + } + + protected EStructuralFeature.Internal.DynamicValueHolder eSettings() + { + if (eSettings == null) + { + int size = eClass().getFeatureCount() - eStaticFeatureCount(); + eSettings = size == 0 ? ENO_SETTINGS : new Object [size]; + } + + return this; + } + + protected EClass eDynamicClass() + { + return eClass; + } + + public EClass eClass() + { + return eClass; + } + + public void eSetClass(EClass eClass) + { + this.eClass = eClass; + } + + public Object dynamicGet(int dynamicFeatureID) + { + return eSettings[dynamicFeatureID]; + } + + public void dynamicSet(int dynamicFeatureID, Object value) + { + eSettings[dynamicFeatureID] = value; + } + + public void dynamicUnset(int dynamicFeatureID) + { + eSettings[dynamicFeatureID] = null; + } + + public Object eDynamicGet(int featureID, boolean resolve, boolean coreType) + { + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + return eSettingDelegate(eFeature).dynamicGet(this, eSettings(), featureID, resolve, coreType); + } + else + { + return super.eDynamicGet(featureID, resolve, coreType); + } + } + + public void eDynamicSet(int featureID, Object newValue) + { + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + try { + eDynamicSet(featureID, eFeature, newValue); + } catch (IllegalArgumentException e) { + throw new UnsupportedOperationException(e.getMessage()); + } + } + else + { + super.eDynamicSet(featureID, newValue); + } + } + + public void eDynamicUnset(int featureID) + { + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + try { + eDynamicUnset(featureID, eFeature); + } catch (IllegalArgumentException e) { + throw new UnsupportedOperationException(e.getMessage()); + } + } + else + { + super.eDynamicUnset(featureID); + } + } + + public boolean eDynamicIsSet(int featureID) + { + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + return eSettingDelegate(eFeature).dynamicIsSet(this, eSettings(), featureID); + } + else + { + return super.eDynamicIsSet(featureID); + } + } + + /** + * An EFactoryImpl that creates DynamicEDataObjectImpl instances. + */ + public static class FactoryImpl extends EFactoryImpl + { + public FactoryImpl() + { + } + + public EObject basicCreate(EClass eClass) + { + return new DynamicDataObjectImpl(eClass); + } + } + +} //DynamicDataObjectImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicStoreDataObjectImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/DynamicStoreDataObjectImpl.java new file mode 100644 index 0000000000..d9d39bad49 --- /dev/null +++ b/sandbox/kgoodson/events/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; + +/** + * + * An implementation of the model object 'Dynamic Store Data Object'. + * + *

+ *

+ * + * @generated + */ +public class DynamicStoreDataObjectImpl extends StoreDataObjectImpl implements DataObject +{ + protected EClass eClass; + + /** + * + * + * @generated + */ + protected DynamicStoreDataObjectImpl() + { + super(); + } + + public DynamicStoreDataObjectImpl(InternalEObject.EStore eStore) + { + super(eStore); + } + + public DynamicStoreDataObjectImpl(EClass eClass) + { + super(eClass); + } + + public DynamicStoreDataObjectImpl(EClass eClass, InternalEObject.EStore eStore) + { + super(eClass, eStore); + } + + /** + * + * + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getDynamicStoreDataObject(); + } + + protected EClass eDynamicClass() + { + return eClass; + } + + public EClass eClass() + { + return eClass; + } + + public void eSetClass(EClass eClass) + { + this.eClass = eClass; + } + +} //DynamicStoreDataObjectImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/EnumImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/EnumImpl.java new file mode 100644 index 0000000000..54f642d8cf --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/EnumImpl.java @@ -0,0 +1,183 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + +import java.util.Collections; +import java.util.List; + +//import org.apache.tuscany.sdo.SDOPackage; + +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.impl.EEnumImpl; + +import commonj.sdo.Property; +import commonj.sdo.Type; + +/** + * + * An implementation of the model object 'Enum'. + * + *

+ *

+ * + * @generated + * @deprecated SDO doesn't support Enum types + */ +public class EnumImpl extends EEnumImpl implements Type +{ + /** + * + * + * @generated + */ + protected EnumImpl() + { + super(); + } + + /** + * + * + * @generated NOT + */ + protected EClass eStaticClass() + { + return EcorePackage.eINSTANCE.getEEnum(); + } + + /** + * + * + * @generated NOT + */ + public String getURI() + { + return getEPackage().getNsURI(); + } + + /** + * + * + * @generated NOT + */ + public boolean isDataType() + { + return true; + } + + /** + * + * + * @generated NOT + */ + public boolean isOpen() + { + return false; + } + + /** + * + * + * @generated NOT + */ + public boolean isSequenced() + { + return false; + } + + protected List aliasNames = null; + + /** + * + * + * @generated NOT + */ + public List getAliasNames() + { + if (aliasNames == null) + { + aliasNames = DataObjectUtil.getAliasNames(this); + } + return aliasNames; + } + + /** + * + * + * @generated NOT + */ + public List getDeclaredProperties() + { + return Collections.EMPTY_LIST; + } + + /** + * + * + * @generated NOT + */ + public List getProperties() + { + return Collections.EMPTY_LIST; + } + + /** + * + * + * @generated NOT + */ + public List getBaseTypes() + { + return Collections.EMPTY_LIST; + } + + /** + * + * + * @generated NOT + */ + public Property getProperty(String propertyName) + { + return null; + } + + /** + * + * + * @generated NOT + */ + public boolean isAbstract() + { + return false; + } + + public List getInstanceProperties() + { + throw new UnsupportedOperationException(); + } + + public Object get(Property property) + { + throw new UnsupportedOperationException(); + } + +} //EnumTypeImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/EventImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/EventImpl.java new file mode 100644 index 0000000000..b1ae572f21 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/EventImpl.java @@ -0,0 +1,142 @@ +package org.apache.tuscany.sdo.impl; + +import org.apache.tuscany.sdo.api.Event; +import org.eclipse.emf.common.notify.Notification; + +import commonj.sdo.Property; + + +public class EventImpl implements Event { + + protected Notification emfEvent; + protected Object notifier; + + public EventImpl(Notification notification) + { + this.emfEvent = notification; + } + + public Object getNotifier() + { + return notifier == null ? emfEvent.getNotifier() : notifier; + } + + public int getEventType() + { + return emfEvent.getEventType(); + } + + + public Property getProperty() + { + return (Property)emfEvent.getFeature(); + } + + public Object getOldValue() + { + return emfEvent.getOldValue(); + } + + public Object getNewValue() + { + return emfEvent.getNewValue(); + } + + public boolean wasSet() + { + return emfEvent.wasSet(); + } + + public boolean isTouch() + { + return emfEvent.isTouch(); + } + + public int getPosition() + { + return emfEvent.getPosition(); + } + + + public boolean getOldBooleanValue() + { + return emfEvent.getOldBooleanValue(); + } + + public boolean getNewBooleanValue() + { + return emfEvent.getNewBooleanValue(); + } + + public byte getOldByteValue() + { + return emfEvent.getOldByteValue(); + } + public byte getNewByteValue() + { + return emfEvent.getNewByteValue(); + } + + public char getOldCharValue() + { + return emfEvent.getOldCharValue(); + } + public char getNewCharValue() + { + return emfEvent.getNewCharValue(); + } + + public double getOldDoubleValue() + { + return emfEvent.getOldDoubleValue(); + } + public double getNewDoubleValue() + { + return emfEvent.getNewDoubleValue(); + } + + public float getOldFloatValue() + { + return emfEvent.getOldFloatValue(); + } + public float getNewFloatValue() + { + return emfEvent.getNewFloatValue(); + } + + public int getOldIntValue() + { + return emfEvent.getOldIntValue(); + } + public int getNewIntValue() + { + return emfEvent.getNewIntValue(); + } + + public long getOldLongValue() + { + return emfEvent.getOldLongValue(); + } + public long getNewLongValue() + { + return emfEvent.getNewLongValue(); + } + + public short getOldShortValue() + { + return emfEvent.getOldShortValue(); + } + public short getNewShortValue() + { + return emfEvent.getNewShortValue(); + } + + public String getOldStringValue() + { + return emfEvent.getOldStringValue(); + } + public String getNewStringValue() + { + return emfEvent.getNewStringValue(); + } +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ExtensibleDataObjectImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ExtensibleDataObjectImpl.java new file mode 100644 index 0000000000..93825f7873 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ExtensibleDataObjectImpl.java @@ -0,0 +1,267 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.SDOPackage; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; + +/** + * + * An implementation of the model object 'Extensible Data Object'. + * @extends EStructuralFeature.Internal.DynamicValueHolder + * + *

+ *

+ * + * @generated + */ +public class ExtensibleDataObjectImpl extends DataObjectImpl implements DataObject, EStructuralFeature.Internal.DynamicValueHolder +{ + protected EClass eClass; + protected Object [] eSettings; + + protected static final Object [] ENO_SETTINGS = new Object [0]; + + /** + * + * + * @generated + */ + protected ExtensibleDataObjectImpl() + { + super(); + } + + /** + * Creates an extensible DataObject. + */ + public ExtensibleDataObjectImpl(EClass eClass) + { + super(); + eSetClass(eClass); + Property csp = ((ClassImpl)eClass).getChangeSummaryProperty(); + if (csp != null) + { + ChangeSummaryImpl changeSummary = (ChangeSummaryImpl)SDOFactory.eINSTANCE.createChangeSummary(); + set(csp, changeSummary); + changeSummary.setDataObject(this); + } + } + + /** + * + * + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getExtensibleDataObject(); + } + + public int eDerivedStructuralFeatureID(EStructuralFeature eStructuralFeature) + { + return eClass().getFeatureID(eStructuralFeature); + } + + protected boolean eHasSettings() + { + return eSettings != null; + } + + protected EStructuralFeature.Internal.DynamicValueHolder eSettings() + { + if (eSettings == null) + { + int size = eClass().getFeatureCount() - eStaticFeatureCount(); + eSettings = size == 0 ? ENO_SETTINGS : new Object [size]; + } + + return this; + } + + protected EClass eDynamicClass() + { + return eClass; + } + + protected boolean isDynamic() + { + return (eClass != null); + } + + public Object get(int featureID, boolean resolve) + { + return get(featureID, resolve, true); + } + + public Object get(int featureID, boolean resolve, boolean coreType) + { + Object result = null; + if (isDynamic() || featureID >= eStaticFeatureCount()) + { + result = super.eGet(featureID, resolve, coreType); + } + else + { + result = super.get(featureID); + } + return result; + } + + public void set(int featureID, Object newValue) + { + if (isDynamic() || featureID >= eStaticFeatureCount()) + { + super.eSet(featureID, newValue); + } + else + { + super.set(featureID, newValue); + } + } + + public void unset(int featureID) + { + if (isDynamic() || featureID >= eStaticFeatureCount()) + { + super.eUnset(featureID); + } + else + { + super.unset(featureID); + } + } + + public boolean isSet(int featureID) + { + if (isDynamic() || featureID >= eStaticFeatureCount()) + { + return super.eIsSet(featureID); + } + else + { + return super.isSet(featureID); + } + } + + public EClass eClass() + { + return isDynamic() ? eClass : eStaticClass(); + } + + public void eSetClass(EClass eClass) + { + this.eClass = eClass; + } + + public Object dynamicGet(int dynamicFeatureID) + { + return eSettings[dynamicFeatureID]; + } + + public void dynamicSet(int dynamicFeatureID, Object value) + { + eSettings[dynamicFeatureID] = value; + } + + public void dynamicUnset(int dynamicFeatureID) + { + eSettings[dynamicFeatureID] = null; + } + + public Object eDynamicGet(int featureID, boolean resolve, boolean coreType) + { + int dynamicFeatureID = featureID - eStaticFeatureCount(); + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + return eSettingDelegate(eFeature).dynamicGet(this, eSettings(), dynamicFeatureID, resolve, coreType); + } + else + { + return super.eDynamicGet(dynamicFeatureID, resolve, coreType); + } + } + + public void eDynamicSet(int featureID, Object newValue) + { + int dynamicFeatureID = featureID - eStaticFeatureCount(); + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + eDynamicSet(dynamicFeatureID, eFeature, newValue); + } + else + { + super.eDynamicSet(dynamicFeatureID, newValue); + } + } + + public void eDynamicUnset(int featureID) + { + int dynamicFeatureID = featureID - eStaticFeatureCount(); + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + eDynamicUnset(dynamicFeatureID, eFeature); + } + else + { + super.eDynamicUnset(dynamicFeatureID); + } + } + + public boolean eDynamicIsSet(int featureID) + { + int dynamicFeatureID = featureID - eStaticFeatureCount(); + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + return eSettingDelegate(eFeature).dynamicIsSet(this, eSettings(), dynamicFeatureID); + } + else + { + return super.eDynamicIsSet(dynamicFeatureID); + } + } + + /** + * An EFactoryImpl that creates ExtensibleDataObjectImpl instances. + */ + public static class FactoryImpl extends EFactoryImpl + { + public FactoryImpl() + { + } + + public EObject basicCreate(EClass eClass) + { + return new ExtensibleDataObjectImpl(eClass); + } + } + +} //ExtensibleDataObjectImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/FactoryBase.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/FactoryBase.java new file mode 100644 index 0000000000..e344a6ffde --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/FactoryBase.java @@ -0,0 +1,368 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.impl.SDOFactoryImpl.SDOEcoreFactory; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.ENamedElement; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.impl.EClassImpl; +import org.eclipse.emf.ecore.impl.EPackageImpl; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; + +/** + * Base class for generated (static) SDO factories + */ +public class FactoryBase extends EPackageImpl +{ + + public static final boolean IS_ATTRIBUTE = true; + + protected FactoryBase(String namespaceURI, String namespacePrefix) + { + super(new SDOEFactoryImpl()); + ecoreFactory = new SDOEcoreFactory(); + + int index = namespacePrefix.lastIndexOf("."); + setName(index != -1 ? namespacePrefix.substring(index + 1) : namespacePrefix); + setNsPrefix(namespacePrefix); + + createResource(namespaceURI); + setNsURI(namespaceURI); + + ((SDOEFactoryImpl)getEFactoryInstance()).sdoFactory = this; + } + + protected FactoryBase(String namespaceURI, String namespacePrefix, String interfacePackage) + { + super(new SDOEFactoryImpl()); + ecoreFactory = new SDOEcoreFactory(); + + int index = interfacePackage.lastIndexOf("."); + setName(index != -1 ? interfacePackage.substring(index + 1) : interfacePackage); + setNsPrefix(namespacePrefix); + + createResource(namespaceURI); + setNsURI(namespaceURI); + + ((SDOEFactoryImpl)getEFactoryInstance()).sdoFactory = this; + } + + + + public DataObject create(int typeNumber) + { + return null; + } + + public Object createFromString(int typeNumber, String stringValue) + { + return ((SDOEFactoryImpl)getEFactoryInstance()).createFromString(typeNumber, stringValue); + } + + public String convertToString(int typeNumber, Object objectValue) + { + return ((SDOEFactoryImpl)getEFactoryInstance()).convertToString(typeNumber, objectValue); + } + + protected Type createType(boolean isDataType, int typeNumber) + { + if (isDataType) + return (Type)createEDataType(typeNumber); + else + return (Type)createEClass(typeNumber); + } + + protected void createProperty(boolean isDataType, Type containingType, int internalPropertyNumber) + { + if (isDataType) + createEAttribute((EClass)containingType, internalPropertyNumber); + else + createEReference((EClass)containingType, internalPropertyNumber); + } + + /** + * @deprecated - use getLocalProperty instead, since getProperty causes + * caching of structural features. + */ + protected Property getProperty(Type type, int internalPropertyNumber) + { + return (Property)((EClass)type).getEAllStructuralFeatures().get(internalPropertyNumber); + } + + protected Property getLocalProperty(Type type, int localPropertyIndex) + { + return (Property)((EClass)type).getEStructuralFeatures().get(localPropertyIndex); + } + + + protected void initializeType(Type type, Class instanceClass, String name) + { + initEClass((EClass)type, instanceClass, name, !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + } + + protected void initializeType(Type type, Class instanceClass, String name, boolean isAbstract) + { + initEClass((EClass)type, instanceClass, name, isAbstract, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + } + + protected void initializeType(Type type, Class instanceClass, String name, boolean isSerializable, boolean isGenerated) + { + initEDataType((EDataType)type, instanceClass, name, isSerializable, isGenerated); + } + + protected void initializeProperty(Property property, Type type, String name, String defaultValue, int lower, int upper, Class containerClass, boolean isReadonly, boolean isUnsettable, boolean isDerived) + { + initEAttribute((EAttribute)property, type != sequence ? (EClassifier)type : ecorePackage.getEFeatureMapEntry(), name, defaultValue, lower, upper, containerClass, isDerived, isDerived, !isReadonly, isUnsettable, !IS_ID, !IS_UNIQUE, isDerived, IS_ORDERED); + } + + protected void initializeProperty(Property property, Type type, String name, String defaultValue, int lower, int upper, Class containerClass, boolean isReadonly, boolean isUnsettable, boolean isDerived, boolean isComposite, Property oppositeProperty) + { + initEReference((EReference)property, (EClassifier)type, (EReference)oppositeProperty, name, defaultValue, lower, upper, containerClass, isDerived, isDerived, !isReadonly, isComposite, !isComposite /*resolve*/, isUnsettable, IS_UNIQUE, isDerived, IS_ORDERED); + } + + protected void initXSD() + { + createDocumentRoot(); + } + + protected void addXSDMapping(String[] xsdMappings, String annotationSource) + { + addAnnotation((ENamedElement)this, annotationSource, xsdMappings); + } + + protected void addXSDMapping(Type type, String[] xsdMappings) + { + addAnnotation((ENamedElement)type, ANNOTATION_SOURCE, xsdMappings); + } + + protected void addXSDMapping(Property property, String[] xsdMappings) + { + addAnnotation((ENamedElement)property, ANNOTATION_SOURCE, xsdMappings); + } + + protected void setInstanceProperty(Type type, String namespaceURI, String propertyName, String propertyValue) + { + setInstanceProperty((ENamedElement)type, namespaceURI, propertyName, propertyValue); + } + + protected void setInstanceProperty(Property property, String namespaceURI, String propertyName, String propertyValue) + { + setInstanceProperty((ENamedElement)property, namespaceURI, propertyName, propertyValue); + } + + private void setInstanceProperty(ENamedElement eNamedElement, String namespaceURI, String propertyName, String propertyValue) + { + EAnnotation annotation = eNamedElement.getEAnnotation(namespaceURI); + if (annotation == null) + { + addAnnotation(eNamedElement, namespaceURI, new String[]{propertyName, propertyValue}); + } else + { + annotation.getDetails().put(propertyName, propertyValue); + } + } + + protected Property createGlobalProperty(String name, Type type, String[] xsdMappings) + { + return createGlobalProperty(name, type, xsdMappings, false); + } + + protected Property createGlobalProperty(String name, Type type, String[] xsdMappings, boolean asAttribute) + { + return createGlobalProperty(name, type, xsdMappings, asAttribute, ANNOTATION_SOURCE); + } + + protected Property createGlobalProperty(String name, Type type, String[] xsdMappings, boolean asAttribute, String annotationSource) + { + int propertyNumber = documentRootEClass.getEStructuralFeatures().size(); + + EStructuralFeature globalProperty; + if(asAttribute) { + createEAttribute(documentRootEClass, propertyNumber); + EAttribute gatt = (EAttribute)documentRootEClass.getEStructuralFeatures().get(propertyNumber); + initEAttribute(gatt, (EDataType)type, name, null, 0, -2, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, IS_DERIVED, IS_ORDERED); + globalProperty = gatt; + } else { + createEReference(documentRootEClass, propertyNumber); + EReference gref = (EReference)documentRootEClass.getEStructuralFeatures().get(propertyNumber); + initEReference(gref, (EClass)type, null, name, null, 0, -2, null, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + globalProperty = gref; + } + addAnnotation((ENamedElement)globalProperty, annotationSource, xsdMappings); + return (Property) globalProperty; + } + + private static final Type sequence = SDOFactory.eINSTANCE.createDataType(); // dummy type + + protected Type getSequence() + { + return sequence; + } + + protected void addSuperType(Type subType, Type superType) + { + ((EClass)subType).getESuperTypes().add((EClass)superType); + } + + /*** + * @param namespaceURI + * @return Static factory (from the global scope) for the provided URI + * + * @deprecated - Use of the global scope is no longer encouraged. This method uses the + * global scope for retrieving the URI's factory. Instead, it is now possible to simply + * access SomeFactoryInterface.INSTANCE object directly. + * + */ + public static Object getStaticFactory(String namespaceURI) + { + EPackage ePackage = EPackage.Registry.INSTANCE.getEPackage(namespaceURI); + //return (FactoryBase)ePackage; + return ePackage instanceof FactoryBase ? (Object)ePackage : (Object)ePackage.getEFactoryInstance(); + } + + // private EMF-specific methods + + private static class SDOEFactoryImpl extends DynamicDataObjectImpl.FactoryImpl + { + protected FactoryBase sdoFactory; + + public SDOEFactoryImpl() + { + super(); + } + + public EObject create(EClass eClass) + { + DataObject result = sdoFactory.create(eClass.getClassifierID()); + if (result == null) { + if (eClass.isAbstract()) { + Class instanceClass = eClass.getInstanceClass(); + try { + Class concreteInstanceClass = DataObjectUtil.getImplementationClass(instanceClass, true); + return (EObject)concreteInstanceClass.newInstance(); + } + catch (Exception e) + { + //System.out.println("Error: " + e); + } + } + return super.create(eClass); + } + return (EObject)result; + } + + public Object createFromString(EDataType eDataType, String stringValue) + { + return sdoFactory.createFromString(eDataType.getClassifierID(), stringValue); + } + + public String convertToString(EDataType eDataType, Object objectValue) + { + return sdoFactory.convertToString(eDataType.getClassifierID(), objectValue); + } + + protected Object createFromString(int typeNumber, String stringValue) + { + return super.createFromString((EDataType)sdoFactory.getEClassifiers().get(typeNumber), stringValue); + } + + protected String convertToString(int typeNumber, Object objectValue) + { + return super.convertToString((EDataType)sdoFactory.getEClassifiers().get(typeNumber), objectValue); + } + } + + private static final int DOCUMENT_ROOT = 0; + private static final int DOCUMENT_ROOT__MIXED = 0; + private static final int DOCUMENT_ROOT__XMLNS_PREFIX_MAP = 1; + private static final int DOCUMENT_ROOT__XSI_SCHEMA_LOCATION = 2; + private static final String ANNOTATION_SOURCE = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData"; + private EClass documentRootEClass = null; + + private void createDocumentRoot() + { + documentRootEClass = ecoreFactory.createEClass(); + ((EClassImpl)documentRootEClass).setClassifierID(DOCUMENT_ROOT); + getEClassifiers().add(DOCUMENT_ROOT, documentRootEClass); + + createEAttribute(documentRootEClass, DOCUMENT_ROOT__MIXED); + createEReference(documentRootEClass, DOCUMENT_ROOT__XMLNS_PREFIX_MAP); + createEReference(documentRootEClass, DOCUMENT_ROOT__XSI_SCHEMA_LOCATION); + + initEClass(documentRootEClass, null, "DocumentRoot", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + initEAttribute((EAttribute)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__MIXED), ecorePackage.getEFeatureMapEntry(), "mixed", null, 0, -1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference((EReference)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__XMLNS_PREFIX_MAP), ecorePackage.getEStringToStringMapEntry(), null, "xMLNSPrefixMap", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference((EReference)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__XSI_SCHEMA_LOCATION), ecorePackage.getEStringToStringMapEntry(), null, "xSISchemaLocation", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + addAnnotation + (documentRootEClass, + ANNOTATION_SOURCE, + new String[] + { + "name", "", + "kind", "mixed" + }); + addAnnotation + ((EAttribute)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__MIXED), + ANNOTATION_SOURCE, + new String[] + { + "kind", "elementWildcard", + "name", ":mixed" + }); + addAnnotation + ((EReference)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__XMLNS_PREFIX_MAP), + ANNOTATION_SOURCE, + new String[] + { + "kind", "attribute", + "name", "xmlns:prefix" + }); + addAnnotation + ((EReference)documentRootEClass.getEStructuralFeatures().get(DOCUMENT_ROOT__XSI_SCHEMA_LOCATION), + ANNOTATION_SOURCE, + new String[] + { + "kind", "attribute", + "name", "xsi:schemaLocation" + }); + } + + /** + * Initialize SDO runtime. + */ + static + { + DataObjectUtil.initRuntime(); + } +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ReferenceImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ReferenceImpl.java new file mode 100644 index 0000000000..19fb89bbd3 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/ReferenceImpl.java @@ -0,0 +1,785 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + +import java.util.List; + +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.apache.tuscany.sdo.util.SDOUtil; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.impl.EReferenceImpl; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.ExtendedMetaData; + +import commonj.sdo.Property; +import commonj.sdo.Sequence; +import commonj.sdo.Type; + +/** + * + * An implementation of the model object 'Reference'. + * + *

+ *

+ * + * @generated + */ +public class ReferenceImpl extends EReferenceImpl implements Property,/* DataObject,*/ org.apache.tuscany.sdo.model.Property +{ + /** + * + * + * @generated + */ + protected ReferenceImpl() + { + super(); + } + + /** + * + * + * @generated NOT + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getReference(); + } + + /** + * + * + * @generated NOT + */ + public Object getDefault() + { + return getDefaultValue(); + } + + /** + * + * + * @generated NOT + */ + public boolean isReadOnly() + { + //return "true".equals(EcoreUtil.getAnnotation(this, "commonj.sdo", "readOnly")); + return !isChangeable(); //TODO semantics don't exactly match? + } + + /** + * Single-valued SDO properties behave as EMF unsettable, multi-valued properties as EMF !unsettable + */ + public boolean isUnsettable() + { + return !isMany(); + } + + protected List aliasNames = null; + + /** + * + * + * @generated NOT + */ + public List getAliasNames() + { + if (aliasNames == null) + { + aliasNames = DataObjectUtil.getAliasNames(this); + } + return aliasNames; + } + + /** + * + * + * @generated NOT + */ + public Type getType() + { + return (Type)getEType(); + /* + EClassifier eType = getEType(); + //FB More temporary hacks + return eType instanceof Type ? (Type)getEType() : null; + */ + } + + /** + * + * + * @generated NOT + */ + public Type getContainingType() + { + return (Type)getEContainingClass(); + } + + /** + * + * + * @generated NOT + */ + public Property getOpposite() + { + return (Property)getEOpposite(); + } + + public boolean isNullable() + { + String isNillable = EcoreUtil.getAnnotation(this, ExtendedMetaData.ANNOTATION_URI, "nillable"); + return isNillable != null && "true".equals(isNillable); + } + + public boolean isOpenContent() + { + return SDOUtil.isDocumentRoot(getContainingType()); + } + + public List getInstanceProperties() { + return DataObjectUtil.getMetaObjectInstanceProperties(this); + } + + public Object get(Property property) { + return DataObjectUtil.getMetaObjectInstanceProperty(this, property); + } + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // org.apache.tuscany.sdo.model.Property methods + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + + public List getAliasName() { + return this.getAliasNames(); + } + + public Sequence getAny() { + throw new UnsupportedOperationException(); + } + + public void setMany(boolean value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void unsetMany() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetMany() { + return isMany(); + } + + public void setReadOnly(boolean value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void unsetReadOnly() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetReadOnly() { + return isReadOnly(); + } + + public org.apache.tuscany.sdo.model.Type getType_() { + return (org.apache.tuscany.sdo.model.Type)getType(); + } + + public void setType(org.apache.tuscany.sdo.model.Type value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public Sequence getAnyAttribute() { + throw new UnsupportedOperationException(); + } + + public String getDefault_() { + return (String) this.getDefault(); + } + + public void setDefault_(String value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public org.apache.tuscany.sdo.model.Property getOpposite_() { + return (org.apache.tuscany.sdo.model.Property) getOpposite(); + } + + public void setOpposite_(org.apache.tuscany.sdo.model.Property value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void unsetContainment() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetContainment() { + return isContainment(); + } + + public void setNullable(boolean value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void unsetNullable() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetNullable() { + return isNullable(); + } + + public void unsetName() + { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetName() + { + return true; + } + + public void unsetOpposite() + { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetOpposite() + { + return getOpposite() != null; + } + + public void unsetType() + { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetType() + { + return true; + } + + public void unsetDefault() + { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSetDefault() + { + return getDefault() != null; + } + + + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + // DataObject method implementations + ///////////////////////////////////////////////////////////////////////////////////////////////////////// + /* + public Object get(int propertyIndex) { + return DataObjectUtil.get(this, propertyIndex); + } + + public void set(int propertyIndex, Object value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSet(int propertyIndex) { + return DataObjectUtil.isSet(this, propertyIndex); + } + + public void unset(int propertyIndex) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public Object get(Property property) { + return DataObjectUtil.get(this, ((EStructuralFeature)property).getFeatureID()); + } + + public void set(Property property, Object value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSet(Property property) { + return DataObjectUtil.isSet(this, ((EStructuralFeature)property).getFeatureID()); + } + + public void unset(Property property) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject getContainer() { + return (DataObject)eContainer(); + } + + public Property getContainmentProperty() { + return (Property)eContainmentFeature(); + } + + // Remaining DataObject methods are (will be) implemented as straight delegation to DataObjectUtil + + public Object get(String path) { + return DataObjectUtil.get(this, path); + } + + public void set(String path, Object value) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean isSet(String path) { + return DataObjectUtil.isSet(this, path); + } + + public void unset(String path) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public boolean getBoolean(String path) { + return DataObjectUtil.getBoolean(get(path)); + } + + public byte getByte(String path) { + return DataObjectUtil.getByte(get(path)); + } + + public char getChar(String path) { + return DataObjectUtil.getChar(get(path)); + } + + public double getDouble(String path) { + return DataObjectUtil.getDouble(get(path)); + } + + public float getFloat(String path) { + return DataObjectUtil.getFloat(get(path)); + } + + public int getInt(String path) { + return DataObjectUtil.getInt(get(path)); + } + + public long getLong(String path) { + return DataObjectUtil.getLong(get(path)); + } + + public short getShort(String path) { + return DataObjectUtil.getShort(get(path)); + } + + public byte[] getBytes(String path) { + return DataObjectUtil.getBytes(get(path)); + } + + public BigDecimal getBigDecimal(String path) { + return DataObjectUtil.getBigDecimal(get(path)); + } + + public BigInteger getBigInteger(String path) { + return DataObjectUtil.getBigInteger(get(path)); + } + + public DataObject getDataObject(String path) { + return (DataObject)get(path); + } + + public Date getDate(String path) { + return DataObjectUtil.getDate(get(path)); + } + + public String getString(String path) { + return DataObjectUtil.getString(get(path)); + } + + public List getList(String path) { + return (List)get(path); + } + + public Sequence getSequence(String path) { + return (Sequence)get(path); + } + + public void setBoolean(String path, boolean value) { + set(path, new Boolean(value)); + } + + public void setByte(String path, byte value) { + set(path, new Byte(value)); + } + + public void setChar(String path, char value) { + set(path, new Character(value)); + } + + public void setDouble(String path, double value) { + set(path, new Double(value)); + } + + public void setFloat(String path, float value) { + set(path, new Float(value)); + } + + public void setInt(String path, int value) { + set(path, new Integer(value)); + } + + public void setLong(String path, long value) { + set(path, new Long(value)); + } + + public void setShort(String path, short value) { + set(path, new Short(value)); + } + + public void setBytes(String path, byte[] value) { + set(path, value); + } + + public void setBigDecimal(String path, BigDecimal value) { + set(path, value); + } + + public void setBigInteger(String path, BigInteger value) { + set(path, value); + } + + public void setDataObject(String path, DataObject value) { + set(path, value); + } + + public void setDate(String path, Date value) { + set(path, value); + } + + public void setString(String path, String value) { + set(path, value); + } + + public void setList(String path, List value) { + set(path, value); + } + + public boolean getBoolean(int propertyIndex) { + return DataObjectUtil.getBoolean(this, propertyIndex); + } + + public byte getByte(int propertyIndex) { + return DataObjectUtil.getByte(this, propertyIndex); + } + + public char getChar(int propertyIndex) { + return DataObjectUtil.getChar(this, propertyIndex); + } + + public double getDouble(int propertyIndex) { + return DataObjectUtil.getDouble(this, propertyIndex); + } + + public float getFloat(int propertyIndex) { + return DataObjectUtil.getFloat(this, propertyIndex); + } + + public int getInt(int propertyIndex) { + return DataObjectUtil.getInt(this, propertyIndex); + } + + public long getLong(int propertyIndex) { + return DataObjectUtil.getLong(this, propertyIndex); + } + + public short getShort(int propertyIndex) { + return DataObjectUtil.getShort(this, propertyIndex); + } + + public byte[] getBytes(int propertyIndex) { + return DataObjectUtil.getBytes(this, propertyIndex); + } + + public BigDecimal getBigDecimal(int propertyIndex) { + return DataObjectUtil.getBigDecimal(this, propertyIndex); + } + + public BigInteger getBigInteger(int propertyIndex) { + return DataObjectUtil.getBigInteger(this, propertyIndex); + } + + public DataObject getDataObject(int propertyIndex) { + return DataObjectUtil.getDataObject(this, propertyIndex); + } + + public Date getDate(int propertyIndex) { + return DataObjectUtil.getDate(this, propertyIndex); + } + + public String getString(int propertyIndex) { + return DataObjectUtil.getString(this, propertyIndex); + } + + public List getList(int propertyIndex) { + return DataObjectUtil.getList(this, propertyIndex); + } + + public Sequence getSequence(int propertyIndex) { + return DataObjectUtil.getSequence(this, propertyIndex); + } + + public void setBoolean(int propertyIndex, boolean value) { + set(propertyIndex, new Boolean(value)); + } + + public void setByte(int propertyIndex, byte value) { + set(propertyIndex, new Byte(value)); + } + + public void setChar(int propertyIndex, char value) { + set(propertyIndex, new Character(value)); + } + + public void setDouble(int propertyIndex, double value) { + set(propertyIndex, new Double(value)); + } + + public void setFloat(int propertyIndex, float value) { + set(propertyIndex, new Float(value)); + } + + public void setInt(int propertyIndex, int value) { + set(propertyIndex, new Integer(value)); + } + + public void setLong(int propertyIndex, long value) { + set(propertyIndex, new Long(value)); + } + + public void setShort(int propertyIndex, short value) { + set(propertyIndex, new Short(value)); + } + + public void setBytes(int propertyIndex, byte[] value) { + set(propertyIndex, value); + } + + public void setBigDecimal(int propertyIndex, BigDecimal value) { + set(propertyIndex, value); + } + + public void setBigInteger(int propertyIndex, BigInteger value) { + set(propertyIndex, value); + } + + public void setDataObject(int propertyIndex, DataObject value) { + set(propertyIndex, value); + } + + public void setDate(int propertyIndex, Date value) { + set(propertyIndex, value); + } + + public void setString(int propertyIndex, String value) { + set(propertyIndex, value); + } + + public void setList(int propertyIndex, List value) { + set(propertyIndex, value); + } + + public boolean getBoolean(Property property) { + return DataObjectUtil.getBoolean(this, property); + } + + public byte getByte(Property property) { + return DataObjectUtil.getByte(this, property); + } + + public char getChar(Property property) { + return DataObjectUtil.getChar(this, property); + } + + public double getDouble(Property property) { + return DataObjectUtil.getDouble(this, property); + } + + public float getFloat(Property property) { + return DataObjectUtil.getFloat(this, property); + } + + public int getInt(Property property) { + return DataObjectUtil.getInt(this, property); + } + + public long getLong(Property property) { + return DataObjectUtil.getLong(this, property); + } + + public short getShort(Property property) { + return DataObjectUtil.getShort(this, property); + } + + public byte[] getBytes(Property property) { + return DataObjectUtil.getBytes(this, property); + } + + public BigDecimal getBigDecimal(Property property) { + return DataObjectUtil.getBigDecimal(this, property); + } + + public BigInteger getBigInteger(Property property) { + return DataObjectUtil.getBigInteger(this, property); + } + + public DataObject getDataObject(Property property) { + return DataObjectUtil.getDataObject(this, property); + } + + public Date getDate(Property property) { + return DataObjectUtil.getDate(this, property); + } + + public String getString(Property property) { + return DataObjectUtil.getString(this, property); + } + + public List getList(Property property) { + return DataObjectUtil.getList(this, property); + } + + public Sequence getSequence(Property property) { + return DataObjectUtil.getSequence(this, property); + } + + public void setBoolean(Property property, boolean value) { + set(property, new Boolean(value)); + } + + public void setByte(Property property, byte value) { + set(property, new Byte(value)); + } + + public void setChar(Property property, char value) { + set(property, new Character(value)); + } + + public void setDouble(Property property, double value) { + set(property, new Double(value)); + } + + public void setFloat(Property property, float value) { + set(property, new Float(value)); + } + + public void setInt(Property property, int value) { + set(property, new Integer(value)); + } + + public void setLong(Property property, long value) { + set(property, new Long(value)); + } + + public void setShort(Property property, short value) { + set(property, new Short(value)); + } + + public void setBytes(Property property, byte[] value) { + set(property, value); + } + + public void setBigDecimal(Property property, BigDecimal value) { + set(property, value); + } + + public void setBigInteger(Property property, BigInteger value) { + set(property, value); + } + + public void setDataObject(Property property, DataObject value) { + set(property, value); + } + + public void setDate(Property property, Date value) { + set(property, value); + } + + public void setString(Property property, String value) { + set(property, value); + } + + public void setList(Property property, List value) { + set(property, value); + } + + public DataObject createDataObject(String propertyName) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(String propertyName, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(int propertyIndex, String namespaceURI, String typeName) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataObject createDataObject(Property property, Type type) { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public void delete() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + } + + public DataGraph getDataGraph() { + return DataObjectUtil.getDataGraph(this); + } + + public Sequence getSequence() { + EAttribute mixedFeature = BasicExtendedMetaData.INSTANCE.getMixedFeature(eClass()); + return mixedFeature != null ? (Sequence)eGet(mixedFeature, true, false) : null; + } + + public List getInstanceProperties() { + return DataObjectUtil.getInstanceProperties(this); + } + + public DataObject getRootObject() { + return DataObjectUtil.getRootObject(this); + } + + public ChangeSummary getChangeSummary() { + // TODO: implement this method + throw new UnsupportedOperationException(); + } + + public void detach() { + throw new UnsupportedOperationException("Property is frozen and cannot be modified"); + //DataObjectUtil.detach(this); + } + + public Property getProperty(String propertyName) { + return DataObjectUtil.getProperty(this, propertyName); + } + */ + +} //ReferenceImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOFactoryImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOFactoryImpl.java new file mode 100644 index 0000000000..bb0f5ccd2a --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOFactoryImpl.java @@ -0,0 +1,337 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + +import org.apache.tuscany.sdo.AnyTypeDataObject; +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.SimpleAnyTypeDataObject; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.impl.EFactoryImpl; +import org.eclipse.emf.ecore.impl.EcoreFactoryImpl; +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; + +/** + * + * An implementation of the model Factory. + * + * @generated + */ +public class SDOFactoryImpl extends EFactoryImpl implements SDOFactory +{ + /** + * Creates the default factory implementation. + * + * + * @generated NOT + */ + public static SDOFactory init() + { + try + { + SDOFactory theSDOFactory = (SDOFactory)EPackage.Registry.INSTANCE.getEFactory(SDOPackage.eNS_URI); + if (theSDOFactory != null) + { + return theSDOFactory; + } + } + catch (Exception exception) + { + EcorePlugin.INSTANCE.log(exception); + } + return new SDOFactoryImpl(); + } + + public static class SDOEcoreFactory extends EcoreFactoryImpl + { + public EClass createEClass() { return new ClassImpl(); } + public EDataType createEDataType() { return new DataTypeImpl(); } + //public EEnum createEEnum() { return new EnumImpl(); } + public EAttribute createEAttribute() { return new AttributeImpl(); } + public EReference createEReference() { return new ReferenceImpl(); } + +// public EFactory createEFactory() +// { +// EFactoryImpl eFactory = new EFactoryImpl() { OVERRIDE basicCreate(); } // TODO think about doing this +// return eFactory; +// } + } + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public SDOFactoryImpl() + { + super(); + } + + /** + * + * + * @generated + */ + public EObject create(EClass eClass) + { + switch (eClass.getClassifierID()) + { + case SDOPackage.CHANGE_SUMMARY: return (EObject)createChangeSummary(); + case SDOPackage.CHANGE_SUMMARY_SETTING: return (EObject)createChangeSummarySetting(); + case SDOPackage.DATA_GRAPH: return (EObject)createDataGraph(); + case SDOPackage.ANY_TYPE_DATA_OBJECT: return createAnyTypeDataObject(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT: return createSimpleAnyTypeDataObject(); + case SDOPackage.CLASS: return (EObject)createClass(); + case SDOPackage.DATA_TYPE: return (EObject)createDataType(); + case SDOPackage.ATTRIBUTE: return (EObject)createAttribute(); + case SDOPackage.REFERENCE: return (EObject)createReference(); + case SDOPackage.ENUM: return (EObject)createEnum(); + case SDOPackage.DYNAMIC_DATA_OBJECT: return (EObject)createDynamicDataObject(); + case SDOPackage.STORE_DATA_OBJECT: return (EObject)createStoreDataObject(); + case SDOPackage.DYNAMIC_STORE_DATA_OBJECT: return (EObject)createDynamicStoreDataObject(); + case SDOPackage.EXTENSIBLE_DATA_OBJECT: return (EObject)createExtensibleDataObject(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + public Object createFromString(EDataType eDataType, String initialValue) + { + switch (eDataType.getClassifierID()) + { + default: + throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + public String convertToString(EDataType eDataType, Object instanceValue) + { + switch (eDataType.getClassifierID()) + { + default: + throw new IllegalArgumentException("The datatype '" + eDataType.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + public ChangeSummary createChangeSummary() + { + ChangeSummaryImpl changeSummary = new ChangeSummaryImpl(); + return changeSummary; + } + + /** + * + * + * @generated + */ + public ChangeSummary.Setting createChangeSummarySetting() + { + ChangeSummarySettingImpl changeSummarySetting = new ChangeSummarySettingImpl(); + return changeSummarySetting; + } + + /** + * + * + * @generated + */ + public DataGraph createDataGraph() + { + DataGraphImpl dataGraph = new DataGraphImpl(); + return dataGraph; + } + + /** + * + * + * @generated + */ + public AnyTypeDataObject createAnyTypeDataObject() + { + AnyTypeDataObjectImpl anyTypeDataObject = new AnyTypeDataObjectImpl(); + return anyTypeDataObject; + } + + /** + * + * + * @generated + */ + public SimpleAnyTypeDataObject createSimpleAnyTypeDataObject() + { + SimpleAnyTypeDataObjectImpl simpleAnyTypeDataObject = new SimpleAnyTypeDataObjectImpl(); + return simpleAnyTypeDataObject; + } + + /** + * + * + * @generated + */ + public Type createClass() + { + ClassImpl class_ = new ClassImpl(); + return class_; + } + + /** + * + * + * @generated + */ + public Type createDataType() + { + DataTypeImpl dataType = new DataTypeImpl(); + return dataType; + } + + /** + * + * + * @generated + */ + public Property createAttribute() + { + AttributeImpl attribute = new AttributeImpl(); + return attribute; + } + + /** + * + * + * @generated + */ + public Property createReference() + { + ReferenceImpl reference = new ReferenceImpl(); + return reference; + } + + /** + * + * + * @generated + */ + public Type createEnum() + { + EnumImpl enum_ = new EnumImpl(); + return enum_; + } + + /** + * + * + * @generated + */ + public DataObject createDynamicDataObject() + { + DynamicDataObjectImpl dynamicDataObject = new DynamicDataObjectImpl(); + return dynamicDataObject; + } + + /** + * + * + * @generated + */ + public DataObject createStoreDataObject() + { + StoreDataObjectImpl storeDataObject = new StoreDataObjectImpl(); + return storeDataObject; + } + + /** + * + * + * @generated + */ + public DataObject createDynamicStoreDataObject() + { + DynamicStoreDataObjectImpl dynamicStoreDataObject = new DynamicStoreDataObjectImpl(); + return dynamicStoreDataObject; + } + + /** + * + * + * @generated + */ + public DataObject createExtensibleDataObject() + { + ExtensibleDataObjectImpl extensibleDataObject = new ExtensibleDataObjectImpl(); + return extensibleDataObject; + } + + /** + * + * + * @generated + */ + public SDOPackage getSDOPackage() + { + return (SDOPackage)getEPackage(); + } + + /** + * + * + * @deprecated + * @generated + */ + public static SDOPackage getPackage() + { + return SDOPackage.eINSTANCE; + } + + public ChangeSummary.Setting createChangeSummarySetting(EStructuralFeature eStructuralFeature, Object value, boolean isSet) + { + ChangeSummarySettingImpl eChangeSummarySetting = new ChangeSummarySettingImpl(eStructuralFeature, value, isSet); + return eChangeSummarySetting; + } + +} //SDOFactoryImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOPackageImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOPackageImpl.java new file mode 100644 index 0000000000..25bdab16fe --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/SDOPackageImpl.java @@ -0,0 +1,2207 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.impl; + +import java.io.ObjectStreamException; +import java.util.Collections; +import java.util.List; + +import org.apache.tuscany.sdo.AnyTypeDataObject; +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.SimpleAnyTypeDataObject; +import org.apache.tuscany.sdo.impl.SDOFactoryImpl.SDOEcoreFactory; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EOperation; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.change.ChangePackage; +import org.eclipse.emf.ecore.change.impl.ChangePackageImpl; +import org.eclipse.emf.ecore.impl.EClassImpl; +import org.eclipse.emf.ecore.impl.EPackageImpl; +import org.eclipse.emf.ecore.impl.EcorePackageImpl; +import org.eclipse.emf.ecore.xml.type.XMLTypePackage; +import org.eclipse.emf.ecore.xml.type.impl.XMLTypePackageImpl; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Sequence; +import commonj.sdo.Type; + +/** + * + * An implementation of the model Package. + * + * @generated + */ +public class SDOPackageImpl extends EPackageImpl implements SDOPackage +{ + /** + * + * + * @generated + */ + private EClass changeSummaryEClass = null; + + /** + * + * + * @generated + */ + private EClass changeSummarySettingEClass = null; + + /** + * + * + * @generated + */ + private EClass dataGraphEClass = null; + + /** + * + * + * @generated + */ + private EClass dataObjectEClass = null; + + /** + * + * + * @generated + */ + private EClass propertyEClass = null; + + /** + * + * + * @generated + */ + private EClass sequenceEClass = null; + + /** + * + * + * @generated + */ + private EClass typeEClass = null; + + /** + * + * + * @generated + */ + private EClass anyTypeDataObjectEClass = null; + + /** + * + * + * @generated + */ + private EClass simpleAnyTypeDataObjectEClass = null; + + /** + * + * + * @generated + */ + private EClass classEClass = null; + + /** + * + * + * @generated + */ + private EClass dataTypeEClass = null; + + /** + * + * + * @generated + */ + private EClass attributeEClass = null; + + /** + * + * + * @generated + */ + private EClass referenceEClass = null; + + /** + * + * + * @generated + */ + private EClass enumEClass = null; + + /** + * + * + * @generated + */ + private EClass dynamicDataObjectEClass = null; + + /** + * + * + * @generated + */ + private EClass storeDataObjectEClass = null; + + /** + * + * + * @generated + */ + private EClass dynamicStoreDataObjectEClass = null; + + /** + * + * + * @generated + */ + private EClass extensibleDataObjectEClass = null; + + /** + * + * + * @generated + */ + private EDataType eJavaListEDataType = null; + + /** + * + * + * @generated + */ + private EDataType eObjectStreamExceptionEDataType = null; + + /** + * Creates an instance of the model Package, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + *

Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * + * + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see org.apache.tuscany.sdo.SDOPackage#eNS_URI + * @see #init() + * @generated NOT + */ + private SDOPackageImpl() + { + super(eNS_URI, SDOFactory.eINSTANCE); + ecoreFactory = new SDOEcoreFactory(); + } + + /** + * + * + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the Package for this + * model, and for any others upon which it depends. Simple + * dependencies are satisfied by calling this method on all + * dependent packages before doing anything else. This method drives + * initialization for interdependent packages directly, in parallel + * with this package, itself. + *

Of this package and its interdependencies, all packages which + * have not yet been registered by their URI values are first created + * and registered. The packages are then initialized in two steps: + * meta-model objects for all of the packages are created before any + * are initialized, since one package's meta-model objects may refer to + * those of another. + *

Invocation of this method will not affect any packages that have + * already been initialized. + * + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static SDOPackage init() + { + if (isInited) return (SDOPackage)EPackage.Registry.INSTANCE.getEPackage(SDOPackage.eNS_URI); + + // Obtain or create and register package + SDOPackageImpl theSDOPackage = (SDOPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof SDOPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new SDOPackageImpl()); + + isInited = true; + + // Initialize simple dependencies + EcorePackageImpl.init(); + XMLTypePackageImpl.init(); + ChangePackageImpl.init(); + + // Create package meta-data objects + theSDOPackage.createPackageContents(); + + // Initialize created meta-data + theSDOPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theSDOPackage.freeze(); + + return theSDOPackage; + } + + /** + * + * + * @generated + */ + public EClass getChangeSummary() + { + return changeSummaryEClass; + } + + /** + * + * + * @generated + */ + public EReference getChangeSummary_EDataGraph() + { + return (EReference)changeSummaryEClass.getEStructuralFeatures().get(0); + } + +// /** +// * +// * +// * +// */ +// public EReference getChangeSummary_EDataObject() +// { +// return (EReference)changeSummaryEClass.getEStructuralFeatures().get(1); +// } + + /** + * + * + * @generated + */ + public EClass getChangeSummarySetting() + { + return changeSummarySettingEClass; + } + + /** + * + * + * @generated + */ + public EClass getDataGraph() + { + return dataGraphEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getDataGraph_ResourceSet() + { + return (EAttribute)dataGraphEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EAttribute getDataGraph_RootResource() + { + return (EAttribute)dataGraphEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EReference getDataGraph_EChangeSummary() + { + return (EReference)dataGraphEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + public EReference getDataGraph_ERootObject() + { + return (EReference)dataGraphEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + public EClass getDataObject() + { + return dataObjectEClass; + } + + /** + * + * + * @generated + */ + public EClass getProperty() + { + return propertyEClass; + } + + /** + * + * + * @generated + */ + public EClass getSequence() + { + return sequenceEClass; + } + + /** + * + * + * @generated + */ + public EClass getType() + { + return typeEClass; + } + + /** + * + * + * @generated + */ + public EClass getAnyTypeDataObject() + { + return anyTypeDataObjectEClass; + } + + /** + * + * + * @generated + */ + public EClass getSimpleAnyTypeDataObject() + { + return simpleAnyTypeDataObjectEClass; + } + + /** + * + * + * @generated + */ + public EClass getClass_() + { + return classEClass; + } + + /** + * + * + * @generated + */ + public EClass getDataType() + { + return dataTypeEClass; + } + + /** + * + * + * @generated + */ + public EClass getAttribute() + { + return attributeEClass; + } + + /** + * + * + * @generated + */ + public EClass getReference() + { + return referenceEClass; + } + + /** + * + * + * @generated + */ + public EClass getEnum() + { + return enumEClass; + } + + /** + * + * + * @generated + */ + public EClass getDynamicDataObject() + { + return dynamicDataObjectEClass; + } + + /** + * + * + * @generated + */ + public EClass getStoreDataObject() + { + return storeDataObjectEClass; + } + + /** + * + * + * @generated + */ + public EClass getDynamicStoreDataObject() + { + return dynamicStoreDataObjectEClass; + } + + /** + * + * + * @generated + */ + public EClass getExtensibleDataObject() + { + return extensibleDataObjectEClass; + } + + /** + * + * + * @generated + */ + public EDataType getEJavaList() + { + return eJavaListEDataType; + } + + /** + * + * + * @generated + */ + public EDataType getEObjectStreamException() + { + return eObjectStreamExceptionEDataType; + } + + /** + * + * + * @generated + */ + public SDOFactory getSDOFactory() + { + return (SDOFactory)getEFactoryInstance(); + } + + /** + * + * + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void createPackageContents() + { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + changeSummaryEClass = createEClass(CHANGE_SUMMARY); + createEReference(changeSummaryEClass, CHANGE_SUMMARY__EDATA_GRAPH); + + changeSummarySettingEClass = createEClass(CHANGE_SUMMARY_SETTING); + + dataGraphEClass = createEClass(DATA_GRAPH); + createEAttribute(dataGraphEClass, DATA_GRAPH__RESOURCE_SET); + createEAttribute(dataGraphEClass, DATA_GRAPH__ROOT_RESOURCE); + createEReference(dataGraphEClass, DATA_GRAPH__ECHANGE_SUMMARY); + createEReference(dataGraphEClass, DATA_GRAPH__EROOT_OBJECT); + + dataObjectEClass = createEClass(DATA_OBJECT); + + propertyEClass = createEClass(PROPERTY); + + sequenceEClass = createEClass(SEQUENCE); + + typeEClass = createEClass(TYPE); + + anyTypeDataObjectEClass = createEClass(ANY_TYPE_DATA_OBJECT); + + simpleAnyTypeDataObjectEClass = createEClass(SIMPLE_ANY_TYPE_DATA_OBJECT); + + classEClass = createEClass(CLASS); + + dataTypeEClass = createEClass(DATA_TYPE); + + attributeEClass = createEClass(ATTRIBUTE); + + referenceEClass = createEClass(REFERENCE); + + enumEClass = createEClass(ENUM); + + dynamicDataObjectEClass = createEClass(DYNAMIC_DATA_OBJECT); + + storeDataObjectEClass = createEClass(STORE_DATA_OBJECT); + + dynamicStoreDataObjectEClass = createEClass(DYNAMIC_STORE_DATA_OBJECT); + + extensibleDataObjectEClass = createEClass(EXTENSIBLE_DATA_OBJECT); + + // Create data types + eJavaListEDataType = createEDataType(EJAVA_LIST); + eObjectStreamExceptionEDataType = createEDataType(EOBJECT_STREAM_EXCEPTION); + } + + protected EClass createEClass(int id) + { + EClassImpl c; + switch(id) { + case ANY_TYPE_DATA_OBJECT: + c = new ClassImpl() { + List baseTypes = null; + public List getBaseTypes() { + if (baseTypes == null) + baseTypes = Collections.singletonList(getDataObject()); + return baseTypes; + } + public List getTypeFeatures() { + return getEAllStructuralFeatures(); + } + }; + break; + case SIMPLE_ANY_TYPE_DATA_OBJECT: + c = new ClassImpl() { + List baseTypes = null; + public List getBaseTypes() { + if (baseTypes == null) + baseTypes = Collections.singletonList(getAnyTypeDataObject()); + return baseTypes; + } + }; + break; + default: + c = (EClassImpl)ecoreFactory.createEClass(); + } + c.setClassifierID(id); + getEClassifiers().add(c); + return c; + } + + /** + * + * + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void initializePackageContents() + { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Obtain other dependent packages + ChangePackageImpl theChangePackage = (ChangePackageImpl)EPackage.Registry.INSTANCE.getEPackage(ChangePackage.eNS_URI); + EcorePackageImpl theEcorePackage = (EcorePackageImpl)EPackage.Registry.INSTANCE.getEPackage(EcorePackage.eNS_URI); + XMLTypePackageImpl theXMLTypePackage = (XMLTypePackageImpl)EPackage.Registry.INSTANCE.getEPackage(XMLTypePackage.eNS_URI); + + // Add supertypes to classes + changeSummaryEClass.getESuperTypes().add(theChangePackage.getChangeDescription()); + changeSummarySettingEClass.getESuperTypes().add(theChangePackage.getFeatureChange()); + dataGraphEClass.getESuperTypes().add(theEcorePackage.getEObject()); + anyTypeDataObjectEClass.getESuperTypes().add(this.getDataObject()); + anyTypeDataObjectEClass.getESuperTypes().add(theXMLTypePackage.getAnyType()); + simpleAnyTypeDataObjectEClass.getESuperTypes().add(this.getAnyTypeDataObject()); + simpleAnyTypeDataObjectEClass.getESuperTypes().add(theXMLTypePackage.getSimpleAnyType()); + classEClass.getESuperTypes().add(theEcorePackage.getEClass()); + classEClass.getESuperTypes().add(this.getType()); + dataTypeEClass.getESuperTypes().add(theEcorePackage.getEDataType()); + dataTypeEClass.getESuperTypes().add(this.getType()); + attributeEClass.getESuperTypes().add(theEcorePackage.getEAttribute()); + attributeEClass.getESuperTypes().add(this.getProperty()); + referenceEClass.getESuperTypes().add(theEcorePackage.getEReference()); + referenceEClass.getESuperTypes().add(this.getProperty()); + enumEClass.getESuperTypes().add(theEcorePackage.getEEnum()); + enumEClass.getESuperTypes().add(this.getType()); + dynamicDataObjectEClass.getESuperTypes().add(this.getDataObject()); + storeDataObjectEClass.getESuperTypes().add(this.getDataObject()); + dynamicStoreDataObjectEClass.getESuperTypes().add(this.getStoreDataObject()); + extensibleDataObjectEClass.getESuperTypes().add(this.getDataObject()); + + // Initialize classes and features; add operations and parameters + initEClass(changeSummaryEClass, ChangeSummary.class, "ChangeSummary", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + initEReference(getChangeSummary_EDataGraph(), this.getDataGraph(), this.getDataGraph_EChangeSummary(), "eDataGraph", null, 1, 1, ChangeSummary.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + addEOperation(changeSummaryEClass, null, "beginLogging"); + + addEOperation(changeSummaryEClass, null, "endLogging"); + + EOperation op = addEOperation(changeSummaryEClass, ecorePackage.getEBoolean(), "isCreated"); + addEParameter(op, this.getDataObject(), "dataObject"); + + op = addEOperation(changeSummaryEClass, ecorePackage.getEBoolean(), "isDeleted"); + addEParameter(op, this.getDataObject(), "dataObject"); + + op = addEOperation(changeSummaryEClass, this.getEJavaList(), "getOldValues"); + addEParameter(op, this.getDataObject(), "dataObject"); + + op = addEOperation(changeSummaryEClass, ecorePackage.getEBoolean(), "isModified"); + addEParameter(op, this.getDataObject(), "dataObject"); + + op = addEOperation(changeSummaryEClass, this.getChangeSummarySetting(), "getOldValue"); + addEParameter(op, this.getDataObject(), "dataObject"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(changeSummaryEClass, this.getDataObject(), "getOldContainer"); + addEParameter(op, this.getDataObject(), "dataObject"); + + op = addEOperation(changeSummaryEClass, this.getProperty(), "getOldContainmentProperty"); + addEParameter(op, this.getDataObject(), "dataObject"); + + op = addEOperation(changeSummaryEClass, this.getSequence(), "getOldSequence"); + addEParameter(op, this.getDataObject(), "dataObject"); + + addEOperation(changeSummaryEClass, null, "undoChanges"); + + addEOperation(changeSummaryEClass, ecorePackage.getEBoolean(), "isLogging"); + + addEOperation(changeSummaryEClass, this.getDataGraph(), "getDataGraph"); + + addEOperation(changeSummaryEClass, this.getEJavaList(), "getChangedObjects"); + + addEOperation(changeSummaryEClass, this.getDataObject(), "getRootObject"); + + initEClass(changeSummarySettingEClass, ChangeSummary.Setting.class, "ChangeSummarySetting", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + addEOperation(changeSummarySettingEClass, ecorePackage.getEBoolean(), "isSet"); + + addEOperation(changeSummarySettingEClass, theEcorePackage.getEJavaObject(), "getValue"); + + addEOperation(changeSummarySettingEClass, this.getProperty(), "getProperty"); + + initEClass(dataGraphEClass, DataGraph.class, "DataGraph", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getDataGraph_ResourceSet(), theEcorePackage.getEResourceSet(), "resourceSet", null, 0, 1, DataGraph.class, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getDataGraph_RootResource(), theEcorePackage.getEResource(), "rootResource", null, 0, 1, DataGraph.class, IS_TRANSIENT, IS_VOLATILE, !IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + initEReference(getDataGraph_EChangeSummary(), this.getChangeSummary(), this.getChangeSummary_EDataGraph(), "eChangeSummary", null, 1, 1, DataGraph.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getDataGraph_ERootObject(), theEcorePackage.getEObject(), null, "eRootObject", null, 1, 1, DataGraph.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + op = addEOperation(dataGraphEClass, this.getDataObject(), "createRootObject"); + addEParameter(op, ecorePackage.getEString(), "namespaceURI"); + addEParameter(op, ecorePackage.getEString(), "typeName"); + + op = addEOperation(dataGraphEClass, this.getDataObject(), "createRootObject"); + addEParameter(op, this.getType(), "type"); + + op = addEOperation(dataGraphEClass, this.getType(), "getType"); + addEParameter(op, ecorePackage.getEString(), "namespaceURI"); + addEParameter(op, ecorePackage.getEString(), "typeName"); + + addEOperation(dataGraphEClass, this.getDataObject(), "getRootObject"); + + addEOperation(dataGraphEClass, this.getChangeSummary(), "getChangeSummary"); + + initEClass(dataObjectEClass, DataObject.class, "DataObject", IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEJavaObject(), "get"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, null, "set"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, theEcorePackage.getEJavaObject(), "value"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEBoolean(), "isSet"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, null, "unset"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEJavaObject(), "get"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, null, "set"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, theEcorePackage.getEJavaObject(), "value"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEBoolean(), "isSet"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, null, "unset"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEJavaObject(), "get"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, null, "set"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, theEcorePackage.getEJavaObject(), "value"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEBoolean(), "isSet"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, null, "unset"); + addEParameter(op, this.getProperty(), "property"); + + addEOperation(dataObjectEClass, this.getDataObject(), "getContainer"); + + addEOperation(dataObjectEClass, this.getProperty(), "getContainmentProperty"); + + addEOperation(dataObjectEClass, this.getDataGraph(), "getDataGraph"); + + addEOperation(dataObjectEClass, this.getType(), "getType"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEBigDecimal(), "getBigDecimal"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEBigInteger(), "getBigInteger"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEBoolean(), "getBoolean"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEByte(), "getByte"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEByteArray(), "getBytes"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEChar(), "getChar"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, this.getDataObject(), "getDataObject"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEDate(), "getDate"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEDouble(), "getDouble"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEFloat(), "getFloat"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEInt(), "getInt"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, this.getEJavaList(), "getList"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, ecorePackage.getELong(), "getLong"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, this.getSequence(), "getSequence"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEShort(), "getShort"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEString(), "getString"); + addEParameter(op, ecorePackage.getEString(), "path"); + + op = addEOperation(dataObjectEClass, null, "setBigDecimal"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, theEcorePackage.getEBigDecimal(), "value"); + + op = addEOperation(dataObjectEClass, null, "setBigInteger"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, theEcorePackage.getEBigInteger(), "value"); + + op = addEOperation(dataObjectEClass, null, "setBoolean"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, ecorePackage.getEBoolean(), "value"); + + op = addEOperation(dataObjectEClass, null, "setByte"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, ecorePackage.getEByte(), "value"); + + op = addEOperation(dataObjectEClass, null, "setBytes"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, theEcorePackage.getEByteArray(), "value"); + + op = addEOperation(dataObjectEClass, null, "setChar"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, ecorePackage.getEChar(), "value"); + + op = addEOperation(dataObjectEClass, null, "setDataObject"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, this.getDataObject(), "value"); + + op = addEOperation(dataObjectEClass, null, "setDate"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, theEcorePackage.getEDate(), "value"); + + op = addEOperation(dataObjectEClass, null, "setDouble"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, ecorePackage.getEDouble(), "value"); + + op = addEOperation(dataObjectEClass, null, "setFloat"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, ecorePackage.getEFloat(), "value"); + + op = addEOperation(dataObjectEClass, null, "setInt"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, ecorePackage.getEInt(), "value"); + + op = addEOperation(dataObjectEClass, null, "setList"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, this.getEJavaList(), "value"); + + op = addEOperation(dataObjectEClass, null, "setLong"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, ecorePackage.getELong(), "value"); + + op = addEOperation(dataObjectEClass, null, "setShort"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, ecorePackage.getEShort(), "value"); + + op = addEOperation(dataObjectEClass, null, "setString"); + addEParameter(op, ecorePackage.getEString(), "path"); + addEParameter(op, ecorePackage.getEString(), "value"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEBigDecimal(), "getBigDecimal"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEBigInteger(), "getBigInteger"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEBoolean(), "getBoolean"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEByte(), "getByte"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEByteArray(), "getBytes"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEChar(), "getChar"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, this.getDataObject(), "getDataObject"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEDate(), "getDate"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEDouble(), "getDouble"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEFloat(), "getFloat"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEInt(), "getInt"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, this.getEJavaList(), "getList"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, ecorePackage.getELong(), "getLong"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, this.getSequence(), "getSequence"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEShort(), "getShort"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEString(), "getString"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, null, "setBigDecimal"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, theEcorePackage.getEBigDecimal(), "value"); + + op = addEOperation(dataObjectEClass, null, "setBigInteger"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, theEcorePackage.getEBigInteger(), "value"); + + op = addEOperation(dataObjectEClass, null, "setBoolean"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, ecorePackage.getEBoolean(), "value"); + + op = addEOperation(dataObjectEClass, null, "setByte"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, ecorePackage.getEByte(), "value"); + + op = addEOperation(dataObjectEClass, null, "setBytes"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, theEcorePackage.getEByteArray(), "value"); + + op = addEOperation(dataObjectEClass, null, "setChar"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, ecorePackage.getEChar(), "value"); + + op = addEOperation(dataObjectEClass, null, "setDataObject"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, this.getDataObject(), "value"); + + op = addEOperation(dataObjectEClass, null, "setDate"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, theEcorePackage.getEDate(), "value"); + + op = addEOperation(dataObjectEClass, null, "setDouble"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, ecorePackage.getEDouble(), "value"); + + op = addEOperation(dataObjectEClass, null, "setFloat"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, ecorePackage.getEFloat(), "value"); + + op = addEOperation(dataObjectEClass, null, "setInt"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, ecorePackage.getEInt(), "value"); + + op = addEOperation(dataObjectEClass, null, "setList"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, this.getEJavaList(), "value"); + + op = addEOperation(dataObjectEClass, null, "setLong"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, ecorePackage.getELong(), "value"); + + op = addEOperation(dataObjectEClass, null, "setShort"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, ecorePackage.getEShort(), "value"); + + op = addEOperation(dataObjectEClass, null, "setString"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, ecorePackage.getEString(), "value"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEBigDecimal(), "getBigDecimal"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEBigInteger(), "getBigInteger"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEBoolean(), "getBoolean"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEByte(), "getByte"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEByteArray(), "getBytes"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEChar(), "getChar"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, this.getDataObject(), "getDataObject"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, theEcorePackage.getEDate(), "getDate"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEDouble(), "getDouble"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEFloat(), "getFloat"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEInt(), "getInt"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, this.getEJavaList(), "getList"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, ecorePackage.getELong(), "getLong"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, this.getSequence(), "getSequence"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEShort(), "getShort"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, ecorePackage.getEString(), "getString"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, null, "setBigDecimal"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, theEcorePackage.getEBigDecimal(), "value"); + + op = addEOperation(dataObjectEClass, null, "setBigInteger"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, theEcorePackage.getEBigInteger(), "value"); + + op = addEOperation(dataObjectEClass, null, "setBoolean"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, ecorePackage.getEBoolean(), "value"); + + op = addEOperation(dataObjectEClass, null, "setByte"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, ecorePackage.getEByte(), "value"); + + op = addEOperation(dataObjectEClass, null, "setBytes"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, theEcorePackage.getEByteArray(), "value"); + + op = addEOperation(dataObjectEClass, null, "setChar"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, ecorePackage.getEChar(), "value"); + + op = addEOperation(dataObjectEClass, null, "setDataObject"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, this.getDataObject(), "value"); + + op = addEOperation(dataObjectEClass, null, "setDate"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, theEcorePackage.getEDate(), "value"); + + op = addEOperation(dataObjectEClass, null, "setDouble"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, ecorePackage.getEDouble(), "value"); + + op = addEOperation(dataObjectEClass, null, "setFloat"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, ecorePackage.getEFloat(), "value"); + + op = addEOperation(dataObjectEClass, null, "setInt"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, ecorePackage.getEInt(), "value"); + + op = addEOperation(dataObjectEClass, null, "setList"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, this.getEJavaList(), "value"); + + op = addEOperation(dataObjectEClass, null, "setLong"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, ecorePackage.getELong(), "value"); + + op = addEOperation(dataObjectEClass, null, "setShort"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, ecorePackage.getEShort(), "value"); + + op = addEOperation(dataObjectEClass, null, "setString"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, ecorePackage.getEString(), "value"); + + op = addEOperation(dataObjectEClass, this.getDataObject(), "createDataObject"); + addEParameter(op, ecorePackage.getEString(), "propertyName"); + + op = addEOperation(dataObjectEClass, this.getDataObject(), "createDataObject"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + + op = addEOperation(dataObjectEClass, this.getDataObject(), "createDataObject"); + addEParameter(op, this.getProperty(), "property"); + + op = addEOperation(dataObjectEClass, this.getDataObject(), "createDataObject"); + addEParameter(op, ecorePackage.getEString(), "propertyName"); + addEParameter(op, ecorePackage.getEString(), "namespaceURI"); + addEParameter(op, ecorePackage.getEString(), "typeName"); + + op = addEOperation(dataObjectEClass, this.getDataObject(), "createDataObject"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, ecorePackage.getEString(), "namespaceURI"); + addEParameter(op, ecorePackage.getEString(), "typeName"); + + op = addEOperation(dataObjectEClass, this.getDataObject(), "createDataObject"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, this.getType(), "type"); + + addEOperation(dataObjectEClass, null, "delete"); + + addEOperation(dataObjectEClass, this.getSequence(), "getSequence"); + + addEOperation(dataObjectEClass, this.getEJavaList(), "getInstanceProperties"); + + op = addEOperation(dataObjectEClass, this.getProperty(), "getProperty"); + addEParameter(op, ecorePackage.getEString(), "propertyName"); + + addEOperation(dataObjectEClass, this.getDataObject(), "getRootObject"); + + addEOperation(dataObjectEClass, this.getChangeSummary(), "getChangeSummary"); + + addEOperation(dataObjectEClass, null, "detach"); + + initEClass(propertyEClass, Property.class, "Property", IS_ABSTRACT, IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + addEOperation(propertyEClass, ecorePackage.getEString(), "getName"); + + addEOperation(propertyEClass, this.getType(), "getType"); + + addEOperation(propertyEClass, ecorePackage.getEBoolean(), "isMany"); + + addEOperation(propertyEClass, ecorePackage.getEBoolean(), "isContainment"); + + addEOperation(propertyEClass, ecorePackage.getEBoolean(), "isReadOnly"); + + addEOperation(propertyEClass, this.getType(), "getContainingType"); + + addEOperation(propertyEClass, this.getEJavaList(), "getAliasNames"); + + addEOperation(propertyEClass, this.getProperty(), "getOpposite"); + + addEOperation(propertyEClass, theEcorePackage.getEJavaObject(), "getDefault"); + + initEClass(sequenceEClass, Sequence.class, "Sequence", IS_ABSTRACT, IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + addEOperation(sequenceEClass, ecorePackage.getEInt(), "size"); + + op = addEOperation(sequenceEClass, this.getProperty(), "getProperty"); + addEParameter(op, ecorePackage.getEInt(), "index"); + + op = addEOperation(sequenceEClass, theEcorePackage.getEJavaObject(), "getValue"); + addEParameter(op, ecorePackage.getEInt(), "index"); + + op = addEOperation(sequenceEClass, theEcorePackage.getEJavaObject(), "setValue"); + addEParameter(op, ecorePackage.getEInt(), "index"); + addEParameter(op, theEcorePackage.getEJavaObject(), "value"); + + op = addEOperation(sequenceEClass, ecorePackage.getEBoolean(), "add"); + addEParameter(op, ecorePackage.getEString(), "propertyName"); + addEParameter(op, theEcorePackage.getEJavaObject(), "value"); + + op = addEOperation(sequenceEClass, ecorePackage.getEBoolean(), "add"); + addEParameter(op, ecorePackage.getEInt(), "propertIndex"); + addEParameter(op, theEcorePackage.getEJavaObject(), "value"); + + op = addEOperation(sequenceEClass, ecorePackage.getEBoolean(), "add"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, theEcorePackage.getEJavaObject(), "value"); + + op = addEOperation(sequenceEClass, null, "add"); + addEParameter(op, ecorePackage.getEInt(), "index"); + addEParameter(op, ecorePackage.getEString(), "propertyName"); + addEParameter(op, theEcorePackage.getEJavaObject(), "value"); + + op = addEOperation(sequenceEClass, null, "add"); + addEParameter(op, ecorePackage.getEInt(), "index"); + addEParameter(op, ecorePackage.getEInt(), "propertyIndex"); + addEParameter(op, theEcorePackage.getEJavaObject(), "value"); + + op = addEOperation(sequenceEClass, null, "add"); + addEParameter(op, ecorePackage.getEInt(), "index"); + addEParameter(op, this.getProperty(), "property"); + addEParameter(op, theEcorePackage.getEJavaObject(), "value"); + + op = addEOperation(sequenceEClass, null, "add"); + addEParameter(op, ecorePackage.getEString(), "text"); + + op = addEOperation(sequenceEClass, null, "add"); + addEParameter(op, ecorePackage.getEInt(), "index"); + addEParameter(op, ecorePackage.getEString(), "text"); + + initEClass(typeEClass, Type.class, "Type", IS_ABSTRACT, IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + addEOperation(typeEClass, ecorePackage.getEString(), "getName"); + + addEOperation(typeEClass, ecorePackage.getEString(), "getURI"); + + addEOperation(typeEClass, theEcorePackage.getEJavaClass(), "getInstanceClass"); + + op = addEOperation(typeEClass, ecorePackage.getEBoolean(), "isInstance"); + addEParameter(op, theEcorePackage.getEJavaObject(), "object"); + + addEOperation(typeEClass, ecorePackage.getEBoolean(), "isDataType"); + + addEOperation(typeEClass, ecorePackage.getEBoolean(), "isSequenced"); + + addEOperation(typeEClass, ecorePackage.getEBoolean(), "isOpen"); + + addEOperation(typeEClass, ecorePackage.getEBoolean(), "isAbstract"); + + addEOperation(typeEClass, this.getEJavaList(), "getBaseTypes"); + + addEOperation(typeEClass, this.getEJavaList(), "getAliasNames"); + + addEOperation(typeEClass, this.getEJavaList(), "getProperties"); + + addEOperation(typeEClass, this.getEJavaList(), "getDeclaredProperties"); + + op = addEOperation(typeEClass, this.getProperty(), "getProperty"); + addEParameter(op, ecorePackage.getEString(), "propertyName"); + + initEClass(anyTypeDataObjectEClass, AnyTypeDataObject.class, "AnyTypeDataObject", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + + initEClass(simpleAnyTypeDataObjectEClass, SimpleAnyTypeDataObject.class, "SimpleAnyTypeDataObject", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + + initEClass(classEClass, Type.class, "Class", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + initEClass(dataTypeEClass, Type.class, "DataType", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + initEClass(attributeEClass, Property.class, "Attribute", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + initEClass(referenceEClass, Property.class, "Reference", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + initEClass(enumEClass, Type.class, "Enum", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + initEClass(dynamicDataObjectEClass, DataObject.class, "DynamicDataObject", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + initEClass(storeDataObjectEClass, DataObject.class, "StoreDataObject", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + initEClass(dynamicStoreDataObjectEClass, DataObject.class, "DynamicStoreDataObject", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + initEClass(extensibleDataObjectEClass, DataObject.class, "ExtensibleDataObject", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + + // Initialize data types + initEDataType(eJavaListEDataType, List.class, "EJavaList", !IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + initEDataType(eObjectStreamExceptionEDataType, ObjectStreamException.class, "EObjectStreamException", !IS_SERIALIZABLE, !IS_GENERATED_INSTANCE_CLASS); + + // Create resource + createResource(eNS_URI); + + // Create annotations + // http://www.eclipse.org/emf/2002/GenModel + createGenModelAnnotations(); + // http:///org/eclipse/emf/ecore/util/ExtendedMetaData + createExtendedMetaDataAnnotations(); + } + + /** + * Initializes the annotations for http://www.eclipse.org/emf/2002/GenModel. + * + * + * @generated + */ + protected void createGenModelAnnotations() + { + String source = "http://www.eclipse.org/emf/2002/GenModel"; + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(0), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.get(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(1), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.set(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(2), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.isSet(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(3), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.unset(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(4), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.get(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(5), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.set(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(6), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.isSet(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(7), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.unset(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(8), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.get(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(9), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.set(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(10), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.isSet(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(11), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.unset(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(12), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getContainer(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(13), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getContainmentProperty(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(14), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDataGraph(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(15), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getType(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(16), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBigDecimal(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(17), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBigInteger(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(18), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBoolean(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(19), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getByte(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(20), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBytes(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(21), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getChar(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(22), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDataObject(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(23), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDate(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(24), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDouble(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(25), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getFloat(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(26), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getInt(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(27), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getList(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(28), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getLong(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(29), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getSequence(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(30), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getShort(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(31), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getString(this, path);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(32), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBigDecimal(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(33), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBigInteger(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(34), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBoolean(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(35), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setByte(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(36), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBytes(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(37), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setChar(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(38), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDataObject(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(39), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDate(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(40), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDouble(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(41), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setFloat(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(42), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setInt(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(43), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setList(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(44), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setLong(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(45), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setShort(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(46), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setString(this, path, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(47), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBigDecimal(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(48), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBigInteger(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(49), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBoolean(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(50), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getByte(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(51), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBytes(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(52), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getChar(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(53), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDataObject(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(54), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDate(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(55), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDouble(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(56), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getFloat(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(57), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getInt(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(58), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getList(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(59), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getLong(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(60), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getSequence(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(61), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getShort(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(62), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getString(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(63), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBigDecimal(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(64), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBigInteger(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(65), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBoolean(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(66), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setByte(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(67), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBytes(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(68), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setChar(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(69), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDataObject(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(70), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDate(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(71), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDouble(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(72), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setFloat(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(73), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setInt(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(74), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setList(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(75), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setLong(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(76), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setShort(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(77), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setString(this, propertyIndex, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(78), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBigDecimal(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(79), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBigInteger(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(80), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBoolean(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(81), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getByte(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(82), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getBytes(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(83), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getChar(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(84), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDataObject(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(85), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDate(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(86), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getDouble(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(87), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getFloat(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(88), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getInt(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(89), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getList(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(90), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getLong(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(91), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getSequence(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(92), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getShort(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(93), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getString(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(94), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBigDecimal(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(95), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBigInteger(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(96), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBoolean(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(97), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setByte(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(98), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setBytes(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(99), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setChar(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(100), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDataObject(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(101), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDate(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(102), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setDouble(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(103), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setFloat(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(104), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setInt(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(105), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setList(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(106), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setLong(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(107), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setShort(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(108), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.setString(this, property, value);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(109), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, propertyName);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(110), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, propertyIndex);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(111), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, property);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(112), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, propertyName, namespaceURI, typeName);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(113), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, propertyIndex, namespaceURI, typeName);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(114), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.createDataObject(this, property, type);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(115), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.delete(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(116), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getSequence(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(117), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getInstanceProperties(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(118), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getProperty(this, propertyName);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(119), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getRootObject(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(120), + source, + new String[] + { + "body", "return <%org.apache.sdo.util.SDOUtil%>.getChangeSummary(this);" + }); + addAnnotation + ((EOperation)dataObjectEClass.getEOperations().get(121), + source, + new String[] + { + "body", "<%org.apache.sdo.util.SDOUtil%>.detach(this);" + }); + } + + /** + * Initializes the annotations for http:///org/eclipse/emf/ecore/util/ExtendedMetaData. + * + * + * @generated + */ + protected void createExtendedMetaDataAnnotations() + { + String source = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData"; + addAnnotation + (anyTypeDataObjectEClass, + source, + new String[] + { + "kind", "mixed" + }); + addAnnotation + (simpleAnyTypeDataObjectEClass, + source, + new String[] + { + "kind", "simple" + }); + } + +} //SDOPackageImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/SimpleAnyTypeDataObjectImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/SimpleAnyTypeDataObjectImpl.java new file mode 100644 index 0000000000..e257e30d27 --- /dev/null +++ b/sandbox/kgoodson/events/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; + +/** + * + * An implementation of the model object 'EData Object Simple Any Type'. + * + *

+ * The following features are implemented: + *

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

+ * + * @generated + */ +public class SimpleAnyTypeDataObjectImpl extends AnyTypeDataObjectImpl implements SimpleAnyTypeDataObject +{ + /** + * The default value of the '{@link #getRawValue() Raw Value}' attribute. + * + * + * @see #getRawValue() + * @generated + * @ordered + */ + protected static final String RAW_VALUE_EDEFAULT = null; + + /** + * The default value of the '{@link #getValue() Value}' attribute. + * + * + * @see #getValue() + * @generated + * @ordered + */ + protected static final Object VALUE_EDEFAULT = null; + + /** + * The cached value of the '{@link #getInstanceType() Instance Type}' reference. + * + * + * @see #getInstanceType() + * @generated + * @ordered + */ + protected EDataType instanceType = null; + + /** + * + * + * @generated + */ + protected SimpleAnyTypeDataObjectImpl() + { + super(); + } + + /** + * + * + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getSimpleAnyTypeDataObject(); + } + + /** + * + * + * @generated NOT + */ + public String getRawValue() + { + StringBuffer value = new StringBuffer(); + for (Iterator i = getMixed().iterator(); i.hasNext(); ) + { + FeatureMap.Entry entry = (FeatureMap.Entry)i.next(); + if (entry.getEStructuralFeature() == XMLTypePackage.eINSTANCE.getXMLTypeDocumentRoot_Text()) + { + value.append(entry.getValue()); + } + } + return value.toString(); + } + + /** + * + * + * @generated NOT + */ + public void setRawValue(String newRawValue) + { + getMixed().clear(); + if (newRawValue != null) + { + getMixed().add(XMLTypePackage.eINSTANCE.getXMLTypeDocumentRoot_Text(), newRawValue); + } + } + + /** + * + * + * @generated NOT + */ + public Object getValue() + { + return EcoreUtil.createFromString(instanceType, getRawValue()); + } + + /** + * + * + * @generated NOT + */ + public void setValue(Object newValue) + { + setRawValue(EcoreUtil.convertToString(instanceType, newValue)); + } + + /** + * + * + * @generated + */ + public EDataType getInstanceType() + { + return instanceType; + } + + /** + * + * + * @generated + */ + public void setInstanceType(EDataType newInstanceType) + { + EDataType oldInstanceType = instanceType; + instanceType = newInstanceType; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE, oldInstanceType, instanceType)); + } + + /** + * + * + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__MIXED: + if (coreType) return getMixed(); + return ((FeatureMap.Internal)getMixed()).getWrapper(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY: + if (coreType) return getAny(); + return ((FeatureMap.Internal)getAny()).getWrapper(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + if (coreType) return getAnyAttribute(); + return ((FeatureMap.Internal)getAnyAttribute()).getWrapper(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__RAW_VALUE: + return getRawValue(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__VALUE: + return getValue(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE: + return getInstanceType(); + } + return eDynamicGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__MIXED: + ((FeatureMap.Internal)getMixed()).set(newValue); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY: + ((FeatureMap.Internal)getAny()).set(newValue); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + ((FeatureMap.Internal)getAnyAttribute()).set(newValue); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__RAW_VALUE: + setRawValue((String)newValue); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__VALUE: + setValue((Object)newValue); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE: + setInstanceType((EDataType)newValue); + return; + } + eDynamicSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__MIXED: + getMixed().clear(); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY: + getAny().clear(); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + getAnyAttribute().clear(); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__RAW_VALUE: + setRawValue(RAW_VALUE_EDEFAULT); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__VALUE: + setValue(VALUE_EDEFAULT); + return; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE: + setInstanceType((EDataType)null); + return; + } + eDynamicUnset(featureID); + } + + /** + * + * + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__MIXED: + return mixed != null && !mixed.isEmpty(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY: + return !getAny().isEmpty(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__ANY_ATTRIBUTE: + return anyAttribute != null && !anyAttribute.isEmpty(); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__RAW_VALUE: + return RAW_VALUE_EDEFAULT == null ? getRawValue() != null : !RAW_VALUE_EDEFAULT.equals(getRawValue()); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__VALUE: + return VALUE_EDEFAULT == null ? getValue() != null : !VALUE_EDEFAULT.equals(getValue()); + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE: + return instanceType != null; + } + return eDynamicIsSet(featureID); + } + + /** + * + * + * @generated + */ + public int eBaseStructuralFeatureID(int derivedFeatureID, Class baseClass) + { + if (baseClass == SimpleAnyType.class) + { + switch (derivedFeatureID) + { + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__RAW_VALUE: return XMLTypePackage.SIMPLE_ANY_TYPE__RAW_VALUE; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__VALUE: return XMLTypePackage.SIMPLE_ANY_TYPE__VALUE; + case SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE: return XMLTypePackage.SIMPLE_ANY_TYPE__INSTANCE_TYPE; + default: return -1; + } + } + return super.eBaseStructuralFeatureID(derivedFeatureID, baseClass); + } + + /** + * + * + * @generated + */ + public int eDerivedStructuralFeatureID(int baseFeatureID, Class baseClass) + { + if (baseClass == SimpleAnyType.class) + { + switch (baseFeatureID) + { + case XMLTypePackage.SIMPLE_ANY_TYPE__RAW_VALUE: return SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__RAW_VALUE; + case XMLTypePackage.SIMPLE_ANY_TYPE__VALUE: return SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__VALUE; + case XMLTypePackage.SIMPLE_ANY_TYPE__INSTANCE_TYPE: return SDOPackage.SIMPLE_ANY_TYPE_DATA_OBJECT__INSTANCE_TYPE; + default: return -1; + } + } + return super.eDerivedStructuralFeatureID(baseFeatureID, baseClass); + } + +} //EDataObjectSimpleAnyTypeImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/StoreDataObjectImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/impl/StoreDataObjectImpl.java new file mode 100644 index 0000000000..0cf7f3586c --- /dev/null +++ b/sandbox/kgoodson/events/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; + +/** + * + * An implementation of the model object 'Store Data Object'. + * @extends EStructuralFeature.Internal.DynamicValueHolder + * + *

+ *

+ * + * @generated + */ +public class StoreDataObjectImpl extends DataObjectImpl implements DataObject, EStructuralFeature.Internal.DynamicValueHolder +{ + //TODO consider factoring the eSettings code into a new base class that this and DynamicDataObjectImpl could extend + + protected static final Object [] ENO_SETTINGS = new Object [0]; + protected static final InternalEObject EUNINITIALIZED_CONTAINER = new DynamicDataObjectImpl(); + + protected Object [] eSettings; + protected InternalEObject.EStore eStore; + + /** + * Creates a store-based DataObject. + */ + public StoreDataObjectImpl() + { + super(); + eContainer = EUNINITIALIZED_CONTAINER; + } + + /** + * Creates a store-based DataObject. + */ + public StoreDataObjectImpl(InternalEObject.EStore eStore) + { + super(); + eSetStore(eStore); + eContainer = EUNINITIALIZED_CONTAINER; + } + + /** + * Creates a store-based DataObject. + */ + public StoreDataObjectImpl(EClass eClass) + { + super(); + eSetClass(eClass); + eContainer = EUNINITIALIZED_CONTAINER; + } + + /** + * Creates a store-based DataObject. + */ + public StoreDataObjectImpl(EClass eClass, InternalEObject.EStore eStore) + { + super(); + eSetClass(eClass); + eSetStore(eStore); + eContainer = EUNINITIALIZED_CONTAINER; + } + + protected boolean eIsCaching() + { + return true; + } + + public Object dynamicGet(int dynamicFeatureID) + { + Object result = eSettings[dynamicFeatureID]; + if (result == null) + { + EStructuralFeature eStructuralFeature = eDynamicFeature(dynamicFeatureID); + if (!eStructuralFeature.isTransient()) + { + if (FeatureMapUtil.isFeatureMap(eStructuralFeature)) + { + eSettings[dynamicFeatureID] = result = createFeatureMap(eStructuralFeature); + } + else if (eStructuralFeature.isMany()) + { + eSettings[dynamicFeatureID] = result = createList(eStructuralFeature); + } + else + { + result = eStore().get(this, eStructuralFeature, InternalEObject.EStore.NO_INDEX); + if (eIsCaching()) + { + eSettings[dynamicFeatureID] = result; + } + } + } + } + return result; + } + + public void dynamicSet(int dynamicFeatureID, Object value) + { + EStructuralFeature eStructuralFeature = eDynamicFeature(dynamicFeatureID); + if (eStructuralFeature.isTransient()) + { + eSettings[dynamicFeatureID] = value; + } + else + { + eStore().set(this, eStructuralFeature, InternalEObject.EStore.NO_INDEX, value == NIL ? null : value); + if (eIsCaching()) + { + eSettings[dynamicFeatureID] = value; + } + } + } + + public void dynamicUnset(int dynamicFeatureID) + { + eStore().unset(this, eDynamicFeature(dynamicFeatureID)); + eSettings[dynamicFeatureID] = null; + } + + public Object eDynamicGet(int featureID, boolean resolve, boolean coreType) + { + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + return eSettingDelegate(eFeature).dynamicGet(this, eSettings(), featureID, resolve, coreType); + } + else + { + return super.eDynamicGet(featureID, resolve, coreType); + } + } + + public void eDynamicSet(int featureID, Object newValue) + { + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + eDynamicSet(featureID, eFeature, newValue); + } + else + { + super.eDynamicSet(featureID, newValue); + } + } + + public void eDynamicUnset(int featureID) + { + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + eDynamicUnset(featureID, eFeature); + } + else + { + super.eDynamicUnset(featureID); + } + } + + public boolean eDynamicIsSet(int featureID) + { + if (featureID < eClass().getFeatureCount()) + { + EStructuralFeature eFeature = eClass().getEStructuralFeature(featureID); + return eFeature.isTransient() ? + eSettingDelegate(eFeature).dynamicIsSet(this, eSettings(), featureID) : + eStore().isSet(this, eFeature); + } + else + { + return super.eDynamicIsSet(featureID); + } + } + + /* + public boolean eDynamicIsSet(EStructuralFeature eStructuralFeature) + { + return + eStructuralFeature.isTransient() ? + super.eDynamicIsSet(eStructuralFeature) : + eStore().isSet(this, eStructuralFeature); + } + */ + + protected EList createList(EStructuralFeature eStructuralFeature) + { + return new EStoreEList(this, eStructuralFeature, eStore()); + } + + protected FeatureMap createFeatureMap(EStructuralFeature eStructuralFeature) + { + return new EStoreFeatureMap(this, eStructuralFeature, eStore()); + } + + public EObject eContainer() + { + if (eContainer == EUNINITIALIZED_CONTAINER) + { + eInitializeContainer(); + } + + return eContainer; + } + + public int eContainerFeatureID() + { + if (eContainer == EUNINITIALIZED_CONTAINER) + { + eInitializeContainer(); + } + + return eContainerFeatureID; + } + + protected void eInitializeContainer() + { + eContainer = eStore().getContainer(this); + if (eContainer != null) + { + EStructuralFeature eContainingFeature = eStore().getContainingFeature(this); + if (eContainingFeature instanceof EReference) + { + EReference eContainingReference = (EReference)eContainingFeature; + EReference eOpposite = eContainingReference.getEOpposite(); + if (eOpposite != null) + { + eContainerFeatureID = eClass().getFeatureID(eOpposite); + return; + } + } + + eContainerFeatureID = EOPPOSITE_FEATURE_BASE - eContainer.eClass().getFeatureID(eContainingFeature); + } + } + + public InternalEObject.EStore eStore() + { + return eStore; + } + + public void eSetStore(InternalEObject.EStore store) + { + this.eStore = store; + } + + protected int eStaticFeatureCount() + { + return 0; + } + + public int eDerivedStructuralFeatureID(EStructuralFeature eStructuralFeature) + { + return eClass().getFeatureID(eStructuralFeature); + } + + protected boolean eHasSettings() + { + return eSettings != null; + } + + protected EStructuralFeature.Internal.DynamicValueHolder eSettings() + { + if (eSettings == null) + { + int size = eClass().getFeatureCount() - eStaticFeatureCount(); + eSettings = size == 0 ? ENO_SETTINGS : new Object [size]; + } + + return this; + } + + /** + * + * + * @generated + */ + protected EClass eStaticClass() + { + return SDOPackage.eINSTANCE.getStoreDataObject(); + } + +} //StoreDataObjectImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/BaseDataGraphType.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/BaseDataGraphType.java new file mode 100644 index 0000000000..e57b11474b --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/BaseDataGraphType.java @@ -0,0 +1,213 @@ +/** + * + * 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.ChangeSummary; +import commonj.sdo.Sequence; + +import java.io.Serializable; + +/** + * + * A representation of the model object 'Base Data Graph Type'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.apache.tuscany.sdo.model.BaseDataGraphType#getModels Models}
  • + *
  • {@link org.apache.tuscany.sdo.model.BaseDataGraphType#getXsd Xsd}
  • + *
  • {@link org.apache.tuscany.sdo.model.BaseDataGraphType#getChangeSummary Change Summary}
  • + *
  • {@link org.apache.tuscany.sdo.model.BaseDataGraphType#getAnyAttribute Any Attribute}
  • + *
+ *

+ * + * @extends Serializable + * @generated + */ +public interface BaseDataGraphType extends Serializable +{ + /** + * Returns the value of the 'Models' containment reference. + * + *

+ * If the meaning of the 'Models' containment reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Models' containment reference. + * @see #isSetModels() + * @see #unsetModels() + * @see #setModels(ModelsType) + * @generated + */ + ModelsType getModels(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getModels Models}' containment reference. + * + * + * @param value the new value of the 'Models' containment reference. + * @see #isSetModels() + * @see #unsetModels() + * @see #getModels() + * @generated + */ + void setModels(ModelsType value); + + /** + * Unsets the value of the '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getModels Models}' containment reference. + * + * + * @see #isSetModels() + * @see #getModels() + * @see #setModels(ModelsType) + * @generated + */ + void unsetModels(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getModels Models}' containment reference is set. + * + * + * @return whether the value of the 'Models' containment reference is set. + * @see #unsetModels() + * @see #getModels() + * @see #setModels(ModelsType) + * @generated + */ + boolean isSetModels(); + + /** + * Returns the value of the 'Xsd' containment reference. + * + *

+ * If the meaning of the 'Xsd' containment reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Xsd' containment reference. + * @see #isSetXsd() + * @see #unsetXsd() + * @see #setXsd(XSDType) + * @generated + */ + XSDType getXsd(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getXsd Xsd}' containment reference. + * + * + * @param value the new value of the 'Xsd' containment reference. + * @see #isSetXsd() + * @see #unsetXsd() + * @see #getXsd() + * @generated + */ + void setXsd(XSDType value); + + /** + * Unsets the value of the '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getXsd Xsd}' containment reference. + * + * + * @see #isSetXsd() + * @see #getXsd() + * @see #setXsd(XSDType) + * @generated + */ + void unsetXsd(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getXsd Xsd}' containment reference is set. + * + * + * @return whether the value of the 'Xsd' containment reference is set. + * @see #unsetXsd() + * @see #getXsd() + * @see #setXsd(XSDType) + * @generated + */ + boolean isSetXsd(); + + /** + * Returns the value of the 'Change Summary' attribute. + * + *

+ * If the meaning of the 'Change Summary' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Change Summary' attribute. + * @see #isSetChangeSummary() + * @see #unsetChangeSummary() + * @see #setChangeSummary(ChangeSummary) + * @generated + */ + ChangeSummary getChangeSummary(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getChangeSummary Change Summary}' attribute. + * + * + * @param value the new value of the 'Change Summary' attribute. + * @see #isSetChangeSummary() + * @see #unsetChangeSummary() + * @see #getChangeSummary() + * @generated + */ + void setChangeSummary(ChangeSummary value); + + /** + * Unsets the value of the '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getChangeSummary Change Summary}' attribute. + * + * + * @see #isSetChangeSummary() + * @see #getChangeSummary() + * @see #setChangeSummary(ChangeSummary) + * @generated + */ + void unsetChangeSummary(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.BaseDataGraphType#getChangeSummary Change Summary}' attribute is set. + * + * + * @return whether the value of the 'Change Summary' attribute is set. + * @see #unsetChangeSummary() + * @see #getChangeSummary() + * @see #setChangeSummary(ChangeSummary) + * @generated + */ + boolean isSetChangeSummary(); + + /** + * Returns the value of the 'Any Attribute' attribute list. + * + *

+ * If the meaning of the 'Any Attribute' attribute list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Any Attribute' attribute list. + * @generated + */ + Sequence getAnyAttribute(); + +} // BaseDataGraphType diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/DataGraphType.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/DataGraphType.java new file mode 100644 index 0000000000..2c83244789 --- /dev/null +++ b/sandbox/kgoodson/events/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; + +/** + * + * A representation of the model object 'Data Graph Type'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.apache.tuscany.sdo.model.DataGraphType#getAny Any}
  • + *
+ *

+ * + * @generated + */ +public interface DataGraphType extends BaseDataGraphType +{ + /** + * Returns the value of the 'Any' attribute list. + * + *

+ * If the meaning of the 'Any' attribute list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Any' attribute list. + * @generated + */ + Sequence getAny(); + +} // DataGraphType diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/DataObject.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/DataObject.java new file mode 100644 index 0000000000..9e3b2a1386 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/DataObject.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.model; + +import java.io.Serializable; + +/** + * + * A representation of the model object 'Data Object'. + * + * + * + * @extends Serializable + * @generated + */ +public interface DataObject extends Serializable +{ +} // DataObject diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/ModelFactory.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/ModelFactory.java new file mode 100644 index 0000000000..c8fe69167e --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/ModelFactory.java @@ -0,0 +1,106 @@ +/** + * + * 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.helper.HelperContext; + + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @generated + */ +public interface ModelFactory +{ + + /** + * The singleton instance of the factory. + * + * + * @generated + */ + ModelFactory INSTANCE = org.apache.tuscany.sdo.model.impl.ModelFactoryImpl.init(); + + /** + * Returns a new object of class 'Data Graph Type'. + * + * + * @return a new object of class 'Data Graph Type'. + * @generated + */ + DataGraphType createDataGraphType(); + + /** + * Returns a new object of class 'Models Type'. + * + * + * @return a new object of class 'Models Type'. + * @generated + */ + ModelsType createModelsType(); + + /** + * Returns a new object of class 'Property'. + * + * + * @return a new object of class 'Property'. + * @generated + */ + Property createProperty(); + + /** + * Returns a new object of class 'Type'. + * + * + * @return a new object of class 'Type'. + * @generated + */ + Type createType(); + + /** + * Returns a new object of class 'Types'. + * + * + * @return a new object of class 'Types'. + * @generated + */ + Types createTypes(); + + /** + * Returns a new object of class 'XSD Type'. + * + * + * @return a new object of class 'XSD Type'. + * @generated + */ + XSDType createXSDType(); + + /** + * Registers the types supported by this Factory within the supplied scope.argument + * + * + * @param scope an instance of HelperContext used to manage the scoping of types. + * @generated + */ + public void register(HelperContext scope); + +} //ModelFactory diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/ModelsType.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/ModelsType.java new file mode 100644 index 0000000000..4159ac9dc1 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/ModelsType.java @@ -0,0 +1,62 @@ +/** + * + * 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.io.Serializable; + +/** + * + * A representation of the model object 'Models Type'. + * + * + * + * + * Expected type is emof:Package. + * + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.apache.tuscany.sdo.model.ModelsType#getAny Any}
  • + *
+ *

+ * + * @extends Serializable + * @generated + */ +public interface ModelsType extends Serializable +{ + /** + * Returns the value of the 'Any' attribute list. + * + *

+ * If the meaning of the 'Any' attribute list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Any' attribute list. + * @generated + */ + Sequence getAny(); + +} // ModelsType diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/Property.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/Property.java new file mode 100644 index 0000000000..15ee4c2f99 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/Property.java @@ -0,0 +1,503 @@ +/** + * + * 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.io.Serializable; + +import java.util.List; + +/** + * + * A representation of the model object 'Property'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.apache.tuscany.sdo.model.Property#getAliasName Alias Name}
  • + *
  • {@link org.apache.tuscany.sdo.model.Property#getAny Any}
  • + *
  • {@link org.apache.tuscany.sdo.model.Property#getName Name}
  • + *
  • {@link org.apache.tuscany.sdo.model.Property#isMany Many}
  • + *
  • {@link org.apache.tuscany.sdo.model.Property#isContainment Containment}
  • + *
  • {@link org.apache.tuscany.sdo.model.Property#getDefault Default}
  • + *
  • {@link org.apache.tuscany.sdo.model.Property#isReadOnly Read Only}
  • + *
  • {@link org.apache.tuscany.sdo.model.Property#getType_ Type}
  • + *
  • {@link org.apache.tuscany.sdo.model.Property#getOpposite Opposite}
  • + *
  • {@link org.apache.tuscany.sdo.model.Property#isNullable Nullable}
  • + *
  • {@link org.apache.tuscany.sdo.model.Property#getAnyAttribute Any Attribute}
  • + *
+ *

+ * + * @extends Serializable + * @generated + */ +public interface Property extends Serializable +{ + /** + * Returns the value of the 'Alias Name' attribute list. + * The list contents are of type {@link java.lang.String}. + * + *

+ * If the meaning of the 'Alias Name' attribute list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Alias Name' attribute list. + * @generated + */ + List getAliasName(); + + /** + * Returns the value of the 'Any' attribute list. + * + *

+ * If the meaning of the 'Any' attribute list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Any' attribute list. + * @generated + */ + Sequence getAny(); + + /** + * Returns the value of the 'Name' attribute. + * + *

+ * If the meaning of the 'Name' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Name' attribute. + * @see #isSetName() + * @see #unsetName() + * @see #setName(String) + * @generated + */ + String getName(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Property#getName Name}' attribute. + * + * + * @param value the new value of the 'Name' attribute. + * @see #isSetName() + * @see #unsetName() + * @see #getName() + * @generated + */ + void setName(String value); + + /** + * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Property#getName Name}' attribute. + * + * + * @see #isSetName() + * @see #getName() + * @see #setName(String) + * @generated + */ + void unsetName(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Property#getName Name}' attribute is set. + * + * + * @return whether the value of the 'Name' attribute is set. + * @see #unsetName() + * @see #getName() + * @see #setName(String) + * @generated + */ + boolean isSetName(); + + /** + * Returns the value of the 'Many' attribute. + * + *

+ * If the meaning of the 'Many' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Many' attribute. + * @see #isSetMany() + * @see #unsetMany() + * @see #setMany(boolean) + * @generated + */ + boolean isMany(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Property#isMany Many}' attribute. + * + * + * @param value the new value of the 'Many' 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 Many}' attribute. + * + * + * @see #isSetMany() + * @see #isMany() + * @see #setMany(boolean) + * @generated + */ + void unsetMany(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Property#isMany Many}' attribute is set. + * + * + * @return whether the value of the 'Many' attribute is set. + * @see #unsetMany() + * @see #isMany() + * @see #setMany(boolean) + * @generated + */ + boolean isSetMany(); + + /** + * Returns the value of the 'Containment' attribute. + * + *

+ * If the meaning of the 'Containment' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Containment' attribute. + * @see #isSetContainment() + * @see #unsetContainment() + * @see #setContainment(boolean) + * @generated + */ + boolean isContainment(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Property#isContainment Containment}' attribute. + * + * + * @param value the new value of the 'Containment' 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 Containment}' attribute. + * + * + * @see #isSetContainment() + * @see #isContainment() + * @see #setContainment(boolean) + * @generated + */ + void unsetContainment(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Property#isContainment Containment}' attribute is set. + * + * + * @return whether the value of the 'Containment' attribute is set. + * @see #unsetContainment() + * @see #isContainment() + * @see #setContainment(boolean) + * @generated + */ + boolean isSetContainment(); + + /** + * Returns the value of the 'Default' attribute. + * + *

+ * If the meaning of the 'Default' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Default' attribute. + * @see #isSetDefault() + * @see #unsetDefault() + * @see #setDefault_(String) + * @generated + */ + String getDefault_(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Property#getDefault Default}' attribute. + * + * + * @param value the new value of the 'Default' attribute. + * @see #isSetDefault() + * @see #unsetDefault() + * @see #getDefault_() + * @generated + */ + void setDefault_(String value); + + /** + * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Property#getDefault Default}' attribute. + * + * + * @see #isSetDefault() + * @see #getDefault_() + * @see #setDefault_(String) + * @generated + */ + void unsetDefault(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Property#getDefault Default}' attribute is set. + * + * + * @return whether the value of the 'Default' attribute is set. + * @see #unsetDefault() + * @see #getDefault_() + * @see #setDefault_(String) + * @generated + */ + boolean isSetDefault(); + + /** + * Returns the value of the 'Read Only' attribute. + * + *

+ * If the meaning of the 'Read Only' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Read Only' attribute. + * @see #isSetReadOnly() + * @see #unsetReadOnly() + * @see #setReadOnly(boolean) + * @generated + */ + boolean isReadOnly(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Property#isReadOnly Read Only}' attribute. + * + * + * @param value the new value of the 'Read Only' 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 Read Only}' attribute. + * + * + * @see #isSetReadOnly() + * @see #isReadOnly() + * @see #setReadOnly(boolean) + * @generated + */ + void unsetReadOnly(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Property#isReadOnly Read Only}' attribute is set. + * + * + * @return whether the value of the 'Read Only' attribute is set. + * @see #unsetReadOnly() + * @see #isReadOnly() + * @see #setReadOnly(boolean) + * @generated + */ + boolean isSetReadOnly(); + + /** + * Returns the value of the 'Type' reference. + * + *

+ * If the meaning of the 'Type' reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Type' reference. + * @see #isSetType() + * @see #unsetType() + * @see #setType(Type) + * @generated + */ + Type getType_(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Property#getType_ Type}' reference. + * + * + * @param value the new value of the 'Type' reference. + * @see #isSetType() + * @see #unsetType() + * @see #getType_() + * @generated + */ + void setType(Type value); + + /** + * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Property#getType_ Type}' reference. + * + * + * @see #isSetType() + * @see #getType_() + * @see #setType(Type) + * @generated + */ + void unsetType(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Property#getType_ Type}' reference is set. + * + * + * @return whether the value of the 'Type' reference is set. + * @see #unsetType() + * @see #getType_() + * @see #setType(Type) + * @generated + */ + boolean isSetType(); + + /** + * Returns the value of the 'Opposite' reference. + * + *

+ * If the meaning of the 'Opposite' reference isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Opposite' reference. + * @see #isSetOpposite() + * @see #unsetOpposite() + * @see #setOpposite_(Property) + * @generated + */ + Property getOpposite_(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Property#getOpposite Opposite}' reference. + * + * + * @param value the new value of the 'Opposite' reference. + * @see #isSetOpposite() + * @see #unsetOpposite() + * @see #getOpposite_() + * @generated + */ + void setOpposite_(Property value); + + /** + * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Property#getOpposite Opposite}' reference. + * + * + * @see #isSetOpposite() + * @see #getOpposite_() + * @see #setOpposite_(Property) + * @generated + */ + void unsetOpposite(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Property#getOpposite Opposite}' reference is set. + * + * + * @return whether the value of the 'Opposite' reference is set. + * @see #unsetOpposite() + * @see #getOpposite_() + * @see #setOpposite_(Property) + * @generated + */ + boolean isSetOpposite(); + + /** + * Returns the value of the 'Nullable' attribute. + * + *

+ * If the meaning of the 'Nullable' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Nullable' attribute. + * @see #isSetNullable() + * @see #unsetNullable() + * @see #setNullable(boolean) + * @generated + */ + boolean isNullable(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Property#isNullable Nullable}' attribute. + * + * + * @param value the new value of the 'Nullable' attribute. + * @see #isSetNullable() + * @see #unsetNullable() + * @see #isNullable() + * @generated + */ + void setNullable(boolean value); + + /** + * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Property#isNullable Nullable}' attribute. + * + * + * @see #isSetNullable() + * @see #isNullable() + * @see #setNullable(boolean) + * @generated + */ + void unsetNullable(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Property#isNullable Nullable}' attribute is set. + * + * + * @return whether the value of the 'Nullable' attribute is set. + * @see #unsetNullable() + * @see #isNullable() + * @see #setNullable(boolean) + * @generated + */ + boolean isSetNullable(); + + /** + * Returns the value of the 'Any Attribute' attribute list. + * + *

+ * If the meaning of the 'Any Attribute' attribute list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Any Attribute' attribute list. + * @generated + */ + Sequence getAnyAttribute(); + +} // Property diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/TextType.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/TextType.java new file mode 100644 index 0000000000..741343e5a8 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/TextType.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; + +import java.io.Serializable; + +import java.util.List; + +/** + * + * A representation of the model object 'Text Type'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.apache.tuscany.sdo.model.TextType#getText Text}
  • + *
+ *

+ * + * @extends Serializable + * @generated + */ +public interface TextType extends Serializable +{ + /** + * Returns the value of the 'Text' attribute list. + * The list contents are of type {@link java.lang.String}. + * + *

+ * If the meaning of the 'Text' attribute list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Text' attribute list. + * @generated + */ + List getText(); + +} // TextType diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/Type.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/Type.java new file mode 100644 index 0000000000..26a02f7cc0 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/Type.java @@ -0,0 +1,431 @@ +/** + * + * 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.io.Serializable; + +import java.util.List; + +/** + * + * A representation of the model object 'Type'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.apache.tuscany.sdo.model.Type#getBaseType Base Type}
  • + *
  • {@link org.apache.tuscany.sdo.model.Type#getProperty Property}
  • + *
  • {@link org.apache.tuscany.sdo.model.Type#getAliasName Alias Name}
  • + *
  • {@link org.apache.tuscany.sdo.model.Type#getAny Any}
  • + *
  • {@link org.apache.tuscany.sdo.model.Type#getName Name}
  • + *
  • {@link org.apache.tuscany.sdo.model.Type#getUri Uri}
  • + *
  • {@link org.apache.tuscany.sdo.model.Type#isDataType Data Type}
  • + *
  • {@link org.apache.tuscany.sdo.model.Type#isOpen Open}
  • + *
  • {@link org.apache.tuscany.sdo.model.Type#isSequenced Sequenced}
  • + *
  • {@link org.apache.tuscany.sdo.model.Type#isAbstract Abstract}
  • + *
  • {@link org.apache.tuscany.sdo.model.Type#getAnyAttribute Any Attribute}
  • + *
+ *

+ * + * @extends Serializable + * @generated + */ +public interface Type extends Serializable +{ + /** + * Returns the value of the 'Base Type' reference list. + * The list contents are of type {@link org.apache.tuscany.sdo.model.Type}. + * + *

+ * If the meaning of the 'Base Type' reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Base Type' reference list. + * @generated + */ + List getBaseType(); + + /** + * Returns the value of the 'Property' containment reference list. + * The list contents are of type {@link org.apache.tuscany.sdo.model.Property}. + * + *

+ * If the meaning of the 'Property' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Property' containment reference list. + * @generated + */ + List getProperty(); + + /** + * Returns the value of the 'Alias Name' attribute list. + * The list contents are of type {@link java.lang.String}. + * + *

+ * If the meaning of the 'Alias Name' attribute list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Alias Name' attribute list. + * @generated + */ + List getAliasName(); + + /** + * Returns the value of the 'Any' attribute list. + * + *

+ * If the meaning of the 'Any' attribute list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Any' attribute list. + * @generated + */ + Sequence getAny(); + + /** + * Returns the value of the 'Name' attribute. + * + *

+ * If the meaning of the 'Name' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Name' attribute. + * @see #isSetName() + * @see #unsetName() + * @see #setName(String) + * @generated + */ + String getName(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Type#getName Name}' attribute. + * + * + * @param value the new value of the 'Name' attribute. + * @see #isSetName() + * @see #unsetName() + * @see #getName() + * @generated + */ + void setName(String value); + + /** + * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Type#getName Name}' attribute. + * + * + * @see #isSetName() + * @see #getName() + * @see #setName(String) + * @generated + */ + void unsetName(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Type#getName Name}' attribute is set. + * + * + * @return whether the value of the 'Name' attribute is set. + * @see #unsetName() + * @see #getName() + * @see #setName(String) + * @generated + */ + boolean isSetName(); + + /** + * Returns the value of the 'Uri' attribute. + * + *

+ * If the meaning of the 'Uri' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Uri' attribute. + * @see #isSetUri() + * @see #unsetUri() + * @see #setUri(String) + * @generated + */ + String getUri(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Type#getUri Uri}' attribute. + * + * + * @param value the new value of the 'Uri' attribute. + * @see #isSetUri() + * @see #unsetUri() + * @see #getUri() + * @generated + */ + void setUri(String value); + + /** + * Unsets the value of the '{@link org.apache.tuscany.sdo.model.Type#getUri Uri}' attribute. + * + * + * @see #isSetUri() + * @see #getUri() + * @see #setUri(String) + * @generated + */ + void unsetUri(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Type#getUri Uri}' attribute is set. + * + * + * @return whether the value of the 'Uri' attribute is set. + * @see #unsetUri() + * @see #getUri() + * @see #setUri(String) + * @generated + */ + boolean isSetUri(); + + /** + * Returns the value of the 'Data Type' attribute. + * + *

+ * If the meaning of the 'Data Type' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Data Type' attribute. + * @see #isSetDataType() + * @see #unsetDataType() + * @see #setDataType(boolean) + * @generated + */ + boolean isDataType(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Type#isDataType Data Type}' attribute. + * + * + * @param value the new value of the 'Data Type' 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 Data Type}' attribute. + * + * + * @see #isSetDataType() + * @see #isDataType() + * @see #setDataType(boolean) + * @generated + */ + void unsetDataType(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Type#isDataType Data Type}' attribute is set. + * + * + * @return whether the value of the 'Data Type' attribute is set. + * @see #unsetDataType() + * @see #isDataType() + * @see #setDataType(boolean) + * @generated + */ + boolean isSetDataType(); + + /** + * Returns the value of the 'Open' attribute. + * + *

+ * If the meaning of the 'Open' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Open' attribute. + * @see #isSetOpen() + * @see #unsetOpen() + * @see #setOpen(boolean) + * @generated + */ + boolean isOpen(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Type#isOpen Open}' attribute. + * + * + * @param value the new value of the 'Open' 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 Open}' attribute. + * + * + * @see #isSetOpen() + * @see #isOpen() + * @see #setOpen(boolean) + * @generated + */ + void unsetOpen(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Type#isOpen Open}' attribute is set. + * + * + * @return whether the value of the 'Open' attribute is set. + * @see #unsetOpen() + * @see #isOpen() + * @see #setOpen(boolean) + * @generated + */ + boolean isSetOpen(); + + /** + * Returns the value of the 'Sequenced' attribute. + * + *

+ * If the meaning of the 'Sequenced' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Sequenced' attribute. + * @see #isSetSequenced() + * @see #unsetSequenced() + * @see #setSequenced(boolean) + * @generated + */ + boolean isSequenced(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Type#isSequenced Sequenced}' attribute. + * + * + * @param value the new value of the 'Sequenced' 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 Sequenced}' attribute. + * + * + * @see #isSetSequenced() + * @see #isSequenced() + * @see #setSequenced(boolean) + * @generated + */ + void unsetSequenced(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Type#isSequenced Sequenced}' attribute is set. + * + * + * @return whether the value of the 'Sequenced' attribute is set. + * @see #unsetSequenced() + * @see #isSequenced() + * @see #setSequenced(boolean) + * @generated + */ + boolean isSetSequenced(); + + /** + * Returns the value of the 'Abstract' attribute. + * + *

+ * If the meaning of the 'Abstract' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Abstract' attribute. + * @see #isSetAbstract() + * @see #unsetAbstract() + * @see #setAbstract(boolean) + * @generated + */ + boolean isAbstract(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.Type#isAbstract Abstract}' attribute. + * + * + * @param value the new value of the 'Abstract' 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 Abstract}' attribute. + * + * + * @see #isSetAbstract() + * @see #isAbstract() + * @see #setAbstract(boolean) + * @generated + */ + void unsetAbstract(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.Type#isAbstract Abstract}' attribute is set. + * + * + * @return whether the value of the 'Abstract' attribute is set. + * @see #unsetAbstract() + * @see #isAbstract() + * @see #setAbstract(boolean) + * @generated + */ + boolean isSetAbstract(); + + /** + * Returns the value of the 'Any Attribute' attribute list. + * + *

+ * If the meaning of the 'Any Attribute' attribute list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Any Attribute' attribute list. + * @generated + */ + Sequence getAnyAttribute(); + + String getInstanceClassName(); + +} // Type diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/Types.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/Types.java new file mode 100644 index 0000000000..26fb9c57ce --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/Types.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 java.io.Serializable; + +import java.util.List; + +/** + * + * A representation of the model object 'Types'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.apache.tuscany.sdo.model.Types#getType_ Type}
  • + *
+ *

+ * + * @extends Serializable + * @generated + */ +public interface Types extends Serializable +{ + /** + * Returns the value of the 'Type' containment reference list. + * The list contents are of type {@link org.apache.tuscany.sdo.model.Type}. + * + *

+ * If the meaning of the 'Type' containment reference list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Type' containment reference list. + * @generated + */ + List getType_(); + + List getTypeList(); + +} // Types diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/XSDType.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/XSDType.java new file mode 100644 index 0000000000..32cde02086 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/XSDType.java @@ -0,0 +1,62 @@ +/** + * + * 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.io.Serializable; + +/** + * + * A representation of the model object 'XSD Type'. + * + * + * + * + * Expected type is xsd:schema. + * + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.apache.tuscany.sdo.model.XSDType#getAny Any}
  • + *
+ *

+ * + * @extends Serializable + * @generated + */ +public interface XSDType extends Serializable +{ + /** + * Returns the value of the 'Any' attribute list. + * + *

+ * If the meaning of the 'Any' attribute list isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Any' attribute list. + * @generated + */ + Sequence getAny(); + +} // XSDType diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/BaseDataGraphTypeImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/BaseDataGraphTypeImpl.java new file mode 100644 index 0000000000..e8824974a0 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/BaseDataGraphTypeImpl.java @@ -0,0 +1,625 @@ +/** + * + * 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.ChangeSummary; +import commonj.sdo.Sequence; +import commonj.sdo.Type; + +import org.apache.tuscany.sdo.impl.DataObjectBase; + +import org.apache.tuscany.sdo.model.BaseDataGraphType; +import org.apache.tuscany.sdo.model.ModelFactory; +import org.apache.tuscany.sdo.model.ModelsType; +import org.apache.tuscany.sdo.model.XSDType; + +/** + * + * An implementation of the model object 'Base Data Graph Type'. + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.apache.tuscany.sdo.model.impl.BaseDataGraphTypeImpl#getModels Models}
  • + *
  • {@link org.apache.tuscany.sdo.model.impl.BaseDataGraphTypeImpl#getXsd Xsd}
  • + *
  • {@link org.apache.tuscany.sdo.model.impl.BaseDataGraphTypeImpl#getChangeSummary Change Summary}
  • + *
  • {@link org.apache.tuscany.sdo.model.impl.BaseDataGraphTypeImpl#getAnyAttribute Any Attribute}
  • + *
+ *

+ * + * @generated + */ +public abstract class BaseDataGraphTypeImpl extends DataObjectBase implements BaseDataGraphType +{ + + public final static int MODELS = 0; + + public final static int XSD = 1; + + public final static int CHANGE_SUMMARY = 2; + + public final static int ANY_ATTRIBUTE = -1; + + public final static int SDO_PROPERTY_COUNT = 3; + + public final static int EXTENDED_PROPERTY_COUNT = -1; + + + /** + * The internal feature id for the 'Models' containment reference. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_MODELS = 0; + + /** + * The internal feature id for the 'Xsd' containment reference. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_XSD = 1; + + /** + * The internal feature id for the 'Change Summary' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_CHANGE_SUMMARY = 2; + + /** + * The internal feature id for the 'Any Attribute' attribute list. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_ANY_ATTRIBUTE = 3; + + /** + * The number of properties for this type. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_PROPERTY_COUNT = 4; + + protected int internalConvertIndex(int internalIndex) + { + switch (internalIndex) + { + case INTERNAL_MODELS: return MODELS; + case INTERNAL_XSD: return XSD; + case INTERNAL_CHANGE_SUMMARY: return CHANGE_SUMMARY; + case INTERNAL_ANY_ATTRIBUTE: return ANY_ATTRIBUTE; + } + return super.internalConvertIndex(internalIndex); + } + + + /** + * The cached value of the '{@link #getModels() Models}' containment reference. + * + * + * @see #getModels() + * @generated + * @ordered + */ + + protected ModelsType models = null; + + /** + * This is true if the Models containment reference has been set. + * + * + * @generated + * @ordered + */ + protected boolean models_set_ = false; + + /** + * The cached value of the '{@link #getXsd() Xsd}' containment reference. + * + * + * @see #getXsd() + * @generated + * @ordered + */ + + protected XSDType xsd = null; + + /** + * This is true if the Xsd containment reference has been set. + * + * + * @generated + * @ordered + */ + protected boolean xsd_set_ = false; + + /** + * The default value of the '{@link #getChangeSummary() Change Summary}' attribute. + * + * + * @see #getChangeSummary() + * @generated + * @ordered + */ + protected static final ChangeSummary CHANGE_SUMMARY_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getChangeSummary() Change Summary}' attribute. + * + * + * @see #getChangeSummary() + * @generated + * @ordered + */ + protected ChangeSummary changeSummary = CHANGE_SUMMARY_DEFAULT_; + + /** + * This is true if the Change Summary attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean changeSummary_set_ = false; + + /** + * The cached value of the '{@link #getAnyAttribute() Any Attribute}' attribute list. + * + * + * @see #getAnyAttribute() + * @generated + * @ordered + */ + + protected Sequence anyAttribute = null; + + /** + * + * + * @generated + */ + public BaseDataGraphTypeImpl() + { + super(); + createChangeSummary(CHANGE_SUMMARY); + } + + /** + * + * + * @generated + */ + public Type getStaticType() + { + return ((ModelFactoryImpl)ModelFactory.INSTANCE).getBaseDataGraphType(); + } + + /** + * + * + * @generated + */ + public ModelsType getModels() + { + return models; + } + /** + * + * + * @generated + */ + public ChangeContext basicSetModels(ModelsType newModels, ChangeContext changeContext) + { + ModelsType oldModels = models; + models = newModels; + boolean oldModels_set_ = models_set_; + models_set_ = true; + if (isNotifying()) + { + addNotification(this, ChangeKind.SET, INTERNAL_MODELS, oldModels, newModels, !oldModels_set_, changeContext); + } + return changeContext; + } + + /** + * + * + * @generated + */ + public void setModels(ModelsType newModels) + { + if (newModels != models) + { + ChangeContext changeContext = null; + if (models != null) + changeContext = inverseRemove(models, this, OPPOSITE_FEATURE_BASE - INTERNAL_MODELS, null, changeContext); + if (newModels != null) + changeContext = inverseAdd(newModels, this, OPPOSITE_FEATURE_BASE - INTERNAL_MODELS, null, changeContext); + changeContext = basicSetModels(newModels, changeContext); + if (changeContext != null) dispatch(changeContext); + } + else + { + boolean oldModels_set_ = models_set_; + models_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INTERNAL_MODELS, newModels, newModels, !oldModels_set_); + } + } + + /** + * + * + * @generated + */ + public ChangeContext basicUnsetModels(ChangeContext changeContext) + { + ModelsType oldModels = models; + models = null; + boolean oldModels_set_ = models_set_; + models_set_ = false; + if (isNotifying()) + { + addNotification(this, ChangeKind.UNSET, INTERNAL_MODELS, oldModels, null, !oldModels_set_, changeContext); + } + return changeContext; + } + + /** + * + * + * @generated + */ + public void unsetModels() + { + if (models != null) + { + ChangeContext changeContext = null; + changeContext = inverseRemove(models, this, EOPPOSITE_FEATURE_BASE - INTERNAL_MODELS, null, changeContext); + changeContext = basicUnsetModels(changeContext); + if (changeContext != null) dispatch(changeContext); + } + else + { + boolean oldModels_set_ = models_set_; + models_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INTERNAL_MODELS, null, null, oldModels_set_); + } + } + + /** + * + * + * @generated + */ + public boolean isSetModels() + { + return models_set_; + } + + /** + * + * + * @generated + */ + public XSDType getXsd() + { + return xsd; + } + /** + * + * + * @generated + */ + public ChangeContext basicSetXsd(XSDType newXsd, ChangeContext changeContext) + { + XSDType oldXsd = xsd; + xsd = newXsd; + boolean oldXsd_set_ = xsd_set_; + xsd_set_ = true; + if (isNotifying()) + { + addNotification(this, ChangeKind.SET, INTERNAL_XSD, oldXsd, newXsd, !oldXsd_set_, changeContext); + } + return changeContext; + } + + /** + * + * + * @generated + */ + public void setXsd(XSDType newXsd) + { + if (newXsd != xsd) + { + ChangeContext changeContext = null; + if (xsd != null) + changeContext = inverseRemove(xsd, this, OPPOSITE_FEATURE_BASE - INTERNAL_XSD, null, changeContext); + if (newXsd != null) + changeContext = inverseAdd(newXsd, this, OPPOSITE_FEATURE_BASE - INTERNAL_XSD, null, changeContext); + changeContext = basicSetXsd(newXsd, changeContext); + if (changeContext != null) dispatch(changeContext); + } + else + { + boolean oldXsd_set_ = xsd_set_; + xsd_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INTERNAL_XSD, newXsd, newXsd, !oldXsd_set_); + } + } + + /** + * + * + * @generated + */ + public ChangeContext basicUnsetXsd(ChangeContext changeContext) + { + XSDType oldXsd = xsd; + xsd = null; + boolean oldXsd_set_ = xsd_set_; + xsd_set_ = false; + if (isNotifying()) + { + addNotification(this, ChangeKind.UNSET, INTERNAL_XSD, oldXsd, null, !oldXsd_set_, changeContext); + } + return changeContext; + } + + /** + * + * + * @generated + */ + public void unsetXsd() + { + if (xsd != null) + { + ChangeContext changeContext = null; + changeContext = inverseRemove(xsd, this, EOPPOSITE_FEATURE_BASE - INTERNAL_XSD, null, changeContext); + changeContext = basicUnsetXsd(changeContext); + if (changeContext != null) dispatch(changeContext); + } + else + { + boolean oldXsd_set_ = xsd_set_; + xsd_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INTERNAL_XSD, null, null, oldXsd_set_); + } + } + + /** + * + * + * @generated + */ + public boolean isSetXsd() + { + return xsd_set_; + } + + /** + * + * + * @generated + */ + public ChangeSummary getChangeSummary() + { + return changeSummary; + } + /** + * + * + * @generated + */ + public void setChangeSummary(ChangeSummary newChangeSummary) + { + ChangeSummary oldChangeSummary = changeSummary; + changeSummary = newChangeSummary; + boolean oldChangeSummary_set_ = changeSummary_set_; + changeSummary_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INTERNAL_CHANGE_SUMMARY, oldChangeSummary, changeSummary, !oldChangeSummary_set_); + } + + /** + * + * + * @generated + */ + public void unsetChangeSummary() + { + ChangeSummary oldChangeSummary = changeSummary; + boolean oldChangeSummary_set_ = changeSummary_set_; + changeSummary = CHANGE_SUMMARY_DEFAULT_; + changeSummary_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INTERNAL_CHANGE_SUMMARY, oldChangeSummary, CHANGE_SUMMARY_DEFAULT_, oldChangeSummary_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetChangeSummary() + { + return changeSummary_set_; + } + + /** + * + * + * @generated + */ + public Sequence getAnyAttribute() + { + if (anyAttribute == null) + { + anyAttribute = createSequence(INTERNAL_ANY_ATTRIBUTE); + } + return anyAttribute; + } + /** + * + * + * @generated + */ + public ChangeContext inverseRemove(Object otherEnd, int propertyIndex, ChangeContext changeContext) + { + switch (propertyIndex) + { + case MODELS: + return basicUnsetModels(changeContext); + case XSD: + return basicUnsetXsd(changeContext); + case ANY_ATTRIBUTE: + return removeFromSequence(getAnyAttribute(), otherEnd, changeContext); + } + return super.inverseRemove(otherEnd, propertyIndex, changeContext); + } + + /** + * + * + * @generated + */ + public Object get(int propertyIndex, boolean resolve) + { + switch (propertyIndex) + { + case MODELS: + return getModels(); + case XSD: + return getXsd(); + case CHANGE_SUMMARY: + return getChangeSummary(); + case ANY_ATTRIBUTE: + // XXX query introduce coreType as an argument? -- semantic = if true -- coreType - return the core EMF object if value is a non-EMF wrapper/view + //if (coreType) + return getAnyAttribute(); + } + return super.get(propertyIndex, resolve); + } + + /** + * + * + * @generated + */ + public void set(int propertyIndex, Object newValue) + { + switch (propertyIndex) + { + case MODELS: + setModels((ModelsType)newValue); + return; + case XSD: + setXsd((XSDType)newValue); + return; + case CHANGE_SUMMARY: + setChangeSummary((ChangeSummary)newValue); + return; + case ANY_ATTRIBUTE: + setSequence(getAnyAttribute(), newValue); + return; + } + super.set(propertyIndex, newValue); + } + + /** + * + * + * @generated + */ + public void unset(int propertyIndex) + { + switch (propertyIndex) + { + case MODELS: + unsetModels(); + return; + case XSD: + unsetXsd(); + return; + case CHANGE_SUMMARY: + unsetChangeSummary(); + return; + case ANY_ATTRIBUTE: + unsetSequence(getAnyAttribute()); + return; + } + super.unset(propertyIndex); + } + + /** + * + * + * @generated + */ + public boolean isSet(int propertyIndex) + { + switch (propertyIndex) + { + case MODELS: + return isSetModels(); + case XSD: + return isSetXsd(); + case CHANGE_SUMMARY: + return isSetChangeSummary(); + case ANY_ATTRIBUTE: + return anyAttribute != null && !isSequenceEmpty(getAnyAttribute()); + } + return super.isSet(propertyIndex); + } + + /** + * + * + * @generated + */ + public String toString() + { + if (isProxy(this)) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (changeSummary: "); + if (changeSummary_set_) result.append(changeSummary); else result.append(""); + result.append(", anyAttribute: "); + result.append(anyAttribute); + result.append(')'); + return result.toString(); + } + +} //BaseDataGraphTypeImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/DataGraphTypeImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/DataGraphTypeImpl.java new file mode 100644 index 0000000000..ef13797850 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/DataGraphTypeImpl.java @@ -0,0 +1,258 @@ +/** + * + * 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 commonj.sdo.Type; + +import org.apache.tuscany.sdo.model.DataGraphType; +import org.apache.tuscany.sdo.model.ModelFactory; + +/** + * + * An implementation of the model object 'Data Graph Type'. + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.apache.tuscany.sdo.model.impl.DataGraphTypeImpl#getAny Any}
  • + *
+ *

+ * + * @generated + */ +public class DataGraphTypeImpl extends BaseDataGraphTypeImpl implements DataGraphType +{ + + public final static int ANY = BaseDataGraphTypeImpl.EXTENDED_PROPERTY_COUNT + -1; + + public final static int SDO_PROPERTY_COUNT = BaseDataGraphTypeImpl.SDO_PROPERTY_COUNT + 0; + + public final static int EXTENDED_PROPERTY_COUNT = BaseDataGraphTypeImpl.EXTENDED_PROPERTY_COUNT - 1; + + + /** + * The internal feature id for the 'Models' containment reference. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_MODELS = BaseDataGraphTypeImpl.INTERNAL_MODELS; + + /** + * The internal feature id for the 'Xsd' containment reference. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_XSD = BaseDataGraphTypeImpl.INTERNAL_XSD; + + /** + * The internal feature id for the 'Change Summary' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_CHANGE_SUMMARY = BaseDataGraphTypeImpl.INTERNAL_CHANGE_SUMMARY; + + /** + * The internal feature id for the 'Any Attribute' attribute list. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_ANY_ATTRIBUTE = BaseDataGraphTypeImpl.INTERNAL_ANY_ATTRIBUTE; + + /** + * The internal feature id for the 'Any' attribute list. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_ANY = BaseDataGraphTypeImpl.INTERNAL_PROPERTY_COUNT + 0; + + /** + * The number of properties for this type. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_PROPERTY_COUNT = BaseDataGraphTypeImpl.INTERNAL_PROPERTY_COUNT + 1; + + protected int internalConvertIndex(int internalIndex) + { + switch (internalIndex) + { + case INTERNAL_MODELS: return MODELS; + case INTERNAL_XSD: return XSD; + case INTERNAL_CHANGE_SUMMARY: return CHANGE_SUMMARY; + case INTERNAL_ANY_ATTRIBUTE: return ANY_ATTRIBUTE; + case INTERNAL_ANY: return ANY; + } + return super.internalConvertIndex(internalIndex); + } + + + /** + * The cached value of the '{@link #getAny() Any}' attribute list. + * + * + * @see #getAny() + * @generated + * @ordered + */ + + protected Sequence any = null; + + /** + * + * + * @generated + */ + public DataGraphTypeImpl() + { + super(); + } + + /** + * + * + * @generated + */ + public Type getStaticType() + { + return ((ModelFactoryImpl)ModelFactory.INSTANCE).getDataGraphType(); + } + + /** + * + * + * @generated + */ + public Sequence getAny() + { + if (any == null) + { + any = createSequence(INTERNAL_ANY); + } + return any; + } + /** + * + * + * @generated + */ + public ChangeContext inverseRemove(Object otherEnd, int propertyIndex, ChangeContext changeContext) + { + switch (propertyIndex) + { + case ANY: + return removeFromSequence(getAny(), otherEnd, changeContext); + } + return super.inverseRemove(otherEnd, propertyIndex, changeContext); + } + + /** + * + * + * @generated + */ + public Object get(int propertyIndex, boolean resolve) + { + switch (propertyIndex) + { + case ANY: + // XXX query introduce coreType as an argument? -- semantic = if true -- coreType - return the core EMF object if value is a non-EMF wrapper/view + //if (coreType) + return getAny(); + } + return super.get(propertyIndex, resolve); + } + + /** + * + * + * @generated + */ + public void set(int propertyIndex, Object newValue) + { + switch (propertyIndex) + { + case ANY: + setSequence(getAny(), newValue); + return; + } + super.set(propertyIndex, newValue); + } + + /** + * + * + * @generated + */ + public void unset(int propertyIndex) + { + switch (propertyIndex) + { + case ANY: + unsetSequence(getAny()); + return; + } + super.unset(propertyIndex); + } + + /** + * + * + * @generated + */ + public boolean isSet(int propertyIndex) + { + switch (propertyIndex) + { + case ANY: + return any != null && !isSequenceEmpty(getAny()); + } + return super.isSet(propertyIndex); + } + + /** + * + * + * @generated + */ + public String toString() + { + if (isProxy(this)) 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/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/DataObjectImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/DataObjectImpl.java new file mode 100644 index 0000000000..0dc673907c --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/DataObjectImpl.java @@ -0,0 +1,84 @@ +/** + * + * 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.Type; + +import org.apache.tuscany.sdo.impl.DataObjectBase; + +import org.apache.tuscany.sdo.model.DataObject; +import org.apache.tuscany.sdo.model.ModelFactory; + +/** + * + * An implementation of the model object 'Data Object'. + * + *

+ *

+ * + * @generated + */ +public abstract class DataObjectImpl extends DataObjectBase implements DataObject +{ + + public final static int SDO_PROPERTY_COUNT = 0; + + public final static int EXTENDED_PROPERTY_COUNT = 0; + + + /** + * The number of properties for this type. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_PROPERTY_COUNT = 0; + + protected int internalConvertIndex(int internalIndex) + { + switch (internalIndex) + { + } + return super.internalConvertIndex(internalIndex); + } + + + /** + * + * + * @generated + */ + public DataObjectImpl() + { + super(); + } + + /** + * + * + * @generated + */ + public Type getStaticType() + { + return ((ModelFactoryImpl)ModelFactory.INSTANCE).getDataObject(); + } + +} //DataObjectImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ModelFactoryImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ModelFactoryImpl.java new file mode 100644 index 0000000000..761efb4217 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ModelFactoryImpl.java @@ -0,0 +1,2401 @@ +/** + * + * 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.helper.DataHelper; +import commonj.sdo.helper.HelperContext; + +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.helper.TypeHelperImpl; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataObject; + +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.impl.FactoryBase; + +import org.apache.tuscany.sdo.model.*; +import org.eclipse.emf.ecore.xml.type.XMLTypeFactory; +import org.eclipse.emf.ecore.xml.type.util.XMLTypeUtil; + +/** + * + * An implementation of the commonj.sdo model factory. + * This model is generated from sdoModel.xsd, in the sdo-api project. + * Until the SDO code generator supports name conflicts and regen/merge, follow the following steps to regenerate this model: + * 1. Regenerate the model into a temporary directory: + * XSD2JavaGenerator -generateBuiltIn commonj.sdo -targetDirectory -javaPackage org.apache.tuscany.sdo.model /src/main/resources/xml/sdoModel.xsd + * 2. Rename the following methods in the generated Property/PropertyImpl interface and implementation class: + * getDefault() to getDefault_(); + * setDefault() to setDefault_(); + * getOpposite() to getOpposite_(); + * setOpposite() to setOpposite_(); + * 3. Copy the following method from the old to new generated Type/TypeImpl interface and implemention class (resolve any missing imports): + * String getInstanceClassName(); + * 4. Copy the following method from the old to new generated Types/TypesImpl interface and implemention class (resolve any missing imports): + * List getTypeList(); + * 5. Delete all the createXXXFromString() and convertXXXToString() methods in the newly generated ModelFactoryImpl and + * replace them with the ones from this file (resolve any missing imports). + * 6. Comment out the call to registerStaticTypes of ModelFactory.class in the init() method + * 7. Change org.apache.tuscany.sdo.model.DataObject.class to commonj.sdo.DataObject.class for the following method found in method initializeMetaData(); + * initializeType(dataObjectType, commonj.sdo.DataObject.class, "DataObject", true); // generated as org.apache.tuscany.sdo.model.DataObject.class + * 8. Add the following case to the generated create() method: + * case DATA_OBJECT: return SDOFactory.eINSTANCE.createAnyTypeDataObject(); + * 9. Make sure the top of each generated file contains the ASF License. + * 10. Move this JavaDoc comment into the newly generated ModelFactoryImpl class. + * + * @generated + */ +public class ModelFactoryImpl extends FactoryBase implements ModelFactory +{ + + /** + * The package namespace URI. + * + * + * @generated + */ + public static final String NAMESPACE_URI = "commonj.sdo"; + + /** + * The package namespace name. + * + * + * @generated + */ + public static final String NAMESPACE_PREFIX = "sdo"; + + /** + * The version of the generator pattern used to generate this class. + * + * + * @generated + */ + public static final String PATTERN_VERSION = "1.2"; + + public static final int BASE_DATA_GRAPH_TYPE = 1; + public static final int DATA_GRAPH_TYPE = 2; + public static final int DATA_OBJECT = 3; + public static final int MODELS_TYPE = 4; + public static final int PROPERTY = 5; + public static final int TEXT_TYPE = 6; + public static final int TYPE = 7; + public static final int TYPES = 8; + public static final int XSD_TYPE = 9; + public static final int BOOLEAN = 10; + public static final int BOOLEAN_OBJECT = 11; + public static final int BYTE = 12; + public static final int BYTE_OBJECT = 13; + public static final int BYTES = 14; + public static final int CHANGE_SUMMARY_TYPE = 15; + public static final int CHARACTER = 16; + public static final int CHARACTER_OBJECT = 17; + public static final int DATE = 18; + public static final int DATE_TIME = 19; + public static final int DAY = 20; + public static final int DECIMAL = 21; + public static final int DOUBLE = 22; + public static final int DOUBLE_OBJECT = 23; + public static final int DURATION = 24; + public static final int FLOAT = 25; + public static final int FLOAT_OBJECT = 26; + public static final int INT = 27; + public static final int INTEGER = 28; + public static final int INT_OBJECT = 29; + public static final int LONG = 30; + public static final int LONG_OBJECT = 31; + public static final int MONTH = 32; + public static final int MONTH_DAY = 33; + public static final int OBJECT = 34; + public static final int SHORT = 35; + public static final int SHORT_OBJECT = 36; + public static final int STRING = 37; + public static final int STRINGS = 38; + public static final int TIME = 39; + public static final int URI = 40; + public static final int YEAR = 41; + public static final int YEAR_MONTH = 42; + public static final int YEAR_MONTH_DAY = 43; + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public ModelFactoryImpl() + { + super(NAMESPACE_URI, NAMESPACE_PREFIX, "org.apache.tuscany.sdo.model"); + } + + /** + * Registers the Factory instance so that it is available within the supplied scope. + * @argument scope a HelperContext instance that will make the types supported by this Factory available. + * + * + * @generated + */ + public void register(HelperContext scope) + { + if(scope == null) { + throw new IllegalArgumentException("Scope can not be null"); + } + + //Register dependent packages with provided scope + + // Initialize this package + TypeHelperImpl th = (TypeHelperImpl)scope.getTypeHelper(); + th.getExtendedMetaData().putPackage(NAMESPACE_URI, this); + } + + /** + * + * + * @generated NOT + */ + public DataObject create(int typeNumber) + { + switch (typeNumber) + { + case DATA_GRAPH_TYPE: return (DataObject)createDataGraphType(); + case MODELS_TYPE: return (DataObject)createModelsType(); + case PROPERTY: return (DataObject)createProperty(); + case TYPE: return (DataObject)createType(); + case TYPES: return (DataObject)createTypes(); + case XSD_TYPE: return (DataObject)createXSDType(); + case DATA_OBJECT: return SDOFactory.eINSTANCE.createAnyTypeDataObject(); + default: + return super.create(typeNumber); + } + } + + /** + * + * + * @generated + */ + public Object createFromString(int typeNumber, String initialValue) + { + switch (typeNumber) + { + case BOOLEAN: + return createBooleanFromString(initialValue); + case BOOLEAN_OBJECT: + return createBooleanObjectFromString(initialValue); + case BYTE: + return createByteFromString(initialValue); + case BYTE_OBJECT: + return createByteObjectFromString(initialValue); + case BYTES: + return createBytesFromString(initialValue); + case CHANGE_SUMMARY_TYPE: + return createChangeSummaryTypeFromString(initialValue); + case CHARACTER: + return createCharacterFromString(initialValue); + case CHARACTER_OBJECT: + return createCharacterObjectFromString(initialValue); + case DATE: + return createDateFromString(initialValue); + case DATE_TIME: + return createDateTimeFromString(initialValue); + case DAY: + return createDayFromString(initialValue); + case DECIMAL: + return createDecimalFromString(initialValue); + case DOUBLE: + return createDoubleFromString(initialValue); + case DOUBLE_OBJECT: + return createDoubleObjectFromString(initialValue); + case DURATION: + return createDurationFromString(initialValue); + case FLOAT: + return createFloatFromString(initialValue); + case FLOAT_OBJECT: + return createFloatObjectFromString(initialValue); + case INT: + return createIntFromString(initialValue); + case INTEGER: + return createIntegerFromString(initialValue); + case INT_OBJECT: + return createIntObjectFromString(initialValue); + case LONG: + return createLongFromString(initialValue); + case LONG_OBJECT: + return createLongObjectFromString(initialValue); + case MONTH: + return createMonthFromString(initialValue); + case MONTH_DAY: + return createMonthDayFromString(initialValue); + case OBJECT: + return createObjectFromString(initialValue); + case SHORT: + return createShortFromString(initialValue); + case SHORT_OBJECT: + return createShortObjectFromString(initialValue); + case STRING: + return createStringFromString(initialValue); + case STRINGS: + return createStringsFromString(initialValue); + case TIME: + return createTimeFromString(initialValue); + case URI: + return createURIFromString(initialValue); + case YEAR: + return createYearFromString(initialValue); + case YEAR_MONTH: + return createYearMonthFromString(initialValue); + case YEAR_MONTH_DAY: + return createYearMonthDayFromString(initialValue); + default: + throw new IllegalArgumentException("The type number '" + typeNumber + "' is not a valid datatype"); + } + } + + /** + * + * + * @generated + */ + public String convertToString(int typeNumber, Object instanceValue) + { + switch (typeNumber) + { + case BOOLEAN: + return convertBooleanToString(instanceValue); + case BOOLEAN_OBJECT: + return convertBooleanObjectToString(instanceValue); + case BYTE: + return convertByteToString(instanceValue); + case BYTE_OBJECT: + return convertByteObjectToString(instanceValue); + case BYTES: + return convertBytesToString(instanceValue); + case CHANGE_SUMMARY_TYPE: + return convertChangeSummaryTypeToString(instanceValue); + case CHARACTER: + return convertCharacterToString(instanceValue); + case CHARACTER_OBJECT: + return convertCharacterObjectToString(instanceValue); + case DATE: + return convertDateToString(instanceValue); + case DATE_TIME: + return convertDateTimeToString(instanceValue); + case DAY: + return convertDayToString(instanceValue); + case DECIMAL: + return convertDecimalToString(instanceValue); + case DOUBLE: + return convertDoubleToString(instanceValue); + case DOUBLE_OBJECT: + return convertDoubleObjectToString(instanceValue); + case DURATION: + return convertDurationToString(instanceValue); + case FLOAT: + return convertFloatToString(instanceValue); + case FLOAT_OBJECT: + return convertFloatObjectToString(instanceValue); + case INT: + return convertIntToString(instanceValue); + case INTEGER: + return convertIntegerToString(instanceValue); + case INT_OBJECT: + return convertIntObjectToString(instanceValue); + case LONG: + return convertLongToString(instanceValue); + case LONG_OBJECT: + return convertLongObjectToString(instanceValue); + case MONTH: + return convertMonthToString(instanceValue); + case MONTH_DAY: + return convertMonthDayToString(instanceValue); + case OBJECT: + return convertObjectToString(instanceValue); + case SHORT: + return convertShortToString(instanceValue); + case SHORT_OBJECT: + return convertShortObjectToString(instanceValue); + case STRING: + return convertStringToString(instanceValue); + case STRINGS: + return convertStringsToString(instanceValue); + case TIME: + return convertTimeToString(instanceValue); + case URI: + return convertURIToString(instanceValue); + case YEAR: + return convertYearToString(instanceValue); + case YEAR_MONTH: + return convertYearMonthToString(instanceValue); + case YEAR_MONTH_DAY: + return convertYearMonthDayToString(instanceValue); + default: + throw new IllegalArgumentException("The type number '" + typeNumber + "' is not a valid datatype"); + } + } + /** + * + * + * @generated + */ + public DataGraphType createDataGraphType() + { + DataGraphTypeImpl dataGraphType = new DataGraphTypeImpl(); + return dataGraphType; + } + /** + * + * + * @generated + */ + public ModelsType createModelsType() + { + ModelsTypeImpl modelsType = new ModelsTypeImpl(); + return modelsType; + } + /** + * + * + * @generated + */ + public Property createProperty() + { + PropertyImpl property = new PropertyImpl(); + return property; + } + /** + * + * + * @generated + */ + public Type createType() + { + TypeImpl type = new TypeImpl(); + return type; + } + /** + * + * + * @generated + */ + public Types createTypes() + { + TypesImpl types = new TypesImpl(); + return types; + } + /** + * + * + * @generated + */ + public XSDType createXSDType() + { + XSDTypeImpl xsdType = new XSDTypeImpl(); + return xsdType; + } + + // Following creates and initializes SDO metadata for the supported types. + protected commonj.sdo.Type baseDataGraphTypeType = null; + + public commonj.sdo.Type getBaseDataGraphType() + { + return baseDataGraphTypeType; + } + + protected commonj.sdo.Type dataGraphTypeType = null; + + public commonj.sdo.Type getDataGraphType() + { + return dataGraphTypeType; + } + + protected commonj.sdo.Type dataObjectType = null; + + public commonj.sdo.Type getDataObject() + { + return dataObjectType; + } + + protected commonj.sdo.Type modelsTypeType = null; + + public commonj.sdo.Type getModelsType() + { + return modelsTypeType; + } + + protected commonj.sdo.Type propertyType = null; + + public commonj.sdo.Type getProperty() + { + return propertyType; + } + + protected commonj.sdo.Type textTypeType = null; + + public commonj.sdo.Type getTextType() + { + return textTypeType; + } + + protected commonj.sdo.Type typeType = null; + + public commonj.sdo.Type getType() + { + return typeType; + } + + protected commonj.sdo.Type typesType = null; + + public commonj.sdo.Type getTypes() + { + return typesType; + } + + protected commonj.sdo.Type xsdTypeType = null; + + public commonj.sdo.Type getXSDType() + { + return xsdTypeType; + } + + protected commonj.sdo.Type boolean_Type = null; + + public commonj.sdo.Type getBoolean() + { + return boolean_Type; + } + + protected commonj.sdo.Type booleanObjectType = null; + + public commonj.sdo.Type getBooleanObject() + { + return booleanObjectType; + } + + protected commonj.sdo.Type byte_Type = null; + + public commonj.sdo.Type getByte() + { + return byte_Type; + } + + protected commonj.sdo.Type byteObjectType = null; + + public commonj.sdo.Type getByteObject() + { + return byteObjectType; + } + + protected commonj.sdo.Type bytesType = null; + + public commonj.sdo.Type getBytes() + { + return bytesType; + } + + protected commonj.sdo.Type changeSummaryTypeType = null; + + public commonj.sdo.Type getChangeSummaryType() + { + return changeSummaryTypeType; + } + + protected commonj.sdo.Type characterType = null; + + public commonj.sdo.Type getCharacter() + { + return characterType; + } + + protected commonj.sdo.Type characterObjectType = null; + + public commonj.sdo.Type getCharacterObject() + { + return characterObjectType; + } + + protected commonj.sdo.Type dateType = null; + + public commonj.sdo.Type getDate() + { + return dateType; + } + + protected commonj.sdo.Type dateTimeType = null; + + public commonj.sdo.Type getDateTime() + { + return dateTimeType; + } + + protected commonj.sdo.Type dayType = null; + + public commonj.sdo.Type getDay() + { + return dayType; + } + + protected commonj.sdo.Type decimalType = null; + + public commonj.sdo.Type getDecimal() + { + return decimalType; + } + + protected commonj.sdo.Type double_Type = null; + + public commonj.sdo.Type getDouble() + { + return double_Type; + } + + protected commonj.sdo.Type doubleObjectType = null; + + public commonj.sdo.Type getDoubleObject() + { + return doubleObjectType; + } + + protected commonj.sdo.Type durationType = null; + + public commonj.sdo.Type getDuration() + { + return durationType; + } + + protected commonj.sdo.Type float_Type = null; + + public commonj.sdo.Type getFloat() + { + return float_Type; + } + + protected commonj.sdo.Type floatObjectType = null; + + public commonj.sdo.Type getFloatObject() + { + return floatObjectType; + } + + protected commonj.sdo.Type int_Type = null; + + public commonj.sdo.Type getInt() + { + return int_Type; + } + + protected commonj.sdo.Type integerType = null; + + public commonj.sdo.Type getInteger() + { + return integerType; + } + + protected commonj.sdo.Type intObjectType = null; + + public commonj.sdo.Type getIntObject() + { + return intObjectType; + } + + protected commonj.sdo.Type long_Type = null; + + public commonj.sdo.Type getLong() + { + return long_Type; + } + + protected commonj.sdo.Type longObjectType = null; + + public commonj.sdo.Type getLongObject() + { + return longObjectType; + } + + protected commonj.sdo.Type monthType = null; + + public commonj.sdo.Type getMonth() + { + return monthType; + } + + protected commonj.sdo.Type monthDayType = null; + + public commonj.sdo.Type getMonthDay() + { + return monthDayType; + } + + protected commonj.sdo.Type objectType = null; + + public commonj.sdo.Type getObject() + { + return objectType; + } + + protected commonj.sdo.Type short_Type = null; + + public commonj.sdo.Type getShort() + { + return short_Type; + } + + protected commonj.sdo.Type shortObjectType = null; + + public commonj.sdo.Type getShortObject() + { + return shortObjectType; + } + + protected commonj.sdo.Type stringType = null; + + public commonj.sdo.Type getString() + { + return stringType; + } + + protected commonj.sdo.Type stringsType = null; + + public commonj.sdo.Type getStrings() + { + return stringsType; + } + + protected commonj.sdo.Type timeType = null; + + public commonj.sdo.Type getTime() + { + return timeType; + } + + protected commonj.sdo.Type uriType = null; + + public commonj.sdo.Type getURI() + { + return uriType; + } + + protected commonj.sdo.Type yearType = null; + + public commonj.sdo.Type getYear() + { + return yearType; + } + + protected commonj.sdo.Type yearMonthType = null; + + public commonj.sdo.Type getYearMonth() + { + return yearMonthType; + } + + protected commonj.sdo.Type yearMonthDayType = null; + + public commonj.sdo.Type getYearMonthDay() + { + return yearMonthDayType; + } + + + private static ModelFactoryImpl instance = null; + public static ModelFactoryImpl init() + { + if (instance != null ) return instance; + instance = new ModelFactoryImpl(); + + // Initialize dependent packages + + // Create package meta-data objects + instance.createMetaData(); + + // Initialize created meta-data + instance.initializeMetaData(); + + // Mark meta-data to indicate it can't be changed + //theModelFactoryImpl.freeze(); //FB do we need to freeze / should we freeze ???? + + return instance; + } + + private boolean isCreated = false; + + public void createMetaData() + { + if (isCreated) return; + isCreated = true; + + // Create types and their properties + baseDataGraphTypeType = createType(false, BASE_DATA_GRAPH_TYPE); + createProperty(false, baseDataGraphTypeType,BaseDataGraphTypeImpl.INTERNAL_MODELS); + createProperty(false, baseDataGraphTypeType,BaseDataGraphTypeImpl.INTERNAL_XSD); + createProperty(true, baseDataGraphTypeType,BaseDataGraphTypeImpl.INTERNAL_CHANGE_SUMMARY); + createProperty(true, baseDataGraphTypeType,BaseDataGraphTypeImpl.INTERNAL_ANY_ATTRIBUTE); + dataGraphTypeType = createType(false, DATA_GRAPH_TYPE); + createProperty(true, dataGraphTypeType,DataGraphTypeImpl.INTERNAL_ANY); + dataObjectType = createType(false, DATA_OBJECT); + modelsTypeType = createType(false, MODELS_TYPE); + createProperty(true, modelsTypeType,ModelsTypeImpl.INTERNAL_ANY); + propertyType = createType(false, PROPERTY); + createProperty(true, propertyType,PropertyImpl.INTERNAL_ALIAS_NAME); + createProperty(true, propertyType,PropertyImpl.INTERNAL_ANY); + createProperty(true, propertyType,PropertyImpl.INTERNAL_NAME); + createProperty(true, propertyType,PropertyImpl.INTERNAL_MANY); + createProperty(true, propertyType,PropertyImpl.INTERNAL_CONTAINMENT); + createProperty(true, propertyType,PropertyImpl.INTERNAL_DEFAULT); + createProperty(true, propertyType,PropertyImpl.INTERNAL_READ_ONLY); + createProperty(false, propertyType,PropertyImpl.INTERNAL_TYPE); + createProperty(false, propertyType,PropertyImpl.INTERNAL_OPPOSITE); + createProperty(true, propertyType,PropertyImpl.INTERNAL_NULLABLE); + createProperty(true, propertyType,PropertyImpl.INTERNAL_ANY_ATTRIBUTE); + textTypeType = createType(false, TEXT_TYPE); + createProperty(true, textTypeType,TextTypeImpl.INTERNAL_TEXT); + typeType = createType(false, TYPE); + createProperty(false, typeType,TypeImpl.INTERNAL_BASE_TYPE); + createProperty(false, typeType,TypeImpl.INTERNAL_PROPERTY); + createProperty(true, typeType,TypeImpl.INTERNAL_ALIAS_NAME); + createProperty(true, typeType,TypeImpl.INTERNAL_ANY); + createProperty(true, typeType,TypeImpl.INTERNAL_NAME); + createProperty(true, typeType,TypeImpl.INTERNAL_URI); + createProperty(true, typeType,TypeImpl.INTERNAL_DATA_TYPE); + createProperty(true, typeType,TypeImpl.INTERNAL_OPEN); + createProperty(true, typeType,TypeImpl.INTERNAL_SEQUENCED); + createProperty(true, typeType,TypeImpl.INTERNAL_ABSTRACT); + createProperty(true, typeType,TypeImpl.INTERNAL_ANY_ATTRIBUTE); + typesType = createType(false, TYPES); + createProperty(false, typesType,TypesImpl.INTERNAL_TYPE); + xsdTypeType = createType(false, XSD_TYPE); + createProperty(true, xsdTypeType,XSDTypeImpl.INTERNAL_ANY); + + // Create data types + boolean_Type = createType(true, BOOLEAN ); + booleanObjectType = createType(true, BOOLEAN_OBJECT ); + byte_Type = createType(true, BYTE ); + byteObjectType = createType(true, BYTE_OBJECT ); + bytesType = createType(true, BYTES ); + changeSummaryTypeType = createType(true, CHANGE_SUMMARY_TYPE ); + characterType = createType(true, CHARACTER ); + characterObjectType = createType(true, CHARACTER_OBJECT ); + dateType = createType(true, DATE ); + dateTimeType = createType(true, DATE_TIME ); + dayType = createType(true, DAY ); + decimalType = createType(true, DECIMAL ); + double_Type = createType(true, DOUBLE ); + doubleObjectType = createType(true, DOUBLE_OBJECT ); + durationType = createType(true, DURATION ); + float_Type = createType(true, FLOAT ); + floatObjectType = createType(true, FLOAT_OBJECT ); + int_Type = createType(true, INT ); + integerType = createType(true, INTEGER ); + intObjectType = createType(true, INT_OBJECT ); + long_Type = createType(true, LONG ); + longObjectType = createType(true, LONG_OBJECT ); + monthType = createType(true, MONTH ); + monthDayType = createType(true, MONTH_DAY ); + objectType = createType(true, OBJECT ); + short_Type = createType(true, SHORT ); + shortObjectType = createType(true, SHORT_OBJECT ); + stringType = createType(true, STRING ); + stringsType = createType(true, STRINGS ); + timeType = createType(true, TIME ); + uriType = createType(true, URI ); + yearType = createType(true, YEAR ); + yearMonthType = createType(true, YEAR_MONTH ); + yearMonthDayType = createType(true, YEAR_MONTH_DAY ); + } + + private boolean isInitialized = false; + + public void initializeMetaData() + { + if (isInitialized) return; + isInitialized = true; + commonj.sdo.Property property = null; + + // Add supertypes to types + addSuperType(dataGraphTypeType, this.getBaseDataGraphType()); + + // Initialize types and properties + initializeType(baseDataGraphTypeType, BaseDataGraphType.class, "BaseDataGraphType", true); + property = getLocalProperty(baseDataGraphTypeType, 0); + initializeProperty(property, this.getModelsType(), "models", null, 0, 1, BaseDataGraphType.class, false, true, false, true , null); + + property = getLocalProperty(baseDataGraphTypeType, 1); + initializeProperty(property, this.getXSDType(), "xsd", null, 0, 1, BaseDataGraphType.class, false, true, false, true , null); + + property = getLocalProperty(baseDataGraphTypeType, 2); + initializeProperty(property, this.getChangeSummaryType(), "changeSummary", null, 0, 1, BaseDataGraphType.class, false, true, false); + + property = getLocalProperty(baseDataGraphTypeType, 3); + initializeProperty(property, getSequence(), "anyAttribute", null, 0, -1, BaseDataGraphType.class, false, false, false); + + initializeType(dataGraphTypeType, DataGraphType.class, "DataGraphType", false); + property = getLocalProperty(dataGraphTypeType, 0); + initializeProperty(property, getSequence(), "any", null, 0, 1, DataGraphType.class, false, false, false); + + initializeType(dataObjectType, commonj.sdo.DataObject.class, "DataObject", true); // generated as org.apache.tuscany.sdo.model.DataObject.class + initializeType(modelsTypeType, ModelsType.class, "ModelsType", false); + property = getLocalProperty(modelsTypeType, 0); + initializeProperty(property, getSequence(), "any", null, 0, -1, ModelsType.class, false, false, false); + + initializeType(propertyType, Property.class, "Property", false); + property = getLocalProperty(propertyType, 0); + initializeProperty(property, this.getString(), "aliasName", null, 0, -1, Property.class, false, false, false); + + property = getLocalProperty(propertyType, 1); + initializeProperty(property, getSequence(), "any", null, 0, -1, Property.class, false, false, false); + + property = getLocalProperty(propertyType, 2); + initializeProperty(property, this.getString(), "name", null, 0, 1, Property.class, false, true, false); + + property = getLocalProperty(propertyType, 3); + initializeProperty(property, this.getBoolean(), "many", null, 0, 1, Property.class, false, true, false); + + property = getLocalProperty(propertyType, 4); + initializeProperty(property, this.getBoolean(), "containment", null, 0, 1, Property.class, false, true, false); + + property = getLocalProperty(propertyType, 5); + initializeProperty(property, this.getString(), "default", null, 0, 1, Property.class, false, true, false); + + property = getLocalProperty(propertyType, 6); + initializeProperty(property, this.getBoolean(), "readOnly", null, 0, 1, Property.class, false, true, false); + + property = getLocalProperty(propertyType, 7); + initializeProperty(property, this.getType(), "type", null, 0, 1, Property.class, false, true, false, false , null); + setInstanceProperty (property, "commonj.sdo/xml", "propertyType", "sdo:Type"); + + property = getLocalProperty(propertyType, 8); + initializeProperty(property, this.getProperty(), "opposite", null, 0, 1, Property.class, false, true, false, false , null); + setInstanceProperty (property, "commonj.sdo/xml", "propertyType", "sdo:Property"); + + property = getLocalProperty(propertyType, 9); + initializeProperty(property, this.getBoolean(), "nullable", null, 0, 1, Property.class, false, true, false); + + property = getLocalProperty(propertyType, 10); + initializeProperty(property, getSequence(), "anyAttribute", null, 0, -1, Property.class, false, false, false); + + initializeType(textTypeType, TextType.class, "TextType", true); + property = getLocalProperty(textTypeType, 0); + initializeProperty(property, this.getString(), "text", null, 0, -1, TextType.class, false, false, false); + + initializeType(typeType, Type.class, "Type", false); + property = getLocalProperty(typeType, 0); + initializeProperty(property, this.getType(), "baseType", null, 0, -1, Type.class, false, false, false, false , null); + setInstanceProperty (property, "commonj.sdo/xml", "propertyType", "sdo:Type"); + + property = getLocalProperty(typeType, 1); + initializeProperty(property, this.getProperty(), "property", null, 0, -1, Type.class, false, false, false, true , null); + + property = getLocalProperty(typeType, 2); + initializeProperty(property, this.getString(), "aliasName", null, 0, -1, Type.class, false, false, false); + + property = getLocalProperty(typeType, 3); + initializeProperty(property, getSequence(), "any", null, 0, -1, Type.class, false, false, false); + + property = getLocalProperty(typeType, 4); + initializeProperty(property, this.getString(), "name", null, 0, 1, Type.class, false, true, false); + setInstanceProperty (property, "commonj.sdo/xml", "dataType", "sdo:String"); + + property = getLocalProperty(typeType, 5); + initializeProperty(property, this.getURI(), "uri", null, 0, 1, Type.class, false, true, false); + + property = getLocalProperty(typeType, 6); + initializeProperty(property, this.getBoolean(), "dataType", null, 0, 1, Type.class, false, true, false); + + property = getLocalProperty(typeType, 7); + initializeProperty(property, this.getBoolean(), "open", null, 0, 1, Type.class, false, true, false); + + property = getLocalProperty(typeType, 8); + initializeProperty(property, this.getBoolean(), "sequenced", null, 0, 1, Type.class, false, true, false); + + property = getLocalProperty(typeType, 9); + initializeProperty(property, this.getBoolean(), "abstract", null, 0, 1, Type.class, false, true, false); + + property = getLocalProperty(typeType, 10); + initializeProperty(property, getSequence(), "anyAttribute", null, 0, -1, Type.class, false, false, false); + + initializeType(typesType, Types.class, "Types", false); + property = getLocalProperty(typesType, 0); + initializeProperty(property, this.getType(), "type", null, 0, -1, Types.class, false, false, false, true , null); + + initializeType(xsdTypeType, XSDType.class, "XSDType", false); + property = getLocalProperty(xsdTypeType, 0); + initializeProperty(property, getSequence(), "any", null, 0, -1, XSDType.class, false, false, false); + + // Initialize data types + initializeType(boolean_Type, boolean.class, "Boolean", true, false); + setInstanceProperty (boolean_Type, "commonj.sdo/java", "instanceClass", "boolean"); + + initializeType(booleanObjectType, Boolean.class, "BooleanObject", true, false); + + initializeType(byte_Type, byte.class, "Byte", true, false); + setInstanceProperty (byte_Type, "commonj.sdo/java", "instanceClass", "byte"); + + initializeType(byteObjectType, Byte.class, "ByteObject", true, false); + + initializeType(bytesType, byte[].class, "Bytes", true, false); + setInstanceProperty (bytesType, "commonj.sdo/java", "instanceClass", "byte[]"); + + initializeType(changeSummaryTypeType, ChangeSummary.class, "ChangeSummaryType", true, false); + setInstanceProperty (changeSummaryTypeType, "commonj.sdo/java", "instanceClass", "commonj.sdo.ChangeSummary"); + + initializeType(characterType, char.class, "Character", true, false); + setInstanceProperty (characterType, "commonj.sdo/java", "instanceClass", "char"); + + initializeType(characterObjectType, Character.class, "CharacterObject", true, false); + + initializeType(dateType, Date.class, "Date", true, false); + setInstanceProperty (dateType, "commonj.sdo/java", "instanceClass", "java.util.Date"); + + initializeType(dateTimeType, String.class, "DateTime", true, false); + setInstanceProperty (dateTimeType, "commonj.sdo/java", "instanceClass", "java.lang.String"); + + initializeType(dayType, String.class, "Day", true, false); + setInstanceProperty (dayType, "commonj.sdo/java", "instanceClass", "java.lang.String"); + + initializeType(decimalType, BigDecimal.class, "Decimal", true, false); + setInstanceProperty (decimalType, "commonj.sdo/java", "instanceClass", "java.math.BigDecimal"); + + initializeType(double_Type, double.class, "Double", true, false); + setInstanceProperty (double_Type, "commonj.sdo/java", "instanceClass", "double"); + + initializeType(doubleObjectType, Double.class, "DoubleObject", true, false); + + initializeType(durationType, String.class, "Duration", true, false); + setInstanceProperty (durationType, "commonj.sdo/java", "instanceClass", "java.lang.String"); + + initializeType(float_Type, float.class, "Float", true, false); + setInstanceProperty (float_Type, "commonj.sdo/java", "instanceClass", "float"); + + initializeType(floatObjectType, Float.class, "FloatObject", true, false); + + initializeType(int_Type, int.class, "Int", true, false); + setInstanceProperty (int_Type, "commonj.sdo/java", "instanceClass", "int"); + + initializeType(integerType, BigInteger.class, "Integer", true, false); + setInstanceProperty (integerType, "commonj.sdo/java", "instanceClass", "java.math.BigInteger"); + + initializeType(intObjectType, Integer.class, "IntObject", true, false); + + initializeType(long_Type, long.class, "Long", true, false); + setInstanceProperty (long_Type, "commonj.sdo/java", "instanceClass", "long"); + + initializeType(longObjectType, Long.class, "LongObject", true, false); + + initializeType(monthType, String.class, "Month", true, false); + setInstanceProperty (monthType, "commonj.sdo/java", "instanceClass", "java.lang.String"); + + initializeType(monthDayType, String.class, "MonthDay", true, false); + setInstanceProperty (monthDayType, "commonj.sdo/java", "instanceClass", "java.lang.String"); + + initializeType(objectType, Object.class, "Object", true, false); + setInstanceProperty (objectType, "commonj.sdo/java", "instanceClass", "java.lang.Object"); + + initializeType(short_Type, short.class, "Short", true, false); + setInstanceProperty (short_Type, "commonj.sdo/java", "instanceClass", "short"); + + initializeType(shortObjectType, Short.class, "ShortObject", true, false); + + initializeType(stringType, String.class, "String", true, false); + setInstanceProperty (stringType, "commonj.sdo/java", "instanceClass", "java.lang.String"); + + initializeType(stringsType, List.class, "Strings", true, false); + setInstanceProperty (stringsType, "commonj.sdo/java", "instanceClass", "java.util.List"); + + initializeType(timeType, String.class, "Time", true, false); + setInstanceProperty (timeType, "commonj.sdo/java", "instanceClass", "java.lang.String"); + + initializeType(uriType, String.class, "URI", true, false); + setInstanceProperty (uriType, "commonj.sdo/java", "instanceClass", "java.lang.String"); + + initializeType(yearType, String.class, "Year", true, false); + setInstanceProperty (yearType, "commonj.sdo/java", "instanceClass", "java.lang.String"); + + initializeType(yearMonthType, String.class, "YearMonth", true, false); + setInstanceProperty (yearMonthType, "commonj.sdo/java", "instanceClass", "java.lang.String"); + + initializeType(yearMonthDayType, String.class, "YearMonthDay", true, false); + setInstanceProperty (yearMonthDayType, "commonj.sdo/java", "instanceClass", "java.lang.String"); + + createXSDMetaData(); + } + + protected void createXSDMetaData() + { + super.initXSD(); + + commonj.sdo.Property property = null; + + + addXSDMapping + (baseDataGraphTypeType, + new String[] + { + "name", "BaseDataGraphType", + "kind", "elementOnly" + }); + + addXSDMapping + (getProperty(baseDataGraphTypeType, BaseDataGraphTypeImpl.INTERNAL_MODELS), + new String[] + { + "kind", "element", + "name", "models" + }); + + addXSDMapping + (getProperty(baseDataGraphTypeType, BaseDataGraphTypeImpl.INTERNAL_XSD), + new String[] + { + "kind", "element", + "name", "xsd" + }); + + addXSDMapping + (getProperty(baseDataGraphTypeType, BaseDataGraphTypeImpl.INTERNAL_CHANGE_SUMMARY), + new String[] + { + "kind", "element", + "name", "changeSummary" + }); + + addXSDMapping + (getProperty(baseDataGraphTypeType, BaseDataGraphTypeImpl.INTERNAL_ANY_ATTRIBUTE), + new String[] + { + "kind", "attributeWildcard", + "wildcards", "##other", + "name", ":3", + "processing", "lax" + }); + + addXSDMapping + (dataGraphTypeType, + new String[] + { + "name", "DataGraphType", + "kind", "elementOnly" + }); + + addXSDMapping + (getProperty(dataGraphTypeType, DataGraphTypeImpl.INTERNAL_ANY), + new String[] + { + "kind", "elementWildcard", + "wildcards", "##other", + "name", ":4", + "processing", "lax" + }); + + addXSDMapping + (dataObjectType, + new String[] + { + "name", "DataObject", + "kind", "empty" + }); + + property = createGlobalProperty + ("datagraph", + this.getDataGraphType(), + new String[] + { + "kind", "element", + "name", "datagraph", + "namespace", "##targetNamespace" + }); + + property = createGlobalProperty + ("dataObject", + this.getDataObject(), + new String[] + { + "kind", "element", + "name", "dataObject", + "namespace", "##targetNamespace" + }); + + property = createGlobalProperty + ("type", + this.getType(), + new String[] + { + "kind", "element", + "name", "type", + "namespace", "##targetNamespace" + }); + + property = createGlobalProperty + ("types", + this.getTypes(), + new String[] + { + "kind", "element", + "name", "types", + "namespace", "##targetNamespace" + }); + + property = createGlobalProperty + ("ref", + this.getString(), + new String[] + { + "kind", "attribute", + "name", "ref", + "namespace", "##targetNamespace" + }, + IS_ATTRIBUTE); + + property = createGlobalProperty + ("unset", + this.getString(), + new String[] + { + "kind", "attribute", + "name", "unset", + "namespace", "##targetNamespace" + }, + IS_ATTRIBUTE); + + addXSDMapping + (modelsTypeType, + new String[] + { + "name", "ModelsType", + "kind", "elementOnly" + }); + + addXSDMapping + (getProperty(modelsTypeType, ModelsTypeImpl.INTERNAL_ANY), + new String[] + { + "kind", "elementWildcard", + "wildcards", "##other", + "name", ":0", + "processing", "lax" + }); + + addXSDMapping + (propertyType, + new String[] + { + "name", "Property", + "kind", "elementOnly" + }); + + addXSDMapping + (getProperty(propertyType, PropertyImpl.INTERNAL_ALIAS_NAME), + new String[] + { + "kind", "element", + "name", "aliasName", + "namespace", "##targetNamespace" + }); + + addXSDMapping + (getProperty(propertyType, PropertyImpl.INTERNAL_ANY), + new String[] + { + "kind", "elementWildcard", + "wildcards", "##other", + "name", ":1", + "processing", "lax" + }); + + addXSDMapping + (getProperty(propertyType, PropertyImpl.INTERNAL_NAME), + new String[] + { + "kind", "attribute", + "name", "name" + }); + + addXSDMapping + (getProperty(propertyType, PropertyImpl.INTERNAL_MANY), + new String[] + { + "kind", "attribute", + "name", "many" + }); + + addXSDMapping + (getProperty(propertyType, PropertyImpl.INTERNAL_CONTAINMENT), + new String[] + { + "kind", "attribute", + "name", "containment" + }); + + addXSDMapping + (getProperty(propertyType, PropertyImpl.INTERNAL_DEFAULT), + new String[] + { + "kind", "attribute", + "name", "default" + }); + + addXSDMapping + (getProperty(propertyType, PropertyImpl.INTERNAL_READ_ONLY), + new String[] + { + "kind", "attribute", + "name", "readOnly" + }); + + addXSDMapping + (getProperty(propertyType, PropertyImpl.INTERNAL_TYPE), + new String[] + { + "kind", "attribute", + "name", "type" + }); + + addXSDMapping + (getProperty(propertyType, PropertyImpl.INTERNAL_OPPOSITE), + new String[] + { + "kind", "attribute", + "name", "opposite" + }); + + addXSDMapping + (getProperty(propertyType, PropertyImpl.INTERNAL_NULLABLE), + new String[] + { + "kind", "attribute", + "name", "nullable" + }); + + addXSDMapping + (getProperty(propertyType, PropertyImpl.INTERNAL_ANY_ATTRIBUTE), + new String[] + { + "kind", "attributeWildcard", + "wildcards", "##any", + "name", ":10", + "processing", "lax" + }); + + addXSDMapping + (textTypeType, + new String[] + { + "name", "TextType", + "kind", "elementOnly" + }); + + addXSDMapping + (getProperty(textTypeType, TextTypeImpl.INTERNAL_TEXT), + new String[] + { + "kind", "element", + "name", "text", + "namespace", "##targetNamespace" + }); + + addXSDMapping + (typeType, + new String[] + { + "name", "Type", + "kind", "elementOnly" + }); + + addXSDMapping + (getProperty(typeType, TypeImpl.INTERNAL_BASE_TYPE), + new String[] + { + "kind", "element", + "name", "baseType", + "namespace", "##targetNamespace" + }); + + addXSDMapping + (getProperty(typeType, TypeImpl.INTERNAL_PROPERTY), + new String[] + { + "kind", "element", + "name", "property", + "namespace", "##targetNamespace" + }); + + addXSDMapping + (getProperty(typeType, TypeImpl.INTERNAL_ALIAS_NAME), + new String[] + { + "kind", "element", + "name", "aliasName", + "namespace", "##targetNamespace" + }); + + addXSDMapping + (getProperty(typeType, TypeImpl.INTERNAL_ANY), + new String[] + { + "kind", "elementWildcard", + "wildcards", "##other", + "name", ":3", + "processing", "lax" + }); + + addXSDMapping + (getProperty(typeType, TypeImpl.INTERNAL_NAME), + new String[] + { + "kind", "attribute", + "name", "name" + }); + + addXSDMapping + (getProperty(typeType, TypeImpl.INTERNAL_URI), + new String[] + { + "kind", "attribute", + "name", "uri" + }); + + addXSDMapping + (getProperty(typeType, TypeImpl.INTERNAL_DATA_TYPE), + new String[] + { + "kind", "attribute", + "name", "dataType" + }); + + addXSDMapping + (getProperty(typeType, TypeImpl.INTERNAL_OPEN), + new String[] + { + "kind", "attribute", + "name", "open" + }); + + addXSDMapping + (getProperty(typeType, TypeImpl.INTERNAL_SEQUENCED), + new String[] + { + "kind", "attribute", + "name", "sequenced" + }); + + addXSDMapping + (getProperty(typeType, TypeImpl.INTERNAL_ABSTRACT), + new String[] + { + "kind", "attribute", + "name", "abstract" + }); + + addXSDMapping + (getProperty(typeType, TypeImpl.INTERNAL_ANY_ATTRIBUTE), + new String[] + { + "kind", "attributeWildcard", + "wildcards", "##any", + "name", ":10", + "processing", "lax" + }); + + addXSDMapping + (typesType, + new String[] + { + "name", "Types", + "kind", "elementOnly" + }); + + addXSDMapping + (getProperty(typesType, TypesImpl.INTERNAL_TYPE), + new String[] + { + "kind", "element", + "name", "type", + "namespace", "##targetNamespace" + }); + + addXSDMapping + (xsdTypeType, + new String[] + { + "name", "XSDType", + "kind", "elementOnly" + }); + + addXSDMapping + (getProperty(xsdTypeType, XSDTypeImpl.INTERNAL_ANY), + new String[] + { + "kind", "elementWildcard", + "wildcards", "http://www.w3.org/2001/XMLSchema", + "name", ":0", + "processing", "lax" + }); + + addXSDMapping + (boolean_Type, + new String[] + { + "name", "Boolean" + }); + + addXSDMapping + (booleanObjectType, + new String[] + { + "name", "Boolean:Object", + "baseType", "Boolean" + }); + + addXSDMapping + (byte_Type, + new String[] + { + "name", "Byte" + }); + + addXSDMapping + (byteObjectType, + new String[] + { + "name", "Byte:Object", + "baseType", "Byte" + }); + + addXSDMapping + (bytesType, + new String[] + { + "name", "Bytes" + }); + + addXSDMapping + (changeSummaryTypeType, + new String[] + { + "name", "ChangeSummaryType" + }); + + addXSDMapping + (characterType, + new String[] + { + "name", "Character" + }); + + addXSDMapping + (characterObjectType, + new String[] + { + "name", "Character:Object", + "baseType", "Character" + }); + + addXSDMapping + (dateType, + new String[] + { + "name", "Date" + }); + + addXSDMapping + (dateTimeType, + new String[] + { + "name", "DateTime" + }); + + addXSDMapping + (dayType, + new String[] + { + "name", "Day" + }); + + addXSDMapping + (decimalType, + new String[] + { + "name", "Decimal" + }); + + addXSDMapping + (double_Type, + new String[] + { + "name", "Double" + }); + + addXSDMapping + (doubleObjectType, + new String[] + { + "name", "Double:Object", + "baseType", "Double" + }); + + addXSDMapping + (durationType, + new String[] + { + "name", "Duration" + }); + + addXSDMapping + (float_Type, + new String[] + { + "name", "Float" + }); + + addXSDMapping + (floatObjectType, + new String[] + { + "name", "Float:Object", + "baseType", "Float" + }); + + addXSDMapping + (int_Type, + new String[] + { + "name", "Int" + }); + + addXSDMapping + (integerType, + new String[] + { + "name", "Integer" + }); + + addXSDMapping + (intObjectType, + new String[] + { + "name", "Int:Object", + "baseType", "Int" + }); + + addXSDMapping + (long_Type, + new String[] + { + "name", "Long" + }); + + addXSDMapping + (longObjectType, + new String[] + { + "name", "Long:Object", + "baseType", "Long" + }); + + addXSDMapping + (monthType, + new String[] + { + "name", "Month" + }); + + addXSDMapping + (monthDayType, + new String[] + { + "name", "MonthDay" + }); + + addXSDMapping + (objectType, + new String[] + { + "name", "Object" + }); + + addXSDMapping + (short_Type, + new String[] + { + "name", "Short" + }); + + addXSDMapping + (shortObjectType, + new String[] + { + "name", "Short:Object", + "baseType", "Short" + }); + + addXSDMapping + (stringType, + new String[] + { + "name", "String" + }); + + addXSDMapping + (stringsType, + new String[] + { + "name", "Strings" + }); + + addXSDMapping + (timeType, + new String[] + { + "name", "Time" + }); + + addXSDMapping + (uriType, + new String[] + { + "name", "URI" + }); + + addXSDMapping + (yearType, + new String[] + { + "name", "Year" + }); + + addXSDMapping + (yearMonthType, + new String[] + { + "name", "YearMonth" + }); + + addXSDMapping + (yearMonthDayType, + new String[] + { + "name", "YearMonthDay" + }); + + } + + /** + * + * + * @generated NOT + */ + public Boolean createBooleanFromString(String initialValue) + { + return XMLTypeFactory.eINSTANCE.createBooleanObject(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertBooleanToString(Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertBooleanObject((Boolean)instanceValue); + } + + /** + * + * + * @generated NOT + */ + public Boolean createBooleanObjectFromString(String initialValue) + { + return (Boolean)createBooleanFromString(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertBooleanObjectToString(Object instanceValue) + { + return convertBooleanToString(instanceValue); + } + + /** + * + * + * @generated NOT + */ + public Byte createByteFromString(String initialValue) + { + return XMLTypeFactory.eINSTANCE.createByteObject(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertByteToString(Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertByteObject((Byte)instanceValue); + } + + /** + * + * + * @generated NOT + */ + public Byte createByteObjectFromString(String initialValue) + { + return (Byte)createByteFromString(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertByteObjectToString(Object instanceValue) + { + return convertByteToString(instanceValue); + } + + /** + * + * + * @generated NOT + */ + public byte[] createBytesFromString(String initialValue) + { + return XMLTypeFactory.eINSTANCE.createHexBinary(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertBytesToString(Object instanceValue) + { + if (instanceValue instanceof byte[]) { + return XMLTypeFactory.eINSTANCE.convertHexBinary((byte[])instanceValue); + } else { + return XMLTypeFactory.eINSTANCE.convertHexBinary(instanceValue.toString().getBytes()); + } + } + + /** + * + * + * @generated NOT + */ + public ChangeSummary createChangeSummaryTypeFromString(String initialValue) + { + return null; + } + + /** + * + * + * @generated NOT + */ + public String convertChangeSummaryTypeToString(Object instanceValue) + { + return "change summary serialization goes here ..."; + } + + /** + * + * + * @generated NOT + */ + public Character createCharacterFromString(String initialValue) + { + return (initialValue == null && initialValue.length() > 0) + ? null : (new Character(XMLTypeUtil.normalize(initialValue, true).charAt(0))); + } + + /** + * + * + * @generated NOT + */ + public String convertCharacterToString(Object instanceValue) + { + return String.valueOf(((Character)instanceValue).charValue()); + } + + /** + * + * + * @generated NOT + */ + public Character createCharacterObjectFromString(String initialValue) + { + return (Character)createCharacterFromString(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertCharacterObjectToString(Object instanceValue) + { + return convertCharacterToString(instanceValue); + } + + /** + * + * + * @generated NOT + */ + public Date createDateFromString(String initialValue) + { + // XMLCalendar cal = (XMLCalendar) XMLTypeFactory.eINSTANCE.createDate(initialValue); + // return (cal != null) ? cal.getDate() : null; + return DataHelper.INSTANCE.toDate(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertDateToString(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); + } + + /** + * + * + * @generated NOT + */ + public String createDateTimeFromString(String initialValue) + { + return initialValue; + } + + /** + * + * + * @generated NOT + */ + public String convertDateTimeToString(Object instanceValue) + { + return (String)instanceValue; + } + + /** + * + * + * @generated NOT + */ + public String createDayFromString(String initialValue) + { + return initialValue; + } + + /** + * + * + * @generated NOT + */ + public String convertDayToString(Object instanceValue) + { + return (String)instanceValue; + } + + /** + * + * + * @generated NOT + */ + public BigDecimal createDecimalFromString(String initialValue) + { + return XMLTypeFactory.eINSTANCE.createDecimal(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertDecimalToString(Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertDecimal((BigDecimal)instanceValue); + } + + /** + * + * + * @generated NOT + */ + public Double createDoubleFromString(String initialValue) + { + return XMLTypeFactory.eINSTANCE.createDoubleObject(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertDoubleToString(Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertDoubleObject((Double)instanceValue); + } + + /** + * + * + * @generated NOT + */ + public Double createDoubleObjectFromString(String initialValue) + { + return (Double)createDoubleFromString(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertDoubleObjectToString(Object instanceValue) + { + return convertDoubleToString(instanceValue); + } + + /** + * + * + * @generated NOT + */ + public String createDurationFromString(String initialValue) + { + return initialValue; + } + + /** + * + * + * @generated NOT + */ + public String convertDurationToString(Object instanceValue) + { + return (String)instanceValue; + } + + /** + * + * + * @generated NOT + */ + public Float createFloatFromString(String initialValue) + { + return XMLTypeFactory.eINSTANCE.createFloatObject(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertFloatToString(Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertFloatObject((Float)instanceValue); + } + + /** + * + * + * @generated NOT + */ + public Float createFloatObjectFromString(String initialValue) + { + return (Float)createFloatFromString(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertFloatObjectToString(Object instanceValue) + { + return convertFloatToString(instanceValue); + } + + /** + * + * + * @generated NOT + */ + public Integer createIntFromString(String initialValue) + { + return XMLTypeFactory.eINSTANCE.createIntObject(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertIntToString(Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertIntObject((Integer)instanceValue); + } + + /** + * + * + * @generated NOT + */ + public BigInteger createIntegerFromString(String initialValue) + { + return XMLTypeFactory.eINSTANCE.createInteger(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertIntegerToString(Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertInteger((BigInteger)instanceValue); + } + + /** + * + * + * @generated NOT + */ + public Integer createIntObjectFromString(String initialValue) + { + return (Integer)createIntFromString(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertIntObjectToString(Object instanceValue) + { + return convertIntToString(instanceValue); + } + + /** + * + * + * @generated NOT + */ + public Long createLongFromString(String initialValue) + { + return XMLTypeFactory.eINSTANCE.createLongObject(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertLongToString(Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertLongObject((Long)instanceValue); + } + + /** + * + * + * @generated NOT + */ + public Long createLongObjectFromString(String initialValue) + { + return (Long)createLongFromString(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertLongObjectToString(Object instanceValue) + { + return convertLongToString(instanceValue); + } + + /** + * + * + * @generated NOT + */ + public String createMonthFromString(String initialValue) + { + return initialValue; + } + + /** + * + * + * @generated NOT + */ + public String convertMonthToString(Object instanceValue) + { + return (String)instanceValue; + } + + /** + * + * + * @generated NOT + */ + public String createMonthDayFromString(String initialValue) + { + return initialValue; + } + + /** + * + * + * @generated NOT + */ + public String convertMonthDayToString(Object instanceValue) + { + return (String)instanceValue; + } + + /** + * + * + * @generated NOT + */ + public Object createObjectFromString(String initialValue) + { + return initialValue; + } + + /** + * + * + * @generated NOT + */ + public String convertObjectToString(Object instanceValue) + { + return (instanceValue != null) ? instanceValue.toString() : null; + } + + /** + * + * + * @generated NOT + */ + public Short createShortFromString(String initialValue) + { + return XMLTypeFactory.eINSTANCE.createShortObject(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertShortToString(Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertShortObject((Short)instanceValue); + } + + /** + * + * + * @generated NOT + */ + public Short createShortObjectFromString(String initialValue) + { + return (Short)createShortFromString(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertShortObjectToString(Object instanceValue) + { + return convertShortToString(instanceValue); + } + + /** + * + * + * @generated NOT + */ + public String createStringFromString(String initialValue) + { + return initialValue; + } + + /** + * + * + * @generated NOT + */ + public String convertStringToString(Object instanceValue) + { + return (instanceValue != null) ? instanceValue.toString() : null; + } + + /** + * + * + * @generated NOT + */ + public List createStringsFromString(String initialValue) + { + return XMLTypeFactory.eINSTANCE.createENTITIES(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertStringsToString(Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertENTITIES((List)instanceValue); + } + + /** + * + * + * @generated NOT + */ + public String createTimeFromString(String initialValue) + { + return initialValue; + } + + /** + * + * + * @generated NOT + */ + public String convertTimeToString(Object instanceValue) + { + return (String)instanceValue; + } + + /** + * + * + * @generated NOT + */ + public String createURIFromString(String initialValue) + { + return initialValue; + } + + /** + * + * + * @generated NOT + */ + public String convertURIToString(Object instanceValue) + { + return (instanceValue != null) ? instanceValue.toString() : null; + } + + /** + * + * + * @generated NOT + */ + public String createYearFromString(String initialValue) + { + return initialValue; + } + + /** + * + * + * @generated NOT + */ + public String convertYearToString(Object instanceValue) + { + return (String)instanceValue; + } + + /** + * + * + * @generated NOT + */ + public String createYearMonthFromString(String initialValue) + { + return initialValue; + } + + /** + * + * + * @generated NOT + */ + public String convertYearMonthToString(Object instanceValue) + { + return (String)instanceValue; + } + + /** + * + * + * @generated NOT + */ + public String createYearMonthDayFromString(String initialValue) + { + return initialValue; + } + + /** + * + * + * @generated NOT + */ + public String convertYearMonthDayToString(Object instanceValue) + { + return (String)instanceValue; + } + + + +} //ModelFactoryImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ModelsTypeImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ModelsTypeImpl.java new file mode 100644 index 0000000000..df043a0d10 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/ModelsTypeImpl.java @@ -0,0 +1,220 @@ +/** + * + * 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 commonj.sdo.Type; + +import org.apache.tuscany.sdo.impl.DataObjectBase; + +import org.apache.tuscany.sdo.model.ModelFactory; +import org.apache.tuscany.sdo.model.ModelsType; + +/** + * + * An implementation of the model object 'Models Type'. + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.apache.tuscany.sdo.model.impl.ModelsTypeImpl#getAny Any}
  • + *
+ *

+ * + * @generated + */ +public class ModelsTypeImpl extends DataObjectBase implements ModelsType +{ + + public final static int ANY = -1; + + public final static int SDO_PROPERTY_COUNT = 0; + + public final static int EXTENDED_PROPERTY_COUNT = -1; + + + /** + * The internal feature id for the 'Any' attribute list. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_ANY = 0; + + /** + * The number of properties for this type. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_PROPERTY_COUNT = 1; + + protected int internalConvertIndex(int internalIndex) + { + switch (internalIndex) + { + case INTERNAL_ANY: return ANY; + } + return super.internalConvertIndex(internalIndex); + } + + + /** + * The cached value of the '{@link #getAny() Any}' attribute list. + * + * + * @see #getAny() + * @generated + * @ordered + */ + + protected Sequence any = null; + + /** + * + * + * @generated + */ + public ModelsTypeImpl() + { + super(); + } + + /** + * + * + * @generated + */ + public Type getStaticType() + { + return ((ModelFactoryImpl)ModelFactory.INSTANCE).getModelsType(); + } + + /** + * + * + * @generated + */ + public Sequence getAny() + { + if (any == null) + { + any = createSequence(INTERNAL_ANY); + } + return any; + } + /** + * + * + * @generated + */ + public ChangeContext inverseRemove(Object otherEnd, int propertyIndex, ChangeContext changeContext) + { + switch (propertyIndex) + { + case ANY: + return removeFromSequence(getAny(), otherEnd, changeContext); + } + return super.inverseRemove(otherEnd, propertyIndex, changeContext); + } + + /** + * + * + * @generated + */ + public Object get(int propertyIndex, boolean resolve) + { + switch (propertyIndex) + { + case ANY: + // XXX query introduce coreType as an argument? -- semantic = if true -- coreType - return the core EMF object if value is a non-EMF wrapper/view + //if (coreType) + return getAny(); + } + return super.get(propertyIndex, resolve); + } + + /** + * + * + * @generated + */ + public void set(int propertyIndex, Object newValue) + { + switch (propertyIndex) + { + case ANY: + setSequence(getAny(), newValue); + return; + } + super.set(propertyIndex, newValue); + } + + /** + * + * + * @generated + */ + public void unset(int propertyIndex) + { + switch (propertyIndex) + { + case ANY: + unsetSequence(getAny()); + return; + } + super.unset(propertyIndex); + } + + /** + * + * + * @generated + */ + public boolean isSet(int propertyIndex) + { + switch (propertyIndex) + { + case ANY: + return any != null && !isSequenceEmpty(getAny()); + } + return super.isSet(propertyIndex); + } + + /** + * + * + * @generated + */ + public String toString() + { + if (isProxy(this)) 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/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/PropertyImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/PropertyImpl.java new file mode 100644 index 0000000000..c8348ded2d --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/PropertyImpl.java @@ -0,0 +1,1170 @@ +/** + * + * 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.DataObjectBase; + +import org.apache.tuscany.sdo.model.ModelFactory; +import org.apache.tuscany.sdo.model.Property; +import org.apache.tuscany.sdo.model.Type; + +/** + * + * An implementation of the model object 'Property'. + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.apache.tuscany.sdo.model.impl.PropertyImpl#getAliasName Alias Name}
  • + *
  • {@link org.apache.tuscany.sdo.model.impl.PropertyImpl#getAny Any}
  • + *
  • {@link org.apache.tuscany.sdo.model.impl.PropertyImpl#getName Name}
  • + *
  • {@link org.apache.tuscany.sdo.model.impl.PropertyImpl#isMany Many}
  • + *
  • {@link org.apache.tuscany.sdo.model.impl.PropertyImpl#isContainment Containment}
  • + *
  • {@link org.apache.tuscany.sdo.model.impl.PropertyImpl#getDefault Default}
  • + *
  • {@link org.apache.tuscany.sdo.model.impl.PropertyImpl#isReadOnly Read Only}
  • + *
  • {@link org.apache.tuscany.sdo.model.impl.PropertyImpl#getType_ Type}
  • + *
  • {@link org.apache.tuscany.sdo.model.impl.PropertyImpl#getOpposite Opposite}
  • + *
  • {@link org.apache.tuscany.sdo.model.impl.PropertyImpl#isNullable Nullable}
  • + *
  • {@link org.apache.tuscany.sdo.model.impl.PropertyImpl#getAnyAttribute Any Attribute}
  • + *
+ *

+ * + * @generated + */ +public class PropertyImpl extends DataObjectBase implements Property +{ + + public final static int ALIAS_NAME = 0; + + public final static int ANY = -1; + + public final static int NAME = 1; + + public final static int MANY = 2; + + public final static int CONTAINMENT = 3; + + public final static int DEFAULT = 4; + + public final static int READ_ONLY = 5; + + public final static int TYPE = 6; + + public final static int OPPOSITE = 7; + + public final static int NULLABLE = 8; + + public final static int ANY_ATTRIBUTE = -2; + + public final static int SDO_PROPERTY_COUNT = 9; + + public final static int EXTENDED_PROPERTY_COUNT = -2; + + + /** + * The internal feature id for the 'Alias Name' attribute list. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_ALIAS_NAME = 0; + + /** + * The internal feature id for the 'Any' attribute list. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_ANY = 1; + + /** + * The internal feature id for the 'Name' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_NAME = 2; + + /** + * The internal feature id for the 'Many' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_MANY = 3; + + /** + * The internal feature id for the 'Containment' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_CONTAINMENT = 4; + + /** + * The internal feature id for the 'Default' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_DEFAULT = 5; + + /** + * The internal feature id for the 'Read Only' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_READ_ONLY = 6; + + /** + * The internal feature id for the 'Type' reference. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_TYPE = 7; + + /** + * The internal feature id for the 'Opposite' reference. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_OPPOSITE = 8; + + /** + * The internal feature id for the 'Nullable' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_NULLABLE = 9; + + /** + * The internal feature id for the 'Any Attribute' attribute list. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_ANY_ATTRIBUTE = 10; + + /** + * The number of properties for this type. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_PROPERTY_COUNT = 11; + + protected int internalConvertIndex(int internalIndex) + { + switch (internalIndex) + { + case INTERNAL_ALIAS_NAME: return ALIAS_NAME; + case INTERNAL_ANY: return ANY; + case INTERNAL_NAME: return NAME; + case INTERNAL_MANY: return MANY; + case INTERNAL_CONTAINMENT: return CONTAINMENT; + case INTERNAL_DEFAULT: return DEFAULT; + case INTERNAL_READ_ONLY: return READ_ONLY; + case INTERNAL_TYPE: return TYPE; + case INTERNAL_OPPOSITE: return OPPOSITE; + case INTERNAL_NULLABLE: return NULLABLE; + case INTERNAL_ANY_ATTRIBUTE: return ANY_ATTRIBUTE; + } + return super.internalConvertIndex(internalIndex); + } + + + /** + * The cached value of the '{@link #getAliasName() Alias Name}' attribute list. + * + * + * @see #getAliasName() + * @generated + * @ordered + */ + + protected List aliasName = null; + + /** + * The cached value of the '{@link #getAny() Any}' attribute list. + * + * + * @see #getAny() + * @generated + * @ordered + */ + + protected Sequence any = null; + + /** + * The default value of the '{@link #getName() Name}' attribute. + * + * + * @see #getName() + * @generated + * @ordered + */ + protected static final String NAME_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getName() Name}' attribute. + * + * + * @see #getName() + * @generated + * @ordered + */ + protected String name = NAME_DEFAULT_; + + /** + * This is true if the Name attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean name_set_ = false; + + /** + * The default value of the '{@link #isMany() Many}' attribute. + * + * + * @see #isMany() + * @generated + * @ordered + */ + protected static final boolean MANY_DEFAULT_ = false; + + /** + * The cached value of the '{@link #isMany() Many}' attribute. + * + * + * @see #isMany() + * @generated + * @ordered + */ + protected boolean many = MANY_DEFAULT_; + + /** + * This is true if the Many attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean many_set_ = false; + + /** + * The default value of the '{@link #isContainment() Containment}' attribute. + * + * + * @see #isContainment() + * @generated + * @ordered + */ + protected static final boolean CONTAINMENT_DEFAULT_ = false; + + /** + * The cached value of the '{@link #isContainment() Containment}' attribute. + * + * + * @see #isContainment() + * @generated + * @ordered + */ + protected boolean containment = CONTAINMENT_DEFAULT_; + + /** + * This is true if the Containment attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean containment_set_ = false; + + /** + * The default value of the '{@link #getDefault_() Default}' attribute. + * + * + * @see #getDefault_() + * @generated + * @ordered + */ + protected static final String DEFAULT_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getDefault_() Default}' attribute. + * + * + * @see #getDefault_() + * @generated + * @ordered + */ + protected String default_ = DEFAULT_DEFAULT_; + + /** + * This is true if the Default attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean default_set_ = false; + + /** + * The default value of the '{@link #isReadOnly() Read Only}' attribute. + * + * + * @see #isReadOnly() + * @generated + * @ordered + */ + protected static final boolean READ_ONLY_DEFAULT_ = false; + + /** + * The cached value of the '{@link #isReadOnly() Read Only}' attribute. + * + * + * @see #isReadOnly() + * @generated + * @ordered + */ + protected boolean readOnly = READ_ONLY_DEFAULT_; + + /** + * This is true if the Read Only attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean readOnly_set_ = false; + + /** + * The cached value of the '{@link #getType_() Type}' reference. + * + * + * @see #getType_() + * @generated + * @ordered + */ + + protected Type type = null; + + /** + * This is true if the Type reference has been set. + * + * + * @generated + * @ordered + */ + protected boolean type_set_ = false; + + /** + * The cached value of the '{@link #getOpposite_() Opposite}' reference. + * + * + * @see #getOpposite_() + * @generated + * @ordered + */ + + protected Property opposite = null; + + /** + * This is true if the Opposite reference has been set. + * + * + * @generated + * @ordered + */ + protected boolean opposite_set_ = false; + + /** + * The default value of the '{@link #isNullable() Nullable}' attribute. + * + * + * @see #isNullable() + * @generated + * @ordered + */ + protected static final boolean NULLABLE_DEFAULT_ = false; + + /** + * The cached value of the '{@link #isNullable() Nullable}' attribute. + * + * + * @see #isNullable() + * @generated + * @ordered + */ + protected boolean nullable = NULLABLE_DEFAULT_; + + /** + * This is true if the Nullable attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean nullable_set_ = false; + + /** + * The cached value of the '{@link #getAnyAttribute() Any Attribute}' attribute list. + * + * + * @see #getAnyAttribute() + * @generated + * @ordered + */ + + protected Sequence anyAttribute = null; + + /** + * + * + * @generated + */ + public PropertyImpl() + { + super(); + } + + /** + * + * + * @generated + */ + public commonj.sdo.Type getStaticType() + { + return ((ModelFactoryImpl)ModelFactory.INSTANCE).getProperty(); + } + + /** + * + * + * @generated + */ + public List getAliasName() + { + if (aliasName == null) + { + aliasName = createPropertyList(ListKind.DATATYPE, String.class, ALIAS_NAME, 0); + } + return aliasName; + } + /** + * + * + * @generated + */ + public Sequence getAny() + { + if (any == null) + { + any = createSequence(INTERNAL_ANY); + } + return any; + } + /** + * + * + * @generated + */ + public String getName() + { + return name; + } + /** + * + * + * @generated + */ + public void setName(String newName) + { + String oldName = name; + name = newName; + boolean oldName_set_ = name_set_; + name_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INTERNAL_NAME, oldName, name, !oldName_set_); + } + + /** + * + * + * @generated + */ + public void unsetName() + { + String oldName = name; + boolean oldName_set_ = name_set_; + name = NAME_DEFAULT_; + name_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INTERNAL_NAME, oldName, NAME_DEFAULT_, oldName_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetName() + { + return name_set_; + } + + /** + * + * + * @generated + */ + public boolean isMany() + { + return many; + } + /** + * + * + * @generated + */ + public void setMany(boolean newMany) + { + boolean oldMany = many; + many = newMany; + boolean oldMany_set_ = many_set_; + many_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INTERNAL_MANY, oldMany, many, !oldMany_set_); + } + + /** + * + * + * @generated + */ + public void unsetMany() + { + boolean oldMany = many; + boolean oldMany_set_ = many_set_; + many = MANY_DEFAULT_; + many_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INTERNAL_MANY, oldMany, MANY_DEFAULT_, oldMany_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetMany() + { + return many_set_; + } + + /** + * + * + * @generated + */ + public boolean isContainment() + { + return containment; + } + /** + * + * + * @generated + */ + public void setContainment(boolean newContainment) + { + boolean oldContainment = containment; + containment = newContainment; + boolean oldContainment_set_ = containment_set_; + containment_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INTERNAL_CONTAINMENT, oldContainment, containment, !oldContainment_set_); + } + + /** + * + * + * @generated + */ + public void unsetContainment() + { + boolean oldContainment = containment; + boolean oldContainment_set_ = containment_set_; + containment = CONTAINMENT_DEFAULT_; + containment_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INTERNAL_CONTAINMENT, oldContainment, CONTAINMENT_DEFAULT_, oldContainment_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetContainment() + { + return containment_set_; + } + + /** + * + * + * @generated + */ + public String getDefault_() + { + return default_; + } + /** + * + * + * @generated + */ + public void setDefault_(String newDefault) + { + String oldDefault = default_; + default_ = newDefault; + boolean oldDefault_set_ = default_set_; + default_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INTERNAL_DEFAULT, oldDefault, default_, !oldDefault_set_); + } + + /** + * + * + * @generated + */ + public void unsetDefault() + { + String oldDefault = default_; + boolean oldDefault_set_ = default_set_; + default_ = DEFAULT_DEFAULT_; + default_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INTERNAL_DEFAULT, oldDefault, DEFAULT_DEFAULT_, oldDefault_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetDefault() + { + return default_set_; + } + + /** + * + * + * @generated + */ + public boolean isReadOnly() + { + return readOnly; + } + /** + * + * + * @generated + */ + public void setReadOnly(boolean newReadOnly) + { + boolean oldReadOnly = readOnly; + readOnly = newReadOnly; + boolean oldReadOnly_set_ = readOnly_set_; + readOnly_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INTERNAL_READ_ONLY, oldReadOnly, readOnly, !oldReadOnly_set_); + } + + /** + * + * + * @generated + */ + public void unsetReadOnly() + { + boolean oldReadOnly = readOnly; + boolean oldReadOnly_set_ = readOnly_set_; + readOnly = READ_ONLY_DEFAULT_; + readOnly_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INTERNAL_READ_ONLY, oldReadOnly, READ_ONLY_DEFAULT_, oldReadOnly_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetReadOnly() + { + return readOnly_set_; + } + + /** + * + * + * @generated + */ + public Type getType_() + { + if (type != null && isProxy(type)) + { + Object oldType = type; + type = (Type)resolveProxy(oldType); + if (type != oldType) + { + if (isNotifying()) + notify(ChangeKind.RESOLVE, INTERNAL_TYPE, oldType, type); + } + } + return type; + } + /** + * + * + * @generated + */ + public Type basicGetType() + { + return type; + } + + /** + * + * + * @generated + */ + public void setType(Type newType) + { + Type oldType = type; + type = newType; + boolean oldType_set_ = type_set_; + type_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INTERNAL_TYPE, oldType, type, !oldType_set_); + } + + /** + * + * + * @generated + */ + public void unsetType() + { + Type oldType = type; + boolean oldType_set_ = type_set_; + type = null; + type_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INTERNAL_TYPE, oldType, null, oldType_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetType() + { + return type_set_; + } + + /** + * + * + * @generated + */ + public Property getOpposite_() + { + if (opposite != null && isProxy(opposite)) + { + Object oldOpposite = opposite; + opposite = (Property)resolveProxy(oldOpposite); + if (opposite != oldOpposite) + { + if (isNotifying()) + notify(ChangeKind.RESOLVE, INTERNAL_OPPOSITE, oldOpposite, opposite); + } + } + return opposite; + } + /** + * + * + * @generated + */ + public Property basicGetOpposite() + { + return opposite; + } + + /** + * + * + * @generated + */ + public void setOpposite_(Property newOpposite) + { + Property oldOpposite = opposite; + opposite = newOpposite; + boolean oldOpposite_set_ = opposite_set_; + opposite_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INTERNAL_OPPOSITE, oldOpposite, opposite, !oldOpposite_set_); + } + + /** + * + * + * @generated + */ + public void unsetOpposite() + { + Property oldOpposite = opposite; + boolean oldOpposite_set_ = opposite_set_; + opposite = null; + opposite_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INTERNAL_OPPOSITE, oldOpposite, null, oldOpposite_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetOpposite() + { + return opposite_set_; + } + + /** + * + * + * @generated + */ + public boolean isNullable() + { + return nullable; + } + /** + * + * + * @generated + */ + public void setNullable(boolean newNullable) + { + boolean oldNullable = nullable; + nullable = newNullable; + boolean oldNullable_set_ = nullable_set_; + nullable_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INTERNAL_NULLABLE, oldNullable, nullable, !oldNullable_set_); + } + + /** + * + * + * @generated + */ + public void unsetNullable() + { + boolean oldNullable = nullable; + boolean oldNullable_set_ = nullable_set_; + nullable = NULLABLE_DEFAULT_; + nullable_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INTERNAL_NULLABLE, oldNullable, NULLABLE_DEFAULT_, oldNullable_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetNullable() + { + return nullable_set_; + } + + /** + * + * + * @generated + */ + public Sequence getAnyAttribute() + { + if (anyAttribute == null) + { + anyAttribute = createSequence(INTERNAL_ANY_ATTRIBUTE); + } + return anyAttribute; + } + /** + * + * + * @generated + */ + public ChangeContext inverseRemove(Object otherEnd, int propertyIndex, ChangeContext changeContext) + { + switch (propertyIndex) + { + case ANY: + return removeFromSequence(getAny(), otherEnd, changeContext); + case ANY_ATTRIBUTE: + return removeFromSequence(getAnyAttribute(), otherEnd, changeContext); + } + return super.inverseRemove(otherEnd, propertyIndex, changeContext); + } + + /** + * + * + * @generated + */ + public Object get(int propertyIndex, boolean resolve) + { + switch (propertyIndex) + { + case ALIAS_NAME: + return getAliasName(); + case ANY: + // XXX query introduce coreType as an argument? -- semantic = if true -- coreType - return the core EMF object if value is a non-EMF wrapper/view + //if (coreType) + return getAny(); + case NAME: + return getName(); + case MANY: + return isMany() ? Boolean.TRUE : Boolean.FALSE; + case CONTAINMENT: + return isContainment() ? Boolean.TRUE : Boolean.FALSE; + case DEFAULT: + return getDefault_(); + case READ_ONLY: + return isReadOnly() ? Boolean.TRUE : Boolean.FALSE; + case TYPE: + if (resolve) return getType_(); + return basicGetType(); + case OPPOSITE: + if (resolve) return getOpposite_(); + return basicGetOpposite(); + case NULLABLE: + return isNullable() ? Boolean.TRUE : Boolean.FALSE; + case ANY_ATTRIBUTE: + // XXX query introduce coreType as an argument? -- semantic = if true -- coreType - return the core EMF object if value is a non-EMF wrapper/view + //if (coreType) + return getAnyAttribute(); + } + return super.get(propertyIndex, resolve); + } + + /** + * + * + * @generated + */ + public void set(int propertyIndex, Object newValue) + { + switch (propertyIndex) + { + case ALIAS_NAME: + getAliasName().clear(); + getAliasName().addAll((Collection)newValue); + return; + case ANY: + setSequence(getAny(), newValue); + return; + case NAME: + setName((String)newValue); + return; + case MANY: + setMany(((Boolean)newValue).booleanValue()); + return; + case CONTAINMENT: + setContainment(((Boolean)newValue).booleanValue()); + return; + case DEFAULT: + setDefault_((String)newValue); + return; + case READ_ONLY: + setReadOnly(((Boolean)newValue).booleanValue()); + return; + case TYPE: + setType((Type)newValue); + return; + case OPPOSITE: + setOpposite_((Property)newValue); + return; + case NULLABLE: + setNullable(((Boolean)newValue).booleanValue()); + return; + case ANY_ATTRIBUTE: + setSequence(getAnyAttribute(), newValue); + return; + } + super.set(propertyIndex, newValue); + } + + /** + * + * + * @generated + */ + public void unset(int propertyIndex) + { + switch (propertyIndex) + { + case ALIAS_NAME: + getAliasName().clear(); + return; + case ANY: + unsetSequence(getAny()); + return; + case NAME: + unsetName(); + return; + case MANY: + unsetMany(); + return; + case CONTAINMENT: + unsetContainment(); + return; + case DEFAULT: + unsetDefault(); + return; + case READ_ONLY: + unsetReadOnly(); + return; + case TYPE: + unsetType(); + return; + case OPPOSITE: + unsetOpposite(); + return; + case NULLABLE: + unsetNullable(); + return; + case ANY_ATTRIBUTE: + unsetSequence(getAnyAttribute()); + return; + } + super.unset(propertyIndex); + } + + /** + * + * + * @generated + */ + public boolean isSet(int propertyIndex) + { + switch (propertyIndex) + { + case ALIAS_NAME: + return aliasName != null && !aliasName.isEmpty(); + case ANY: + return any != null && !isSequenceEmpty(getAny()); + case NAME: + return isSetName(); + case MANY: + return isSetMany(); + case CONTAINMENT: + return isSetContainment(); + case DEFAULT: + return isSetDefault(); + case READ_ONLY: + return isSetReadOnly(); + case TYPE: + return isSetType(); + case OPPOSITE: + return isSetOpposite(); + case NULLABLE: + return isSetNullable(); + case ANY_ATTRIBUTE: + return anyAttribute != null && !isSequenceEmpty(getAnyAttribute()); + } + return super.isSet(propertyIndex); + } + + /** + * + * + * @generated + */ + public String toString() + { + if (isProxy(this)) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (aliasName: "); + result.append(aliasName); + result.append(", any: "); + result.append(any); + result.append(", name: "); + if (name_set_) result.append(name); else result.append(""); + result.append(", many: "); + if (many_set_) result.append(many); else result.append(""); + result.append(", containment: "); + if (containment_set_) result.append(containment); else result.append(""); + result.append(", default: "); + if (default_set_) result.append(default_); else result.append(""); + result.append(", readOnly: "); + if (readOnly_set_) result.append(readOnly); else result.append(""); + result.append(", nullable: "); + if (nullable_set_) result.append(nullable); else result.append(""); + result.append(", anyAttribute: "); + result.append(anyAttribute); + result.append(')'); + return result.toString(); + } + +} //PropertyImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/TextTypeImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/TextTypeImpl.java new file mode 100644 index 0000000000..48a310b142 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/TextTypeImpl.java @@ -0,0 +1,206 @@ +/** + * + * 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.Type; + +import java.util.Collection; +import java.util.List; + +import org.apache.tuscany.sdo.impl.DataObjectBase; + +import org.apache.tuscany.sdo.model.ModelFactory; +import org.apache.tuscany.sdo.model.TextType; + +/** + * + * An implementation of the model object 'Text Type'. + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.apache.tuscany.sdo.model.impl.TextTypeImpl#getText Text}
  • + *
+ *

+ * + * @generated + */ +public abstract class TextTypeImpl extends DataObjectBase implements TextType +{ + + public final static int TEXT = 0; + + public final static int SDO_PROPERTY_COUNT = 1; + + public final static int EXTENDED_PROPERTY_COUNT = 0; + + + /** + * The internal feature id for the 'Text' attribute list. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_TEXT = 0; + + /** + * The number of properties for this type. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_PROPERTY_COUNT = 1; + + protected int internalConvertIndex(int internalIndex) + { + switch (internalIndex) + { + case INTERNAL_TEXT: return TEXT; + } + return super.internalConvertIndex(internalIndex); + } + + + /** + * The cached value of the '{@link #getText() Text}' attribute list. + * + * + * @see #getText() + * @generated + * @ordered + */ + + protected List text = null; + + /** + * + * + * @generated + */ + public TextTypeImpl() + { + super(); + } + + /** + * + * + * @generated + */ + public Type getStaticType() + { + return ((ModelFactoryImpl)ModelFactory.INSTANCE).getTextType(); + } + + /** + * + * + * @generated + */ + public List getText() + { + if (text == null) + { + text = createPropertyList(ListKind.DATATYPE, String.class, TEXT, 0); + } + return text; + } + /** + * + * + * @generated + */ + public Object get(int propertyIndex, boolean resolve) + { + switch (propertyIndex) + { + case TEXT: + return getText(); + } + return super.get(propertyIndex, resolve); + } + + /** + * + * + * @generated + */ + public void set(int propertyIndex, Object newValue) + { + switch (propertyIndex) + { + case TEXT: + getText().clear(); + getText().addAll((Collection)newValue); + return; + } + super.set(propertyIndex, newValue); + } + + /** + * + * + * @generated + */ + public void unset(int propertyIndex) + { + switch (propertyIndex) + { + case TEXT: + getText().clear(); + return; + } + super.unset(propertyIndex); + } + + /** + * + * + * @generated + */ + public boolean isSet(int propertyIndex) + { + switch (propertyIndex) + { + case TEXT: + return text != null && !text.isEmpty(); + } + return super.isSet(propertyIndex); + } + + /** + * + * + * @generated + */ + public String toString() + { + if (isProxy(this)) 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/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/TypeImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/TypeImpl.java new file mode 100644 index 0000000000..aee2ecaaab --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/TypeImpl.java @@ -0,0 +1,1068 @@ +/** + * + * 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 commonj.sdo.helper.TypeHelper; + +import java.util.Collection; +import java.util.List; + +import org.apache.tuscany.sdo.impl.DataObjectBase; + +import org.apache.tuscany.sdo.model.ModelFactory; +import org.apache.tuscany.sdo.model.Property; +import org.apache.tuscany.sdo.model.Type; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.util.BasicExtendedMetaData; + +/** + * + * An implementation of the model object 'Type'. + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.apache.tuscany.sdo.model.impl.TypeImpl#getBaseType Base Type}
  • + *
  • {@link org.apache.tuscany.sdo.model.impl.TypeImpl#getProperty Property}
  • + *
  • {@link org.apache.tuscany.sdo.model.impl.TypeImpl#getAliasName Alias Name}
  • + *
  • {@link org.apache.tuscany.sdo.model.impl.TypeImpl#getAny Any}
  • + *
  • {@link org.apache.tuscany.sdo.model.impl.TypeImpl#getName Name}
  • + *
  • {@link org.apache.tuscany.sdo.model.impl.TypeImpl#getUri Uri}
  • + *
  • {@link org.apache.tuscany.sdo.model.impl.TypeImpl#isDataType Data Type}
  • + *
  • {@link org.apache.tuscany.sdo.model.impl.TypeImpl#isOpen Open}
  • + *
  • {@link org.apache.tuscany.sdo.model.impl.TypeImpl#isSequenced Sequenced}
  • + *
  • {@link org.apache.tuscany.sdo.model.impl.TypeImpl#isAbstract Abstract}
  • + *
  • {@link org.apache.tuscany.sdo.model.impl.TypeImpl#getAnyAttribute Any Attribute}
  • + *
+ *

+ * + * @generated + */ +public class TypeImpl extends DataObjectBase implements Type +{ + + public final static int BASE_TYPE = 0; + + public final static int PROPERTY = 1; + + public final static int ALIAS_NAME = 2; + + public final static int ANY = -1; + + public final static int NAME = 3; + + public final static int URI = 4; + + public final static int DATA_TYPE = 5; + + public final static int OPEN = 6; + + public final static int SEQUENCED = 7; + + public final static int ABSTRACT = 8; + + public final static int ANY_ATTRIBUTE = -2; + + public final static int SDO_PROPERTY_COUNT = 9; + + public final static int EXTENDED_PROPERTY_COUNT = -2; + + + /** + * The internal feature id for the 'Base Type' reference list. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_BASE_TYPE = 0; + + /** + * The internal feature id for the 'Property' containment reference list. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_PROPERTY = 1; + + /** + * The internal feature id for the 'Alias Name' attribute list. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_ALIAS_NAME = 2; + + /** + * The internal feature id for the 'Any' attribute list. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_ANY = 3; + + /** + * The internal feature id for the 'Name' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_NAME = 4; + + /** + * The internal feature id for the 'Uri' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_URI = 5; + + /** + * The internal feature id for the 'Data Type' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_DATA_TYPE = 6; + + /** + * The internal feature id for the 'Open' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_OPEN = 7; + + /** + * The internal feature id for the 'Sequenced' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_SEQUENCED = 8; + + /** + * The internal feature id for the 'Abstract' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_ABSTRACT = 9; + + /** + * The internal feature id for the 'Any Attribute' attribute list. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_ANY_ATTRIBUTE = 10; + + /** + * The number of properties for this type. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_PROPERTY_COUNT = 11; + + protected int internalConvertIndex(int internalIndex) + { + switch (internalIndex) + { + case INTERNAL_BASE_TYPE: return BASE_TYPE; + case INTERNAL_PROPERTY: return PROPERTY; + case INTERNAL_ALIAS_NAME: return ALIAS_NAME; + case INTERNAL_ANY: return ANY; + case INTERNAL_NAME: return NAME; + case INTERNAL_URI: return URI; + case INTERNAL_DATA_TYPE: return DATA_TYPE; + case INTERNAL_OPEN: return OPEN; + case INTERNAL_SEQUENCED: return SEQUENCED; + case INTERNAL_ABSTRACT: return ABSTRACT; + case INTERNAL_ANY_ATTRIBUTE: return ANY_ATTRIBUTE; + } + return super.internalConvertIndex(internalIndex); + } + + + /** + * The cached value of the '{@link #getBaseType() Base Type}' reference list. + * + * + * @see #getBaseType() + * @generated + * @ordered + */ + + protected List baseType = null; + + /** + * The cached value of the '{@link #getProperty() Property}' containment reference list. + * + * + * @see #getProperty() + * @generated + * @ordered + */ + + protected List property = null; + + /** + * The cached value of the '{@link #getAliasName() Alias Name}' attribute list. + * + * + * @see #getAliasName() + * @generated + * @ordered + */ + + protected List aliasName = null; + + /** + * The cached value of the '{@link #getAny() Any}' attribute list. + * + * + * @see #getAny() + * @generated + * @ordered + */ + + protected Sequence any = null; + + /** + * The default value of the '{@link #getName() Name}' attribute. + * + * + * @see #getName() + * @generated + * @ordered + */ + protected static final String NAME_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getName() Name}' attribute. + * + * + * @see #getName() + * @generated + * @ordered + */ + protected String name = NAME_DEFAULT_; + + /** + * This is true if the Name attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean name_set_ = false; + + /** + * The default value of the '{@link #getUri() Uri}' attribute. + * + * + * @see #getUri() + * @generated + * @ordered + */ + protected static final String URI_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getUri() Uri}' attribute. + * + * + * @see #getUri() + * @generated + * @ordered + */ + protected String uri = URI_DEFAULT_; + + /** + * This is true if the Uri attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean uri_set_ = false; + + /** + * The default value of the '{@link #isDataType() Data Type}' attribute. + * + * + * @see #isDataType() + * @generated + * @ordered + */ + protected static final boolean DATA_TYPE_DEFAULT_ = false; + + /** + * The cached value of the '{@link #isDataType() Data Type}' attribute. + * + * + * @see #isDataType() + * @generated + * @ordered + */ + protected boolean dataType = DATA_TYPE_DEFAULT_; + + /** + * This is true if the Data Type attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean dataType_set_ = false; + + /** + * The default value of the '{@link #isOpen() Open}' attribute. + * + * + * @see #isOpen() + * @generated + * @ordered + */ + protected static final boolean OPEN_DEFAULT_ = false; + + /** + * The cached value of the '{@link #isOpen() Open}' attribute. + * + * + * @see #isOpen() + * @generated + * @ordered + */ + protected boolean open = OPEN_DEFAULT_; + + /** + * This is true if the Open attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean open_set_ = false; + + /** + * The default value of the '{@link #isSequenced() Sequenced}' attribute. + * + * + * @see #isSequenced() + * @generated + * @ordered + */ + protected static final boolean SEQUENCED_DEFAULT_ = false; + + /** + * The cached value of the '{@link #isSequenced() Sequenced}' attribute. + * + * + * @see #isSequenced() + * @generated + * @ordered + */ + protected boolean sequenced = SEQUENCED_DEFAULT_; + + /** + * This is true if the Sequenced attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean sequenced_set_ = false; + + /** + * The default value of the '{@link #isAbstract() Abstract}' attribute. + * + * + * @see #isAbstract() + * @generated + * @ordered + */ + protected static final boolean ABSTRACT_DEFAULT_ = false; + + /** + * The cached value of the '{@link #isAbstract() Abstract}' attribute. + * + * + * @see #isAbstract() + * @generated + * @ordered + */ + protected boolean abstract_ = ABSTRACT_DEFAULT_; + + /** + * This is true if the Abstract attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean abstract_set_ = false; + + /** + * The cached value of the '{@link #getAnyAttribute() Any Attribute}' attribute list. + * + * + * @see #getAnyAttribute() + * @generated + * @ordered + */ + + protected Sequence anyAttribute = null; + + /** + * + * + * @generated + */ + public TypeImpl() + { + super(); + } + + /** + * + * + * @generated + */ + public commonj.sdo.Type getStaticType() + { + return ((ModelFactoryImpl)ModelFactory.INSTANCE).getType(); + } + + /** + * + * + * @generated + */ + public List getBaseType() + { + if (baseType == null) + { + baseType = createPropertyList(ListKind.NONCONTAINMENT_RESOLVING, Type.class, BASE_TYPE, 0); + } + return baseType; + } + /** + * + * + * @generated + */ + public List getProperty() + { + if (property == null) + { + property = createPropertyList(ListKind.CONTAINMENT, Property.class, PROPERTY, 0); + } + return property; + } + /** + * + * + * @generated + */ + public List getAliasName() + { + if (aliasName == null) + { + aliasName = createPropertyList(ListKind.DATATYPE, String.class, ALIAS_NAME, 0); + } + return aliasName; + } + /** + * + * + * @generated + */ + public Sequence getAny() + { + if (any == null) + { + any = createSequence(INTERNAL_ANY); + } + return any; + } + /** + * + * + * @generated + */ + public String getName() + { + return name; + } + /** + * + * + * @generated + */ + public void setName(String newName) + { + String oldName = name; + name = newName; + boolean oldName_set_ = name_set_; + name_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INTERNAL_NAME, oldName, name, !oldName_set_); + } + + /** + * + * + * @generated + */ + public void unsetName() + { + String oldName = name; + boolean oldName_set_ = name_set_; + name = NAME_DEFAULT_; + name_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INTERNAL_NAME, oldName, NAME_DEFAULT_, oldName_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetName() + { + return name_set_; + } + + /** + * + * + * @generated + */ + public String getUri() + { + return uri; + } + /** + * + * + * @generated + */ + public void setUri(String newUri) + { + String oldUri = uri; + uri = newUri; + boolean oldUri_set_ = uri_set_; + uri_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INTERNAL_URI, oldUri, uri, !oldUri_set_); + } + + /** + * + * + * @generated + */ + public void unsetUri() + { + String oldUri = uri; + boolean oldUri_set_ = uri_set_; + uri = URI_DEFAULT_; + uri_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INTERNAL_URI, oldUri, URI_DEFAULT_, oldUri_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetUri() + { + return uri_set_; + } + + /** + * + * + * @generated + */ + public boolean isDataType() + { + return dataType; + } + /** + * + * + * @generated + */ + public void setDataType(boolean newDataType) + { + boolean oldDataType = dataType; + dataType = newDataType; + boolean oldDataType_set_ = dataType_set_; + dataType_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INTERNAL_DATA_TYPE, oldDataType, dataType, !oldDataType_set_); + } + + /** + * + * + * @generated + */ + public void unsetDataType() + { + boolean oldDataType = dataType; + boolean oldDataType_set_ = dataType_set_; + dataType = DATA_TYPE_DEFAULT_; + dataType_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INTERNAL_DATA_TYPE, oldDataType, DATA_TYPE_DEFAULT_, oldDataType_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetDataType() + { + return dataType_set_; + } + + /** + * + * + * @generated + */ + public boolean isOpen() + { + return open; + } + /** + * + * + * @generated + */ + public void setOpen(boolean newOpen) + { + boolean oldOpen = open; + open = newOpen; + boolean oldOpen_set_ = open_set_; + open_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INTERNAL_OPEN, oldOpen, open, !oldOpen_set_); + } + + /** + * + * + * @generated + */ + public void unsetOpen() + { + boolean oldOpen = open; + boolean oldOpen_set_ = open_set_; + open = OPEN_DEFAULT_; + open_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INTERNAL_OPEN, oldOpen, OPEN_DEFAULT_, oldOpen_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetOpen() + { + return open_set_; + } + + /** + * + * + * @generated + */ + public boolean isSequenced() + { + return sequenced; + } + /** + * + * + * @generated + */ + public void setSequenced(boolean newSequenced) + { + boolean oldSequenced = sequenced; + sequenced = newSequenced; + boolean oldSequenced_set_ = sequenced_set_; + sequenced_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INTERNAL_SEQUENCED, oldSequenced, sequenced, !oldSequenced_set_); + } + + /** + * + * + * @generated + */ + public void unsetSequenced() + { + boolean oldSequenced = sequenced; + boolean oldSequenced_set_ = sequenced_set_; + sequenced = SEQUENCED_DEFAULT_; + sequenced_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INTERNAL_SEQUENCED, oldSequenced, SEQUENCED_DEFAULT_, oldSequenced_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetSequenced() + { + return sequenced_set_; + } + + /** + * + * + * @generated + */ + public boolean isAbstract() + { + return abstract_; + } + /** + * + * + * @generated + */ + public void setAbstract(boolean newAbstract) + { + boolean oldAbstract = abstract_; + abstract_ = newAbstract; + boolean oldAbstract_set_ = abstract_set_; + abstract_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INTERNAL_ABSTRACT, oldAbstract, abstract_, !oldAbstract_set_); + } + + /** + * + * + * @generated + */ + public void unsetAbstract() + { + boolean oldAbstract = abstract_; + boolean oldAbstract_set_ = abstract_set_; + abstract_ = ABSTRACT_DEFAULT_; + abstract_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INTERNAL_ABSTRACT, oldAbstract, ABSTRACT_DEFAULT_, oldAbstract_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetAbstract() + { + return abstract_set_; + } + + /** + * + * + * @generated + */ + public Sequence getAnyAttribute() + { + if (anyAttribute == null) + { + anyAttribute = createSequence(INTERNAL_ANY_ATTRIBUTE); + } + return anyAttribute; + } + /** + * + * + * @generated + */ + public ChangeContext inverseRemove(Object otherEnd, int propertyIndex, ChangeContext changeContext) + { + switch (propertyIndex) + { + case PROPERTY: + return removeFromList(getProperty(), otherEnd, changeContext); + case ANY: + return removeFromSequence(getAny(), otherEnd, changeContext); + case ANY_ATTRIBUTE: + return removeFromSequence(getAnyAttribute(), otherEnd, changeContext); + } + return super.inverseRemove(otherEnd, propertyIndex, changeContext); + } + + /** + * + * + * @generated + */ + public Object get(int propertyIndex, boolean resolve) + { + switch (propertyIndex) + { + case BASE_TYPE: + return getBaseType(); + case PROPERTY: + return getProperty(); + case ALIAS_NAME: + return getAliasName(); + case ANY: + // XXX query introduce coreType as an argument? -- semantic = if true -- coreType - return the core EMF object if value is a non-EMF wrapper/view + //if (coreType) + return getAny(); + case NAME: + return getName(); + case URI: + return getUri(); + case DATA_TYPE: + return isDataType() ? Boolean.TRUE : Boolean.FALSE; + case OPEN: + return isOpen() ? Boolean.TRUE : Boolean.FALSE; + case SEQUENCED: + return isSequenced() ? Boolean.TRUE : Boolean.FALSE; + case ABSTRACT: + return isAbstract() ? Boolean.TRUE : Boolean.FALSE; + case ANY_ATTRIBUTE: + // XXX query introduce coreType as an argument? -- semantic = if true -- coreType - return the core EMF object if value is a non-EMF wrapper/view + //if (coreType) + return getAnyAttribute(); + } + return super.get(propertyIndex, resolve); + } + + /** + * + * + * @generated + */ + public void set(int propertyIndex, Object newValue) + { + switch (propertyIndex) + { + case BASE_TYPE: + getBaseType().clear(); + getBaseType().addAll((Collection)newValue); + return; + case PROPERTY: + getProperty().clear(); + getProperty().addAll((Collection)newValue); + return; + case ALIAS_NAME: + getAliasName().clear(); + getAliasName().addAll((Collection)newValue); + return; + case ANY: + setSequence(getAny(), newValue); + return; + case NAME: + setName((String)newValue); + return; + case URI: + setUri((String)newValue); + return; + case DATA_TYPE: + setDataType(((Boolean)newValue).booleanValue()); + return; + case OPEN: + setOpen(((Boolean)newValue).booleanValue()); + return; + case SEQUENCED: + setSequenced(((Boolean)newValue).booleanValue()); + return; + case ABSTRACT: + setAbstract(((Boolean)newValue).booleanValue()); + return; + case ANY_ATTRIBUTE: + setSequence(getAnyAttribute(), newValue); + return; + } + super.set(propertyIndex, newValue); + } + + /** + * + * + * @generated + */ + public void unset(int propertyIndex) + { + switch (propertyIndex) + { + case BASE_TYPE: + getBaseType().clear(); + return; + case PROPERTY: + getProperty().clear(); + return; + case ALIAS_NAME: + getAliasName().clear(); + return; + case ANY: + unsetSequence(getAny()); + return; + case NAME: + unsetName(); + return; + case URI: + unsetUri(); + return; + case DATA_TYPE: + unsetDataType(); + return; + case OPEN: + unsetOpen(); + return; + case SEQUENCED: + unsetSequenced(); + return; + case ABSTRACT: + unsetAbstract(); + return; + case ANY_ATTRIBUTE: + unsetSequence(getAnyAttribute()); + return; + } + super.unset(propertyIndex); + } + + /** + * + * + * @generated + */ + public boolean isSet(int propertyIndex) + { + switch (propertyIndex) + { + case BASE_TYPE: + return baseType != null && !baseType.isEmpty(); + case PROPERTY: + return property != null && !property.isEmpty(); + case ALIAS_NAME: + return aliasName != null && !aliasName.isEmpty(); + case ANY: + return any != null && !isSequenceEmpty(getAny()); + case NAME: + return isSetName(); + case URI: + return isSetUri(); + case DATA_TYPE: + return isSetDataType(); + case OPEN: + return isSetOpen(); + case SEQUENCED: + return isSetSequenced(); + case ABSTRACT: + return isSetAbstract(); + case ANY_ATTRIBUTE: + return anyAttribute != null && !isSequenceEmpty(getAnyAttribute()); + } + return super.isSet(propertyIndex); + } + + /** + * + * + * @generated + */ + public String toString() + { + if (isProxy(this)) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (aliasName: "); + result.append(aliasName); + result.append(", any: "); + result.append(any); + result.append(", name: "); + if (name_set_) result.append(name); else result.append(""); + result.append(", uri: "); + if (uri_set_) result.append(uri); else result.append(""); + result.append(", dataType: "); + if (dataType_set_) result.append(dataType); else result.append(""); + result.append(", open: "); + if (open_set_) result.append(open); else result.append(""); + result.append(", sequenced: "); + if (sequenced_set_) result.append(sequenced); else result.append(""); + result.append(", abstract: "); + if (abstract_set_) result.append(abstract_); else result.append(""); + result.append(", anyAttribute: "); + result.append(anyAttribute); + result.append(')'); + return result.toString(); + } + +EStructuralFeature javaClassFeature = null; + +public String getInstanceClassName() + { + if (javaClassFeature == null) + { + //FB TODO figure out what helper to use + javaClassFeature = (EStructuralFeature)TypeHelper.INSTANCE.getOpenContentProperty("commonj.sdo/java", "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/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/TypesImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/TypesImpl.java new file mode 100644 index 0000000000..80945b289a --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/TypesImpl.java @@ -0,0 +1,210 @@ +/** + * + * 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.Type; + +import java.util.Collection; +import java.util.List; + +import org.apache.tuscany.sdo.impl.DataObjectBase; + +import org.apache.tuscany.sdo.model.ModelFactory; +import org.apache.tuscany.sdo.model.Types; + +/** + * + * An implementation of the model object 'Types'. + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.apache.tuscany.sdo.model.impl.TypesImpl#getType_ Type}
  • + *
+ *

+ * + * @generated + */ +public class TypesImpl extends DataObjectBase implements Types +{ + + public final static int TYPE = 0; + + public final static int SDO_PROPERTY_COUNT = 1; + + public final static int EXTENDED_PROPERTY_COUNT = 0; + + + /** + * The internal feature id for the 'Type' containment reference list. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_TYPE = 0; + + /** + * The number of properties for this type. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_PROPERTY_COUNT = 1; + + protected int internalConvertIndex(int internalIndex) + { + switch (internalIndex) + { + case INTERNAL_TYPE: return TYPE; + } + return super.internalConvertIndex(internalIndex); + } + + + /** + * The cached value of the '{@link #getType_() Type}' containment reference list. + * + * + * @see #getType_() + * @generated + * @ordered + */ + + protected List type = null; + + /** + * + * + * @generated + */ + public TypesImpl() + { + super(); + } + + /** + * + * + * @generated + */ + public Type getStaticType() + { + return ((ModelFactoryImpl)ModelFactory.INSTANCE).getTypes(); + } + + /** + * + * + * @generated + */ + public List getType_() + { + if (type == null) + { + type = createPropertyList(ListKind.CONTAINMENT, org.apache.tuscany.sdo.model.Type.class, TYPE, 0); + } + return type; + } + /** + * + * + * @generated + */ + public ChangeContext inverseRemove(Object otherEnd, int propertyIndex, ChangeContext changeContext) + { + switch (propertyIndex) + { + case TYPE: + return removeFromList(getType_(), otherEnd, changeContext); + } + return super.inverseRemove(otherEnd, propertyIndex, changeContext); + } + + /** + * + * + * @generated + */ + public Object get(int propertyIndex, boolean resolve) + { + switch (propertyIndex) + { + case TYPE: + return getType_(); + } + return super.get(propertyIndex, resolve); + } + + /** + * + * + * @generated + */ + public void set(int propertyIndex, Object newValue) + { + switch (propertyIndex) + { + case TYPE: + getType_().clear(); + getType_().addAll((Collection)newValue); + return; + } + super.set(propertyIndex, newValue); + } + + /** + * + * + * @generated + */ + public void unset(int propertyIndex) + { + switch (propertyIndex) + { + case TYPE: + getType_().clear(); + return; + } + super.unset(propertyIndex); + } + + /** + * + * + * @generated + */ + public boolean isSet(int propertyIndex) + { + switch (propertyIndex) + { + case TYPE: + return type != null && !type.isEmpty(); + } + return super.isSet(propertyIndex); + } + + public List getTypeList() + { + return getType_(); + } + +} //TypesImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/XSDTypeImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/XSDTypeImpl.java new file mode 100644 index 0000000000..5d0777dd1c --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/impl/XSDTypeImpl.java @@ -0,0 +1,220 @@ +/** + * + * 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 commonj.sdo.Type; + +import org.apache.tuscany.sdo.impl.DataObjectBase; + +import org.apache.tuscany.sdo.model.ModelFactory; +import org.apache.tuscany.sdo.model.XSDType; + +/** + * + * An implementation of the model object 'XSD Type'. + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.apache.tuscany.sdo.model.impl.XSDTypeImpl#getAny Any}
  • + *
+ *

+ * + * @generated + */ +public class XSDTypeImpl extends DataObjectBase implements XSDType +{ + + public final static int ANY = -1; + + public final static int SDO_PROPERTY_COUNT = 0; + + public final static int EXTENDED_PROPERTY_COUNT = -1; + + + /** + * The internal feature id for the 'Any' attribute list. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_ANY = 0; + + /** + * The number of properties for this type. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_PROPERTY_COUNT = 1; + + protected int internalConvertIndex(int internalIndex) + { + switch (internalIndex) + { + case INTERNAL_ANY: return ANY; + } + return super.internalConvertIndex(internalIndex); + } + + + /** + * The cached value of the '{@link #getAny() Any}' attribute list. + * + * + * @see #getAny() + * @generated + * @ordered + */ + + protected Sequence any = null; + + /** + * + * + * @generated + */ + public XSDTypeImpl() + { + super(); + } + + /** + * + * + * @generated + */ + public Type getStaticType() + { + return ((ModelFactoryImpl)ModelFactory.INSTANCE).getXSDType(); + } + + /** + * + * + * @generated + */ + public Sequence getAny() + { + if (any == null) + { + any = createSequence(INTERNAL_ANY); + } + return any; + } + /** + * + * + * @generated + */ + public ChangeContext inverseRemove(Object otherEnd, int propertyIndex, ChangeContext changeContext) + { + switch (propertyIndex) + { + case ANY: + return removeFromSequence(getAny(), otherEnd, changeContext); + } + return super.inverseRemove(otherEnd, propertyIndex, changeContext); + } + + /** + * + * + * @generated + */ + public Object get(int propertyIndex, boolean resolve) + { + switch (propertyIndex) + { + case ANY: + // XXX query introduce coreType as an argument? -- semantic = if true -- coreType - return the core EMF object if value is a non-EMF wrapper/view + //if (coreType) + return getAny(); + } + return super.get(propertyIndex, resolve); + } + + /** + * + * + * @generated + */ + public void set(int propertyIndex, Object newValue) + { + switch (propertyIndex) + { + case ANY: + setSequence(getAny(), newValue); + return; + } + super.set(propertyIndex, newValue); + } + + /** + * + * + * @generated + */ + public void unset(int propertyIndex) + { + switch (propertyIndex) + { + case ANY: + unsetSequence(getAny()); + return; + } + super.unset(propertyIndex); + } + + /** + * + * + * @generated + */ + public boolean isSet(int propertyIndex) + { + switch (propertyIndex) + { + case ANY: + return any != null && !isSequenceEmpty(getAny()); + } + return super.isSet(propertyIndex); + } + + /** + * + * + * @generated + */ + public String toString() + { + if (isProxy(this)) 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/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/internal/InternalFactory.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/internal/InternalFactory.java new file mode 100644 index 0000000000..4776cb958f --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/internal/InternalFactory.java @@ -0,0 +1,52 @@ +/** + * + * 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.internal; + +import commonj.sdo.helper.HelperContext; + + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @generated + */ +public interface InternalFactory +{ + + /** + * The singleton instance of the factory. + * + * + * @generated + */ + InternalFactory INSTANCE = org.apache.tuscany.sdo.model.internal.impl.InternalFactoryImpl.init(); + + /** + * Registers the types supported by this Factory within the supplied scope.argument + * + * + * @param scope an instance of HelperContext used to manage the scoping of types. + * @generated + */ + public void register(HelperContext scope); + +} //InternalFactory diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/internal/impl/InternalFactoryImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/internal/impl/InternalFactoryImpl.java new file mode 100644 index 0000000000..4517f4a2a9 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/internal/impl/InternalFactoryImpl.java @@ -0,0 +1,296 @@ +/** + * + * 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.internal.impl; + +import commonj.sdo.helper.HelperContext; +import org.apache.tuscany.sdo.helper.TypeHelperImpl; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; + +import org.apache.tuscany.sdo.impl.FactoryBase; + +import org.apache.tuscany.sdo.model.internal.*; +import org.eclipse.emf.ecore.xml.type.XMLTypeFactory; + +/** + * + * An implementation of the commonj.sdo.internal model factory. + * This model is generated from sdoInternal.xsd, in the tuscany-sdo-impl project. + * Until the SDO code generator supports regen/merge, follow the following steps to regenerate this model: + * 1. Regenerate the model into a temporary directory: + * XSD2JavaGenerator -generateBuiltIn http://www.apache.org/tuscany/commonj.sdo.internal -targetDirectory -javaPackage org.apache.tuscany.sdo.model.internal /src/main/resources/xml/sdoInternal.xsd + * 2. Delete all the createXXXFromString() and convertXXXToString() methods in the newly generated InternalFactoryImpl and + * replace them with the ones from this file (resolve any missing imports). + * 3. Comment out all simple depedencies (SDOUtil.registerStaticTypes calls) in the init() method. + * 4. Make sure the top of each generated file contains the ASF License. + * 5. Move this JavaDoc comment into the newly generated ModelFactoryImpl class. + * + * @generated + */ +public class InternalFactoryImpl extends FactoryBase implements InternalFactory +{ + + /** + * The package namespace URI. + * + * + * @generated + */ + public static final String NAMESPACE_URI = "http://www.apache.org/tuscany/commonj.sdo.internal"; + + /** + * The package namespace name. + * + * + * @generated + */ + public static final String NAMESPACE_PREFIX = "internal"; + + /** + * The version of the generator pattern used to generate this class. + * + * + * @generated + */ + public static final String PATTERN_VERSION = "1.2"; + + public static final int BASE64_BYTES = 1; + public static final int QNAME = 2; + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public InternalFactoryImpl() + { + super(NAMESPACE_URI, NAMESPACE_PREFIX, "org.apache.tuscany.sdo.model.internal"); + } + + /** + * Registers the Factory instance so that it is available within the supplied scope. + * @argument scope a HelperContext instance that will make the types supported by this Factory available. + * + * + * @generated + */ + public void register(HelperContext scope) + { + if(scope == null) { + throw new IllegalArgumentException("Scope can not be null"); + } + + //Register dependent packages with provided scope + + // Initialize this package + TypeHelperImpl th = (TypeHelperImpl)scope.getTypeHelper(); + th.getExtendedMetaData().putPackage(NAMESPACE_URI, this); + } + + /** + * + * + * @generated + */ + public DataObject create(int typeNumber) + { + switch (typeNumber) + { + default: + return super.create(typeNumber); + } + } + + /** + * + * + * @generated + */ + public Object createFromString(int typeNumber, String initialValue) + { + switch (typeNumber) + { + case BASE64_BYTES: + return createBase64BytesFromString(initialValue); + case QNAME: + return createQNameFromString(initialValue); + default: + throw new IllegalArgumentException("The type number '" + typeNumber + "' is not a valid datatype"); + } + } + + /** + * + * + * @generated + */ + public String convertToString(int typeNumber, Object instanceValue) + { + switch (typeNumber) + { + case BASE64_BYTES: + return convertBase64BytesToString(instanceValue); + case QNAME: + return convertQNameToString(instanceValue); + default: + throw new IllegalArgumentException("The type number '" + typeNumber + "' is not a valid datatype"); + } + } + + // Following creates and initializes SDO metadata for the supported types. + protected Type base64BytesType = null; + + public Type getBase64Bytes() + { + return base64BytesType; + } + + protected Type qNameType = null; + + public Type getQName() + { + return qNameType; + } + + + private static InternalFactoryImpl instance = null; + public static InternalFactoryImpl init() + { + if (instance != null ) return instance; + instance = new InternalFactoryImpl(); + + // Initialize dependent packages + + // Create package meta-data objects + instance.createMetaData(); + + // Initialize created meta-data + instance.initializeMetaData(); + + // Mark meta-data to indicate it can't be changed + //theInternalFactoryImpl.freeze(); //FB do we need to freeze / should we freeze ???? + + return instance; + } + + private boolean isCreated = false; + + public void createMetaData() + { + if (isCreated) return; + isCreated = true; + + // Create data types + base64BytesType = createType(true, BASE64_BYTES ); + qNameType = createType(true, QNAME ); + } + + private boolean isInitialized = false; + + public void initializeMetaData() + { + if (isInitialized) return; + isInitialized = true; + Property property = null; + + // Add supertypes to types + + // Initialize types and properties + // Initialize data types + initializeType(base64BytesType, byte[].class, "Base64Bytes", true, false); + setInstanceProperty (base64BytesType, "commonj.sdo/java", "instanceClass", "byte[]"); + + initializeType(qNameType, String.class, "QName", true, false); + setInstanceProperty (qNameType, "commonj.sdo/java", "instanceClass", "java.lang.String"); + + createXSDMetaData(); + } + + protected void createXSDMetaData() + { + super.initXSD(); + + Property property = null; + + + addXSDMapping + (base64BytesType, + new String[] + { + "name", "Base64Bytes" + }); + + addXSDMapping + (qNameType, + new String[] + { + "name", "QName" + }); + + } + + /** + * + * + * @generated NOT + */ + public byte[] createBase64BytesFromString(String initialValue) + { + return XMLTypeFactory.eINSTANCE.createBase64Binary(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertBase64BytesToString(Object instanceValue) + { + if (instanceValue instanceof byte[]) { + return XMLTypeFactory.eINSTANCE.convertBase64Binary((byte[])instanceValue); + } else { + return XMLTypeFactory.eINSTANCE.convertBase64Binary(instanceValue.toString().getBytes()); + } + } + + /** + * + * + * @generated + */ + public String createQNameFromString(String initialValue) + { + return (String)super.createFromString(QNAME, initialValue); + } + + /** + * + * + * @generated + */ + public String convertQNameToString(Object instanceValue) + { + return super.convertToString(QNAME, instanceValue); + } + +} //InternalFactoryImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/java/JavaFactory.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/java/JavaFactory.java new file mode 100644 index 0000000000..50be023db5 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/java/JavaFactory.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.model.java; + +import commonj.sdo.helper.HelperContext; + + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @generated + */ +public interface JavaFactory +{ + + /** + * The singleton instance of the factory. + * + * + * @generated + */ + JavaFactory INSTANCE = org.apache.tuscany.sdo.model.java.impl.JavaFactoryImpl.init(); + + /** + * Returns a new object of class 'Info'. + * + * + * @return a new object of class 'Info'. + * @generated + */ + JavaInfo createJavaInfo(); + + /** + * Registers the types supported by this Factory within the supplied scope.argument + * + * + * @param scope an instance of HelperContext used to manage the scoping of types. + * @generated + */ + public void register(HelperContext scope); + +} //JavaFactory diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/java/JavaInfo.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/java/JavaInfo.java new file mode 100644 index 0000000000..b5eabb0f4a --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/java/JavaInfo.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.model.java; + +import java.io.Serializable; + +/** + * + * A representation of the model object 'Info'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.apache.tuscany.sdo.model.java.JavaInfo#getJavaClass Java Class}
  • + *
+ *

+ * + * @extends Serializable + * @generated + */ +public interface JavaInfo extends Serializable +{ + /** + * Returns the value of the 'Java Class' attribute. + * + *

+ * If the meaning of the 'Java Class' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Java Class' attribute. + * @see #isSetJavaClass() + * @see #unsetJavaClass() + * @see #setJavaClass(String) + * @generated + */ + String getJavaClass(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.java.JavaInfo#getJavaClass Java Class}' attribute. + * + * + * @param value the new value of the 'Java Class' attribute. + * @see #isSetJavaClass() + * @see #unsetJavaClass() + * @see #getJavaClass() + * @generated + */ + void setJavaClass(String value); + + /** + * Unsets the value of the '{@link org.apache.tuscany.sdo.model.java.JavaInfo#getJavaClass Java Class}' attribute. + * + * + * @see #isSetJavaClass() + * @see #getJavaClass() + * @see #setJavaClass(String) + * @generated + */ + void unsetJavaClass(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.java.JavaInfo#getJavaClass Java Class}' attribute is set. + * + * + * @return whether the value of the 'Java Class' attribute is set. + * @see #unsetJavaClass() + * @see #getJavaClass() + * @see #setJavaClass(String) + * @generated + */ + boolean isSetJavaClass(); + +} // JavaInfo diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/java/impl/JavaFactoryImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/java/impl/JavaFactoryImpl.java new file mode 100644 index 0000000000..515311f7ff --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/java/impl/JavaFactoryImpl.java @@ -0,0 +1,659 @@ +/** + * + * 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 commonj.sdo.helper.HelperContext; +import org.apache.tuscany.sdo.helper.TypeHelperImpl; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; + +import org.apache.tuscany.sdo.impl.FactoryBase; + +import org.apache.tuscany.sdo.model.ModelFactory; + +import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl; + +import org.apache.tuscany.sdo.model.java.*; +import org.eclipse.emf.ecore.xml.type.XMLTypeFactory; +import org.eclipse.emf.ecore.xml.type.util.XMLTypeUtil; + +/** + * + * An implementation of the commonj.sdo/java model factory. + * This model is generated from sdoJava.xsd, in the sdo-api project. + * Until the SDO code generator supports name conflicts and regen/merge, follow the following steps to regenerate this model: + * 1. Regenerate the model into a temporary directory: + * XSD2JavaGenerator -generateBuiltIn commonj.sdo/java -targetDirectory -javaPackage org.apache.tuscany.sdo.model.java /src/main/resources/xml/sdoJava.xsd + * 2. Delete all the createXXXFromString() and convertXXXToString() methods in the newly generated JavaFactoryImpl and + * replace them with the ones from this file. + * 3. Make sure the top of each generated file contains the ASF License. + * 4. Move this JavaDoc comment into the newly generated JavaFactoryImpl class. + * + * @generated + */ + +public class JavaFactoryImpl extends FactoryBase implements JavaFactory +{ + + /** + * The package namespace URI. + * + * + * @generated + */ + public static final String NAMESPACE_URI = "commonj.sdo/java"; + + /** + * The package namespace name. + * + * + * @generated + */ + public static final String NAMESPACE_PREFIX = "sdoJava"; + + /** + * The version of the generator pattern used to generate this class. + * + * + * @generated + */ + public static final String PATTERN_VERSION = "1.2"; + + public static final int JAVA_INFO = 1; + public static final int BOOLEAN_OBJECT = 2; + public static final int BYTE_OBJECT = 3; + public static final int CHARACTER_OBJECT = 4; + public static final int DOUBLE_OBJECT = 5; + public static final int FLOAT_OBJECT = 6; + public static final int INT_OBJECT = 7; + public static final int LONG_OBJECT = 8; + public static final int SHORT_OBJECT = 9; + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public JavaFactoryImpl() + { + super(NAMESPACE_URI, NAMESPACE_PREFIX, "org.apache.tuscany.sdo.model.java"); + } + + /** + * Registers the Factory instance so that it is available within the supplied scope. + * @argument scope a HelperContext instance that will make the types supported by this Factory available. + * + * + * @generated + */ + public void register(HelperContext scope) + { + if(scope == null) { + throw new IllegalArgumentException("Scope can not be null"); + } + + //Register dependent packages with provided scope + ModelFactory.INSTANCE.register(scope); + + // Initialize this package + TypeHelperImpl th = (TypeHelperImpl)scope.getTypeHelper(); + th.getExtendedMetaData().putPackage(NAMESPACE_URI, this); + } + + /** + * + * + * @generated + */ + public DataObject create(int typeNumber) + { + switch (typeNumber) + { + case JAVA_INFO: return (DataObject)createJavaInfo(); + default: + return super.create(typeNumber); + } + } + + /** + * + * + * @generated + */ + public Object createFromString(int typeNumber, String initialValue) + { + switch (typeNumber) + { + case BOOLEAN_OBJECT: + return createBooleanObjectFromString(initialValue); + case BYTE_OBJECT: + return createByteObjectFromString(initialValue); + case CHARACTER_OBJECT: + return createCharacterObjectFromString(initialValue); + case DOUBLE_OBJECT: + return createDoubleObjectFromString(initialValue); + case FLOAT_OBJECT: + return createFloatObjectFromString(initialValue); + case INT_OBJECT: + return createIntObjectFromString(initialValue); + case LONG_OBJECT: + return createLongObjectFromString(initialValue); + case SHORT_OBJECT: + return createShortObjectFromString(initialValue); + default: + throw new IllegalArgumentException("The type number '" + typeNumber + "' is not a valid datatype"); + } + } + + /** + * + * + * @generated + */ + public String convertToString(int typeNumber, Object instanceValue) + { + switch (typeNumber) + { + case BOOLEAN_OBJECT: + return convertBooleanObjectToString(instanceValue); + case BYTE_OBJECT: + return convertByteObjectToString(instanceValue); + case CHARACTER_OBJECT: + return convertCharacterObjectToString(instanceValue); + case DOUBLE_OBJECT: + return convertDoubleObjectToString(instanceValue); + case FLOAT_OBJECT: + return convertFloatObjectToString(instanceValue); + case INT_OBJECT: + return convertIntObjectToString(instanceValue); + case LONG_OBJECT: + return convertLongObjectToString(instanceValue); + case SHORT_OBJECT: + return convertShortObjectToString(instanceValue); + default: + throw new IllegalArgumentException("The type number '" + typeNumber + "' is not a valid datatype"); + } + } + /** + * + * + * @generated + */ + public JavaInfo createJavaInfo() + { + JavaInfoImpl javaInfo = new JavaInfoImpl(); + return javaInfo; + } + + // Following creates and initializes SDO metadata for the supported types. + protected Type javaInfoType = null; + + public Type getJavaInfo() + { + return javaInfoType; + } + + protected Type booleanObjectType = null; + + public Type getBooleanObject() + { + return booleanObjectType; + } + + protected Type byteObjectType = null; + + public Type getByteObject() + { + return byteObjectType; + } + + protected Type characterObjectType = null; + + public Type getCharacterObject() + { + return characterObjectType; + } + + protected Type doubleObjectType = null; + + public Type getDoubleObject() + { + return doubleObjectType; + } + + protected Type floatObjectType = null; + + public Type getFloatObject() + { + return floatObjectType; + } + + protected Type intObjectType = null; + + public Type getIntObject() + { + return intObjectType; + } + + protected Type longObjectType = null; + + public Type getLongObject() + { + return longObjectType; + } + + protected Type shortObjectType = null; + + public Type getShortObject() + { + return shortObjectType; + } + + + private static JavaFactoryImpl instance = null; + public static JavaFactoryImpl init() + { + if (instance != null ) return instance; + instance = new JavaFactoryImpl(); + + // Initialize dependent packages + ModelFactory ModelFactoryInstance = ModelFactory.INSTANCE; + + // Create package meta-data objects + instance.createMetaData(); + + // Initialize created meta-data + instance.initializeMetaData(); + + // Mark meta-data to indicate it can't be changed + //theJavaFactoryImpl.freeze(); //FB do we need to freeze / should we freeze ???? + + return instance; + } + + private boolean isCreated = false; + + public void createMetaData() + { + if (isCreated) return; + isCreated = true; + + // Create types and their properties + javaInfoType = createType(false, JAVA_INFO); + createProperty(true, javaInfoType,JavaInfoImpl.INTERNAL_JAVA_CLASS); + + // Create data types + booleanObjectType = createType(true, BOOLEAN_OBJECT ); + byteObjectType = createType(true, BYTE_OBJECT ); + characterObjectType = createType(true, CHARACTER_OBJECT ); + doubleObjectType = createType(true, DOUBLE_OBJECT ); + floatObjectType = createType(true, FLOAT_OBJECT ); + intObjectType = createType(true, INT_OBJECT ); + longObjectType = createType(true, LONG_OBJECT ); + shortObjectType = createType(true, SHORT_OBJECT ); + } + + private boolean isInitialized = false; + + public void initializeMetaData() + { + if (isInitialized) return; + isInitialized = true; + + // Obtain other dependent packages + ModelFactoryImpl theModelPackageImpl = (ModelFactoryImpl)ModelFactory.INSTANCE; + Property property = null; + + // Add supertypes to types + + // Initialize types and properties + initializeType(javaInfoType, JavaInfo.class, "JavaInfo", false); + property = getLocalProperty(javaInfoType, 0); + initializeProperty(property, theModelPackageImpl.getString(), "javaClass", null, 0, 1, JavaInfo.class, false, true, false); + + // Initialize data types + initializeType(booleanObjectType, Boolean.class, "BooleanObject", true, false); + setInstanceProperty (booleanObjectType, "commonj.sdo/java", "instanceClass", "java.lang.Boolean"); + + initializeType(byteObjectType, Byte.class, "ByteObject", true, false); + setInstanceProperty (byteObjectType, "commonj.sdo/java", "instanceClass", "java.lang.Byte"); + + initializeType(characterObjectType, Character.class, "CharacterObject", true, false); + setInstanceProperty (characterObjectType, "commonj.sdo/java", "instanceClass", "java.lang.Character"); + + initializeType(doubleObjectType, Double.class, "DoubleObject", true, false); + setInstanceProperty (doubleObjectType, "commonj.sdo/java", "instanceClass", "java.lang.Double"); + + initializeType(floatObjectType, Float.class, "FloatObject", true, false); + setInstanceProperty (floatObjectType, "commonj.sdo/java", "instanceClass", "java.lang.Float"); + + initializeType(intObjectType, Integer.class, "IntObject", true, false); + setInstanceProperty (intObjectType, "commonj.sdo/java", "instanceClass", "java.lang.Integer"); + + initializeType(longObjectType, Long.class, "LongObject", true, false); + setInstanceProperty (longObjectType, "commonj.sdo/java", "instanceClass", "java.lang.Long"); + + initializeType(shortObjectType, Short.class, "ShortObject", true, false); + setInstanceProperty (shortObjectType, "commonj.sdo/java", "instanceClass", "java.lang.Short"); + + createXSDMetaData(theModelPackageImpl); + } + + protected void createXSDMetaData(ModelFactoryImpl theModelPackageImpl) + { + super.initXSD(); + + Property property = null; + + + property = createGlobalProperty + ("extendedInstanceClass", + theModelPackageImpl.getString(), + new String[] + { + "kind", "attribute", + "name", "extendedInstanceClass", + "namespace", "##targetNamespace" + }, + IS_ATTRIBUTE); + + property = createGlobalProperty + ("instanceClass", + theModelPackageImpl.getString(), + new String[] + { + "kind", "attribute", + "name", "instanceClass", + "namespace", "##targetNamespace" + }, + IS_ATTRIBUTE); + + property = createGlobalProperty + ("javaClass", + theModelPackageImpl.getString(), + new String[] + { + "kind", "attribute", + "name", "javaClass", + "namespace", "##targetNamespace" + }, + IS_ATTRIBUTE); + + property = createGlobalProperty + ("nestedInterfaces", + theModelPackageImpl.getBoolean(), + new String[] + { + "kind", "attribute", + "name", "nestedInterfaces", + "namespace", "##targetNamespace" + }, + IS_ATTRIBUTE); + + property = createGlobalProperty + ("package", + theModelPackageImpl.getString(), + new String[] + { + "kind", "attribute", + "name", "package", + "namespace", "##targetNamespace" + }, + IS_ATTRIBUTE); + + addXSDMapping + (javaInfoType, + new String[] + { + "name", "JavaInfo", + "kind", "empty" + }); + + addXSDMapping + (getProperty(javaInfoType, JavaInfoImpl.INTERNAL_JAVA_CLASS), + new String[] + { + "kind", "attribute", + "name", "javaClass" + }); + + addXSDMapping + (booleanObjectType, + new String[] + { + "name", "BooleanObject" + }); + + addXSDMapping + (byteObjectType, + new String[] + { + "name", "ByteObject" + }); + + addXSDMapping + (characterObjectType, + new String[] + { + "name", "CharacterObject" + }); + + addXSDMapping + (doubleObjectType, + new String[] + { + "name", "DoubleObject" + }); + + addXSDMapping + (floatObjectType, + new String[] + { + "name", "FloatObject" + }); + + addXSDMapping + (intObjectType, + new String[] + { + "name", "IntObject" + }); + + addXSDMapping + (longObjectType, + new String[] + { + "name", "LongObject" + }); + + addXSDMapping + (shortObjectType, + new String[] + { + "name", "ShortObject" + }); + + } + + /** + * + * + * @generated NOT + */ + public Boolean createBooleanObjectFromString(String initialValue) + { + return XMLTypeFactory.eINSTANCE.createBooleanObject(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertBooleanObjectToString(Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertBooleanObject((Boolean)instanceValue); + } + + /** + * + * + * @generated NOT + */ + public Byte createByteObjectFromString(String initialValue) + { + return XMLTypeFactory.eINSTANCE.createByteObject(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertByteObjectToString(Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertByteObject((Byte)instanceValue); + } + + /** + * + * + * @generated NOT + */ + public Character createCharacterObjectFromString(String initialValue) + { + return (initialValue == null && initialValue.length() > 0) + ? null : (new Character(XMLTypeUtil.normalize(initialValue, true).charAt(0))); + } + + /** + * + * + * @generated NOT + */ + public String convertCharacterObjectToString(Object instanceValue) + { + return instanceValue == null ? null : instanceValue.toString(); + } + + /** + * + * + * @generated NOT + */ + public Double createDoubleObjectFromString(String initialValue) + { + return XMLTypeFactory.eINSTANCE.createDoubleObject(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertDoubleObjectToString(Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertDoubleObject((Double)instanceValue); + } + + /** + * + * + * @generated NOT + */ + public Float createFloatObjectFromString(String initialValue) + { + return XMLTypeFactory.eINSTANCE.createFloatObject(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertFloatObjectToString(Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertFloatObject((Float)instanceValue); + } + + /** + * + * + * @generated NOT + */ + public Integer createIntObjectFromString(String initialValue) + { + return XMLTypeFactory.eINSTANCE.createIntObject(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertIntObjectToString(Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertIntObject((Integer)instanceValue); + } + + /** + * + * + * @generated NOT + */ + public Long createLongObjectFromString(String initialValue) + { + return XMLTypeFactory.eINSTANCE.createLongObject(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertLongObjectToString(Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertLongObject((Long)instanceValue); + } + + /** + * + * + * @generated NOT + */ + public Short createShortObjectFromString(String initialValue) + { + return XMLTypeFactory.eINSTANCE.createShortObject(initialValue); + } + + /** + * + * + * @generated NOT + */ + public String convertShortObjectToString(Object instanceValue) + { + return XMLTypeFactory.eINSTANCE.convertShortObject((Short)instanceValue); + } + +} //JavaFactoryImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/java/impl/JavaInfoImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/java/impl/JavaInfoImpl.java new file mode 100644 index 0000000000..de25db5d1e --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/java/impl/JavaInfoImpl.java @@ -0,0 +1,256 @@ +/** + * + * 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 commonj.sdo.Type; + +import org.apache.tuscany.sdo.impl.DataObjectBase; + +import org.apache.tuscany.sdo.model.java.JavaFactory; +import org.apache.tuscany.sdo.model.java.JavaInfo; + +/** + * + * An implementation of the model object 'Info'. + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.apache.tuscany.sdo.model.java.impl.JavaInfoImpl#getJavaClass Java Class}
  • + *
+ *

+ * + * @generated + */ +public class JavaInfoImpl extends DataObjectBase implements JavaInfo +{ + + public final static int JAVA_CLASS = 0; + + public final static int SDO_PROPERTY_COUNT = 1; + + public final static int EXTENDED_PROPERTY_COUNT = 0; + + + /** + * The internal feature id for the 'Java Class' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_JAVA_CLASS = 0; + + /** + * The number of properties for this type. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_PROPERTY_COUNT = 1; + + protected int internalConvertIndex(int internalIndex) + { + switch (internalIndex) + { + case INTERNAL_JAVA_CLASS: return JAVA_CLASS; + } + return super.internalConvertIndex(internalIndex); + } + + + /** + * The default value of the '{@link #getJavaClass() Java Class}' attribute. + * + * + * @see #getJavaClass() + * @generated + * @ordered + */ + protected static final String JAVA_CLASS_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getJavaClass() Java Class}' attribute. + * + * + * @see #getJavaClass() + * @generated + * @ordered + */ + protected String javaClass = JAVA_CLASS_DEFAULT_; + + /** + * This is true if the Java Class attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean javaClass_set_ = false; + + /** + * + * + * @generated + */ + public JavaInfoImpl() + { + super(); + } + + /** + * + * + * @generated + */ + public Type getStaticType() + { + return ((JavaFactoryImpl)JavaFactory.INSTANCE).getJavaInfo(); + } + + /** + * + * + * @generated + */ + public String getJavaClass() + { + return javaClass; + } + /** + * + * + * @generated + */ + public void setJavaClass(String newJavaClass) + { + String oldJavaClass = javaClass; + javaClass = newJavaClass; + boolean oldJavaClass_set_ = javaClass_set_; + javaClass_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INTERNAL_JAVA_CLASS, oldJavaClass, javaClass, !oldJavaClass_set_); + } + + /** + * + * + * @generated + */ + public void unsetJavaClass() + { + String oldJavaClass = javaClass; + boolean oldJavaClass_set_ = javaClass_set_; + javaClass = JAVA_CLASS_DEFAULT_; + javaClass_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INTERNAL_JAVA_CLASS, oldJavaClass, JAVA_CLASS_DEFAULT_, oldJavaClass_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetJavaClass() + { + return javaClass_set_; + } + + /** + * + * + * @generated + */ + public Object get(int propertyIndex, boolean resolve) + { + switch (propertyIndex) + { + case JAVA_CLASS: + return getJavaClass(); + } + return super.get(propertyIndex, resolve); + } + + /** + * + * + * @generated + */ + public void set(int propertyIndex, Object newValue) + { + switch (propertyIndex) + { + case JAVA_CLASS: + setJavaClass((String)newValue); + return; + } + super.set(propertyIndex, newValue); + } + + /** + * + * + * @generated + */ + public void unset(int propertyIndex) + { + switch (propertyIndex) + { + case JAVA_CLASS: + unsetJavaClass(); + return; + } + super.unset(propertyIndex); + } + + /** + * + * + * @generated + */ + public boolean isSet(int propertyIndex) + { + switch (propertyIndex) + { + case JAVA_CLASS: + return isSetJavaClass(); + } + return super.isSet(propertyIndex); + } + + /** + * + * + * @generated + */ + public String toString() + { + if (isProxy(this)) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (javaClass: "); + if (javaClass_set_) result.append(javaClass); else result.append(""); + result.append(')'); + return result.toString(); + } + +} //JavaInfoImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/xml/XMLFactory.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/xml/XMLFactory.java new file mode 100644 index 0000000000..84a60cf849 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/xml/XMLFactory.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.model.xml; + +import commonj.sdo.helper.HelperContext; + + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @generated + */ +public interface XMLFactory +{ + + /** + * The singleton instance of the factory. + * + * + * @generated + */ + XMLFactory INSTANCE = org.apache.tuscany.sdo.model.xml.impl.XMLFactoryImpl.init(); + + /** + * Returns a new object of class 'Info'. + * + * + * @return a new object of class 'Info'. + * @generated + */ + XMLInfo createXMLInfo(); + + /** + * Registers the types supported by this Factory within the supplied scope.argument + * + * + * @param scope an instance of HelperContext used to manage the scoping of types. + * @generated + */ + public void register(HelperContext scope); + +} //XMLFactory diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/xml/XMLInfo.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/xml/XMLInfo.java new file mode 100644 index 0000000000..85cad641c9 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/xml/XMLInfo.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.model.xml; + +import java.io.Serializable; + +/** + * + * A representation of the model object 'Info'. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.apache.tuscany.sdo.model.xml.XMLInfo#isXmlElement Xml Element}
  • + *
+ *

+ * + * @extends Serializable + * @generated + */ +public interface XMLInfo extends Serializable +{ + /** + * Returns the value of the 'Xml Element' attribute. + * + *

+ * If the meaning of the 'Xml Element' attribute isn't clear, + * there really should be more of a description here... + *

+ * + * @return the value of the 'Xml Element' attribute. + * @see #isSetXmlElement() + * @see #unsetXmlElement() + * @see #setXmlElement(boolean) + * @generated + */ + boolean isXmlElement(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.model.xml.XMLInfo#isXmlElement Xml Element}' attribute. + * + * + * @param value the new value of the 'Xml Element' attribute. + * @see #isSetXmlElement() + * @see #unsetXmlElement() + * @see #isXmlElement() + * @generated + */ + void setXmlElement(boolean value); + + /** + * Unsets the value of the '{@link org.apache.tuscany.sdo.model.xml.XMLInfo#isXmlElement Xml Element}' attribute. + * + * + * @see #isSetXmlElement() + * @see #isXmlElement() + * @see #setXmlElement(boolean) + * @generated + */ + void unsetXmlElement(); + + /** + * Returns whether the value of the '{@link org.apache.tuscany.sdo.model.xml.XMLInfo#isXmlElement Xml Element}' attribute is set. + * + * + * @return whether the value of the 'Xml Element' attribute is set. + * @see #unsetXmlElement() + * @see #isXmlElement() + * @see #setXmlElement(boolean) + * @generated + */ + boolean isSetXmlElement(); + +} // XMLInfo diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/xml/impl/XMLFactoryImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/xml/impl/XMLFactoryImpl.java new file mode 100644 index 0000000000..293a7b0398 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/xml/impl/XMLFactoryImpl.java @@ -0,0 +1,341 @@ +/** + * + * 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.xml.impl; + +import commonj.sdo.helper.HelperContext; +import org.apache.tuscany.sdo.helper.TypeHelperImpl; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; + +import org.apache.tuscany.sdo.impl.FactoryBase; + +import org.apache.tuscany.sdo.model.ModelFactory; + +import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl; + +import org.apache.tuscany.sdo.model.internal.InternalFactory; + +import org.apache.tuscany.sdo.model.internal.impl.InternalFactoryImpl; + +import org.apache.tuscany.sdo.model.xml.*; + +/** + * + * An implementation of the commonj.sdo/xml model factory. + * This model is generated from sdoXML.xsd, in the sdo-api project. + * Until the SDO code generator supports name conflicts and regen/merge, follow the following steps to regenerate this model: + * 1. Regenerate the model into a temporary directory: + * XSD2JavaGenerator -generateBuiltIn commonj.sdo/xml -prefix XML -targetDirectory -javaPackage org.apache.tuscany.sdo.model.xml /src/main/resources/xml/sdoXML.xsd + * 2. Make sure the top of each generated file contains the ASF License. + * 3. Move this JavaDoc comment into the newly generated XMLFactoryImpl class. + * + * @generated + */ +public class XMLFactoryImpl extends FactoryBase implements XMLFactory +{ + + /** + * The package namespace URI. + * + * + * @generated + */ + public static final String NAMESPACE_URI = "commonj.sdo/xml"; + + /** + * The package namespace name. + * + * + * @generated + */ + public static final String NAMESPACE_PREFIX = "sdoXML"; + + /** + * The version of the generator pattern used to generate this class. + * + * + * @generated + */ + public static final String PATTERN_VERSION = "1.2"; + + public static final int XML_INFO = 1; + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public XMLFactoryImpl() + { + super(NAMESPACE_URI, NAMESPACE_PREFIX, "org.apache.tuscany.sdo.model.xml"); + } + + /** + * Registers the Factory instance so that it is available within the supplied scope. + * @argument scope a HelperContext instance that will make the types supported by this Factory available. + * + * + * @generated + */ + public void register(HelperContext scope) + { + if(scope == null) { + throw new IllegalArgumentException("Scope can not be null"); + } + + //Register dependent packages with provided scope + ModelFactory.INSTANCE.register(scope); + InternalFactory.INSTANCE.register(scope); + + // Initialize this package + TypeHelperImpl th = (TypeHelperImpl)scope.getTypeHelper(); + th.getExtendedMetaData().putPackage(NAMESPACE_URI, this); + } + + /** + * + * + * @generated + */ + public DataObject create(int typeNumber) + { + switch (typeNumber) + { + case XML_INFO: return (DataObject)createXMLInfo(); + default: + return super.create(typeNumber); + } + } + + /** + * + * + * @generated + */ + public XMLInfo createXMLInfo() + { + XMLInfoImpl xmlInfo = new XMLInfoImpl(); + return xmlInfo; + } + + // Following creates and initializes SDO metadata for the supported types. + protected Type xmlInfoType = null; + + public Type getXMLInfo() + { + return xmlInfoType; + } + + + private static XMLFactoryImpl instance = null; + public static XMLFactoryImpl init() + { + if (instance != null ) return instance; + instance = new XMLFactoryImpl(); + + // Initialize dependent packages + ModelFactory ModelFactoryInstance = ModelFactory.INSTANCE; + InternalFactory InternalFactoryInstance = InternalFactory.INSTANCE; + + // Create package meta-data objects + instance.createMetaData(); + + // Initialize created meta-data + instance.initializeMetaData(); + + // Mark meta-data to indicate it can't be changed + //theXMLFactoryImpl.freeze(); //FB do we need to freeze / should we freeze ???? + + return instance; + } + + private boolean isCreated = false; + + public void createMetaData() + { + if (isCreated) return; + isCreated = true; + + // Create types and their properties + xmlInfoType = createType(false, XML_INFO); + createProperty(true, xmlInfoType,XMLInfoImpl.INTERNAL_XML_ELEMENT); + } + + private boolean isInitialized = false; + + public void initializeMetaData() + { + if (isInitialized) return; + isInitialized = true; + + // Obtain other dependent packages + ModelFactoryImpl theModelPackageImpl = (ModelFactoryImpl)ModelFactory.INSTANCE; + InternalFactoryImpl theInternalPackageImpl = (InternalFactoryImpl)InternalFactory.INSTANCE; + Property property = null; + + // Add supertypes to types + + // Initialize types and properties + initializeType(xmlInfoType, XMLInfo.class, "XMLInfo", false); + property = getLocalProperty(xmlInfoType, 0); + initializeProperty(property, theModelPackageImpl.getBoolean(), "xmlElement", null, 0, 1, XMLInfo.class, false, true, false); + + createXSDMetaData(theModelPackageImpl, theInternalPackageImpl); + } + + protected void createXSDMetaData(ModelFactoryImpl theModelPackageImpl, InternalFactoryImpl theInternalPackageImpl) + { + super.initXSD(); + + Property property = null; + + + property = createGlobalProperty + ("aliasName", + theModelPackageImpl.getString(), + new String[] + { + "kind", "attribute", + "name", "aliasName", + "namespace", "##targetNamespace" + }, + IS_ATTRIBUTE); + + property = createGlobalProperty + ("dataType", + theInternalPackageImpl.getQName(), + new String[] + { + "kind", "attribute", + "name", "dataType", + "namespace", "##targetNamespace" + }, + IS_ATTRIBUTE); + + property = createGlobalProperty + ("many", + theModelPackageImpl.getBoolean(), + new String[] + { + "kind", "attribute", + "name", "many", + "namespace", "##targetNamespace" + }, + IS_ATTRIBUTE); + + property = createGlobalProperty + ("name", + theModelPackageImpl.getString(), + new String[] + { + "kind", "attribute", + "name", "name", + "namespace", "##targetNamespace" + }, + IS_ATTRIBUTE); + + property = createGlobalProperty + ("oppositeProperty", + theModelPackageImpl.getString(), + new String[] + { + "kind", "attribute", + "name", "oppositeProperty", + "namespace", "##targetNamespace" + }, + IS_ATTRIBUTE); + + property = createGlobalProperty + ("propertyType", + theInternalPackageImpl.getQName(), + new String[] + { + "kind", "attribute", + "name", "propertyType", + "namespace", "##targetNamespace" + }, + IS_ATTRIBUTE); + + property = createGlobalProperty + ("readOnly", + theModelPackageImpl.getBoolean(), + new String[] + { + "kind", "attribute", + "name", "readOnly", + "namespace", "##targetNamespace" + }, + IS_ATTRIBUTE); + + property = createGlobalProperty + ("sequence", + theModelPackageImpl.getBoolean(), + new String[] + { + "kind", "attribute", + "name", "sequence", + "namespace", "##targetNamespace" + }, + IS_ATTRIBUTE); + + property = createGlobalProperty + ("string", + theModelPackageImpl.getBoolean(), + new String[] + { + "kind", "attribute", + "name", "string", + "namespace", "##targetNamespace" + }, + IS_ATTRIBUTE); + + property = createGlobalProperty + ("xmlElement", + theModelPackageImpl.getBoolean(), + new String[] + { + "kind", "attribute", + "name", "xmlElement", + "namespace", "##targetNamespace" + }, + IS_ATTRIBUTE); + + addXSDMapping + (xmlInfoType, + new String[] + { + "name", "XMLInfo", + "kind", "empty" + }); + + addXSDMapping + (getProperty(xmlInfoType, XMLInfoImpl.INTERNAL_XML_ELEMENT), + new String[] + { + "kind", "attribute", + "name", "xmlElement" + }); + + } + +} //XMLFactoryImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/xml/impl/XMLInfoImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/xml/impl/XMLInfoImpl.java new file mode 100644 index 0000000000..a0906e32c1 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/model/xml/impl/XMLInfoImpl.java @@ -0,0 +1,256 @@ +/** + * + * 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.xml.impl; + +import commonj.sdo.Type; + +import org.apache.tuscany.sdo.impl.DataObjectBase; + +import org.apache.tuscany.sdo.model.xml.XMLFactory; +import org.apache.tuscany.sdo.model.xml.XMLInfo; + +/** + * + * An implementation of the model object 'Info'. + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.apache.tuscany.sdo.model.xml.impl.XMLInfoImpl#isXmlElement Xml Element}
  • + *
+ *

+ * + * @generated + */ +public class XMLInfoImpl extends DataObjectBase implements XMLInfo +{ + + public final static int XML_ELEMENT = 0; + + public final static int SDO_PROPERTY_COUNT = 1; + + public final static int EXTENDED_PROPERTY_COUNT = 0; + + + /** + * The internal feature id for the 'Xml Element' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_XML_ELEMENT = 0; + + /** + * The number of properties for this type. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_PROPERTY_COUNT = 1; + + protected int internalConvertIndex(int internalIndex) + { + switch (internalIndex) + { + case INTERNAL_XML_ELEMENT: return XML_ELEMENT; + } + return super.internalConvertIndex(internalIndex); + } + + + /** + * The default value of the '{@link #isXmlElement() Xml Element}' attribute. + * + * + * @see #isXmlElement() + * @generated + * @ordered + */ + protected static final boolean XML_ELEMENT_DEFAULT_ = false; + + /** + * The cached value of the '{@link #isXmlElement() Xml Element}' attribute. + * + * + * @see #isXmlElement() + * @generated + * @ordered + */ + protected boolean xmlElement = XML_ELEMENT_DEFAULT_; + + /** + * This is true if the Xml Element attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean xmlElement_set_ = false; + + /** + * + * + * @generated + */ + public XMLInfoImpl() + { + super(); + } + + /** + * + * + * @generated + */ + public Type getStaticType() + { + return ((XMLFactoryImpl)XMLFactory.INSTANCE).getXMLInfo(); + } + + /** + * + * + * @generated + */ + public boolean isXmlElement() + { + return xmlElement; + } + /** + * + * + * @generated + */ + public void setXmlElement(boolean newXmlElement) + { + boolean oldXmlElement = xmlElement; + xmlElement = newXmlElement; + boolean oldXmlElement_set_ = xmlElement_set_; + xmlElement_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INTERNAL_XML_ELEMENT, oldXmlElement, xmlElement, !oldXmlElement_set_); + } + + /** + * + * + * @generated + */ + public void unsetXmlElement() + { + boolean oldXmlElement = xmlElement; + boolean oldXmlElement_set_ = xmlElement_set_; + xmlElement = XML_ELEMENT_DEFAULT_; + xmlElement_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INTERNAL_XML_ELEMENT, oldXmlElement, XML_ELEMENT_DEFAULT_, oldXmlElement_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetXmlElement() + { + return xmlElement_set_; + } + + /** + * + * + * @generated + */ + public Object get(int propertyIndex, boolean resolve) + { + switch (propertyIndex) + { + case XML_ELEMENT: + return isXmlElement() ? Boolean.TRUE : Boolean.FALSE; + } + return super.get(propertyIndex, resolve); + } + + /** + * + * + * @generated + */ + public void set(int propertyIndex, Object newValue) + { + switch (propertyIndex) + { + case XML_ELEMENT: + setXmlElement(((Boolean)newValue).booleanValue()); + return; + } + super.set(propertyIndex, newValue); + } + + /** + * + * + * @generated + */ + public void unset(int propertyIndex) + { + switch (propertyIndex) + { + case XML_ELEMENT: + unsetXmlElement(); + return; + } + super.unset(propertyIndex); + } + + /** + * + * + * @generated + */ + public boolean isSet(int propertyIndex) + { + switch (propertyIndex) + { + case XML_ELEMENT: + return isSetXmlElement(); + } + return super.isSet(propertyIndex); + } + + /** + * + * + * @generated + */ + public String toString() + { + if (isProxy(this)) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (xmlElement: "); + if (xmlElement_set_) result.append(xmlElement); else result.append(""); + result.append(')'); + return result.toString(); + } + +} //XMLInfoImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/BasicSequence.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/BasicSequence.java new file mode 100644 index 0000000000..e25d30e61c --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/BasicSequence.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.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.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Sequence; +import commonj.sdo.Type; + +/** + * 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); + return getFeatureProperty(feature); + } + + public static Property getFeatureProperty(EStructuralFeature feature) + { + 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(String propertyName, Object value) + { + EStructuralFeature result = featureMap.getEObject().eClass().getEStructuralFeature(propertyName); + if (result == null) + { + Type type = (Type)featureMap.getEObject().eClass(); + if (type.isOpen()) + { + result = (EStructuralFeature)DataObjectUtil.demandOpenProperty(type, propertyName, value, true); + } + } + return result; + } + + protected EStructuralFeature getEStructuralFeature(int propertyIndex) + { + return (EStructuralFeature)DataObjectUtil.getProperty((DataObject)featureMap.getEObject(), propertyIndex); + } + + public boolean add(String propertyName, Object value) + { + return featureMap.add(getEStructuralFeature(propertyName, value), 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), 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); + } + + /** + * @deprecated + */ + public void add(String text) + { + FeatureMapUtil.addText(featureMap, text); + } + + /** + * @deprecated + */ + public void add(int index, String text) + { + FeatureMapUtil.addText(featureMap, index, text); + } + + public void addText(String text) + { + FeatureMapUtil.addText(featureMap, text); + } + + public void addText(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/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/DataGraphResourceFactoryImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/DataGraphResourceFactoryImpl.java new file mode 100644 index 0000000000..c3f321d9f9 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/DataGraphResourceFactoryImpl.java @@ -0,0 +1,705 @@ +/** + * + * 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(""); + 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()); + } + } + + //FB TEMPORARY allow loading proper serialization (global element instead of type name) + //FB Proper fix is to reimplement DataGraph as proper DataObject, and remove this entire class + EStructuralFeature rootFeature = extendedMetaData.getElement(helper.getURI(prefix), name); + if (rootFeature != null) name = rootFeature.getEType().getName(); + + 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/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java new file mode 100644 index 0000000000..fbf5f81d9d --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java @@ -0,0 +1,2998 @@ +/** + * + * 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.security.AccessController; +import java.security.PrivilegedExceptionAction; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +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 java.util.TimeZone; + +import org.apache.tuscany.sdo.SDOExtendedMetaData; +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.api.SDOUtil; +import org.apache.tuscany.sdo.helper.HelperContextImpl; +import org.apache.tuscany.sdo.impl.ClassImpl; +import org.apache.tuscany.sdo.impl.DataGraphImpl; +import org.apache.tuscany.sdo.model.ModelFactory; +import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl; +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.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.EModelElement; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.impl.EPackageRegistryImpl; +import org.eclipse.emf.ecore.impl.EStringToStringMapEntryImpl; +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.emf.ecore.xml.type.XMLTypePackage; +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.HelperContext; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.impl.HelperProvider; + + +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)); + } + + + public static void setString(DataObject dataObject, int propertyIndex, String value) { + setString(dataObject,getProperty(dataObject, propertyIndex), value); + } + + public static void setShort(DataObject dataObject, int propertyIndex, short value) { + setShort(dataObject,getProperty(dataObject, propertyIndex), value); + } + + public static void setLong(DataObject dataObject, int propertyIndex, long value) { + setLong(dataObject,getProperty(dataObject, propertyIndex), value); + } + + public static void setList(DataObject dataObject, int propertyIndex, List value) { + setList(dataObject,getProperty(dataObject, propertyIndex), value); + } + + public static void setInt(DataObject dataObject, int propertyIndex, int value) { + setInt(dataObject,getProperty(dataObject, propertyIndex), value); + } + + public static void setFloat(DataObject dataObject, int propertyIndex, float value) { + setFloat(dataObject,getProperty(dataObject, propertyIndex), value); + } + + public static void setDouble(DataObject dataObject, int propertyIndex, double value) { + setDouble(dataObject,getProperty(dataObject, propertyIndex), value); + } + + public static void setDate(DataObject dataObject, int propertyIndex, Date value) { + setDate(dataObject,getProperty(dataObject, propertyIndex), value); + } + + public static void setDataObject(DataObject dataObject, int propertyIndex, DataObject value) { + dataObject.set(getProperty(dataObject, propertyIndex), value); + } + + public static void setChar(DataObject dataObject, int propertyIndex, char value) { + setChar(dataObject,getProperty(dataObject, propertyIndex), value); + } + + public static void setBytes(DataObject dataObject, int propertyIndex, byte[] value) { + setBytes(dataObject,getProperty(dataObject, propertyIndex), value); + } + + public static void setByte(DataObject dataObject, int propertyIndex, byte value) { + setByte(dataObject,getProperty(dataObject, propertyIndex), value); + } + + public static void setBoolean(DataObject dataObject, int propertyIndex, boolean value) { + setBoolean(dataObject,getProperty(dataObject, propertyIndex), value); + } + + public static void setBigInteger(DataObject dataObject, int propertyIndex, BigInteger value) + { + setBigInteger(dataObject,getProperty(dataObject, propertyIndex), value); + } + + public static void setBigDecimal(DataObject dataObject, int propertyIndex, BigDecimal value) + { + setBigDecimal(dataObject,getProperty(dataObject, propertyIndex), value); + } + + public static String getString(DataObject dataObject, int propertyIndex) + { + return getString(dataObject.get(getProperty(dataObject, propertyIndex))); + } + + public static short getShort(DataObject dataObject, int propertyIndex) + { + return getShort(dataObject.get(getProperty(dataObject, 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(getProperty(dataObject, propertyIndex))); + } + + public static List getList(DataObject dataObject, int propertyIndex) + { + return (List)dataObject.get(getProperty(dataObject, propertyIndex)); + } + + public static int getInt(DataObject dataObject, int propertyIndex) + { + return getInt(dataObject.get(getProperty(dataObject, propertyIndex))); + } + + public static float getFloat(DataObject dataObject, int propertyIndex) + { + return getFloat(dataObject.get(getProperty(dataObject, propertyIndex))); + } + + public static double getDouble(DataObject dataObject, int propertyIndex) + { + return getDouble(dataObject.get(getProperty(dataObject, propertyIndex))); + } + + public static Date getDate(DataObject dataObject, int propertyIndex) + { + return getDate(dataObject.get(getProperty(dataObject, propertyIndex))); + } + + public static DataObject getDataObject(DataObject dataObject, int propertyIndex) + { + return (DataObject)dataObject.get(getProperty(dataObject, propertyIndex)); + } + + public static char getChar(DataObject dataObject, int propertyIndex) + { + return getChar(dataObject.get(getProperty(dataObject, propertyIndex))); + } + + public static byte[] getBytes(DataObject dataObject, int propertyIndex) + { + return getBytes(dataObject.get(getProperty(dataObject, propertyIndex))); + } + + public static byte getByte(DataObject dataObject, int propertyIndex) + { + return getByte(dataObject.get(getProperty(dataObject, propertyIndex))); + } + + public static boolean getBoolean(DataObject dataObject, int propertyIndex) + { + return getBoolean(dataObject.get(getProperty(dataObject, propertyIndex))); + } + + public static BigInteger getBigInteger(DataObject dataObject, int propertyIndex) + { + return getBigInteger(dataObject.get(getProperty(dataObject, propertyIndex))); + } + + public static BigDecimal getBigDecimal(DataObject dataObject, int propertyIndex) + { + return getBigDecimal(dataObject.get(getProperty(dataObject, 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 boolean isInternalProperty(EStructuralFeature eStructuralFeature) + { + //return FeatureMapUtil.isFeatureMap(eStructuralFeature); + EClassifier eClassifier = eStructuralFeature.getEType(); + return !(eClassifier instanceof Type || eClassifier == XMLTypePackage.Literals.BASE64_BINARY); + } + + public static List getInstanceProperties(DataObject dataObject) + { + Type type = dataObject.getType(); + List result = new UniqueEList(type.getProperties()); + ((ClassImpl)type).addOpenProperties((EObject)dataObject, result); + 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 = getInstanceProperty(dataObject, propertyName); + if (property != null) { + Type type = DataObjectUtil.getType(dataObject, namespaceURI, typeName); + return createDataObject(dataObject, property, type); + } + else { + if (dataObject.getType().isOpen()) { + HelperContext ctx = HelperProvider.getDefaultContext(); + Type propertyType = ctx.getTypeHelper().getType( namespaceURI, typeName ); + if (propertyType == null) { + throw new IllegalStateException( "type does not exist: uri=" + namespaceURI + ", name=" + typeName ); + } + DataObject value = ctx.getDataFactory().create( propertyType ); + List list = new ArrayList(1); + list.add(value); + dataObject.setList( propertyName, list ); + return value; + } + else { + throw new IllegalArgumentException( "property '" + propertyName + "' does not exist" ); + } + } + } + + 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)getInstanceProperty(dataObject, propertyName); + if (property != null) { + Type type = property.getType(); + return createDataObject(dataObject,property, type); + } + else { + return createDataObject(dataObject, propertyName, "http://www.apache.org/tuscany/2005/SDO", "AnyTypeDataObject" ); + } + } + + 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(); + } + else + { + for (DataObject csDataObject = dataObject; csDataObject != null; csDataObject = csDataObject.getContainer()) + { + Property csp = ((ClassImpl)csDataObject.getType()).getChangeSummaryProperty(); + if (csp != null) return (ChangeSummary)csDataObject.get(csp); + } + } + 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, value).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 Long) + { + return new BigDecimal(((Long)value).longValue()); + } + + 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 ClassCastException("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 ClassCastException 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 ClassCastException("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 ClassCastException 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 ClassCastException("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 ClassCastException 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 ClassCastException("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 ClassCastException 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 ClassCastException("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 ClassCastException 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 ClassCastException("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 ClassCastException 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 ClassCastException("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 ClassCastException 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 ClassCastException 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 ClassCastException("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 ClassCastException 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 ClassCastException("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 ClassCastException 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 ClassCastException("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 ClassCastException 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 ClassCastException("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 ClassCastException 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 ClassCastException("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 ClassCastException 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 ClassCastException("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 ClassCastException 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 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; + } + + protected static Property demandOpenProperty(Type type, String name, Object value, boolean isSequence) + { + TypeHelper typeHelper = TypeHelper.INSTANCE; //FB TODO: what TypeHelper to use? + + String uri = type.getURI() + "/" + type.getName(); // unique URI for open content properties on instances of the type + Property property = typeHelper.getOpenContentProperty(uri, name); + if (property != null) + return property; + + boolean isMany = isSequence; + boolean isContainment = false; + Type propertyType; + + if (value instanceof DataObject) + { + DataObject dataObject = (DataObject)value; + propertyType = dataObject.getType(); + isContainment = dataObject.getContainer() == null; + } + else if (value instanceof List && !((List)value).isEmpty()) + { + Object listValue = ((List)value).get(0); //TODO: get common base class if all values are not the same type? + if (listValue instanceof DataObject) + propertyType = ((DataObject)listValue).getType(); + else + propertyType = typeHelper.getType(listValue.getClass()); + isMany = true; + } + else + { + propertyType = typeHelper.getType(value.getClass()); + } + if (propertyType == null) + { + propertyType = ((ModelFactoryImpl)ModelFactory.INSTANCE).getObject(); + } + + Property newProperty = SDOUtil.createOpenContentProperty(HelperProvider.getDefaultContext(), uri, name, propertyType); + if (isMany) + SDOUtil.setMany(newProperty, isMany); + if (isContainment) + SDOUtil.setContainment(newProperty, isContainment); + + return newProperty; + } + + /** + * Process the default EMF path and minimal XPath syntax. + * This design is still under review and construction. + * + * Syntax: + * + *
+   * path = /? (step '/')* step
+   * step = feature
+   *      | feature '.' index_from_0 
+   *      | feature '[' index_from_1 ']'
+   *      | reference '[' attribute '=' value ']'
+   *      | ..
+   *      | '@' step
+   *
+ * + * feature = the name of an attribute or reference + * attribute = the name of an attribute + * reference = the name of a reference + * index = positive integer + * value = the string value of an attribute + * leading / begins at the root + * .. is containing object + * + * features must be multi-valued to use '.' and '[' operations. + * Only the last step may have an attribute as the feature. + */ + public static final class Accessor //TODO rewrite this using SDO APIs + { + /** + * Creates an accessor for the path of the object. + */ + public static Accessor create(EObject eObject, String path) + { + return create(eObject, path, null); + } + + public static Accessor create(EObject eObject, String path, Object value) + { + Accessor result = pool.get(); + result.init(eObject, path, value); + 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 Object value; + + protected EStructuralFeature feature; + + protected int index; + + RuntimeException runtimeException; + + protected Accessor() + { + } + + //protected Accessor(EObject eObject, String path) + //{ + // init(eObject, path); + //} + + protected void init(EObject eObject, String path, Object value) + { + this.eObject = eObject; + this.value = value; + runtimeException = null; + + // 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; + } + + protected final void assertSuccessfulProcess() + { + if (runtimeException != null) + throw runtimeException; + } + + public void set(Object newValue) + { + assertSuccessfulProcess(); + 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 feature != null && eObject.eIsSet(feature); + } + + public boolean isSetAndRecyle() + { + boolean result = isSet(); + pool.recycle(this); + return result; + } + + public void unset() + { + assertSuccessfulProcess(); + 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() + { + assertSuccessfulProcess(); + return (Property)feature; + } + + protected void setFeatureName(String name) + { + if (name != null) + { + feature = (EStructuralFeature)((DataObject)eObject).getInstanceProperty(name); + if (feature == null) + { + int index = name.lastIndexOf('.'); + if (index == -1) + { + Type type = (Type)eObject.eClass(); + if (value != null && type.isOpen()) + { + feature = (EStructuralFeature)demandOpenProperty(type, name, value, false); + this.index = NO_INDEX; + return; + } + runtimeException = new IllegalArgumentException("Class '" + eObject.eClass().getName() + "' does not have a feature named '" + name + '\''); + } + else + { + int propertyNameEnd = index; + try + { + index = Integer.parseInt(name.substring(++index)); + // NumberFormatException may be thrown + String propertyName = name.substring(0, propertyNameEnd); + feature = (EStructuralFeature)((DataObject)eObject).getInstanceProperty(propertyName); + if (feature != null) + { + setIndex(index); + return; + } + runtimeException = new IllegalArgumentException("Class '" + eObject.eClass().getName() + "' does not have a feature named '" + name + "' or '" + propertyName + '\''); + } + catch(NumberFormatException eNumberFormat) + { + runtimeException = eNumberFormat; + } + } + setEObject(null); + } + } + 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 not be less than 0. + runtimeException = new IndexOutOfBoundsException("Index value is too low"); + setEObject(null); + return; + } + if (!FeatureMapUtil.isMany(eObject, feature)) + { + runtimeException = new IndexOutOfBoundsException("Index applies only to multi-valued features"); + setEObject(null); + return; + } + int size = ((List) eObject.eGet(feature)).size(); + if (index >= size) + { + // The index value should be less than size. + runtimeException = new IndexOutOfBoundsException("Index value should have been less than " + size); + setEObject(null); + } + this.index = index; + } + + 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()); + if (eObject == null) break; + } + else if ("..".equals(token)) + { + setEObject(eObject.eContainer()); + if (eObject == null) break; + } + else if ('[' == c) + { + x++; // skip [ + token = tokens.peek(x); // name or index + char following = tokens.peek(x + 1).charAt(0); + if ('=' != following) + { + try + { + setIndex(Integer.parseInt(token) - 1); + // runtimeException may be recorded + } + catch(NumberFormatException eNumberFormat) + { + runtimeException = eNumberFormat; + setEObject(null); + break; + } + if (runtimeException != null) + break; + 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); + break; + } + else + { + setIndex(index); + } + } + } + else if ('@' == c) + { + // skip @ + } + else + { + setFeatureName(token); + if (eObject == null) break; + } + } + } + + protected static int matchingIndex(List dataObjects, String attributeName, String attributeValue) + { + for (int i = 0, size = dataObjects.size(); i < size; i++) + { + DataObject dataObject = (DataObject)dataObjects.get(i); + Property property = getInstanceProperty(dataObject, attributeName); + if (property != null) + { + Object test = dataObject.get(property); + if (test != null) + { + String testString = EcoreUtil.convertToString((EDataType)property.getType(), 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 ':': + if (cPrev != c) + { + endToken(token, false); + } + token.append(c); + if (cNext != c) + { + endToken(token, false); + } + break; + + // double token (..) + case '.': + if (cNext == '.') + endToken(token, false); + token.append(c); + if (cPrev == '.') + 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 getInstanceProperty(DataObject dataObject, String propertyName) + { + ClassImpl type = (ClassImpl)dataObject.getType(); + Property property = type.getProperty(propertyName); + if (property == null) + { + property = type.getOpenProperty((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(); + try { + Property property = propertyIndex < typeProperties.size() ? + (Property)typeProperties.get(propertyIndex) : + (Property)dataObject.getInstanceProperties().get(propertyIndex); + + return property; + } catch (IndexOutOfBoundsException e) { + throw new IllegalArgumentException(); + } + } + + 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); + if ((type instanceof EClass) && !type.isAbstract()) { + EClass eClass = (EClass)type; + try { + return (DataObject)EcoreUtil.create(eClass); + } catch (ClassCastException e) { + throw new IllegalArgumentException(); + } + } + throw new IllegalArgumentException(); + } + + 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()); + resourceSet.setPackageRegistry(new EPackageRegistryImpl(HelperContextImpl.getBuiltInModelRegistry())); +// resourceSet.setURIConverter(new SDOURIConverterImpl()); + } + + public static EClass createDocumentRoot() + { + EClass documentRootEClass = (EClass)SDOFactory.eINSTANCE.createClass(); + documentRootEClass.setName("DocumentRoot"); + ExtendedMetaData.INSTANCE.setName(documentRootEClass, ""); + ExtendedMetaData.INSTANCE.setContentKind(documentRootEClass, ExtendedMetaData.MIXED_CONTENT); + + EAttribute mixed = (EAttribute)SDOFactory.eINSTANCE.createAttribute(); + 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 = (EReference)SDOFactory.eINSTANCE.createReference(); + 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 = (EReference)SDOFactory.eINSTANCE.createReference(); + 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 root) + { + DataObject container = dataObject.getContainer(); + if (container == null) return path; + + if (container == root) { + throw new IllegalStateException("There is a cycle in the containment hierarchy of " + root); + } + + boolean first = path.length() == 0; + Property property = dataObject.getContainmentProperty(); + if (SDOUtil.isMany(property, dataObject)) + { + 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, root); + } + */ + + public static String getXPath(DataObject dataObject) + { + return SDOUtil.getXPath(dataObject); + //StringBuffer path = getXPath(dataObject, new StringBuffer(), dataObject); + //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); + } + + /** + * @deprecated SDO runtime initialization is no longer required + */ + 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; + } + */ + + /** + * Returns a unique list of meta object instance properties (stored in EAnnotations) + * + * @param metaObject - A Type or Property instance + * @return A list of commonj.sdo.Property instances + */ + public static List getMetaObjectInstanceProperties(EModelElement metaObject) + { + // Use the default helper context for now +// TypeHelper typeHelper = HelperProvider.getDefaultContext().getTypeHelper(); + HelperContext hc = HelperProvider.getDefaultContext(); + + List result = new UniqueEList(); + List annotations = metaObject.getEAnnotations(); + int size = annotations.size(); + for (int i=0; i + *
  • ignorableWhitespace
  • + *
  • skippedEntity
  • + *
      + * Also the following StAX events are not mapped: + *
        + *
      • CDATA
      • + *
      • COMMENT
      • + *
      • DTD
      • + *
      • ENTITY_DECLARATION
      • + *
      • ENTITY_REFERENCE
      • + *
      • NOTATION_DECLARATION
      • + *
      • SPACE
      • + *
      + * 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. + *

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

      + * For example + *

      + * <a:root xmlns:a="foo" xmlns:b="bar"><b:sub>a:foo</b:sub></a:root> + *

      + * And if you are handed a parser at <b:sub>, then your SAX events should look like: + *

      + * <b:sub xmlns:a="foo" xmlns:b="bar">a:foo</b:sub> + *

      + * not: + *

      + * <b:sub>a:foo</b:sub> + *

      + *

      + * 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 == 1) { + 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/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/StreamDeserializer.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/StreamDeserializer.java new file mode 100644 index 0000000000..5d7bee9c3f --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/StreamDeserializer.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.util; + +import java.util.Comparator; + +import javax.xml.XMLConstants; +import javax.xml.namespace.NamespaceContext; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamReader; + +import org.apache.tuscany.sdo.util.resource.RecordedEventXMLStreamReader; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.ExtendedMetaData; +import org.eclipse.emf.ecore.xmi.XMLResource; +import org.eclipse.emf.ecore.xml.type.internal.QName; + +/** + * StAX Deserializer. The instance isn't thread-safe, however it's safe to use the instance any times on the same thread. + */ +public class StreamDeserializer implements XMLStreamConstants { + protected XMLStreamReader reader; + + protected final XMLStreamReader play(RecordedEventXMLStreamReader.Tag tag) { + return tag.play(reader); + } + + protected String nameSpace, name; + + protected final boolean typedXSI() { + name = reader.getAttributeValue(ExtendedMetaData.XSI_URI, XMLResource.TYPE); + if (name == null) + return false; + int index = name.indexOf(':'); + if (index == -1) + nameSpace = reader.getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX); // may be XMLConstants.NULL_NS_URI + else { + nameSpace = reader.getNamespaceURI(name.substring(0, index)); + name = name.substring(++index); + } + return true; + } + + static protected Object value(Object type, String literal, NamespaceContext nameSpaces) { + Object value = EcoreUtil.createFromString((EDataType) type, literal); + if (!(value instanceof QName)) + return value; + QName qName = (QName) value; + qName.setNamespaceURI(nameSpaces.getNamespaceURI(qName.getPrefix())); + return value; + } + + static public class Attribute { + public String name, value; + } + + static public final class QualifiedAttribute extends Attribute { + public String nameSpace; + } + + static protected final Comparator EQUAL_NULL = new Comparator() { + public int compare(Object v, Object NULL) { + return v == null || v.equals(null) ? 0 : 1; + } + }, EQUAL = new Comparator() { + public int compare(Object v, Object value) { + return value.equals(v) ? 0 : -1; + } + }, SAME = new Comparator() { + public int compare(Object v, Object value) { + return value == v ? 0 : -1; + } + }; +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/VirtualSequence.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/VirtualSequence.java new file mode 100644 index 0000000000..2f86fa9d12 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/VirtualSequence.java @@ -0,0 +1,780 @@ +/** + * + * 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.util.Iterator; +import java.util.List; + +import org.apache.tuscany.sdo.impl.ClassImpl; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.util.FeatureMapUtil; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Sequence; + +/** + * SDO Sequance implementation which delegates to a Collection of DataObject properties. + */ +public class VirtualSequence implements Sequence +{ + private final DataObject dataObject; + protected final List delegateProperties; // size > 1 + + public VirtualSequence(DataObject object) + { + dataObject = object; + delegateProperties = ((ClassImpl)dataObject.getType()).getVirtualSequenceProperties(); + } + + static protected boolean isSequenceProperty(Object property) + { + return FeatureMapUtil.isFeatureMap((EStructuralFeature)property); + } + + public int size() + { + int size = 0; + for (Iterator iterator = delegateProperties.iterator() ; iterator.hasNext() ;) + { + Property property = (Property)iterator.next(); + if (dataObject.isSet(property)) + if (isSequenceProperty(property)) + size += ((Sequence)dataObject.get(property)).size(); + else if (property.isMany()) + size += dataObject.getList(property).size(); + else + ++size; + } + return size; + } + + public Property getProperty(int index) + { + for (Iterator iterator = delegateProperties.iterator() ; iterator.hasNext() ;) + { + Property property = (Property)iterator.next(); + if (dataObject.isSet(property)) + if (isSequenceProperty(property)) + { + Sequence sequence = (Sequence)dataObject.get(property); + int size = sequence.size(); + if (index < size) + return sequence.getProperty(index); + index -= size; + } + else if (property.isMany()) + { + int size = dataObject.getList(property).size(); + if (index < size) + return property; + index -= size; + } + else if (index == 0) + return property; + else + --index; + } + throw new IndexOutOfBoundsException(); + } + + public Object getValue(int index) + { + for (Iterator iterator = delegateProperties.iterator() ; iterator.hasNext() ;) + { + Property property = (Property)iterator.next(); + if (dataObject.isSet(property)) + if (isSequenceProperty(property)) + { + Sequence sequence = (Sequence)dataObject.get(property); + int size = sequence.size(); + if (index < size) + return sequence.getValue(index); + index -= size; + } + else if (property.isMany()) + { + List values = dataObject.getList(property); + int size = values.size(); + if (index < size) + return values.get(index); + index -= size; + } + else if (index == 0) + return dataObject.get(property); + else + --index; + } + throw new IndexOutOfBoundsException(); + } + + public Object setValue(int index, Object value) + { + for (Iterator iterator = delegateProperties.iterator() ; iterator.hasNext() ;) + { + Property property = (Property)iterator.next(); + if (dataObject.isSet(property)) + if (isSequenceProperty(property)) + { + Sequence sequence = (Sequence)dataObject.get(property); + int size = sequence.size(); + if (index < size) + return sequence.setValue(index, value); + index -= size; + } + else if (property.isMany()) + { + List values = dataObject.getList(property); + int size = values.size(); + if (index < size) + return values.set(index, value); + index -= size; + } + else if (index == 0) + { + Object old = dataObject.get(property); + dataObject.set(property, value); + return old; + } + else + --index; + } + throw new IndexOutOfBoundsException(); + } + + boolean validate(EStructuralFeature feature, Object property) + { + return FeatureMapUtil.getValidator((EClass)dataObject.getType(), feature).isValid((EStructuralFeature)property); + } + + boolean append(Property delegateProperty, Property property, Object value) + { + return ((Sequence)dataObject.get(delegateProperty)).add(property, value); + } + + boolean append(Property property, Object value) + { + return dataObject.getList(property).add(value); + } + + boolean set(Property property, Object value) + { + if (property.isMany()) + return append(property, value); + dataObject.set(property, value); + return true; + } + + public final boolean add(Property p, Object value) + { + Property property; + int size = delegateProperties.size(), index = size; + do + { + property = (Property)delegateProperties.get(--index); + if (!dataObject.isSet(property)) + continue; + EStructuralFeature feature = (EStructuralFeature)property; + if (FeatureMapUtil.isFeatureMap(feature)) + { + if (validate(feature, p)) + return append(property, p, value); + } + else if (property == p && property.isMany()) + return append(property, value); + if (size == ++index) + return false; + property = (Property)delegateProperties.get(index); + break; + } + while (index != 0); + for (;;) + { + EStructuralFeature feature = (EStructuralFeature)property; + if (FeatureMapUtil.isFeatureMap(feature)) + { + if (validate(feature, p)) + return append(property, p, value); + } + else if (property == p) + return set(p, value); + if (size == ++index) + return false; + property = (Property)delegateProperties.get(index); + } + } + + protected final Property property(String name) + { + return dataObject.getType().getProperty(name); + } + + public boolean add(String propertyName, Object value) + { + return add(property(propertyName), value); + } + + protected final Property property(int index) + { + return (Property)dataObject.getType().getProperties().get(index); + } + + public boolean add(int propertyIndex, Object value) + { + return add(property(propertyIndex), value); + } + + void insert(Property property, Property p, Object value) + { + ((Sequence)dataObject.get(property)).add(0, p, value); + } + + void insert(Property property, Object value) + { + dataObject.getList(property).add(0, value); + } + + protected final int insert(Iterator iterator, Property p, Object value) + { + while (iterator.hasNext()) + { + Property property = (Property)iterator.next(); + EStructuralFeature feature = (EStructuralFeature)property; + if (dataObject.isSet(property)) + { + if (FeatureMapUtil.isFeatureMap(feature)) + { + if (!validate(feature, p)) + return 2; + insert(property, p, value); + return 0; + } + if (property != p || !property.isMany()) + return 2; + insert(property, value); + return 0; + } + if (FeatureMapUtil.isFeatureMap(feature)) + { + if (validate(feature, p)) + { + append(property, p, value); + return 0; + } + } + else if (property == p) + { + set(property, value); + return 0; + } + } // iterator.hasNext() + return 1; + } + + public final void add(int index, Property p, Object value) + { + Iterator iterator = delegateProperties.iterator(); + if (index == 0) + switch (insert(iterator, p, value)) + { + case 0: + return; + case 1: + throw new IndexOutOfBoundsException(); + default: // 2 + throw new IllegalArgumentException(); + } + while (iterator.hasNext()) + { + Property property = (Property)iterator.next(); + if (dataObject.isSet(property)) + if (isSequenceProperty(property)) + { + Sequence sequence = (Sequence)dataObject.get(property); + int size = sequence.size(); + if (index < size) + { + sequence.add(index, p, value); + return; + } + index -= size; + if (index != 0) + continue; + if (insert(iterator, p, value) != 0) + /*assert */sequence.add(p, value); + return; + } // sequence(property) + else if (property.isMany()) + { + List values = dataObject.getList(property); + int size = values.size(); + if (index < size) + { + values.add(index, value); + return; + } + index -= size; + if (index == 0 && property == p) + { + values.add(value); + return; + } + } + else if (index == 0) + throw new IllegalArgumentException(); + else + --index; + } + throw new IndexOutOfBoundsException(); + } + + public void add(int index, String propertyName, Object value) + { + add(index, property(propertyName), value); + } + + public void add(int index, int propertyIndex, Object value) + { + add(index, property(propertyIndex), value); + } + + public final void addText(String text) + { + throw new IllegalArgumentException(); + } + + /** + * @deprecated + */ + public void add(String text) + { + addText(text); + } + + public final void addText(int index, String text) + { + throw new IllegalArgumentException(); + } + + /** + * @deprecated + */ + public void add(int index, String text) + { + addText(index, text); + } + + public void remove(int index) + { + for (Iterator iterator = delegateProperties.iterator() ; iterator.hasNext() ;) + { + Property property = (Property)iterator.next(); + if (dataObject.isSet(property)) + if (isSequenceProperty(property)) + { + Sequence sequence = (Sequence)dataObject.get(property); + int size = sequence.size(); + if (index < size) + { + sequence.remove(index); + return; + } + index -= size; + } + else if (property.isMany()) + { + List values = dataObject.getList(property); + int size = values.size(); + if (index < size) + { + values.remove(index); + return; + } + index -= size; + } + else if (index == 0) + { + dataObject.unset(property); + return; + } + else + --index; + } + throw new IndexOutOfBoundsException(); + } + + static private Object remove(Sequence sequence, int index) + { + Object value = sequence.getValue(index); + sequence.remove(index); + return value; + } + + static void move(Sequence fromSequence, int fromIndex, Sequence toSequence, int toIndex, Property property) + { + toSequence.add(toIndex, property, remove(fromSequence, fromIndex)); // removes containment + } + + static protected void move(Sequence fromSequence, int fromIndex, Sequence toSequence, int toIndex) + { + move(fromSequence, fromIndex, toSequence, toIndex, fromSequence.getProperty(fromIndex)); + } + + static protected void add(Object value,List list,int index, int size) + { + if (++index == size) + /*assert */list.add(value); + else + list.add(index, value); // removes containment + } + + static protected void add(Property property, Object value, Sequence toSequence, int toIndex, int size) + { + if (++toIndex == size) + toSequence.add(property, value); // removes containment + else + toSequence.add(toIndex, property, value); // removes containment + } + + public void move(int toIndex, int fromIndex) + { + for (Iterator iterator = delegateProperties.iterator(); iterator.hasNext() ;) + { + Property property = (Property)iterator.next(); + if (dataObject.isSet(property)) + if (isSequenceProperty(property)) + { + Sequence sequence = (Sequence)dataObject.get(property); + int size = sequence.size(); + if (toIndex < size) + { + if (fromIndex < size) + { + sequence.move(toIndex, fromIndex); + return; + } + while (iterator.hasNext()) + { + property = (Property)iterator.next(); + if (!dataObject.isSet(property)) + continue; + fromIndex -= size; + if (isSequenceProperty(property)) + { + Sequence fromSequence = (Sequence)dataObject.get(property); + size = fromSequence.size(); + if (fromIndex >= size) + continue; + move(fromSequence, fromIndex, sequence, toIndex); + return; + } + if (property.isMany()) + { + List list = dataObject.getList(property); + size = list.size(); + if (fromIndex >= size) + continue; + sequence.add(toIndex, property, list.remove(fromIndex)); // removes containment + return; + } + if (fromIndex == 0) + { + sequence.add(toIndex, property, dataObject.get(property)); // removes containment + dataObject.unset(property); + return; + } + size = 1; + } // iterator.hasNext() + break; + } // toIndex < size + if (fromIndex < size) + { + while (iterator.hasNext()) + { + property = (Property)iterator.next(); + if (!dataObject.isSet(property)) + continue; + toIndex -= size; + if (isSequenceProperty(property)) + { + Sequence toSequence = (Sequence)dataObject.get(property); + size = toSequence.size(); + if (toIndex >= size) + continue; + if (++toIndex == size) + toSequence.add(sequence.getProperty(fromIndex), remove(sequence, fromIndex)); // Java pushes stack from left to right + // removes containment + else + move(sequence, fromIndex, toSequence, toIndex); + return; + } + if (property.isMany()) + { + List list = dataObject.getList(property); + size = list.size(); + if (toIndex >= size) + continue; + if (sequence.getProperty(fromIndex) != property) + throw new IllegalArgumentException(); + add(remove(sequence, fromIndex), list, toIndex, size); + return; + } + if (toIndex == 0) + { + while (iterator.hasNext()) + { + Property p = sequence.getProperty(fromIndex); + property = (Property)iterator.next(); + EStructuralFeature feature = (EStructuralFeature)property; + if (dataObject.isSet(property)) + { + if (FeatureMapUtil.isFeatureMap(feature)) + { + /*if (!validate(feature, p)) + throw new IllegalArgumentException(); */ + move(sequence, fromIndex, (Sequence)dataObject.get(property), 0, p); + return; + } + if (property != p || !property.isMany()) + throw new IllegalArgumentException(); + insert(property, remove(sequence, fromIndex)); // removes containment + return; + } + if (FeatureMapUtil.isFeatureMap(feature)) + { + if (validate(feature, p)) + { + append(property, p, remove(sequence, fromIndex)); // removes containment + return; + } + } + else if (property == p) + { + set(property, remove(sequence, fromIndex)); + return; + } + } // iterator.hasNext() + break; + } + size = 1; + } // iterator.hasNext() + break; + } // fromIndex < size + toIndex -= size; + fromIndex -= size; + } // sequence(property) + else if (property.isMany()) + { + List list = dataObject.getList(property); + int size = list.size(); + if (toIndex < size) + { + if (fromIndex < size) + { + ((EList)list).move(toIndex, fromIndex); + return; + } + while (iterator.hasNext()) + { + Property p = (Property)iterator.next(); + if (!dataObject.isSet(p)) + continue; + fromIndex -= size; + if (isSequenceProperty(p)) + { + Sequence fromSequence = (Sequence)dataObject.get(p); + size = fromSequence.size(); + if (fromIndex >= size) + continue; + if (fromSequence.getProperty(fromIndex) != property) + throw new IllegalArgumentException(); + list.add(toIndex, remove(fromSequence, fromIndex)); // removes containment + return; + } + if (p.isMany()) + { + List l = dataObject.getList(p); + size = l.size(); + if (fromIndex >= size) + continue; + /*if (p != property) + throw new IllegalArgumentException(); */ + list.add(toIndex, l.remove(fromIndex)); // removes containment + return; + } + if (fromIndex == 0) + { + /*if (p != property) + throw new IllegalArgumentException(); */ + list.add(toIndex, dataObject.get(p)); // removes containment + dataObject.unset(p); + return; + } + size = 1; + } // iterator.hasNext() + break; + } // toIndex < size + if (fromIndex < size) + { + while (iterator.hasNext()) + { + Property p = (Property)iterator.next(); + if (!dataObject.isSet(p)) + continue; + toIndex -= size; + if (isSequenceProperty(p)) + { + Sequence toSequence = (Sequence)dataObject.get(p); + size = toSequence.size(); + if (toIndex >= size) + continue; + add(property, list.remove(fromIndex), toSequence, toIndex, size); + return; + } + if (p.isMany()) + { + List l = dataObject.getList(p); + size = l.size(); + if (toIndex >= size) + continue; + /*if (property != p) + throw new IllegalArgumentException(); */ + add(list.remove(fromIndex), l, toIndex, size); + return; + } + if (toIndex == 0) + { + while (iterator.hasNext()) + { + p = (Property)iterator.next(); + EStructuralFeature feature = (EStructuralFeature)p; + if (dataObject.isSet(p)) + { + if (FeatureMapUtil.isFeatureMap(feature)) + { + /*if (!validate(feature, property)) + throw new IllegalArgumentException(); */ + insert(p, property, list.remove(fromIndex)); + return; + } + if (/*p != property || */!p.isMany()) + throw new IllegalArgumentException(); + insert(p, list.remove(fromIndex)); // removes containment + return; + } + if (FeatureMapUtil.isFeatureMap(feature)) + { + if (!validate(feature, property)) + continue; + append(p, property, list.remove(fromIndex)); // removes containment + return; + } + else if (p == property) + { + set(p, list.remove(fromIndex)); + return; + } + } // iterator.hasNext() + break; + } // toIndex == 0 + size = 1; + } // iterator.hasNext() + break; + } // fromIndex < size + toIndex -= size; + fromIndex -= size; + } // property.isMany() + else if (toIndex == 0) + throw new IllegalArgumentException(); + else if (fromIndex == 0) + { + for (int size = 1; iterator.hasNext() ;) + { + Property p = (Property)iterator.next(); + if (!dataObject.isSet(p)) + continue; + toIndex -= size; + if (isSequenceProperty(p)) + { + Sequence toSequence = (Sequence)dataObject.get(p); + size = toSequence.size(); + if (toIndex >= size) + continue; + add(property, dataObject.get(property), toSequence, toIndex, size); + dataObject.unset(property); + return; + } + if (p.isMany()) + { + List l = dataObject.getList(p); + size = l.size(); + if (toIndex >= size) + continue; + /*if (property != p) + throw new IllegalArgumentException(); */ + add(dataObject.get(property), l, toIndex, size); + dataObject.unset(property); + return; + } + if (toIndex == 0) + { + while (iterator.hasNext()) + { + p = (Property)iterator.next(); + EStructuralFeature feature = (EStructuralFeature)p; + if (dataObject.isSet(p)) + if (FeatureMapUtil.isFeatureMap(feature)) + /*if (!validate(feature, property)) + throw new IllegalArgumentException(); */ + insert(p, property, dataObject.get(property)); + else if (/*p == property && */p.isMany()) + insert(p, dataObject.get(property)); // removes containment + else + throw new IllegalArgumentException(); + else if (FeatureMapUtil.isFeatureMap(feature)) + { + if (!validate(feature, property)) + continue; + append(p, property, dataObject.get(property)); // removes containment + } + else if (p == property) + set(p, dataObject.get(property)); + else + continue; + dataObject.unset(property); + return; + } // iterator.hasNext() + break; + } // toIndex == 0 + size = 1; + } // iterator.hasNext() + break; + } // fromIndex == 0 + else + { + --toIndex; + --fromIndex; + } + } + throw new IndexOutOfBoundsException(); + } +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/JavaMetaData.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/JavaMetaData.java new file mode 100644 index 0000000000..f24b166f77 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/JavaMetaData.java @@ -0,0 +1,90 @@ +/** + * + * 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.io.Serializable; + +/** + * + * A representation of the model object 'Java Meta Data'. + * + * + *

      + * The following features are supported: + *

        + *
      • {@link org.apache.tuscany.sdo.util.metadata.JavaMetaData#getFactoryInterface Factory Interface}
      • + *
      • {@link org.apache.tuscany.sdo.util.metadata.JavaMetaData#getTypeInterface Type Interface}
      • + *
      + *

      + * + * @extends Serializable + * @generated + */ +public interface JavaMetaData extends Serializable +{ + /** + * Returns the value of the 'Factory Interface' attribute. + * + *

      + * If the meaning of the 'Factory Interface' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Factory Interface' attribute. + * @see #setFactoryInterface(String) + * @generated + */ + String getFactoryInterface(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.util.metadata.JavaMetaData#getFactoryInterface Factory Interface}' attribute. + * + * + * @param value the new value of the 'Factory Interface' attribute. + * @see #getFactoryInterface() + * @generated + */ + void setFactoryInterface(String value); + + /** + * Returns the value of the 'Type Interface' attribute. + * + *

      + * If the meaning of the 'Type Interface' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Type Interface' attribute. + * @see #setTypeInterface(String) + * @generated + */ + String getTypeInterface(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.util.metadata.JavaMetaData#getTypeInterface Type Interface}' attribute. + * + * + * @param value the new value of the 'Type Interface' attribute. + * @see #getTypeInterface() + * @generated + */ + void setTypeInterface(String value); + +} // JavaMetaData diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/MetadataFactory.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/MetadataFactory.java new file mode 100644 index 0000000000..1f540afa2c --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/MetadataFactory.java @@ -0,0 +1,77 @@ +/** + * + * 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; + + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @generated + */ +public interface MetadataFactory +{ + + /** + * The singleton instance of the factory. + * + * + * @generated + */ + MetadataFactory INSTANCE = org.apache.tuscany.sdo.util.metadata.impl.MetadataFactoryImpl.init(); + + /** + * Returns a new object of class 'Java Meta Data'. + * + * + * @return a new object of class 'Java Meta Data'. + * @generated + */ + JavaMetaData createJavaMetaData(); + + /** + * Returns a new object of class 'SDO Meta Data Group'. + * + * + * @return a new object of class 'SDO Meta Data Group'. + * @generated + */ + SDOMetaDataGroup createSDOMetaDataGroup(); + + /** + * Returns a new object of class 'Type Meta Data'. + * + * + * @return a new object of class 'Type Meta Data'. + * @generated + */ + TypeMetaData createTypeMetaData(); + + /** + * Returns a new object of class 'XSD Meta Data'. + * + * + * @return a new object of class 'XSD Meta Data'. + * @generated + */ + XSDMetaData createXSDMetaData(); + +} //MetadataFactory diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/SDOMetaDataGroup.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/SDOMetaDataGroup.java new file mode 100644 index 0000000000..5657f26ca5 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/SDOMetaDataGroup.java @@ -0,0 +1,87 @@ +/** + * + * 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.io.Serializable; + +import java.util.List; + +/** + * + * A representation of the model object 'SDO Meta Data Group'. + * + * + *

      + * The following features are supported: + *

        + *
      • {@link org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getJavaMetaData Java Meta Data}
      • + *
      • {@link org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getXsdMetaData Xsd Meta Data}
      • + *
      • {@link org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getTypeMetaData Type Meta Data}
      • + *
      + *

      + * + * @extends Serializable + * @generated + */ +public interface SDOMetaDataGroup extends Serializable +{ + /** + * Returns the value of the 'Java Meta Data' containment reference list. + * The list contents are of type {@link org.apache.tuscany.sdo.util.metadata.JavaMetaData}. + * + *

      + * If the meaning of the 'Java Meta Data' containment reference list isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Java Meta Data' containment reference list. + * @generated + */ + List getJavaMetaData(); + + /** + * Returns the value of the 'Xsd Meta Data' containment reference list. + * The list contents are of type {@link org.apache.tuscany.sdo.util.metadata.XSDMetaData}. + * + *

      + * If the meaning of the 'Xsd Meta Data' containment reference list isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Xsd Meta Data' containment reference list. + * @generated + */ + List getXsdMetaData(); + + /** + * Returns the value of the 'Type Meta Data' containment reference list. + * The list contents are of type {@link org.apache.tuscany.sdo.util.metadata.TypeMetaData}. + * + *

      + * If the meaning of the 'Type Meta Data' containment reference list isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Type Meta Data' containment reference list. + * @generated + */ + List getTypeMetaData(); + +} // SDOMetaDataGroup diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/TypeMetaData.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/TypeMetaData.java new file mode 100644 index 0000000000..c3d67a8318 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/TypeMetaData.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.util.metadata; + +import java.io.Serializable; + +/** + * + * A representation of the model object 'Type Meta Data'. + * + * + *

      + * The following features are supported: + *

        + *
      • {@link org.apache.tuscany.sdo.util.metadata.TypeMetaData#getLocation Location}
      • + *
      + *

      + * + * @extends Serializable + * @generated + */ +public interface TypeMetaData extends Serializable +{ + /** + * Returns the value of the 'Location' attribute. + * + *

      + * If the meaning of the 'Location' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Location' attribute. + * @see #setLocation(String) + * @generated + */ + String getLocation(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.util.metadata.TypeMetaData#getLocation Location}' attribute. + * + * + * @param value the new value of the 'Location' attribute. + * @see #getLocation() + * @generated + */ + void setLocation(String value); + +} // TypeMetaData diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/XSDMetaData.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/XSDMetaData.java new file mode 100644 index 0000000000..09bffece71 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/XSDMetaData.java @@ -0,0 +1,66 @@ +/** + * + * 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.io.Serializable; + +/** + * + * A representation of the model object 'XSD Meta Data'. + * + * + *

      + * The following features are supported: + *

        + *
      • {@link org.apache.tuscany.sdo.util.metadata.XSDMetaData#getLocation Location}
      • + *
      + *

      + * + * @extends Serializable + * @generated + */ +public interface XSDMetaData extends Serializable +{ + /** + * Returns the value of the 'Location' attribute. + * + *

      + * If the meaning of the 'Location' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Location' attribute. + * @see #setLocation(String) + * @generated + */ + String getLocation(); + + /** + * Sets the value of the '{@link org.apache.tuscany.sdo.util.metadata.XSDMetaData#getLocation Location}' attribute. + * + * + * @param value the new value of the 'Location' attribute. + * @see #getLocation() + * @generated + */ + void setLocation(String value); + +} // XSDMetaData diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/JavaMetaDataImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/JavaMetaDataImpl.java new file mode 100644 index 0000000000..8a6dce6161 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/JavaMetaDataImpl.java @@ -0,0 +1,267 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.util.metadata.impl; + +import commonj.sdo.Type; + +import org.apache.tuscany.sdo.impl.DataObjectBase; + +import org.apache.tuscany.sdo.util.metadata.JavaMetaData; +import org.apache.tuscany.sdo.util.metadata.MetadataFactory; + +/** + * + * An implementation of the model object 'Java Meta Data'. + * + *

      + * The following features are implemented: + *

        + *
      • {@link org.apache.tuscany.sdo.util.metadata.impl.JavaMetaDataImpl#getFactoryInterface Factory Interface}
      • + *
      • {@link org.apache.tuscany.sdo.util.metadata.impl.JavaMetaDataImpl#getTypeInterface Type Interface}
      • + *
      + *

      + * + * @generated + */ +public class JavaMetaDataImpl extends DataObjectBase implements JavaMetaData +{ + /** + * The feature id for the 'Factory Interface' attribute. + * + * + * @generated + * @ordered + */ + public final static int FACTORY_INTERFACE = 0; + + /** + * The feature id for the 'Type Interface' attribute. + * + * + * @generated + * @ordered + */ + public final static int TYPE_INTERFACE = 1; + + /** + * This represents the number of properties for this type. + * + * + * @generated + * @ordered + */ + + public final static int SDO_PROPERTY_COUNT = 2; + + /** + * The default value of the '{@link #getFactoryInterface() Factory Interface}' attribute. + * + * + * @see #getFactoryInterface() + * @generated + * @ordered + */ + protected static final String FACTORY_INTERFACE_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getFactoryInterface() Factory Interface}' attribute. + * + * + * @see #getFactoryInterface() + * @generated + * @ordered + */ + protected String factoryInterface = FACTORY_INTERFACE_DEFAULT_; + + /** + * The default value of the '{@link #getTypeInterface() Type Interface}' attribute. + * + * + * @see #getTypeInterface() + * @generated + * @ordered + */ + protected static final String TYPE_INTERFACE_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getTypeInterface() Type Interface}' attribute. + * + * + * @see #getTypeInterface() + * @generated + * @ordered + */ + protected String typeInterface = TYPE_INTERFACE_DEFAULT_; + + /** + * + * + * @generated + */ + protected JavaMetaDataImpl() + { + super(); + } + + /** + * + * + * @generated + */ + public Type getStaticType() + { + return ((MetadataFactoryImpl)MetadataFactory.INSTANCE).getJavaMetaData(); + } + + /** + * + * + * @generated + */ + public String getFactoryInterface() + { + return factoryInterface; + } + /** + * + * + * @generated + */ + public void setFactoryInterface(String newFactoryInterface) + { + String oldFactoryInterface = factoryInterface; + factoryInterface = newFactoryInterface; + if (isNotifying()) + notify(ChangeKind.SET, FACTORY_INTERFACE, oldFactoryInterface, factoryInterface); + } + + /** + * + * + * @generated + */ + public String getTypeInterface() + { + return typeInterface; + } + /** + * + * + * @generated + */ + public void setTypeInterface(String newTypeInterface) + { + String oldTypeInterface = typeInterface; + typeInterface = newTypeInterface; + if (isNotifying()) + notify(ChangeKind.SET, TYPE_INTERFACE, oldTypeInterface, typeInterface); + } + + /** + * + * + * @generated + */ + public Object get(int propertyIndex, boolean resolve) + { + switch (propertyIndex) + { + case FACTORY_INTERFACE: + return getFactoryInterface(); + case TYPE_INTERFACE: + return getTypeInterface(); + } + return super.get(propertyIndex, resolve); + } + + /** + * + * + * @generated + */ + public void set(int propertyIndex, Object newValue) + { + switch (propertyIndex) + { + case FACTORY_INTERFACE: + setFactoryInterface((String)newValue); + return; + case TYPE_INTERFACE: + setTypeInterface((String)newValue); + return; + } + super.set(propertyIndex, newValue); + } + + /** + * + * + * @generated + */ + public void unset(int propertyIndex) + { + switch (propertyIndex) + { + case FACTORY_INTERFACE: + setFactoryInterface(FACTORY_INTERFACE_DEFAULT_); + return; + case TYPE_INTERFACE: + setTypeInterface(TYPE_INTERFACE_DEFAULT_); + return; + } + super.unset(propertyIndex); + } + + /** + * + * + * @generated + */ + public boolean isSet(int propertyIndex) + { + switch (propertyIndex) + { + case FACTORY_INTERFACE: + return FACTORY_INTERFACE_DEFAULT_ == null ? factoryInterface != null : !FACTORY_INTERFACE_DEFAULT_.equals(factoryInterface); + case TYPE_INTERFACE: + return TYPE_INTERFACE_DEFAULT_ == null ? typeInterface != null : !TYPE_INTERFACE_DEFAULT_.equals(typeInterface); + } + return super.isSet(propertyIndex); + } + + /** + * + * + * @generated + */ + public String toString() + { + if (isProxy(this)) 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/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/MetadataFactoryImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/MetadataFactoryImpl.java new file mode 100644 index 0000000000..a4ea322549 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/MetadataFactoryImpl.java @@ -0,0 +1,367 @@ +/** + * + * 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 commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; + +import org.apache.tuscany.sdo.SDOFactory; + +import org.apache.tuscany.sdo.impl.FactoryBase; + +import org.apache.tuscany.sdo.model.ModelFactory; + +import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl; + +import org.apache.tuscany.sdo.util.SDOUtil; + +import org.apache.tuscany.sdo.util.metadata.*; + +/** + * + * An implementation of the model Factory. + * + * @generated + */ +public class MetadataFactoryImpl extends FactoryBase implements MetadataFactory +{ + + /** + * The package namespace URI. + * + * + * @generated + */ + public static final String NAMESPACE_URI = "org.apache.tuscany.sdo/metadata"; + + /** + * The package namespace name. + * + * + * @generated + */ + public static final String NAMESPACE_PREFIX = "metadata"; + public static final int JAVA_META_DATA = 1; + public static final int SDO_META_DATA_GROUP = 2; + public static final int TYPE_META_DATA = 3; + public static final int XSD_META_DATA = 4; + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public MetadataFactoryImpl() + { + super(NAMESPACE_URI, NAMESPACE_PREFIX); + } + + /** + * + * + * @generated + */ + public DataObject create(int typeNumber) + { + switch (typeNumber) + { + case JAVA_META_DATA: return (DataObject)createJavaMetaData(); + case SDO_META_DATA_GROUP: return (DataObject)createSDOMetaDataGroup(); + case TYPE_META_DATA: return (DataObject)createTypeMetaData(); + case XSD_META_DATA: return (DataObject)createXSDMetaData(); + default: + return super.create(typeNumber); + } + } + + /** + * + * + * @generated + */ + public JavaMetaData createJavaMetaData() + { + JavaMetaDataImpl javaMetaData = new JavaMetaDataImpl(); + return javaMetaData; + } + /** + * + * + * @generated + */ + public SDOMetaDataGroup createSDOMetaDataGroup() + { + SDOMetaDataGroupImpl sdoMetaDataGroup = new SDOMetaDataGroupImpl(); + return sdoMetaDataGroup; + } + /** + * + * + * @generated + */ + public TypeMetaData createTypeMetaData() + { + TypeMetaDataImpl typeMetaData = new TypeMetaDataImpl(); + return typeMetaData; + } + /** + * + * + * @generated + */ + public XSDMetaData createXSDMetaData() + { + XSDMetaDataImpl xsdMetaData = new XSDMetaDataImpl(); + return xsdMetaData; + } + + // Following creates and initializes SDO metadata for the supported types. + protected Type javaMetaDataType = null; + + public Type getJavaMetaData() + { + return javaMetaDataType; + } + + protected Type sdoMetaDataGroupType = null; + + public Type getSDOMetaDataGroup() + { + return sdoMetaDataGroupType; + } + + protected Type typeMetaDataType = null; + + public Type getTypeMetaData() + { + return typeMetaDataType; + } + + protected Type xsdMetaDataType = null; + + public Type getXSDMetaData() + { + return xsdMetaDataType; + } + + + private static boolean isInited = false; + + public static MetadataFactoryImpl init() + { + if (isInited) return (MetadataFactoryImpl)FactoryBase.getStaticFactory(MetadataFactoryImpl.NAMESPACE_URI); + MetadataFactoryImpl theMetadataFactoryImpl = new MetadataFactoryImpl(); + isInited = true; + + // Initialize simple dependencies + SDOUtil.registerStaticTypes(SDOFactory.class); + SDOUtil.registerStaticTypes(ModelFactory.class); + + // Create package meta-data objects + theMetadataFactoryImpl.createMetaData(); + + // Initialize created meta-data + theMetadataFactoryImpl.initializeMetaData(); + + // Mark meta-data to indicate it can't be changed + //theMetadataFactoryImpl.freeze(); //FB do we need to freeze / should we freeze ???? + + return theMetadataFactoryImpl; + } + + private boolean isCreated = false; + + public void createMetaData() + { + if (isCreated) return; + isCreated = true; + + + javaMetaDataType = createType(false, JAVA_META_DATA); + createProperty(true, javaMetaDataType, JavaMetaDataImpl.FACTORY_INTERFACE); + createProperty(true, javaMetaDataType, JavaMetaDataImpl.TYPE_INTERFACE); + + sdoMetaDataGroupType = createType(false, SDO_META_DATA_GROUP); + createProperty(false, sdoMetaDataGroupType, SDOMetaDataGroupImpl.JAVA_META_DATA); + createProperty(false, sdoMetaDataGroupType, SDOMetaDataGroupImpl.XSD_META_DATA); + createProperty(false, sdoMetaDataGroupType, SDOMetaDataGroupImpl.TYPE_META_DATA); + + typeMetaDataType = createType(false, TYPE_META_DATA); + createProperty(true, typeMetaDataType, TypeMetaDataImpl.LOCATION); + + xsdMetaDataType = createType(false, XSD_META_DATA); + createProperty(true, xsdMetaDataType, XSDMetaDataImpl.LOCATION); + } + + private boolean isInitialized = false; + + public void initializeMetaData() + { + if (isInitialized) return; + isInitialized = true; + + // Obtain other dependent packages + ModelFactoryImpl theModelPackageImpl = (ModelFactoryImpl)FactoryBase.getStaticFactory(ModelFactoryImpl.NAMESPACE_URI); + Property property = null; + + // Add supertypes to classes + + // Initialize classes and features; add operations and parameters + initializeType(javaMetaDataType, JavaMetaData.class, "JavaMetaData"); + + property = (Property)javaMetaDataType.getProperties().get(JavaMetaDataImpl.FACTORY_INTERFACE); + initializeProperty(property, theModelPackageImpl.getString(), "factoryInterface", null, 0, 1, JavaMetaData.class, false, false, false); + + property = (Property)javaMetaDataType.getProperties().get(JavaMetaDataImpl.TYPE_INTERFACE); + initializeProperty(property, theModelPackageImpl.getString(), "typeInterface", null, 0, 1, JavaMetaData.class, false, false, false); + + initializeType(sdoMetaDataGroupType, SDOMetaDataGroup.class, "SDOMetaDataGroup"); + + property = (Property)sdoMetaDataGroupType.getProperties().get(SDOMetaDataGroupImpl.JAVA_META_DATA); + initializeProperty(property, this.getJavaMetaData(), "javaMetaData", null, 0, -1, SDOMetaDataGroup.class, false, false, false, true , null); + + property = (Property)sdoMetaDataGroupType.getProperties().get(SDOMetaDataGroupImpl.XSD_META_DATA); + initializeProperty(property, this.getXSDMetaData(), "xsdMetaData", null, 0, -1, SDOMetaDataGroup.class, false, false, false, true , null); + + property = (Property)sdoMetaDataGroupType.getProperties().get(SDOMetaDataGroupImpl.TYPE_META_DATA); + initializeProperty(property, this.getTypeMetaData(), "typeMetaData", null, 0, -1, SDOMetaDataGroup.class, false, false, false, true , null); + + initializeType(typeMetaDataType, TypeMetaData.class, "TypeMetaData"); + + property = (Property)typeMetaDataType.getProperties().get(TypeMetaDataImpl.LOCATION); + initializeProperty(property, theModelPackageImpl.getString(), "location", null, 1, 1, TypeMetaData.class, false, false, false); + + initializeType(xsdMetaDataType, XSDMetaData.class, "XSDMetaData"); + + property = (Property)xsdMetaDataType.getProperties().get(XSDMetaDataImpl.LOCATION); + initializeProperty(property, theModelPackageImpl.getString(), "location", null, 1, 1, XSDMetaData.class, false, false, false); + + createXSDMetaData(theModelPackageImpl); + } + + protected void createXSDMetaData(ModelFactoryImpl theModelPackageImpl) + { + super.initXSD(); + + Property property = null; + + property = createGlobalProperty + ("sdoMetaDataGroup", + this.getSDOMetaDataGroup(), + new String[] + { + "kind", "element", + "name", "sdoMetaDataGroup", + "namespace", "##targetNamespace" + }); + + addXSDMapping + (javaMetaDataType, + new String[] + { + "name", "JavaMetaData", + "kind", "empty" + }); + + addXSDMapping + ((Property)javaMetaDataType.getProperties().get(JavaMetaDataImpl.FACTORY_INTERFACE), + new String[] + { + "kind", "attribute", + "name", "factoryInterface" + }); + + addXSDMapping + ((Property)javaMetaDataType.getProperties().get(JavaMetaDataImpl.TYPE_INTERFACE), + new String[] + { + "kind", "attribute", + "name", "typeInterface" + }); + + addXSDMapping + (sdoMetaDataGroupType, + new String[] + { + "name", "SDOMetaDataGroup", + "kind", "elementOnly" + }); + + addXSDMapping + ((Property)sdoMetaDataGroupType.getProperties().get(SDOMetaDataGroupImpl.JAVA_META_DATA), + new String[] + { + "kind", "element", + "name", "javaMetaData" + }); + + addXSDMapping + ((Property)sdoMetaDataGroupType.getProperties().get(SDOMetaDataGroupImpl.XSD_META_DATA), + new String[] + { + "kind", "element", + "name", "xsdMetaData" + }); + + addXSDMapping + ((Property)sdoMetaDataGroupType.getProperties().get(SDOMetaDataGroupImpl.TYPE_META_DATA), + new String[] + { + "kind", "element", + "name", "typeMetaData" + }); + + addXSDMapping + (typeMetaDataType, + new String[] + { + "name", "TypeMetaData", + "kind", "empty" + }); + + addXSDMapping + ((Property)typeMetaDataType.getProperties().get(TypeMetaDataImpl.LOCATION), + new String[] + { + "kind", "attribute", + "name", "location" + }); + + addXSDMapping + (xsdMetaDataType, + new String[] + { + "name", "XSDMetaData", + "kind", "empty" + }); + + addXSDMapping + ((Property)xsdMetaDataType.getProperties().get(XSDMetaDataImpl.LOCATION), + new String[] + { + "kind", "attribute", + "name", "location" + }); + + } + +} //MetadataFactoryImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/SDOMetaDataGroupImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/SDOMetaDataGroupImpl.java new file mode 100644 index 0000000000..43746399fc --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/SDOMetaDataGroupImpl.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.util.metadata.impl; + +import commonj.sdo.Type; + +import java.util.Collection; +import java.util.List; + +import org.apache.tuscany.sdo.impl.DataObjectBase; + +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; + +/** + * + * An implementation of the model object 'SDO Meta Data Group'. + * + *

      + * The following features are implemented: + *

        + *
      • {@link org.apache.tuscany.sdo.util.metadata.impl.SDOMetaDataGroupImpl#getJavaMetaData Java Meta Data}
      • + *
      • {@link org.apache.tuscany.sdo.util.metadata.impl.SDOMetaDataGroupImpl#getXsdMetaData Xsd Meta Data}
      • + *
      • {@link org.apache.tuscany.sdo.util.metadata.impl.SDOMetaDataGroupImpl#getTypeMetaData Type Meta Data}
      • + *
      + *

      + * + * @generated + */ +public class SDOMetaDataGroupImpl extends DataObjectBase implements SDOMetaDataGroup +{ + /** + * The feature id for the 'Java Meta Data' containment reference list. + * + * + * @generated + * @ordered + */ + public final static int JAVA_META_DATA = 0; + + /** + * The feature id for the 'Xsd Meta Data' containment reference list. + * + * + * @generated + * @ordered + */ + public final static int XSD_META_DATA = 1; + + /** + * The feature id for the 'Type Meta Data' containment reference list. + * + * + * @generated + * @ordered + */ + public final static int TYPE_META_DATA = 2; + + /** + * This represents the number of properties for this type. + * + * + * @generated + * @ordered + */ + + public final static int SDO_PROPERTY_COUNT = 3; + + /** + * The cached value of the '{@link #getJavaMetaData() Java Meta Data}' containment reference list. + * + * + * @see #getJavaMetaData() + * @generated + * @ordered + */ + + protected List javaMetaData = null; + + /** + * The cached value of the '{@link #getXsdMetaData() Xsd Meta Data}' containment reference list. + * + * + * @see #getXsdMetaData() + * @generated + * @ordered + */ + + protected List xsdMetaData = null; + + /** + * The cached value of the '{@link #getTypeMetaData() Type Meta Data}' containment reference list. + * + * + * @see #getTypeMetaData() + * @generated + * @ordered + */ + + protected List typeMetaData = null; + + /** + * + * + * @generated + */ + protected SDOMetaDataGroupImpl() + { + super(); + } + + /** + * + * + * @generated + */ + public Type getStaticType() + { + return ((MetadataFactoryImpl)MetadataFactory.INSTANCE).getSDOMetaDataGroup(); + } + + /** + * + * + * @generated + */ + public List getJavaMetaData() + { + if (javaMetaData == null) + { + javaMetaData = createPropertyList(ListKind.CONTAINMENT, JavaMetaData.class, JAVA_META_DATA); + } + return javaMetaData; + } + /** + * + * + * @generated + */ + public List getXsdMetaData() + { + if (xsdMetaData == null) + { + xsdMetaData = createPropertyList(ListKind.CONTAINMENT, XSDMetaData.class, XSD_META_DATA); + } + return xsdMetaData; + } + /** + * + * + * @generated + */ + public List getTypeMetaData() + { + if (typeMetaData == null) + { + typeMetaData = createPropertyList(ListKind.CONTAINMENT, TypeMetaData.class, TYPE_META_DATA); + } + return typeMetaData; + } + /** + * + * + * @generated + */ + public ChangeContext inverseRemove(Object otherEnd, int propertyIndex, ChangeContext changeContext) + { + switch (propertyIndex) + { + case JAVA_META_DATA: + return removeFromList(getJavaMetaData(), otherEnd, changeContext); + case XSD_META_DATA: + return removeFromList(getXsdMetaData(), otherEnd, changeContext); + case TYPE_META_DATA: + return removeFromList(getTypeMetaData(), otherEnd, changeContext); + } + return super.inverseRemove(otherEnd, propertyIndex, changeContext); + } + + /** + * + * + * @generated + */ + public Object get(int propertyIndex, boolean resolve) + { + switch (propertyIndex) + { + case JAVA_META_DATA: + return getJavaMetaData(); + case XSD_META_DATA: + return getXsdMetaData(); + case TYPE_META_DATA: + return getTypeMetaData(); + } + return super.get(propertyIndex, resolve); + } + + /** + * + * + * @generated + */ + public void set(int propertyIndex, Object newValue) + { + switch (propertyIndex) + { + case JAVA_META_DATA: + getJavaMetaData().clear(); + getJavaMetaData().addAll((Collection)newValue); + return; + case XSD_META_DATA: + getXsdMetaData().clear(); + getXsdMetaData().addAll((Collection)newValue); + return; + case TYPE_META_DATA: + getTypeMetaData().clear(); + getTypeMetaData().addAll((Collection)newValue); + return; + } + super.set(propertyIndex, newValue); + } + + /** + * + * + * @generated + */ + public void unset(int propertyIndex) + { + switch (propertyIndex) + { + case JAVA_META_DATA: + getJavaMetaData().clear(); + return; + case XSD_META_DATA: + getXsdMetaData().clear(); + return; + case TYPE_META_DATA: + getTypeMetaData().clear(); + return; + } + super.unset(propertyIndex); + } + + /** + * + * + * @generated + */ + public boolean isSet(int propertyIndex) + { + switch (propertyIndex) + { + case JAVA_META_DATA: + return javaMetaData != null && !javaMetaData.isEmpty(); + case XSD_META_DATA: + return xsdMetaData != null && !xsdMetaData.isEmpty(); + case TYPE_META_DATA: + return typeMetaData != null && !typeMetaData.isEmpty(); + } + return super.isSet(propertyIndex); + } + +} //SDOMetaDataGroupImpl diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/TypeMetaDataImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/TypeMetaDataImpl.java new file mode 100644 index 0000000000..66d7f8625f --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/TypeMetaDataImpl.java @@ -0,0 +1,203 @@ +/** + * + * 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 commonj.sdo.Type; + +import org.apache.tuscany.sdo.impl.DataObjectBase; + +import org.apache.tuscany.sdo.util.metadata.MetadataFactory; +import org.apache.tuscany.sdo.util.metadata.TypeMetaData; + +/** + * + * An implementation of the model object 'Type Meta Data'. + * + *

      + * The following features are implemented: + *

        + *
      • {@link org.apache.tuscany.sdo.util.metadata.impl.TypeMetaDataImpl#getLocation Location}
      • + *
      + *

      + * + * @generated + */ +public class TypeMetaDataImpl extends DataObjectBase implements TypeMetaData +{ + /** + * The feature id for the 'Location' attribute. + * + * + * @generated + * @ordered + */ + public final static int LOCATION = 0; + + /** + * This represents the number of properties for this type. + * + * + * @generated + * @ordered + */ + + public final static int SDO_PROPERTY_COUNT = 1; + + /** + * The default value of the '{@link #getLocation() Location}' attribute. + * + * + * @see #getLocation() + * @generated + * @ordered + */ + protected static final String LOCATION_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getLocation() Location}' attribute. + * + * + * @see #getLocation() + * @generated + * @ordered + */ + protected String location = LOCATION_DEFAULT_; + + /** + * + * + * @generated + */ + protected TypeMetaDataImpl() + { + super(); + } + + /** + * + * + * @generated + */ + public Type getStaticType() + { + return ((MetadataFactoryImpl)MetadataFactory.INSTANCE).getTypeMetaData(); + } + + /** + * + * + * @generated + */ + public String getLocation() + { + return location; + } + /** + * + * + * @generated + */ + public void setLocation(String newLocation) + { + String oldLocation = location; + location = newLocation; + if (isNotifying()) + notify(ChangeKind.SET, LOCATION, oldLocation, location); + } + + /** + * + * + * @generated + */ + public Object get(int propertyIndex, boolean resolve) + { + switch (propertyIndex) + { + case LOCATION: + return getLocation(); + } + return super.get(propertyIndex, resolve); + } + + /** + * + * + * @generated + */ + public void set(int propertyIndex, Object newValue) + { + switch (propertyIndex) + { + case LOCATION: + setLocation((String)newValue); + return; + } + super.set(propertyIndex, newValue); + } + + /** + * + * + * @generated + */ + public void unset(int propertyIndex) + { + switch (propertyIndex) + { + case LOCATION: + setLocation(LOCATION_DEFAULT_); + return; + } + super.unset(propertyIndex); + } + + /** + * + * + * @generated + */ + public boolean isSet(int propertyIndex) + { + switch (propertyIndex) + { + case LOCATION: + return LOCATION_DEFAULT_ == null ? location != null : !LOCATION_DEFAULT_.equals(location); + } + return super.isSet(propertyIndex); + } + + /** + * + * + * @generated + */ + public String toString() + { + if (isProxy(this)) 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/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/XSDMetaDataImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/XSDMetaDataImpl.java new file mode 100644 index 0000000000..7a04d6b99c --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/XSDMetaDataImpl.java @@ -0,0 +1,203 @@ +/** + * + * 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 commonj.sdo.Type; + +import org.apache.tuscany.sdo.impl.DataObjectBase; + +import org.apache.tuscany.sdo.util.metadata.MetadataFactory; +import org.apache.tuscany.sdo.util.metadata.XSDMetaData; + +/** + * + * An implementation of the model object 'XSD Meta Data'. + * + *

      + * The following features are implemented: + *

        + *
      • {@link org.apache.tuscany.sdo.util.metadata.impl.XSDMetaDataImpl#getLocation Location}
      • + *
      + *

      + * + * @generated + */ +public class XSDMetaDataImpl extends DataObjectBase implements XSDMetaData +{ + /** + * The feature id for the 'Location' attribute. + * + * + * @generated + * @ordered + */ + public final static int LOCATION = 0; + + /** + * This represents the number of properties for this type. + * + * + * @generated + * @ordered + */ + + public final static int SDO_PROPERTY_COUNT = 1; + + /** + * The default value of the '{@link #getLocation() Location}' attribute. + * + * + * @see #getLocation() + * @generated + * @ordered + */ + protected static final String LOCATION_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getLocation() Location}' attribute. + * + * + * @see #getLocation() + * @generated + * @ordered + */ + protected String location = LOCATION_DEFAULT_; + + /** + * + * + * @generated + */ + protected XSDMetaDataImpl() + { + super(); + } + + /** + * + * + * @generated + */ + public Type getStaticType() + { + return ((MetadataFactoryImpl)MetadataFactory.INSTANCE).getXSDMetaData(); + } + + /** + * + * + * @generated + */ + public String getLocation() + { + return location; + } + /** + * + * + * @generated + */ + public void setLocation(String newLocation) + { + String oldLocation = location; + location = newLocation; + if (isNotifying()) + notify(ChangeKind.SET, LOCATION, oldLocation, location); + } + + /** + * + * + * @generated + */ + public Object get(int propertyIndex, boolean resolve) + { + switch (propertyIndex) + { + case LOCATION: + return getLocation(); + } + return super.get(propertyIndex, resolve); + } + + /** + * + * + * @generated + */ + public void set(int propertyIndex, Object newValue) + { + switch (propertyIndex) + { + case LOCATION: + setLocation((String)newValue); + return; + } + super.set(propertyIndex, newValue); + } + + /** + * + * + * @generated + */ + public void unset(int propertyIndex) + { + switch (propertyIndex) + { + case LOCATION: + setLocation(LOCATION_DEFAULT_); + return; + } + super.unset(propertyIndex); + } + + /** + * + * + * @generated + */ + public boolean isSet(int propertyIndex) + { + switch (propertyIndex) + { + case LOCATION: + return LOCATION_DEFAULT_ == null ? location != null : !LOCATION_DEFAULT_.equals(location); + } + return super.isSet(propertyIndex); + } + + /** + * + * + * @generated + */ + public String toString() + { + if (isProxy(this)) 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/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/ChangeSummaryStreamDeserializer.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/ChangeSummaryStreamDeserializer.java new file mode 100644 index 0000000000..6dc461a2fe --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/ChangeSummaryStreamDeserializer.java @@ -0,0 +1,663 @@ +/** + * + * 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.Collection; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.xml.namespace.NamespaceContext; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import org.apache.tuscany.sdo.SDOFactory; +import org.apache.tuscany.sdo.helper.SDOAnnotations; +import org.apache.tuscany.sdo.impl.ChangeSummaryImpl; +import org.apache.tuscany.sdo.impl.ClassImpl; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.ETypedElement; +import org.eclipse.emf.ecore.change.ChangeDescription; +import org.eclipse.emf.ecore.change.ChangeFactory; +import org.eclipse.emf.ecore.change.ChangeKind; +import org.eclipse.emf.ecore.change.FeatureChange; +import org.eclipse.emf.ecore.change.FeatureMapEntry; +import org.eclipse.emf.ecore.change.ListChange; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.ecore.util.FeatureMapUtil; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; +import commonj.sdo.helper.HelperContext; + +/** + * ChangeSummary StAX Deserializer whose input conforms to the SDO Java/C++/PHP specifications. The instance isn't thread-safe, however it's safe to + * use the instance any times on the same thread. + */ +public class ChangeSummaryStreamDeserializer extends SDODeserializer { + static final class ForwardReference extends Ref { + final String unset; + + ForwardReference(String ref, NamespaceContext nameSpaces, String u) { + super(ref, nameSpaces); + unset = u; + } + + Collection attributes/* = null */, qualifiedAttributes/* = null */, tags/* = null */; // may be null, never empty + } + + protected Collection forwardReferences/* = null */; + + static private final class ElementChange extends Ref { + private final Object containing, containment; + private ElementChange(String ref, NamespaceContext nameSpaces, Object property, Object propertyInSequence) { + super(ref, nameSpaces); + containing = property; + containment = propertyInSequence; + } + } + + static private class PropertyMapChanges { + Map/* Property,List */lists/* = null */;// may be null + + Collection put(Object property) { + Collection list = new ArrayList(); + lists.put(property, list); + return list; + } + + protected final Collection get(Object property) { + Object list = lists.get(property); + return list == null ? put(property) : (Collection) list; + } + + protected final Collection newList(Object property) { + lists = new HashMap(); + return put(property); + } + } + + static final class ObjectChanges extends PropertyMapChanges { + Collection elementChanges/* = null */,// may be null, never empty + featureChanges; + + protected final void newElementChanges() { + elementChanges = new ArrayList(); + } + } + + Collection objectChangesCollection/* = null */, objectMapChanges, deletedDataObjects; + + protected final ObjectChanges newObjectChanges(Collection featureChanges) { + ObjectChanges objectChanges = new ObjectChanges(); + objectChanges.featureChanges = featureChanges; + if (objectChangesCollection == null) + objectChangesCollection = new ArrayList(); + objectChangesCollection.add(objectChanges); + return objectChanges; + } + + private ChangeFactory changeFactory; + + private SDOFactory changeSettingFactory; + + private void logPropertyChange(Collection featureChanges, EStructuralFeature feature, Object value, boolean set) { + if (changeSettingFactory == null) + featureChanges.add(changeFactory.createFeatureChange(feature, value, set)); + else + featureChanges.add(changeSettingFactory.createChangeSummarySetting(feature, value, set)); + } + + void unsetProperty(Collection featureChanges, String unset, int begin, int index, Type type) { + logPropertyChange(featureChanges, (EStructuralFeature) type.getProperty(unset.substring(begin, index)), null, false); + } + + static boolean isWhitespace(String unset, int index) { + return Character.isWhitespace(unset.charAt(index)); + } + + protected final Collection unsetProperties(EObject referent, String unset, Type type) { + Map.Entry entry = changeFactory.createEObjectToChangesMapEntry(referent); + objectMapChanges.add(entry); + Collection featureChanges = (Collection) entry.getValue(); + if (unset == null) + return featureChanges; + int end = unset.length(); + if (end != 0) + for (int begin = 0, index = 1;/* true */; ++index) { + if (index == end) { + unsetProperty(featureChanges, unset, begin, index, type); + break; + } + if (isWhitespace(unset, index)) { + unsetProperty(featureChanges, unset, begin, index, type); + while (true) { + if (++index != end) + return featureChanges; + if (!isWhitespace(unset, index)) { + begin = index; + break; + } + } + } + } + return featureChanges; + } + + private Object value(EStructuralFeature containing, Object containment, Object value) { + return FeatureMapUtil.isFeatureMap(containing) ? changeFactory.createFeatureMapEntry((EStructuralFeature) containment, value) : value; + } + + private void logPropertyChange(Collection featureChanges, Object containing, Object containment, Object value) { + EStructuralFeature feature = (EStructuralFeature) containing; + logPropertyChange(featureChanges, feature, value(feature, containment, value), true); + } + + private void logPropertyChange(Collection featureChanges, Object property, Object value) { + logPropertyChange(featureChanges, property, propertyInSequence, value); + } + + void logAttributeChange(Collection featureChanges, Property property, String literal, NamespaceContext nameSpaces) { + logPropertyChange(featureChanges, property, value(property.getType(), literal, nameSpaces)); + } + + protected final void logAttributeChange(Collection featureChanges, String property, Type type, String value, NamespaceContext nameSpaces) { + logAttributeChange(featureChanges, getProperty(type, property), value, nameSpaces); + } + + protected final void logAttributeChange(Collection featureChanges, String nameSpace, String name, Type type, String value, + NamespaceContext nameSpaces) { + logAttributeChange(featureChanges, getProperty(type, nameSpace, name, false), value, nameSpaces); + } + + protected final String ref() { + return reader.getAttributeValue(SDOAnnotations.COMMONJ_SDO_NS, ChangeSummaryStreamSerializer.REF_ATTRIBUTE); + } + + ChangeSummaryImpl changeSummary; + + protected Object load(XMLStreamReader reader, Map options) throws XMLStreamException { + Object value = super.load(reader, options); + deletedDataObjects.add(value); + return value; + } + + protected final void getChangeSummary(DataObject rootObject) { + changeSummary = (ChangeSummaryImpl) rootObject.getChangeSummary(); // DynamicDataObjectImpl(EClass) + } + + static protected final class Tag extends RecordedEventXMLStreamReader.Tag { + protected String ref; + + protected Object value; + + protected Tag(XMLStreamReader reader) { + super(reader); + } + } + + protected final void addPropertyChange(Collection list, Object value, Object containing) { + list.add(value((EStructuralFeature) containing, propertyInSequence, value)); + } + + protected boolean logging; + + /** + * Imports ChangeSummary 2-1. Forward references will be resolved by {@link #end()}. + * + * @param reader + * Never null + * @throws XMLStreamException + */ + public final void begin(DataObject rootObject, HelperContext scope, XMLStreamReader reader) throws XMLStreamException { + /* + * 3-1. Instantiate ChangeSummary input: reader (xsi:type), factory, rootObject output: changeSummary, changeDescription + */ + initialize(reader, scope, rootObject); + if (typedXSI()) { + changeSummary = (ChangeSummaryImpl) scope.getDataFactory().create(nameSpace, name); + if (changeSummary == null) + getChangeSummary(rootObject); + else { + Property csp = ((ClassImpl) rootObject.getType()).getChangeSummaryProperty(); + rootObject.set(csp, changeSummary); + changeSummary.setDataObject(rootObject); + } + } else + getChangeSummary(rootObject); + ChangeDescription changeDescription = (ChangeDescription) changeSummary; + + /* + * 3-2. "logging" attribute input: reader output: logging + */ + logging = Boolean.valueOf(reader.getAttributeValue(null, "logging")).booleanValue(); + + /* + * 3-3. Modified DataObjects input: changeDescription + */ + if (forwardReferences != null) + forwardReferences.clear(); + if (objectChangesCollection != null) + objectChangesCollection.clear(); + if (START_ELEMENT == reader.nextTag()) { + objectMapChanges = changeDescription.getObjectChanges(); + deletedDataObjects = changeDescription.getObjectsToAttach(); + Object factory = changeDescription.eClass().getEPackage().getEFactoryInstance(); + changeFactory = factory instanceof ChangeFactory ? (ChangeFactory) factory : ChangeFactory.eINSTANCE; + changeSettingFactory = factory instanceof SDOFactory ? (SDOFactory) factory : null; + do { + /* + * Modified DataObject + */ + String ref = ref(), unset = reader.getAttributeValue(SDOAnnotations.COMMONJ_SDO_NS, ChangeSummaryStreamSerializer.UNSET); + int attributes = reader.getAttributeCount(); + NamespaceContext nameSpaces = reader.getNamespaceContext(); + EObject referent = referent(ref, nameSpaces); + if (referent == null) { + /* + * Forward-referenced(unresolved) modified DataObject + */ + ForwardReference forwardReference = new ForwardReference(ref, nameSpaces, unset); + if (forwardReferences == null) + forwardReferences = new ArrayList(); + forwardReferences.add(forwardReference); + do // what about xmlns="NS1" a1="qName" xmlns="NS2" a2="qName" ? + { + /* + * Record property old value as attribute for end() + */ + String nameSpace = reader.getAttributeNamespace(--attributes), name = reader.getAttributeLocalName(attributes), value = reader + .getAttributeValue(attributes); + if (nameSpace == null) { + /* + * Local attribute + */ + Attribute attribute = new Attribute(); + attribute.name = name; + attribute.value = value; + if (forwardReference.attributes == null) + forwardReference.attributes = new ArrayList(); + forwardReference.attributes.add(attribute); + } else if (!SDOAnnotations.COMMONJ_SDO_NS.equals(nameSpace) || !ChangeSummaryStreamSerializer.REF_ATTRIBUTE.equals(name) + && !ChangeSummaryStreamSerializer.UNSET.equals(name)) { + /* + * Qualified(global) attribute + */ + QualifiedAttribute attribute = new QualifiedAttribute(); + attribute.name = name; + attribute.value = value; + attribute.nameSpace = nameSpace; + if (forwardReference.qualifiedAttributes == null) + forwardReference.qualifiedAttributes = new ArrayList(); + forwardReference.qualifiedAttributes.add(attribute); + } + } while (attributes != 0); + while (START_ELEMENT == reader.nextTag()) { + /* + * Record property old value as element for end() + */ + Tag tag = new Tag(reader); + if (forwardReference.tags == null) + forwardReference.tags = new ArrayList(); + forwardReference.tags.add(tag); + tag.ref = ref(); + if (tag.ref != null) + continue; + Type xsi = typeXSI(); + if (xsi == null) { + if (tag.nameSpace != null) + tag.value = value(globalElementType(tag.nameSpace, tag.name.getLocalPart())); // TODO substitutionGroup type if null + else if (tag.record(reader)) + break; + } else + tag.value = value(xsi); + } + } else { + /* + * Resolved(back-referenced) modified DataObject + */ + Type type = ((DataObject) referent).getType(); + Collection featureChanges = unsetProperties(referent, unset, type); + do // what about xmlns="NS1" a1="qName" xmlns="NS2" a2="qName" ? + { + /* + * Log property old value as attribute + */ + String nameSpace = reader.getAttributeNamespace(--attributes), name = reader.getAttributeLocalName(attributes), value = reader + .getAttributeValue(attributes); + if (nameSpace == null) + logAttributeChange(featureChanges, name, type, value, nameSpaces); + else if (!SDOAnnotations.COMMONJ_SDO_NS.equals(nameSpace) || !ChangeSummaryStreamSerializer.REF_ATTRIBUTE.equals(name) + && !ChangeSummaryStreamSerializer.UNSET.equals(name)) + logAttributeChange(featureChanges, nameSpace, name, type, value, nameSpaces); + } while (attributes != 0); + if (START_ELEMENT == reader.nextTag()) { + ObjectChanges objectChanges = null; + do { + /* + * Log property old value as element + */ + String nameSpace = reader.getNamespaceURI(), name = reader.getLocalName(); + Property property = getProperty(nameSpace, name, type); + boolean many = property.isMany(); + Object value; + ref = ref(); + if (ref == null) { + /* + * Contained property old value + */ + Type xsi = typeXSI(); + if (xsi != null) + value = value(xsi); + else if (nameSpace == null) + value = value(reader); + else { + xsi = globalElementType(nameSpace, name); + value = value(xsi == null ? propertyInSequence.getType() : xsi); + } + } else { + /* + * Referenced child DataObject + */ + nameSpaces = reader.getNamespaceContext(); + reader.nextTag()/* END_ELEMENT */; + value = referent(ref, nameSpaces); + if (value == null) { + /* + * Forward-referenced(unresolved) child DataObject + */ + if (!many) { + ElementChange elementChange = new ElementChange(ref, nameSpaces, property, propertyInSequence); + if (objectChanges == null) { + objectChanges = newObjectChanges(featureChanges); + objectChanges.newElementChanges(); + } else if (objectChanges.elementChanges == null) + objectChanges.newElementChanges(); + objectChanges.elementChanges.add(elementChange); + continue; + } + value = new Ref(ref, nameSpaces); + } + } + if (many) { + Collection list; + if (objectChanges == null) { + objectChanges = newObjectChanges(featureChanges); + list = objectChanges.newList(property); + } else if (objectChanges.lists == null) + list = objectChanges.newList(property); + else + list = objectChanges.get(property); + addPropertyChange(list, value, property); + } else + logPropertyChange(featureChanges, property, value); + } while (START_ELEMENT == reader.nextTag()); + } + } + } while (START_ELEMENT == reader.nextTag()); + } + } + + static private boolean sequence(Object listChanges) { + return FeatureMapUtil.isFeatureMap(((FeatureChange) ((EStructuralFeature.Setting) listChanges).getEObject()).getFeature()); + } + + private ListChange createListChange(ChangeKind changeKind, int index, Collection listChanges) { + ListChange listChange = changeFactory.createListChange(); + listChange.setKind(changeKind); + listChange.setIndex(index); + listChanges.add(listChange); + return listChange; + } + + Collection add(Collection adds, int change, Collection listChanges, Object value) { + if (adds == null) { + ListChange listChange = createListChange(ChangeKind.ADD_LITERAL, change, listChanges); + adds = sequence(listChanges) ? listChange.getFeatureMapEntryValues() : listChange.getValues(); + } + adds.add(value); + return adds; + } + + private int remove(int change, Collection listChanges, List list, int begin, int end) { + ListChange listChange = createListChange(ChangeKind.REMOVE_LITERAL, change, listChanges); + if (sequence(listChanges)) { + Collection removes = listChange.getFeatureMapEntryValues(); + do { + FeatureMap.Entry fme = (FeatureMap.Entry) list.get(begin); + removes.add(changeFactory.createFeatureMapEntry(fme.getEStructuralFeature(), fme.getValue())); + } while (++begin != end); + return begin; + } + Collection removes = listChange.getValues(); + do + removes.add(list.get(begin)); + while (++begin != end); + return begin; + } + + int remove(int begin, int end, int change, Collection listChanges, List list) { + return begin == end ? begin : remove(change, listChanges, list, begin, end); + } + + protected final void logManyChanges(PropertyMapChanges propertyMapChanges, EObject referent, Collection featureChanges) { + for (Iterator lists = propertyMapChanges.lists.entrySet().iterator(); lists.hasNext();) { + /* + * Compute ListChanges out of comparision of old and new list + */ + Map.Entry entry = (Map.Entry) lists.next(); + EStructuralFeature property = (EStructuralFeature) entry.getKey(); + Iterator values = ((Collection) entry.getValue()).iterator(); // old list + Object value = referent.eGet(property); + List list = value instanceof FeatureMap.Internal.Wrapper ? ((FeatureMap.Internal.Wrapper) value).featureMap() : (List) value; // new + int change = 0; + FeatureChange featureChange = changeSettingFactory == null ? changeFactory.createFeatureChange() : (FeatureChange) changeSettingFactory + .createChangeSummarySetting(); + featureChange.setFeature(property); + Collection listChanges = featureChange.getListChanges(), adds = null; + featureChanges.add(featureChange); + if (property.getEType() instanceof EClass) { + /* + * Log child DataObject changes + */ + int begin = 0, end = list.size(); + while (values.hasNext()) { + value = values.next(); + if (value.getClass() == Ref.class) { + value = referent((Ref) value); + if (value == null) + continue;// report error? + } + // values.remove(); + for (int index = begin;/* true */; ++index) + if (index == end) { + adds = add(adds, change, listChanges, value); + break; + } else if (list.get(index) == value) // List#indexOf uses equals + { + begin = remove(begin, index, change, listChanges, list); + ++begin; + adds = null; + break; + } + ++change; + } + remove(begin, end, change, listChanges, list); + } else if (FeatureMapUtil.isFeatureMap(property)) { + /* + * Log Sequence changes + */ + int begin = 0, end = list.size(); + while (values.hasNext()) { + FeatureMapEntry featureMapEntry = (FeatureMapEntry) values.next(); + value = featureMapEntry.getValue(); + if (value.getClass() == Ref.class) { + value = referent((Ref) value); + if (value == null) + continue;// report error? + } + // values.remove(); + Comparator equality; + ETypedElement feature = featureMapEntry.getFeature(); + if (((Type) feature.getEType()).isDataType()) + if (value == null) + equality = EQUAL_NULL; + else + equality = EQUAL; + else + equality = SAME; + for (int index = begin;/* true */; ++index) + if (index == end) { + adds = add(adds, change, listChanges, featureMapEntry); + break; + } else { + FeatureMap.Entry fme = (FeatureMap.Entry) list.get(index); + if (feature == fme.getEStructuralFeature() && equality.compare(fme.getValue(), value) == 0) { + begin = remove(begin, index, change, listChanges, list); + ++begin; + adds = null; + break; + } + } + ++change; + } + remove(begin, end, change, listChanges, list); + } else { + /* + * Log simple value changes + */ + while (values.hasNext()) { + value = values.next(); + // values.remove(); + int index = list.indexOf(value); + switch (index) { + case -1: + adds = add(adds, change, listChanges, value); + break; + default: + remove(change, listChanges, list, 0, index); + case 0: + list = list.subList(++index, list.size()); + adds = null; + } + ++change; + } + remove(0, list.size(), change, listChanges, list); + } + } + } + + protected PropertyMapChanges propertyMapChanges/* = null */; + + /** + * Imports ChangeSummary 2-2. Resolves forward references from {@link #begin} and resumes logging if necessary. If it's invoked from + * patching/resolving, try to make it last since logging may be turned on. + * + * @see #begin + */ + public final ChangeSummary end() throws XMLStreamException { + if (forwardReferences != null) + for (Iterator iterator = forwardReferences.iterator(); iterator.hasNext();) { + /* + * Forward-referenced(unresolved) modified DataObject from begin(...) + */ + ForwardReference forwardReference = (ForwardReference) iterator.next(); + EObject referent = referent(forwardReference); + if (referent == null) + continue; // report error? + // iterator.remove(); + Type type = ((DataObject) referent).getType(); + Collection featureChanges = unsetProperties(referent, forwardReference.unset, type); + if (forwardReference.attributes != null) + for (Iterator attributes = forwardReference.attributes.iterator(); attributes.hasNext();) { + /* + * Log property old value as local attribute from begin(...) + */ + Attribute attribute = (Attribute) attributes.next(); + logAttributeChange(featureChanges, attribute.name, type, attribute.value, forwardReference.nameSpaces); + } + if (forwardReference.qualifiedAttributes != null) + for (Iterator attributes = forwardReference.qualifiedAttributes.iterator(); attributes.hasNext();) { + /* + * Log property old value as qualified/global attribute from begin(...) + */ + QualifiedAttribute attribute = (QualifiedAttribute) attributes.next(); + logAttributeChange(featureChanges, attribute.nameSpace, attribute.name, type, attribute.value, forwardReference.nameSpaces); + } + if (forwardReference.tags != null) { + if (propertyMapChanges != null) + propertyMapChanges.lists.clear(); + for (Iterator tags = forwardReference.tags.iterator(); tags.hasNext();) { + /* + * Log property old value as element from begin(...) + */ + Tag tag = (Tag) tags.next(); + Property property = getProperty(tag.nameSpace, tag.name.getLocalPart(), type); + if (tag.ref != null) + tag.value = referent(tag.ref, tag.nameSpaceContext); + // if (tag.value == null) report error? + else if (tag.events != null) + tag.value = value(play(tag)); + if (property.isMany()) { + Collection list; + if (propertyMapChanges == null) { + propertyMapChanges = new PropertyMapChanges(); + list = propertyMapChanges.newList(property); + } else + list = propertyMapChanges.get(property); + addPropertyChange( list, tag.value, property); + } else + logPropertyChange(featureChanges, property, tag.value); + } + if (propertyMapChanges != null) + logManyChanges(propertyMapChanges, referent, featureChanges); + } + } + if (objectChangesCollection != null) + for (Iterator iterator = objectChangesCollection.iterator(); iterator.hasNext();) { + /* + * Forward-referenced(unresolved) child DataObject from begin(...) + */ + ObjectChanges objectChanges = (ObjectChanges) iterator.next(); + if (objectChanges.elementChanges != null) + for (Iterator elementChanges = objectChanges.elementChanges.iterator(); elementChanges.hasNext();) { + ElementChange elementChange = (ElementChange) elementChanges.next(); + Object value = referent(elementChange); + if (value == null) + continue; // report error? + // iterator.remove(); + logPropertyChange(objectChanges.featureChanges, elementChange.containing, elementChange.containment, value); + } + if (objectChanges.lists != null) + logManyChanges(objectChanges, (EObject) ((Map.Entry) ((EStructuralFeature.Setting) objectChanges.featureChanges).getEObject()) + .getKey(), objectChanges.featureChanges); + } + if (logging) + changeSummary.resumeLogging(); + return changeSummary; + } +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/ChangeSummaryStreamSerializer.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/ChangeSummaryStreamSerializer.java new file mode 100644 index 0000000000..bb598bea54 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/ChangeSummaryStreamSerializer.java @@ -0,0 +1,690 @@ +/** + * + * 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.Collection; +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.XMLOutputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.helper.HelperContextImpl; +import org.apache.tuscany.sdo.helper.SDOAnnotations; +import org.apache.tuscany.sdo.helper.XSDHelperImpl; +import org.apache.tuscany.sdo.impl.ChangeSummaryImpl; +import org.apache.tuscany.sdo.model.ModelFactory; +import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl; +import org.apache.tuscany.sdo.util.SDOUtil; +import org.eclipse.emf.common.util.EMap; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.change.ChangeDescription; +import org.eclipse.emf.ecore.change.ChangeKind; +import org.eclipse.emf.ecore.change.FeatureChange; +import org.eclipse.emf.ecore.change.ListChange; +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.XMLResource; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.helper.XSDHelper; + +/** + * ChangeSummary StAX Serializer whose output conforms to the SDO Java/C++/PHP specifications. The instance isn't thread-safe, however it's safe to + * use the instance any times on the same thread. + */ +public class ChangeSummaryStreamSerializer { + private XMLStreamWriter writer; + + private String writeNamespace(String prefix, String nameSpace) throws XMLStreamException { + writer.writeNamespace(prefix, nameSpace); + writer.setPrefix(prefix, nameSpace); + return prefix; + } + + private int nsPrefixSuffix; + + private String prefix(String nameSpace, String preference) throws XMLStreamException { + if (preference != null) { + String bound = writer.getNamespaceContext().getNamespaceURI(preference); + if (bound == null) { + String prefix = writer.getPrefix(nameSpace); + return prefix == null ? writeNamespace(preference, nameSpace) : prefix/* or null */; + } + if (bound.equals(nameSpace)) + return preference; + } + Object automaticNsPrefix = writer.getProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES); + if (automaticNsPrefix != null && automaticNsPrefix.getClass() == Boolean.class // faster than instanceof since Boolean is final + && ((Boolean) automaticNsPrefix).booleanValue()) + return null; + String prefix = writer.getPrefix(nameSpace); + if (prefix != null) + return prefix; // or null + NamespaceContext nameSpaces = writer.getNamespaceContext(); + do + prefix = "CS" + nsPrefixSuffix++; + while (nameSpaces.getNamespaceURI(prefix) != null); + return writeNamespace(prefix, nameSpace); + } + + void writeGlobalAttribute(String prefix, String nameSpace, String name, String value) throws XMLStreamException { + prefix = prefix(nameSpace, prefix); + if (prefix == null) + writer.writeAttribute(nameSpace, name, value); + else + writer.writeAttribute(prefix, nameSpace, name, value); + } + + XSDHelper xsdHelper; + + protected final void writeAttribute(Property property, String value) throws XMLStreamException { + String name = xsdHelper.getLocalName(property), nameSpace = xsdHelper.getNamespaceURI(property); + // TODO "" for no-NameSpace global attribute + if (nameSpace == null) + writer.writeAttribute(name, value); + else + writeGlobalAttribute(null, nameSpace, name, value); + } + + private String lineBreak, indent, margin; + + private int nest; + + private void breakLine() throws XMLStreamException { + writer.writeCharacters(lineBreak); + + if (margin != null) + writer.writeCharacters(margin); + + if (indent != null) + for (int count = nest; count != 0; --count) + writer.writeCharacters(indent); + } + + private Map options; + + static private final String STRING_OPTION = "String option"; + + void startElement() throws XMLStreamException { + if (options == null) + return; + if (lineBreak == STRING_OPTION) + lineBreak = (String) options.get(SDOUtil.XML_SAVE_LineBreak); + if (lineBreak == null) + return; + if (margin == STRING_OPTION) + margin = (String) options.get(SDOUtil.XML_SAVE_MARGIN); + if (indent == STRING_OPTION) + indent = (String) options.get(SDOUtil.XML_SAVE_INDENT); + breakLine(); + } + + void writeStartElement(String prefix, String nameSpace, String name) throws XMLStreamException { + startElement(); + if (nameSpace == null) + writer.writeStartElement(name); + else { + prefix = prefix(nameSpace, prefix); + if (prefix == null) + writer.writeStartElement(nameSpace, name); + else + writer.writeStartElement(prefix, name, nameSpace); + } + } + + void writeStartElement(Property property) throws XMLStreamException { + ++nest; + writeStartElement(null, xsdHelper.getNamespaceURI(property),// TODO "" for no-NameSpace global element + xsdHelper.getLocalName(property)); + } + + static protected final String CREATE_ATTRIBUTE = "create", DELETE_ATTRIBUTE = "delete", LOGGING_ATTRIBUTE = "logging", REF_ATTRIBUTE = "ref", UNSET = "unset"; + + private StringBuffer step(String nameSpace, String name, StringBuffer path) throws XMLStreamException { + if (nameSpace != null) { + nameSpace = writer.getPrefix(nameSpace); + if (nameSpace != null && nameSpace.length() != 0) + return path.append(nameSpace).append(':').append(name); // *:name[namespace-uri()='nameSpace'] + } + return path.append(name); + } + + private StringBuffer step(Property containmentProperty, StringBuffer path) throws XMLStreamException { + return step(xsdHelper.getNamespaceURI(containmentProperty),// TODO "" for no-NameSpace global element + xsdHelper.getLocalName(containmentProperty), path); + } + + private StringBuffer step(Property containmentProperty) throws XMLStreamException { + return step(containmentProperty, new StringBuffer()); + } + + private DataObject dataObject; + + private StringBuffer step(Object container) throws XMLStreamException { + Property containmentProperty = dataObject.getContainmentProperty(); + StringBuffer step = step(containmentProperty); + if (containmentProperty.isMany() || ((EObject) dataObject).eContainingFeature() != containmentProperty) + step.append('[').append(((DataObject) container).getList(containmentProperty).indexOf(dataObject) + 1).append(']'); + return step; + } + + private String pathRootObject; + private DataObject rootObject; + + private EObject container(EObject object) { + final EObject container = object.eContainer(); + if (!(container instanceof DataObject)) + return null; + String name = extendedMetaData.getName(container.eClass()); + return name != null && name.length() == 0 // DocumentRoot + ? null : container; + } + + private String path() throws XMLStreamException { + if (pathRootObject == STRING_OPTION) + pathRootObject = options == null ? null : (String) options.get(OPTION_RootObject_PATH); + if (pathRootObject != null && dataObject == rootObject) + return null; + EObject container = container((EObject) dataObject); + if (container == null) + return null; + StringBuffer step = step(container); + while (true) { + String path = step.toString(); + dataObject = (DataObject) container; + if (pathRootObject != null && container == rootObject) + return path; + container = container(container); + if (container == null) + return path; + step = step(container).append('/').append(path); + } + } + + /* + * not to support DataGraph 3-1 private org.eclipse.emf.ecore.resource.Resource rootResource; + */ + + protected String rootElementNS; + + String rootElementName; + + ExtendedMetaData extendedMetaData; + + protected final String rootElementName() { + if (rootElementNS != null) + return rootElementName; + QName rootElement = (QName) options.get(OPTION_ROOT_ELEMENT); + if (rootElement != null) { + rootElementNS = rootElement.getNamespaceURI(); + return rootElementName = rootElement.getLocalPart(); + } + EStructuralFeature element = ((EObject) rootObject).eContainingFeature(); + if (element == null) { + rootElementNS = ""; + return rootElementName = "descendant-or-self::node()"; + } + rootElementNS = extendedMetaData.getNamespace(element); + if (rootElementNS == null) + rootElementNS = ""; + return rootElementName = extendedMetaData.getName(element); + } + + String ref() throws XMLStreamException { + /* + * not to support DataGraph 3-2 if (rootResource != null) return rootResource.getURIFragment((EObject) dataObject); + */ + String id = EcoreUtil.getID((EObject) dataObject); + if (id != null) + return id; + id = path(); + if (pathRootObject == null) + return id == null ? "#/" + rootElementName() // descendant-or-self::node() + : "#//" + id; + return id == null ? pathRootObject/* + "."*/ : pathRootObject + id; + } + + void writeRef(String ref) throws XMLStreamException { + writer.writeAttribute(SDOAnnotations.COMMONJ_SDO_NS, REF_ATTRIBUTE, ref); + } + + void writeRef() throws XMLStreamException { + writeRef(ref()); + } + + void writeEndElement(String lineBreak) throws XMLStreamException { + if (lineBreak != null) + breakLine(); + writer.writeEndElement(); + --nest; + } + + private StringBuffer pathDeleted/* = null */; + + private Collection modifiedDataObjects; + + private int lengthDeleted; + + private String changeSummaryElementNS, changeSummaryElementName; + + private ChangeSummary changeSummary; + + protected boolean skipDeletedModification(DataObject modifiedDataObject) { + return changeSummary.isDeleted(modifiedDataObject); + } + + String refDeleted() throws XMLStreamException { + String id = EcoreUtil.getID((EObject) dataObject); + if (id != null) + return id; + id = path(); // "dataObject" is updated too!! + DataObject deletedDataObject = dataObject; + + /* + * construct "#//...changeSummary/" + * output: pathDeleted + */ + if (lengthDeleted == -1) { + String path = pathRootObject == null ? "#//" : pathRootObject; + if (pathDeleted == null) + pathDeleted = new StringBuffer(path); + else + pathDeleted.replace(0, pathDeleted.length(), path); + dataObject = rootObject; + path = path(); + if (path != null) + pathDeleted.append(path).append('/'); + step(changeSummaryElementNS, changeSummaryElementName, pathDeleted).append('/'); + lengthDeleted = pathDeleted.length(); + } else + pathDeleted.delete(lengthDeleted, pathDeleted.length()); + + dataObject = changeSummary.getOldContainer(deletedDataObject); + Property containmentProperty = dataObject.getContainmentProperty(); + String name = containmentProperty == null ? rootElementName() : xsdHelper.getLocalName(containmentProperty); + int index = 1; + for (Iterator iterator = modifiedDataObjects.iterator(); iterator.hasNext();) { + DataObject modifiedDataObject = (DataObject) iterator.next(); + if (skipDeletedModification(modifiedDataObject)) + continue; + if (modifiedDataObject == dataObject) + break; + Property property = modifiedDataObject.getContainmentProperty(); + if (property == containmentProperty || name.equals(property == null ? rootElementName() : xsdHelper.getLocalName(property))) + ++index; + } + pathDeleted/*.append("*:")*/.append(name).append('[').append(index).append("]/"); + containmentProperty = changeSummary.getOldContainmentProperty(deletedDataObject); + // assert containmentProperty != null; + step(containmentProperty, pathDeleted); + Object f; + if (containmentProperty.isMany() + || (f = extendedMetaData.getAffiliation(((EObject) dataObject).eClass(), (EStructuralFeature) containmentProperty)) != null + && f != containmentProperty) + pathDeleted.append('[').append( + ((List) changeSummary.getOldValue(dataObject, containmentProperty).getValue()).indexOf(deletedDataObject) + 1).append(']'); + if (id != null) + pathDeleted.append('/').append(id); + return pathDeleted.toString(); + } + + static String convertToString(Property property, Object value) { + return EcoreUtil.convertToString((EDataType) property.getType(), value); + } + + void writeRefDeleted() throws XMLStreamException { + writeRef(refDeleted()); + } + + protected final void writeDeletedObject(Property property) throws XMLStreamException { + ++nest; + startElement(); + --nest; + DataObject oldDataObject = ((ChangeSummaryImpl)changeSummary).getOldDataObject(dataObject); + XMLStreamReader reader = new DataObjectXMLStreamReader(property, oldDataObject, null, xsdHelper); + new XMLStreamSerializer().serialize(new XMLDocumentStreamReader(reader), writer); + } + + static public final Object ChangeSummary_TYPE = ((ModelFactoryImpl) ModelFactory.INSTANCE).getChangeSummaryType(); + + Collection deletedDataObjects; + + protected final void writeElement(Object value, Property property) throws XMLStreamException { + if (value == null) { + writeStartElement(property); + writeGlobalAttribute(ExtendedMetaData.XSI_PREFIX, ExtendedMetaData.XSI_URI, XMLResource.NIL, "true"); + writeEndElement(null); + } else if (value instanceof DataObject) { + dataObject = (DataObject) value; + if (!changeSummary.isDeleted(dataObject)) { + writeStartElement(property); + writeRef(); + writeEndElement(null); + } else if (property.isContainment() && deletedDataObjects.contains(dataObject)) { + writeDeletedObject(property); + } else { + writeStartElement(property); + writeRefDeleted(); + writeEndElement(null); + } + } else { + Object type = property.getType(); + if (type == ChangeSummary_TYPE) + return; + writeStartElement(property); + writer.writeCharacters(EcoreUtil.convertToString((EDataType) type, value)); + writeEndElement(null); + } + } + + protected final void writeElement(Object value) throws XMLStreamException { + FeatureMap.Entry entry = (FeatureMap.Entry) value; + writeElement(entry.getValue(), (Property)entry.getEStructuralFeature()); + } + + static protected List optimize(List values, Object featureChange, int size) { + int fromIndex = size, toIndex = 0; + for (Iterator changes = ((FeatureChange) featureChange).getListChanges().iterator(); changes.hasNext();) { + ListChange change = (ListChange) changes.next(); + Object kind = change.getKind(); + if (kind == ChangeKind.MOVE_LITERAL) + return values; + int index = change.getIndex(); + if (kind == ChangeKind.ADD_LITERAL) { + if (index == 0) { + fromIndex = 0; + if (toIndex == 0) + toIndex = 1; + } else { + int to = index; + if (--index < fromIndex) + fromIndex = index; + if (++to > toIndex) + toIndex = to; + else if (to < toIndex) + ++toIndex; + } + ++size; + } else { + --size; + if (index < fromIndex) + fromIndex = index; + if (index < toIndex) + --toIndex; + else if (index > toIndex && index != size) + toIndex = index; + } + } + return values.subList(fromIndex, toIndex); + } + + static protected final Object CHANGE_SUMMARY = SDOPackage.eINSTANCE.getChangeSummary(); + + /** + * Root Object path String such as "#", etc. Absent/null is the default (automatic computation) + */ + static public final String OPTION_RootObject_PATH = "RootObject path", + /** + * Boolean to optimize sequence/list/array. Absent/null/Boolean.FALSE is the default (no optimization) + */ + OPTION_OPTIMIZE_LIST = "optimize sequence/list/array", + /** + * Element QName if the changeSummary Root Object is a XML root; the NameSpace can be empty, never null; the prefix is ignored. + * Absent/null is the default (automatic computation from DocumentRoot if any) + */ + OPTION_ROOT_ELEMENT = "Root Element"; + + /** + * Exports ChangeSummary + * + * @param changeSummary + * Never null + * @param changeSummaryElement + * changeSummary element; the NameSpace can be empty if no NameSpace, or null if local element; the prefix can be null(no preference) + * @param writer + * Never null + * @param options + * {@link SDOUtil#XML_SAVE_LineBreak} (absence/null is the default i.e. no Line Breaking), {@link SDOUtil#XML_SAVE_INDENT} (absence/null is the default i.e. no indentation), {@link SDOUtil#XML_SAVE_MARGIN}, {@link #OPTION_RootObject_PATH}, {@link #OPTION_OPTIMIZE_LIST} and XMLResource.OPTION_EXTENDED_META_DATA; can be null or empty + */ + public final void saveChangeSummary(ChangeSummary changeSummary, QName changeSummaryElement, XMLStreamWriter writer, Map options) + throws XMLStreamException { + /* + * 6-1. Group created, deleted and modified DataObjects + * input: changeSummary output: createdDataObjects, deletedDataObjects & modifiedDataObjects + * implement: careful if compute from changeSummary.getChangedDataObjects() since it also includes children of deleted objects (thank Frank) + */ + if (changeSummary.isLogging()) + ((ChangeSummaryImpl) changeSummary).summarize(); + ChangeDescription changeDescription = (ChangeDescription) changeSummary; + Iterator createdDataObjects = changeDescription.getObjectsToDetach().iterator(); + deletedDataObjects = changeDescription.getObjectsToAttach(); + EMap objectChanges = changeDescription.getObjectChanges(); + modifiedDataObjects = objectChanges.keySet(); // may contain DO(s) from createdDataObjects and/or deletedDataObjects + + /* + * 6-2. Prepare to compute (X)Path + * input: changeSummary + * output: rootResource + */ + /*not to support DataGraph 3-3 + Object dataGraph = changeSummary.getDataGraph(); + if (dataGraph == null) { + DataObject rootObject = changeSummary.getRootObject(); + // assert rootObject != null; + rootResource = rootObject.getContainer() == null ? ((EObject) rootObject).eResource() // Can be null since this *StAX* writer does NOT + // require rootObject contained by an *EMF* Resource + : null; // eResource() direct content may not necessarily always be the XML document + } else + // assert dataGraph instanceof DataGraphImpl; + rootResource = ((org.apache.tuscany.sdo.impl.DataGraphImpl) dataGraph).getRootResource(); */ + + /* + * 6-2. Start ChangeSummary element + * input: writer, options, elementCS, changeSummary & changeDescription (6-1) + */ + nsPrefixSuffix = 0; + this.writer = writer; + this.options = options; + lineBreak = ""; + indent = margin = pathRootObject = STRING_OPTION; + nest = 0; + changeSummaryElementNS = changeSummaryElement.getNamespaceURI(); + changeSummaryElementName = changeSummaryElement.getLocalPart(); + writeStartElement(changeSummaryElement.getPrefix(), changeSummaryElementNS, changeSummaryElementName); + lineBreak = STRING_OPTION; + rootObject = changeSummary.getRootObject(); + extendedMetaData = (ExtendedMetaData) options.get(XMLResource.OPTION_EXTENDED_META_DATA); + if (extendedMetaData == null) + { + extendedMetaData = ExtendedMetaData.INSTANCE; + xsdHelper = XSDHelper.INSTANCE; + } + else{ + xsdHelper = (new HelperContextImpl(extendedMetaData, false)).getXSDHelper(); + } + Property declaration = changeSummaryElementNS == null + ? rootObject.getType().getProperty(changeSummaryElementName) + : xsdHelper.getGlobalProperty(changeSummaryElementNS, changeSummaryElementName, true); + if (declaration != null) + { + EClassifier type = changeDescription.eClass(); + if (type != declaration.getType() && type != CHANGE_SUMMARY) + writeGlobalAttribute(ExtendedMetaData.XSI_PREFIX, ExtendedMetaData.XSI_URI, XMLResource.TYPE, new StringBuffer(prefix(extendedMetaData.getNamespace(type), null)) + .append(':').append(extendedMetaData.getName(type)).toString()); + } + + /* + * 6-3. "create" attribute + * input: createdDataObjects (6-1), rootResource (6-2), changeSummary & writer + */ + rootElementNS = null; + this.changeSummary = changeSummary; + if (createdDataObjects.hasNext()) { + StringBuffer buffer = new StringBuffer(); + while (true) { + dataObject = (DataObject) createdDataObjects.next(); + buffer.append(ref()); + if (!createdDataObjects.hasNext()) + break; + buffer.append(' '); + } + writer.writeAttribute(CREATE_ATTRIBUTE, buffer.toString()); + } + + /* + * 6-4. "delete" attribute + * input: deletedDataObjects (6-1), modifiedDataObjects (6-1) & writer + */ + Iterator iterator = deletedDataObjects.iterator(); + if (iterator.hasNext()) { + lengthDeleted = -1; + StringBuffer buffer = null; + do { + dataObject = (DataObject) iterator.next(); + if (skipDeletedModification(changeSummary.getOldContainer(dataObject))) + continue; + if (buffer == null) + buffer = new StringBuffer(); + else + buffer.append(' '); + buffer.append(refDeleted()); + } while (iterator.hasNext()); + writer.writeAttribute(DELETE_ATTRIBUTE, buffer.toString()); + } + + /* + * 6-5. "logging" attribute + * input: changeSummary & writer + */ + writer.writeAttribute(LOGGING_ATTRIBUTE, changeSummary.isLogging() ? "true" : "false"); + + /* + * 6-6. Modified DataObjects + * input: modifiedDataObjects (6-1), rootResource (6-2), changeSummary & writer + */ + iterator = modifiedDataObjects.iterator(); + if (iterator.hasNext()) { + boolean optimizeList; + if (options == null) + optimizeList = false; + else + { + Object option = options.get(OPTION_OPTIMIZE_LIST); + optimizeList = option == null ? false : ((Boolean)option).booleanValue(); + } + prefix(SDOAnnotations.COMMONJ_SDO_NS, SDOPackage.eNS_PREFIX); + do { + DataObject dataObject = (DataObject) iterator.next(); + if (skipDeletedModification(dataObject)) + continue; + Property containmentProperty = dataObject.getContainmentProperty(); + if (containmentProperty == null) { + ++nest; + startElement(); + rootElementName(); + writer.writeStartElement(rootElementNS, rootElementName); + } else + writeStartElement(containmentProperty); + this.dataObject = dataObject; + writeRef(); + + String lineBreak = null; + Collection oldValues = (Collection) objectChanges.get(dataObject); // changeSummary.getOldValues repeats Sequence changes + Iterator settings = oldValues.iterator(); + if (settings.hasNext()) { + do { + ChangeSummary.Setting oldValue = (ChangeSummary.Setting) settings.next(); + if (oldValue.isSet()) + continue; + StringBuffer unset = step(oldValue.getProperty()); + while (settings.hasNext()) { + oldValue = (ChangeSummary.Setting) settings.next(); + if (!oldValue.isSet()) + step(oldValue.getProperty(), unset.append(' ')); + } + writer.writeAttribute(SDOAnnotations.COMMONJ_SDO_NS, UNSET, unset.toString()); + break; + } while (settings.hasNext()); + for (settings = oldValues.iterator(); settings.hasNext();) { + ChangeSummary.Setting oldValue = (ChangeSummary.Setting) settings.next(); + Property property = oldValue.getProperty(); + if (oldValue.isSet() && xsdHelper.isAttribute(property)) + // assert ! property.isMany(); + writeAttribute(property, convertToString(property, oldValue.getValue())); + } + for (settings = oldValues.iterator(); settings.hasNext();) { + ChangeSummary.Setting oldValue = (ChangeSummary.Setting) settings.next(); + Property property = oldValue.getProperty(); + if (!xsdHelper.isAttribute(property)) + if (property.isMany()) { + Object value = oldValue.getValue(); + List list = (List) value; + if (FeatureMapUtil.isFeatureMap((EStructuralFeature) property)) { + if (optimizeList) + list = optimize(list, oldValue, dataObject.getSequence(property).size()); + Iterator values = list.iterator(); + if (!values.hasNext()) + continue; + do + writeElement(values.next()); + while (values.hasNext()); + } else { + if (optimizeList) + list = optimize(list, oldValue, dataObject.getList(property).size()); + Iterator values = list.iterator(); + if (!values.hasNext()) + continue; + do + writeElement(values.next(), property); + while (values.hasNext()); + } + lineBreak = this.lineBreak; + } else if (oldValue.isSet()) { + Object value = oldValue.getValue(); + if (value instanceof FeatureMap.Entry) + writeElement(value); + else + writeElement(value, property); + lineBreak = this.lineBreak; + } + } + } + writeEndElement(lineBreak); + } while (iterator.hasNext()); + writeEndElement(lineBreak); + } else + writeEndElement(null); + writer.flush(); + } +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/DataObjectXMLStreamReader.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/DataObjectXMLStreamReader.java new file mode 100644 index 0000000000..94aaa6304e --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/DataObjectXMLStreamReader.java @@ -0,0 +1,1577 @@ +/** + * + * 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.model.internal.InternalFactory; +import org.apache.tuscany.sdo.model.internal.impl.InternalFactoryImpl; +import org.apache.tuscany.sdo.util.SDOUtil; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EDataType; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.util.ExtendedMetaData; + +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 DataObject serializeRoot; + + 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 NameSpaceContext namespaceContext; + + 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.serializeRoot = dataObject; + 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); + namespaceContext = new NameSpaceContext(); + populateProperties(); + } + + protected DataObjectXMLStreamReader(TypeHelper typeHelper, XSDHelper xsdHelper, Property rootElement, DataObject dataObject) { + 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); + } + + protected DataObjectXMLStreamReader(TypeHelper typeHelper, XSDHelper xsdHelper, Property rootElement, DataObject dataObject, DataObject serializeRoot) { + 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.serializeRoot = serializeRoot; + this.rootElementURI = xsdHelper.getNamespaceURI(rootElement); + this.rootElementName = xsdHelper.getLocalName(rootElement); + } + public DataObjectXMLStreamReader(Property rootElement, DataObject dataObject, TypeHelper typeHelper, XSDHelper xsdHelper) { + this(typeHelper, xsdHelper, rootElement, dataObject); + namespaceContext = new NameSpaceContext(); + populateProperties(); + } + + public DataObjectXMLStreamReader(XMLDocument document, TypeHelper typeHelper) { + this.dataObject = document.getRootObject(); + this.rootElementName = document.getRootElementName(); + this.rootElementURI = document.getRootElementURI(); + this.serializeRoot = this.dataObject; + this.typeHelper = typeHelper; + this.xsdHelper = typeHelper == null ? XSDHelper.INSTANCE : SDOUtil.createXSDHelper(typeHelper); + namespaceContext = new NameSpaceContext(); + 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; + namespaceContext = new NameSpaceContext(); + } + + private void addProperty(Property property, Object value, List propertyList) { + 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); + } + } + + void addProperty(List propertyList, Property property, Object value, Object type) { + if (!isTransient(property, type)) + addProperty(property, value, propertyList); + } + + 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); + } + } + } + + static private boolean isTransient(Property property, Object type) { + // HACK: We need some SDOUtil extension to understand a property is derived + EStructuralFeature feature = (EStructuralFeature) property; + if (ExtendedMetaData.INSTANCE.getGroup(feature) != null) + return false; + feature = ExtendedMetaData.INSTANCE.getAffiliation((EClass) type, feature); + if (feature != null && feature != property) + return false; + 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 if (property.isContainment() && value == serializeRoot) { + // do not create the childReader because a containmentCycle exists and this is the second + // time this DataObject has been encountered + } else { + DataObjectXMLStreamReader childReader = new DataObjectXMLStreamReader(typeHelper, xsdHelper, property, (DataObject) value, serializeRoot); + childReader.namespaceContext = namespaceContext; + childReader.populateProperties(); + 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(); + declaredNamespaceMap.put(realTypeName.getPrefix(), 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(property, value, elementList); + } + } + // 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, type); + } + } + } 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, type); + else + addProperty(elementList, property, value, type); + } + } + properties = (Map.Entry[]) elementList.toArray(new Map.Entry[0]); + attributes = (Map.Entry[]) attributeList.toArray(new Map.Entry[0]); + } + + public DataObject getDataObject() { + return dataObject; + } + + /** + * 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(); + + // Handle xsd:QName/SDO URI type property + // Before save, convert # to : + String propertyName = null; + if (attribPointer instanceof String) + propertyName = (String)attribPointer; + else if (attribPointer instanceof QName) + propertyName = ((QName)attribPointer).getLocalPart(); + else + return null; + + String attrValue = (String)omAttribObj; + + Property property = dataObject.getType().getProperty(propertyName); + // property can be null for xsi:type + if (property != null && "URI".equals(property.getType().getName())) { + String namespace = null; + String localPart = attrValue; + + int index = attrValue.indexOf('#'); + if (index == -1) { + return localPart; + } + else { + namespace = localPart.substring(0, index); + localPart = localPart.substring(index+1); + + String prefix = namespaceContext.getPrefix(namespace); + if (prefix == null || prefix.length() == 0) + return localPart; + + return prefix + ":" + localPart; + } + } + else { + return attrValue; + } + } + } + } 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 getTextData(); + } else { + throw new IllegalStateException(); + } + } + + private char[] getTextData() { + return properties[currentPropertyIndex - 1].getValue() == null ? new char[0] : ((String) properties[currentPropertyIndex - 1].getValue()) + .toCharArray(); + } + + private int copy(int sourceStart, char[] target, int targetStart, int length) { + char[] source = getTextData(); + if (sourceStart > source.length) + throw new IndexOutOfBoundsException("source start > source length"); + int sourceLen = source.length - sourceStart; + if (length > sourceLen) + length = sourceLen; + System.arraycopy(source, sourceStart, target, targetStart, length); + return sourceLen; + } + + 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) { + return copy(i, chars, i1, i2); + } 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 getTextData().length; + } 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, 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.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 final NameSpaceContext namespaceContext; + + private QName name; + + private String value; + + private int state = START_ELEMENT_STATE; + + public SimpleElementStreamReader(QName name, String value, NameSpaceContext nameSpaces) { + this.name = name; + this.value = value; + if (value == null) + state = START_ELEMENT_STATE_WITH_NULL; + namespaceContext = nameSpaces; + } + + 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 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 class NameSpaceContext implements NamespaceContext { + private Map prefixToNamespaceMapping = new HashMap(); + + public NameSpaceContext() { + 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 + 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(); + } + } + 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()); + } + } + 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); + declaredNamespaceMap.put(prefix, nsURI); + } + return new QName(nsURI, name, prefix); + } + + public void removeMapping(String prefix) { + prefixToNamespaceMapping.remove(prefix); + } + } + +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/RecordedEventXMLStreamReader.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/RecordedEventXMLStreamReader.java new file mode 100644 index 0000000000..b2b3036692 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/RecordedEventXMLStreamReader.java @@ -0,0 +1,868 @@ +/** + * + * 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.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; + +import javax.xml.XMLConstants; +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; + +import org.eclipse.emf.ecore.xmi.XMLResource; +import org.xml.sax.Attributes; +import org.xml.sax.Locator; + +/** + * This special purpose XMLStreamReader is used to produce a StAX event stream corresponding to a list of events + * recorded earlier. The recorded events are generated by the inner class RecordedEventXMLStreamReader.Tag, + * which records the events in either of 2 ways: + * + * 1) in conjunction with class SDOXMLLoadImpl, it records events corresponding to the SAX events being + * handled by the SDOXMLLoadImpl when loading XML using SDOXMLResourceImpl. + * 2) when Tag.record() is called (see class ChangeSummaryStreamDeserializer), it walks through and records + * the StAX events produced by another XMLStreamReader. + * + * This class is used by the SDO StAX-based ChangeSummaryType-property loader, class + * ChangeSummaryStreamDeserializer, which is inoked by and uses (for loading deleted object XML fragments) + * the SAX-based loader class XMLResourceImpl. + */ +public abstract class RecordedEventXMLStreamReader implements XMLStreamReader { + + static private class Event { + int type; + + public NamespaceContext nameSpaceContext; + + Location location; + + protected final void initialize(XMLStreamReader reader) { + nameSpaceContext = reader.getNamespaceContext(); + location = reader.getLocation(); + } + + protected final void location(final Locator locator) { + location = new Location() { + public int getCharacterOffset() { + return -1; + } + + public int getColumnNumber() { + return locator.getColumnNumber(); + } + + public int getLineNumber() { + return locator.getLineNumber(); + } + + public String getPublicId() { + return locator.getPublicId(); + } + + public String getSystemId() { + return locator.getSystemId(); + } + }; + } + } + + static class ValueEvent extends Event { + final String value; + + protected ValueEvent(String v) { + value = v; + } + } + + static protected class Reference extends ValueEvent { + final String target; + + protected Reference(String name, String data) { + super(data); + target = name; + } + } + + static protected final class AttributeEvent extends Reference { + final QName name; + + final String nameSpace, prefix; + + int attributes; + + final boolean specified; + + protected AttributeEvent(XMLStreamReader reader) { + super(reader.getAttributeType(0), reader.getAttributeValue(0)); + attributes = reader.getAttributeCount(); + name = reader.getAttributeName(0); + nameSpace = reader.getAttributeNamespace(0); + prefix = reader.getAttributePrefix(0); + specified = reader.isAttributeSpecified(0); + } + } + + static protected final class NameSpaceEvent extends Reference { + int nameSpaces; + + protected NameSpaceEvent(XMLStreamReader reader) { + super(reader.getNamespacePrefix(0), reader.getNamespaceURI(0)); + nameSpaces = reader.getNamespaceCount(); + } + } + + static protected String prefix(String qName, String nameSpace) { + int delimiter = qName.indexOf(':'); + if (delimiter != -1) + return qName.substring(0, delimiter); + if (nameSpace.length() != 0) + return XMLConstants.DEFAULT_NS_PREFIX; + // if (nameSpaceContext.getNamespaceURI(XMLConstants.DEFAULT_NS_PREFIX) != null || xsdHelper.getGlobalProperty(null, name, element) == null) + return null; + } + + static class EndElement extends Event { + List nameSpaces/* = null */; + + public final QName name; + + public final String nameSpace; + + final String prefix; + + protected EndElement(XMLStreamReader reader) { + name = reader.getName(); + nameSpace = reader.getNamespaceURI(); + prefix = reader.getPrefix(); + int count = reader.getNamespaceCount(); + if (count == 0) + return; + nameSpaces = new ArrayList(count); + int index = 0; + do + Tag.bind(reader.getNamespacePrefix(index), reader.getNamespaceURI(index), nameSpaces); + while (++index != count); + } + + protected EndElement(String uri, String local, String p, Locator locator) { + if (p == null) { + name = new QName(uri, local, XMLConstants.DEFAULT_NS_PREFIX); + nameSpace = null; + } else { + name = new QName(uri, local, p); + nameSpace = uri; + } + prefix = p; + location(locator); + } + } + + static class NameSpace { + final String prefix, uri; + + protected NameSpace(String p, String nameSpace) { + prefix = p; + uri = nameSpace; + } + } + + static final class Attribute extends NameSpace { + final String type, value; + + final QName qName; + + boolean specified/* = false */; + + protected Attribute(String t, String v, QName name, String prefix, String nameSpace) { + super(prefix, nameSpace); + type = t; + value = v; + qName = name; + } + } + + static final class AttributeList /* implements Attributes */{// TODO exclude XMLConstants.XMLNS_ATTRIBUTE + final List attributes; + + protected AttributeList(int size) { + attributes = new ArrayList(size); + } + + /* + * @param uri Never null + */ + public final int getIndex(String uri, String localName) { + for (int index = getLength(); index != 0;) + if (getLocalName(--index).equals(localName) && uri.equals(getURI(index))) + return index; + return -1; + } + + public final int getLength() { + return attributes.size(); + } + + protected final Attribute attribute(int index) { + return (Attribute) attributes.get(index); + } + + public final String getLocalName(int index) { + return attribute(index).qName.getLocalPart(); + } + + public final String getType(int index) { + return attribute(index).type; + } + + /*public String getType(String uri, String localName) { + int index = getIndex(uri, localName); + return index == -1 ? null: getType(index); + } */ + + public final String getURI(int index) { + return attribute(index).uri; + } + + public final String getValue(int index) { + return attribute(index).value; + } + + /* + * @param uri Never null + */ + public final String getValue(String uri, String localName) { + int index = getIndex(uri, localName); + return index == -1 ? null : getValue(index); + } + } + + static protected class StartElement extends EndElement { + final AttributeList attributes; + + protected StartElement(XMLStreamReader reader) { + super(reader); + int count = reader.getAttributeCount(); + if (count == 0) + attributes = null; + else { + attributes = new AttributeList(count); + int index = 0; + do { + Attribute attribute = new Attribute(reader.getAttributeType(index), reader.getAttributeValue(index), reader + .getAttributeName(index), reader.getAttributePrefix(index), reader.getAttributeNamespace(index)); + attribute.specified = reader.isAttributeSpecified(index); + attributes.attributes.add(attribute); + } while (++index != count); + } + } + + protected StartElement(String nameSpace, String local, String prefix, Attributes attributeArray, Locator locator, List bindings, + final NamespaceContext context) { + super(nameSpace, local, prefix, locator); + nameSpaces = bindings; + nameSpaceContext = bindings == null || bindings.isEmpty() ? context : new NamespaceContext() { + public String getNamespaceURI(String prefix) { + for (int index = nameSpaces.size(); index != 0;) { + NameSpace binding = (NameSpace) nameSpaces.get(--index); + if (binding.prefix.equals(prefix)) + return binding.uri; + } + return context.getNamespaceURI(prefix); + } + + public String getPrefix(String namespaceURI) { + for (int index = nameSpaces.size(); index != 0;) { + NameSpace binding = (NameSpace) nameSpaces.get(--index); + if (binding.uri.equals(namespaceURI)) + return binding.prefix; + } + return context.getPrefix(namespaceURI); + } + + public Iterator getPrefixes(final String namespaceURI) { + final Iterator iterator = context.getPrefixes(namespaceURI); + return new Iterator() { + Iterator bindings = nameSpaces.iterator(); + + NameSpace binding/* = null */; + + protected final boolean prefix() { + while (bindings.hasNext()) { + binding = (NameSpace) bindings.next(); + if (binding.uri.equals(namespaceURI)) + return true; + } + bindings = null; + return false; + } + + public boolean hasNext() { + return bindings != null && prefix() || iterator.hasNext(); + } + + protected NameSpace nameSpace; + + public Object next() { + if (bindings == null || binding == null && !prefix()) + return iterator.next(); + nameSpace = binding; + binding = null; + return nameSpace.prefix; + } + + public void remove() { + if (bindings == null) + iterator.remove(); + else + nameSpaces.remove(nameSpace); + } + }; + } + }; + int count = attributeArray.getLength(); + if (count == 0) + attributes = null; + else { + attributes = new AttributeList(count); + int index = 0; + do { + QName name; + nameSpace = attributeArray.getURI(index); + local = attributeArray.getLocalName(index); + prefix = prefix(attributeArray.getQName(index), nameSpace); + if (prefix == null) { + name = new QName(nameSpace, local, XMLConstants.DEFAULT_NS_PREFIX); + nameSpace = null; + } else + name = new QName(nameSpace, local, prefix); + attributes.attributes.add(new Attribute(attributeArray.getType(index), attributeArray.getValue(index), name, prefix, nameSpace)); + } while (++index != count); + } + } + } + + static public class Tag extends StartElement { + public Tag(XMLStreamReader reader) { + super(reader); + initialize(reader); + } + + public List events/* = null */; // may be empty + + protected final void events() { + events = new ArrayList(); + } + + public Tag(String nameSpace, String local, String prefix, Attributes attributes, Locator locator, NamespaceContext context, List bindings) { + super(nameSpace, local, prefix, attributes, locator, bindings, context); + events(); + } + + static public void bind(String prefix, String nameSpace, Collection nameSpaces) { + nameSpaces.add(new NameSpace(prefix, nameSpace)); + } + + protected int nest/* = 0 */; + + public final void start(String nameSpace, String local, String qName, Attributes attributes, Locator locator, List bindings) { + Event event; + for (int index = events.size();/* true */;) { + if (index == 0) { + event = this; + break; + } + event = (Event) events.get(--index); + if (event.type != END_ELEMENT) + break; + siblings: for (int nest = 0;/* true */;) + switch (((Event) events.get(--index)).type) { + case START_ELEMENT: + if (nest == 0) + break siblings; + --nest; + break; + case END_ELEMENT: + ++nest; + } + } + Event start = new StartElement(nameSpace, local, prefix(qName, nameSpace), attributes, locator, bindings, event.nameSpaceContext); + start.type = START_ELEMENT; + events.add(start); + ++nest; + } + + protected final void add (Event event) + { + int index = events.size(); + event.nameSpaceContext = index == 0 ? nameSpaceContext : ((Event) events.get(--index)).nameSpaceContext; + events.add(event); + } + + public final void text(int type, String value, Locator locator) { + Event event = new ValueEvent(value); + event.type = type; + event.location(locator); + //int index = events.size(); + add(event); + } + + public final boolean end(String nameSpace, String local, String qName, Locator locator) { + Event end = new EndElement(nameSpace, local, prefix(qName, nameSpace), locator); + end.type = END_ELEMENT; + add(end); + if (nest == 0) + return true; + --nest; + return false; + } + + public final XMLStreamReader play(final XMLResource resource) { + return new RecordedEventXMLStreamReader(this) { + public void close() { + } + + public String getCharacterEncodingScheme() { + return null; // TODO + } + + public String getEncoding() { + return resource.getEncoding(); + } + + public Object getProperty(String property) { + return null; // TODO javax.xml.stream.notations & javax.xml.stream.entities for DTD + } + + public String getVersion() { + return resource.getXMLVersion(); + } + + public boolean isStandalone() { + return false; // TODO + } + + public boolean standaloneSet() { + return false; // TODO + } + }; + } + + protected final void add(Event event, int type, XMLStreamReader reader) { + event.type = type; + event.initialize(reader); + events.add(event); + } + + public final boolean record(XMLStreamReader reader) throws XMLStreamException { + events(); + for (int nest = 0; reader.hasNext();) { + Event event; + int type = reader.next(); + switch (type) { + case CHARACTERS: + case CDATA: + case COMMENT: + case SPACE: + case DTD: + event = new ValueEvent(reader.getText()); + break; + case ENTITY_REFERENCE: + event = new Reference(reader.getLocalName(), reader.getText()); + break; + case PROCESSING_INSTRUCTION: + event = new Reference(reader.getPITarget(), reader.getPIData()); + break; + case ATTRIBUTE: + event = new AttributeEvent(reader); + break; + case NAMESPACE: + event = new NameSpaceEvent(reader); + break; + case START_ELEMENT: + ++nest; + event = new StartElement(reader); + break; + case END_ELEMENT: + add(new EndElement(reader), type, reader); + if (nest == 0) + return false; + --nest; + continue; + case END_DOCUMENT: + return true; // report error? + default: // new type + event = new Event(); + } + add(event, type, reader); + } + return true; // report error? + } + + public final XMLStreamReader play(final XMLStreamReader reader) { + return new RecordedEventXMLStreamReader(this) { + public void close() throws XMLStreamException { + reader.close(); + } + + public String getCharacterEncodingScheme() { + return reader.getCharacterEncodingScheme(); + } + + public String getEncoding() { + return reader.getEncoding(); + } + + public Object getProperty(String property) { + return reader.getProperty(property); // TODO javax.xml.stream.notations & javax.xml.stream.entities for DTD + } + + public String getVersion() { + return reader.getVersion(); + } + + public boolean isStandalone() { + return reader.isStandalone(); + } + + public boolean standaloneSet() { + return reader.standaloneSet(); + } + }; + } + } + + Event event; + + final List events; + + final int size; + + protected RecordedEventXMLStreamReader(Tag tag) { + event = tag; + tag.type = START_ELEMENT; + events = tag.events; + size = events.size(); + } + + public int getAttributeCount() { + switch (getEventType()) { + case START_ELEMENT: + AttributeList attributes = ((StartElement) event).attributes; + return attributes == null ? 0 : attributes.getLength(); + case ATTRIBUTE: + return ((AttributeEvent) event).attributes; + } + throw new IllegalStateException("Neither START_ELEMENT nor ATTRIBUTE"); + } + + protected final AttributeList attributes() { + if (getEventType() == START_ELEMENT) + return ((StartElement) event).attributes; + throw new IllegalStateException("Neither START_ELEMENT nor ATTRIBUTE"); + } + + public String getAttributeLocalName(int index) { + return attributes().getLocalName(index); + } + + static Attribute attribute(AttributeList attributes, int index) { + return (Attribute) attributes.attributes.get(index); + } + + public QName getAttributeName(int index) { + return getEventType() == ATTRIBUTE ? ((AttributeEvent) event).name : attribute(attributes(), index).qName; + } + + public String getAttributeNamespace(int index) { + return getEventType() == ATTRIBUTE ? ((AttributeEvent) event).nameSpace : attributes().getURI(index); + } + + public String getAttributePrefix(int index) { + return getEventType() == ATTRIBUTE ? ((AttributeEvent) event).prefix : attribute(attributes(), index).prefix; + } + + public String getAttributeType(int index) { + return getEventType() == ATTRIBUTE ? ((Reference) event).target : attributes().getType(index); + } + + public String getAttributeValue(int index) { + return getEventType() == ATTRIBUTE ? ((ValueEvent) event).value : attributes().getValue(index); + } + + public boolean isAttributeSpecified(int index) { + if (getEventType() == ATTRIBUTE) + return ((AttributeEvent) event).specified; + AttributeList attributes = attributes(); + return attribute(attributes, index).specified; + } + + public String getAttributeValue(String nameSpace, String name) { + if (getEventType() == ATTRIBUTE) { + AttributeEvent attribute = (AttributeEvent) event; + return !attribute.name.getLocalPart().equals(name) ? null : nameSpace == null ? (attribute.nameSpace == null ? attribute.value : null) + : nameSpace.equals(attribute.nameSpace) ? attribute.value : null; + } + AttributeList attributes = attributes(); + return attributes == null ? null : attributes.getValue(nameSpace == null ? "" : nameSpace, name); + } + + protected StringBuffer buffer/* = null */; + + public String getElementText() { + if (buffer != null) + buffer.delete(0, buffer.length()); + for (;;) + switch (next()) { + case END_ELEMENT: + return buffer == null ? null : buffer.toString(); + default: + if (buffer == null) + buffer = new StringBuffer(); + buffer.append(getText()); + case PROCESSING_INSTRUCTION: + case COMMENT: + } + } + + public final int getEventType() { + return event.type; + } + + public String getLocalName() { + if (getEventType() == ENTITY_REFERENCE) + return ((Reference) event).target; + if (event instanceof EndElement) + return ((EndElement) event).name.getLocalPart(); + throw new IllegalStateException("Neither START_ELEMENT, END_ELEMENT nor ENTITY_REFERENCE"); + } + + public final Location getLocation() { + return event.location; + } + + public QName getName() { + if (hasName()) + return ((EndElement) event).name; + throw new IllegalStateException("Neither START_ELEMENT nor END_ELEMENT"); + } + + public final NamespaceContext getNamespaceContext() { + return event.nameSpaceContext; + } + + public int getNamespaceCount() { + if (getEventType() == NAMESPACE) + return ((NameSpaceEvent) event).nameSpaces; + if (!(event instanceof EndElement)) + throw new IllegalStateException("Neither START_ELEMENT, END_ELEMENT nor NAMESPACE"); + Collection nameSpaces = ((EndElement) event).nameSpaces; + return nameSpaces == null ? 0 : nameSpaces.size(); + } + + protected final NameSpace getNameSpace(int index) { + if (event instanceof EndElement) + return (NameSpace) ((EndElement) event).nameSpaces.get(index); + throw new IllegalStateException("Neither START_ELEMENT, END_ELEMENT nor NAMESPACE"); + } + + public String getNamespacePrefix(int index) { + return getEventType() == NAMESPACE ? ((Reference) event).target : getNameSpace(index).prefix; + } + + public final String getNamespaceURI() { + switch (getEventType()) { + case ATTRIBUTE: + return ((AttributeEvent) event).nameSpace; + case NAMESPACE: + return ((ValueEvent) event).value; + } + return event instanceof EndElement ? ((EndElement) event).nameSpace : null; + } + + public String getNamespaceURI(String prefix) { + return getNamespaceContext().getNamespaceURI(prefix); + } + + public String getNamespaceURI(int index) { + return getEventType() == NAMESPACE ? ((ValueEvent) event).value : getNameSpace(index).uri; + } + + public String getPIData() { + return getEventType() == PROCESSING_INSTRUCTION ? ((ValueEvent) event).value : null; + } + + public String getPITarget() { + return getEventType() == PROCESSING_INSTRUCTION ? ((Reference) event).target : null; + } + + public String getPrefix() { + switch (getEventType()) { + case ATTRIBUTE: + return ((AttributeEvent) event).prefix; + case NAMESPACE: + return ((Reference) event).target; + } + return event instanceof EndElement ? ((EndElement) event).prefix : null; + } + + public final String getText() { + if (hasText()) + return ((ValueEvent) event).value; + throw new IllegalStateException("Neither CHARACTERS, CDATA, COMMENT, SPACE, ENTITY_REFERENCE nor DTD"); + } + + public final char[] getTextCharacters() { + switch (getEventType()) { + case CHARACTERS: + case CDATA: + case COMMENT: + case SPACE: + return ((ValueEvent) event).value.toCharArray(); + } + throw new IllegalStateException("Neither CHARACTERS, CDATA, COMMENT nor SPACE"); + } + + public int getTextCharacters(int sourceStart, char[] target, int targetStart, int length) { + char[] source = getTextCharacters(); + if (sourceStart > source.length) + throw new IndexOutOfBoundsException("source start > source length"); + int sourceLen = source.length - sourceStart; + if (length > sourceLen) + length = sourceLen; + System.arraycopy(source, sourceStart, target, targetStart, length); + return sourceLen; + } + + public int getTextLength() { + return getTextCharacters().length; + } + + public int getTextStart() { + return 0; + } + + public final boolean hasName() { + return event instanceof EndElement; + } + + protected int next/* = 0 */; + + public final boolean hasNext() { + return next != size; + } + + public final boolean hasText() { + switch (getEventType()) { + case CHARACTERS: + case CDATA: + case COMMENT: + case SPACE: + case ENTITY_REFERENCE: + case DTD: + return true; + } + return false; + } + + public boolean isCharacters() { + switch (getEventType()) { + case CHARACTERS: + case CDATA: + case SPACE: + return true; + } + return false; + } + + public boolean isEndElement() { + return getEventType() == END_ELEMENT; + } + + public boolean isStartElement() { + return getEventType() == START_ELEMENT; + } + + protected final boolean areWhiteSpace() { + String text = getText(); + for (int index = text.length(); index != 0;) + if (!Character.isWhitespace(text.charAt(--index))) + return false; + return true; + } + + public boolean isWhiteSpace() { + switch (getEventType()) { + case CHARACTERS: + case CDATA: + return areWhiteSpace(); + case SPACE: + return true; + } + return false; + } + + public final int next() { + if (!hasNext()) + throw new NoSuchElementException(); + event = (Event) events.get(next++); + return event.type; + } + + protected final void throwXMLStreamException(String message) throws XMLStreamException { + throw new XMLStreamException(message, getLocation()); + } + + public int nextTag() throws XMLStreamException { + for (;;) { + int type = next(); + switch (type) { + case CHARACTERS: + case CDATA: + if (!areWhiteSpace()) + break; + case SPACE: + case PROCESSING_INSTRUCTION: + case COMMENT: + continue; + case START_ELEMENT: + case END_ELEMENT: + return type; + } + throwXMLStreamException("expected start or end tag"); + } + } + + public void require(int type, String nameSpace, String name) throws XMLStreamException { + if (getEventType() != type) + throwXMLStreamException("type not matched"); + if (nameSpace != null && !nameSpace.equals(getNamespaceURI())) + throwXMLStreamException("Name Space not matched"); + if (name != null + && !(getEventType() == ATTRIBUTE ? name.equals(((AttributeEvent) event).name.getLocalPart()) : event instanceof EndElement + && name.equals(((EndElement) event).name.getLocalPart()))) + throwXMLStreamException("name not matched"); + } +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDODeserializer.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDODeserializer.java new file mode 100644 index 0000000000..af14f13319 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDODeserializer.java @@ -0,0 +1,340 @@ +/** + * + * 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.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import javax.xml.namespace.NamespaceContext; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import org.apache.tuscany.sdo.helper.HelperContextImpl; +import org.apache.tuscany.sdo.helper.TypeHelperImpl; +import org.apache.tuscany.sdo.helper.XMLStreamHelper; +import org.apache.tuscany.sdo.helper.XMLStreamHelperImpl; +import org.apache.tuscany.sdo.util.StreamDeserializer; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.TreeIterator; +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.Resource; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.ExtendedMetaData; +import org.eclipse.emf.ecore.xmi.XMLResource; + +import commonj.sdo.Property; +import commonj.sdo.Type; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XSDHelper; + +/** + * SDO StAX Deserializer. The instance isn't thread-safe, however it's safe to use the instance any times on the same thread. + */ +public class SDODeserializer extends StreamDeserializer { + private HelperContext hc; + protected final void initialize(XMLStreamReader stream, HelperContext scope, Object rootObject) { + hc = scope; + reader = stream; + xsdHelper = scope.getXSDHelper(); + typeHelper = scope.getTypeHelper(); + extendedMetaData = ((TypeHelperImpl) typeHelper).getExtendedMetaData(); + deserializer = (XMLStreamHelperImpl)((HelperContextImpl)scope).getXMLStreamHelper();; + root = (EObject) rootObject; + } + + XSDHelper xsdHelper; + + protected Property propertyInSequence; + + Property getProperty(Object type) { + EClass c = (EClass) type; + EStructuralFeature containment = (EStructuralFeature) propertyInSequence; + Object containing = extendedMetaData.getAffiliation(c, containment); + // if (containing == null) report error? + if (containment == containing && containment.isDerived()) { + containing = extendedMetaData.getMixedFeature(c); + if (containing == null) { + containing = extendedMetaData.getGroup(containment); + if (containing == null) + return propertyInSequence; + } + } + return (Property) containing; + } + + protected final Property getProperty(Type type, String nameSpace, String name, boolean element) { + for (Iterator iterator = type.getProperties().iterator(); iterator.hasNext();) { + propertyInSequence = (Property) iterator.next(); + if (name.equals(xsdHelper.getLocalName(propertyInSequence)) + && nameSpace.equals(xsdHelper.getNamespaceURI(propertyInSequence))) + return getProperty(type); + } + propertyInSequence = xsdHelper.getGlobalProperty(nameSpace, name, element); + // if (propertyInSequence == null) report error? + return getProperty(type); + } + + protected final Property getProperty(Type type, String name) { + propertyInSequence = type.getProperty(name); + // if (propertyInSequence == null) report error? + return getProperty(type); + } + + protected final Property getProperty(String nameSpace, String name, Type type) { + return null == nameSpace ? getProperty(type, name) : getProperty(type, nameSpace, name, true); + } + + XMLStreamHelperImpl deserializer; + + TypeHelper typeHelper; + + protected Object load(XMLStreamReader reader, Map options) throws XMLStreamException { + return deserializer.loadObject(reader, options); + } + + static Object value(Type type, XMLStreamReader reader) throws XMLStreamException { + return value(type, reader.getElementText(), reader.getNamespaceContext()); + } + + protected final Object value(Type type) throws XMLStreamException { + return "true".equals(reader.getAttributeValue(ExtendedMetaData.XSI_URI, XMLResource.NIL)) ? null : type.isDataType() ? value(type, reader) + : load(reader, null); + } + + Map options/* = null */; + + protected final Object value(XMLStreamReader reader) throws XMLStreamException { + Type propertyType = propertyInSequence.getType(); + if (propertyType.isDataType()) + return value(propertyType, reader); + if (options == null) + options = new HashMap(); + options.put(XMLStreamHelper.OPTION_DEFAULT_ROOT_TYPE, propertyType); + return load(reader, options); + } + + private boolean match(String name, String space, EStructuralFeature feature) { + return name.equals(extendedMetaData.getName(feature)) && space.equals(extendedMetaData.getNamespace(feature)); + } + + EObject step(String ref, int step, int index, EObject container, String prefix, NamespaceContext nameSpaces) { + String name = ref.substring(step, index); + Iterator iterator = container.eContents().iterator(); + if (iterator.hasNext()) + if (prefix == null) + do { + container = (EObject) iterator.next(); + // if( container == null )continue; + if (name.equals(extendedMetaData.getName(container.eContainmentFeature()))) + return container; + } while (iterator.hasNext()); + else { + prefix = nameSpaces.getNamespaceURI(prefix); + do { + container = (EObject) iterator.next(); + // if( container == null )continue; + if (match(name, prefix, container.eContainmentFeature())) + return container; + } while (iterator.hasNext()); + } + return null; + } + + EObject root; + + ExtendedMetaData extendedMetaData; + + protected final EObject referent(String ref, NamespaceContext nameSpaces) { + int length = ref.length(); + switch (length) { + case 0: + return null; + case 1: // # + return root; + } + EObject container; + int step; + if (ref.charAt(1) == '/') { + container = EcoreUtil.getRootContainer(root); + if (length == 2) + return container; + if (ref.charAt(2) == '/') { + for (Iterator iterator = container.eContents().iterator();/* true */;) { + if (!iterator.hasNext()) + return null; + container = (EObject) iterator.next(); + // if( container != null ) + break; + } + /*#// is invalid + if (length == 3) + return container; */ + step = 3; + } else + step = 2; + } else { + container = root; + step = 1; + } + String prefix = null; + for (int index = step; ++index != length;) { + switch (ref.charAt(index)) { + case '/': + container = step(ref, step, index, container, prefix, nameSpaces); + if (container == null) + return null; + break; + case ':': + prefix = ref.substring(step, index); + if (++index == length) + return container; // report error? + step = index; + default: + continue; + case '[': + name = ref.substring(step, index); + step = ref.indexOf(']', index + 2); + if (step == -1) + return container; // report error? + index = Integer.parseInt(ref.substring(++index, step)); + EStructuralFeature feature; + Iterator iterator = container.eContents().iterator(); + if (prefix == null) + do { + if (!iterator.hasNext()) + return null; + EObject content = (EObject) iterator.next(); + // if( content == null )continue; + feature = content.eContainmentFeature(); + } while (!name.equals(extendedMetaData.getName(feature))); + else { + prefix = nameSpaces.getNamespaceURI(prefix); + do { + if (!iterator.hasNext()) + return null; + EObject content = (EObject) iterator.next(); + // if( content == null )continue; + feature = content.eContainmentFeature(); + } while (!match(name, prefix, feature)); + } + Object value = container.eGet(feature); + if (value instanceof List) { + List values = (List) value; + if (index > values.size()) + return null; + container = (EObject) values.get(--index); + } else if (index == 1) + container = (EObject) value; + else + return null; + index = ref.indexOf('/', ++step); + if (index == -1) + return container; + } + if (++index == length) + return container; + step = index; + prefix = null; + } + return step(ref, step, length, container, prefix, nameSpaces); + } + + static protected class Ref implements EObject // FeatureMapEntry value + { + protected Ref(String path, NamespaceContext context) { + ref = path; + nameSpaces = context; + } + + final String ref; + + final NamespaceContext nameSpaces; + + public TreeIterator eAllContents() { + return null; + } + public EClass eClass() { + return null; + } + public EObject eContainer() { + return null; + } + public EStructuralFeature eContainingFeature() { + return null; + } + public EReference eContainmentFeature() { + return null; + } + public EList eContents() { + return null; + } + public EList eCrossReferences() { + return null; + } + public Object eGet(EStructuralFeature feature) { + return null; + } + public Object eGet(EStructuralFeature feature, boolean resolve) { + return null; + } + public boolean eIsProxy() { + return false; + } + public boolean eIsSet(EStructuralFeature feature) { + return false; + } + public Resource eResource() { + return null; + } + public void eSet(EStructuralFeature feature, Object newValue) { + } + public void eUnset(EStructuralFeature feature) { + } + public EList eAdapters() { + return null; + } + public boolean eDeliver() { + return false; + } + public void eNotify(Notification notification) { + } + public void eSetDeliver(boolean deliver) { + } + } + + protected final EObject referent(Ref path) { + return referent(path.ref, path.nameSpaces); + } + + protected final Type typeXSI() { + return typedXSI() ? typeHelper.getType(nameSpace, name) : null; + } + + protected final Type globalElementType(String nameSpace, String name) { + return xsdHelper.getGlobalProperty(nameSpace, name, true).getType(); + } +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDOURIConverterImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDOURIConverterImpl.java new file mode 100644 index 0000000000..639c556c83 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDOURIConverterImpl.java @@ -0,0 +1,55 @@ +/** + * + * 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.io.InputStream; +import java.io.OutputStream; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.impl.URIConverterImpl; + +public class SDOURIConverterImpl extends URIConverterImpl +{ + /** + * Disable going out to the wire. + */ + protected InputStream createURLInputStream(URI uri) throws IOException { + String scheme = uri.scheme(); + if ("http".equalsIgnoreCase(scheme) || "https".equalsIgnoreCase(scheme)) { + throw new Resource.IOWrappedException( + new RuntimeException("Reading remote URL not supported.")); + } + return super.createURLInputStream(uri); + } + + /** + * Disable going out to the wire. + */ + protected OutputStream createURLOutputStream(URI uri) throws IOException { + String scheme = uri.scheme(); + if ("http".equalsIgnoreCase(scheme) || "https".equalsIgnoreCase(scheme)) { + throw new Resource.IOWrappedException( + new RuntimeException("Writing remote URL not supported.")); + } + return super.createURLOutputStream(uri); + } +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDOXMLResourceFactoryImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDOXMLResourceFactoryImpl.java new file mode 100644 index 0000000000..c8189f9766 --- /dev/null +++ b/sandbox/kgoodson/events/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/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDOXMLResourceImpl.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDOXMLResourceImpl.java new file mode 100644 index 0000000000..0117686759 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDOXMLResourceImpl.java @@ -0,0 +1,1005 @@ +/** + * + * 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.io.InputStream; +import java.io.Writer; +import java.net.URL; +import java.security.AccessController; +import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.xml.XMLConstants; +import javax.xml.namespace.NamespaceContext; +import javax.xml.namespace.QName; +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 org.apache.tuscany.sdo.SDOExtendedMetaData; +import org.apache.tuscany.sdo.helper.HelperContextImpl; +import org.apache.tuscany.sdo.helper.SDOExtendedMetaDataImpl; +import org.apache.tuscany.sdo.helper.XMLStreamHelper; +import org.apache.tuscany.sdo.helper.XSDHelperImpl; +import org.apache.tuscany.sdo.api.SDOHelper; +import org.apache.tuscany.sdo.api.SDOUtil; +import org.apache.tuscany.sdo.util.StAX2SAXAdapter; +import org.apache.tuscany.sdo.model.internal.InternalFactory; +import org.apache.tuscany.sdo.model.internal.impl.InternalFactoryImpl; +import org.eclipse.emf.common.util.EMap; +import org.eclipse.emf.common.util.URI; +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.InternalEObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.util.ExtendedMetaData; +import org.eclipse.emf.ecore.util.FeatureMap; +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.XMLOptions; +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.XMLOptionsImpl; +import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; +import org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl; +import org.eclipse.emf.ecore.xmi.impl.XMLString; +import org.eclipse.emf.ecore.xmi.util.DefaultEcoreBuilder; +import org.eclipse.emf.ecore.xml.type.XMLTypePackage; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.xml.sax.Attributes; +import org.xml.sax.ContentHandler; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataObject; +import commonj.sdo.helper.XSDHelper; + +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 { + + /** + * EMF XMLResource (SAX) may be used to load from only a *portion* of a StAX stream + * which may reference (global) namespaces bound outside the (local) portion. + * This class extends EMF's NamespaceSupport to make {@link #getPrefix} and {@link #getURI} + * query these global binding(s) after first checking the local context(s). + */ + private static class StreamNamespaceSupport extends XMLHelperImpl.NamespaceSupport { + protected NamespaceContext nameSpaceContext; + + public String getPrefix(String uri) { + String prefix = super.getPrefix(uri); + if (prefix == null) + try { + prefix = nameSpaceContext.getPrefix(uri); + } catch (Exception e) { + // HACK: + // java.lang.UnsupportedOperationException + // at org.apache.axiom.om.impl.llom.OMStAXWrapper.getNamespaceContext(OMStAXWrapper.java:984) + } + return prefix; + } + + public String getURI(String prefix) { + String uri = super.getURI(prefix); + if (uri == null) + try { + uri = nameSpaceContext.getNamespaceURI(prefix); + } catch (Exception e) { + // HACK: + // java.lang.UnsupportedOperationException + // at org.apache.axiom.om.impl.llom.OMStAXWrapper.getNamespaceContext(OMStAXWrapper.java:984) + } + return uri; + } + + public StreamNamespaceSupport(XMLStreamReader reader) { + super(); + nameSpaceContext = reader.getNamespaceContext(); + } + + } + + public SDOXMLHelperImpl(XMLResource resource, XMLStreamReader reader) { + this(reader); + setResource(resource); + } + + public SDOXMLHelperImpl(XMLStreamReader reader) { + super(); + if (reader instanceof XMLDocumentStreamReader) // Only use StreamNamespaceSupport when loading from a *portion* of a StAX stream + namespaceSupport = new StreamNamespaceSupport(reader); + } + + private class NameSpaceContext implements NamespaceContext { // TODO Helper# pushContext() & popContext + public String getNamespaceURI(String prefix) { + return SDOXMLHelperImpl.this.getNamespaceURI(prefix); + } + + public String getPrefix(String namespaceURI) { + return SDOXMLHelperImpl.this.getPrefix(namespaceURI); + } + + public Iterator getPrefixes(String namespaceURI) { + return ((Collection) urisToPrefixes.get(namespaceURI)).iterator(); + } + } + + NameSpaceContext nameSpaceContext/* = null */; + + protected final NameSpaceContext nameSpaceContext() { + if (nameSpaceContext == null) + nameSpaceContext = new NameSpaceContext(); + return nameSpaceContext; + } + + private String xsdQName2SDOURI(String xsdQName) { + org.eclipse.emf.ecore.xml.type.internal.QName qname = new org.eclipse.emf.ecore.xml.type.internal.QName(xsdQName); + try { + updateQNameURI(qname); + } + catch (IllegalArgumentException e) { + return xsdQName; + } + return qname.getNamespaceURI() + "#" + qname.getLocalPart(); + } + + private String getPrefixFromNamespaceURI(String nsURI) { + String nsPrefix = null; + + List prefixes = (List)urisToPrefixes.get(nsURI); + if (prefixes != null) + { + for (Iterator i = prefixes.iterator(); i.hasNext(); ) + { + nsPrefix = (String)i.next(); + if (nsPrefix.length() >= 0) { + // When the length is 0, it's the default namespace + return nsPrefix; + } + } + } + + nsPrefix = namespaceSupport.getPrefix(nsURI); + if (nsPrefix != null) + { + return nsPrefix; + } + + // Demand create a new package + EPackage ePackage = extendedMetaData.demandPackage(nsURI); + + if (ExtendedMetaData.XSI_URI.equals(nsURI)) { + ePackage.setNsPrefix(ExtendedMetaData.XSI_PREFIX); + } + + // getPrefix() will make sure all mapping tables are configured correctly + nsPrefix = getPrefix(ePackage, true); + + return nsPrefix; + } + + private String SDOURI2XsdQName(String sdoURI) { + String namespace = null; + String localPart = sdoURI; + + int index = sdoURI.indexOf('#'); + if (index == -1) { + return localPart; + } + else { + namespace = sdoURI.substring(0, index); + localPart = sdoURI.substring(index+1); + + String prefix = getPrefixFromNamespaceURI(namespace); + + if (prefix.length() == 0) + return localPart; + + return prefix + ":" + localPart; + } + } + + protected Object createFromString(EFactory eFactory, EDataType eDataType, String value) { + Object obj = super.createFromString(eFactory, eDataType, value); + if (eDataType == ((InternalFactoryImpl)InternalFactory.INSTANCE).getQName()) { + if (extendedMetaData != null) { + if (obj instanceof List) { + List list = (List)obj; + for (int i=0; i 0) { + xsiPrefix = typeQName.substring(0, index); + typeName = typeQName.substring(index + 1); + } else + typeName = typeQName; + eFactory = getFactoryForPrefix(xsiPrefix); + if (eFactory != null) + type = helper.getType(eFactory, typeName); + else if (XMLConstants.DEFAULT_NS_PREFIX.equals(xsiPrefix) && helper.getURI(xsiPrefix) == null) { + EPackage ePackage = handleMissingPackage(null); + if (ePackage == null) { + type = defaultRootType(prefix, name, isElement, peekObject, value); + if (type == null) + return; + eFactory = type.getEPackage().getEFactoryInstance(); + } else + type = helper.getType(eFactory = ePackage.getEFactoryInstance(), typeName); + } else { + type = defaultRootType(prefix, name, isElement, peekObject, value); + if (type == null) + return; + eFactory = type.getEPackage().getEFactoryInstance(); + } + } + root = helper.createObject(eFactory, type); + if (root != null) { + if (disableNotify) + root.eSetDeliver(false); + handleObjectAttribs(root); + processObject(root); + return; + } + } + super.handleUnknownFeature(prefix, name, isElement, peekObject, value); + } + + protected RecordedEventXMLStreamReader.Tag tag/* =null */; + + protected List nameSpaces/* = null */; + + public void startPrefixMapping(String prefix, String uri) { + if (nameSpaces == null) + nameSpaces = new ArrayList(); + RecordedEventXMLStreamReader.Tag.bind(prefix, uri, nameSpaces); + if (tag == null) + super.startPrefixMapping(prefix, uri); + } + + public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { + if (tag != null) { + tag.start(uri, localName, qName, attributes, locator, nameSpaces); + nameSpaces = null; + return; + } + EObject peekObject = objects.peekEObject(); + if (peekObject != null) { + String prefix = helper.getPrefix(uri.length() == 0 ? null : uri); + EStructuralFeature feature = getFeature(peekObject, prefix == null ? XMLConstants.DEFAULT_NS_PREFIX : prefix, localName, true); + if (feature != null && feature.getEType() == ChangeSummaryStreamSerializer.ChangeSummary_TYPE) { + tag = new RecordedEventXMLStreamReader.Tag(uri, localName, prefix, attributes, locator, ((SDOXMLHelperImpl) helper).nameSpaceContext(), + nameSpaces); + nameSpaces = null; + return; + } + } + if (nameSpaces != null) + nameSpaces.clear(); + super.startElement(uri, localName, qName, attributes); + } + + public void characters(char[] ch, int start, int length) { + if (tag == null) + super.characters(ch, start, length); + else + tag.text(XMLStreamConstants.CHARACTERS, new String(ch, start, length), locator); + } + + protected Collection changeSummaryDeserializers/* = null */; + + public void endElement(String uri, String localName, String qName) { + if (tag == null) + super.endElement(uri, localName, qName); + else if (tag.end(uri, localName, qName, locator)) { + if (changeSummaryDeserializers == null) + changeSummaryDeserializers = new ArrayList(); + ChangeSummaryStreamDeserializer changeSummaryDeserializer = new ChangeSummaryStreamDeserializer(); + try { + changeSummaryDeserializer.begin( + (DataObject) objects.peekEObject(), + new HelperContextImpl(extendedMetaData, false), + tag.play(xmlResource)); + changeSummaryDeserializers.add(changeSummaryDeserializer); + } catch (XMLStreamException e) { + xmlResource.getErrors().add(new XMIException(e)); + } + tag = null; + } + } + + public void endDocument() { + super.endDocument(); + if (changeSummaryDeserializers != null) + for (Iterator iterator = changeSummaryDeserializers.iterator(); iterator.hasNext();) + try { + ((ChangeSummaryStreamDeserializer) iterator.next()).end(); + // iterator.remove(); + } catch (XMLStreamException e) { + xmlResource.getErrors().add(new XMIException(e)); + } + } + } + + protected DefaultHandler makeDefaultHandler() { + return new XmlHandler(); + } + + /** + * 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()); + } + + static protected int loadLaxForm; + static { + int defaultLaxForm = 0x4242; + String property = System.getProperty("XML.load.form.lax"); + if (property == null) + loadLaxForm = defaultLaxForm; + else + try { + loadLaxForm = Integer.decode(property).intValue(); + } catch (NumberFormatException eNumberFormat) { + loadLaxForm = defaultLaxForm; + } + } + + public void doLoad(InputSource inputSource, Map options) throws IOException { + if (options != null) { + /* + * Tolerates element/attribute malform unless indicated not to + */ + Object option = options.get(SDOHelper.XMLOptions.XML_LOAD_LAX_FORM); + int tolerance = option == null ? loadLaxForm : ((Number) option).intValue(); + option = options.get(OPTION_EXTENDED_META_DATA); + if (tolerance == 0) { + if (option instanceof SDOExtendedMetaData) + ((SDOExtendedMetaData) option).setFeatureNamespaceMatchingLax(false); + } else if (option instanceof SDOExtendedMetaData){ + ((SDOExtendedMetaData) option).setFeatureNamespaceMatchingLax(true); + } + else{ + options.put(OPTION_EXTENDED_META_DATA, option = new SDOExtendedMetaDataImpl()); // TODO copy (BasicExtendedMetaData)option + } + /* + * Loads schema if necessary + */ + if (Boolean.TRUE.equals(options.get(SDOHelper.XMLOptions.XML_LOAD_SCHEMA))){ + XMLOptions xmlOptions = (XMLOptions) options.get(OPTION_XML_OPTIONS); + if (xmlOptions == null) { + xmlOptions = new XMLOptionsImpl(); + options.put(OPTION_XML_OPTIONS, xmlOptions); + } + xmlOptions.setProcessSchemaLocations(true); + if (option == null){ + option = getDefaultLoadOptions().get(OPTION_EXTENDED_META_DATA); + } + ExtendedMetaData extendedMetaData; + final XSDHelper xsdHelper; + if (option == null) { + extendedMetaData = ExtendedMetaData.INSTANCE; + xsdHelper = XSDHelper.INSTANCE; + } else { + extendedMetaData = (ExtendedMetaData) option; + xsdHelper = (new HelperContextImpl(extendedMetaData, false)).getXSDHelper(); + } + xmlOptions.setEcoreBuilder(new DefaultEcoreBuilder(extendedMetaData) { + public Collection generate(Map targetNamespaceToURI) throws IOException { + for (Iterator iterator = targetNamespaceToURI.values().iterator(); iterator.hasNext();) { + String uri = iterator.next().toString(); + xsdHelper.define(uri.indexOf(":/") == -1 ? Thread.currentThread().getContextClassLoader().getResourceAsStream(uri) + : new URL(uri).openStream(), uri); + } + return null; // XMLHandler#processSchemaLocations doesn't take the result + } + }); + } + + if (Boolean.TRUE.equals(options.get(SDOHelper.XMLOptions.XML_LOAD_UNKNOWN_PROPERTIES))) { + options.put(OPTION_RECORD_UNKNOWN_FEATURE , Boolean.TRUE); + } + } + else if (loadLaxForm != 0) { + /* + * Tolerates element/attribute malform + */ + options = new HashMap(); + options.put(OPTION_EXTENDED_META_DATA, new SDOExtendedMetaDataImpl()); + } + super.doLoad(inputSource, options); + // TODO there is some thinking to be done about the restoration of options + } + + /** + * 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); + } + + ChangeSummaryStreamSerializer changeSummarySerializer/* = null*/; + + static private final class LocalName extends QName { + private LocalName(String name) { + super(name); + } + + public String getNamespaceURI() { + return null; + } + } + + static final String INDENT = " ", LINE_SEPARATOR = System.getProperty("line.separator"); + + static final class XmlString extends XMLString { + XmlString(int lineWidth, String temporaryFileName) { + super(lineWidth, temporaryFileName); // setLineWidth & setTemporaryFileName + } + + XmlString(int lineWidth, String publicId, String systemId, String temporaryFileName) { + super(lineWidth, publicId, systemId, temporaryFileName); + } + + void setLineBreak(String lineBreak) { + lineSeparator = lineBreak; + } + + void margin(String margin) { + indents.set(0, margin); + } + + String indent = INDENT; + + protected String getElementIndent(int extra) { + int nesting = depth + extra - 1; + for (int i = indents.size() - 1; i < nesting; ++i) { + indents.add(indents.get(i) + indent); + } + return (String) indents.get(nesting); + } + + protected String getAttributeIndent() { + return getElementIndent(); + } + + public final boolean mixed() { + return isMixed; + } + + public void reset(String publicId, String systemId, int lineWidth, String temporaryFileName) { + super.reset(publicId, systemId, lineWidth, temporaryFileName); + setLineBreak(LINE_SEPARATOR); + indent = INDENT; + } + } + + static final char MARK = '\n'; + + static final String LINE_BREAK = new String(new char[] { MARK }); + + final class SDOXMLSaveImpl extends XMLSaveImpl { + SDOXMLSaveImpl(XMLHelper helper) { + super(helper); + } + + XmlString doc(XMLResource resource, Map options) { + if (doc instanceof XmlString) + return (XmlString) doc; + Object lineWidth = options.get(OPTION_LINE_WIDTH); + int width = lineWidth == null ? Integer.MAX_VALUE : ((Number) lineWidth).intValue(); + XmlString d = resource != null && Boolean.TRUE.equals(options.get(OPTION_SAVE_DOCTYPE)) ? new XmlString(width, resource.getPublicId(), + resource.getSystemId(), doc.getTemporaryFileName()) : new XmlString(width, doc.getTemporaryFileName()); + doc = d; + return d; + } + + Map changeSummaryOptions = new HashMap(); + String indent = INDENT, margin; + + protected void init(XMLResource resource, Map options) { + super.init(resource, options); + int unformat = 0; + String lineBreak = (String) options.get(SDOHelper.XMLOptions.XML_SAVE_LINE_BREAK); + if (lineBreak == null) + changeSummaryOptions.put(SDOHelper.XMLOptions.XML_SAVE_LINE_BREAK, LINE_BREAK); + else if (lineBreak.length() == 0) + ++unformat; + else { + changeSummaryOptions.put(SDOHelper.XMLOptions.XML_SAVE_LINE_BREAK, LINE_BREAK); + if (lineBreak.equals(LINE_SEPARATOR)) + lineBreak = null; + } + String indent = (String) options.get(SDOHelper.XMLOptions.XML_SAVE_INDENT); + if (indent == null) + changeSummaryOptions.put(SDOHelper.XMLOptions.XML_SAVE_INDENT, INDENT); + else if (indent.length() == 0) + ++unformat; + else { + changeSummaryOptions.put(SDOHelper.XMLOptions.XML_SAVE_INDENT, this.indent = indent); + if (indent.equals(INDENT)) + indent = null; + } + String margin = (String) options.get(SDOHelper.XMLOptions.XML_SAVE_MARGIN); + if (margin == null || margin.length() == 0) { + if (unformat == 2) + doc.setUnformatted(true); + else if (lineBreak != null) { + XmlString d = doc(resource, options); + d.setLineBreak(lineBreak); + if (indent != null) + d.indent = indent; + } else if (indent != null) + doc(resource, options).indent = indent; + this.margin = this.indent; + } else { + XmlString d = doc(resource, options); + d.margin(margin); + if (lineBreak != null) + d.setLineBreak(lineBreak); + if (indent != null) + d.indent = indent; + this.margin = margin + this.indent; + if (!toDOM && declareXML) + d.add(margin); + } + // changeSummaryOptions.put(ChangeSummaryStreamSerializer.OPTION_RootObject_PATH, "#"); + // changeSummaryOptions.put(ChangeSummaryStreamSerializer.OPTION_OPTIMIZE_LIST, Boolean.TRUE); + changeSummaryOptions.put(OPTION_EXTENDED_META_DATA, extendedMetaData); + } + + QName qName(EStructuralFeature f) { + if (extendedMetaData == null) + return new LocalName(f.getName()); + String nameSpace = extendedMetaData.getNamespace(f), name = extendedMetaData.getName(f); + return nameSpace == null ? new LocalName(name) : new QName(nameSpace, name); + } + + XMLStreamWriter xmlStreamWriter/* = null*/; + + void saveChangeSummary(EObject o, EStructuralFeature f, Object changeSummary) { + boolean notMixed; + if (doc instanceof XmlString) + notMixed = !((XmlString) doc).mixed(); + else if (extendedMetaData == null) + notMixed = true; + else + switch (extendedMetaData.getContentKind(o.eClass())) { + case ExtendedMetaData.MIXED_CONTENT: + case ExtendedMetaData.SIMPLE_CONTENT: + notMixed = false; + break; + default: + notMixed = true; + } + if (notMixed) { + StringBuffer margin = new StringBuffer(this.margin); + for (EObject container = o.eContainer(), grandContainer; (grandContainer = container.eContainer()) != null; container = grandContainer) + margin.append(indent); + changeSummaryOptions.put(SDOHelper.XMLOptions.XML_SAVE_MARGIN, margin.toString()); + } + try { + if (xmlStreamWriter == null) { + xmlStreamWriter = XMLOutputFactory.newInstance().createXMLStreamWriter(new Writer() { + public void close() { + } + + public void flush() { + } + + protected final void add(char[] cbuf, int index, int off) { + doc.addText(new String(cbuf, index, off - index)); + } + + public void write(char[] cbuf, int off, int len) { + if (len != 0) + for (;;) { + while (cbuf[off] == MARK) { + doc.addLine(); + if (--len == 0) + return; + ++off; + } + for (int index = off;/* true */;) { + ++off; + if (--len == 0) + add(cbuf, index, off); + else { + if (cbuf[off] != MARK) + continue; + add(cbuf, index, off); + doc.addLine(); + if (--len != 0) + break; + } + return; + } + ++off; + } + } + }); + xmlStreamWriter.setNamespaceContext(((SDOXMLHelperImpl) helper).new NameSpaceContext() { + public String getNamespaceURI(String prefix) { + return declareXSI && ExtendedMetaData.XSI_PREFIX.equals(prefix) ? ExtendedMetaData.XSI_URI : super + .getNamespaceURI(prefix); + } + + public String getPrefix(String namespaceURI) { + return declareXSI && ExtendedMetaData.XSI_URI.equals(namespaceURI) ? ExtendedMetaData.XSI_PREFIX : super + .getPrefix(namespaceURI); + } + + public Iterator getPrefixes(String namespaceURI) { + final Iterator iterator = super.getPrefixes(namespaceURI); + return ExtendedMetaData.XSI_URI.equals(namespaceURI) ? new Iterator() { + boolean first = true; + + public boolean hasNext() { + if (first) + if (declareXSI) // never from true to false + return true; + else + first = false; + return iterator.hasNext(); + } + + public Object next() { + if (first) { + first = false; + if (declareXSI) + return ExtendedMetaData.XSI_PREFIX; + } + return iterator.next(); + } + + public void remove() { + if (first) + declareXSI = false; + else + iterator.remove(); + } + } : iterator; + } + }); + for (Iterator iterator = helper.getPrefixToNamespaceMap().iterator(); iterator.hasNext();) { + Map.Entry entry = (Map.Entry) iterator.next(); + xmlStreamWriter.setPrefix((String) entry.getKey(), (String) entry.getValue()); + } + if (declareXSI) + xmlStreamWriter.setPrefix(ExtendedMetaData.XSI_PREFIX, ExtendedMetaData.XSI_URI); + if (changeSummarySerializer == null) + changeSummarySerializer = new ChangeSummaryStreamSerializer(); + } + changeSummarySerializer.saveChangeSummary((ChangeSummary) changeSummary, qName(f), xmlStreamWriter, changeSummaryOptions); + if (notMixed) + doc.addLine(); + } catch (XMLStreamException e) { + xmlResource.getErrors().add(new XMIException(e)); + } + } + + protected void saveDataTypeElementSingle(EObject o, EStructuralFeature f) { + if (f.getEType() == ChangeSummaryStreamSerializer.ChangeSummary_TYPE) + saveChangeSummary(o, f, helper.getValue(o, f)); + else + super.saveDataTypeElementSingle(o, f); + } + + /* + * TEMPORARILY COPIED FROM BASE CLASS - DO NOT EDIT - WILL BE REMOVED WHEN WE MOVE TO EMF 2.3 + */ + protected boolean saveElementFeatureMap(EObject o, EStructuralFeature f) + { + List values = (List)helper.getValue(o, f); + int size = values.size(); + for (int i = 0; i < size; i++) + { + FeatureMap.Entry entry = (FeatureMap.Entry)values.get(i); + EStructuralFeature entryFeature = entry.getEStructuralFeature(); + Object value = entry.getValue(); + if (entryFeature instanceof EReference) + { + if (value == null) + { + saveNil(o, entryFeature); + } + else + { + EReference referenceEntryFeature = (EReference)entryFeature; + if (referenceEntryFeature.isContainment()) + { + saveElement((InternalEObject)value, entryFeature); + } + else if (referenceEntryFeature.isResolveProxies()) + { + saveFeatureMapElementReference((EObject)value, referenceEntryFeature); + } + else + { + saveElementIDRef(o, (EObject)value, entryFeature); + } + } + } + else + { + if (entryFeature == XMLTypePackage.eINSTANCE.getXMLTypeDocumentRoot_Text()) + { + String svalue = value.toString(); + if (escape != null) + { + svalue = escape.convertText(svalue); + } + if (!toDOM) + { + doc.addText(svalue); + } + else + { + Node text = document.createTextNode(svalue); + currentNode.appendChild(text); + handler.recordValues(text, o, f, entry); + } + } + else if (entryFeature == XMLTypePackage.eINSTANCE.getXMLTypeDocumentRoot_CDATA()) + { + String stringValue = value.toString(); + if (escape != null) + { + stringValue = escape.convertLines(stringValue); + } + if (!toDOM) + { + doc.addCDATA(stringValue); + } + else + { + Node cdata = document.createCDATASection(stringValue); + currentNode.appendChild(cdata); + handler.recordValues(cdata, o, f, entry); + } + } + else if (entryFeature == XMLTypePackage.eINSTANCE.getXMLTypeDocumentRoot_Comment()) + { + String stringValue = value.toString(); + if (escape != null) + { + stringValue = escape.convertLines(stringValue); + } + if (!toDOM) + { + doc.addComment(stringValue); + } + else + { + // TODO comments are not sent to recordValues + currentNode.appendChild(document.createComment(stringValue)); + } + } + else + { + saveElement(o, value, entryFeature); + } + } + } + return size > 0; + } + + protected final void saveElement(EObject o, Object value, EStructuralFeature f) + { + if (f.getEType() == ChangeSummaryStreamSerializer.ChangeSummary_TYPE) + { + saveChangeSummary(o, f, value); + return; + } + /* super.saveElement(o, value, f); + * TEMPORARILY COPIED FROM BASE CLASS - DO NOT EDIT - WILL BE REMOVED WHEN WE MOVE TO EMF 2.3 + */ + if (value == null) + { + saveNil(o, f); + } + else + { + String svalue = getDatatypeValue(value, f, false); + if (!toDOM) + { + doc.saveDataValueElement(helper.getQName(f), svalue); + } + else + { + helper.populateNameInfo(nameInfo, f); + Element elem = document.createElementNS(nameInfo.getNamespaceURI(), nameInfo.getQualifiedName()); + Node text = document.createTextNode(svalue); + elem.appendChild(text); + currentNode.appendChild(elem); + handler.recordValues(elem, o, f, value); + handler.recordValues(text, o, f, value); + } + } + } + } + + protected XMLSave createXMLSave() { + return new SDOXMLSaveImpl(createXMLHelper()); + } +} diff --git a/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/XMLDocumentStreamReader.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/XMLDocumentStreamReader.java new file mode 100644 index 0000000000..64088a0366 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/XMLDocumentStreamReader.java @@ -0,0 +1,438 @@ +/** + * + * 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 + * org.apache.axis2.util.StreamWrapper. 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 { + return realReader.getProperty(s); + } + + 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/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/XMLFragmentStreamReader.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/XMLFragmentStreamReader.java new file mode 100644 index 0000000000..66d8fbdc6a --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/XMLFragmentStreamReader.java @@ -0,0 +1,44 @@ +/** + * + * 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.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(); + + /** + * 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/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/XMLStreamSerializer.java b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/XMLStreamSerializer.java new file mode 100644 index 0000000000..2c2dc87aa4 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/java/org/apache/tuscany/sdo/util/resource/XMLStreamSerializer.java @@ -0,0 +1,414 @@ +/* + * 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 java.util.Map; +import javax.xml.namespace.NamespaceContext; +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 org.apache.tuscany.sdo.api.SDOHelper; +import org.apache.tuscany.sdo.api.SDOUtil; +/** + * 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); + } + + public void serialize(XMLStreamReader node, XMLStreamWriter writer, Map options) throws XMLStreamException { + this.options = options; + 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) { + if(options == null){ + serializeElement(reader, writer); + } + else{ + serializeElementWithOptions(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) { + if(options == null){ + serializeEndElement(writer); + }else{ + serializeEndElementWithOptions(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 { + if(options == null){ + serializeEndElement(writer); + } + else{ + serializeEndElementWithOptions(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); + + } + /** + * @param reader + * @param writer + * @throws XMLStreamException + */ + protected void serializeElementWithOptions(XMLStreamReader reader, XMLStreamWriter writer) throws XMLStreamException { + ++nest; + boolean brk=false; + if(oldNest != nest){ + if(oldNest < nest) brk = true; + oldNest = nest; + } + startElement(writer); + String prefix = reader.getPrefix(); + String nameSpaceName = reader.getNamespaceURI(); + if (nameSpaceName != null) { + String writer_prefix = writer.getPrefix(nameSpaceName); + + if (writer_prefix != null) { + if(brk && nest != 1){ + breakLine(writer, true, true); + } + else{ + breakLine(writer, false, true); + } + + writer.writeStartElement(nameSpaceName, reader.getLocalName()); + } else { + if (prefix != null) { + if(brk && nest == 1){ + breakLine(writer, false, true); + } + writer.writeStartElement(prefix, reader.getLocalName(), nameSpaceName); + writer.writeNamespace(prefix, nameSpaceName); + writer.setPrefix(prefix, nameSpaceName); + } else { + if(brk && nest == 1){ + breakLine(writer, false, true); + } + writer.writeStartElement(nameSpaceName, reader.getLocalName()); + writer.writeDefaultNamespace(nameSpaceName); + writer.setDefaultNamespace(nameSpaceName); + if(brk && nest == 1){ + breakLine(writer, false, true); + } + } + } + } 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(); + } + + /** + * Method serializeEndElement. + * + * @param writer + * @throws XMLStreamException + */ + protected void serializeEndElementWithOptions(XMLStreamWriter writer) throws XMLStreamException { + --nest; + if(oldNest > nest+1){ + nest++; + breakLine(writer, false, true); + writer.writeEndElement(); + breakLine(writer, true, false); + nest--; + } + else{ + writer.writeEndElement(); + breakLine(writer, true, false); + } + } + /** + * @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); + } + } + private String lineBreak, indent, margin = null; + + private int nest; + private int oldNest; + + private void breakLine(XMLStreamWriter writer, boolean breakLine, boolean others) throws XMLStreamException { + if (options == null || (lineBreak==null && indent==null && margin==null) ) + return; + if(breakLine) + writer.writeCharacters(lineBreak); + + if (margin != null){ + if(others) + writer.writeCharacters(margin); + } + + if (indent != null && others){ + for (int count = nest; count != 1; --count){//!= 0 + writer.writeCharacters(indent); + } + } + } + + private Map options; + + static private final String STRING_OPTION = "String option"; + + void startElement(XMLStreamWriter writer) throws XMLStreamException { + if (options == null) + return; + lineBreak = (String) options.get(SDOHelper.XMLOptions.XML_SAVE_LINE_BREAK); + if (lineBreak == null) + return; + margin = (String) options.get(SDOHelper.XMLOptions.XML_SAVE_MARGIN); + indent = (String) options.get(SDOHelper.XMLOptions.XML_SAVE_INDENT); + } +} diff --git a/sandbox/kgoodson/events/impl/src/main/resources/META-INF/DISCLAIMER b/sandbox/kgoodson/events/impl/src/main/resources/META-INF/DISCLAIMER new file mode 100644 index 0000000000..a65af91c5a --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/resources/META-INF/DISCLAIMER @@ -0,0 +1,7 @@ +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. \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/main/resources/META-INF/LICENSE.txt b/sandbox/kgoodson/events/impl/src/main/resources/META-INF/LICENSE.txt new file mode 100644 index 0000000000..9a90d375bc --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/resources/META-INF/LICENSE.txt @@ -0,0 +1,207 @@ + + 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. + + + + + diff --git a/sandbox/kgoodson/events/impl/src/main/resources/META-INF/MANIFEST.MF b/sandbox/kgoodson/events/impl/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..e81250d5e3 --- /dev/null +++ b/sandbox/kgoodson/events/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-M3 +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/kgoodson/events/impl/src/main/resources/META-INF/NOTICE b/sandbox/kgoodson/events/impl/src/main/resources/META-INF/NOTICE new file mode 100644 index 0000000000..ba033412a9 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/resources/META-INF/NOTICE @@ -0,0 +1,14 @@ +Apache Tuscany +Copyright (c) 2005 - 2007 The Apache Software Foundation + +========================================================================= +== NOTICE file corresponding to the section 4 d of == +== the Apache License, Version 2.0, == +== in this case for the Apache Tuscany distribution. == +========================================================================= + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + +Please see the LICENSE file present in the META-INF directory of this archive. + diff --git a/sandbox/kgoodson/events/impl/src/main/resources/META-INF/README.txt b/sandbox/kgoodson/events/impl/src/main/resources/META-INF/README.txt new file mode 100644 index 0000000000..0ad57411e2 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/resources/META-INF/README.txt @@ -0,0 +1,23 @@ +Apache Tuscany 1.0-incubating build (July 2007) +=============================================== + +http://incubator.apache.org/tuscany/ + +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/kgoodson/events/impl/src/main/resources/META-INF/services/commonj.sdo.impl.HelperProvider b/sandbox/kgoodson/events/impl/src/main/resources/META-INF/services/commonj.sdo.impl.HelperProvider new file mode 100644 index 0000000000..73693d6556 --- /dev/null +++ b/sandbox/kgoodson/events/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/kgoodson/events/impl/src/main/resources/sdo-metadata.xsd b/sandbox/kgoodson/events/impl/src/main/resources/sdo-metadata.xsd new file mode 100644 index 0000000000..6a5132ed56 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/resources/sdo-metadata.xsd @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/main/resources/xml/sdoInternal.xsd b/sandbox/kgoodson/events/impl/src/main/resources/xml/sdoInternal.xsd new file mode 100644 index 0000000000..c1616ad7fe --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/resources/xml/sdoInternal.xsd @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/main/resources/xml/sdoModelChangeSummary.xsd b/sandbox/kgoodson/events/impl/src/main/resources/xml/sdoModelChangeSummary.xsd new file mode 100644 index 0000000000..645b7b700a --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/main/resources/xml/sdoModelChangeSummary.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionFactory.java b/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionFactory.java new file mode 100644 index 0000000000..0ba0d7037e --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionFactory.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 com.example.ExpectedException; + +import commonj.sdo.helper.HelperContext; + + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @generated + */ +public interface ExpectedExceptionFactory +{ + + /** + * The singleton instance of the factory. + * + * + * @generated + */ + ExpectedExceptionFactory INSTANCE = com.example.ExpectedException.impl.ExpectedExceptionFactoryImpl.init(); + + /** + * Returns a new object of class 'Type'. + * + * + * @return a new object of class 'Type'. + * @generated + */ + ExpectedExceptionType createExpectedExceptionType(); + + /** + * Returns a new object of class 'Sequence Read Only Type'. + * + * + * @return a new object of class 'Sequence Read Only Type'. + * @generated + */ + SequenceReadOnlyType createSequenceReadOnlyType(); + + /** + * Registers the types supported by this Factory within the supplied scope.argument + * + * + * @param scope an instance of HelperContext used to manage the scoping of types. + * @generated + */ + public void register(HelperContext scope); + +} //ExpectedExceptionFactory diff --git a/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionType.java b/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionType.java new file mode 100644 index 0000000000..2f3e1ba63a --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionType.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 com.example.ExpectedException; + +import java.io.Serializable; + +import java.math.BigDecimal; +import java.math.BigInteger; + +import java.util.List; + +/** + * + * A representation of the model object 'Type'. + * + * + *

      + * The following features are supported: + *

        + *
      • {@link com.example.ExpectedException.ExpectedExceptionType#getStringVal String Val}
      • + *
      • {@link com.example.ExpectedException.ExpectedExceptionType#isBooleanVal Boolean Val}
      • + *
      • {@link com.example.ExpectedException.ExpectedExceptionType#getByteVal Byte Val}
      • + *
      • {@link com.example.ExpectedException.ExpectedExceptionType#getDecimalVal Decimal Val}
      • + *
      • {@link com.example.ExpectedException.ExpectedExceptionType#getIntVal Int Val}
      • + *
      • {@link com.example.ExpectedException.ExpectedExceptionType#getFloatVal Float Val}
      • + *
      • {@link com.example.ExpectedException.ExpectedExceptionType#getDoubleVal Double Val}
      • + *
      • {@link com.example.ExpectedException.ExpectedExceptionType#getDateVal Date Val}
      • + *
      • {@link com.example.ExpectedException.ExpectedExceptionType#getShortVal Short Val}
      • + *
      • {@link com.example.ExpectedException.ExpectedExceptionType#getLongVal Long Val}
      • + *
      • {@link com.example.ExpectedException.ExpectedExceptionType#getListVal List Val}
      • + *
      • {@link com.example.ExpectedException.ExpectedExceptionType#getBytesVal Bytes Val}
      • + *
      • {@link com.example.ExpectedException.ExpectedExceptionType#getIntegerVal Integer Val}
      • + *
      • {@link com.example.ExpectedException.ExpectedExceptionType#getCharVal Char Val}
      • + *
      • {@link com.example.ExpectedException.ExpectedExceptionType#getReadOnlyVal Read Only Val}
      • + *
      • {@link com.example.ExpectedException.ExpectedExceptionType#getReadOnlyListVal Read Only List Val}
      • + *
      + *

      + * + * @extends Serializable + * @generated + */ +public interface ExpectedExceptionType extends Serializable +{ + /** + * Returns the value of the 'String Val' attribute. + * + *

      + * If the meaning of the 'String Val' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'String Val' attribute. + * @see #isSetStringVal() + * @see #unsetStringVal() + * @see #setStringVal(String) + * @generated + */ + String getStringVal(); + + /** + * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getStringVal String Val}' attribute. + * + * + * @param value the new value of the 'String Val' attribute. + * @see #isSetStringVal() + * @see #unsetStringVal() + * @see #getStringVal() + * @generated + */ + void setStringVal(String value); + + /** + * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getStringVal String Val}' attribute. + * + * + * @see #isSetStringVal() + * @see #getStringVal() + * @see #setStringVal(String) + * @generated + */ + void unsetStringVal(); + + /** + * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getStringVal String Val}' attribute is set. + * + * + * @return whether the value of the 'String Val' attribute is set. + * @see #unsetStringVal() + * @see #getStringVal() + * @see #setStringVal(String) + * @generated + */ + boolean isSetStringVal(); + + /** + * Returns the value of the 'Boolean Val' attribute. + * + *

      + * If the meaning of the 'Boolean Val' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Boolean Val' attribute. + * @see #isSetBooleanVal() + * @see #unsetBooleanVal() + * @see #setBooleanVal(boolean) + * @generated + */ + boolean isBooleanVal(); + + /** + * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#isBooleanVal Boolean Val}' attribute. + * + * + * @param value the new value of the 'Boolean Val' attribute. + * @see #isSetBooleanVal() + * @see #unsetBooleanVal() + * @see #isBooleanVal() + * @generated + */ + void setBooleanVal(boolean value); + + /** + * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#isBooleanVal Boolean Val}' attribute. + * + * + * @see #isSetBooleanVal() + * @see #isBooleanVal() + * @see #setBooleanVal(boolean) + * @generated + */ + void unsetBooleanVal(); + + /** + * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#isBooleanVal Boolean Val}' attribute is set. + * + * + * @return whether the value of the 'Boolean Val' attribute is set. + * @see #unsetBooleanVal() + * @see #isBooleanVal() + * @see #setBooleanVal(boolean) + * @generated + */ + boolean isSetBooleanVal(); + + /** + * Returns the value of the 'Byte Val' attribute. + * + *

      + * If the meaning of the 'Byte Val' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Byte Val' attribute. + * @see #isSetByteVal() + * @see #unsetByteVal() + * @see #setByteVal(byte) + * @generated + */ + byte getByteVal(); + + /** + * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getByteVal Byte Val}' attribute. + * + * + * @param value the new value of the 'Byte Val' attribute. + * @see #isSetByteVal() + * @see #unsetByteVal() + * @see #getByteVal() + * @generated + */ + void setByteVal(byte value); + + /** + * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getByteVal Byte Val}' attribute. + * + * + * @see #isSetByteVal() + * @see #getByteVal() + * @see #setByteVal(byte) + * @generated + */ + void unsetByteVal(); + + /** + * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getByteVal Byte Val}' attribute is set. + * + * + * @return whether the value of the 'Byte Val' attribute is set. + * @see #unsetByteVal() + * @see #getByteVal() + * @see #setByteVal(byte) + * @generated + */ + boolean isSetByteVal(); + + /** + * Returns the value of the 'Decimal Val' attribute. + * + *

      + * If the meaning of the 'Decimal Val' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Decimal Val' attribute. + * @see #isSetDecimalVal() + * @see #unsetDecimalVal() + * @see #setDecimalVal(BigDecimal) + * @generated + */ + BigDecimal getDecimalVal(); + + /** + * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDecimalVal Decimal Val}' attribute. + * + * + * @param value the new value of the 'Decimal Val' attribute. + * @see #isSetDecimalVal() + * @see #unsetDecimalVal() + * @see #getDecimalVal() + * @generated + */ + void setDecimalVal(BigDecimal value); + + /** + * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDecimalVal Decimal Val}' attribute. + * + * + * @see #isSetDecimalVal() + * @see #getDecimalVal() + * @see #setDecimalVal(BigDecimal) + * @generated + */ + void unsetDecimalVal(); + + /** + * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDecimalVal Decimal Val}' attribute is set. + * + * + * @return whether the value of the 'Decimal Val' attribute is set. + * @see #unsetDecimalVal() + * @see #getDecimalVal() + * @see #setDecimalVal(BigDecimal) + * @generated + */ + boolean isSetDecimalVal(); + + /** + * Returns the value of the 'Int Val' attribute. + * + *

      + * If the meaning of the 'Int Val' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Int Val' attribute. + * @see #isSetIntVal() + * @see #unsetIntVal() + * @see #setIntVal(int) + * @generated + */ + int getIntVal(); + + /** + * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntVal Int Val}' attribute. + * + * + * @param value the new value of the 'Int Val' attribute. + * @see #isSetIntVal() + * @see #unsetIntVal() + * @see #getIntVal() + * @generated + */ + void setIntVal(int value); + + /** + * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntVal Int Val}' attribute. + * + * + * @see #isSetIntVal() + * @see #getIntVal() + * @see #setIntVal(int) + * @generated + */ + void unsetIntVal(); + + /** + * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntVal Int Val}' attribute is set. + * + * + * @return whether the value of the 'Int Val' attribute is set. + * @see #unsetIntVal() + * @see #getIntVal() + * @see #setIntVal(int) + * @generated + */ + boolean isSetIntVal(); + + /** + * Returns the value of the 'Float Val' attribute. + * + *

      + * If the meaning of the 'Float Val' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Float Val' attribute. + * @see #isSetFloatVal() + * @see #unsetFloatVal() + * @see #setFloatVal(float) + * @generated + */ + float getFloatVal(); + + /** + * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getFloatVal Float Val}' attribute. + * + * + * @param value the new value of the 'Float Val' attribute. + * @see #isSetFloatVal() + * @see #unsetFloatVal() + * @see #getFloatVal() + * @generated + */ + void setFloatVal(float value); + + /** + * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getFloatVal Float Val}' attribute. + * + * + * @see #isSetFloatVal() + * @see #getFloatVal() + * @see #setFloatVal(float) + * @generated + */ + void unsetFloatVal(); + + /** + * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getFloatVal Float Val}' attribute is set. + * + * + * @return whether the value of the 'Float Val' attribute is set. + * @see #unsetFloatVal() + * @see #getFloatVal() + * @see #setFloatVal(float) + * @generated + */ + boolean isSetFloatVal(); + + /** + * Returns the value of the 'Double Val' attribute. + * + *

      + * If the meaning of the 'Double Val' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Double Val' attribute. + * @see #isSetDoubleVal() + * @see #unsetDoubleVal() + * @see #setDoubleVal(double) + * @generated + */ + double getDoubleVal(); + + /** + * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDoubleVal Double Val}' attribute. + * + * + * @param value the new value of the 'Double Val' attribute. + * @see #isSetDoubleVal() + * @see #unsetDoubleVal() + * @see #getDoubleVal() + * @generated + */ + void setDoubleVal(double value); + + /** + * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDoubleVal Double Val}' attribute. + * + * + * @see #isSetDoubleVal() + * @see #getDoubleVal() + * @see #setDoubleVal(double) + * @generated + */ + void unsetDoubleVal(); + + /** + * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDoubleVal Double Val}' attribute is set. + * + * + * @return whether the value of the 'Double Val' attribute is set. + * @see #unsetDoubleVal() + * @see #getDoubleVal() + * @see #setDoubleVal(double) + * @generated + */ + boolean isSetDoubleVal(); + + /** + * Returns the value of the 'Date Val' attribute. + * + *

      + * If the meaning of the 'Date Val' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Date Val' attribute. + * @see #isSetDateVal() + * @see #unsetDateVal() + * @see #setDateVal(String) + * @generated + */ + String getDateVal(); + + /** + * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDateVal Date Val}' attribute. + * + * + * @param value the new value of the 'Date Val' attribute. + * @see #isSetDateVal() + * @see #unsetDateVal() + * @see #getDateVal() + * @generated + */ + void setDateVal(String value); + + /** + * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDateVal Date Val}' attribute. + * + * + * @see #isSetDateVal() + * @see #getDateVal() + * @see #setDateVal(String) + * @generated + */ + void unsetDateVal(); + + /** + * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDateVal Date Val}' attribute is set. + * + * + * @return whether the value of the 'Date Val' attribute is set. + * @see #unsetDateVal() + * @see #getDateVal() + * @see #setDateVal(String) + * @generated + */ + boolean isSetDateVal(); + + /** + * Returns the value of the 'Short Val' attribute. + * + *

      + * If the meaning of the 'Short Val' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Short Val' attribute. + * @see #isSetShortVal() + * @see #unsetShortVal() + * @see #setShortVal(short) + * @generated + */ + short getShortVal(); + + /** + * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getShortVal Short Val}' attribute. + * + * + * @param value the new value of the 'Short Val' attribute. + * @see #isSetShortVal() + * @see #unsetShortVal() + * @see #getShortVal() + * @generated + */ + void setShortVal(short value); + + /** + * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getShortVal Short Val}' attribute. + * + * + * @see #isSetShortVal() + * @see #getShortVal() + * @see #setShortVal(short) + * @generated + */ + void unsetShortVal(); + + /** + * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getShortVal Short Val}' attribute is set. + * + * + * @return whether the value of the 'Short Val' attribute is set. + * @see #unsetShortVal() + * @see #getShortVal() + * @see #setShortVal(short) + * @generated + */ + boolean isSetShortVal(); + + /** + * Returns the value of the 'Long Val' attribute. + * + *

      + * If the meaning of the 'Long Val' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Long Val' attribute. + * @see #isSetLongVal() + * @see #unsetLongVal() + * @see #setLongVal(long) + * @generated + */ + long getLongVal(); + + /** + * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getLongVal Long Val}' attribute. + * + * + * @param value the new value of the 'Long Val' attribute. + * @see #isSetLongVal() + * @see #unsetLongVal() + * @see #getLongVal() + * @generated + */ + void setLongVal(long value); + + /** + * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getLongVal Long Val}' attribute. + * + * + * @see #isSetLongVal() + * @see #getLongVal() + * @see #setLongVal(long) + * @generated + */ + void unsetLongVal(); + + /** + * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getLongVal Long Val}' attribute is set. + * + * + * @return whether the value of the 'Long Val' attribute is set. + * @see #unsetLongVal() + * @see #getLongVal() + * @see #setLongVal(long) + * @generated + */ + boolean isSetLongVal(); + + /** + * Returns the value of the 'List Val' attribute list. + * The list contents are of type {@link java.lang.String}. + * + *

      + * If the meaning of the 'List Val' attribute list isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'List Val' attribute list. + * @generated + */ + List getListVal(); + + /** + * Returns the value of the 'Bytes Val' attribute. + * + *

      + * If the meaning of the 'Bytes Val' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Bytes Val' attribute. + * @see #isSetBytesVal() + * @see #unsetBytesVal() + * @see #setBytesVal(byte[]) + * @generated + */ + byte[] getBytesVal(); + + /** + * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getBytesVal Bytes Val}' attribute. + * + * + * @param value the new value of the 'Bytes Val' attribute. + * @see #isSetBytesVal() + * @see #unsetBytesVal() + * @see #getBytesVal() + * @generated + */ + void setBytesVal(byte[] value); + + /** + * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getBytesVal Bytes Val}' attribute. + * + * + * @see #isSetBytesVal() + * @see #getBytesVal() + * @see #setBytesVal(byte[]) + * @generated + */ + void unsetBytesVal(); + + /** + * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getBytesVal Bytes Val}' attribute is set. + * + * + * @return whether the value of the 'Bytes Val' attribute is set. + * @see #unsetBytesVal() + * @see #getBytesVal() + * @see #setBytesVal(byte[]) + * @generated + */ + boolean isSetBytesVal(); + + /** + * Returns the value of the 'Integer Val' attribute. + * + *

      + * If the meaning of the 'Integer Val' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Integer Val' attribute. + * @see #isSetIntegerVal() + * @see #unsetIntegerVal() + * @see #setIntegerVal(BigInteger) + * @generated + */ + BigInteger getIntegerVal(); + + /** + * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntegerVal Integer Val}' attribute. + * + * + * @param value the new value of the 'Integer Val' attribute. + * @see #isSetIntegerVal() + * @see #unsetIntegerVal() + * @see #getIntegerVal() + * @generated + */ + void setIntegerVal(BigInteger value); + + /** + * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntegerVal Integer Val}' attribute. + * + * + * @see #isSetIntegerVal() + * @see #getIntegerVal() + * @see #setIntegerVal(BigInteger) + * @generated + */ + void unsetIntegerVal(); + + /** + * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntegerVal Integer Val}' attribute is set. + * + * + * @return whether the value of the 'Integer Val' attribute is set. + * @see #unsetIntegerVal() + * @see #getIntegerVal() + * @see #setIntegerVal(BigInteger) + * @generated + */ + boolean isSetIntegerVal(); + + /** + * Returns the value of the 'Char Val' attribute. + * + *

      + * If the meaning of the 'Char Val' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Char Val' attribute. + * @see #isSetCharVal() + * @see #unsetCharVal() + * @see #setCharVal(String) + * @generated + */ + String getCharVal(); + + /** + * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getCharVal Char Val}' attribute. + * + * + * @param value the new value of the 'Char Val' attribute. + * @see #isSetCharVal() + * @see #unsetCharVal() + * @see #getCharVal() + * @generated + */ + void setCharVal(String value); + + /** + * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getCharVal Char Val}' attribute. + * + * + * @see #isSetCharVal() + * @see #getCharVal() + * @see #setCharVal(String) + * @generated + */ + void unsetCharVal(); + + /** + * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getCharVal Char Val}' attribute is set. + * + * + * @return whether the value of the 'Char Val' attribute is set. + * @see #unsetCharVal() + * @see #getCharVal() + * @see #setCharVal(String) + * @generated + */ + boolean isSetCharVal(); + + /** + * Returns the value of the 'Read Only Val' attribute. + * + *

      + * If the meaning of the 'Read Only Val' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Read Only Val' attribute. + * @see #isSetReadOnlyVal() + * @generated + */ + String getReadOnlyVal(); + + /** + * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getReadOnlyVal Read Only Val}' attribute is set. + * + * + * @return whether the value of the 'Read Only Val' attribute is set. + * @see #getReadOnlyVal() + * @generated + */ + boolean isSetReadOnlyVal(); + + /** + * Returns the value of the 'Read Only List Val' attribute. + * + *

      + * If the meaning of the 'Read Only List Val' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Read Only List Val' attribute. + * @see #isSetReadOnlyListVal() + * @generated + */ + String getReadOnlyListVal(); + + /** + * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getReadOnlyListVal Read Only List Val}' attribute is set. + * + * + * @return whether the value of the 'Read Only List Val' attribute is set. + * @see #getReadOnlyListVal() + * @generated + */ + boolean isSetReadOnlyListVal(); + +} // ExpectedExceptionType diff --git a/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/SequenceReadOnlyType.java b/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/SequenceReadOnlyType.java new file mode 100644 index 0000000000..2a2ae0db02 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/SequenceReadOnlyType.java @@ -0,0 +1,158 @@ +/** + * + * 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.ExpectedException; + +import commonj.sdo.Sequence; + +import java.io.Serializable; + +/** + * + * A representation of the model object 'Sequence Read Only Type'. + * + * + *

      + * The following features are supported: + *

        + *
      • {@link com.example.ExpectedException.SequenceReadOnlyType#getMixed Mixed}
      • + *
      • {@link com.example.ExpectedException.SequenceReadOnlyType#getReadOnlyVal Read Only Val}
      • + *
      • {@link com.example.ExpectedException.SequenceReadOnlyType#getReadOnlyListVal Read Only List Val}
      • + *
      • {@link com.example.ExpectedException.SequenceReadOnlyType#getUniqueName Unique Name}
      • + *
      + *

      + * + * @extends Serializable + * @generated + */ +public interface SequenceReadOnlyType extends Serializable +{ + /** + * Returns the value of the 'Mixed' attribute list. + * + *

      + * If the meaning of the 'Mixed' attribute list isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Mixed' attribute list. + * @generated + */ + Sequence getMixed(); + + /** + * Returns the value of the 'Read Only Val' attribute. + * + *

      + * If the meaning of the 'Read Only Val' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Read Only Val' attribute. + * @see #isSetReadOnlyVal() + * @generated + */ + String getReadOnlyVal(); + + /** + * Returns whether the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getReadOnlyVal Read Only Val}' attribute is set. + * + * + * @return whether the value of the 'Read Only Val' attribute is set. + * @see #getReadOnlyVal() + * @generated + */ + boolean isSetReadOnlyVal(); + + /** + * Returns the value of the 'Read Only List Val' attribute. + * + *

      + * If the meaning of the 'Read Only List Val' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Read Only List Val' attribute. + * @see #isSetReadOnlyListVal() + * @generated + */ + String getReadOnlyListVal(); + + /** + * Returns whether the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getReadOnlyListVal Read Only List Val}' attribute is set. + * + * + * @return whether the value of the 'Read Only List Val' attribute is set. + * @see #getReadOnlyListVal() + * @generated + */ + boolean isSetReadOnlyListVal(); + + /** + * Returns the value of the 'Unique Name' attribute. + * + *

      + * If the meaning of the 'Unique Name' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Unique Name' attribute. + * @see #isSetUniqueName() + * @see #unsetUniqueName() + * @see #setUniqueName(String) + * @generated + */ + String getUniqueName(); + + /** + * Sets the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getUniqueName Unique Name}' attribute. + * + * + * @param value the new value of the 'Unique Name' attribute. + * @see #isSetUniqueName() + * @see #unsetUniqueName() + * @see #getUniqueName() + * @generated + */ + void setUniqueName(String value); + + /** + * Unsets the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getUniqueName Unique Name}' attribute. + * + * + * @see #isSetUniqueName() + * @see #getUniqueName() + * @see #setUniqueName(String) + * @generated + */ + void unsetUniqueName(); + + /** + * Returns whether the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getUniqueName Unique Name}' attribute is set. + * + * + * @return whether the value of the 'Unique Name' attribute is set. + * @see #unsetUniqueName() + * @see #getUniqueName() + * @see #setUniqueName(String) + * @generated + */ + boolean isSetUniqueName(); + +} // SequenceReadOnlyType diff --git a/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionFactoryImpl.java b/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionFactoryImpl.java new file mode 100644 index 0000000000..791c5a4604 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionFactoryImpl.java @@ -0,0 +1,579 @@ +/** + * + * 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.ExpectedException.impl; + +import commonj.sdo.helper.HelperContext; +import org.apache.tuscany.sdo.helper.TypeHelperImpl; + +import com.example.ExpectedException.*; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; + +import org.apache.tuscany.sdo.SDOFactory; + +import org.apache.tuscany.sdo.impl.FactoryBase; + +import org.apache.tuscany.sdo.model.ModelFactory; + +import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl; + +import org.apache.tuscany.sdo.model.internal.InternalFactory; + +import org.apache.tuscany.sdo.util.SDOUtil; + +/** + * + * An implementation of the model Factory. + * Generator information: + * patternVersion=1.2; -prefix ExpectedException + * + * @generated + */ +public class ExpectedExceptionFactoryImpl extends FactoryBase implements ExpectedExceptionFactory +{ + + /** + * The package namespace URI. + * + * + * @generated + */ + public static final String NAMESPACE_URI = "http://example.com/ExpectedException"; + + /** + * The package namespace name. + * + * + * @generated + */ + public static final String NAMESPACE_PREFIX = "expect"; + + /** + * The version of the generator pattern used to generate this class. + * + * + * @generated + */ + public static final String PATTERN_VERSION = "1.2"; + + public static final int EXPECTED_EXCEPTION_TYPE = 1; + public static final int SEQUENCE_READ_ONLY_TYPE = 2; + public static final int CHAR = 3; + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public ExpectedExceptionFactoryImpl() + { + super(NAMESPACE_URI, NAMESPACE_PREFIX, "com.sdo.test.ExpectedException"); + } + + /** + * Registers the Factory instance so that it is available within the supplied scope. + * @argument scope a HelperContext instance that will make the types supported by this Factory available. + * + * + * @generated + */ + public void register(HelperContext scope) { + if(scope == null) { + throw new IllegalArgumentException("Scope can not be null"); + } + TypeHelperImpl th = (TypeHelperImpl)scope.getTypeHelper(); + th.getExtendedMetaData().putPackage(NAMESPACE_URI, this); + } + + /** + * + * + * @generated + */ + public DataObject create(int typeNumber) + { + switch (typeNumber) + { + case EXPECTED_EXCEPTION_TYPE: return (DataObject)createExpectedExceptionType(); + case SEQUENCE_READ_ONLY_TYPE: return (DataObject)createSequenceReadOnlyType(); + default: + return super.create(typeNumber); + } + } + + /** + * + * + * @generated + */ + public Object createFromString(int typeNumber, String initialValue) + { + switch (typeNumber) + { + case CHAR: + return createcharFromString(initialValue); + default: + throw new IllegalArgumentException("The type number '" + typeNumber + "' is not a valid datatype"); + } + } + + /** + * + * + * @generated + */ + public String convertToString(int typeNumber, Object instanceValue) + { + switch (typeNumber) + { + case CHAR: + return convertcharToString(instanceValue); + default: + throw new IllegalArgumentException("The type number '" + typeNumber + "' is not a valid datatype"); + } + } + /** + * + * + * @generated + */ + public ExpectedExceptionType createExpectedExceptionType() + { + ExpectedExceptionTypeImpl expectedExceptionType = new ExpectedExceptionTypeImpl(); + return expectedExceptionType; + } + /** + * + * + * @generated + */ + public SequenceReadOnlyType createSequenceReadOnlyType() + { + SequenceReadOnlyTypeImpl sequenceReadOnlyType = new SequenceReadOnlyTypeImpl(); + return sequenceReadOnlyType; + } + + // Following creates and initializes SDO metadata for the supported types. + protected Type expectedExceptionTypeType = null; + + public Type getExpectedExceptionType() + { + return expectedExceptionTypeType; + } + + protected Type sequenceReadOnlyTypeType = null; + + public Type getSequenceReadOnlyType() + { + return sequenceReadOnlyTypeType; + } + + protected Type char_Type = null; + + public Type getchar() + { + return char_Type; + } + + + private static boolean isInited = false; + + public static ExpectedExceptionFactoryImpl init() + { + if (isInited) return (ExpectedExceptionFactoryImpl)FactoryBase.getStaticFactory(ExpectedExceptionFactoryImpl.NAMESPACE_URI); + ExpectedExceptionFactoryImpl theExpectedExceptionFactoryImpl = new ExpectedExceptionFactoryImpl(); + isInited = true; + + // Initialize dependencies + SDOUtil.registerStaticTypes(SDOFactory.class); + SDOUtil.registerStaticTypes(ModelFactory.class); + SDOUtil.registerStaticTypes(InternalFactory.class); + + // Create package meta-data objects + theExpectedExceptionFactoryImpl.createMetaData(); + + // Initialize created meta-data + theExpectedExceptionFactoryImpl.initializeMetaData(); + + // Mark meta-data to indicate it can't be changed + //theExpectedExceptionFactoryImpl.freeze(); //FB do we need to freeze / should we freeze ???? + + return theExpectedExceptionFactoryImpl; + } + + private boolean isCreated = false; + + public void createMetaData() + { + if (isCreated) return; + isCreated = true; + + // Create types and their properties + expectedExceptionTypeType = createType(false, EXPECTED_EXCEPTION_TYPE); + createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_STRING_VAL); + createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_BOOLEAN_VAL); + createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_BYTE_VAL); + createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_DECIMAL_VAL); + createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_INT_VAL); + createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_FLOAT_VAL); + createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_DOUBLE_VAL); + createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_DATE_VAL); + createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_SHORT_VAL); + createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_LONG_VAL); + createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_LIST_VAL); + createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_BYTES_VAL); + createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_INTEGER_VAL); + createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_CHAR_VAL); + createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_READ_ONLY_VAL); + createProperty(true, expectedExceptionTypeType,ExpectedExceptionTypeImpl.INTERNAL_READ_ONLY_LIST_VAL); + sequenceReadOnlyTypeType = createType(false, SEQUENCE_READ_ONLY_TYPE); + createProperty(true, sequenceReadOnlyTypeType,SequenceReadOnlyTypeImpl.INTERNAL_MIXED); + createProperty(true, sequenceReadOnlyTypeType,SequenceReadOnlyTypeImpl.INTERNAL_READ_ONLY_VAL); + createProperty(true, sequenceReadOnlyTypeType,SequenceReadOnlyTypeImpl.INTERNAL_READ_ONLY_LIST_VAL); + createProperty(true, sequenceReadOnlyTypeType,SequenceReadOnlyTypeImpl.INTERNAL_UNIQUE_NAME); + + // Create data types + char_Type = createType(true, CHAR ); + } + + private boolean isInitialized = false; + + public void initializeMetaData() + { + if (isInitialized) return; + isInitialized = true; + + // Obtain other dependent packages + ModelFactoryImpl theModelPackageImpl = (ModelFactoryImpl)FactoryBase.getStaticFactory(ModelFactoryImpl.NAMESPACE_URI); + Property property = null; + + // Add supertypes to types + + // Initialize types and properties + initializeType(expectedExceptionTypeType, ExpectedExceptionType.class, "ExpectedExceptionType", false); + property = getLocalProperty(expectedExceptionTypeType, 0); + initializeProperty(property, theModelPackageImpl.getString(), "stringVal", null, 1, 1, ExpectedExceptionType.class, false, true, false); + + property = getLocalProperty(expectedExceptionTypeType, 1); + initializeProperty(property, theModelPackageImpl.getBoolean(), "booleanVal", null, 1, 1, ExpectedExceptionType.class, false, true, false); + + property = getLocalProperty(expectedExceptionTypeType, 2); + initializeProperty(property, theModelPackageImpl.getByte(), "byteVal", null, 1, 1, ExpectedExceptionType.class, false, true, false); + + property = getLocalProperty(expectedExceptionTypeType, 3); + initializeProperty(property, theModelPackageImpl.getDecimal(), "decimalVal", null, 1, 1, ExpectedExceptionType.class, false, true, false); + + property = getLocalProperty(expectedExceptionTypeType, 4); + initializeProperty(property, theModelPackageImpl.getInt(), "intVal", null, 1, 1, ExpectedExceptionType.class, false, true, false); + + property = getLocalProperty(expectedExceptionTypeType, 5); + initializeProperty(property, theModelPackageImpl.getFloat(), "floatVal", null, 1, 1, ExpectedExceptionType.class, false, true, false); + + property = getLocalProperty(expectedExceptionTypeType, 6); + initializeProperty(property, theModelPackageImpl.getDouble(), "doubleVal", null, 1, 1, ExpectedExceptionType.class, false, true, false); + + property = getLocalProperty(expectedExceptionTypeType, 7); + initializeProperty(property, theModelPackageImpl.getDateTime(), "dateVal", null, 1, 1, ExpectedExceptionType.class, false, true, false); + + property = getLocalProperty(expectedExceptionTypeType, 8); + initializeProperty(property, theModelPackageImpl.getShort(), "shortVal", null, 1, 1, ExpectedExceptionType.class, false, true, false); + + property = getLocalProperty(expectedExceptionTypeType, 9); + initializeProperty(property, theModelPackageImpl.getLong(), "longVal", null, 1, 1, ExpectedExceptionType.class, false, true, false); + + property = getLocalProperty(expectedExceptionTypeType, 10); + initializeProperty(property, theModelPackageImpl.getString(), "listVal", null, 0, -1, ExpectedExceptionType.class, false, false, false); + + property = getLocalProperty(expectedExceptionTypeType, 11); + initializeProperty(property, theModelPackageImpl.getBytes(), "bytesVal", null, 1, 1, ExpectedExceptionType.class, false, true, false); + + property = getLocalProperty(expectedExceptionTypeType, 12); + initializeProperty(property, theModelPackageImpl.getInteger(), "integerVal", null, 1, 1, ExpectedExceptionType.class, false, true, false); + + property = getLocalProperty(expectedExceptionTypeType, 13); + initializeProperty(property, this.getchar(), "charVal", null, 1, 1, ExpectedExceptionType.class, false, true, false); + + property = getLocalProperty(expectedExceptionTypeType, 14); + initializeProperty(property, theModelPackageImpl.getString(), "readOnlyVal", null, 1, 1, ExpectedExceptionType.class, true, true, false); + setInstanceProperty (property, "commonj.sdo/xml", "readOnly", "true"); + + property = getLocalProperty(expectedExceptionTypeType, 15); + initializeProperty(property, theModelPackageImpl.getString(), "readOnlyListVal", null, 1, 1, ExpectedExceptionType.class, true, true, false); + setInstanceProperty (property, "commonj.sdo/xml", "readOnly", "true"); + + initializeType(sequenceReadOnlyTypeType, SequenceReadOnlyType.class, "SequenceReadOnlyType", false); + property = getLocalProperty(sequenceReadOnlyTypeType, 0); + initializeProperty(property, getSequence(), "mixed", null, 0, -1, SequenceReadOnlyType.class, false, false, false); + + property = getLocalProperty(sequenceReadOnlyTypeType, 1); + initializeProperty(property, theModelPackageImpl.getString(), "readOnlyVal", null, 1, 1, SequenceReadOnlyType.class, true, true, true); + setInstanceProperty (property, "commonj.sdo/xml", "readOnly", "true"); + + property = getLocalProperty(sequenceReadOnlyTypeType, 2); + initializeProperty(property, theModelPackageImpl.getString(), "readOnlyListVal", null, 1, 1, SequenceReadOnlyType.class, true, true, true); + setInstanceProperty (property, "commonj.sdo/xml", "readOnly", "true"); + + property = getLocalProperty(sequenceReadOnlyTypeType, 3); + initializeProperty(property, theModelPackageImpl.getString(), "uniqueName", null, 1, 1, SequenceReadOnlyType.class, false, true, true); + + // Initialize data types + initializeType(char_Type, String.class, "char", true, false); + + createXSDMetaData(theModelPackageImpl); + } + + protected void createXSDMetaData(ModelFactoryImpl theModelPackageImpl) + { + super.initXSD(); + + Property property = null; + + + property = createGlobalProperty + ("expectedExceptionsElem", + this.getExpectedExceptionType(), + new String[] + { + "kind", "element", + "name", "expectedExceptionsElem", + "namespace", "##targetNamespace" + }); + + property = createGlobalProperty + ("sequencedReadOnlyElem", + this.getSequenceReadOnlyType(), + new String[] + { + "kind", "element", + "name", "sequencedReadOnlyElem", + "namespace", "##targetNamespace" + }); + + addXSDMapping + (expectedExceptionTypeType, + new String[] + { + "name", "ExpectedExceptionType", + "kind", "elementOnly" + }); + + addXSDMapping + (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_STRING_VAL), + new String[] + { + "kind", "element", + "name", "stringVal" + }); + + addXSDMapping + (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_BOOLEAN_VAL), + new String[] + { + "kind", "element", + "name", "booleanVal" + }); + + addXSDMapping + (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_BYTE_VAL), + new String[] + { + "kind", "element", + "name", "byteVal" + }); + + addXSDMapping + (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_DECIMAL_VAL), + new String[] + { + "kind", "element", + "name", "decimalVal" + }); + + addXSDMapping + (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_INT_VAL), + new String[] + { + "kind", "element", + "name", "intVal" + }); + + addXSDMapping + (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_FLOAT_VAL), + new String[] + { + "kind", "element", + "name", "floatVal" + }); + + addXSDMapping + (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_DOUBLE_VAL), + new String[] + { + "kind", "element", + "name", "doubleVal" + }); + + addXSDMapping + (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_DATE_VAL), + new String[] + { + "kind", "element", + "name", "dateVal" + }); + + addXSDMapping + (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_SHORT_VAL), + new String[] + { + "kind", "element", + "name", "shortVal" + }); + + addXSDMapping + (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_LONG_VAL), + new String[] + { + "kind", "element", + "name", "longVal" + }); + + addXSDMapping + (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_LIST_VAL), + new String[] + { + "kind", "element", + "name", "listVal" + }); + + addXSDMapping + (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_BYTES_VAL), + new String[] + { + "kind", "element", + "name", "bytesVal" + }); + + addXSDMapping + (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_INTEGER_VAL), + new String[] + { + "kind", "element", + "name", "integerVal" + }); + + addXSDMapping + (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_CHAR_VAL), + new String[] + { + "kind", "element", + "name", "charVal" + }); + + addXSDMapping + (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_READ_ONLY_VAL), + new String[] + { + "kind", "element", + "name", "readOnlyVal" + }); + + addXSDMapping + (getProperty(expectedExceptionTypeType, ExpectedExceptionTypeImpl.INTERNAL_READ_ONLY_LIST_VAL), + new String[] + { + "kind", "element", + "name", "readOnlyListVal" + }); + + addXSDMapping + (sequenceReadOnlyTypeType, + new String[] + { + "name", "SequenceReadOnlyType", + "kind", "mixed" + }); + + addXSDMapping + (getProperty(sequenceReadOnlyTypeType, SequenceReadOnlyTypeImpl.INTERNAL_MIXED), + new String[] + { + "kind", "elementWildcard", + "name", ":mixed" + }); + + addXSDMapping + (getProperty(sequenceReadOnlyTypeType, SequenceReadOnlyTypeImpl.INTERNAL_READ_ONLY_VAL), + new String[] + { + "kind", "element", + "name", "readOnlyVal" + }); + + addXSDMapping + (getProperty(sequenceReadOnlyTypeType, SequenceReadOnlyTypeImpl.INTERNAL_READ_ONLY_LIST_VAL), + new String[] + { + "kind", "element", + "name", "readOnlyListVal" + }); + + addXSDMapping + (getProperty(sequenceReadOnlyTypeType, SequenceReadOnlyTypeImpl.INTERNAL_UNIQUE_NAME), + new String[] + { + "kind", "element", + "name", "uniqueName" + }); + + addXSDMapping + (char_Type, + new String[] + { + "name", "char", + "baseType", "commonj.sdo#String", + "length", "1" + }); + + } + + /** + * + * + * @generated + */ + public String createcharFromString(String initialValue) + { + return (String)((ModelFactoryImpl)ModelFactory.INSTANCE).createStringFromString(initialValue); + } + + /** + * + * + * @generated + */ + public String convertcharToString(Object instanceValue) + { + return ((ModelFactoryImpl)ModelFactory.INSTANCE).convertStringToString(instanceValue); + } + +} //ExpectedExceptionFactoryImpl diff --git a/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionTypeImpl.java b/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionTypeImpl.java new file mode 100644 index 0000000000..9021e52c18 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionTypeImpl.java @@ -0,0 +1,1682 @@ +/** + * + * 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.ExpectedException.impl; + +import com.example.ExpectedException.ExpectedExceptionFactory; +import com.example.ExpectedException.ExpectedExceptionType; + +import commonj.sdo.Type; + +import java.math.BigDecimal; +import java.math.BigInteger; + +import java.util.Collection; +import java.util.List; + +import org.apache.tuscany.sdo.impl.DataObjectBase; + +/** + * + * An implementation of the model object 'Type'. + * + *

      + * The following features are implemented: + *

        + *
      • {@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getStringVal String Val}
      • + *
      • {@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#isBooleanVal Boolean Val}
      • + *
      • {@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getByteVal Byte Val}
      • + *
      • {@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getDecimalVal Decimal Val}
      • + *
      • {@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getIntVal Int Val}
      • + *
      • {@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getFloatVal Float Val}
      • + *
      • {@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getDoubleVal Double Val}
      • + *
      • {@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getDateVal Date Val}
      • + *
      • {@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getShortVal Short Val}
      • + *
      • {@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getLongVal Long Val}
      • + *
      • {@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getListVal List Val}
      • + *
      • {@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getBytesVal Bytes Val}
      • + *
      • {@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getIntegerVal Integer Val}
      • + *
      • {@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getCharVal Char Val}
      • + *
      • {@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getReadOnlyVal Read Only Val}
      • + *
      • {@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getReadOnlyListVal Read Only List Val}
      • + *
      + *

      + * + * @generated + */ +public class ExpectedExceptionTypeImpl extends DataObjectBase implements ExpectedExceptionType +{ + + public final static int STRING_VAL = 0; + + public final static int BOOLEAN_VAL = 1; + + public final static int BYTE_VAL = 2; + + public final static int DECIMAL_VAL = 3; + + public final static int INT_VAL = 4; + + public final static int FLOAT_VAL = 5; + + public final static int DOUBLE_VAL = 6; + + public final static int DATE_VAL = 7; + + public final static int SHORT_VAL = 8; + + public final static int LONG_VAL = 9; + + public final static int LIST_VAL = 10; + + public final static int BYTES_VAL = 11; + + public final static int INTEGER_VAL = 12; + + public final static int CHAR_VAL = 13; + + public final static int READ_ONLY_VAL = 14; + + public final static int READ_ONLY_LIST_VAL = 15; + + public final static int SDO_PROPERTY_COUNT = 16; + + public final static int EXTENDED_PROPERTY_COUNT = 0; + + + /** + * The internal feature id for the 'String Val' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_STRING_VAL = 0; + + /** + * The internal feature id for the 'Boolean Val' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_BOOLEAN_VAL = 1; + + /** + * The internal feature id for the 'Byte Val' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_BYTE_VAL = 2; + + /** + * The internal feature id for the 'Decimal Val' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_DECIMAL_VAL = 3; + + /** + * The internal feature id for the 'Int Val' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_INT_VAL = 4; + + /** + * The internal feature id for the 'Float Val' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_FLOAT_VAL = 5; + + /** + * The internal feature id for the 'Double Val' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_DOUBLE_VAL = 6; + + /** + * The internal feature id for the 'Date Val' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_DATE_VAL = 7; + + /** + * The internal feature id for the 'Short Val' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_SHORT_VAL = 8; + + /** + * The internal feature id for the 'Long Val' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_LONG_VAL = 9; + + /** + * The internal feature id for the 'List Val' attribute list. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_LIST_VAL = 10; + + /** + * The internal feature id for the 'Bytes Val' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_BYTES_VAL = 11; + + /** + * The internal feature id for the 'Integer Val' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_INTEGER_VAL = 12; + + /** + * The internal feature id for the 'Char Val' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_CHAR_VAL = 13; + + /** + * The internal feature id for the 'Read Only Val' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_READ_ONLY_VAL = 14; + + /** + * The internal feature id for the 'Read Only List Val' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_READ_ONLY_LIST_VAL = 15; + + /** + * The number of properties for this type. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_PROPERTY_COUNT = 16; + + protected int internalConvertIndex(int internalIndex) + { + switch (internalIndex) + { + case INTERNAL_STRING_VAL: return STRING_VAL; + case INTERNAL_BOOLEAN_VAL: return BOOLEAN_VAL; + case INTERNAL_BYTE_VAL: return BYTE_VAL; + case INTERNAL_DECIMAL_VAL: return DECIMAL_VAL; + case INTERNAL_INT_VAL: return INT_VAL; + case INTERNAL_FLOAT_VAL: return FLOAT_VAL; + case INTERNAL_DOUBLE_VAL: return DOUBLE_VAL; + case INTERNAL_DATE_VAL: return DATE_VAL; + case INTERNAL_SHORT_VAL: return SHORT_VAL; + case INTERNAL_LONG_VAL: return LONG_VAL; + case INTERNAL_LIST_VAL: return LIST_VAL; + case INTERNAL_BYTES_VAL: return BYTES_VAL; + case INTERNAL_INTEGER_VAL: return INTEGER_VAL; + case INTERNAL_CHAR_VAL: return CHAR_VAL; + case INTERNAL_READ_ONLY_VAL: return READ_ONLY_VAL; + case INTERNAL_READ_ONLY_LIST_VAL: return READ_ONLY_LIST_VAL; + } + return super.internalConvertIndex(internalIndex); + } + + + /** + * The default value of the '{@link #getStringVal() String Val}' attribute. + * + * + * @see #getStringVal() + * @generated + * @ordered + */ + protected static final String STRING_VAL_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getStringVal() String Val}' attribute. + * + * + * @see #getStringVal() + * @generated + * @ordered + */ + protected String stringVal = STRING_VAL_DEFAULT_; + + /** + * This is true if the String Val attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean stringVal_set_ = false; + + /** + * The default value of the '{@link #isBooleanVal() Boolean Val}' attribute. + * + * + * @see #isBooleanVal() + * @generated + * @ordered + */ + protected static final boolean BOOLEAN_VAL_DEFAULT_ = false; + + /** + * The cached value of the '{@link #isBooleanVal() Boolean Val}' attribute. + * + * + * @see #isBooleanVal() + * @generated + * @ordered + */ + protected boolean booleanVal = BOOLEAN_VAL_DEFAULT_; + + /** + * This is true if the Boolean Val attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean booleanVal_set_ = false; + + /** + * The default value of the '{@link #getByteVal() Byte Val}' attribute. + * + * + * @see #getByteVal() + * @generated + * @ordered + */ + protected static final byte BYTE_VAL_DEFAULT_ = 0; + + /** + * The cached value of the '{@link #getByteVal() Byte Val}' attribute. + * + * + * @see #getByteVal() + * @generated + * @ordered + */ + protected byte byteVal = BYTE_VAL_DEFAULT_; + + /** + * This is true if the Byte Val attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean byteVal_set_ = false; + + /** + * The default value of the '{@link #getDecimalVal() Decimal Val}' attribute. + * + * + * @see #getDecimalVal() + * @generated + * @ordered + */ + protected static final BigDecimal DECIMAL_VAL_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getDecimalVal() Decimal Val}' attribute. + * + * + * @see #getDecimalVal() + * @generated + * @ordered + */ + protected BigDecimal decimalVal = DECIMAL_VAL_DEFAULT_; + + /** + * This is true if the Decimal Val attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean decimalVal_set_ = false; + + /** + * The default value of the '{@link #getIntVal() Int Val}' attribute. + * + * + * @see #getIntVal() + * @generated + * @ordered + */ + protected static final int INT_VAL_DEFAULT_ = 0; + + /** + * The cached value of the '{@link #getIntVal() Int Val}' attribute. + * + * + * @see #getIntVal() + * @generated + * @ordered + */ + protected int intVal = INT_VAL_DEFAULT_; + + /** + * This is true if the Int Val attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean intVal_set_ = false; + + /** + * The default value of the '{@link #getFloatVal() Float Val}' attribute. + * + * + * @see #getFloatVal() + * @generated + * @ordered + */ + protected static final float FLOAT_VAL_DEFAULT_ = 0.0F; + + /** + * The cached value of the '{@link #getFloatVal() Float Val}' attribute. + * + * + * @see #getFloatVal() + * @generated + * @ordered + */ + protected float floatVal = FLOAT_VAL_DEFAULT_; + + /** + * This is true if the Float Val attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean floatVal_set_ = false; + + /** + * The default value of the '{@link #getDoubleVal() Double Val}' attribute. + * + * + * @see #getDoubleVal() + * @generated + * @ordered + */ + protected static final double DOUBLE_VAL_DEFAULT_ = 0.0; + + /** + * The cached value of the '{@link #getDoubleVal() Double Val}' attribute. + * + * + * @see #getDoubleVal() + * @generated + * @ordered + */ + protected double doubleVal = DOUBLE_VAL_DEFAULT_; + + /** + * This is true if the Double Val attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean doubleVal_set_ = false; + + /** + * The default value of the '{@link #getDateVal() Date Val}' attribute. + * + * + * @see #getDateVal() + * @generated + * @ordered + */ + protected static final String DATE_VAL_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getDateVal() Date Val}' attribute. + * + * + * @see #getDateVal() + * @generated + * @ordered + */ + protected String dateVal = DATE_VAL_DEFAULT_; + + /** + * This is true if the Date Val attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean dateVal_set_ = false; + + /** + * The default value of the '{@link #getShortVal() Short Val}' attribute. + * + * + * @see #getShortVal() + * @generated + * @ordered + */ + protected static final short SHORT_VAL_DEFAULT_ = 0; + + /** + * The cached value of the '{@link #getShortVal() Short Val}' attribute. + * + * + * @see #getShortVal() + * @generated + * @ordered + */ + protected short shortVal = SHORT_VAL_DEFAULT_; + + /** + * This is true if the Short Val attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean shortVal_set_ = false; + + /** + * The default value of the '{@link #getLongVal() Long Val}' attribute. + * + * + * @see #getLongVal() + * @generated + * @ordered + */ + protected static final long LONG_VAL_DEFAULT_ = 0L; + + /** + * The cached value of the '{@link #getLongVal() Long Val}' attribute. + * + * + * @see #getLongVal() + * @generated + * @ordered + */ + protected long longVal = LONG_VAL_DEFAULT_; + + /** + * This is true if the Long Val attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean longVal_set_ = false; + + /** + * The cached value of the '{@link #getListVal() List Val}' attribute list. + * + * + * @see #getListVal() + * @generated + * @ordered + */ + + protected List listVal = null; + + /** + * The default value of the '{@link #getBytesVal() Bytes Val}' attribute. + * + * + * @see #getBytesVal() + * @generated + * @ordered + */ + protected static final byte[] BYTES_VAL_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getBytesVal() Bytes Val}' attribute. + * + * + * @see #getBytesVal() + * @generated + * @ordered + */ + protected byte[] bytesVal = BYTES_VAL_DEFAULT_; + + /** + * This is true if the Bytes Val attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean bytesVal_set_ = false; + + /** + * The default value of the '{@link #getIntegerVal() Integer Val}' attribute. + * + * + * @see #getIntegerVal() + * @generated + * @ordered + */ + protected static final BigInteger INTEGER_VAL_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getIntegerVal() Integer Val}' attribute. + * + * + * @see #getIntegerVal() + * @generated + * @ordered + */ + protected BigInteger integerVal = INTEGER_VAL_DEFAULT_; + + /** + * This is true if the Integer Val attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean integerVal_set_ = false; + + /** + * The default value of the '{@link #getCharVal() Char Val}' attribute. + * + * + * @see #getCharVal() + * @generated + * @ordered + */ + protected static final String CHAR_VAL_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getCharVal() Char Val}' attribute. + * + * + * @see #getCharVal() + * @generated + * @ordered + */ + protected String charVal = CHAR_VAL_DEFAULT_; + + /** + * This is true if the Char Val attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean charVal_set_ = false; + + /** + * The default value of the '{@link #getReadOnlyVal() Read Only Val}' attribute. + * + * + * @see #getReadOnlyVal() + * @generated + * @ordered + */ + protected static final String READ_ONLY_VAL_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getReadOnlyVal() Read Only Val}' attribute. + * + * + * @see #getReadOnlyVal() + * @generated + * @ordered + */ + protected String readOnlyVal = READ_ONLY_VAL_DEFAULT_; + + /** + * This is true if the Read Only Val attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean readOnlyVal_set_ = false; + + /** + * The default value of the '{@link #getReadOnlyListVal() Read Only List Val}' attribute. + * + * + * @see #getReadOnlyListVal() + * @generated + * @ordered + */ + protected static final String READ_ONLY_LIST_VAL_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getReadOnlyListVal() Read Only List Val}' attribute. + * + * + * @see #getReadOnlyListVal() + * @generated + * @ordered + */ + protected String readOnlyListVal = READ_ONLY_LIST_VAL_DEFAULT_; + + /** + * This is true if the Read Only List Val attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean readOnlyListVal_set_ = false; + + /** + * + * + * @generated + */ + public ExpectedExceptionTypeImpl() + { + super(); + } + + /** + * + * + * @generated + */ + public Type getStaticType() + { + return ((ExpectedExceptionFactoryImpl)ExpectedExceptionFactory.INSTANCE).getExpectedExceptionType(); + } + + /** + * + * + * @generated + */ + public String getStringVal() + { + return stringVal; + } + /** + * + * + * @generated + */ + public void setStringVal(String newStringVal) + { + String oldStringVal = stringVal; + stringVal = newStringVal; + boolean oldStringVal_set_ = stringVal_set_; + stringVal_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, STRING_VAL, oldStringVal, stringVal, !oldStringVal_set_); + } + + /** + * + * + * @generated + */ + public void unsetStringVal() + { + String oldStringVal = stringVal; + boolean oldStringVal_set_ = stringVal_set_; + stringVal = STRING_VAL_DEFAULT_; + stringVal_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, STRING_VAL, oldStringVal, STRING_VAL_DEFAULT_, oldStringVal_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetStringVal() + { + return stringVal_set_; + } + + /** + * + * + * @generated + */ + public boolean isBooleanVal() + { + return booleanVal; + } + /** + * + * + * @generated + */ + public void setBooleanVal(boolean newBooleanVal) + { + boolean oldBooleanVal = booleanVal; + booleanVal = newBooleanVal; + boolean oldBooleanVal_set_ = booleanVal_set_; + booleanVal_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, BOOLEAN_VAL, oldBooleanVal, booleanVal, !oldBooleanVal_set_); + } + + /** + * + * + * @generated + */ + public void unsetBooleanVal() + { + boolean oldBooleanVal = booleanVal; + boolean oldBooleanVal_set_ = booleanVal_set_; + booleanVal = BOOLEAN_VAL_DEFAULT_; + booleanVal_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, BOOLEAN_VAL, oldBooleanVal, BOOLEAN_VAL_DEFAULT_, oldBooleanVal_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetBooleanVal() + { + return booleanVal_set_; + } + + /** + * + * + * @generated + */ + public byte getByteVal() + { + return byteVal; + } + /** + * + * + * @generated + */ + public void setByteVal(byte newByteVal) + { + byte oldByteVal = byteVal; + byteVal = newByteVal; + boolean oldByteVal_set_ = byteVal_set_; + byteVal_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, BYTE_VAL, oldByteVal, byteVal, !oldByteVal_set_); + } + + /** + * + * + * @generated + */ + public void unsetByteVal() + { + byte oldByteVal = byteVal; + boolean oldByteVal_set_ = byteVal_set_; + byteVal = BYTE_VAL_DEFAULT_; + byteVal_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, BYTE_VAL, oldByteVal, BYTE_VAL_DEFAULT_, oldByteVal_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetByteVal() + { + return byteVal_set_; + } + + /** + * + * + * @generated + */ + public BigDecimal getDecimalVal() + { + return decimalVal; + } + /** + * + * + * @generated + */ + public void setDecimalVal(BigDecimal newDecimalVal) + { + BigDecimal oldDecimalVal = decimalVal; + decimalVal = newDecimalVal; + boolean oldDecimalVal_set_ = decimalVal_set_; + decimalVal_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, DECIMAL_VAL, oldDecimalVal, decimalVal, !oldDecimalVal_set_); + } + + /** + * + * + * @generated + */ + public void unsetDecimalVal() + { + BigDecimal oldDecimalVal = decimalVal; + boolean oldDecimalVal_set_ = decimalVal_set_; + decimalVal = DECIMAL_VAL_DEFAULT_; + decimalVal_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, DECIMAL_VAL, oldDecimalVal, DECIMAL_VAL_DEFAULT_, oldDecimalVal_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetDecimalVal() + { + return decimalVal_set_; + } + + /** + * + * + * @generated + */ + public int getIntVal() + { + return intVal; + } + /** + * + * + * @generated + */ + public void setIntVal(int newIntVal) + { + int oldIntVal = intVal; + intVal = newIntVal; + boolean oldIntVal_set_ = intVal_set_; + intVal_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INT_VAL, oldIntVal, intVal, !oldIntVal_set_); + } + + /** + * + * + * @generated + */ + public void unsetIntVal() + { + int oldIntVal = intVal; + boolean oldIntVal_set_ = intVal_set_; + intVal = INT_VAL_DEFAULT_; + intVal_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INT_VAL, oldIntVal, INT_VAL_DEFAULT_, oldIntVal_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetIntVal() + { + return intVal_set_; + } + + /** + * + * + * @generated + */ + public float getFloatVal() + { + return floatVal; + } + /** + * + * + * @generated + */ + public void setFloatVal(float newFloatVal) + { + float oldFloatVal = floatVal; + floatVal = newFloatVal; + boolean oldFloatVal_set_ = floatVal_set_; + floatVal_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, FLOAT_VAL, oldFloatVal, floatVal, !oldFloatVal_set_); + } + + /** + * + * + * @generated + */ + public void unsetFloatVal() + { + float oldFloatVal = floatVal; + boolean oldFloatVal_set_ = floatVal_set_; + floatVal = FLOAT_VAL_DEFAULT_; + floatVal_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, FLOAT_VAL, oldFloatVal, FLOAT_VAL_DEFAULT_, oldFloatVal_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetFloatVal() + { + return floatVal_set_; + } + + /** + * + * + * @generated + */ + public double getDoubleVal() + { + return doubleVal; + } + /** + * + * + * @generated + */ + public void setDoubleVal(double newDoubleVal) + { + double oldDoubleVal = doubleVal; + doubleVal = newDoubleVal; + boolean oldDoubleVal_set_ = doubleVal_set_; + doubleVal_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, DOUBLE_VAL, oldDoubleVal, doubleVal, !oldDoubleVal_set_); + } + + /** + * + * + * @generated + */ + public void unsetDoubleVal() + { + double oldDoubleVal = doubleVal; + boolean oldDoubleVal_set_ = doubleVal_set_; + doubleVal = DOUBLE_VAL_DEFAULT_; + doubleVal_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, DOUBLE_VAL, oldDoubleVal, DOUBLE_VAL_DEFAULT_, oldDoubleVal_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetDoubleVal() + { + return doubleVal_set_; + } + + /** + * + * + * @generated + */ + public String getDateVal() + { + return dateVal; + } + /** + * + * + * @generated + */ + public void setDateVal(String newDateVal) + { + String oldDateVal = dateVal; + dateVal = newDateVal; + boolean oldDateVal_set_ = dateVal_set_; + dateVal_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, DATE_VAL, oldDateVal, dateVal, !oldDateVal_set_); + } + + /** + * + * + * @generated + */ + public void unsetDateVal() + { + String oldDateVal = dateVal; + boolean oldDateVal_set_ = dateVal_set_; + dateVal = DATE_VAL_DEFAULT_; + dateVal_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, DATE_VAL, oldDateVal, DATE_VAL_DEFAULT_, oldDateVal_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetDateVal() + { + return dateVal_set_; + } + + /** + * + * + * @generated + */ + public short getShortVal() + { + return shortVal; + } + /** + * + * + * @generated + */ + public void setShortVal(short newShortVal) + { + short oldShortVal = shortVal; + shortVal = newShortVal; + boolean oldShortVal_set_ = shortVal_set_; + shortVal_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, SHORT_VAL, oldShortVal, shortVal, !oldShortVal_set_); + } + + /** + * + * + * @generated + */ + public void unsetShortVal() + { + short oldShortVal = shortVal; + boolean oldShortVal_set_ = shortVal_set_; + shortVal = SHORT_VAL_DEFAULT_; + shortVal_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, SHORT_VAL, oldShortVal, SHORT_VAL_DEFAULT_, oldShortVal_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetShortVal() + { + return shortVal_set_; + } + + /** + * + * + * @generated + */ + public long getLongVal() + { + return longVal; + } + /** + * + * + * @generated + */ + public void setLongVal(long newLongVal) + { + long oldLongVal = longVal; + longVal = newLongVal; + boolean oldLongVal_set_ = longVal_set_; + longVal_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, LONG_VAL, oldLongVal, longVal, !oldLongVal_set_); + } + + /** + * + * + * @generated + */ + public void unsetLongVal() + { + long oldLongVal = longVal; + boolean oldLongVal_set_ = longVal_set_; + longVal = LONG_VAL_DEFAULT_; + longVal_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, LONG_VAL, oldLongVal, LONG_VAL_DEFAULT_, oldLongVal_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetLongVal() + { + return longVal_set_; + } + + /** + * + * + * @generated + */ + public List getListVal() + { + if (listVal == null) + { + listVal = createPropertyList(ListKind.DATATYPE, String.class, LIST_VAL, 0); + } + return listVal; + } + /** + * + * + * @generated + */ + public byte[] getBytesVal() + { + return bytesVal; + } + /** + * + * + * @generated + */ + public void setBytesVal(byte[] newBytesVal) + { + byte[] oldBytesVal = bytesVal; + bytesVal = newBytesVal; + boolean oldBytesVal_set_ = bytesVal_set_; + bytesVal_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, BYTES_VAL, oldBytesVal, bytesVal, !oldBytesVal_set_); + } + + /** + * + * + * @generated + */ + public void unsetBytesVal() + { + byte[] oldBytesVal = bytesVal; + boolean oldBytesVal_set_ = bytesVal_set_; + bytesVal = BYTES_VAL_DEFAULT_; + bytesVal_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, BYTES_VAL, oldBytesVal, BYTES_VAL_DEFAULT_, oldBytesVal_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetBytesVal() + { + return bytesVal_set_; + } + + /** + * + * + * @generated + */ + public BigInteger getIntegerVal() + { + return integerVal; + } + /** + * + * + * @generated + */ + public void setIntegerVal(BigInteger newIntegerVal) + { + BigInteger oldIntegerVal = integerVal; + integerVal = newIntegerVal; + boolean oldIntegerVal_set_ = integerVal_set_; + integerVal_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, INTEGER_VAL, oldIntegerVal, integerVal, !oldIntegerVal_set_); + } + + /** + * + * + * @generated + */ + public void unsetIntegerVal() + { + BigInteger oldIntegerVal = integerVal; + boolean oldIntegerVal_set_ = integerVal_set_; + integerVal = INTEGER_VAL_DEFAULT_; + integerVal_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, INTEGER_VAL, oldIntegerVal, INTEGER_VAL_DEFAULT_, oldIntegerVal_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetIntegerVal() + { + return integerVal_set_; + } + + /** + * + * + * @generated + */ + public String getCharVal() + { + return charVal; + } + /** + * + * + * @generated + */ + public void setCharVal(String newCharVal) + { + String oldCharVal = charVal; + charVal = newCharVal; + boolean oldCharVal_set_ = charVal_set_; + charVal_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, CHAR_VAL, oldCharVal, charVal, !oldCharVal_set_); + } + + /** + * + * + * @generated + */ + public void unsetCharVal() + { + String oldCharVal = charVal; + boolean oldCharVal_set_ = charVal_set_; + charVal = CHAR_VAL_DEFAULT_; + charVal_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, CHAR_VAL, oldCharVal, CHAR_VAL_DEFAULT_, oldCharVal_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetCharVal() + { + return charVal_set_; + } + + /** + * + * + * @generated + */ + public String getReadOnlyVal() + { + return readOnlyVal; + } + /** + * + * + * @generated + */ + public boolean isSetReadOnlyVal() + { + return readOnlyVal_set_; + } + + /** + * + * + * @generated + */ + public String getReadOnlyListVal() + { + return readOnlyListVal; + } + /** + * + * + * @generated + */ + public boolean isSetReadOnlyListVal() + { + return readOnlyListVal_set_; + } + + /** + * + * + * @generated + */ + public Object get(int propertyIndex, boolean resolve) + { + switch (propertyIndex) + { + case STRING_VAL: + return getStringVal(); + case BOOLEAN_VAL: + return isBooleanVal() ? Boolean.TRUE : Boolean.FALSE; + case BYTE_VAL: + return new Byte(getByteVal()); + case DECIMAL_VAL: + return getDecimalVal(); + case INT_VAL: + return new Integer(getIntVal()); + case FLOAT_VAL: + return new Float(getFloatVal()); + case DOUBLE_VAL: + return new Double(getDoubleVal()); + case DATE_VAL: + return getDateVal(); + case SHORT_VAL: + return new Short(getShortVal()); + case LONG_VAL: + return new Long(getLongVal()); + case LIST_VAL: + return getListVal(); + case BYTES_VAL: + return getBytesVal(); + case INTEGER_VAL: + return getIntegerVal(); + case CHAR_VAL: + return getCharVal(); + case READ_ONLY_VAL: + return getReadOnlyVal(); + case READ_ONLY_LIST_VAL: + return getReadOnlyListVal(); + } + return super.get(propertyIndex, resolve); + } + + /** + * + * + * @generated + */ + public void set(int propertyIndex, Object newValue) + { + switch (propertyIndex) + { + case STRING_VAL: + setStringVal((String)newValue); + return; + case BOOLEAN_VAL: + setBooleanVal(((Boolean)newValue).booleanValue()); + return; + case BYTE_VAL: + setByteVal(((Byte)newValue).byteValue()); + return; + case DECIMAL_VAL: + setDecimalVal((BigDecimal)newValue); + return; + case INT_VAL: + setIntVal(((Integer)newValue).intValue()); + return; + case FLOAT_VAL: + setFloatVal(((Float)newValue).floatValue()); + return; + case DOUBLE_VAL: + setDoubleVal(((Double)newValue).doubleValue()); + return; + case DATE_VAL: + setDateVal((String)newValue); + return; + case SHORT_VAL: + setShortVal(((Short)newValue).shortValue()); + return; + case LONG_VAL: + setLongVal(((Long)newValue).longValue()); + return; + case LIST_VAL: + getListVal().clear(); + getListVal().addAll((Collection)newValue); + return; + case BYTES_VAL: + setBytesVal((byte[])newValue); + return; + case INTEGER_VAL: + setIntegerVal((BigInteger)newValue); + return; + case CHAR_VAL: + setCharVal((String)newValue); + return; + } + super.set(propertyIndex, newValue); + } + + /** + * + * + * @generated + */ + public void unset(int propertyIndex) + { + switch (propertyIndex) + { + case STRING_VAL: + unsetStringVal(); + return; + case BOOLEAN_VAL: + unsetBooleanVal(); + return; + case BYTE_VAL: + unsetByteVal(); + return; + case DECIMAL_VAL: + unsetDecimalVal(); + return; + case INT_VAL: + unsetIntVal(); + return; + case FLOAT_VAL: + unsetFloatVal(); + return; + case DOUBLE_VAL: + unsetDoubleVal(); + return; + case DATE_VAL: + unsetDateVal(); + return; + case SHORT_VAL: + unsetShortVal(); + return; + case LONG_VAL: + unsetLongVal(); + return; + case LIST_VAL: + getListVal().clear(); + return; + case BYTES_VAL: + unsetBytesVal(); + return; + case INTEGER_VAL: + unsetIntegerVal(); + return; + case CHAR_VAL: + unsetCharVal(); + return; + } + super.unset(propertyIndex); + } + + /** + * + * + * @generated + */ + public boolean isSet(int propertyIndex) + { + switch (propertyIndex) + { + case STRING_VAL: + return isSetStringVal(); + case BOOLEAN_VAL: + return isSetBooleanVal(); + case BYTE_VAL: + return isSetByteVal(); + case DECIMAL_VAL: + return isSetDecimalVal(); + case INT_VAL: + return isSetIntVal(); + case FLOAT_VAL: + return isSetFloatVal(); + case DOUBLE_VAL: + return isSetDoubleVal(); + case DATE_VAL: + return isSetDateVal(); + case SHORT_VAL: + return isSetShortVal(); + case LONG_VAL: + return isSetLongVal(); + case LIST_VAL: + return listVal != null && !listVal.isEmpty(); + case BYTES_VAL: + return isSetBytesVal(); + case INTEGER_VAL: + return isSetIntegerVal(); + case CHAR_VAL: + return isSetCharVal(); + case READ_ONLY_VAL: + return isSetReadOnlyVal(); + case READ_ONLY_LIST_VAL: + return isSetReadOnlyListVal(); + } + return super.isSet(propertyIndex); + } + + /** + * + * + * @generated + */ + public String toString() + { + if (isProxy(this)) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (stringVal: "); + if (stringVal_set_) result.append(stringVal); else result.append(""); + result.append(", booleanVal: "); + if (booleanVal_set_) result.append(booleanVal); else result.append(""); + result.append(", byteVal: "); + if (byteVal_set_) result.append(byteVal); else result.append(""); + result.append(", decimalVal: "); + if (decimalVal_set_) result.append(decimalVal); else result.append(""); + result.append(", intVal: "); + if (intVal_set_) result.append(intVal); else result.append(""); + result.append(", floatVal: "); + if (floatVal_set_) result.append(floatVal); else result.append(""); + result.append(", doubleVal: "); + if (doubleVal_set_) result.append(doubleVal); else result.append(""); + result.append(", dateVal: "); + if (dateVal_set_) result.append(dateVal); else result.append(""); + result.append(", shortVal: "); + if (shortVal_set_) result.append(shortVal); else result.append(""); + result.append(", longVal: "); + if (longVal_set_) result.append(longVal); else result.append(""); + result.append(", listVal: "); + result.append(listVal); + result.append(", bytesVal: "); + if (bytesVal_set_) result.append(bytesVal); else result.append(""); + result.append(", integerVal: "); + if (integerVal_set_) result.append(integerVal); else result.append(""); + result.append(", charVal: "); + if (charVal_set_) result.append(charVal); else result.append(""); + result.append(", readOnlyVal: "); + if (readOnlyVal_set_) result.append(readOnlyVal); else result.append(""); + result.append(", readOnlyListVal: "); + if (readOnlyListVal_set_) result.append(readOnlyListVal); else result.append(""); + result.append(')'); + return result.toString(); + } + +} //ExpectedExceptionTypeImpl diff --git a/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/impl/SequenceReadOnlyTypeImpl.java b/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/impl/SequenceReadOnlyTypeImpl.java new file mode 100644 index 0000000000..4ac8a19807 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/com/example/ExpectedException/impl/SequenceReadOnlyTypeImpl.java @@ -0,0 +1,354 @@ +/** + * + * 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.ExpectedException.impl; + +import com.example.ExpectedException.ExpectedExceptionFactory; +import com.example.ExpectedException.SequenceReadOnlyType; + +import commonj.sdo.Sequence; +import commonj.sdo.Type; + +import org.apache.tuscany.sdo.impl.DataObjectBase; + +/** + * + * An implementation of the model object 'Sequence Read Only Type'. + * + *

      + * The following features are implemented: + *

        + *
      • {@link com.example.ExpectedException.impl.SequenceReadOnlyTypeImpl#getMixed Mixed}
      • + *
      • {@link com.example.ExpectedException.impl.SequenceReadOnlyTypeImpl#getReadOnlyVal Read Only Val}
      • + *
      • {@link com.example.ExpectedException.impl.SequenceReadOnlyTypeImpl#getReadOnlyListVal Read Only List Val}
      • + *
      • {@link com.example.ExpectedException.impl.SequenceReadOnlyTypeImpl#getUniqueName Unique Name}
      • + *
      + *

      + * + * @generated + */ +public class SequenceReadOnlyTypeImpl extends DataObjectBase implements SequenceReadOnlyType +{ + + public final static int MIXED = -1; + + public final static int READ_ONLY_VAL = 0; + + public final static int READ_ONLY_LIST_VAL = 1; + + public final static int UNIQUE_NAME = 2; + + public final static int SDO_PROPERTY_COUNT = 3; + + public final static int EXTENDED_PROPERTY_COUNT = -1; + + + /** + * The internal feature id for the 'Mixed' attribute list. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_MIXED = 0; + + /** + * The internal feature id for the 'Read Only Val' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_READ_ONLY_VAL = 1; + + /** + * The internal feature id for the 'Read Only List Val' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_READ_ONLY_LIST_VAL = 2; + + /** + * The internal feature id for the 'Unique Name' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_UNIQUE_NAME = 3; + + /** + * The number of properties for this type. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_PROPERTY_COUNT = 4; + + protected int internalConvertIndex(int internalIndex) + { + switch (internalIndex) + { + case INTERNAL_MIXED: return MIXED; + case INTERNAL_READ_ONLY_VAL: return READ_ONLY_VAL; + case INTERNAL_READ_ONLY_LIST_VAL: return READ_ONLY_LIST_VAL; + case INTERNAL_UNIQUE_NAME: return UNIQUE_NAME; + } + return super.internalConvertIndex(internalIndex); + } + + + /** + * The cached value of the '{@link #getMixed() Mixed}' attribute list. + * + * + * @see #getMixed() + * @generated + * @ordered + */ + + protected Sequence mixed = null; + + /** + * + * + * @generated + */ + public SequenceReadOnlyTypeImpl() + { + super(); + } + + /** + * + * + * @generated + */ + public Type getStaticType() + { + return ((ExpectedExceptionFactoryImpl)ExpectedExceptionFactory.INSTANCE).getSequenceReadOnlyType(); + } + + /** + * + * + * @generated + */ + public Sequence getMixed() + { + if (mixed == null) + { + mixed = createSequence(INTERNAL_MIXED); + } + return mixed; + } + /** + * + * + * @generated + */ + public String getReadOnlyVal() + { + return (String)get(getMixed(), getType(), INTERNAL_READ_ONLY_VAL); + } + /** + * + * + * @generated + */ + public boolean isSetReadOnlyVal() + { + return isSet(getMixed(), getType(), INTERNAL_READ_ONLY_VAL); + } + + /** + * + * + * @generated + */ + public String getReadOnlyListVal() + { + return (String)get(getMixed(), getType(), INTERNAL_READ_ONLY_LIST_VAL); + } + /** + * + * + * @generated + */ + public boolean isSetReadOnlyListVal() + { + return isSet(getMixed(), getType(), INTERNAL_READ_ONLY_LIST_VAL); + } + + /** + * + * + * @generated + */ + public String getUniqueName() + { + return (String)get(getMixed(), getType(), INTERNAL_UNIQUE_NAME); + } + /** + * + * + * @generated + */ + public void setUniqueName(String newUniqueName) + { + set(getMixed(), getType(), INTERNAL_UNIQUE_NAME, newUniqueName); + } + + /** + * + * + * @generated + */ + public void unsetUniqueName() + { + unset(getMixed(), getType(), INTERNAL_UNIQUE_NAME); + } + + /** + * + * + * @generated + */ + public boolean isSetUniqueName() + { + return isSet(getMixed(), getType(), INTERNAL_UNIQUE_NAME); + } + + /** + * + * + * @generated + */ + public ChangeContext inverseRemove(Object otherEnd, int propertyIndex, ChangeContext changeContext) + { + switch (propertyIndex) + { + case MIXED: + return removeFromSequence(getMixed(), otherEnd, changeContext); + } + return super.inverseRemove(otherEnd, propertyIndex, changeContext); + } + + /** + * + * + * @generated + */ + public Object get(int propertyIndex, boolean resolve) + { + switch (propertyIndex) + { + case MIXED: + // XXX query introduce coreType as an argument? -- semantic = if true -- coreType - return the core EMF object if value is a non-EMF wrapper/view + //if (coreType) + return getMixed(); + case READ_ONLY_VAL: + return getReadOnlyVal(); + case READ_ONLY_LIST_VAL: + return getReadOnlyListVal(); + case UNIQUE_NAME: + return getUniqueName(); + } + return super.get(propertyIndex, resolve); + } + + /** + * + * + * @generated + */ + public void set(int propertyIndex, Object newValue) + { + switch (propertyIndex) + { + case MIXED: + setSequence(getMixed(), newValue); + return; + case UNIQUE_NAME: + setUniqueName((String)newValue); + return; + } + super.set(propertyIndex, newValue); + } + + /** + * + * + * @generated + */ + public void unset(int propertyIndex) + { + switch (propertyIndex) + { + case MIXED: + unsetSequence(getMixed()); + return; + case UNIQUE_NAME: + unsetUniqueName(); + return; + } + super.unset(propertyIndex); + } + + /** + * + * + * @generated + */ + public boolean isSet(int propertyIndex) + { + switch (propertyIndex) + { + case MIXED: + return mixed != null && !isSequenceEmpty(getMixed()); + case READ_ONLY_VAL: + return isSetReadOnlyVal(); + case READ_ONLY_LIST_VAL: + return isSetReadOnlyListVal(); + case UNIQUE_NAME: + return isSetUniqueName(); + } + return super.isSet(propertyIndex); + } + + /** + * + * + * @generated + */ + public String toString() + { + if (isProxy(this)) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (mixed: "); + result.append(mixed); + result.append(')'); + return result.toString(); + } + +} //SequenceReadOnlyTypeImpl diff --git a/sandbox/kgoodson/events/impl/src/test/java/com/example/simple/Quote.java b/sandbox/kgoodson/events/impl/src/test/java/com/example/simple/Quote.java new file mode 100644 index 0000000000..48dcf96d64 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/com/example/simple/Quote.java @@ -0,0 +1,475 @@ +/** + * + * 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.io.Serializable; + +import java.math.BigDecimal; + +import java.util.List; + +/** + * + * A representation of the model object 'Quote'. + * + * + *

      + * The following features are supported: + *

        + *
      • {@link com.example.simple.Quote#getSymbol Symbol}
      • + *
      • {@link com.example.simple.Quote#getCompanyName Company Name}
      • + *
      • {@link com.example.simple.Quote#getPrice Price}
      • + *
      • {@link com.example.simple.Quote#getOpen1 Open1}
      • + *
      • {@link com.example.simple.Quote#getHigh High}
      • + *
      • {@link com.example.simple.Quote#getLow Low}
      • + *
      • {@link com.example.simple.Quote#getVolume Volume}
      • + *
      • {@link com.example.simple.Quote#getChange1 Change1}
      • + *
      • {@link com.example.simple.Quote#getQuotes Quotes}
      • + *
      + *

      + * + * @extends Serializable + * @generated + */ +public interface Quote extends Serializable +{ + /** + * Returns the value of the 'Symbol' attribute. + * + *

      + * If the meaning of the 'Symbol' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Symbol' attribute. + * @see #isSetSymbol() + * @see #unsetSymbol() + * @see #setSymbol(String) + * @generated + */ + String getSymbol(); + + /** + * Sets the value of the '{@link com.example.simple.Quote#getSymbol Symbol}' attribute. + * + * + * @param value the new value of the 'Symbol' attribute. + * @see #isSetSymbol() + * @see #unsetSymbol() + * @see #getSymbol() + * @generated + */ + void setSymbol(String value); + + /** + * Unsets the value of the '{@link com.example.simple.Quote#getSymbol Symbol}' attribute. + * + * + * @see #isSetSymbol() + * @see #getSymbol() + * @see #setSymbol(String) + * @generated + */ + void unsetSymbol(); + + /** + * Returns whether the value of the '{@link com.example.simple.Quote#getSymbol Symbol}' attribute is set. + * + * + * @return whether the value of the 'Symbol' attribute is set. + * @see #unsetSymbol() + * @see #getSymbol() + * @see #setSymbol(String) + * @generated + */ + boolean isSetSymbol(); + + /** + * Returns the value of the 'Company Name' attribute. + * + *

      + * If the meaning of the 'Company Name' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Company Name' attribute. + * @see #isSetCompanyName() + * @see #unsetCompanyName() + * @see #setCompanyName(String) + * @generated + */ + String getCompanyName(); + + /** + * Sets the value of the '{@link com.example.simple.Quote#getCompanyName Company Name}' attribute. + * + * + * @param value the new value of the 'Company Name' attribute. + * @see #isSetCompanyName() + * @see #unsetCompanyName() + * @see #getCompanyName() + * @generated + */ + void setCompanyName(String value); + + /** + * Unsets the value of the '{@link com.example.simple.Quote#getCompanyName Company Name}' attribute. + * + * + * @see #isSetCompanyName() + * @see #getCompanyName() + * @see #setCompanyName(String) + * @generated + */ + void unsetCompanyName(); + + /** + * Returns whether the value of the '{@link com.example.simple.Quote#getCompanyName Company Name}' attribute is set. + * + * + * @return whether the value of the 'Company Name' attribute is set. + * @see #unsetCompanyName() + * @see #getCompanyName() + * @see #setCompanyName(String) + * @generated + */ + boolean isSetCompanyName(); + + /** + * Returns the value of the 'Price' attribute. + * + *

      + * If the meaning of the 'Price' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Price' attribute. + * @see #isSetPrice() + * @see #unsetPrice() + * @see #setPrice(BigDecimal) + * @generated + */ + BigDecimal getPrice(); + + /** + * Sets the value of the '{@link com.example.simple.Quote#getPrice Price}' attribute. + * + * + * @param value the new value of the 'Price' attribute. + * @see #isSetPrice() + * @see #unsetPrice() + * @see #getPrice() + * @generated + */ + void setPrice(BigDecimal value); + + /** + * Unsets the value of the '{@link com.example.simple.Quote#getPrice Price}' attribute. + * + * + * @see #isSetPrice() + * @see #getPrice() + * @see #setPrice(BigDecimal) + * @generated + */ + void unsetPrice(); + + /** + * Returns whether the value of the '{@link com.example.simple.Quote#getPrice Price}' attribute is set. + * + * + * @return whether the value of the 'Price' attribute is set. + * @see #unsetPrice() + * @see #getPrice() + * @see #setPrice(BigDecimal) + * @generated + */ + boolean isSetPrice(); + + /** + * Returns the value of the 'Open1' attribute. + * + *

      + * If the meaning of the 'Open1' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Open1' attribute. + * @see #isSetOpen1() + * @see #unsetOpen1() + * @see #setOpen1(BigDecimal) + * @generated + */ + BigDecimal getOpen1(); + + /** + * Sets the value of the '{@link com.example.simple.Quote#getOpen1 Open1}' attribute. + * + * + * @param value the new value of the 'Open1' attribute. + * @see #isSetOpen1() + * @see #unsetOpen1() + * @see #getOpen1() + * @generated + */ + void setOpen1(BigDecimal value); + + /** + * Unsets the value of the '{@link com.example.simple.Quote#getOpen1 Open1}' attribute. + * + * + * @see #isSetOpen1() + * @see #getOpen1() + * @see #setOpen1(BigDecimal) + * @generated + */ + void unsetOpen1(); + + /** + * Returns whether the value of the '{@link com.example.simple.Quote#getOpen1 Open1}' attribute is set. + * + * + * @return whether the value of the 'Open1' attribute is set. + * @see #unsetOpen1() + * @see #getOpen1() + * @see #setOpen1(BigDecimal) + * @generated + */ + boolean isSetOpen1(); + + /** + * Returns the value of the 'High' attribute. + * + *

      + * If the meaning of the 'High' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'High' attribute. + * @see #isSetHigh() + * @see #unsetHigh() + * @see #setHigh(BigDecimal) + * @generated + */ + BigDecimal getHigh(); + + /** + * Sets the value of the '{@link com.example.simple.Quote#getHigh High}' attribute. + * + * + * @param value the new value of the 'High' attribute. + * @see #isSetHigh() + * @see #unsetHigh() + * @see #getHigh() + * @generated + */ + void setHigh(BigDecimal value); + + /** + * Unsets the value of the '{@link com.example.simple.Quote#getHigh High}' attribute. + * + * + * @see #isSetHigh() + * @see #getHigh() + * @see #setHigh(BigDecimal) + * @generated + */ + void unsetHigh(); + + /** + * Returns whether the value of the '{@link com.example.simple.Quote#getHigh High}' attribute is set. + * + * + * @return whether the value of the 'High' attribute is set. + * @see #unsetHigh() + * @see #getHigh() + * @see #setHigh(BigDecimal) + * @generated + */ + boolean isSetHigh(); + + /** + * Returns the value of the 'Low' attribute. + * + *

      + * If the meaning of the 'Low' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Low' attribute. + * @see #isSetLow() + * @see #unsetLow() + * @see #setLow(BigDecimal) + * @generated + */ + BigDecimal getLow(); + + /** + * Sets the value of the '{@link com.example.simple.Quote#getLow Low}' attribute. + * + * + * @param value the new value of the 'Low' attribute. + * @see #isSetLow() + * @see #unsetLow() + * @see #getLow() + * @generated + */ + void setLow(BigDecimal value); + + /** + * Unsets the value of the '{@link com.example.simple.Quote#getLow Low}' attribute. + * + * + * @see #isSetLow() + * @see #getLow() + * @see #setLow(BigDecimal) + * @generated + */ + void unsetLow(); + + /** + * Returns whether the value of the '{@link com.example.simple.Quote#getLow Low}' attribute is set. + * + * + * @return whether the value of the 'Low' attribute is set. + * @see #unsetLow() + * @see #getLow() + * @see #setLow(BigDecimal) + * @generated + */ + boolean isSetLow(); + + /** + * Returns the value of the 'Volume' attribute. + * + *

      + * If the meaning of the 'Volume' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Volume' attribute. + * @see #isSetVolume() + * @see #unsetVolume() + * @see #setVolume(double) + * @generated + */ + double getVolume(); + + /** + * Sets the value of the '{@link com.example.simple.Quote#getVolume Volume}' attribute. + * + * + * @param value the new value of the 'Volume' attribute. + * @see #isSetVolume() + * @see #unsetVolume() + * @see #getVolume() + * @generated + */ + void setVolume(double value); + + /** + * Unsets the value of the '{@link com.example.simple.Quote#getVolume Volume}' attribute. + * + * + * @see #isSetVolume() + * @see #getVolume() + * @see #setVolume(double) + * @generated + */ + void unsetVolume(); + + /** + * Returns whether the value of the '{@link com.example.simple.Quote#getVolume Volume}' attribute is set. + * + * + * @return whether the value of the 'Volume' attribute is set. + * @see #unsetVolume() + * @see #getVolume() + * @see #setVolume(double) + * @generated + */ + boolean isSetVolume(); + + /** + * Returns the value of the 'Change1' attribute. + * + *

      + * If the meaning of the 'Change1' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Change1' attribute. + * @see #isSetChange1() + * @see #unsetChange1() + * @see #setChange1(double) + * @generated + */ + double getChange1(); + + /** + * Sets the value of the '{@link com.example.simple.Quote#getChange1 Change1}' attribute. + * + * + * @param value the new value of the 'Change1' attribute. + * @see #isSetChange1() + * @see #unsetChange1() + * @see #getChange1() + * @generated + */ + void setChange1(double value); + + /** + * Unsets the value of the '{@link com.example.simple.Quote#getChange1 Change1}' attribute. + * + * + * @see #isSetChange1() + * @see #getChange1() + * @see #setChange1(double) + * @generated + */ + void unsetChange1(); + + /** + * Returns whether the value of the '{@link com.example.simple.Quote#getChange1 Change1}' attribute is set. + * + * + * @return whether the value of the 'Change1' attribute is set. + * @see #unsetChange1() + * @see #getChange1() + * @see #setChange1(double) + * @generated + */ + boolean isSetChange1(); + + /** + * Returns the value of the 'Quotes' containment reference list. + * The list contents are of type {@link com.example.simple.Quote}. + * + *

      + * If the meaning of the 'Quotes' containment reference list isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Quotes' containment reference list. + * @generated + */ + List getQuotes(); + +} // Quote diff --git a/sandbox/kgoodson/events/impl/src/test/java/com/example/simple/SimpleFactory.java b/sandbox/kgoodson/events/impl/src/test/java/com/example/simple/SimpleFactory.java new file mode 100644 index 0000000000..98dc01d69a --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/com/example/simple/SimpleFactory.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 com.example.simple; + +import commonj.sdo.helper.HelperContext; + + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @generated + */ +public interface SimpleFactory +{ + + /** + * The singleton instance of the factory. + * + * + * @generated + */ + SimpleFactory INSTANCE = com.example.simple.impl.SimpleFactoryImpl.init(); + + /** + * Returns a new object of class 'Quote'. + * + * + * @return a new object of class 'Quote'. + * @generated + */ + Quote createQuote(); + + /** + * Registers the types supported by this Factory within the supplied scope.argument + * + * + * @param scope an instance of HelperContext used to manage the scoping of types. + * @generated + */ + public void register(HelperContext scope); + +} //SimpleFactory diff --git a/sandbox/kgoodson/events/impl/src/test/java/com/example/simple/impl/QuoteImpl.java b/sandbox/kgoodson/events/impl/src/test/java/com/example/simple/impl/QuoteImpl.java new file mode 100644 index 0000000000..39af3bbdb2 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/com/example/simple/impl/QuoteImpl.java @@ -0,0 +1,1045 @@ +/** + * + * 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 commonj.sdo.Type; + +import java.math.BigDecimal; + +import java.util.Collection; +import java.util.List; + +import org.apache.tuscany.sdo.impl.DataObjectBase; + +/** + * + * An implementation of the model object 'Quote'. + * + *

      + * The following features are implemented: + *

        + *
      • {@link com.example.simple.impl.QuoteImpl#getSymbol Symbol}
      • + *
      • {@link com.example.simple.impl.QuoteImpl#getCompanyName Company Name}
      • + *
      • {@link com.example.simple.impl.QuoteImpl#getPrice Price}
      • + *
      • {@link com.example.simple.impl.QuoteImpl#getOpen1 Open1}
      • + *
      • {@link com.example.simple.impl.QuoteImpl#getHigh High}
      • + *
      • {@link com.example.simple.impl.QuoteImpl#getLow Low}
      • + *
      • {@link com.example.simple.impl.QuoteImpl#getVolume Volume}
      • + *
      • {@link com.example.simple.impl.QuoteImpl#getChange1 Change1}
      • + *
      • {@link com.example.simple.impl.QuoteImpl#getQuotes Quotes}
      • + *
      + *

      + * + * @generated + */ +public class QuoteImpl extends DataObjectBase implements Quote +{ + + public final static int SYMBOL = 0; + + public final static int COMPANY_NAME = 1; + + public final static int PRICE = 2; + + public final static int OPEN1 = 3; + + public final static int HIGH = 4; + + public final static int LOW = 5; + + public final static int VOLUME = 6; + + public final static int CHANGE1 = 7; + + public final static int QUOTES = 8; + + public final static int SDO_PROPERTY_COUNT = 9; + + public final static int EXTENDED_PROPERTY_COUNT = 0; + + + /** + * The internal feature id for the 'Symbol' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_SYMBOL = 0; + + /** + * The internal feature id for the 'Company Name' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_COMPANY_NAME = 1; + + /** + * The internal feature id for the 'Price' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_PRICE = 2; + + /** + * The internal feature id for the 'Open1' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_OPEN1 = 3; + + /** + * The internal feature id for the 'High' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_HIGH = 4; + + /** + * The internal feature id for the 'Low' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_LOW = 5; + + /** + * The internal feature id for the 'Volume' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_VOLUME = 6; + + /** + * The internal feature id for the 'Change1' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_CHANGE1 = 7; + + /** + * The internal feature id for the 'Quotes' containment reference list. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_QUOTES = 8; + + /** + * The number of properties for this type. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_PROPERTY_COUNT = 9; + + protected int internalConvertIndex(int internalIndex) + { + switch (internalIndex) + { + case INTERNAL_SYMBOL: return SYMBOL; + case INTERNAL_COMPANY_NAME: return COMPANY_NAME; + case INTERNAL_PRICE: return PRICE; + case INTERNAL_OPEN1: return OPEN1; + case INTERNAL_HIGH: return HIGH; + case INTERNAL_LOW: return LOW; + case INTERNAL_VOLUME: return VOLUME; + case INTERNAL_CHANGE1: return CHANGE1; + case INTERNAL_QUOTES: return QUOTES; + } + return super.internalConvertIndex(internalIndex); + } + + + /** + * The default value of the '{@link #getSymbol() Symbol}' attribute. + * + * + * @see #getSymbol() + * @generated + * @ordered + */ + protected static final String SYMBOL_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getSymbol() Symbol}' attribute. + * + * + * @see #getSymbol() + * @generated + * @ordered + */ + protected String symbol = SYMBOL_DEFAULT_; + + /** + * This is true if the Symbol attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean symbol_set_ = false; + + /** + * The default value of the '{@link #getCompanyName() Company Name}' attribute. + * + * + * @see #getCompanyName() + * @generated + * @ordered + */ + protected static final String COMPANY_NAME_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getCompanyName() Company Name}' attribute. + * + * + * @see #getCompanyName() + * @generated + * @ordered + */ + protected String companyName = COMPANY_NAME_DEFAULT_; + + /** + * This is true if the Company Name attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean companyName_set_ = false; + + /** + * The default value of the '{@link #getPrice() Price}' attribute. + * + * + * @see #getPrice() + * @generated + * @ordered + */ + protected static final BigDecimal PRICE_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getPrice() Price}' attribute. + * + * + * @see #getPrice() + * @generated + * @ordered + */ + protected BigDecimal price = PRICE_DEFAULT_; + + /** + * This is true if the Price attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean price_set_ = false; + + /** + * The default value of the '{@link #getOpen1() Open1}' attribute. + * + * + * @see #getOpen1() + * @generated + * @ordered + */ + protected static final BigDecimal OPEN1_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getOpen1() Open1}' attribute. + * + * + * @see #getOpen1() + * @generated + * @ordered + */ + protected BigDecimal open1 = OPEN1_DEFAULT_; + + /** + * This is true if the Open1 attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean open1_set_ = false; + + /** + * The default value of the '{@link #getHigh() High}' attribute. + * + * + * @see #getHigh() + * @generated + * @ordered + */ + protected static final BigDecimal HIGH_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getHigh() High}' attribute. + * + * + * @see #getHigh() + * @generated + * @ordered + */ + protected BigDecimal high = HIGH_DEFAULT_; + + /** + * This is true if the High attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean high_set_ = false; + + /** + * The default value of the '{@link #getLow() Low}' attribute. + * + * + * @see #getLow() + * @generated + * @ordered + */ + protected static final BigDecimal LOW_DEFAULT_ = null; + + /** + * The cached value of the '{@link #getLow() Low}' attribute. + * + * + * @see #getLow() + * @generated + * @ordered + */ + protected BigDecimal low = LOW_DEFAULT_; + + /** + * This is true if the Low attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean low_set_ = false; + + /** + * The default value of the '{@link #getVolume() Volume}' attribute. + * + * + * @see #getVolume() + * @generated + * @ordered + */ + protected static final double VOLUME_DEFAULT_ = 0.0; + + /** + * The cached value of the '{@link #getVolume() Volume}' attribute. + * + * + * @see #getVolume() + * @generated + * @ordered + */ + protected double volume = VOLUME_DEFAULT_; + + /** + * This is true if the Volume attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean volume_set_ = false; + + /** + * The default value of the '{@link #getChange1() Change1}' attribute. + * + * + * @see #getChange1() + * @generated + * @ordered + */ + protected static final double CHANGE1_DEFAULT_ = 0.0; + + /** + * The cached value of the '{@link #getChange1() Change1}' attribute. + * + * + * @see #getChange1() + * @generated + * @ordered + */ + protected double change1 = CHANGE1_DEFAULT_; + + /** + * This is true if the Change1 attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean change1_set_ = false; + + /** + * The cached value of the '{@link #getQuotes() Quotes}' containment reference list. + * + * + * @see #getQuotes() + * @generated + * @ordered + */ + + protected List quotes = null; + + /** + * + * + * @generated + */ + public QuoteImpl() + { + super(); + } + + /** + * + * + * @generated + */ + public Type getStaticType() + { + return ((SimpleFactoryImpl)SimpleFactory.INSTANCE).getQuote(); + } + + /** + * + * + * @generated + */ + public String getSymbol() + { + return symbol; + } + /** + * + * + * @generated + */ + public void setSymbol(String newSymbol) + { + String oldSymbol = symbol; + symbol = newSymbol; + boolean oldSymbol_set_ = symbol_set_; + symbol_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, SYMBOL, oldSymbol, symbol, !oldSymbol_set_); + } + + /** + * + * + * @generated + */ + public void unsetSymbol() + { + String oldSymbol = symbol; + boolean oldSymbol_set_ = symbol_set_; + symbol = SYMBOL_DEFAULT_; + symbol_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, SYMBOL, oldSymbol, SYMBOL_DEFAULT_, oldSymbol_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetSymbol() + { + return symbol_set_; + } + + /** + * + * + * @generated + */ + public String getCompanyName() + { + return companyName; + } + /** + * + * + * @generated + */ + public void setCompanyName(String newCompanyName) + { + String oldCompanyName = companyName; + companyName = newCompanyName; + boolean oldCompanyName_set_ = companyName_set_; + companyName_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, COMPANY_NAME, oldCompanyName, companyName, !oldCompanyName_set_); + } + + /** + * + * + * @generated + */ + public void unsetCompanyName() + { + String oldCompanyName = companyName; + boolean oldCompanyName_set_ = companyName_set_; + companyName = COMPANY_NAME_DEFAULT_; + companyName_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, COMPANY_NAME, oldCompanyName, COMPANY_NAME_DEFAULT_, oldCompanyName_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetCompanyName() + { + return companyName_set_; + } + + /** + * + * + * @generated + */ + public BigDecimal getPrice() + { + return price; + } + /** + * + * + * @generated + */ + public void setPrice(BigDecimal newPrice) + { + BigDecimal oldPrice = price; + price = newPrice; + boolean oldPrice_set_ = price_set_; + price_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, PRICE, oldPrice, price, !oldPrice_set_); + } + + /** + * + * + * @generated + */ + public void unsetPrice() + { + BigDecimal oldPrice = price; + boolean oldPrice_set_ = price_set_; + price = PRICE_DEFAULT_; + price_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, PRICE, oldPrice, PRICE_DEFAULT_, oldPrice_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetPrice() + { + return price_set_; + } + + /** + * + * + * @generated + */ + public BigDecimal getOpen1() + { + return open1; + } + /** + * + * + * @generated + */ + public void setOpen1(BigDecimal newOpen1) + { + BigDecimal oldOpen1 = open1; + open1 = newOpen1; + boolean oldOpen1_set_ = open1_set_; + open1_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, OPEN1, oldOpen1, open1, !oldOpen1_set_); + } + + /** + * + * + * @generated + */ + public void unsetOpen1() + { + BigDecimal oldOpen1 = open1; + boolean oldOpen1_set_ = open1_set_; + open1 = OPEN1_DEFAULT_; + open1_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, OPEN1, oldOpen1, OPEN1_DEFAULT_, oldOpen1_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetOpen1() + { + return open1_set_; + } + + /** + * + * + * @generated + */ + public BigDecimal getHigh() + { + return high; + } + /** + * + * + * @generated + */ + public void setHigh(BigDecimal newHigh) + { + BigDecimal oldHigh = high; + high = newHigh; + boolean oldHigh_set_ = high_set_; + high_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, HIGH, oldHigh, high, !oldHigh_set_); + } + + /** + * + * + * @generated + */ + public void unsetHigh() + { + BigDecimal oldHigh = high; + boolean oldHigh_set_ = high_set_; + high = HIGH_DEFAULT_; + high_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, HIGH, oldHigh, HIGH_DEFAULT_, oldHigh_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetHigh() + { + return high_set_; + } + + /** + * + * + * @generated + */ + public BigDecimal getLow() + { + return low; + } + /** + * + * + * @generated + */ + public void setLow(BigDecimal newLow) + { + BigDecimal oldLow = low; + low = newLow; + boolean oldLow_set_ = low_set_; + low_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, LOW, oldLow, low, !oldLow_set_); + } + + /** + * + * + * @generated + */ + public void unsetLow() + { + BigDecimal oldLow = low; + boolean oldLow_set_ = low_set_; + low = LOW_DEFAULT_; + low_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, LOW, oldLow, LOW_DEFAULT_, oldLow_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetLow() + { + return low_set_; + } + + /** + * + * + * @generated + */ + public double getVolume() + { + return volume; + } + /** + * + * + * @generated + */ + public void setVolume(double newVolume) + { + double oldVolume = volume; + volume = newVolume; + boolean oldVolume_set_ = volume_set_; + volume_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, VOLUME, oldVolume, volume, !oldVolume_set_); + } + + /** + * + * + * @generated + */ + public void unsetVolume() + { + double oldVolume = volume; + boolean oldVolume_set_ = volume_set_; + volume = VOLUME_DEFAULT_; + volume_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, VOLUME, oldVolume, VOLUME_DEFAULT_, oldVolume_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetVolume() + { + return volume_set_; + } + + /** + * + * + * @generated + */ + public double getChange1() + { + return change1; + } + /** + * + * + * @generated + */ + public void setChange1(double newChange1) + { + double oldChange1 = change1; + change1 = newChange1; + boolean oldChange1_set_ = change1_set_; + change1_set_ = true; + if (isNotifying()) + notify(ChangeKind.SET, CHANGE1, oldChange1, change1, !oldChange1_set_); + } + + /** + * + * + * @generated + */ + public void unsetChange1() + { + double oldChange1 = change1; + boolean oldChange1_set_ = change1_set_; + change1 = CHANGE1_DEFAULT_; + change1_set_ = false; + if (isNotifying()) + notify(ChangeKind.UNSET, CHANGE1, oldChange1, CHANGE1_DEFAULT_, oldChange1_set_); + } + + /** + * + * + * @generated + */ + public boolean isSetChange1() + { + return change1_set_; + } + + /** + * + * + * @generated + */ + public List getQuotes() + { + if (quotes == null) + { + quotes = createPropertyList(ListKind.CONTAINMENT, Quote.class, QUOTES, 0); + } + return quotes; + } + /** + * + * + * @generated + */ + public ChangeContext inverseRemove(Object otherEnd, int propertyIndex, ChangeContext changeContext) + { + switch (propertyIndex) + { + case QUOTES: + return removeFromList(getQuotes(), otherEnd, changeContext); + } + return super.inverseRemove(otherEnd, propertyIndex, changeContext); + } + + /** + * + * + * @generated + */ + public Object get(int propertyIndex, boolean resolve) + { + switch (propertyIndex) + { + case SYMBOL: + return getSymbol(); + case COMPANY_NAME: + return getCompanyName(); + case PRICE: + return getPrice(); + case OPEN1: + return getOpen1(); + case HIGH: + return getHigh(); + case LOW: + return getLow(); + case VOLUME: + return new Double(getVolume()); + case CHANGE1: + return new Double(getChange1()); + case QUOTES: + return getQuotes(); + } + return super.get(propertyIndex, resolve); + } + + /** + * + * + * @generated + */ + public void set(int propertyIndex, Object newValue) + { + switch (propertyIndex) + { + case SYMBOL: + setSymbol((String)newValue); + return; + case COMPANY_NAME: + setCompanyName((String)newValue); + return; + case PRICE: + setPrice((BigDecimal)newValue); + return; + case OPEN1: + setOpen1((BigDecimal)newValue); + return; + case HIGH: + setHigh((BigDecimal)newValue); + return; + case LOW: + setLow((BigDecimal)newValue); + return; + case VOLUME: + setVolume(((Double)newValue).doubleValue()); + return; + case CHANGE1: + setChange1(((Double)newValue).doubleValue()); + return; + case QUOTES: + getQuotes().clear(); + getQuotes().addAll((Collection)newValue); + return; + } + super.set(propertyIndex, newValue); + } + + /** + * + * + * @generated + */ + public void unset(int propertyIndex) + { + switch (propertyIndex) + { + case SYMBOL: + unsetSymbol(); + return; + case COMPANY_NAME: + unsetCompanyName(); + return; + case PRICE: + unsetPrice(); + return; + case OPEN1: + unsetOpen1(); + return; + case HIGH: + unsetHigh(); + return; + case LOW: + unsetLow(); + return; + case VOLUME: + unsetVolume(); + return; + case CHANGE1: + unsetChange1(); + return; + case QUOTES: + getQuotes().clear(); + return; + } + super.unset(propertyIndex); + } + + /** + * + * + * @generated + */ + public boolean isSet(int propertyIndex) + { + switch (propertyIndex) + { + case SYMBOL: + return isSetSymbol(); + case COMPANY_NAME: + return isSetCompanyName(); + case PRICE: + return isSetPrice(); + case OPEN1: + return isSetOpen1(); + case HIGH: + return isSetHigh(); + case LOW: + return isSetLow(); + case VOLUME: + return isSetVolume(); + case CHANGE1: + return isSetChange1(); + case QUOTES: + return quotes != null && !quotes.isEmpty(); + } + return super.isSet(propertyIndex); + } + + /** + * + * + * @generated + */ + public String toString() + { + if (isProxy(this)) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (symbol: "); + if (symbol_set_) result.append(symbol); else result.append(""); + result.append(", companyName: "); + if (companyName_set_) result.append(companyName); else result.append(""); + result.append(", price: "); + if (price_set_) result.append(price); else result.append(""); + result.append(", open1: "); + if (open1_set_) result.append(open1); else result.append(""); + result.append(", high: "); + if (high_set_) result.append(high); else result.append(""); + result.append(", low: "); + if (low_set_) result.append(low); else result.append(""); + result.append(", volume: "); + if (volume_set_) result.append(volume); else result.append(""); + result.append(", change1: "); + if (change1_set_) result.append(change1); else result.append(""); + result.append(')'); + return result.toString(); + } + +} //QuoteImpl diff --git a/sandbox/kgoodson/events/impl/src/test/java/com/example/simple/impl/SimpleFactoryImpl.java b/sandbox/kgoodson/events/impl/src/test/java/com/example/simple/impl/SimpleFactoryImpl.java new file mode 100644 index 0000000000..51099d70a7 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/com/example/simple/impl/SimpleFactoryImpl.java @@ -0,0 +1,330 @@ +/** + * + * 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 commonj.sdo.helper.HelperContext; +import org.apache.tuscany.sdo.helper.TypeHelperImpl; + +import com.example.simple.*; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; + +import org.apache.tuscany.sdo.SDOFactory; + +import org.apache.tuscany.sdo.impl.FactoryBase; + +import org.apache.tuscany.sdo.model.ModelFactory; + +import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl; + +import org.apache.tuscany.sdo.model.internal.InternalFactory; + +import org.apache.tuscany.sdo.util.SDOUtil; + +/** + * + * An implementation of the model Factory. + * Generator information: + * patternVersion=1.2; + * + * @generated + */ +public class SimpleFactoryImpl extends FactoryBase implements SimpleFactory +{ + + /** + * The package namespace URI. + * + * + * @generated + */ + public static final String NAMESPACE_URI = "http://www.example.com/simple"; + + /** + * The package namespace name. + * + * + * @generated + */ + public static final String NAMESPACE_PREFIX = "simple"; + + /** + * The version of the generator pattern used to generate this class. + * + * + * @generated + */ + public static final String PATTERN_VERSION = "1.2"; + + public static final int QUOTE = 1; + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public SimpleFactoryImpl() + { + super(NAMESPACE_URI, NAMESPACE_PREFIX, "com.example.simple"); + } + + /** + * Registers the Factory instance so that it is available within the supplied scope. + * @argument scope a HelperContext instance that will make the types supported by this Factory available. + * + * + * @generated + */ + public void register(HelperContext scope) { + if(scope == null) { + throw new IllegalArgumentException("Scope can not be null"); + } + TypeHelperImpl th = (TypeHelperImpl)scope.getTypeHelper(); + th.getExtendedMetaData().putPackage(NAMESPACE_URI, this); + } + + /** + * + * + * @generated + */ + public DataObject create(int typeNumber) + { + switch (typeNumber) + { + case QUOTE: return (DataObject)createQuote(); + default: + return super.create(typeNumber); + } + } + + /** + * + * + * @generated + */ + public Quote createQuote() + { + QuoteImpl quote = new QuoteImpl(); + return quote; + } + + // Following creates and initializes SDO metadata for the supported types. + protected Type quoteType = null; + + public Type getQuote() + { + return quoteType; + } + + + private static boolean isInited = false; + + public static SimpleFactoryImpl init() + { + if (isInited) return (SimpleFactoryImpl)FactoryBase.getStaticFactory(SimpleFactoryImpl.NAMESPACE_URI); + SimpleFactoryImpl theSimpleFactoryImpl = new SimpleFactoryImpl(); + isInited = true; + + // Initialize dependencies + SDOUtil.registerStaticTypes(SDOFactory.class); + SDOUtil.registerStaticTypes(ModelFactory.class); + SDOUtil.registerStaticTypes(InternalFactory.class); + + // Create package meta-data objects + theSimpleFactoryImpl.createMetaData(); + + // Initialize created meta-data + theSimpleFactoryImpl.initializeMetaData(); + + // Mark meta-data to indicate it can't be changed + //theSimpleFactoryImpl.freeze(); //FB do we need to freeze / should we freeze ???? + + return theSimpleFactoryImpl; + } + + private boolean isCreated = false; + + public void createMetaData() + { + if (isCreated) return; + isCreated = true; + + // Create types and their properties + quoteType = createType(false, QUOTE); + createProperty(true, quoteType,QuoteImpl.INTERNAL_SYMBOL); + createProperty(true, quoteType,QuoteImpl.INTERNAL_COMPANY_NAME); + createProperty(true, quoteType,QuoteImpl.INTERNAL_PRICE); + createProperty(true, quoteType,QuoteImpl.INTERNAL_OPEN1); + createProperty(true, quoteType,QuoteImpl.INTERNAL_HIGH); + createProperty(true, quoteType,QuoteImpl.INTERNAL_LOW); + createProperty(true, quoteType,QuoteImpl.INTERNAL_VOLUME); + createProperty(true, quoteType,QuoteImpl.INTERNAL_CHANGE1); + createProperty(false, quoteType,QuoteImpl.INTERNAL_QUOTES); + } + + private boolean isInitialized = false; + + public void initializeMetaData() + { + if (isInitialized) return; + isInitialized = true; + + // Obtain other dependent packages + ModelFactoryImpl theModelPackageImpl = (ModelFactoryImpl)FactoryBase.getStaticFactory(ModelFactoryImpl.NAMESPACE_URI); + Property property = null; + + // Add supertypes to types + + // Initialize types and properties + initializeType(quoteType, Quote.class, "Quote", false); + property = getLocalProperty(quoteType, 0); + initializeProperty(property, theModelPackageImpl.getString(), "symbol", null, 1, 1, Quote.class, false, true, false); + + property = getLocalProperty(quoteType, 1); + initializeProperty(property, theModelPackageImpl.getString(), "companyName", null, 1, 1, Quote.class, false, true, false); + + property = getLocalProperty(quoteType, 2); + initializeProperty(property, theModelPackageImpl.getDecimal(), "price", null, 1, 1, Quote.class, false, true, false); + + property = getLocalProperty(quoteType, 3); + initializeProperty(property, theModelPackageImpl.getDecimal(), "open1", null, 1, 1, Quote.class, false, true, false); + + property = getLocalProperty(quoteType, 4); + initializeProperty(property, theModelPackageImpl.getDecimal(), "high", null, 1, 1, Quote.class, false, true, false); + + property = getLocalProperty(quoteType, 5); + initializeProperty(property, theModelPackageImpl.getDecimal(), "low", null, 1, 1, Quote.class, false, true, false); + + property = getLocalProperty(quoteType, 6); + initializeProperty(property, theModelPackageImpl.getDouble(), "volume", null, 1, 1, Quote.class, false, true, false); + + property = getLocalProperty(quoteType, 7); + initializeProperty(property, theModelPackageImpl.getDouble(), "change1", null, 1, 1, Quote.class, false, true, false); + + property = getLocalProperty(quoteType, 8); + initializeProperty(property, this.getQuote(), "quotes", null, 0, -1, Quote.class, false, false, false, true , null); + + createXSDMetaData(theModelPackageImpl); + } + + protected void createXSDMetaData(ModelFactoryImpl theModelPackageImpl) + { + super.initXSD(); + + Property property = null; + + + property = createGlobalProperty + ("stockQuote", + this.getQuote(), + new String[] + { + "kind", "element", + "name", "stockQuote", + "namespace", "##targetNamespace" + }); + + addXSDMapping + (quoteType, + new String[] + { + "name", "Quote", + "kind", "elementOnly" + }); + + addXSDMapping + (getProperty(quoteType, QuoteImpl.INTERNAL_SYMBOL), + new String[] + { + "kind", "element", + "name", "symbol" + }); + + addXSDMapping + (getProperty(quoteType, QuoteImpl.INTERNAL_COMPANY_NAME), + new String[] + { + "kind", "element", + "name", "companyName" + }); + + addXSDMapping + (getProperty(quoteType, QuoteImpl.INTERNAL_PRICE), + new String[] + { + "kind", "element", + "name", "price" + }); + + addXSDMapping + (getProperty(quoteType, QuoteImpl.INTERNAL_OPEN1), + new String[] + { + "kind", "element", + "name", "open1" + }); + + addXSDMapping + (getProperty(quoteType, QuoteImpl.INTERNAL_HIGH), + new String[] + { + "kind", "element", + "name", "high" + }); + + addXSDMapping + (getProperty(quoteType, QuoteImpl.INTERNAL_LOW), + new String[] + { + "kind", "element", + "name", "low" + }); + + addXSDMapping + (getProperty(quoteType, QuoteImpl.INTERNAL_VOLUME), + new String[] + { + "kind", "element", + "name", "volume" + }); + + addXSDMapping + (getProperty(quoteType, QuoteImpl.INTERNAL_CHANGE1), + new String[] + { + "kind", "element", + "name", "change1" + }); + + addXSDMapping + (getProperty(quoteType, QuoteImpl.INTERNAL_QUOTES), + new String[] + { + "kind", "element", + "name", "quotes" + }); + + } + +} //SimpleFactoryImpl diff --git a/sandbox/kgoodson/events/impl/src/test/java/com/example/test/Containment/ContainmentFactory.java b/sandbox/kgoodson/events/impl/src/test/java/com/example/test/Containment/ContainmentFactory.java new file mode 100644 index 0000000000..c8ee9a96c8 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/com/example/test/Containment/ContainmentFactory.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 com.example.test.Containment; + +import commonj.sdo.helper.HelperContext; + + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @generated + */ +public interface ContainmentFactory +{ + + /** + * The singleton instance of the factory. + * + * + * @generated + */ + ContainmentFactory INSTANCE = com.example.test.Containment.impl.ContainmentFactoryImpl.init(); + + /** + * Returns a new object of class 'Test'. + * + * + * @return a new object of class 'Test'. + * @generated + */ + ContainmentTest createContainmentTest(); + + /** + * Registers the types supported by this Factory within the supplied scope.argument + * + * + * @param scope an instance of HelperContext used to manage the scoping of types. + * @generated + */ + public void register(HelperContext scope); + +} //ContainmentFactory diff --git a/sandbox/kgoodson/events/impl/src/test/java/com/example/test/Containment/ContainmentTest.java b/sandbox/kgoodson/events/impl/src/test/java/com/example/test/Containment/ContainmentTest.java new file mode 100644 index 0000000000..64734b8862 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/com/example/test/Containment/ContainmentTest.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 com.example.test.Containment; + +import commonj.sdo.Sequence; + +import java.io.Serializable; + +import java.util.List; + +/** + * + * A representation of the model object 'Test'. + * + * + *

      + * The following features are supported: + *

        + *
      • {@link com.example.test.Containment.ContainmentTest#getMixed Mixed}
      • + *
      • {@link com.example.test.Containment.ContainmentTest#getName Name}
      • + *
      • {@link com.example.test.Containment.ContainmentTest#getContain Contain}
      • + *
      • {@link com.example.test.Containment.ContainmentTest#getContainMany Contain Many}
      • + *
      + *

      + * + * @extends Serializable + * @generated + */ +public interface ContainmentTest extends Serializable +{ + /** + * Returns the value of the 'Mixed' attribute list. + * + *

      + * If the meaning of the 'Mixed' attribute list isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Mixed' attribute list. + * @generated + */ + Sequence getMixed(); + + /** + * Returns the value of the 'Name' attribute. + * + *

      + * If the meaning of the 'Name' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Name' attribute. + * @see #isSetName() + * @see #unsetName() + * @see #setName(String) + * @generated + */ + String getName(); + + /** + * Sets the value of the '{@link com.example.test.Containment.ContainmentTest#getName Name}' attribute. + * + * + * @param value the new value of the 'Name' attribute. + * @see #isSetName() + * @see #unsetName() + * @see #getName() + * @generated + */ + void setName(String value); + + /** + * Unsets the value of the '{@link com.example.test.Containment.ContainmentTest#getName Name}' attribute. + * + * + * @see #isSetName() + * @see #getName() + * @see #setName(String) + * @generated + */ + void unsetName(); + + /** + * Returns whether the value of the '{@link com.example.test.Containment.ContainmentTest#getName Name}' attribute is set. + * + * + * @return whether the value of the 'Name' attribute is set. + * @see #unsetName() + * @see #getName() + * @see #setName(String) + * @generated + */ + boolean isSetName(); + + /** + * Returns the value of the 'Contain' containment reference. + * + *

      + * If the meaning of the 'Contain' containment reference isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Contain' containment reference. + * @see #isSetContain() + * @see #unsetContain() + * @see #setContain(ContainmentTest) + * @generated + */ + ContainmentTest getContain(); + + /** + * Sets the value of the '{@link com.example.test.Containment.ContainmentTest#getContain Contain}' containment reference. + * + * + * @param value the new value of the 'Contain' containment reference. + * @see #isSetContain() + * @see #unsetContain() + * @see #getContain() + * @generated + */ + void setContain(ContainmentTest value); + + /** + * Unsets the value of the '{@link com.example.test.Containment.ContainmentTest#getContain Contain}' containment reference. + * + * + * @see #isSetContain() + * @see #getContain() + * @see #setContain(ContainmentTest) + * @generated + */ + void unsetContain(); + + /** + * Returns whether the value of the '{@link com.example.test.Containment.ContainmentTest#getContain Contain}' containment reference is set. + * + * + * @return whether the value of the 'Contain' containment reference is set. + * @see #unsetContain() + * @see #getContain() + * @see #setContain(ContainmentTest) + * @generated + */ + boolean isSetContain(); + + /** + * Returns the value of the 'Contain Many' containment reference list. + * The list contents are of type {@link com.example.test.Containment.ContainmentTest}. + * + *

      + * If the meaning of the 'Contain Many' containment reference list isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Contain Many' containment reference list. + * @generated + */ + List getContainMany(); + +} // ContainmentTest diff --git a/sandbox/kgoodson/events/impl/src/test/java/com/example/test/Containment/impl/ContainmentFactoryImpl.java b/sandbox/kgoodson/events/impl/src/test/java/com/example/test/Containment/impl/ContainmentFactoryImpl.java new file mode 100644 index 0000000000..9f51d02590 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/com/example/test/Containment/impl/ContainmentFactoryImpl.java @@ -0,0 +1,270 @@ +/** + * + * 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.test.Containment.impl; + +import commonj.sdo.helper.HelperContext; +import org.apache.tuscany.sdo.helper.TypeHelperImpl; + +import com.example.test.Containment.*; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; + +import org.apache.tuscany.sdo.SDOFactory; + +import org.apache.tuscany.sdo.impl.FactoryBase; + +import org.apache.tuscany.sdo.model.ModelFactory; + +import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl; + +import org.apache.tuscany.sdo.model.internal.InternalFactory; + +import org.apache.tuscany.sdo.util.SDOUtil; + +/** + * + * An implementation of the model Factory. + * Generator information: + * patternVersion=1.2; -prefix Containment + * + * @generated + */ +public class ContainmentFactoryImpl extends FactoryBase implements ContainmentFactory +{ + + /** + * The package namespace URI. + * + * + * @generated + */ + public static final String NAMESPACE_URI = "http://www.example.com/ContainmentTest"; + + /** + * The package namespace name. + * + * + * @generated + */ + public static final String NAMESPACE_PREFIX = "contain"; + + /** + * The version of the generator pattern used to generate this class. + * + * + * @generated + */ + public static final String PATTERN_VERSION = "1.2"; + + public static final int CONTAINMENT_TEST = 1; + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public ContainmentFactoryImpl() + { + super(NAMESPACE_URI, NAMESPACE_PREFIX, "com.example.test.Containment"); + } + + /** + * Registers the Factory instance so that it is available within the supplied scope. + * @argument scope a HelperContext instance that will make the types supported by this Factory available. + * + * + * @generated + */ + public void register(HelperContext scope) { + if(scope == null) { + throw new IllegalArgumentException("Scope can not be null"); + } + TypeHelperImpl th = (TypeHelperImpl)scope.getTypeHelper(); + th.getExtendedMetaData().putPackage(NAMESPACE_URI, this); + } + + /** + * + * + * @generated + */ + public DataObject create(int typeNumber) + { + switch (typeNumber) + { + case CONTAINMENT_TEST: return (DataObject)createContainmentTest(); + default: + return super.create(typeNumber); + } + } + + /** + * + * + * @generated + */ + public ContainmentTest createContainmentTest() + { + ContainmentTestImpl containmentTest = new ContainmentTestImpl(); + return containmentTest; + } + + // Following creates and initializes SDO metadata for the supported types. + protected Type containmentTestType = null; + + public Type getContainmentTest() + { + return containmentTestType; + } + + + private static boolean isInited = false; + + public static ContainmentFactoryImpl init() + { + if (isInited) return (ContainmentFactoryImpl)FactoryBase.getStaticFactory(ContainmentFactoryImpl.NAMESPACE_URI); + ContainmentFactoryImpl theContainmentFactoryImpl = new ContainmentFactoryImpl(); + isInited = true; + + // Initialize dependencies + SDOUtil.registerStaticTypes(SDOFactory.class); + SDOUtil.registerStaticTypes(ModelFactory.class); + SDOUtil.registerStaticTypes(InternalFactory.class); + + // Create package meta-data objects + theContainmentFactoryImpl.createMetaData(); + + // Initialize created meta-data + theContainmentFactoryImpl.initializeMetaData(); + + // Mark meta-data to indicate it can't be changed + //theContainmentFactoryImpl.freeze(); //FB do we need to freeze / should we freeze ???? + + return theContainmentFactoryImpl; + } + + private boolean isCreated = false; + + public void createMetaData() + { + if (isCreated) return; + isCreated = true; + + // Create types and their properties + containmentTestType = createType(false, CONTAINMENT_TEST); + createProperty(true, containmentTestType,ContainmentTestImpl.INTERNAL_MIXED); + createProperty(true, containmentTestType,ContainmentTestImpl.INTERNAL_NAME); + createProperty(false, containmentTestType,ContainmentTestImpl.INTERNAL_CONTAIN); + createProperty(false, containmentTestType,ContainmentTestImpl.INTERNAL_CONTAIN_MANY); + } + + private boolean isInitialized = false; + + public void initializeMetaData() + { + if (isInitialized) return; + isInitialized = true; + + // Obtain other dependent packages + ModelFactoryImpl theModelPackageImpl = (ModelFactoryImpl)FactoryBase.getStaticFactory(ModelFactoryImpl.NAMESPACE_URI); + Property property = null; + + // Add supertypes to types + + // Initialize types and properties + initializeType(containmentTestType, ContainmentTest.class, "ContainmentTest", false); + property = getLocalProperty(containmentTestType, 0); + initializeProperty(property, getSequence(), "mixed", null, 0, -1, ContainmentTest.class, false, false, false); + + property = getLocalProperty(containmentTestType, 1); + initializeProperty(property, theModelPackageImpl.getString(), "Name", null, 1, 1, ContainmentTest.class, false, true, true); + + property = getLocalProperty(containmentTestType, 2); + initializeProperty(property, this.getContainmentTest(), "Contain", null, 1, 1, ContainmentTest.class, false, true, true, true , null); + + property = getLocalProperty(containmentTestType, 3); + initializeProperty(property, this.getContainmentTest(), "ContainMany", null, 0, -1, ContainmentTest.class, false, false, true, true , null); + + createXSDMetaData(theModelPackageImpl); + } + + protected void createXSDMetaData(ModelFactoryImpl theModelPackageImpl) + { + super.initXSD(); + + Property property = null; + + + addXSDMapping + (containmentTestType, + new String[] + { + "name", "ContainmentTest", + "kind", "mixed" + }); + + addXSDMapping + (getProperty(containmentTestType, ContainmentTestImpl.INTERNAL_MIXED), + new String[] + { + "kind", "elementWildcard", + "name", ":mixed" + }); + + addXSDMapping + (getProperty(containmentTestType, ContainmentTestImpl.INTERNAL_NAME), + new String[] + { + "kind", "element", + "name", "Name" + }); + + addXSDMapping + (getProperty(containmentTestType, ContainmentTestImpl.INTERNAL_CONTAIN), + new String[] + { + "kind", "element", + "name", "Contain" + }); + + addXSDMapping + (getProperty(containmentTestType, ContainmentTestImpl.INTERNAL_CONTAIN_MANY), + new String[] + { + "kind", "element", + "name", "ContainMany" + }); + + property = createGlobalProperty + ("containTestInstance", + this.getContainmentTest(), + new String[] + { + "kind", "element", + "name", "containTestInstance", + "namespace", "##targetNamespace" + }); + + } + +} //ContainmentFactoryImpl diff --git a/sandbox/kgoodson/events/impl/src/test/java/com/example/test/Containment/impl/ContainmentTestImpl.java b/sandbox/kgoodson/events/impl/src/test/java/com/example/test/Containment/impl/ContainmentTestImpl.java new file mode 100644 index 0000000000..14d4678d2d --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/com/example/test/Containment/impl/ContainmentTestImpl.java @@ -0,0 +1,409 @@ +/** + * + * 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.test.Containment.impl; + +import com.example.test.Containment.ContainmentFactory; +import com.example.test.Containment.ContainmentTest; + +import commonj.sdo.Sequence; +import commonj.sdo.Type; + +import java.util.Collection; +import java.util.List; + +import org.apache.tuscany.sdo.impl.DataObjectBase; + +/** + * + * An implementation of the model object 'Test'. + * + *

      + * The following features are implemented: + *

        + *
      • {@link com.example.test.Containment.impl.ContainmentTestImpl#getMixed Mixed}
      • + *
      • {@link com.example.test.Containment.impl.ContainmentTestImpl#getName Name}
      • + *
      • {@link com.example.test.Containment.impl.ContainmentTestImpl#getContain Contain}
      • + *
      • {@link com.example.test.Containment.impl.ContainmentTestImpl#getContainMany Contain Many}
      • + *
      + *

      + * + * @generated + */ +public class ContainmentTestImpl extends DataObjectBase implements ContainmentTest +{ + + public final static int MIXED = -1; + + public final static int NAME = 0; + + public final static int CONTAIN = 1; + + public final static int CONTAIN_MANY = 2; + + public final static int SDO_PROPERTY_COUNT = 3; + + public final static int EXTENDED_PROPERTY_COUNT = -1; + + + /** + * The internal feature id for the 'Mixed' attribute list. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_MIXED = 0; + + /** + * The internal feature id for the 'Name' attribute. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_NAME = 1; + + /** + * The internal feature id for the 'Contain' containment reference. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_CONTAIN = 2; + + /** + * The internal feature id for the 'Contain Many' containment reference list. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_CONTAIN_MANY = 3; + + /** + * The number of properties for this type. + * + * + * @generated + * @ordered + */ + public final static int INTERNAL_PROPERTY_COUNT = 4; + + protected int internalConvertIndex(int internalIndex) + { + switch (internalIndex) + { + case INTERNAL_MIXED: return MIXED; + case INTERNAL_NAME: return NAME; + case INTERNAL_CONTAIN: return CONTAIN; + case INTERNAL_CONTAIN_MANY: return CONTAIN_MANY; + } + return super.internalConvertIndex(internalIndex); + } + + + /** + * The cached value of the '{@link #getMixed() Mixed}' attribute list. + * + * + * @see #getMixed() + * @generated + * @ordered + */ + + protected Sequence mixed = null; + + /** + * + * + * @generated + */ + public ContainmentTestImpl() + { + super(); + } + + /** + * + * + * @generated + */ + public Type getStaticType() + { + return ((ContainmentFactoryImpl)ContainmentFactory.INSTANCE).getContainmentTest(); + } + + /** + * + * + * @generated + */ + public Sequence getMixed() + { + if (mixed == null) + { + mixed = createSequence(INTERNAL_MIXED); + } + return mixed; + } + /** + * + * + * @generated + */ + public String getName() + { + return (String)get(getMixed(), getType(), INTERNAL_NAME); + } + /** + * + * + * @generated + */ + public void setName(String newName) + { + set(getMixed(), getType(), INTERNAL_NAME, newName); + } + + /** + * + * + * @generated + */ + public void unsetName() + { + unset(getMixed(), getType(), INTERNAL_NAME); + } + + /** + * + * + * @generated + */ + public boolean isSetName() + { + return isSet(getMixed(), getType(), INTERNAL_NAME); + } + + /** + * + * + * @generated + */ + public ContainmentTest getContain() + { + return (ContainmentTest)get(getMixed(), getType(), INTERNAL_CONTAIN); + } + /** + * + * + * @generated + */ + public ChangeContext basicSetContain(ContainmentTest newContain, ChangeContext changeContext) + { + return basicAdd(getMixed(), getType(), INTERNAL_CONTAIN, newContain, changeContext); + } + + /** + * + * + * @generated + */ + public void setContain(ContainmentTest newContain) + { + set(getMixed(), getType(), INTERNAL_CONTAIN, newContain); + } + + /** + * + * + * @generated + */ + public ChangeContext basicUnsetContain(ChangeContext changeContext) + { + // TODO: implement this method to unset the contained 'Contain' containment reference + // -> this method is automatically invoked to keep the containment relationship in synch + // -> do not modify other features + // -> return changeContext, after adding any generated Notification to it (if it is null, a NotificationChain object must be created first) + // Ensure that you remove @generated or mark it @generated NOT + throw new UnsupportedOperationException(); + } + + /** + * + * + * @generated + */ + public void unsetContain() + { + unset(getMixed(), getType(), INTERNAL_CONTAIN); + } + + /** + * + * + * @generated + */ + public boolean isSetContain() + { + return isSet(getMixed(), getType(), INTERNAL_CONTAIN); + } + + /** + * + * + * @generated + */ + public List getContainMany() + { + return getList(getMixed(), getType(), INTERNAL_CONTAIN_MANY); + } + /** + * + * + * @generated + */ + public ChangeContext inverseRemove(Object otherEnd, int propertyIndex, ChangeContext changeContext) + { + switch (propertyIndex) + { + case MIXED: + return removeFromSequence(getMixed(), otherEnd, changeContext); + case CONTAIN: + return basicUnsetContain(changeContext); + case CONTAIN_MANY: + return removeFromList(getContainMany(), otherEnd, changeContext); + } + return super.inverseRemove(otherEnd, propertyIndex, changeContext); + } + + /** + * + * + * @generated + */ + public Object get(int propertyIndex, boolean resolve) + { + switch (propertyIndex) + { + case MIXED: + // XXX query introduce coreType as an argument? -- semantic = if true -- coreType - return the core EMF object if value is a non-EMF wrapper/view + //if (coreType) + return getMixed(); + case NAME: + return getName(); + case CONTAIN: + return getContain(); + case CONTAIN_MANY: + return getContainMany(); + } + return super.get(propertyIndex, resolve); + } + + /** + * + * + * @generated + */ + public void set(int propertyIndex, Object newValue) + { + switch (propertyIndex) + { + case MIXED: + setSequence(getMixed(), newValue); + return; + case NAME: + setName((String)newValue); + return; + case CONTAIN: + setContain((ContainmentTest)newValue); + return; + case CONTAIN_MANY: + getContainMany().clear(); + getContainMany().addAll((Collection)newValue); + return; + } + super.set(propertyIndex, newValue); + } + + /** + * + * + * @generated + */ + public void unset(int propertyIndex) + { + switch (propertyIndex) + { + case MIXED: + unsetSequence(getMixed()); + return; + case NAME: + unsetName(); + return; + case CONTAIN: + unsetContain(); + return; + case CONTAIN_MANY: + getContainMany().clear(); + return; + } + super.unset(propertyIndex); + } + + /** + * + * + * @generated + */ + public boolean isSet(int propertyIndex) + { + switch (propertyIndex) + { + case MIXED: + return mixed != null && !isSequenceEmpty(getMixed()); + case NAME: + return isSetName(); + case CONTAIN: + return isSetContain(); + case CONTAIN_MANY: + return !getContainMany().isEmpty(); + } + return super.isSet(propertyIndex); + } + + /** + * + * + * @generated + */ + public String toString() + { + if (isProxy(this)) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (mixed: "); + result.append(mixed); + result.append(')'); + return result.toString(); + } + +} //ContainmentTestImpl diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/AllTests.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/AllTests.java new file mode 100644 index 0000000000..7d91456137 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/AllTests.java @@ -0,0 +1,41 @@ +/** + * + * 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 junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTests { + + public static Test suite() { + + TestSuite suite = new TestSuite(); + + suite.addTest(org.apache.tuscany.sdo.codegen.AllTests.suite()); + suite.addTest(org.apache.tuscany.sdo.test.AllTests.suite()); + + return suite; + } + + + public static void main(String[] args) { + junit.textui.TestRunner.run(suite()); + } +} + diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/AllTests.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/AllTests.java new file mode 100644 index 0000000000..d67b53fb7c --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/AllTests.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.codegen; +import junit.framework.Test; +import junit.framework.TestSuite; + +public class AllTests { + + + public static TestSuite suite() { + + TestSuite suite = new TestSuite(); + + suite.addTestSuite(BytecodeInterfaceGeneratorTestCase.class); + suite.addTestSuite(JavaInterfaceGeneratorTestCase.class); + + + return suite; + } + + + /** + * Runs the test suite using the textual runner. + */ + public static void main(String[] args) { + junit.textui.TestRunner.run(suite()); + } +} + diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar1.java new file mode 100644 index 0000000000..4a51310cd0 --- /dev/null +++ b/sandbox/kgoodson/events/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/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/Bar2.java new file mode 100644 index 0000000000..e9151b9d46 --- /dev/null +++ b/sandbox/kgoodson/events/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/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/BytecodeInterfaceGeneratorTestCase.java new file mode 100644 index 0000000000..218a725226 --- /dev/null +++ b/sandbox/kgoodson/events/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/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/Foo.java new file mode 100644 index 0000000000..56bf6af9b4 --- /dev/null +++ b/sandbox/kgoodson/events/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/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/JavaInterfaceGeneratorTestCase.java new file mode 100644 index 0000000000..6cc0529c5f --- /dev/null +++ b/sandbox/kgoodson/events/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/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java new file mode 100644 index 0000000000..3e3e87e47b --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockProperty.java @@ -0,0 +1,94 @@ +/** + * + * 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(); + } + + public boolean isNullable() { + throw new UnsupportedOperationException(); + } + + public boolean isOpenContent() { + throw new UnsupportedOperationException(); + } + + public List getInstanceProperties() { + throw new UnsupportedOperationException(); + } + + public Object get(Property property) { + throw new UnsupportedOperationException(); + } +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java new file mode 100644 index 0000000000..ec848de4fa --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/codegen/MockType.java @@ -0,0 +1,104 @@ +/** + * + * 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(); + } + + public List getInstanceProperties() { + throw new UnsupportedOperationException(); + } + + public Object get(Property property) { + throw new UnsupportedOperationException(); + } +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/AllTests.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/AllTests.java new file mode 100644 index 0000000000..79fed495de --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/AllTests.java @@ -0,0 +1,84 @@ + +/** + * + * 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 junit.framework.TestSuite; + +public class AllTests extends TestCase { + + + public static TestSuite suite() { + + TestSuite suite = new TestSuite(); + + suite.addTestSuite(ChangeSummaryOnDataObjectTestCase.class); + suite.addTestSuite(ChangeSummaryPropertyTestCase.class); + suite.addTestSuite(ChangeSummaryTestCase.class); + suite.addTestSuite(ContainmentCycleTestCase.class); + suite.addTestSuite(CrossScopeCopyTestCase.class); + suite.addTestSuite(DataGraphTestCase.class); + suite.addTestSuite(DataTypeBaseTypeTestCase.class); + suite.addTestSuite(DateConversionTestCase.class); + suite.addTestSuite(DefineOpenContentPropertyTestCase.class); + suite.addTestSuite(DefineTypeTestCase.class); + suite.addTestSuite(FormTestCase.class); + suite.addTestSuite(HelperContextTestCase.class); + suite.addTestSuite(IsManyTestCase.class); + suite.addTestSuite(JavaSerializeDeserializeTestCase.class); + suite.addTestSuite(MixedTypeTestCase.class); + suite.addTestSuite(NeverStaleChangeSummaryTestCase.class); + suite.addTestSuite(OpenTypeTestCase.class); + suite.addTestSuite(SchemaLocationTestCase.class); + suite.addTestSuite(SerializeTypesTestCase.class); + suite.addTestSuite(SimpleCopyTestCase.class); + suite.addTestSuite(SimpleDynamicTestCase.class); + suite.addTestSuite(SimpleEqualityTestCase.class); + suite.addTestSuite(SubstitutionValuesTestCase.class); + suite.addTestSuite(TypeConversionTestCase.class); + suite.addTestSuite(TypeRoundTripTestCase.class); + suite.addTestSuite(XMLDocumentTestCase.class); + suite.addTestSuite(XMLHelperTestCase.class); + suite.addTestSuite(XMLStreamHelperTestCase.class); + suite.addTestSuite(XPathTestCase.class); + suite.addTestSuite(XSDHelperTestCase.class); + suite.addTestSuite(XSDQNameTestCase.class); + suite.addTestSuite(XMLLoadOptionsTestCase.class); + suite.addTestSuite(XMLSaveOptionsTestCase.class); + suite.addTestSuite(XMLUnknownPropertiesTestCase.class); + suite.addTestSuite(ExpectedExceptionsTestCase.class); + suite.addTestSuite(TypeHelperTestCase.class); + return suite; + } + + + + /** + * Runs the test suite using the textual runner. + */ + public static void main(String[] args) { + junit.textui.TestRunner.run(suite()); + } +} + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/AnyTypeTest.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/AnyTypeTest.java new file mode 100644 index 0000000000..4d085eae28 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/AnyTypeTest.java @@ -0,0 +1,112 @@ +/** + * + * 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.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.api.XMLStreamHelper; +import org.apache.tuscany.sdo.api.SDOUtil; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.HelperContext; +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 { + final Property property = typeHelper.getOpenContentProperty(TEST_NAMESPACE, "globalElement"); + final 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 + final XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); + final StringWriter writer = new StringWriter(); + final XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(writer); + streamHelper.saveObject(rootObject, streamWriter); + streamWriter.flush(); + // System.out.println(writer.toString()); + + final XMLInputFactory inputFactory = XMLInputFactory.newInstance(); + final StringReader reader = new StringReader(writer.toString()); + final XMLStreamReader streamReader = inputFactory.createXMLStreamReader(reader); + final 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); + } + + public void testAbstractTypeFails() { + try { + final DataObject abstractObj = dataFactory.create("commonj.sdo","DataObject"); + assertTrue("Should not succeed", false); + } + catch ( final IllegalArgumentException e) { + // expected result + } + } + + protected void setUp() throws Exception { + final HelperContext hc = SDOUtil.createHelperContext(); + typeHelper = hc.getTypeHelper(); + dataFactory = hc.getDataFactory(); + xsdHelper = hc.getXSDHelper(); + streamHelper = SDOUtil.createXMLStreamHelper(hc); + + // Populate the meta data for the test (Stock Quote) model + final URL url = getClass().getResource(TEST_MODEL); + final InputStream inputStream = url.openStream(); + xsdHelper.define(inputStream, url.toString()); + inputStream.close(); + } + +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryOnDataObjectTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryOnDataObjectTestCase.java new file mode 100644 index 0000000000..b9b9c0f2ea --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryOnDataObjectTestCase.java @@ -0,0 +1,216 @@ +/** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.tuscany.sdo.test; + + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.InputStream; +import java.math.BigDecimal; +import java.net.URL; +import java.util.List; + +import junit.framework.TestCase; + +import org.apache.tuscany.sdo.api.SDOUtil; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XSDHelper; + + +public class ChangeSummaryOnDataObjectTestCase extends TestCase { + + + private final String TEST_DATA = "/simplechangesummary.xml"; + HelperContext hc; + XSDHelper xh; + TypeHelper th; + + public void testBasicsDO() { + Type cst = th.getType("commonj.sdo","ChangeSummaryType"); + Type strt = th.getType("commonj.sdo", "String"); + + Type newt = SDOUtil.createType(hc, "testcases.changesummary", "simpleCS", false); + Property strProp = SDOUtil.createProperty(newt, "strElem", strt); + SDOUtil.createProperty(newt, "changeSummary", cst); + + DataObject iNewt = hc.getDataFactory().create(newt); + + testBasicsBody(strProp, iNewt); +} + + public void testBasicsDG() { + + Type strt = th.getType("commonj.sdo", "String"); + + + Type newt = SDOUtil.createType(hc, "testcases.changesummary", "simpleNOCS", false); + Property strProp = SDOUtil.createProperty(newt, "strElem", strt); + + DataGraph graph = SDOUtil.createDataGraph(); + DataObject iNewt = graph.createRootObject(newt); + + testBasicsBody(strProp, iNewt); +} + + + /** + * @param strProp + * @param iNewt + */ + private void testBasicsBody(Property strProp, DataObject iNewt) { + ChangeSummary cs = iNewt.getChangeSummary(); + cs.beginLogging(); + + List co = cs.getChangedDataObjects(); + assertEquals(0, co.size()); + iNewt.set(strProp, "some text"); + assertEquals(0, co.size()); + co = cs.getChangedDataObjects(); + assertEquals(1, co.size()); + + List oldValues = cs.getOldValues((DataObject)co.get(0)); + + ChangeSummary.Setting ov1 = (ChangeSummary.Setting)oldValues.get(0); + Property p = ov1.getProperty(); + assertEquals("strElem", p.getName()); + Object v = ov1.getValue(); + assertEquals(null, v); + + assertTrue(cs.isLogging()); + cs.endLogging(); + assertFalse(cs.isLogging()); + + } + + + + public void testDynamicNestedDataObjectsDG() throws Exception { + DataGraph dataGraph = SDOUtil.createDataGraph(); + DataObject quote = dataGraph.createRootObject(th.getType("http://www.example.com/simple", "Quote")); + + testDynamicNestedDOBody(quote); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + SDOUtil.saveDataGraph(dataGraph, baos, null); + // SDOUtil.saveDataGraph(dataGraph, System.out, null); + + assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(TEST_DATA))); + + + assertEquals(1, quote.getList("quotes").size()); + assertEquals("fbnt", quote.getString("symbol")); + dataGraph.getChangeSummary().undoChanges(); + // SDOUtil.saveDataGraph(dataGraph, System.out, null); + assertEquals(0, quote.getList("quotes").size()); + assertNull(quote.getString("symbol")); + + + } + + public void testDynamicNestedDataObjectsDO() throws Exception { + Type quoteType = th.getType("http://www.example.com/simpleCS", "RootQuote"); + DataObject quote = hc.getDataFactory().create(quoteType); + + testDynamicNestedDOBody(quote); + //hc.getXMLHelper().save(quote, "http://www.example.com/simpleCS", "stockQuote", System.out); + assertEquals(1, quote.getList("quotes").size()); + assertEquals("fbnt", quote.getString("symbol")); + + quote.getChangeSummary().undoChanges(); + + assertEquals(0, quote.getList("quotes").size()); + assertNull(quote.getString("symbol")); + + + + } + + /** + * @param quote + */ + private void testDynamicNestedDOBody(DataObject quote) { + // Begin logging changes + // + ChangeSummary changeSummary = quote.getChangeSummary(); + assertNotNull(changeSummary); + assertFalse(changeSummary.isLogging()); + 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")); + + changeSummary.endLogging(); + assertEquals(2, changeSummary.getChangedDataObjects().size()); // 2 DataObjects + assertTrue(changeSummary.getChangedDataObjects().contains(quote)); + assertTrue(changeSummary.getChangedDataObjects().contains(child)); + assertFalse(changeSummary.isCreated(quote)); + assertTrue(changeSummary.isCreated(child)); + + ChangeSummary.Setting ov = changeSummary.getOldValue(quote, quote.getType().getProperty("symbol")); + assertNull(ov.getValue()); + + + } + + protected void setUp() throws Exception { + super.setUp(); + +// uncomment these lines for sending aspect trace to a file +// tracing.lib.TraceMyClasses tmc = (TraceMyClasses)Aspects.aspectOf(TraceMyClasses.class); +// tmc.initStream(new PrintStream("c:\\temp\\trace.log")); + + // Populate the meta data for the test (Stock Quote) model + URL url = getClass().getResource("/simple.xsd"); + InputStream inputStream = url.openStream(); + hc = SDOUtil.createHelperContext(); + th = hc.getTypeHelper(); + xh = hc.getXSDHelper(); + xh.define(inputStream, url.toString()); + inputStream.close(); + + URL url2 = getClass().getResource("/simpleWithChangeSummary.xsd"); + InputStream inputStream2 = url2.openStream(); + xh.define(inputStream2, url2.toString()); + inputStream.close(); + + + +} + +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryPropertyTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryPropertyTestCase.java new file mode 100644 index 0000000000..4a62ec6135 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryPropertyTestCase.java @@ -0,0 +1,219 @@ +/** + * + * 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.math.BigDecimal; +import java.net.URL; +import java.util.List; + +import junit.framework.TestCase; + +import org.apache.tuscany.sdo.util.SDOUtil; + +import commonj.sdo.ChangeSummary; +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.HelperContext; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; + +public class ChangeSummaryPropertyTestCase extends TestCase { + private final String TEST_MODEL = "/simpleWithChangeSummary.xsd"; + private final String TEST_NAMESPACE = "http://www.example.com/simpleCS"; + + private final String TEST_DATA_BEFORE_UNDO = "/simpleWithChangeSummary.xml"; + private final String TEST_DATA_AFTER_UNDO = "/simpleWithChangeSummaryUndone.xml"; + + HelperContext hc; + DataFactory dataFactory; + XMLHelper xmlHelper; + + void verify(ChangeSummary cs, DataObject quote, String nameSpace, String element, String beforeUndo, String afterUndo) throws IOException { + // Stop logging changes and serialize the resulting data graph + // + cs.endLogging(); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + xmlHelper.save(quote, nameSpace, element, baos); + //xmlHelper.save(quote, nameSpace, element, System.out); + + byte[] bytes = baos.toByteArray(); + URL url = getClass().getResource(beforeUndo); + assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(bytes), url)); + + DataObject loaded = xmlHelper.load(new ByteArrayInputStream(bytes)).getRootObject(); + baos.reset(); + xmlHelper.save(loaded, nameSpace, element, baos); + //xmlHelper.save(loaded, nameSpace, element, System.out); + assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), url)); + + // Undo all changes and then serialize the resulting data graph again + // + cs.undoChanges(); + + baos.reset(); + xmlHelper.save(quote, nameSpace, element, baos); + //xmlHelper.save(quote, nameSpace, element, System.out); + + assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(afterUndo))); + } + + /** + * ChangeSummary property test. + */ + protected final void change(String nameSpace, String beforeUndo, String afterUndo) throws Exception { + Type quoteType = hc.getTypeHelper().getType(nameSpace, "RootQuote"); + DataObject quote = dataFactory.create(quoteType); + + ChangeSummary cs = quote.getChangeSummary(); + ChangeSummary csp = (ChangeSummary)quote.get("changes"); + + assertSame(cs, csp); + + quote.setString("symbol", "fbnt"); + quote.setString("companyName", "FlyByNightTechnology"); + quote.setBigDecimal("price", new BigDecimal("1000.0")); + DataObject child = quote.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("1500.0")); + child = quote.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("2000.0")); + child = child.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("2000.99")); + child = quote.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("2500.0")); + + // Begin logging changes + // + cs.beginLogging(); + + // Modify the data graph in various ways + // + quote.setString("symbol", "FBNT"); + quote.setBigDecimal("price", new BigDecimal("999.0")); + quote.setDouble("volume", 1000); + + child = quote.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("3000.0")); + child = quote.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("4000.0")); + + quote.getDataObject("quotes[2]").delete(); + + verify(cs, quote, nameSpace, "stockQuote", beforeUndo, afterUndo); + } + + /** + * Simple ChangeSummary property test. + */ + public void testChangeSummary() throws Exception { + change(TEST_NAMESPACE, TEST_DATA_BEFORE_UNDO, TEST_DATA_AFTER_UNDO); + } + + static final String SequenceTest_NameSpace = "http://www.example.com/sequenceCS"; + + /** + * Mixed ChangeSummary property test. + */ + public void testMixedChangeSummary() throws Exception { + change(SequenceTest_NameSpace, "/mixedChangeSummary.xml", "/mixedChangeSummaryUndone.xml"); + } + + protected final DataObject createDataObject(Type quoteType, Object value, Sequence sequence, Property property) { + DataObject child = dataFactory.create(quoteType); + child.set("symbol", value); + sequence.add(property, child); + return child; + } + + static final String SequenceTest_ELEMENT = "openQuote"; + + private XSDHelper xsdHelper; + + /** + * Open/any ChangeSummary property test. + */ + public void testOpenChangeSummary() throws Exception { + DataObject quote = dataFactory.create(xsdHelper.getGlobalProperty(SequenceTest_NameSpace, SequenceTest_ELEMENT, true).getType()); + + ChangeSummary cs = quote.getChangeSummary(); + ChangeSummary csp = (ChangeSummary)quote.get("changes"); + + assertSame(cs, csp); + + quote.set("symbol", "fbnt"); + Property property = xsdHelper.getGlobalProperty("http://www.example.com/open", "openStockQuote", true); + Type quoteType = property.getType(); + List openStockQuotes = ((DataObject)quote).getList(property); + + addQuote(openStockQuotes, quoteType, "1500.0"); + DataObject osq2 = addQuote(openStockQuotes, quoteType, "2000.0"); + addQuote(osq2.getList(property), quoteType, "2000.99"); + addQuote(openStockQuotes, quoteType, "2500.0"); + + // Begin logging changes + // + cs.beginLogging(); + + // Modify the data graph in various ways + // + quote.set("symbol", "FBNT"); + + addQuote(openStockQuotes, quoteType, "3000.0"); + addQuote(openStockQuotes, quoteType, "4000.0"); + + openStockQuotes.remove(osq2); + + + verify(cs, quote, SequenceTest_NameSpace, SequenceTest_ELEMENT, "/openChangeSummary.xml", "/openChangeSummaryUndone.xml"); + } + + private DataObject addQuote(List openStockQuotes, Type quoteType, + Object value) { + DataObject osq = dataFactory.create(quoteType); + osq.set("symbol", value); + openStockQuotes.add(osq); + return osq; + } + + void define(String model) throws Exception { + // Populate the meta data for the test model + URL url = getClass().getResource(model); + xsdHelper.define(url.openStream(), url.toString()); + } + + protected void setUp() throws Exception { + super.setUp(); + hc = SDOUtil.createHelperContext(); + xsdHelper = hc.getXSDHelper(); + dataFactory = hc.getDataFactory(); + xmlHelper = hc.getXMLHelper(); + + // Populate the meta data for the test (Stock Quote) model + define(TEST_MODEL); + + define("/SequenceChangeSummary.xsd"); + } +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryTestCase.java new file mode 100644 index 0000000000..e956720117 --- /dev/null +++ b/sandbox/kgoodson/events/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/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentCycleTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentCycleTestCase.java new file mode 100644 index 0000000000..843ab9b982 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentCycleTestCase.java @@ -0,0 +1,866 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.test; + +import junit.framework.TestCase; +import commonj.sdo.DataObject; +import commonj.sdo.Sequence; +import commonj.sdo.Type; +import commonj.sdo.helper.HelperContext; + +import org.apache.tuscany.sdo.api.XMLStreamHelper; +import org.apache.tuscany.sdo.api.SDOUtil; + +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; + +import com.example.test.Containment.ContainmentFactory; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.util.ArrayList; +import java.util.List; + +/** + * Tests serialization of containment cycles. For JavaSerialization, the test case + * passes if an IllegalStateException is thrown. For XMLHelper and XMLStreamHelper + * serialization, serization should complete without throwing an Exception. In all + * cases, the actual structure of the DataObject should not be changed by the + * method call to serialize the DO. + * + * The same test is run for a static model (Type created using XSD2JavaGenerator), a + * dynamic model (Type created using TypeHelper), and a 'mixed' model (Type created + * using XSDHelper - dynamic Type creation using static resources). + */ +public class ContainmentCycleTestCase extends TestCase { + + private static final String CONTAIN_URI = "http://www.example.com/ContainmentTest"; + private static final String CONTAIN_TYPE = "ContainmentTest"; + private static HelperContext staticScope; + private static HelperContext dynamicScope; + private static HelperContext mixedScope; + private static boolean initialized = false; + private static boolean mixedCreated = false; + + /** + * Attempt to create a 1-Member Containment Cycle using set____ on a single valued property + * and verify the behavior of serialization. This is the static version of this test case. + */ + // Note: Static test cases are prevented due to a JVM Error in ObjectOutputStream. + // The IllegalStateException thrown by Java serialization is caught, which in turn allows + // the StackOverflowException to occur. The catcher is catching RuntimeException, so it does + // not matter which Exception is thrown by the SDO code. + public void atestStaticOneMemberSingleValueSetDataObject() { + final DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + + dataObj1.setString("Name", "dataObj1"); + + setSingleValueOneMember(dataObj1); + attemptSerialization(dataObj1, staticScope); + } + + /** + * Attempt to create an n-Member Containment Cycle using set____ on a single valued property + * and verify the behavior of serialization. This is the static version of this test case. + */ + public void atestStaticNMemberSingleValueSetDataObject() { + final DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + final DataObject dataObj2 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + final DataObject dataObj3 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + + dataObj1.setString("Name", "dataObj1"); + dataObj2.setString("Name", "dataObj2"); + dataObj3.setString("Name", "dataObj3"); + + setSingleValueNMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, staticScope); + } + + + /** + * Attempt to create a 1-Member Containment Cycle using set____ on a multi valued property + * and verify the behavior of serialization. This is the static version of this test case. + */ + public void atestStaticOneMemberMultiValueSetDataObject() { + final DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + final DataObject dataObj2 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + final DataObject dataObj3 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + + dataObj1.setString("Name", "dataObj1"); + dataObj2.setString("Name", "dataObj2"); + dataObj3.setString("Name", "dataObj3"); + + setMultiValueOneMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, staticScope); + } + + /** + * Attempt to create an n-Member Containment Cycle using set____ on a multi valued property + * and verify the behavior of serialization. This is the static version of this test case. + */ + public void atestStaticNMemberMultiValueSetDataObject() { + final DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + final DataObject dataObj2 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + final DataObject dataObj3 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + + dataObj1.setString("Name", "dataObj1"); + dataObj2.setString("Name", "dataObj2"); + dataObj3.setString("Name", "dataObj3"); + + setManyValueNMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, staticScope); + } + + /** + * Attempt to create a 1-Member Containment Cycle by making updates to a List returned + * from the DataObject and verify the behavior of serialization. This is the static version + * of this test case. + */ + public void atestStaticOneMemberReturnedList() { + final DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + + dataObj1.setString("Name", "dataObj1"); + + returnedListOneMember(dataObj1); + attemptSerialization(dataObj1, staticScope); + } + + /** + * Attempt to create an n-Member Containment Cycle by making updates to a List returned + * from the DataObject and verify the behavior of serialization. This is the static version + * of this test case. + */ + public void atestStaticNMemberReturnedList() { + final DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + final DataObject dataObj2 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + final DataObject dataObj3 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + + dataObj1.setString("Name", "dataObj1"); + dataObj2.setString("Name", "dataObj2"); + dataObj3.setString("Name", "dataObj3"); + + returnedListNMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, staticScope); + } + + /** + * Attempt to create a 1-Member Containment Cycle using by using a Sequence to make updates + * to the DataObject, affecting a single valued property, and verify the behavior of + * serialization. This is the static version of this test case. + */ + public void atestStaticOneMemberSingleValueSequence() { + final DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + + dataObj1.setString("Name", "dataObj1"); + + sequenceSingleValueOneMember(dataObj1); + attemptSerialization(dataObj1, staticScope); + } + + /** + * Attempt to create an n-Member Containment Cycle using by using a Sequence to make updates + * to the DataObject, affecting a single valued property, and verify the behavior of + * serialization. This is the static version of this test case. + */ + public void atestStaticNMemberSingleValueSequence() { + final DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + final DataObject dataObj2 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + final DataObject dataObj3 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + + dataObj1.setString("Name", "dataObj1"); + dataObj2.setString("Name", "dataObj2"); + dataObj3.setString("Name", "dataObj3"); + + sequenceSingleValueNMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, staticScope); + } + + /** + * Attempt to create a 1-Member Containment Cycle using by using a Sequence to make updates + * to the DataObject, affecting a multi valued property, and verify the behavior of + * serialization. This is the static version of this test case. + */ + public void atestStaticOneMemberMultiValueSequence() { + final DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + final DataObject dataObj2 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + final DataObject dataObj3 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + + dataObj1.setString("Name", "dataObj1"); + dataObj2.setString("Name", "dataObj2"); + dataObj3.setString("Name", "dataObj3"); + + sequenceMultiValueOneMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, staticScope); + } + + /** + * Attempt to create an n-Member Containment Cycle using by using a Sequence to make updates + * to the DataObject, affecting a multi valued property, and verify the behavior of + * serialization. This is the static version of this test case. + */ + public void atestStaticNMemberMultiValueSequence() { + final DataObject dataObj1 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + final DataObject dataObj2 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + final DataObject dataObj3 = (DataObject) ContainmentFactory.INSTANCE.createContainmentTest(); + + dataObj1.setString("Name", "dataObj1"); + dataObj2.setString("Name", "dataObj2"); + dataObj3.setString("Name", "dataObj3"); + + sequenceManyValueNMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, staticScope); + } + + /** + * Attempt to create a 1-Member Containment Cycle using set____ on a single valued property + * and verify the behavior of serialization. This is the hybrid version of this test case. + */ + public void testHybridOneMemberSingleValueSetDataObject() { + assertTrue("Test case cannot proceed due to error creating Type.", mixedCreated); + + final DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI, + CONTAIN_TYPE); + dataObj1.setString("Name", "dataObj1"); + + setSingleValueOneMember(dataObj1); + attemptSerialization(dataObj1, mixedScope); + } + + /** + * Attempt to create an n-Member Containment Cycle using set____ on a single valued property + * and verify the behavior of serialization. This is the hybrid version of this test case. + */ + public void testHybridNMemberSingleValueSetDataObject() { + assertTrue("Test case cannot proceed due to error creating Type.", mixedCreated); + + final DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI, + CONTAIN_TYPE); + final DataObject dataObj2 = mixedScope.getDataFactory().create(CONTAIN_URI, + CONTAIN_TYPE); + final DataObject dataObj3 = mixedScope.getDataFactory().create(CONTAIN_URI, + CONTAIN_TYPE); + dataObj1.setString("Name", "dataObj1"); + dataObj2.setString("Name", "dataObj2"); + dataObj3.setString("Name", "dataObj3"); + + setSingleValueNMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, mixedScope); + } + + /** + * Attempt to create a 1-Member Containment Cycle using set____ on a multi valued property + * and verify the behavior of serialization. This is the hybrid version of this test case. + */ + public void testHybridOneMemberMultiValueSetDataObject() { + assertTrue("Test case cannot proceed due to error creating Type.", mixedCreated); + + final DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI, + CONTAIN_TYPE); + final DataObject dataObj2 = mixedScope.getDataFactory().create(CONTAIN_URI, + CONTAIN_TYPE); + final DataObject dataObj3 = mixedScope.getDataFactory().create(CONTAIN_URI, + CONTAIN_TYPE); + + dataObj1.setString("Name", "dataObj1"); + dataObj2.setString("Name", "dataObj2"); + dataObj3.setString("Name", "dataObj3"); + + setMultiValueOneMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, mixedScope); + } + + /** + * Attempt to create an n-Member Containment Cycle using set____ on a multi valued property + * and verify the behavior of serialization. This is the hybrid version of this test case. + */ + public void testHybridNMemberMultiValueSetDataObject() { + assertTrue("Test case cannot proceed due to error creating Type.", mixedCreated); + + final DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI, + CONTAIN_TYPE); + final DataObject dataObj2 = mixedScope.getDataFactory().create(CONTAIN_URI, + CONTAIN_TYPE); + final DataObject dataObj3 = mixedScope.getDataFactory().create(CONTAIN_URI, + CONTAIN_TYPE); + dataObj1.setString("Name", "dataObj1"); + dataObj2.setString("Name", "dataObj2"); + dataObj3.setString("Name", "dataObj3"); + + setManyValueNMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, mixedScope); + } + + /** + * Attempt to create a 1-Member Containment Cycle by making updates to a List returned + * from the DataObject and verify the behavior of serialization. This is the hybrid version + * of this test case. + */ + public void testHybridOneMemberReturnedList() { + assertTrue("Test case cannot proceed due to error creating Type.", mixedCreated); + + final DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI, + CONTAIN_TYPE); + dataObj1.setString("Name", "dataObj1"); + + returnedListOneMember(dataObj1); + attemptSerialization(dataObj1, mixedScope); + } + + /** + * Attempt to create an n-Member Containment Cycle by making updates to a List returned + * from the DataObject and verify the behavior of serialization. This is the hybrid version + * of this test case. + */ + public void testHybridNMemberReturnedList() { + assertTrue("Test case cannot proceed due to error creating Type.", mixedCreated); + + final DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI, + CONTAIN_TYPE); + final DataObject dataObj2 = mixedScope.getDataFactory().create(CONTAIN_URI, + CONTAIN_TYPE); + final DataObject dataObj3 = mixedScope.getDataFactory().create(CONTAIN_URI, + CONTAIN_TYPE); + dataObj1.setString("Name", "dataObj1"); + dataObj2.setString("Name", "dataObj2"); + dataObj3.setString("Name", "dataObj3"); + + returnedListNMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, mixedScope); + } + + /** + * Attempt to create a 1-Member Containment Cycle using by using a Sequence to make updates + * to the DataObject, affecting a single valued property, and verify the behavior of + * serialization. This is the hybrid version of this test case. + */ + public void testHybridOneMemberSingleValueSequence() { + assertTrue("Test case cannot proceed due to error creating Type.", mixedCreated); + + final DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI, + CONTAIN_TYPE); + dataObj1.setString("Name", "dataObj1"); + + sequenceSingleValueOneMember(dataObj1); + attemptSerialization(dataObj1, mixedScope); + } + + /** + * Attempt to create an n-Member Containment Cycle using by using a Sequence to make updates + * to the DataObject, affecting a single valued property, and verify the behavior of + * serialization. This is the hybrid version of this test case. + */ + public void testHybridNMemberSingleValueSequence() { + assertTrue("Test case cannot proceed due to error creating Type.", mixedCreated); + + final DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI, + CONTAIN_TYPE); + final DataObject dataObj2 = mixedScope.getDataFactory().create(CONTAIN_URI, + CONTAIN_TYPE); + final DataObject dataObj3 = mixedScope.getDataFactory().create(CONTAIN_URI, + CONTAIN_TYPE); + dataObj1.setString("Name", "dataObj1"); + dataObj2.setString("Name", "dataObj2"); + dataObj3.setString("Name", "dataObj3"); + + sequenceSingleValueNMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, mixedScope); + } + + /** + * Attempt to create a 1-Member Containment Cycle using by using a Sequence to make updates + * to the DataObject, affecting a multi valued property, and verify the behavior of serialization. + * This is the hybrid version of this test case. + */ + public void testHybridOneMemberMultiValueSequence() { + assertTrue("Test case cannot proceed due to error creating Type.", mixedCreated); + + final DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + final DataObject dataObj2 = mixedScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + final DataObject dataObj3 = mixedScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + dataObj1.setString("Name", "dataObj1"); + dataObj2.setString("Name", "dataObj2"); + dataObj3.setString("Name", "dataObj3"); + + sequenceMultiValueOneMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, mixedScope); + } + + /** + * Attempt to create an n-Member Containment Cycle using by using a Sequence to make updates + * to the DataObject, affecting a multi valued property, and verify the behavior of serialization. + * This is the hybrid version of this test case. + */ + public void testHybridNMemberMultiValueSequence() { + assertTrue("Test case cannot proceed due to error creating Type.", mixedCreated); + + final DataObject dataObj1 = mixedScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + final DataObject dataObj2 = mixedScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + final DataObject dataObj3 = mixedScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + dataObj1.setString("Name", "dataObj1"); + dataObj2.setString("Name", "dataObj2"); + dataObj3.setString("Name", "dataObj3"); + + sequenceManyValueNMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, mixedScope); + } + + /** + * Attempt to create a 1-Member Containment Cycle using set____ on a single valued property + * and verify the behavior of serialization. This is the dynamic version of this test case. + */ + public void testDynamicOneMemberSingleValueSetDataObject() { + final DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, + CONTAIN_TYPE); + dataObj1.setString("Name", "dataObj1"); + + setSingleValueOneMember(dataObj1); + attemptSerialization(dataObj1, dynamicScope); + } + + /** + * Attempt to create an n-Member Containment Cycle using set____ on a single valued property + * and verify the behavior of serialization. This is the dynamic version of this test case. + */ + public void testDynamicNMemberSingleValueSetDataObject() { + final DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + final DataObject dataObj2 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + final DataObject dataObj3 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + dataObj1.setString("Name", "dataObj1"); + dataObj2.setString("Name", "dataObj2"); + dataObj3.setString("Name", "dataObj3"); + + setSingleValueNMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, dynamicScope); + } + + /** + * Attempt to create a 1-Member Containment Cycle using set____ on a multi valued property + * and verify the behavior of serialization. This is the dynamic version of this test case. + */ + public void testDynamicOneMemberMultiValueSetDataObject() { + final DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + final DataObject dataObj2 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + final DataObject dataObj3 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + dataObj1.setString("Name", "dataObj1"); + dataObj2.setString("Name", "dataObj2"); + dataObj3.setString("Name", "dataObj3"); + + setMultiValueOneMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, dynamicScope); + } + + /** + * Attempt to create an n-Member Containment Cycle using set____ on a multi valued property + * and verify the behavior of serialization. This is the dynamic version of this test case. + */ + public void testDynamicNMemberMultiValueSetDataObject() { + final DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + final DataObject dataObj2 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + final DataObject dataObj3 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + dataObj1.setString("Name", "dataObj1"); + dataObj2.setString("Name", "dataObj2"); + dataObj3.setString("Name", "dataObj3"); + + setManyValueNMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, dynamicScope); + } + + /** + * Attempt to create a 1-Member Containment Cycle by making updates to a List returned + * from the DataObject and verify the behavior of serialization. This is the dynamic version + * of this test case. + */ + public void testDynamicOneMemberReturnedList() { + final DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + dataObj1.setString("Name", "dataObj1"); + + returnedListOneMember(dataObj1); + attemptSerialization(dataObj1, dynamicScope); + } + + /** + * Attempt to create an n-Member Containment Cycle by making updates to a List returned + * from the DataObject and verify the behavior of serialization. This is the dynamic version + * of this test case. + */ + public void testDynamicNMemberReturnedList() { + final DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + final DataObject dataObj2 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + final DataObject dataObj3 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + dataObj1.setString("Name", "dataObj1"); + dataObj2.setString("Name", "dataObj2"); + dataObj3.setString("Name", "dataObj3"); + + returnedListNMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, dynamicScope); + } + + /** + * Attempt to create a 1-Member Containment Cycle using by using a Sequence to make updates + * to the DataObject, affecting a single valued property, and verify the behavior of + * serialization. This is the dynamic version of this test case. + */ + public void testDynamicOneMemberSingleValueSequence() { + final DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + dataObj1.setString("Name", "dataObj1"); + + sequenceSingleValueOneMember(dataObj1); + attemptSerialization(dataObj1, dynamicScope); + } + + /** + * Attempt to create an n-Member Containment Cycle using by using a Sequence to make updates + * to the DataObject, affecting a single valued property, and verify the behavior of + * serialization. This is the dynamic version of this test case. + */ + public void testDynamicNMemberSingleValueSequence() { + final DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + final DataObject dataObj2 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + final DataObject dataObj3 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + dataObj1.setString("Name", "dataObj1"); + dataObj2.setString("Name", "dataObj2"); + dataObj3.setString("Name", "dataObj3"); + + sequenceSingleValueNMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, dynamicScope); + } + + /** + * Attempt to create a 1-Member Containment Cycle using by using a Sequence to make updates + * to the DataObject, affecting a multi valued property, and verify the behavior of + * serialization. This is the dynamic version of this test case. + */ + public void testDynamicOneMemberMultiValueSequence() { + final DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + final DataObject dataObj2 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + final DataObject dataObj3 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + dataObj1.setString("Name", "dataObj1"); + dataObj2.setString("Name", "dataObj2"); + dataObj3.setString("Name", "dataObj3"); + + sequenceMultiValueOneMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, dynamicScope); + } + + /** + * Attempt to create an n-Member Containment Cycle using by using a Sequence to make updates + * to the DataObject, affecting a multi valued property, and verify the behavior of + * serialization. This is the dynamic version of this test case. + */ + public void testDynamicNMemberMultiValueSequence() { + final DataObject dataObj1 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + final DataObject dataObj2 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + final DataObject dataObj3 = dynamicScope.getDataFactory().create(CONTAIN_URI, CONTAIN_TYPE); + dataObj1.setString("Name", "dataObj1"); + dataObj2.setString("Name", "dataObj2"); + dataObj3.setString("Name", "dataObj3"); + + sequenceManyValueNMember(dataObj1, dataObj2, dataObj3); + attemptSerialization(dataObj1, dynamicScope); + } + + /** + * Attempt to serialize the DataObject in via XML, XMLStreamHelper, + * and Java serialization. + * @param dataObj + */ + private void attemptSerialization(final DataObject dataObj, final HelperContext scope) { + + assertTrue("Containment cycle was not established.", + containmentCycleExists(dataObj)); + + try { + serializeDataObjectXML(dataObj, scope); + } catch (final Exception e) { + fail("XML serialization of a containment cycle resulted in a(n) " + e.getClass().getName() + "."); + e.printStackTrace(); + } + + assertTrue("Containment cycle was affected by XMLHelper serialization.", + containmentCycleExists(dataObj)); + + try { + serializeDataObjectJava(dataObj); + fail("Java serialization of a containment cycle should result in an IllegalStateException."); + } catch (final Exception e) { + // Do nothing. An Exception is expected in this case. + } + + assertTrue("Containment cycle was affected by Java serialization.", + containmentCycleExists(dataObj)); + + try { + serializeDataObjectStream(dataObj, scope); + } catch (final Exception e) { + fail("XMLStreamHelper serialization of a containment cycle resulted in a(n) " + e.getClass().getName() + "."); + e.printStackTrace(); + } + assertTrue("Containment cycle was affected by XMLStreamHelper serialization.", + containmentCycleExists(dataObj)); + } + /** + * Uses the XMLHelper to serialize the input DataObject + * + * @param dataObject + * @param fileName + * @throws IOException + */ + private static void serializeDataObjectXML(final DataObject dataObject, final HelperContext scope) { + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + final Type type = dataObject.getType(); + + try { + scope.getXMLHelper().save(dataObject, type.getURI(), type.getName(), baos); + } + catch (final IOException e) { + fail("Could not complete test case due to IOException."); + } + } + + /** + * Uses Java serialization to serialize the input DataObject + * + * @param dataObject + * @param fileName + * @throws IOException + */ + private static void serializeDataObjectStream(final DataObject dataObject, final HelperContext scope) { + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + final XMLOutputFactory factory = XMLOutputFactory.newInstance(); + XMLStreamWriter serializer; + final XMLStreamHelper xmlStreamHelper = SDOUtil.createXMLStreamHelper(scope); + try { + serializer = factory.createXMLStreamWriter(baos); + xmlStreamHelper.saveObject(dataObject, serializer); + serializer.flush(); + } + catch (final XMLStreamException e) { + fail("Exception encountered during XMLStreamHelper serialization."); + e.printStackTrace(); + } + } + + /** + * Uses Java serialization to serialize the input DataObject + * + * @param dataObject + * @param fileName + * @throws IOException + */ + private static void serializeDataObjectJava(final DataObject dataObject) { + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + try { + final ObjectOutputStream out = new ObjectOutputStream(baos); + out.writeObject(dataObject); + out.close(); + } + catch (final IOException e) { + fail("Could not complete test case due to IOException."); + } + } + + /** + * Returns true if input DataObject root is part of a containment cycle, + * false otherwise. + * @param root + * @return + */ + private static boolean containmentCycleExists (final DataObject root) + { + DataObject curr = root.getContainer(); + + while (curr != null) + { + if (curr == root) { + return true; + } + + curr = curr.getContainer(); + } + return false; + } + + /** + * Use setDataObject to create a one member containment cycle. + * @param dataObj1 + */ + private void setSingleValueOneMember(final DataObject dataObj1) { + dataObj1.setDataObject("Contain", dataObj1); + } + + /** + * Use setDataObject to create an N-member containment cycle. + * @param dataObj1 + * @param dataObj2 + * @param dataobj3 + */ + private void setSingleValueNMember(final DataObject dataObj1, final DataObject dataObj2, final DataObject dataObj3) { + dataObj1.setDataObject("Contain", dataObj2); + dataObj2.setDataObject("Contain", dataObj3); + dataObj3.setDataObject("Contain", dataObj1); + } + + /** + * Use setList to create a one member containment cycle. + * @param dataObj1 + * @param dataObj2 + * @param dataObj3 + */ + private void setMultiValueOneMember(final DataObject dataObj1, final DataObject dataObj2, final DataObject dataObj3) { + final List addList = new ArrayList(); + + addList.add(dataObj2); + addList.add(dataObj1); + addList.add(dataObj3); + dataObj1.setList("ContainMany", addList); + } + + /** + * Use setList to create an N-member containment cycle. + * @param dataObj1 + * @param dataObj2 + * @param dataObj3 + */ + private void setManyValueNMember(final DataObject dataObj1, final DataObject dataObj2, final DataObject dataObj3) { + final List addList = new ArrayList(); + + dataObj1.setDataObject("Contain", dataObj2); + dataObj2.setDataObject("Contain", dataObj3); + addList.add(dataObj1); + dataObj3.setList("ContainMany", addList); + } + + /** + * Create a 1-member containment cycle by making updates to a returned List. + * @param dataObj1 + */ + private void returnedListOneMember(final DataObject dataObj1) { + final List returnedList = dataObj1.getList("ContainMany"); + + returnedList.add(dataObj1); + } + + /** + * Create an n-member containment cycle by making updates to a returned List. + * @param dataObj1 + * @param dataObj2 + * @param dataobj3 + */ + private void returnedListNMember(final DataObject dataObj1, final DataObject dataObj2, final DataObject dataObj3) { + dataObj1.setDataObject("Contain", dataObj2); + dataObj2.setDataObject("Contain", dataObj3); + + final List returnedList = dataObj3.getList("ContainMany"); + + returnedList.add(dataObj1); + } + + /** + * Create a 1-member containment cycle by making updates to a Sequence. + * The data member in this case is single valued. + * @param dataObj1 + * @param dataObj2 + * @param dataObj3 + */ + private void sequenceSingleValueOneMember(final DataObject dataObj1) { + assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced()); + + final Sequence sequence = dataObj1.getSequence(); + + sequence.add("Contain", dataObj1); + } + + /** + * Create an n-member containment cycle by making updates to a Sequence. + * The data member in this case is single valued. + * @param dataObj1 + * @param dataObj2 + * @param dataObj3 + */ + private void sequenceSingleValueNMember(final DataObject dataObj1, final DataObject dataObj2, final DataObject dataObj3) { + assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced()); + + final Sequence sequence1 = dataObj1.getSequence(); + final Sequence sequence2 = dataObj2.getSequence(); + final Sequence sequence3 = dataObj3.getSequence(); + + sequence1.add("Contain", (Object) dataObj2); + sequence2.add("Contain", (Object) dataObj3); + + sequence3.add("Contain", (Object) dataObj1); + } + + /** + * Create a 1-member containment cycle by making updates to a Sequence. + * The data member in this case is many valued. + * @param dataObj1 + * @param dataObj2 + * @param dataObj3 + */ + private void sequenceMultiValueOneMember(final DataObject dataObj1, final DataObject dataObj2, final DataObject dataObj3) { + assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced()); + + final Sequence sequence = dataObj1.getSequence(); + + sequence.add("ContainMany", dataObj2); + sequence.add("ContainMany", dataObj3); + sequence.add("ContainMany", dataObj1); + } + + /** + * Create an n-member containment cycle by making updates to a Sequence. + * The data member in this case is many valued. + * @param dataObj1 + * @param dataObj2 + * @param dataObj3 + */ + private void sequenceManyValueNMember(final DataObject dataObj1, final DataObject dataObj2, final DataObject dataObj3) { + assertTrue("DataObject is not Sequenced. Test case may not proceed.", dataObj1.getType().isSequenced()); + + final List addList = new ArrayList(); + + addList.add(dataObj2); + dataObj1.setList("ContainMany", addList); + + addList.clear(); + addList.add(dataObj3); + dataObj2.setList("ContainMany", addList); + + final Sequence sequence = dataObj3.getSequence(); + + sequence.add("ContainMany", dataObj1); + } + + public void setUp() { + if (!initialized) { + staticScope = SDOUtil.createHelperContext(); + ContainmentFactory.INSTANCE.register(staticScope); + + dynamicScope = SDOUtil.createHelperContext(); + ContainmentTypeUtil.createDynamically(dynamicScope); + + mixedScope = SDOUtil.createHelperContext(); + mixedCreated = ContainmentTypeUtil.createDynamicWithStaticResources(mixedScope); + + initialized = true; + } + } +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentTypeUtil.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentTypeUtil.java new file mode 100644 index 0000000000..f602555fa6 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ContainmentTypeUtil.java @@ -0,0 +1,86 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.test; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; + +import commonj.sdo.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.TypeHelper; + +/** + * Provides methods to dynamically create the ContainemntTest Type using the XSDHelper + * and the TypeHelper. + */ +public class ContainmentTypeUtil { + + /** + * createDynamicWithStaticResources creates the DataObject type from an existing + * XSD. The same XSD is used to create the Types statically using the XSD2JavaGenerator. + * The XSD should be kept in synch with the createDynamically method in this class. + * @throws IOException + * @return true if + */ + public static boolean createDynamicWithStaticResources(HelperContext hc) { + try { + // Populate the meta data for the test model (ContainTest) + URL url = ContainmentCycleTestCase.class.getResource("/containmenttest.xsd"); + InputStream inputStream = url.openStream(); + hc.getXSDHelper().define(inputStream, url.toString()); + inputStream.close(); + } catch(IOException e) { + e.printStackTrace(); + return false; + } + return true; + } + + /** + * createDynamically() creates the SDO Types using the TypeHelper. This method should be kept in + * synch with the XSD used for createDynamicallyWithStaticResources. The same XSD is used for + * the static generation of SDO Types using XSD2JavaGenerator. + */ + public static void createDynamically(HelperContext hc) { + TypeHelper types = hc.getTypeHelper(); + Type stringType = types.getType("commonj.sdo", "String"); + + DataObject testType = hc.getDataFactory().create("commonj.sdo", "Type"); + testType.set("uri", "http://www.example.com/ContainmentTest"); + testType.set("name", "ContainmentTest"); + testType.setBoolean("sequenced", true); + + DataObject nameProperty = testType.createDataObject("property"); + nameProperty.set("name", "Name"); + nameProperty.set("type", stringType); + + DataObject containProperty = testType.createDataObject("property"); + containProperty.set("name", "Contain"); + containProperty.setBoolean("containment", true); + containProperty.set("type", testType); + + DataObject containManyProperty = testType.createDataObject("property"); + containManyProperty.set("name", "ContainMany"); + containManyProperty.setBoolean("many", true); + containManyProperty.setBoolean("containment", true); + containManyProperty.set("type", testType); + + types.define(testType); + } +} \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/CrossScopeCopyTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/CrossScopeCopyTestCase.java new file mode 100644 index 0000000000..bba7fb4c1b --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/CrossScopeCopyTestCase.java @@ -0,0 +1,474 @@ +/** + * + * 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.api.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.HelperContext; +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 HelperContext hca; + private HelperContext hcb; + 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(hcb); + + // 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 = hca.getDataFactory().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 + hca = SDOUtil.createHelperContext(); + hcb = SDOUtil.createHelperContext(); + scopeA = hca.getTypeHelper(); + scopeB = hcb.getTypeHelper(); + + // Populate scopes with bank model now + URL url = getClass().getResource(BANK_MODEL); + InputStream inputStream = url.openStream(); + hca.getXSDHelper().define(inputStream, url.toString()); + inputStream.close(); + inputStream = url.openStream(); + hcb.getXSDHelper().define(inputStream, url.toString()); + inputStream.close(); + + // Now Populate scopeA with some dynamic models + populateScopeWithDynamicTypes(scopeA); + + // Construct Source Tree + constructSourceTree(hca.getDataFactory()); + } + + 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 " + + " " + + "fbnt " + + "FlyByNightTechnology " + + "1000.0 " + + "1000.0 " + + "1000.0 " + + "1000.0 " + + "1000.0 " + + "1000.0 " + + " " + + "2000.0 " + + " " + + ""; + + public void testLoadQuoteXMLDoc() throws IOException + { + XMLHelper xmlHelper = hc.getXMLHelper(); +/* URL url = getClass().getResource("/quote.xml"); + InputStream inputStream = url.openStream();*/ + XMLDocument doc = xmlHelper.load(xmlStr); + DataObject root = doc.getRootObject(); + + List symbols = root.getList("symbol"); + DataObject symbol = (DataObject)symbols.get(0); + + String seqValue = (String)symbol.getSequence().getValue(0); + assertEquals(seqValue, "fbnt"); + + //String symbol = root.getString("symbol"); + //System.out.println("symbol: " + symbol); + } + + public void testAnyTypeContainer() throws Exception + { + HelperContext hc = SDOUtil.createHelperContext(); + + URL url = getClass().getResource("/simple.xsd"); + InputStream inputStream = url.openStream(); + hc.getXSDHelper().define(inputStream, url.toString()); + + XMLHelper xmlHelper = hc.getXMLHelper(); + url = getClass().getResource("/quoteInSOAP.xml"); + inputStream = url.openStream(); + XMLDocument doc = xmlHelper.load(inputStream); + DataObject root = doc.getRootObject(); + DataObject body = (DataObject)root.getList("Body").get(0); + DataObject stockQuote = (DataObject)body.getList("stockQuote").get(0); + + //xmlHelper.save(stockQuote, stockQuote.getType().getURI(), "stockQuote", System.out); + + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ObjectOutputStream oos = SDOUtil.createObjectOutputStream(bos, hc); + oos.writeObject(stockQuote); + oos.close(); + bos.close(); + + ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray()); + ObjectInputStream ois = SDOUtil.createObjectInputStream(bis, hc); + DataObject objectCopy = (DataObject)ois.readObject(); + ois.close(); + bis.close(); + + assertEquals(objectCopy.getString("symbol"), "fbnt"); + + //xmlHelper.save(objectCopy, stockQuote.getType().getURI(), "stockQuote", System.out); + } + + protected void setUp() throws Exception + { + super.setUp(); + + hc = SDOUtil.createHelperContext(); + th = hc.getTypeHelper(); + } +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/DotNameTest.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/DotNameTest.java new file mode 100644 index 0000000000..476f34c328 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/DotNameTest.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.test; + + +import java.io.IOException; +import java.io.InputStream; +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.HelperContext; +import commonj.sdo.helper.TypeHelper; + + +public class DotNameTest extends TestCase { + private final String TEST_MODEL = "/dotNames.xsd"; + private final String TEST_NAMESPACE = "http://www.example.com/dotNames"; + private HelperContext hc; + private TypeHelper th; + private DataFactory df; + + /** + * Simple Dynamic SDO 2 test. + */ + public void testDynamic() throws IOException { + Type quoteType = th.getType(TEST_NAMESPACE, "DotNameType"); + DataObject quote = df.create(quoteType); + + + quote.getList("property.2.1").add(TEST_NAMESPACE); + assertTrue(quote.isSet("property.2.1")); + assertSame(quote.get("property.2.1.0"), TEST_NAMESPACE); + quote.getList("foo.bar").add(TEST_NAMESPACE); + assertTrue(quote.isSet("foo.bar")); + assertSame(quote.get("foo.bar.0"), TEST_NAMESPACE); + } + + + protected void setUp() throws Exception { + super.setUp(); + + // Populate the meta data for the test (Stock Quote) model + URL url = getClass().getResource(TEST_MODEL); + hc = SDOUtil.createHelperContext(); + th = hc.getTypeHelper(); + df = hc.getDataFactory(); + + InputStream inputStream = url.openStream(); + hc.getXSDHelper().define(inputStream, url.toString()); + inputStream.close(); + + + } + +} \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/DynamicTypesComparisonTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/DynamicTypesComparisonTestCase.java new file mode 100644 index 0000000000..1a9deaf775 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/DynamicTypesComparisonTestCase.java @@ -0,0 +1,256 @@ +/** + * + * 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.util.ArrayList; +import java.util.List; + +import junit.framework.TestCase; + +import org.apache.tuscany.sdo.util.SDOUtil; + +import commonj.sdo.DataObject; +import commonj.sdo.Sequence; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XMLDocument; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; + +/** + * Test to compare data objects created with SDO API with one created from XML + */ +public class DynamicTypesComparisonTestCase extends TestCase { + private final String COMMONJ_SDO = "commonj.sdo"; + + private final String DYNAMIC_ROOT_TYPE_0 = "TestType0"; + + private final String DYNAMIC_TYPES_SCHEMA_STRING = "\n" + "\n" + " \n" + + " \n" + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + " \n" + " \n" + + " \n" + " \n" + "\n"; + + private final String DYNAMIC_TYPES_URI = "http://www.example.com/dynamicTypesFromSchemaSimple"; + + private final String SDO_FROM_API_AND_DYN = "object created with API with dynamic type "; + + private final String SDO_FROM_API_AND_REF = "object created with API with type from XSD"; + + private final String SDO_FROM_XML_AND_REF = "object created with XML with type from XSD"; + + private final String TEST_XML_DOC_0_STRING = "\n" + + "\n" + + " This is a repeated string.\n" + " This is a repeated string.\n" + + " true\n" + " false\n" + " true\n" + + " 1\n" + " 0\n" + " 0\n" + + " 12.5\n" + " 0\n" + "\n"; + + private void comparePropertyObjects(String propName, String name1, String name2, Object propObj1, Object propObj2) { + if (propObj1 == null) { + if (propObj2 != null) { + localFail("property " + propName + " for " + name1 + " was null but " + name2 + " was '" + propObj2 + + "'"); + } + } else if (propObj2 == null) { + localFail("property " + propName + " for " + name2 + " was null but " + name1 + " was '" + propObj1 + "'"); + } else { + if (!propObj1.equals(propObj2)) { + localFail("property " + propName + " for " + name1 + " was '" + propObj1 + "' but " + name2 + " was '" + + propObj2 + "'"); + } + } + } + + private void compareSequencesIgnoringWhitespace(String name1, String name2, Sequence sequence1, Sequence sequence2) { + if (sequence1 == null) { + if (sequence2 != null) { + localFail("sequence for " + name1 + " was null but " + name2 + " was not null"); + } + } else if (sequence2 == null) { + localFail("sequence for " + name2 + " was null but " + name1 + " was not null"); + } else { + List trimmedSeq1 = new ArrayList(); + List trimmedSeq2 = new ArrayList(); + trimWhitespaceFromSequence(trimmedSeq1, sequence1); + trimWhitespaceFromSequence(trimmedSeq2, sequence2); + int size1 = trimmedSeq1.size(); + int size2 = trimmedSeq2.size(); + if (size1 != size2) { + localFail("lengths of trimmed sequences differ: " + name1 + " was " + size1 + ", " + name2 + " was " + + size2); + } else { + Object[] objArr1 = trimmedSeq1.toArray(); + Object[] objArr2 = trimmedSeq2.toArray(); + for (int i = 0; i < size1; i++) { + Object obj1 = objArr1[i]; + Object obj2 = objArr2[i]; + if (obj1 == null) { + if (obj2 != null) { + localFail("sequence for " + name1 + " had null element for which " + name2 + " had '" + obj2 + + "'"); + } + } else if (obj2 == null) { + localFail("sequence for " + name2 + " had null element for which " + name1 + " had '" + obj1 + "'"); + } else { + if (!obj1.equals(obj2)) { + localFail("sequences did not match: " + name1 + " had '" + obj1 + "' but " + name2 + " had '" + + obj2 + "'"); + } + } + } + } + } + } + + private void getAndCompareProperties(String propName, DataObject xmlAndRefTypDO, DataObject apiAndDynTypDO, + DataObject apiAndRefTypDO) { + Object xmlRefProperty = xmlAndRefTypDO.get(propName); + Object apiDynProperty = apiAndDynTypDO.get(propName); + Object apiRefProperty = apiAndRefTypDO.get(propName); + comparePropertyObjects(propName, SDO_FROM_XML_AND_REF, SDO_FROM_API_AND_DYN, xmlRefProperty, apiDynProperty); + comparePropertyObjects(propName, SDO_FROM_XML_AND_REF, SDO_FROM_API_AND_REF, xmlRefProperty, apiRefProperty); + } + + private void localFail(String message) { + // System.err.println(message); + fail(message); + } + + protected void setUp() throws Exception { + super.setUp(); + } + + private void specifyProperty(DataObject containingTypeDO, String nameString, Type typ, boolean isMany) { + DataObject subordinateProperty = containingTypeDO.createDataObject("property"); + subordinateProperty.set("name", nameString); + subordinateProperty.set("type", typ); + subordinateProperty.setBoolean("many", isMany); + } + + /** + * test #0 of Data Object primitive datatypes + */ + public void testDynamicTypesGroup0DO() throws IOException { + HelperContext hcDO = SDOUtil.createHelperContext(); + + TypeHelper thDO = hcDO.getTypeHelper(); + DataFactory dfDO = hcDO.getDataFactory(); + + // create a container object type + DataObject containerTypeDO = dfDO.create("commonj.sdo", "Type"); + containerTypeDO.set("uri", DYNAMIC_TYPES_URI); + containerTypeDO.set("name", DYNAMIC_ROOT_TYPE_0); + containerTypeDO.set("sequenced", Boolean.TRUE); + + specifyProperty(containerTypeDO, "aString", thDO.getType(COMMONJ_SDO, "String"), true); + specifyProperty(containerTypeDO, "aBoolean", thDO.getType(COMMONJ_SDO, "Boolean"), true); + specifyProperty(containerTypeDO, "aFloat", thDO.getType(COMMONJ_SDO, "Float"), true); + + Type containerType = thDO.define(containerTypeDO); + assertNotNull(containerType); + + DataObject doFromApiAndDynTyp = dfDO.create(containerType); + assertNotNull(doFromApiAndDynTyp); + doFromApiAndDynTyp.getList("aString").add("This is a repeated string."); + doFromApiAndDynTyp.getList("aString").add("This is a repeated string."); + doFromApiAndDynTyp.getList("aBoolean").add(new Boolean(true)); + doFromApiAndDynTyp.getList("aBoolean").add(new Boolean(false)); + doFromApiAndDynTyp.getList("aBoolean").add(new Boolean(true)); + doFromApiAndDynTyp.getList("aBoolean").add(new Boolean(true)); + doFromApiAndDynTyp.getList("aBoolean").add(new Boolean(false)); + doFromApiAndDynTyp.getList("aFloat").add(new Float(0)); + doFromApiAndDynTyp.getList("aFloat").add(new Float(12.5)); + doFromApiAndDynTyp.getList("aFloat").add(new Float(0)); + + Type rootType = thDO.getType(DYNAMIC_TYPES_URI, DYNAMIC_ROOT_TYPE_0); + assertNotNull(rootType); + assertSame(containerType, rootType); + + // now load xml to get a reference data object using schema + HelperContext hcRef = SDOUtil.createHelperContext(); + XSDHelper xsdHelper = hcRef.getXSDHelper(); + List typeList = xsdHelper.define(DYNAMIC_TYPES_SCHEMA_STRING); + assertNotNull(typeList); + TypeHelper thRef = hcRef.getTypeHelper(); + Type rootTypeRef = thRef.getType(DYNAMIC_TYPES_URI, DYNAMIC_ROOT_TYPE_0); + + assertNotNull(rootTypeRef); + + XMLHelper xhRef = hcRef.getXMLHelper(); + // XMLDocument docRef = + // xhRef.load(getClass().getResourceAsStream(TEST_XML_DOC_0)); + XMLDocument docRef = xhRef.load(TEST_XML_DOC_0_STRING); + DataObject doFromXmlAndRefTyp = docRef.getRootObject(); + + assertNotNull(doFromXmlAndRefTyp); + + // create a data object using dynamic API from reference type + DataFactory dfRef = hcRef.getDataFactory(); + DataObject doFromApiAndRefTyp = dfRef.create(rootTypeRef); + assertNotNull(doFromApiAndRefTyp); + doFromApiAndRefTyp.getList("aString").add("This is a repeated string."); + doFromApiAndRefTyp.getList("aString").add("This is a repeated string."); + doFromApiAndRefTyp.getList("aBoolean").add(new Boolean(true)); + doFromApiAndRefTyp.getList("aBoolean").add(new Boolean(false)); + doFromApiAndRefTyp.getList("aBoolean").add(new Boolean(true)); + doFromApiAndRefTyp.getList("aBoolean").add(new Boolean(true)); + doFromApiAndRefTyp.getList("aBoolean").add(new Boolean(false)); + doFromApiAndRefTyp.getList("aFloat").add(new Float(0)); + doFromApiAndRefTyp.getList("aFloat").add(new Float(12.5)); + doFromApiAndRefTyp.getList("aFloat").add(new Float(0)); + + getAndCompareProperties("aString", doFromXmlAndRefTyp, doFromApiAndDynTyp, doFromApiAndRefTyp); + getAndCompareProperties("aBoolean", doFromXmlAndRefTyp, doFromApiAndDynTyp, doFromApiAndRefTyp); + getAndCompareProperties("aFloat", doFromXmlAndRefTyp, doFromApiAndDynTyp, doFromApiAndRefTyp); + Sequence seqFromXmlAndRefTyp = doFromXmlAndRefTyp.getSequence(); + Sequence seqFromApiAndDynTyp = doFromApiAndDynTyp.getSequence(); + Sequence seqFromApiAndRefTyp = doFromApiAndRefTyp.getSequence(); + compareSequencesIgnoringWhitespace(SDO_FROM_XML_AND_REF, SDO_FROM_API_AND_DYN, seqFromXmlAndRefTyp, + seqFromApiAndDynTyp); + compareSequencesIgnoringWhitespace(SDO_FROM_XML_AND_REF, SDO_FROM_API_AND_REF, seqFromXmlAndRefTyp, + seqFromApiAndRefTyp); + } + + private void trimWhitespaceFromSequence(List trimmedSeq, Sequence sequence) { + if (sequence != null) { + for (int i = 0; i < sequence.size(); i++) { + Object obj = sequence.getValue(i); + if (obj instanceof String) { + String str = ((String) obj).trim(); + if (str.length() > 0) { + trimmedSeq.add(str); + } + } else { + trimmedSeq.add(obj); + } + } + } + } +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ExpectedExceptionsTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ExpectedExceptionsTestCase.java new file mode 100644 index 0000000000..7674cda42b --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/ExpectedExceptionsTestCase.java @@ -0,0 +1,1878 @@ +/** + * + * 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 org.apache.tuscany.sdo.util.SDOUtil; + +import com.example.ExpectedException.ExpectedExceptionFactory; + +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Sequence; +import commonj.sdo.Type; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.TypeHelper; + +import junit.framework.TestCase; + +/** + * Verifies the Exception related behavior which is explicitly identified in + * the 2.1 SDO Specification. + */ +public class ExpectedExceptionsTestCase extends TestCase { + + private static final String TEST_URI = "http://example.com/ExpectedException"; + private static final String TEST_TYPE_NAME = "ExpectedExceptionType"; + private static final String SEQ_TYPE_NAME = "SequenceReadOnlyType"; + private static boolean typeDefined = false; + private static HelperContext helperContext; + private static DataObject testDO; + private static DataObject seqDO; + + /** + * Verifies the following statement. + * Get(String path) will not throw exceptions other than ClassCastException + * if it is impossible to convert between the actual and expected types. + * Note: This test case will not be implmented because it is already covered + * by testCannnotConvertClassCastException. + */ + + public void testGetTStringClassCastExceptionOnly() { + // This test case will not be implemented. + } + + /** + * Verifies the following statement. + * get(Property property) throws an IllegalArgumentException when + * getInstanceProperties().contains(property) == false. + */ + public void testGetViaPropertyIllegalArgumentException() { + DataObject invalidPropDO = helperContext.getDataFactory().create(TEST_URI, SEQ_TYPE_NAME); + Property invalidProp = invalidPropDO.getInstanceProperty("uniqueName"); + + try { + testDO.get(invalidProp); + fail("get(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("get(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getBoolean(invalidProp); + fail("getBoolean(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBoolean(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getByte(invalidProp); + fail("getByte(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getByte(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getChar(invalidProp); + fail("getChar(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getChar(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getDouble(invalidProp); + fail("getDouble(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getDouble(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getFloat(invalidProp); + fail("getFloat(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getFloat(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getInt(invalidProp); + fail("getInt(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getInt(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getLong(invalidProp); + fail("getLong(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getLong(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getShort(invalidProp); + fail("getShort(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getShort(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getBytes(invalidProp); + fail("getBytes(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBytes(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getBigDecimal(invalidProp); + fail("getBigDecimal(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBigDecimal(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getBigInteger(invalidProp); + fail("getBigInteger(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBigInteger(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getDataObject(invalidProp); + fail("getDataObject(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getDataObject(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getDate(invalidProp); + fail("getDate(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getDate(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getString(invalidProp); + fail("getString(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getString(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getList(invalidProp); + fail("getList(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(propert)== false. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getList(Property property) should throw an IllegalArgumentException when getInstanceProperties().contains(property)== false. " + e.getClass().getName() + " was thrown."); + } + } + + /** + * Verfies the following statement. + * get(int propertyIndex) throws an IllegalArgumentException when + * propertIndex <0 or >= getInstanceProerties().size() + */ + public void testGetViaIndexIllegalArgumentException() { + int numProps = testDO.getInstanceProperties().size(); + + try { + testDO.get(-1); + fail("get(-1) should throw an IllegalArgumentException. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("get(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getBoolean(-1); + fail("getBoolean(-1) should throw an IllegalArgumentException. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBoolean(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getByte(-1); + fail("getByte(-1) should throw an IllegalArgumentException. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getByte(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getChar(-1); + fail("getChar(-1) should throw an IllegalArgumentException. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getChar(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getDouble(-1); + fail("getDouble(-1) should throw an IllegalArgumentException. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getDouble(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getFloat(-1); + fail("getFloat(-1) should throw an IllegalArgumentException. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getFloat(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getInt(-1); + fail("getInt(-1) should throw an IllegalArgumentException. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getInt(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getLong(-1); + fail("getLong(-1) should throw an IllegalArgumentException. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getLong(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getShort(-1); + fail("getShort(-1) should throw an IllegalArgumentException. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getShort(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getBytes(-1); + fail("getBytes(-1) should throw an IllegalArgumentException. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBytes(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getBigDecimal(-1); + fail("getBigDecimal(-1) should throw an IllegalArgumentException. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBigDecimal(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getBigInteger(-1); + fail("getBigInteger(-1) should throw an IllegalArgumentException. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBigInteger(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getDataObject(-1); + fail("getDataObject(-1) should throw an IllegalArgumentException. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getDataObject(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getDate(-1); + fail("getDate(-1) should throw an IllegalArgumentException. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getDate(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getString(-1); + fail("getString(-1) should throw an IllegalArgumentException. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getString(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getList(-1); + fail("getList(-1) should throw an IllegalArgumentException. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getList(-1) should throw an IllegalArgumentException. " + e.getClass().getName() + " was thrown."); + } + + try { + testDO.get(numProps); + fail("get(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("get(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getBoolean(numProps); + fail("getBoolean(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBoolean(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getByte(numProps); + fail("getByte(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getByte(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getChar(numProps); + fail("getChar(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getChar(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getDouble(numProps); + fail("getDouble(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getDouble(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getFloat(numProps); + fail("getFloat(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getFloat(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getInt(numProps); + fail("getInt(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getInt(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getLong(numProps); + fail("getLong(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getLong(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getShort(numProps); + fail("getShort(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getShort(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getBytes(numProps); + fail("getBytes(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBytes(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getBigDecimal(numProps); + fail("getBigDecimal(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBigDecimal(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getBigInteger(numProps); + fail("getBigInteger(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBigInteger(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getDataObject(numProps); + fail("getDataObject(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getDataObject(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getDate(numProps); + fail("getDate(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getDate(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getString(numProps); + fail("getString(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getString(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getList(numProps); + fail("getList(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("getList(int) should throw an IllegalArgumentException when int >= getInstanceProperties.size(). " + e.getClass().getName() + " was thrown."); + } + } + + /** + * Verifies the following statement. + * Using an Index out of range (index < 0 or >= getList(Property property).size()) + * will result in an IndexOutOfBoundsException. + */ + public void testListIndexOutOfBoundsException() { + List list = testDO.getList("listVal"); + +// Not fixed in TUSCANY-578 +// try { +// list.get(-1); +// fail("list.get(-1) should throw an IndexOutOfBoundsException. No Exception was thrown."); +// } catch (IndexOutOfBoundsException e) { +// // Success - do nothing +// } catch (Exception e) { +// fail("list.get(-1) should throw an IndexOutOfBoundsException. " + e.getClass().getName() + " was thrown."); +// } +// try { +// list.get(list.size()); +// fail("list.get(int) should throw an IndexOutOfBoundsException when int >= list.size(). No Exception was thrown."); +// } catch (IndexOutOfBoundsException e) { +// // Success - do nothing +// } catch (Exception e) { +// fail("list.get(int) should throw an IndexOutOfBoundsException when int >= list.size(). " + e.getClass().getName() + " was thrown."); +// } +// try { +// list.remove(-1); +// fail("list.remove(-1) should throw an IndexOutOfBoundsException. No Exception was thrown."); +// } catch (IndexOutOfBoundsException e) { +// // Success - do nothing +// } catch (Exception e) { +// fail("list.remove(-1) should throw an IndexOutOfBoundsException. " + e.getClass().getName() + " was thrown."); +// } + try { + list.remove(list.size()); + fail("list.remove(int) should throw an IndexOutOfBoundsException when int >= list.size(). No Exception was thrown."); + } catch (IndexOutOfBoundsException e) { + // Success - do nothing + } catch (Exception e) { + fail("list.remove(int) should throw an IndexOutOfBoundsException when int >= list.size(). " + e.getClass().getName() + " was thrown."); + } + } + + /** + * Verifies the following statement. + * Modification of a read-only property results in UnsupportedOperationException. + * This test case is for modifications done through the DataObject API. + */ + public void testModifyReadOnlyUnsupportedOperationException() { + Property readOnlyProp = testDO.getInstanceProperty("readOnlyVal"); + List properties = testDO.getInstanceProperties(); + Property currProp; + int readOnlyIndex = -1, i = 0, size = properties.size(); + + // Verify the precondition + assertTrue("readOnlyVal should be read-only.", readOnlyProp.isReadOnly()); + + while (readOnlyIndex < 0 && i < size) { + currProp = (Property) properties.get(i); + if (currProp.equals(readOnlyProp)) + readOnlyIndex = i; + i++; + } + + try { + testDO.set("readOnlyVal", "NewValue"); + fail("DataObject.set(string, value) should throw an UnsupportedOperationException when the Property represented by string is read-only. No Exception was thrown."); + } catch (UnsupportedOperationException e) { + // Success - do nothing + } catch (Exception e) { + fail("DataObject.set(string, value) should throw an UnsupportedOperationException when the Property represented by string is read-only. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.set(readOnlyProp, "NewValue"); + System.out.println("propname =" + readOnlyProp.getName()); + fail("DataObject.set(property, value) should throw an UnsupportedOperationException when the Property represented by property is read-only. No Exception was thrown."); + } catch (UnsupportedOperationException e) { + // Success - do nothing + } catch (Exception e) { + fail("DataObject.set(property, value) should throw an UnsupportedOperationException when the Property represented by property is read-only. " + e.getClass().getName() + " was thrown."); + } + assertTrue("The test case could not procede because the index of the read only Property was not found.", readOnlyIndex > -1); + try { + testDO.set(readOnlyIndex, "NewValue"); + fail("DataObject.set(index, value) should throw an UnsupportedOperationException when the Property represented by index is read-only. No Exception was thrown."); + } catch (UnsupportedOperationException e) { + // Success - do nothing + } catch (Exception e) { + fail("DataObject.set(index, value) should throw an UnsupportedOperationException when the Property represented by index is read-only. " + e.getClass().getName() + " was thrown."); + } + + try { + testDO.unset("readOnlyVal"); + fail("DataObject.unset(string) should throw an UnsupportedOperationException when the Property represented by string is read-only. No Exception was thrown."); + } catch (UnsupportedOperationException e) { + // Success - do nothing + } catch (Exception e) { + fail("DataObject.unset(string) should throw an UnsupportedOperationException when the Property represented by string is read-only. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.unset(readOnlyProp); + fail("DataObject.unset(property) should throw an UnsupportedOperationException when the Property represented by property is read-only. No Exception was thrown."); + } catch (UnsupportedOperationException e) { + // Success - do nothing + } catch (Exception e) { + fail("DataObject.unset(property) should throw an UnsupportedOperationException when the Property represented by property is read-only. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.unset(readOnlyIndex); + fail("DataObject.unset(index) should throw an UnsupportedOperationException when the Property represented by index is read-only. No Exception was thrown."); + } catch (UnsupportedOperationException e) { + // Success - do nothing + } catch (Exception e) { + fail("DataObject.unset(index) should throw an UnsupportedOperationException when the Property represented by index is read-only. " + e.getClass().getName() + " was thrown."); + } + } + + /** + * Verifies the following statement. + * Modification of a read-only property results in UnsupportedOperationException. + * This test case is for modification done through the List API. + */ + public void testModifyReadOnlyUnsupportedOperationExceptionList() { + Property readOnlyProp = testDO.getInstanceProperty("readOnlyVal"); + List properties = testDO.getInstanceProperties(); + Property currProp; + int readOnlyIndex = -1, i = 0, size = properties.size(); + + while (readOnlyIndex < 0 && i < size) { + currProp = (Property) properties.get(i); + if (currProp.equals(readOnlyProp)) + readOnlyIndex = i; + i++; + } + +// Not fixed in TUSCANY-578 +// try { +// List temp = testDO.getList("readOnlyListVal"); +// temp.add("String to add."); +// fail("DataObject.getList(path).add(value) should throw an UnsupportedOperationException when the Property represented by path is read-only. No Exception was thrown."); +// } catch (UnsupportedOperationException e) { +// // Success - do nothing +// } catch (Exception e) { +// fail("DataObject.getList(path).add(value) should throw an IllegalArgumentException when the Property represented by path is read-only. " + e.getClass().getName() + " was thrown."); +// } +// try { +// Sequence temp = testDO.getSequence(); +// temp.add("readOnlyListVal", "String to add."); +// fail("DataObject.getSequence().add(path, value) should throw an UnsupportedOperationException when the Property represtend by path is read-only. No Exception was thrown."); +// } catch (UnsupportedOperationException e) { +// // Success - do nothing +// } catch (Exception e) { +// fail("DataObject.getSequence().add(path, value) should throw an UnsupportedOperationException when the Property represtend by path is read-only. " + e.getClass().getName() + " was thrown."); +// } + } + + /** + * Verifies the following statement. + * Modification of a read-only property results in UnsupportedOperationException. + * This test case is for modification done through the List API. + */ + public void testModifyReadOnlyUnsupportedOperationExceptionSequence() { + Property readOnlyProp = seqDO.getInstanceProperty("readOnlyVal"); + List properties = seqDO.getInstanceProperties(); + Property currProp; + int readOnlyIndex = -1, i = 0, size = properties.size(); + + while (readOnlyIndex < 0 && i < size) { + currProp = (Property) properties.get(i); + if (currProp.equals(readOnlyProp)) + readOnlyIndex = i; + i++; + } + +// Not fixed in TUSCANY-578 +// try { +// Sequence sequence = seqDO.getSequence(); +// sequence.add(readOnlyProp, "New Value"); +// fail("Sequence.add(property, value) should throw an UnsupportedOperationException when the Property represented by property is read-only. No Exception was thrown."); +// } catch (UnsupportedOperationException e) { +// // Success - do nothing +// } catch (Exception e) { +// fail("Sequence.add(property, value) should throw an UnsupportedOperationException when the Property represented by property is read-only. " + e.getClass().getName() + " was thrown."); +// } + } + + /** + * Verifies the following statement. + * A ClassCastException results when cannot convert between value and requested Type. + */ + + public void testCannotConvertClassCastException() { + // Attempt conversion from boolean + + try { + testDO.getByte("booleanVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getChar("booleanVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getDouble("booleanVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getFloat("booleanVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getInt("booleanVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getLong("booleanVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getShort("booleanVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getBytes("booleanVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getBigDecimal("booleanVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getBigInteger("booleanVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getDate("booleanVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + + // Attempt conversion from byte + try { + testDO.getBoolean("byteVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getChar("byteVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getBigDecimal("byteVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getBigInteger("byteVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getDate("byteVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getBytes("byteVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + // Attempt conversion from character + try { + testDO.getBoolean("charVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getByte("charVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getDouble("charVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getFloat("charVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getInt("charVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getLong("charVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getShort("charVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getBytes("charVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getBigDecimal("charVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getBigInteger("charVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getDate("charVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + +// Attempt conversion from double + try { + testDO.getBoolean("doubleVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getChar("doubleVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getBytes("doubleVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getDate("doubleVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + +// Attempt conversion from float + try { + testDO.getBoolean("floatVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getChar("floatVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getBytes("floatVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getDate("floatVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + +// Attempt conversion from int + try { + testDO.getBoolean("intVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getChar("intVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getBytes("intVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getDate("intVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + +// Attempt conversion from long + try { + testDO.getBoolean("longVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getChar("longVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getBytes("longVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + +// Attempt conversion from short + try { + testDO.getBoolean("shortVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getChar("shortVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getBytes("shortVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getBigDecimal("shortVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getBigInteger("shortVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getDate("shortVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + +// Attempt conversion from bytes + try { + testDO.getBoolean("bytesVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getByte("bytesVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getChar("bytesVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getDouble("bytesVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getFloat("bytesVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getInt("bytesVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getLong("bytesVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getShort("bytesVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getBigDecimal("bytesVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getDate("bytesVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + +// Attempt conversion from decimal + try { + testDO.getBoolean("decimalVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getByte("decimalVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getChar("decimalVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getShort("decimalVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getBytes("decimalVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getDate("decimalVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + +// Attempt conversion from BigInteger + try { + testDO.getBoolean("integerVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getByte("integerVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getChar("integerVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getShort("integerVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getDate("integerVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + +// Attempt conversion from date + try { + testDO.getBoolean("dateVal"); + } catch (ClassCastException e) { + // success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getByte("dateVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getChar("dateVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getDouble("dateVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getFloat("dateVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getInt("dateVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getShort("dateVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getBytes("dateVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getBigDecimal("dateVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + try { + testDO.getBigInteger("dateVal"); + } catch (ClassCastException e) { +// success - do nothing + } catch (Exception e) { + fail("Attempted implicit unsupported conversion did not throw the correct Exception. Expected: ClassCastException. Received: " + e.getClass().getName()); + } + } + + + /** + * Verifies the following statement. + * Mixing single-valued and multi-valued Property access results in + * ClassCastException. + */ + public void testMixSingleMultiValueClassCastException() { + Property testedProp = testDO.getInstanceProperty("intVal"); + List properties = testDO.getInstanceProperties(); + Property currProp; + int testedIndex = -1, i = 0, size = properties.size(); + + while (testedIndex < 0 && i < size) { + currProp = (Property) properties.get(i); + + if (currProp.equals(testedProp)) + testedIndex = i; + i++; + } + + try { + testDO.getList("intVal"); + fail("getList(string) should throw a ClassCastException when the property represented by string is single-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getList(string) should throw a ClassCastException when the property represented by string is single-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getList(testedProp); + fail("getList(property) should throw a ClassCastException when the property represented by property is single-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getList(property) should throw a ClassCastException when the property represented by property is single-valued. " + e.getClass().getName() + " was thrown."); + } + + assertTrue("The test case could not procede because the index of the single-valued Property was not found.", testedIndex > -1); + + try { + testDO.getList(testedIndex); + fail("getList(index) should throw a ClassCastException when the property represented by index is single-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getList(index) should throw a ClassCastException when the property represented by index is single-valued. " + e.getClass().getName() + " was thrown."); + } + + testedProp = testDO.getInstanceProperty("listVal"); + testedIndex = -1; + i = 0; + while (testedIndex < 0 && i < size) { + currProp = (Property) properties.get(i); + if (currProp.equals(testedProp)) + testedIndex = i; + i++; + } + + try { + testDO.getBoolean("listVal"); + fail("getBoolean(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBoolean(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getByte("listVal"); + fail("getByte(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getByte(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getChar("listVal"); + fail("getChar(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getChar(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getDouble("listVal"); + fail("getDouble(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getDouble(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getFloat("listVal"); + fail("getFloat(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getFloat(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getInt("listVal"); + fail("getInt(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getInt(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getLong("listVal"); + fail("getLong(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getLong(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getShort("listVal"); + fail("getShort(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getShort(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getBytes("listVal"); + fail("getBytes(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBytes(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getBigDecimal("listVal"); + fail("getBigDecimal(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBigDecimal(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getBigInteger("listVal"); + fail("getBigInteger(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBigInteger(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getDataObject("listVal"); + fail("getDataObject(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getDataObject(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getDate("listVal"); + fail("getDate(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getDate(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getString("listVal"); + fail("getString(string) should throw a ClassCastException when the property represented by string is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getString(string) should throw a ClassCastException when the property represented by string is multi-valued. " + e.getClass().getName() + " was thrown."); + } + + try { + testDO.getBoolean(testedProp); + fail("getBoolean(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBoolean(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getByte(testedProp); + fail("getByte(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getByte(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getChar(testedProp); + fail("getChar(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getChar(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getDouble(testedProp); + fail("getDouble(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getDouble(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getFloat(testedProp); + fail("getFloat(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getFloat(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getInt(testedProp); + fail("getInt(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getInt(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getLong(testedProp); + fail("getLong(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getLong(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getShort(testedProp); + fail("getShort(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getShort(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getBytes(testedProp); + fail("getBytes(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBytes(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getBigDecimal(testedProp); + fail("getBigDecimal(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBigDecimal(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getBigInteger(testedProp); + fail("getBigInteger(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBigInteger(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getDataObject(testedProp); + fail("getDataObject(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getDataObject(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getDate(testedProp); + fail("getDate(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getDate(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getString(testedProp); + fail("getString(property) should throw a ClassCastException when the property represented by property is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getString(property) should throw a ClassCastException when the property represented by property is multi-valued. " + e.getClass().getName() + " was thrown."); + } + + assertTrue("The test case could not procede because the index of the multi-valued Property was not found.", testedIndex > -1); + + try { + testDO.getBoolean(testedIndex); + fail("getBoolean(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBoolean(index) should throw a ClassCastException when the property represented by is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getByte(testedIndex); + fail("getByte(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getByte(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getChar(testedIndex); + fail("getChar(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getChar(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getDouble(testedIndex); + fail("getDouble(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getDouble(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getFloat(testedIndex); + fail("getFloat(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getFloat(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getInt(testedIndex); + fail("getInt(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getInt(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getLong(testedIndex); + fail("getLong(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getLong(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getShort(testedIndex); + fail("getShort(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getShort(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getBytes(testedIndex); + fail("getBytes(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBytes(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getBigDecimal(testedIndex); + fail("getBigDecimal(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBigDecimal(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getBigInteger(testedIndex); + fail("getBigInteger(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getBigInteger(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getDataObject(testedIndex); + fail("getDataObject(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getDataObject(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getDate(testedIndex); + fail("getDate(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getDate(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown."); + } + try { + testDO.getString(testedIndex); + fail("getString(index) should throw a ClassCastException when the property represented by index is multi-valued. No Exception was thrown."); + } catch (ClassCastException e) { + // Success - do nothing + } catch (Exception e) { + fail("getString(index) should throw a ClassCastException when the property represented by index is multi-valued. " + e.getClass().getName() + " was thrown."); + } + } + + /* + /** + * Verifies the following statement. + * Establishing circular containment results in an IllegalArgumentException. + * Note: This test case will not be implemented because it has been determined + * that the statement will be removed from the spec. + */ + /* + public void testContainmentCycleIllegalArgumentException() { + // This test case will not be implemented. + } + */ + + /** + * Verifies the following statement. + * An empty DataGraph can have a root assigned by the createRootObject() methods. + * However, if a previous root DataObject exists than an IllegalStateException is + * thrown. + */ + public void testCreateRootObjectAgainIllegalStateException() { + DataGraph dataGraph = SDOUtil.createDataGraph(); + Type type = testDO.getType(); + + // verify the initial condition + assertNull("The DataGraph should have been created without a root DataObject.", dataGraph.getRootObject()); + assertNotNull("DataObject.getType() returned null.", type); + + dataGraph.createRootObject(type); + + // verify the pre-condition + assertNotNull("The DataGraph.createRootObject() should have created a root DataObject for the DataGraph.", dataGraph.getRootObject()); + + try { + dataGraph.createRootObject(type); + fail("DataGraph.createRootObject(Type) should throw an IllegalStateException a root Object already exists for the DataGraph. No Exception was thrown."); + } catch (IllegalStateException e) { + // Success - do nothing + } catch (Exception e) { + fail("DataGraph.createRootObject(Type) should throw an IllegalStateException a root Object already exists for the DataGraph. " + e.getClass().getName() + " was thrown."); + } + } + + /** + * Verifies the following statement. + * DataFactory.create() throws an IllegalArgumentException if the instanceClass does + * not correspond to a Type this factory can instantiate. + */ + public void testDataFactoryCreateIllegalArgumentException() { + try { + helperContext.getDataFactory().create(java.lang.Object.class); + fail("DataFactory.create(Object) should throw an IllegalArgumentException when it cannot instantiate the Type specified. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("DataFactory.create(Object) should throw an IllegalArgumentException when it cannot instantiate the Type specified. " + e.getClass().getName() + " was thrown."); + } + + try { + helperContext.getDataFactory().create(commonj.sdo.DataObject.class); + fail("DataFactory.create(DataObject) should throw an IllegalArgumentException when it cannot instantiate the Type specified. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("DataFactory.create(DataObject) should throw an IllegalArgumentException when it cannot instantiate the Type specified. " + e.getClass().getName() + " was thrown."); + } + + try { + helperContext.getDataFactory().create(commonj.sdo.ChangeSummary.class); + fail("DataFactory.create(ChangeSummary) should throw an IllegalArgumentException when it cannot instantiate the Type specified. No Exception was thrown."); + } catch (IllegalArgumentException e) { + // Success - do nothing + } catch (Exception e) { + fail("DataFactory.create(ChangeSummary) should throw an IllegalArgumentException when it cannot instantiate the Type specified. " + e.getClass().getName() + " was thrown."); + } + } + + /** + * Defines the Type the first time through. + */ + public void setUp() { + if (!typeDefined) { + helperContext = SDOUtil.createHelperContext(); +// createWithXSD(helperContext); +// createDynamically(helperContext); + createStatically(helperContext); + typeDefined = true; + } +// testDO = helperContext.getDataFactory().create(TEST_URI, TEST_TYPE_NAME); +// seqDO = helperContext.getDataFactory().create(TEST_URI, SEQ_TYPE_NAME); + testDO = (DataObject) ExpectedExceptionFactory.INSTANCE.createExpectedExceptionType(); + seqDO = (DataObject) ExpectedExceptionFactory.INSTANCE.createSequenceReadOnlyType(); + } + + public static void createStatically(HelperContext hc) { + ExpectedExceptionFactory.INSTANCE.register(hc); + } + + public static void createWithXSD(HelperContext hc) { + // Populate the meta data for the test model + URL url = ExpectedExceptionsTestCase.class.getResource("/expectedExceptions.xsd"); + try { + InputStream inputStream = url.openStream(); + hc.getXSDHelper().define(inputStream, url.toString()); + inputStream.close(); + } catch(IOException e) { + e.printStackTrace(); + } + } + + /** + * createDynamically() creates the SDO Types using the TypeHelper. This + * method should be kept in synch with the XSD used for + * createDynamicallyWithStaticResources. The same XSD is used for the static + * generation of SDO Types using XSD2JavaGenerator. + */ + public static void createDynamically(HelperContext hc) { + + TypeHelper types = hc.getTypeHelper(); + Type stringType = types.getType("commonj.sdo", "String"); + Type intType = types.getType("commonj.sdo", "Int"); + Type booleanType = types.getType("commonj.sdo", "Boolean"); + Type byteType = types.getType("commonj.sdo", "Byte"); + Type decimalType = types.getType("commonj.sdo", "Decimal"); + Type floatType = types.getType("commonj.sdo", "Float"); + Type doubleType = types.getType("commonj.sdo", "Double"); + Type dateType = types.getType("commonj.sdo", "Date"); + Type shortType = types.getType("commonj.sdo", "Short"); + Type longType = types.getType("commonj.sdo", "Long"); + Type bytesType = types.getType("commonj.sdo", "Bytes"); + Type integerType = types.getType("commonj.sdo", "Integer"); + Type charType = types.getType("commonj.sdo", "Character"); + + DataObject testType = hc.getDataFactory().create("commonj.sdo", "Type"); + testType.set("uri", TEST_URI); + testType.set("name", TEST_TYPE_NAME); + + DataObject stringProperty = testType.createDataObject("property"); + stringProperty.set("name", "stringVal"); + stringProperty.set("type", stringType); + + DataObject booleanProperty = testType.createDataObject("property"); + booleanProperty.set("name", "booleanVal"); + booleanProperty.set("type", booleanType); + + DataObject byteProperty = testType.createDataObject("property"); + byteProperty.set("name", "byteVal"); + byteProperty.set("type", byteType); + + DataObject decimalProperty = testType.createDataObject("property"); + decimalProperty.set("name", "decimalVal"); + decimalProperty.set("type", decimalType); + + DataObject intProperty = testType.createDataObject("property"); + intProperty.set("name", "intVal"); + intProperty.set("type", intType); + + DataObject floatProperty = testType.createDataObject("property"); + floatProperty.set("name", "floatVal"); + floatProperty.set("type", floatType); + + DataObject doubleProperty = testType.createDataObject("property"); + doubleProperty.set("name", "doubleVal"); + doubleProperty.set("type", doubleType); + + DataObject dateProperty = testType.createDataObject("property"); + dateProperty.set("name", "dateVal"); + dateProperty.set("type", dateType); + + DataObject shortProperty = testType.createDataObject("property"); + shortProperty.set("name", "shortVal"); + shortProperty.set("type", shortType); + + DataObject longProperty = testType.createDataObject("property"); + longProperty.set("name", "longVal"); + longProperty.set("type", longType); + + DataObject childrenProperty = testType.createDataObject("property"); + childrenProperty.set("name", "listVal"); + childrenProperty.setBoolean("many", true); + childrenProperty.set("type", stringType); + + DataObject bytesProperty = testType.createDataObject("property"); + bytesProperty.set("name", "bytesVal"); + bytesProperty.set("type", bytesType); + + DataObject integerProperty = testType.createDataObject("property"); + integerProperty.set("name", "integerVal"); + integerProperty.set("type", integerType); + + DataObject charProperty = testType.createDataObject("property"); + charProperty.set("name", "charVal"); + charProperty.set("type", charType); + + DataObject readOnlyProperty = testType.createDataObject("property"); + readOnlyProperty.set("name", "readOnlyVal"); + readOnlyProperty.set("type", stringType); + readOnlyProperty.setBoolean("readOnly", true); + + DataObject readOnlyListProperty = testType.createDataObject("property"); + readOnlyListProperty.set("name", "readOnlyListVal"); + readOnlyListProperty.set("type", stringType); + readOnlyListProperty.setBoolean("readOnly", true); + readOnlyListProperty.setBoolean("many", true); + + types.define(testType); + + DataObject seqType = hc.getDataFactory().create("commonj.sdo", "Type"); + seqType.set("uri", TEST_URI); + seqType.set("name", SEQ_TYPE_NAME); + seqType.setBoolean("sequenced", true); + + DataObject seqROProperty = seqType.createDataObject("property"); + seqROProperty.set("name", "readOnlyVal"); + seqROProperty.set("type", stringType); + seqROProperty.setBoolean("readOnly", true); + + DataObject seqROListProperty = seqType.createDataObject("property"); + seqROListProperty.set("name", "readOnlyListVal"); + seqROListProperty.set("type", stringType); + seqROListProperty.setBoolean("readOnly", true); + seqROListProperty.setBoolean("many", true); + + DataObject uniqueNameProperty = seqType.createDataObject("property"); + uniqueNameProperty.set("name", "uniqueName"); + uniqueNameProperty.set("type", stringType); + + types.define(seqType); + } +} \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/FormTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/FormTestCase.java new file mode 100644 index 0000000000..e630a8f903 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/FormTestCase.java @@ -0,0 +1,112 @@ +/** + * + * 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.StringReader; +import java.util.HashMap; +import java.util.Map; + +import junit.framework.TestCase; + +import org.apache.tuscany.sdo.util.SDOUtil; +import org.eclipse.emf.ecore.resource.Resource; + +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.XMLHelper; + +public class FormTestCase extends TestCase { + XMLHelper xmlHelper; + Map options; + + protected void setUp() throws Exception { + super.setUp(); + HelperContext hc = SDOUtil.createHelperContext(); + hc.getXSDHelper().define( +""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ +""); + xmlHelper = hc.getXMLHelper(); + options = new HashMap(); + /* + * turn off default behaviour of tolerating malformed xml + * tests using this option and bad xml should demonstrate failure to load + */ + options.put(SDOUtil.XML_LOAD_LaxForm, new Integer(0)); + } + + void load(String xml, Object options) throws IOException { + assertNotNull(xmlHelper.load(new StringReader(xml), null, options).getRootObject()); + } + + /* + * this malformed xml will load, as it uses the default lax approach + */ + public void testLaxForm() throws IOException { + load( +""+ + ""+ + ""+ +"", null); + } + + /* + * any malformed xml through this method will fail to load + * since the options instance member disables lax processing + */ + protected final void load(String xml) throws IOException { + try { + load(xml, options); + fail(); + } catch (Resource.IOWrappedException featureNotFound) { + } + } + + public void testUnqualifiedAttribute() throws IOException { + load(""); + } + + public void testQualifiedAttribute() throws IOException { + load(""); + } + + public void testUnqualifiedElement() throws IOException { + load( +""+ + ""+ +""); + } + + public void testQualifiedElement() throws IOException { + load( +""+ + ""+ +""); + } +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/HelperContextTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/HelperContextTestCase.java new file mode 100644 index 0000000000..14e81b6a32 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/HelperContextTestCase.java @@ -0,0 +1,75 @@ +/** + * + * 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 org.apache.tuscany.sdo.util.SDOUtil; + +import commonj.sdo.helper.CopyHelper; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.DataHelper; +import commonj.sdo.helper.EqualityHelper; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; +import commonj.sdo.impl.HelperProvider; + +public class HelperContextTestCase extends TestCase { + + public void testDefaultHelperContext() { + HelperContext defaultHelperContext = HelperProvider.getDefaultContext(); + + assertNotNull(defaultHelperContext.getCopyHelper()); + assertEquals(defaultHelperContext.getCopyHelper(), CopyHelper.INSTANCE); + assertNotNull(defaultHelperContext.getDataFactory()); + assertEquals(defaultHelperContext.getDataFactory(), DataFactory.INSTANCE); + assertNotNull(defaultHelperContext.getDataHelper()); + assertEquals(defaultHelperContext.getDataHelper(), DataHelper.INSTANCE); + assertNotNull(defaultHelperContext.getEqualityHelper()); + assertEquals(defaultHelperContext.getEqualityHelper(), EqualityHelper.INSTANCE); + assertNotNull(defaultHelperContext.getTypeHelper()); + assertEquals(defaultHelperContext.getTypeHelper(), TypeHelper.INSTANCE); + assertNotNull(defaultHelperContext.getXMLHelper()); + assertEquals(defaultHelperContext.getXMLHelper(), XMLHelper.INSTANCE); + assertNotNull(defaultHelperContext.getXSDHelper()); + assertEquals(defaultHelperContext.getXSDHelper(), XSDHelper.INSTANCE); + + } + + public void testCreateHelperContext() { + HelperContext hc = SDOUtil.createHelperContext(); + assertNotNull(hc.getCopyHelper()); + assertNotNull(hc.getDataFactory()); + assertNotNull(hc.getDataHelper()); + assertNotNull(hc.getEqualityHelper()); + assertNotNull(hc.getTypeHelper()); + assertNotNull(hc.getXMLHelper()); + assertNotNull(hc.getXSDHelper()); + + assertNotSame(hc.getDataFactory(), DataFactory.INSTANCE); + assertNotSame(hc.getTypeHelper(), TypeHelper.INSTANCE); + assertNotSame(hc.getXMLHelper(), XMLHelper.INSTANCE); + assertNotSame(hc.getXSDHelper(), XSDHelper.INSTANCE); + // the other "stateless" helpers may be the same as the singletons + } + +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/IsManyTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/IsManyTestCase.java new file mode 100644 index 0000000000..1eef4ea657 --- /dev/null +++ b/sandbox/kgoodson/events/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 + 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/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/JavaSerializeDeserializeTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/JavaSerializeDeserializeTestCase.java new file mode 100644 index 0000000000..56a293cde0 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/JavaSerializeDeserializeTestCase.java @@ -0,0 +1,297 @@ +/** + * + * 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.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.ArrayList; +import java.util.List; + +import junit.framework.TestCase; + +import org.apache.tuscany.sdo.util.SDOUtil; + +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.TypeHelper; + +public class JavaSerializeDeserializeTestCase extends TestCase +{ + + public void testScopeDefinedSerializeDeserializeOfDataObject() + { + HelperContext hc = SDOUtil.createHelperContext(); + Object originalDataObject = createDynamically(hc,true); + + runSerializeDeserialize((DataObject)originalDataObject, hc); + } + + public void testScopeDefinedSerializeDeserializeOfDataGraph() + { + HelperContext hc = SDOUtil.createHelperContext(); + DataGraph testDO = (DataGraph)createDynamically(hc,false); + + runSerializeDeserializeWithDataGraph(testDO, hc); + } + + private String xsdString = "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + + "" + + "" + + "" + + "" + + "" + + "" + + ""; + + public void testLargePayload() + { + HelperContext hc = SDOUtil.createHelperContext(); + hc.getXSDHelper().define(xsdString); + DataObject company = hc.getDataFactory().create("http://www.example.com/simple", "Company"); + company.setString("symbol", "EXAMPLE"); + company.setString("companyName", "Example Inc."); + List employees = company.getList("employees"); + DataObject employee; + for (int i=0; i<1000; i++) { + employee = hc.getDataFactory().create("http://www.example.com/simple", "Employee"); + employee.setString("employeeID", "ID #" + i); + employee.setString("employeeName", "Empoyee #" + i); + employees.add(employee); + } + try { + ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ObjectOutputStream oos = SDOUtil.createObjectOutputStream(bos, hc); + oos.writeObject(company); + oos.flush(); + byte[] bytes = bos.toByteArray(); + oos.close(); + bos.close(); + + ByteArrayInputStream bis = new ByteArrayInputStream(bytes); + ObjectInputStream ois = SDOUtil.createObjectInputStream(bis, hc); + ois.readObject(); + ois.close(); + bis.close(); + } + catch (Exception e) { + e.printStackTrace(); + fail("An Exception occurred while deserializing the output of the serialization: " + e.toString()); + } + } + + + /** + * Serialize the DataObject then Deserialize the output. + * to testDO. + * @param testDO + * @param scope + */ + + public void runSerializeDeserialize(DataObject originalDataObject, HelperContext hc) + { + + populateFields(originalDataObject); + DataObject tempDO = null; + ByteArrayOutputStream baos = null; + + try + { + baos = serialize(originalDataObject, hc); + + } + catch (Exception e) + { + e.printStackTrace(); + fail("An Exception occurred while serializing the DataObject: " + e.toString()); + } + + try + { + tempDO = deserialize(baos, hc); + + } + catch (Exception e) + { + e.printStackTrace(); + fail("An Exception occurred while deserializing the output of the serialization: " + e.toString()); + } + + assertNotNull("Deserialization returned a null value.", tempDO); + + assertSame(tempDO.getType(), originalDataObject.getType()); + + + } + + /** + * Serialize the DataGraph + * @param dataGraph + * @param scope + */ + public void runSerializeDeserializeWithDataGraph(DataGraph dataGraph, HelperContext hc) + { + DataObject originalDataObject = dataGraph.getRootObject(); + populateFields(originalDataObject); + DataObject tempDO = null; + ByteArrayOutputStream baos = null; + + try + { + baos = serialize(dataGraph, hc); + + } + catch (Exception e) + { + e.printStackTrace(); + fail("An Exception occurred while serializing the DataObject: " + e.toString()); + } + + try + { + tempDO = deserialize(baos, hc); + + } + catch (Exception e) + { + e.printStackTrace(); + fail("An Exception occurred while deserializing the output of the serialization: " + e.toString()); + } + + assertNotNull("Deserialization returned a null value.", tempDO); + + assertSame(tempDO.getType(), originalDataObject.getType()); + + + + } + + /** + * serializeDataObject is a private method to be called by the other methods + * in the ScrenarioLibrary + * + * @param dataObject + * @param fileName + * @throws IOException + */ + public ByteArrayOutputStream serialize(Object object, HelperContext hc) throws IOException + { + //FileOutputStream fos = new FileOutputStream("temp"); + ByteArrayOutputStream byteArrayOutput = new ByteArrayOutputStream(); + ObjectOutputStream out = SDOUtil.createObjectOutputStream(byteArrayOutput, hc); + out.writeObject(object); + out.close(); + return byteArrayOutput; + } + + /** + * deserializeDataObject is a private method to be called by the other + * methods in the ScrenarioLibrary + * + * @param fileName + * @return + * @throws IOException + * @throws ClassNotFoundException + */ + public DataObject deserialize(ByteArrayOutputStream baos, HelperContext hc) throws IOException, ClassNotFoundException + { + //FileInputStream fis = new FileInputStream("temp"); + ObjectInputStream input = null; + ByteArrayInputStream byteArrayInput = new ByteArrayInputStream(baos.toByteArray()); + + input = SDOUtil.createObjectInputStream(byteArrayInput, hc); + + Object object = input.readObject(); + input.close(); + if(object instanceof DataGraph) + return ((DataGraph)object).getRootObject(); + else + return (DataObject)object; + } + + /** + * populateFields uses set to set each of the fields in the + * DataObject. It is used to ensure a known set of expected values that are + * not other than the default values for the various fields. + * + * @param testDO + * @throws ExpectedConditionError + */ + public static void populateFields(DataObject testDO) + { + + testDO.setString("stringVal", "Testing"); + + } + /** + * createDynamically() creates the SDO Types using the TypeHelper. This method should be kept in + * synch with the XSD used for createDynamicallyWithStaticResources. The same XSD is used for + * the static generation of SDO Types using XSD2JavaGenerator. + */ + public Object createDynamically(HelperContext hc, boolean createDataObject) + { + + TypeHelper types = hc.getTypeHelper(); + DataFactory dataFactory = hc.getDataFactory(); + + Type stringType = types.getType("commonj.sdo", "String"); + + DataObject testType = dataFactory.create("commonj.sdo", "Type"); + testType.set("uri", "http://www.example.com/api_test"); + testType.set("name", "APITest"); + + DataObject stringProperty = testType.createDataObject("property"); + stringProperty.set("name", "stringVal"); + stringProperty.set("type", stringType); + + + List types2Define = new ArrayList(); + types2Define.add(testType); + List apiXSD = types.define(types2Define); + Type apiXSDType = (Type) apiXSD.get(0); + + if(createDataObject) + return dataFactory.create(apiXSDType);; + + // Create an empty DataGraph and attach the document root to it. Otherwise, where is the documentRoot ? + DataGraph dataGraph = SDOUtil.createDataGraph(); + /*DataObject testDO =*/ dataGraph.createRootObject(apiXSDType); + + + return dataGraph; + + } +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/JiraTestCases.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/JiraTestCases.java new file mode 100644 index 0000000000..bd66949c89 --- /dev/null +++ b/sandbox/kgoodson/events/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 commonj.sdo.impl.HelperProvider; + +import org.apache.tuscany.sdo.api.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 + * + */ +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() { + HelperContext hc = HelperProvider.getDefaultContext(); + XSDHelper xsdHelper = hc.getXSDHelper(); + // define some types + try { + xsdHelper.define(getClass().getResourceAsStream( + PO_XSD_RESOURCE), null); + + xsdHelper.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) { + HelperContext hc = HelperProvider.getDefaultContext(); + try { + + List actualTypes = SDOUtil.getTypes(hc, 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/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/MetadataInstancePropertiesTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/MetadataInstancePropertiesTestCase.java new file mode 100644 index 0000000000..360ffe3cab --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/MetadataInstancePropertiesTestCase.java @@ -0,0 +1,220 @@ +/** + * + * 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 java.util.List; + +import junit.framework.TestCase; + +import org.apache.tuscany.sdo.api.SDOUtil; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XSDHelper; + + +public class MetadataInstancePropertiesTestCase extends TestCase +{ + private final String TEST_MODEL = "/TypePropertyMetadataInfo.xsd"; + private final String TEST_NAMESPACE = "http://www.example.com/metadata/retrievaltest"; + private final String DYNAMIC_TEST_NAMESPACE = "http://www.example.com/metadata/dynamicmetadata"; + + private HelperContext helperContext; + private TypeHelper typeHelper; + private XSDHelper xsdHelper; + private DataFactory dataFactory; + + public void testXSDTypeProperties() + { + // Note: We won't check the actual value of XSD instance properties yet since they're not defined + // in the SDO spec yet. + + //displayInstanceProperties(TEST_NAMESPACE); + + Type type = typeHelper.getType(TEST_NAMESPACE, "Example"); + assertTrue(getInstanceProperty(type, "appinfo") != null); + assertTrue(getInstanceProperty(type, "foo") == null); + + Property property = type.getProperty("number"); + assertTrue(getInstanceProperty(property, "appinfo") != null); + assertTrue(getInstanceProperty(property, "foo") == null); + + property = type.getProperty("Exampletype"); + assertTrue(getInstanceProperty(property, "appinfo") != null); + assertTrue(getInstanceProperty(property, "foo") == null); + + type = typeHelper.getType(TEST_NAMESPACE, "ExampleNumber"); + assertTrue(getInstanceProperty(type, "appinfo") != null); + assertTrue(getInstanceProperty(type, "minInclusive") != null); + assertTrue(getInstanceProperty(type, "maxInclusive") != null); + assertTrue(getInstanceProperty(type, "foo") == null); + + type = typeHelper.getType(TEST_NAMESPACE, "ExampleRating"); + assertTrue(getInstanceProperty(type, "enumeration") != null); + assertTrue(getInstanceProperty(type, "foo") == null); + + type = typeHelper.getType(TEST_NAMESPACE, "PhoneNumber"); + assertTrue(getInstanceProperty(type, "appinfo") != null); + assertTrue(getInstanceProperty(type, "length") != null); + assertTrue(getInstanceProperty(type, "pattern") != null); + assertTrue(getInstanceProperty(type, "foo") == null); + } + + public void testDynamicTypeProperties() + { + // Create dynamic model + Type intType = typeHelper.getType("commonj.sdo", "Int"); + Type stringType = typeHelper.getType("commonj.sdo", "String"); + + Property openContentProperty = typeHelper.getOpenContentProperty("commonj.sdo/xml", "xmlElement"); + + // create a new Type for Customers + DataObject customerType = dataFactory.create("commonj.sdo", "Type"); + customerType.set("uri", DYNAMIC_TEST_NAMESPACE); + customerType.set("name", "Customer"); + customerType.set(openContentProperty, Boolean.TRUE); + + // 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); + firstNameProperty.set(openContentProperty, Boolean.FALSE); + + // 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 + typeHelper.define(customerType); + + //displayInstanceProperties(DYNAMIC_TEST_NAMESPACE); + + Type type = typeHelper.getType(DYNAMIC_TEST_NAMESPACE, "Customer"); + assertTrue(getInstanceProperty(type, "xmlElement") == openContentProperty); + assertTrue(type.get(openContentProperty) == Boolean.TRUE); + assertTrue(getInstanceProperty(type, "foo") == null); + + Property property = type.getProperty("custNum"); + assertTrue(getInstanceProperty(property, "xmlElement") == null); + assertTrue(getInstanceProperty(property, "foo") == null); + + property = type.getProperty("firstName"); + assertTrue(getInstanceProperty(property, "xmlElement") == openContentProperty); + assertTrue(property.get(openContentProperty) == Boolean.FALSE); + assertTrue(getInstanceProperty(property, "foo") == null); + + property = type.getProperty("lastName"); + assertTrue(getInstanceProperty(property, "xmlElement") == null); + assertTrue(getInstanceProperty(property, "foo") == null); + } + + public void setUp() throws Exception + { + super.setUp(); + + helperContext = SDOUtil.createHelperContext(); + + typeHelper = helperContext.getTypeHelper(); + xsdHelper = helperContext.getXSDHelper(); + dataFactory = helperContext.getDataFactory(); + + URL url = getClass().getResource(TEST_MODEL); + InputStream inputStream = url.openStream(); + + xsdHelper.define(inputStream, url.toString()); + inputStream.close(); + } + + public Property getInstanceProperty(Type type, String propertyName) + { + return getInstanceProperty(type.getInstanceProperties(), propertyName); + } + + public Property getInstanceProperty(Property property, String propertyName) + { + return getInstanceProperty(property.getInstanceProperties(), propertyName); + } + + private Property getInstanceProperty(List instProps, String propertyName) + { + for (int i = 0; i < instProps.size(); i++) + { + Property prop = (Property)instProps.get(i); + if (propertyName.equals(prop.getName())) + return prop; + } + return null; + } + + private void displayInstanceProperties(Type type) + { + System.out.println("Type's name: " + type.getName()); + List instProps = type.getInstanceProperties(); + for (int i = 0; i < instProps.size(); i++) + { + Property prop = (Property)instProps.get(i); + System.out.println("\tType's instance property name: " + prop.getName()); + System.out.println("\tType's instance property value: \"" + type.get(prop) + "\""); + } + } + + private void displayInstanceProperties(Property prop) + { + System.out.println("\tProperty's name: " + prop.getName()); + List propsInstProps = prop.getInstanceProperties(); + for (int j = 0; j < propsInstProps.size(); j++) + { + Property propsInstProp = (Property)propsInstProps.get(j); + System.out.println("\t\tProperty's instance property name: " + propsInstProp.getName()); + System.out.println("\t\tProperty's instance property value: \"" + prop.get(propsInstProp) + "\""); + } + } + + public void displayInstanceProperties(String namespace) + { + List types = SDOUtil.getTypes(helperContext, namespace); + for (int i = 0; i < types.size(); i++) + { + Type type = (Type)types.get(i); + displayInstanceProperties(type); + List properties = type.getProperties(); + for (int j = 0; j < properties.size(); j++) + { + Property property = (Property)properties.get(j); + displayInstanceProperties(property); + } + System.out.println("**************************************"); + } + } + +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/MixedTypeTestCase.java new file mode 100644 index 0000000000..806662a83c --- /dev/null +++ b/sandbox/kgoodson/events/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/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/NeverStaleChangeSummaryTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/NeverStaleChangeSummaryTestCase.java new file mode 100644 index 0000000000..69c8e447df --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/NeverStaleChangeSummaryTestCase.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.test; + +import java.io.InputStream; +import java.net.URL; + +import junit.framework.TestCase; + +import commonj.sdo.ChangeSummary; +import commonj.sdo.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XSDHelper; + +public class NeverStaleChangeSummaryTestCase extends TestCase { + private final String TEST_MODEL = "/simpleWithChangeSummary.xsd"; + private final String TEST_NAMESPACE = "http://www.example.com/simpleCS"; + + /** + * Simple ChangeSummary test. + */ + public void testChangeSummary() throws Exception { + Type quoteType = TypeHelper.INSTANCE.getType(TEST_NAMESPACE, "RootQuote"); + DataObject quote = DataFactory.INSTANCE.create(quoteType); + + ChangeSummary cs = quote.getChangeSummary(); + + // Begin logging changes + // + cs.beginLogging(); + + DataObject child = quote.createDataObject("quotes"); + cs.isCreated(child); + child = quote.createDataObject("quotes"); + assertTrue(cs.isCreated(child)); + + // Stop logging changes and print the resulting data graph to stdout + // + cs.endLogging(); + + cs.isCreated(child); + + cs.undoChanges(); + + assertFalse(cs.isCreated(child)); + } + + 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(); + } +} \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java new file mode 100644 index 0000000000..0f2e09354c --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/OpenTypeTestCase.java @@ -0,0 +1,139 @@ +/** + * + * 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 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.HelperContext; +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 HelperContext hc; + private TypeHelper th; + private XSDHelper xsdh; + private XMLHelper xmlh; + private DataFactory df; + 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 = th.getType(TEST_NAMESPACE, "OpenQuote"); + DataObject quote = df.create(quoteType); + + quote.setString("symbol", "s1"); + + for (Iterator iter = quote.getInstanceProperties().iterator(); iter.hasNext();) { + Property property = (Property) iter.next(); + } + + Property companyProperty = xsdh.getGlobalProperty(TEST_NAMESPACE, "company", true); + DataObject company = quote.createDataObject(companyProperty); + company.setString("name", "FlyByNightTechnology"); + + Property priceProperty = xsdh.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(); + xmlh.save(quote, TEST_NAMESPACE, "openStockQuote", baos); + + assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(TEST_DATA))); + } + + + public void testOpenType_Tuscany_396() throws IOException { + Type quoteType = th.getType(TEST_NAMESPACE, "OpenQuote2"); + DataObject quote = df.create(quoteType); + + Property priceProperty = xsdh.getGlobalProperty(TEST_NAMESPACE, "price", true); + // the importance of this is that the maxOccurs=1 attribute on the xsd:any + // allows is to use the !isMany getters and setters for open content + quote.set(priceProperty, new BigDecimal("1000.0")); + + } + + /** + * Although this behavior is not mandated by the SDO 2.1 specification it should be possible + * to demand-create DataObject properties by calling createDataObject(String name). + * The behavior should be the same as that specified in section 9.10 for parsing XML that has + * no types defined e.g. the property should be created as an open, sequenced type with many=true. + * + * See https://issues.apache.org/jira/browse/TUSCANY-1397 for more information. + * + * @throws Exception + */ + public void testOnDemandCreateDataObject() throws Exception { + // define an open type with no properties + DataObject typeDef = df.create( "commonj.sdo", "Type" ); + typeDef.set( "uri", TEST_NAMESPACE ); + typeDef.set( "name", "testOnDemandCreateDataObjectType" ); + typeDef.setBoolean( "open", true ); + Type t = th.define( typeDef ); + + // create a DataObject that uses this type + DataObject testDO = df.create(t); + + // create an on-demand property + DataObject foo = testDO.createDataObject( "foo" ); + assertNotNull( "createDataObject() demand created a DataObject", foo ); + assertTrue( "DataObject is open", foo.getType().isOpen() ); + assertTrue( "DataObject is sequenced", foo.getType().isSequenced() ); + } + + + 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(); + hc = SDOUtil.createHelperContext(); + th = hc.getTypeHelper(); + xsdh = hc.getXSDHelper(); + df = hc.getDataFactory(); + xmlh = hc.getXMLHelper(); + hc.getXSDHelper().define(inputStream, url.toString()); + inputStream.close(); + } +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SchemaLocationTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SchemaLocationTestCase.java new file mode 100644 index 0000000000..eaec327007 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SchemaLocationTestCase.java @@ -0,0 +1,48 @@ +/** + * + * 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.util.*; + +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.util.SDOUtil; + +import junit.framework.TestCase; + +import commonj.sdo.helper.*; + +public class SchemaLocationTestCase extends TestCase { + private final String TEST_XML_DOCUMENT = "/SchemaLocationTestCase.xml"; + + /** + * 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 + Map options = new HashMap(); + options.put(SDOUtil.XML_LOAD_SCHEMA, Boolean.TRUE); + XMLDocument doc = XMLHelper.INSTANCE.load(getClass().getResourceAsStream(TEST_XML_DOCUMENT), "whatever", options); + assertNotSame(doc.getRootObject().getType(), SDOPackage.eINSTANCE.getAnyTypeDataObject()); + } +} \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SequenceTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SequenceTestCase.java new file mode 100644 index 0000000000..b547f45d1c --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SequenceTestCase.java @@ -0,0 +1,100 @@ +/** + * + * 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 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.HelperContext; +import commonj.sdo.helper.XSDHelper; + +public class SequenceTestCase extends TestCase { + HelperContext hc; + Type type; + Property localA, choiceX, choiceY, localB, open; + + String xml = ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""; + + protected void setUp() throws Exception { + super.setUp(); + hc = SDOUtil.createHelperContext(); + hc.getXSDHelper().define(xml); + type = hc.getTypeHelper().getType("testNS", "Sequenced"); + localA = type.getProperty("localA"); + choiceX = type.getProperty("choiceX"); + choiceY = type.getProperty("choiceY"); + localB = type.getProperty("localB"); + XSDHelper xsdHelper = hc.getXSDHelper(); + open = xsdHelper.getGlobalProperty("testNS", "open", true); + } + + public void testSequenced() { + DataObject dataObject = hc.getDataFactory().create(type); + Sequence sequence = dataObject.getSequence(); + + sequence.add(choiceX, "x1"); + sequence.add(0, localA, "a"); + sequence.add(choiceY, "y1"); + sequence.add(choiceX, "x2"); + sequence.add(localB, "b"); + sequence.add(open, "open"); + + List list = dataObject.getList(localA); + assertEquals(list.size(), 1); + assertEquals(list.get(0), "a"); + + assertEquals(dataObject.getString(localB), "b"); + + list = dataObject.getList(choiceX); + assertEquals(list.size(), 2); + assertEquals(list.get(0), "x1"); + assertEquals(list.get(1), "x2"); + + list = dataObject.getList(choiceY); + assertEquals(list.size(), 1); + assertEquals(list.get(0), "y1"); + + list = dataObject.getList(open); + assertEquals(list.size(), 1); + assertEquals(list.get(0), "open"); + } + +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SerializeTypesTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SerializeTypesTestCase.java new file mode 100644 index 0000000000..7fe1196eb6 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SerializeTypesTestCase.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.test; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.util.ArrayList; +import java.util.List; + +import junit.framework.TestCase; + +import org.apache.tuscany.sdo.api.SDOUtil; + +import commonj.sdo.DataGraph; +import commonj.sdo.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XMLDocument; + +public class SerializeTypesTestCase extends TestCase { + + HelperContext hc; + + protected void setUp() throws Exception { + super.setUp(); + hc = SDOUtil.createHelperContext(); + } + + public void testSerializeTypesRoundTrip() throws Exception { + TypeHelper types = hc.getTypeHelper(); + DataFactory factory = hc.getDataFactory(); + + 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); + + byte[] serialized = baos.toByteArray(); + ByteArrayInputStream bais = new ByteArrayInputStream(serialized); + DataGraph loadedDataGraph = SDOUtil.loadDataGraph(bais, null, hc); + + 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")); + } + + private String xsdString = + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + + + private String testString = "Hello World"; + private String testStringInBase64 = "SGVsbG8gV29ybGQ="; + private String testStringInHex = "48656C6C6F20576F726C64"; + + public void testSerializeXSDBase64BinaryRoundTrip() throws Exception { + hc.getXSDHelper().define(xsdString); + + DataObject typeTest = hc.getDataFactory().create("http://www.example.com/simple", "BytesTypeTest"); + typeTest.setBytes("base64Binary", testString.getBytes()); + + String output = hc.getXMLHelper().save(typeTest, typeTest.getType().getURI(), "bytesTypeTest"); + + String startTag = ""; + String endTag = ""; + int start = output.indexOf(startTag) + startTag.length(); + int end = output.indexOf(endTag); + + String value = output.substring(start, end); + assertEquals(testStringInBase64, value); + + XMLDocument xmlDoc = hc.getXMLHelper().load(output); + typeTest = xmlDoc.getRootObject(); + assertEquals(testString, new String(typeTest.getBytes("base64Binary"))); + } + + public void testSerializeXSDHexBinaryRoundTrip() throws Exception { + hc.getXSDHelper().define(xsdString); + + DataObject typeTest = hc.getDataFactory().create("http://www.example.com/simple", "BytesTypeTest"); + typeTest.setBytes("hexBinary", testString.getBytes()); + + String output = hc.getXMLHelper().save(typeTest, typeTest.getType().getURI(), "bytesTypeTest"); + + String startTag = ""; + String endTag = ""; + int start = output.indexOf(startTag) + startTag.length(); + int end = output.indexOf(endTag); + + String value = output.substring(start, end); + assertEquals(testStringInHex, value); + + XMLDocument xmlDoc = hc.getXMLHelper().load(output); + typeTest = xmlDoc.getRootObject(); + assertEquals(testString, new String(typeTest.getBytes("hexBinary"))); + } +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleCopyTestCase.java new file mode 100644 index 0000000000..36f038d779 --- /dev/null +++ b/sandbox/kgoodson/events/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/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java new file mode 100644 index 0000000000..55aae9d396 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleDynamicTestCase.java @@ -0,0 +1,123 @@ +/** + * + * 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.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.TypeHelper; + + +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"; + + //private final String TEST_MODEL2 = "/simple2.xsd"; + //private final String TEST_NAMESPACE2 = "http://www.example.com/simple2"; + //private final String QUOTE_XML2 = "/quote2.xml"; + + HelperContext hc; + TypeHelper th; + + /** + * Simple Dynamic SDO 2 test. + */ + public void testDynamic() throws IOException { + Type quoteType = th.getType(TEST_NAMESPACE, "Quote"); + DataObject quote = hc.getDataFactory().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(); + hc.getXMLHelper().save(quote, TEST_NAMESPACE, "stockQuote", baos); + + assertFalse(quote.isSet("undefined")); + assertSame(quote.get("undefined"), null); + + assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(QUOTE_XML))); + } + + /* + public void dontTestResolveXSDWithoutSchemaLocation() throws IOException { + + URL url = getClass().getResource(TEST_MODEL2); + InputStream inputStream = url.openStream(); + hc.getXSDHelper().define(inputStream, null); + inputStream.close(); + + Type quote2Type = th.getType(TEST_NAMESPACE2, "Quote2"); + DataObject quote2 = hc.getDataFactory().create(quote2Type); + + quote2.setString("symbol", "fbnt"); + quote2.setString("companyName", "FlyByNightTechnology"); + quote2.setBigDecimal("price", new BigDecimal("1000.0")); + quote2.setBigDecimal("open1", new BigDecimal("1000.0")); + quote2.setBigDecimal("high", new BigDecimal("1000.0")); + quote2.setBigDecimal("low", new BigDecimal("1000.0")); + quote2.setDouble("volume", 1000); + quote2.setDouble("change1", 1000); + + DataObject child = quote2.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("2000.0")); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + hc.getXMLHelper().save(quote2, TEST_NAMESPACE2, "stockQuote", System.out); + } + */ + + protected void setUp() throws Exception { + super.setUp(); + + hc = SDOUtil.createHelperContext(); + th = hc.getTypeHelper(); + + // Populate the meta data for the test (Stock Quote) model + URL url = getClass().getResource(TEST_MODEL); + InputStream inputStream = url.openStream(); + hc.getXSDHelper().define(inputStream, url.toString()); + inputStream.close(); + + + } + +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SimpleEqualityTestCase.java new file mode 100644 index 0000000000..c3fffa4f10 --- /dev/null +++ b/sandbox/kgoodson/events/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/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValuesTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValuesTestCase.java new file mode 100644 index 0000000000..fb729ea125 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/SubstitutionValuesTestCase.java @@ -0,0 +1,83 @@ +/** + * + * 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.net.URL; + +import junit.framework.TestCase; + +import org.apache.tuscany.sdo.api.SDOUtil; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.Sequence; +import commonj.sdo.Type; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; + +public final class SubstitutionValuesTestCase extends TestCase +{ + public void test() throws IOException + { + HelperContext hc = SDOUtil.createHelperContext(); + URL url = getClass().getResource("/SubstitutionValues.xsd"); + XSDHelper xsdHelper = hc.getXSDHelper(); + xsdHelper.define(url.openStream(), url.toString()); + + XMLHelper xmlHelper = hc.getXMLHelper(); + DataObject loadedObject = + xmlHelper.load(getClass().getResourceAsStream("/substitutionValues1.xml")).getRootObject(); + Type type = loadedObject.getType(); + Sequence groupHeadSubstitutionValues = SDOUtil.getSubstitutionValues(loadedObject, type.getProperty("groupHead")); + assertNotNull(groupHeadSubstitutionValues); + assertNull(SDOUtil.getSubstitutionValues(loadedObject, type.getProperty("nonGroupHead"))); + + String nsURI = "http://www.apache.org/tuscany/SubstitutionValues"; + DataObject createdObject = hc.getDataFactory().create(nsURI, "TestObject"); + Property groupMemberProperty = xsdHelper.getGlobalProperty(nsURI, "groupMember", true); + createdObject.set(groupMemberProperty, groupHeadSubstitutionValues.getValue(0)); + createdObject.setString("nonGroupHead", loadedObject.getString("nonGroupHead")); + + assertTrue(hc.getEqualityHelper().equal(loadedObject, createdObject)); + + ByteArrayOutputStream loadedBaos = new ByteArrayOutputStream(); + xmlHelper.save(loadedObject, nsURI, "testObject", loadedBaos); + ByteArrayOutputStream createdBaos = new ByteArrayOutputStream(); + xmlHelper.save(createdObject, nsURI, "testObject", createdBaos); + assertTrue( + TestUtil.equalXmlFiles( + new ByteArrayInputStream(loadedBaos.toByteArray()), + new ByteArrayInputStream(createdBaos.toByteArray()))); + + loadedObject = + xmlHelper.load(getClass().getResourceAsStream("/substitutionValues2.xml")).getRootObject(); + groupHeadSubstitutionValues = SDOUtil.getSubstitutionValues(loadedObject, type.getProperty("groupHead")); + + createdObject = hc.getDataFactory().create(nsURI, "TestObject"); + createdObject.set("groupHead", groupHeadSubstitutionValues.getValue(0)); + createdObject.setString("nonGroupHead", loadedObject.getString("nonGroupHead")); + + assertTrue(hc.getEqualityHelper().equal(loadedObject, createdObject)); + } +} \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/TestUtil.java new file mode 100644 index 0000000000..a7ab3f954a --- /dev/null +++ b/sandbox/kgoodson/events/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, but within + // the array exist the get(index), get(property), and get(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); + } + + public void testTuscany_836() { + if (System.getProperty("java.version").indexOf("1.4") == -1) { + // Work around a bug in SUN and IBM 1.4 JDKs + assertEquals(DataObjectUtil.getBigDecimal(new Long(Long.MAX_VALUE)).longValue(), Long.MAX_VALUE); + } + } +} \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/TypeHelperTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/TypeHelperTestCase.java new file mode 100644 index 0000000000..8fad877d4b --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/TypeHelperTestCase.java @@ -0,0 +1,45 @@ +/** + * + * 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 org.apache.tuscany.sdo.api.SDOUtil; + +import commonj.sdo.helper.HelperContext; + + +public class TypeHelperTestCase extends TestCase { + + + HelperContext hc; + + protected void setUp() throws Exception { + super.setUp(); + hc = SDOUtil.createHelperContext(); + } + + public void testGetType() { + assertTrue(hc.getTypeHelper().getType(List.class) == null ); + } + +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/TypeRoundTripTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/TypeRoundTripTestCase.java new file mode 100644 index 0000000000..f718a3f330 --- /dev/null +++ b/sandbox/kgoodson/events/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/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLDocumentTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLDocumentTestCase.java new file mode 100644 index 0000000000..1cf59757ef --- /dev/null +++ b/sandbox/kgoodson/events/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/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLHelperTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLHelperTestCase.java new file mode 100644 index 0000000000..62daeeafdf --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLHelperTestCase.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.test; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.transform.dom.DOMSource; + +import junit.framework.TestCase; + +import org.apache.tuscany.sdo.api.SDOHelper; +import org.apache.tuscany.sdo.api.SDOUtil; +import org.w3c.dom.Document; +import org.xml.sax.SAXException; + +import commonj.sdo.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.XMLDocument; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; + +public class XMLHelperTestCase extends TestCase { + + HelperContext hc; + private XSDHelper xsdHelper; + XMLHelper xmlh; + static final String INDENT = " ", MARGIN = " ", LINE_BREAK = "\n\n"; + + void define(String model) throws Exception { + // Populate the meta data for the test model + URL url = getClass().getResource(model); + xsdHelper.define(url.openStream(), url.toString()); + } + + protected void setUp() throws Exception { + super.setUp(); + hc = SDOUtil.createHelperContext(); + xsdHelper = hc.getXSDHelper(); + xmlh = hc.getXMLHelper(); + + // Populate the meta data for the test (Stock Quote) model + define("/simpleWithChangeSummary.xsd"); + + define("/SequenceChangeSummary.xsd"); + + define("/simple.xsd"); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + public void testLoadInputStreamStringObject() throws IOException { + + } + + protected final void format(String xml,String formatted) throws IOException { + XMLDocument doc = xmlh.load(getClass().getResource(xml).openStream()); + Map options = new HashMap(); + + options.put(SDOHelper.XMLOptions.XML_SAVE_INDENT, INDENT); + options.put(SDOHelper.XMLOptions.XML_SAVE_MARGIN, MARGIN); + options.put(SDOHelper.XMLOptions.XML_SAVE_LINE_BREAK, LINE_BREAK); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + // doc declares NameSpaces at root + xmlh.save(xmlh.createDocument(doc.getRootObject(), doc.getRootElementURI(), doc.getRootElementName()), baos, options); + //xmlh.save(xmlh.createDocument(doc.getRootObject(), doc.getRootElementURI(), doc.getRootElementName()), System.out, options); + + assertEquals(formatted, baos.toString()); + } + + public void notestSaveXMLDocumentOutputStreamObject() throws IOException { + format("/simpleWithChangeSummary.xml", +MARGIN+ "" +LINE_BREAK+ +MARGIN+ "" +LINE_BREAK+ +MARGIN+INDENT+ "FBNT" +LINE_BREAK+ +MARGIN+INDENT+ "FlyByNightTechnology" +LINE_BREAK+ +MARGIN+INDENT+ "999.0" +LINE_BREAK+ +MARGIN+INDENT+ "1000.0" +LINE_BREAK+ +MARGIN+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+INDENT+ "1500.0" +LINE_BREAK+ +MARGIN+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+INDENT+ "2500.0" +LINE_BREAK+ +MARGIN+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+INDENT+ "3000.0" +LINE_BREAK+ +MARGIN+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+INDENT+ "4000.0" +LINE_BREAK+ +MARGIN+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+INDENT+INDENT+ "fbnt" +LINE_BREAK+ +MARGIN+INDENT+INDENT+INDENT+ "1000.0" +LINE_BREAK+ +MARGIN+INDENT+INDENT+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+INDENT+INDENT+ "2000.02000.99" +LINE_BREAK+ +MARGIN+INDENT+INDENT+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+ "" +LINE_BREAK+ +MARGIN+ ""); + } + + public void notestSaveMixedOutputStreamObject() throws IOException { + format("/mixedChangeSummary.xml", +MARGIN+ "" +LINE_BREAK+ +MARGIN+ "" +LINE_BREAK+ +INDENT+ "" +LINE_BREAK+ +INDENT+INDENT+ "fbnt" +LINE_BREAK+ +INDENT+INDENT+ "FlyByNightTechnology" +LINE_BREAK+ +INDENT+INDENT+ "1000.0" +LINE_BREAK+ +INDENT+INDENT+ "" +LINE_BREAK+ +INDENT+INDENT+ "2000.02000.99" +LINE_BREAK+ +INDENT+INDENT+ "" +LINE_BREAK+ +INDENT+ "" +LINE_BREAK+ +"FBNTFlyByNightTechnology999.01500.02500.01000.03000.04000.0"); + } + + public void notestOpenMixedOutputStreamObject() throws IOException { + format("/openChangeSummary.xml", +MARGIN+ "" +LINE_BREAK+ +MARGIN+ "" +LINE_BREAK+ +MARGIN+INDENT+ "FBNT" +LINE_BREAK+ +MARGIN+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+INDENT+ "1500.0" +LINE_BREAK+ +MARGIN+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+INDENT+ "2500.0" +LINE_BREAK+ +MARGIN+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+INDENT+ "3000.0" +LINE_BREAK+ +MARGIN+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+INDENT+ "4000.0" +LINE_BREAK+ +MARGIN+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+INDENT+INDENT+ "fbnt" +LINE_BREAK+ +MARGIN+INDENT+INDENT+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+INDENT+INDENT+ "2000.02000.99" +LINE_BREAK+ +MARGIN+INDENT+INDENT+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+INDENT+ "" +LINE_BREAK+ +MARGIN+INDENT+ "" +LINE_BREAK+ +MARGIN+ ""); + } + + private String quoteXML = + "" + + "" + + "fbnt" + + "FlyByNightTechnology" + + "1000.0" + + "1000.0" + + "1000.0" + + "1000.0" + + "1000.0" + + "1000.0" + + "" + + "2000.0" + + "" + + ""; + + public void testLoadDOMSource() throws IOException, ParserConfigurationException, SAXException + { + DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance(); + dFactory.setNamespaceAware(true); + + DocumentBuilder dBuilder = dFactory.newDocumentBuilder(); + Document document = dBuilder.parse(new ByteArrayInputStream(quoteXML.getBytes())); + + DOMSource domSource = new DOMSource(document); + + XMLDocument xmlDocument = hc.getXMLHelper().load(domSource, null, null); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + Map options = new HashMap(); + options.put(SDOHelper.XMLOptions.XML_SAVE_INDENT, ""); + options.put(SDOHelper.XMLOptions.XML_SAVE_MARGIN, ""); + options.put(SDOHelper.XMLOptions.XML_SAVE_LINE_BREAK, ""); + + hc.getXMLHelper().save(xmlDocument, baos, options); + + boolean isEqual = TestUtil.equalXmlFiles(new ByteArrayInputStream(quoteXML.getBytes()), new ByteArrayInputStream(baos.toByteArray())); + assertTrue(isEqual); + } + + private String xsdStr = + "" + + "" + +// "" + + "" + + "" + + "" + + "" + + "" + + ""; + + /** + * Test the scenario of serializing and deserializing an SDO with an undefined global SDO property + * In this scenario, the target XSD namespace doesn't have any global element defined + * + */ + public void testDemandCreateRootObject() { + HelperContext hc = SDOUtil.createHelperContext(); + hc.getXSDHelper().define(xsdStr); + DataObject quote = hc.getDataFactory().create("http://www.example.com/simple", "Quote"); + quote.set("symbol", "abc"); + + String xmlStr = hc.getXMLHelper().save(quote, quote.getType().getURI(), "demandcreate"); + + XMLDocument doc = hc.getXMLHelper().load(xmlStr); + try { + doc.getRootObject(); + } + catch (ClassCastException e) { + fail(e.toString()); + } + } + + /** + * This test case is similar to the testDemandCreateRootObject above. The only difference is + * the data model was created using SDO APIs instead of XSD. + * + */ + public void testDemandCreateRootObject2() { + HelperContext hc1 = SDOUtil.createHelperContext(); + Type stringType = hc1.getTypeHelper().getType("commonj.sdo", "String"); + + DataObject quoteTypeDef = hc1.getDataFactory().create("commonj.sdo", "Type"); + quoteTypeDef.set("uri", "http://www.example.com/simple"); + quoteTypeDef.set("name", "Quote"); + + DataObject symbolPropDef = quoteTypeDef.createDataObject("property"); + symbolPropDef.set("name", "symbol"); + symbolPropDef.set("type", stringType); + + hc1.getTypeHelper().define(quoteTypeDef); + + DataObject quote = hc1.getDataFactory().create("http://www.example.com/simple", "Quote"); + quote.set("symbol", "abc"); + + String xmlStr = hc1.getXMLHelper().save(quote, quote.getType().getURI(), "demandcreate"); + + HelperContext hc2 = SDOUtil.createHelperContext(); + hc2.getXSDHelper().define(xsdStr); + + XMLDocument doc = hc2.getXMLHelper().load(xmlStr); + try { + doc.getRootObject(); + } + catch (ClassCastException e) { + fail(e.toString()); + } + } +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLLoadOptionsTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLLoadOptionsTestCase.java new file mode 100644 index 0000000000..ac8d04b683 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLLoadOptionsTestCase.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.io.StringReader; +import java.util.HashMap; +import java.util.Map; + +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; + +import junit.framework.TestCase; + +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.api.SDOHelper; +import org.apache.tuscany.sdo.api.SDOUtil; +import org.apache.tuscany.sdo.api.XMLStreamHelper; +import org.eclipse.emf.ecore.resource.Resource; + +import commonj.sdo.DataObject; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.XMLDocument; +import commonj.sdo.helper.XMLHelper; + +public class XMLLoadOptionsTestCase extends TestCase { + XMLHelper xmlHelper; + Map options; + + protected void setUp() throws Exception { + super.setUp(); + } + + //SDOUtil->SDOHelper->SDOHelperImpl->HelperContextImpl->XMLHelperImpl + public void testXMLOptionsSchema1() throws IOException{ + final String TEST_XML_DOCUMENT = "/SchemaLocationTestCase.xml"; + + options = new HashMap(); + options.put(SDOHelper.XMLOptions.XML_LOAD_SCHEMA, Boolean.TRUE); + + final XMLHelper xmlHelper = SDOUtil.createHelperContext(true, options).getXMLHelper(); + + final XMLDocument xmlDoc = xmlHelper.load(getClass().getResourceAsStream(TEST_XML_DOCUMENT), "whatever", null); + final DataObject root = xmlDoc.getRootObject(); + assertNotSame(root.getType(), SDOPackage.eINSTANCE.getAnyTypeDataObject()); + } + +// SDOUtil->SDOHelper->SDOHelperImpl->HelperContextImpl->XMLHelperImpl + public void testXMLOptionsSchema2() throws IOException{ + final String TEST_XML_DOCUMENT = "/SchemaLocationTestCase.xml"; + + options = new HashMap(); + options.put(SDOHelper.XMLOptions.XML_LOAD_SCHEMA, Boolean.FALSE); + final XMLHelper xmlHelper = SDOUtil.createHelperContext(true, options).getXMLHelper(); + final XMLDocument xmlDoc = xmlHelper.load(getClass().getResourceAsStream(TEST_XML_DOCUMENT), "whatever", null); + final DataObject root = xmlDoc.getRootObject(); + assertSame(root.getType(), SDOPackage.eINSTANCE.getAnyTypeDataObject()); + } + + public void testXMLOptionsLax1() throws IOException{ + options = new HashMap(); + /* + * turn off default behaviour of tolerating malformed xml + * tests using this option and bad xml should demonstrate failure to load + */ + options.put(SDOHelper.XMLOptions.XML_LOAD_LAX_FORM, new Integer(0)); + final HelperContext hc = SDOUtil.createHelperContext(true, options); + hc.getXSDHelper().define( + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""); + + final String xml=""+ + ""+ +""; + + /* + * this malformed xml will not load, as lax is forced OFF + * changing p:unqualifiedElement to unqualifiedElement + * will work */ + try{ + hc.getXMLHelper().load(new StringReader(xml), null, null); + fail(); + } catch (final Resource.IOWrappedException featureNotFound) { + assertTrue(true); + } + + } + + public void testXMLOptionsLax2() throws IOException{ + options = new HashMap(); + /* + * turn on default behaviour of tolerating malformed xml + * tests using this option and bad xml will load + */ + options.put(SDOHelper.XMLOptions.XML_LOAD_LAX_FORM, new Integer(1)); + final HelperContext hc = SDOUtil.createHelperContext(true, options); + hc.getXSDHelper().define( + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""); + + final String xml=""+ + ""+ + ""+ + ""; + + /* + * this malformed xml will load, as lax is forced ON + */ + assertNotNull(hc.getXMLHelper().load(new StringReader(xml), null, null).getRootObject()); + } + + //SDOUtil->SDOHelper->SDOHelperImpl->XMLStreamHelperImpl->XMLDocumentImpl + public void testXMLStreamHelper() throws IOException, XMLStreamException{ + options = new HashMap(); + /* + * turn off default behaviour of tolerating malformed xml + * tests using this option and bad xml will load + */ + options.put(SDOHelper.XMLOptions.XML_LOAD_LAX_FORM, new Integer(1)); + final HelperContext hc = SDOUtil.createHelperContext(false, options); + final XMLStreamHelper streamHelper = SDOUtil.createXMLStreamHelper(hc); + hc.getXSDHelper().define( + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""+ + ""); + + final String xml=""+ + ""+ + ""+ + ""; + + final XMLInputFactory inputFactory = XMLInputFactory.newInstance(); + final XMLStreamReader reader1 = inputFactory.createXMLStreamReader(new StringReader(xml)); + int event = reader1.getEventType(); + while (!(event == XMLStreamConstants.START_ELEMENT)){ + event = reader1.next(); + } + final DataObject dataObject = streamHelper.loadObject(reader1); + /* + * this malformed xml will load, as lax is forced ON + */ + assertNotNull(dataObject); + } +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLSaveOptionsTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLSaveOptionsTestCase.java new file mode 100644 index 0000000000..50c32a8023 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLSaveOptionsTestCase.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.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.StringWriter; +import java.net.URL; +import java.util.HashMap; + +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamWriter; + +import junit.framework.TestCase; + +import org.apache.tuscany.sdo.api.SDOHelper; +import org.apache.tuscany.sdo.api.SDOUtil; +import org.apache.tuscany.sdo.api.XMLStreamHelper; + +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.XMLDocument; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; + +public class XMLSaveOptionsTestCase extends TestCase { + HelperContext hc; + private XSDHelper xsdHelper; + XMLHelper xmlh; + XMLStreamHelper xmlStreamHelper; + static final String INDENT = " ", MARGIN = " ", LINE_BREAK = "\n"; + String formatted1 = MARGIN+ "" +LINE_BREAK+ + MARGIN+ "" +LINE_BREAK+ + MARGIN+INDENT+ "FBNT" +LINE_BREAK+ + MARGIN+INDENT+ "FlyByNightTechnology" +LINE_BREAK+ + MARGIN+INDENT+ "999.0" +LINE_BREAK+ + MARGIN+INDENT+ "1000.0" +LINE_BREAK+ + MARGIN+INDENT+ "" +LINE_BREAK+ + MARGIN+INDENT+INDENT+ "1500.0" +LINE_BREAK+ + MARGIN+INDENT+ "" +LINE_BREAK+ + MARGIN+INDENT+ "" +LINE_BREAK+ + MARGIN+INDENT+INDENT+ "2500.0" +LINE_BREAK+ + MARGIN+INDENT+ "" +LINE_BREAK+ + MARGIN+INDENT+ "" +LINE_BREAK+ + MARGIN+INDENT+INDENT+ "3000.0" +LINE_BREAK+ + MARGIN+INDENT+ "" +LINE_BREAK+ + MARGIN+INDENT+ "" +LINE_BREAK+ + MARGIN+INDENT+INDENT+ "4000.0" +LINE_BREAK+ + MARGIN+INDENT+ "" +LINE_BREAK+ + MARGIN+INDENT+ "" +LINE_BREAK+ + MARGIN+INDENT+INDENT+ "" +LINE_BREAK+ + MARGIN+INDENT+INDENT+INDENT+ "fbnt" +LINE_BREAK+ + MARGIN+INDENT+INDENT+INDENT+ "1000.0" +LINE_BREAK+ + MARGIN+INDENT+INDENT+INDENT+ "" +LINE_BREAK+ + MARGIN+INDENT+INDENT+INDENT+ "2000.02000.99" +LINE_BREAK+ + MARGIN+INDENT+INDENT+INDENT+ "" +LINE_BREAK+ + MARGIN+INDENT+INDENT+ "" +LINE_BREAK+ + MARGIN+INDENT+ "" +LINE_BREAK+ + MARGIN+ ""; + + String formatted2 = + //MARGIN+ "" +LINE_BREAK+ + MARGIN+ "" +LINE_BREAK+ + MARGIN+INDENT+"fbnt" +LINE_BREAK+ + MARGIN+INDENT+"FlyByNightTechnology" +LINE_BREAK+ + MARGIN+INDENT+"1000.0" +LINE_BREAK+ + MARGIN+INDENT+"1000.0" +LINE_BREAK+ + MARGIN+INDENT+"1000.0" +LINE_BREAK+ + MARGIN+INDENT+"1000.0" +LINE_BREAK+ + MARGIN+INDENT+"1000.0" +LINE_BREAK+ + MARGIN+INDENT+"1000.0" +LINE_BREAK+ + MARGIN+"" +LINE_BREAK; + + void define(final String model) throws IOException { + // Populate the meta data for the test model + final URL url = getClass().getResource(model); + xsdHelper.define(url.openStream(), url.toString()); + } + + protected void setUp() throws Exception { + super.setUp(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + //use XMLHelper + public void testSaveXMLDocumentXMLHelper() throws IOException { + final HashMap options = new HashMap(); + options.put(org.apache.tuscany.sdo.api.SDOHelper.XMLOptions.XML_SAVE_INDENT, INDENT); + options.put(org.apache.tuscany.sdo.api.SDOHelper.XMLOptions.XML_SAVE_MARGIN, MARGIN); + options.put(org.apache.tuscany.sdo.api.SDOHelper.XMLOptions.XML_SAVE_LINE_BREAK, LINE_BREAK); + hc = SDOUtil.createHelperContext(false,options); + xsdHelper = hc.getXSDHelper(); + xmlh = hc.getXMLHelper(); + + // Populate the meta data for the test (Stock Quote) model + define("/simpleWithChangeSummary.xsd"); + final XMLDocument doc = xmlh.load(getClass().getResource("/simpleWithChangeSummary.xml").openStream()); + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + xmlh.save(xmlh.createDocument(doc.getRootObject(), doc.getRootElementURI(), doc.getRootElementName()), baos, null); + assertEquals(formatted1, baos.toString()); + } + + //use XMLStreamHelper + public void testSaveXMLDocumentXMLStreamHelper() throws Exception { + final HashMap options = new HashMap(); + options.put(SDOHelper.XMLOptions.XML_LOAD_SCHEMA, Boolean.FALSE); + options.put(org.apache.tuscany.sdo.api.SDOHelper.XMLOptions.XML_SAVE_INDENT, INDENT); + options.put(org.apache.tuscany.sdo.api.SDOHelper.XMLOptions.XML_SAVE_MARGIN, MARGIN); + options.put(org.apache.tuscany.sdo.api.SDOHelper.XMLOptions.XML_SAVE_LINE_BREAK, LINE_BREAK); + final HelperContext hc = SDOUtil.createHelperContext(false, options); + xmlStreamHelper = SDOUtil.createXMLStreamHelper(hc); + + xsdHelper = hc.getXSDHelper(); + define("/simple.xsd"); + + final InputStream inStrm = getClass().getResourceAsStream("/shallowquote.xml"); + final XMLDocument document = hc.getXMLHelper().load(inStrm, null, null); + + final XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); + final StringWriter writer = new StringWriter(); + final XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(writer); + + xmlStreamHelper.save(document, streamWriter, null); + streamWriter.flush(); + assertEquals(formatted2, writer.toString()); + } +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperPerformanceTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperPerformanceTestCase.java new file mode 100644 index 0000000000..ef701059c4 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperPerformanceTestCase.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.test; + + +import java.io.*; +import java.math.BigDecimal; +import java.net.URL; + +import javax.xml.stream.*; + +import org.apache.tuscany.sdo.api.XMLStreamHelper; +import org.apache.tuscany.sdo.api.SDOUtil; + +import junit.framework.TestCase; + +import commonj.sdo.*; +import commonj.sdo.helper.*; + + +public class XMLStreamHelperPerformanceTestCase extends TestCase { + private final String TEST_MODEL = "/XMLStreamHelper.xsd"; + private final String TEST_NAMESPACE = "http://www.example.com/simple"; + + HelperContext hc; + + /** + * Simple Dynamic SDO 2 test. + */ + public void testDynamic() throws Exception { + final TypeHelper typeHelper = hc.getTypeHelper(); + final Type quoteType = typeHelper.getType(TEST_NAMESPACE, "Quote"); + final DataObject quote = hc.getDataFactory().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); + + final DataObject child = quote.createDataObject("quotes"); + child.setBigDecimal("price", new BigDecimal("2000.0")); + + final DataObject quote3 = quote.createDataObject("quotes3"); + quote3.setString("symbol3", "IBM"); + quote3.setString("company3", "IBM Corp."); + + final XMLStreamHelper streamHelper = SDOUtil.createXMLStreamHelper(hc); + final XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); + final StringWriter writer = new StringWriter(); + final XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(writer); + + final XMLDocument doc = hc.getXMLHelper().createDocument(quote, TEST_NAMESPACE, "stockQuote"); + streamHelper.save(doc, streamWriter); + streamWriter.flush(); + assertEquals("fbntFlyByNightTechnology1000.01000.01000.01000.01000.01000.02000.0IBMIBM Corp.",writer.toString()); + } + + protected void setUp() throws Exception { + super.setUp(); + hc = SDOUtil.createHelperContext(); + + // Populate the meta data for the test (Stock Quote) model + final URL url = getClass().getResource(TEST_MODEL); + final InputStream inputStream = url.openStream(); + hc.getXSDHelper().define(inputStream, url.toString()); + inputStream.close(); + + } + +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperTestCase.java new file mode 100644 index 0000000000..35df4909ba --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLStreamHelperTestCase.java @@ -0,0 +1,169 @@ +/** + * + * 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.*; +import java.net.URL; +import java.util.*; + +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.api.XMLStreamHelper; +import org.apache.tuscany.sdo.api.SDOUtil; +import commonj.sdo.DataObject; +import commonj.sdo.helper.*; + +public class XMLStreamHelperTestCase extends TestCase { + + private HelperContext hc; + + private XMLStreamHelper streamHelper; + + private XMLInputFactory inputFactory; + + private XMLOutputFactory outputFactory; + + private final QName module = new QName("http://foo", "module"); + + private final QName name = new QName("http://bar", "implementation.mock"); + + private final String testName = "foo-ext"; + // private String testName = "complex"; + + private String xml; + + // = "1Dummy2"; + + protected void setUp() throws Exception { + super.setUp(); + + hc = SDOUtil.createHelperContext(); + streamHelper = SDOUtil.createXMLStreamHelper(hc); + + URL url = getClass().getClassLoader().getResource(testName + ".xsd"); + hc.getXSDHelper().define(url.openStream(), url.toExternalForm()); + url = getClass().getResource("/mixed.xsd"); + hc.getXSDHelper().define(url.openStream(), url.toString()); + + inputFactory = XMLInputFactory.newInstance(); + outputFactory = XMLOutputFactory.newInstance(); + + url = getClass().getClassLoader().getResource(testName + ".xml"); + final InputStreamReader reader = new InputStreamReader(url.openStream()); + final StringBuffer stringBuffer = new StringBuffer(); + final 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 { + final 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(); + } + final DataObject dataObject = streamHelper.loadObject(reader); + Assert.assertNotNull(dataObject); + Assert.assertTrue(dataObject.getString("myAttr").equals("helloworld.HelloWorldImpl")); + } + + public void testLoadUnqualifiedObject() throws Exception { + final XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(xml.replaceAll("bar:", ""))); + int event = reader.getEventType(); + while (!((event == XMLStreamConstants.START_ELEMENT) && reader.getName().getLocalPart().equals(name.getLocalPart())) && reader.hasNext()) { + event = reader.next(); + } + final Map options = new HashMap(); + options.put(XMLStreamHelper.OPTION_DEFAULT_ROOT_TYPE, hc.getTypeHelper().getType(name.getNamespaceURI(), "MockImplementation")); + final DataObject dataObject = streamHelper.loadObject(reader, options); + Assert.assertNotNull(dataObject); + Assert.assertTrue(dataObject.getString("myAttr").equals("helloworld.HelloWorldImpl")); + } + + public void testLoad() throws Exception { + final XMLStreamReader reader = inputFactory.createXMLStreamReader(new StringReader(xml)); + final XMLDocument document = streamHelper.load(reader); + Assert.assertNotNull(document); + Assert.assertEquals(document.getRootElementURI(), module.getNamespaceURI()); + Assert.assertEquals(document.getRootElementName(), module.getLocalPart()); + final DataObject moduleObject = document.getRootObject(); + final List components = moduleObject.getList("component"); + final DataObject componentObject = (DataObject) components.get(0); + final DataObject implObject = componentObject.getDataObject("implementation.mock"); + Assert.assertTrue(implObject.getString("myAttr").equals("helloworld.HelloWorldImpl")); + } + + public void testSave() throws XMLStreamException { + final XMLDocument document = hc.getXMLHelper().load(xml); + final StringWriter writer = new StringWriter(); + final XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(writer); + streamHelper.save(document, streamWriter); + streamWriter.flush(); + final String xmlStr = writer.toString(); + //System.out.println(xmlStr); + Assert.assertTrue(xmlStr.indexOf("myAttr=\"helloworld.HelloWorldImpl\"")!=-1); + } + + public void testSaveObject() throws XMLStreamException { + final XMLDocument document = hc.getXMLHelper().load(xml); + final DataObject moduleObject = document.getRootObject(); + final List components = moduleObject.getList("component"); + final DataObject componentObject = (DataObject) components.get(0); + final StringWriter writer = new StringWriter(); + final XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(writer); + streamHelper.saveObject(componentObject, streamWriter); + streamWriter.flush(); + Assert.assertTrue(writer.toString().indexOf("myAttr=\"helloworld.HelloWorldImpl\"")!=-1); + } + + public void testSaveSequence() throws IOException, XMLStreamException { + final DataObject quote = hc.getDataFactory().create("http://www.example.com/mixed", "MixedQuote"); + quote.setString("symbol", "fbnt"); + quote.getSequence().addText(0, "testing"); + quote.getSequence().addText("more testing"); + + final StringWriter writer = new StringWriter(); + final XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(writer); + streamHelper.saveObject(quote, streamWriter); + streamWriter.flush(); + //System.out.println(writer); + assertTrue(writer.toString().indexOf("fbnt") != -1); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLUnknownPropertiesTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLUnknownPropertiesTestCase.java new file mode 100644 index 0000000000..63e92503c1 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XMLUnknownPropertiesTestCase.java @@ -0,0 +1,132 @@ +/** + * + * 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.ByteArrayOutputStream; +import java.io.IOException; +import java.io.StringReader; +import java.util.HashMap; +import java.util.Map; + +import junit.framework.Assert; +import junit.framework.TestCase; + +import org.apache.tuscany.sdo.SDOPackage; +import org.apache.tuscany.sdo.api.SDOHelper; +import org.apache.tuscany.sdo.api.SDOUtil; +import commonj.sdo.DataObject; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.XMLDocument; +import commonj.sdo.helper.XMLHelper; + +public class XMLUnknownPropertiesTestCase extends TestCase { + XMLHelper xmlHelper; + Map options; + + protected void setUp() throws Exception { + super.setUp(); + } + + protected void tearDown() throws Exception { + super.tearDown(); + } + + // SDOUtil->SDOHelper->SDOHelperImpl->HelperContextImpl->XMLHelperImpl + public void testOptionUnknownProperties() throws IOException { + options = new HashMap(); + options.put(SDOHelper.XMLOptions.XML_LOAD_UNKNOWN_PROPERTIES, Boolean.TRUE); + + final HelperContext hc = SDOUtil.createHelperContext(true); + hc + .getXSDHelper() + .define("" + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + ""); + + final String xml = + "" + "" + + "my test data0" + + "my test data1" + + ""; + + try { + final XMLDocument xmlDoc = hc.getXMLHelper().load(new StringReader(xml), null, options);// pass + // during + // invoke + + final DataObject root = xmlDoc.getRootObject(); + assertNotSame(root.getType(), SDOPackage.eINSTANCE.getAnyTypeDataObject()); + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + hc.getXMLHelper().save(xmlDoc, baos, null); + assertTrue(baos.toString().indexOf("my test data0") != -1); + assertTrue(baos.toString().indexOf("my test data1") != -1); + } catch (final Exception e) {// (Resource.IOWrappedException featureNotFound) + e.printStackTrace(); + } + } + + public void testOptionUnknownProperties2() throws IOException { + options = new HashMap(); + options.put(SDOHelper.XMLOptions.XML_LOAD_UNKNOWN_PROPERTIES, Boolean.FALSE); + + final HelperContext hc = SDOUtil.createHelperContext(true); + hc + .getXSDHelper() + .define("" + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + "" + + ""); + + final String xml = + "" + "" + + "my test data" + + "my test data" + + ""; + + try { + final XMLDocument xmlDoc = hc.getXMLHelper().load(new StringReader(xml), null, options);// pass + // on + // invokation + final DataObject root = xmlDoc.getRootObject(); + assertNotSame(root.getType(), SDOPackage.eINSTANCE.getAnyTypeDataObject()); + fail(); + } catch (final Exception e) {// (Resource.IOWrappedException featureNotFound) + // e.printStackTrace(); + if (e.getMessage().indexOf("telem") != -1) { + Assert.assertTrue(true); + } + } + } +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java new file mode 100644 index 0000000000..45f92a73b2 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XPathTestCase.java @@ -0,0 +1,125 @@ +/** + * + * 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 junit.framework.TestCase; + +import org.apache.tuscany.sdo.util.SDOUtil; + +import commonj.sdo.DataObject; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.XMLDocument; +import commonj.sdo.helper.XMLHelper; +import commonj.sdo.helper.XSDHelper; + +public class XPathTestCase extends TestCase { + + HelperContext hc; + + protected void setUp() throws Exception { + super.setUp(); + hc = SDOUtil.createHelperContext(); + } + + 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 { + XSDHelper xsdHelper = hc.getXSDHelper(); + XMLHelper xmlHelper = hc.getXMLHelper(); + + 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 { + XSDHelper xsdHelper = hc.getXSDHelper(); + XMLHelper xmlHelper = hc.getXMLHelper(); + + 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]"); + assertNull(noFolder); + } catch (Exception e) { + assertFalse("bad indexing generated exception" + e, true); + } + + try { + noFolder = root.getDataObject("Folder[0]"); + assertNull(noFolder); + } catch (Exception e) { + assertFalse("bad indexing generated exception" + e, true); + } + + try { + noFolder = root.getDataObject("Folder.2"); + assertNull(noFolder); + } catch (Exception e) { + assertFalse("bad indexing generated exception" + e, true); + } + + try { + noFolder = root.getDataObject("Folder.-1"); + assertNull(noFolder); + } catch (Exception e) { + assertFalse("bad indexing generated exception" + e, true); + } + + noFolder = root.getDataObject("Folder[FolderName=foo]"); + assertNull(noFolder); + } +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java new file mode 100644 index 0000000000..b8d3402172 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XSDHelperTestCase.java @@ -0,0 +1,224 @@ +/** + * + * 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.SimpleFactory; +import commonj.sdo.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.DataFactory; +import commonj.sdo.helper.HelperContext; +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 static final String TEST_MODEL2 = "/xsdCorners.xsd"; + private URL modelURL; + private URL xsdCornersURL; + + HelperContext hc; + + protected void setUp() throws Exception { + super.setUp(); + hc = SDOUtil.createHelperContext(); + modelURL = getClass().getResource(TEST_MODEL); + xsdCornersURL = getClass().getResource(TEST_MODEL2); + } + + public void testDefineWithLocation() throws IOException { + XSDHelper xsdHelper = hc.getXSDHelper(); + List types = xsdHelper.define(modelURL.openStream(), modelURL.toString()); + assertEquals(2, types.size()); + } + + public void testDefineWithNoLocation() { + XSDHelper xsdHelper = hc.getXSDHelper(); + List types = xsdHelper.define(getClass().getResourceAsStream(TEST_MODEL), null); + assertEquals(2, types.size()); + } + + public void testDuplicateDefineWithLocation() throws IOException { + XSDHelper xsdHelper = hc.getXSDHelper(); + 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; + + SimpleFactory.INSTANCE.register(hc); + XSDHelper xsdHelper = hc.getXSDHelper(); + DataObject quoteSDO = (DataObject)SimpleFactory.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 = hc.getXSDHelper(); + 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 = hc.getTypeHelper(); + XSDHelper xsdHelper = hc.getXSDHelper(); + + SimpleFactory.INSTANCE.register(hc); + DataObject quoteSDO = (DataObject)SimpleFactory.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); + + } + + public void testPrefixFromNSWithHyphenNumber() throws IOException { + XSDHelper xsdHelper = hc.getXSDHelper(); + xsdHelper.define(xsdCornersURL.openStream(), xsdCornersURL.toString()); + DataFactory df = hc.getDataFactory(); + DataObject root = df.create("http://www.example.com/simple-1", "A"); + root.setString("a1", "a1s"); + root.setString("a2", "a2s"); + + String doc = hc.getXMLHelper().save(root, "http://www.example.com/simple-1", "a"); + assertTrue(doc.indexOf("xmlns:s1=\"http://www.example.com/simple-1\"") != -1); + } + + public void testShortPrefix() throws IOException { + XSDHelper xsdHelper = hc.getXSDHelper(); + URL url = getClass().getResource("/prefix.xsd"); + xsdHelper.define(url.openStream(), url.toString()); + DataObject cmd = hc.getDataFactory().create("http://soaassureservice.soabench.ibm.com", "CreateClaim"); + cmd.setString("requestInfo", "cost"); + String doc = hc.getXMLHelper().save(cmd, "http://soaassureservice.soabench.ibm.com", "createClaim"); + assertTrue(doc.indexOf("xmlns:as=\"http://soaassureservice.soabench.ibm.com\"") != -1); + } +} diff --git a/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XSDQNameTestCase.java b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XSDQNameTestCase.java new file mode 100644 index 0000000000..f369b340ed --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/java/org/apache/tuscany/sdo/test/XSDQNameTestCase.java @@ -0,0 +1,123 @@ +/** + * + * 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.util.regex.Matcher; +import java.util.regex.Pattern; + +import junit.framework.TestCase; + +import commonj.sdo.DataObject; +import commonj.sdo.Type; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.helper.XMLDocument; +import org.apache.tuscany.sdo.api.SDOUtil; + +public class XSDQNameTestCase extends TestCase { + private final String xsdString = + " " + + " " + + " " + + " " + + " " + + " " + + " " + + " " + + ""; + + private final String xmlString = + " " + + " " + + "fbnt " + + "simple:stockQuote " + + ""; + + private final String TEST_NAMESPACE = "http://www.example.com/simple"; + + HelperContext hc; + TypeHelper th; + + /** + * Based on Spec 2.1, section 9.4.1, the return value of DataObject.get() on XSD QName property + * should be http://www.example.com/simple#stockQuote + * TODO add this to the CTS + * + * @throws IOException + */ + public void testLoad() throws IOException { + XMLDocument doc = hc.getXMLHelper().load(xmlString); + DataObject root = doc.getRootObject(); + assertEquals("http://www.example.com/simple#stockQuote", root.get("policy")); + } + + /** + * After serialization, the value of XSD QName property in XML should be :stockQuote + */ + public void testSave() throws IOException { + Type quoteType = th.getType(TEST_NAMESPACE, "Quote"); + DataObject quote = hc.getDataFactory().create(quoteType); + + quote.setString("symbol", "fbnt"); + quote.set("policy", "http://www.example.com/simple#stockQuote"); + + String str = hc.getXMLHelper().save(quote, TEST_NAMESPACE, "stockQuote"); + int start = str.indexOf(""); + int end = str.indexOf(""); + assertTrue(start != -1 && end != -1); + + String policyValue = str.substring(start + "".length(), end); + + Pattern pattern = Pattern.compile(".*:stockQuote"); // prefix can be anything + + Matcher matcher = pattern.matcher(policyValue); + assertTrue(matcher.find()); + } + + /** + * Test the scenario that the xsd:QName property value contains non-existent namespace + */ + public void testSave2() throws IOException { + Type quoteType = th.getType(TEST_NAMESPACE, "Quote"); + DataObject quote = hc.getDataFactory().create(quoteType); + + quote.setString("symbol", "fbnt"); + quote.set("policy", "http://www.example.com/simple2#stockQuote"); + + String str = hc.getXMLHelper().save(quote, TEST_NAMESPACE, "stockQuote"); + + // Make sure the non-existent namespace was serialized + Pattern pattern = Pattern.compile(".*xmlns:.*=\"http://www.example.com/simple2\""); + Matcher matcher = pattern.matcher(str); + assertTrue(matcher.find()); + } + + protected void setUp() throws Exception { + super.setUp(); + + hc = SDOUtil.createHelperContext(); + th = hc.getTypeHelper(); + + hc.getXSDHelper().define(xsdString); + } +} diff --git a/sandbox/kgoodson/events/impl/src/test/resources/SchemaLocationTestCase.xml b/sandbox/kgoodson/events/impl/src/test/resources/SchemaLocationTestCase.xml new file mode 100644 index 0000000000..e13f45a877 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/SchemaLocationTestCase.xml @@ -0,0 +1,33 @@ + + + + some string + + another string + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/SequenceChangeSummary.xsd b/sandbox/kgoodson/events/impl/src/test/resources/SequenceChangeSummary.xsd new file mode 100644 index 0000000000..dd3c2bc2dc --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/SequenceChangeSummary.xsd @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/resources/SubstitutionValues.xsd b/sandbox/kgoodson/events/impl/src/test/resources/SubstitutionValues.xsd new file mode 100644 index 0000000000..e977e6e631 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/SubstitutionValues.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/resources/TypePropertyMetadataInfo.xsd b/sandbox/kgoodson/events/impl/src/test/resources/TypePropertyMetadataInfo.xsd new file mode 100644 index 0000000000..b6d7841ec4 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/TypePropertyMetadataInfo.xsd @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + forest.jpg + + + + + + + + + + getNumber + setNumber + + + + + + + + + + getPhonetype + setPhonetype + + + + + + + + + + + This is the metadata for defining the ExampleNumber type. + + + + + + + + + + + + This is the metadata for defining the PhoneNumber type. + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/resources/XMLDocumentNoNamespaceSchemaLocation.xsd b/sandbox/kgoodson/events/impl/src/test/resources/XMLDocumentNoNamespaceSchemaLocation.xsd new file mode 100644 index 0000000000..c2beb7708d --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/XMLDocumentNoNamespaceSchemaLocation.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/XMLDocumentSchemaLocation.xsd b/sandbox/kgoodson/events/impl/src/test/resources/XMLDocumentSchemaLocation.xsd new file mode 100644 index 0000000000..0561eb555b --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/XMLDocumentSchemaLocation.xsd @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/XMLDocumentTestCase.xml b/sandbox/kgoodson/events/impl/src/test/resources/XMLDocumentTestCase.xml new file mode 100644 index 0000000000..88160e0b2f --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/XMLDocumentTestCase.xml @@ -0,0 +1,14 @@ + + some string + + another string + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/XMLStreamHelper.xsd b/sandbox/kgoodson/events/impl/src/test/resources/XMLStreamHelper.xsd new file mode 100644 index 0000000000..492f61b1d2 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/XMLStreamHelper.xsd @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/anytype.xsd b/sandbox/kgoodson/events/impl/src/test/resources/anytype.xsd new file mode 100644 index 0000000000..db10376360 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/anytype.xsd @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/api_test.xsd b/sandbox/kgoodson/events/impl/src/test/resources/api_test.xsd new file mode 100644 index 0000000000..5238c72605 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/api_test.xsd @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/bank.xsd b/sandbox/kgoodson/events/impl/src/test/resources/bank.xsd new file mode 100644 index 0000000000..a0cb7970b0 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/bank.xsd @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/company.xsd b/sandbox/kgoodson/events/impl/src/test/resources/company.xsd new file mode 100644 index 0000000000..18e99352be --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/company.xsd @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/containmenttest.xsd b/sandbox/kgoodson/events/impl/src/test/resources/containmenttest.xsd new file mode 100644 index 0000000000..e576bc9b41 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/containmenttest.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/customer1.xml b/sandbox/kgoodson/events/impl/src/test/resources/customer1.xml new file mode 100644 index 0000000000..5a29e30a3c --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/customer1.xml @@ -0,0 +1,8 @@ + + \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/resources/customer2.xml b/sandbox/kgoodson/events/impl/src/test/resources/customer2.xml new file mode 100644 index 0000000000..e9ebb92677 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/customer2.xml @@ -0,0 +1,8 @@ + + \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/resources/datatype.xsd b/sandbox/kgoodson/events/impl/src/test/resources/datatype.xsd new file mode 100644 index 0000000000..05f55e0502 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/datatype.xsd @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/dotNames.xsd b/sandbox/kgoodson/events/impl/src/test/resources/dotNames.xsd new file mode 100644 index 0000000000..a788b7b4f4 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/dotNames.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/expectedExceptions.xsd b/sandbox/kgoodson/events/impl/src/test/resources/expectedExceptions.xsd new file mode 100644 index 0000000000..79f90d311d --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/expectedExceptions.xsd @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/foo-ext.xml b/sandbox/kgoodson/events/impl/src/test/resources/foo-ext.xml new file mode 100644 index 0000000000..000909a52e --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/foo-ext.xml @@ -0,0 +1,9 @@ + + + 1Dummy2 + + + \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/resources/foo-ext.xsd b/sandbox/kgoodson/events/impl/src/test/resources/foo-ext.xsd new file mode 100644 index 0000000000..4cdfd1bcd6 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/foo-ext.xsd @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/foo.xsd b/sandbox/kgoodson/events/impl/src/test/resources/foo.xsd new file mode 100644 index 0000000000..f50002ec3d --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/foo.xsd @@ -0,0 +1,232 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/mixed.xml b/sandbox/kgoodson/events/impl/src/test/resources/mixed.xml new file mode 100644 index 0000000000..42ff3a3a5b --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/mixed.xml @@ -0,0 +1,9 @@ + + + fbnt + FlyByNightTechnology + some text + 2000.0 + more text + 1000.0 + \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/resources/mixed.xsd b/sandbox/kgoodson/events/impl/src/test/resources/mixed.xsd new file mode 100644 index 0000000000..deee92e9c1 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/mixed.xsd @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/mixed2.xml b/sandbox/kgoodson/events/impl/src/test/resources/mixed2.xml new file mode 100644 index 0000000000..d95d179478 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/mixed2.xml @@ -0,0 +1,12 @@ + + + fbnt + FlyByNightTechnology + some text + 2000.0 + more text + 1000.0 + \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/resources/mixedChangeSummary.xml b/sandbox/kgoodson/events/impl/src/test/resources/mixedChangeSummary.xml new file mode 100644 index 0000000000..49dbb89f38 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/mixedChangeSummary.xml @@ -0,0 +1,11 @@ + + + + fbnt + FlyByNightTechnology + 1000.0 + + 2000.02000.99 + + +FBNTFlyByNightTechnology999.01500.02500.01000.03000.04000.0 \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/resources/mixedChangeSummaryUndone.xml b/sandbox/kgoodson/events/impl/src/test/resources/mixedChangeSummaryUndone.xml new file mode 100644 index 0000000000..d8097ace8b --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/mixedChangeSummaryUndone.xml @@ -0,0 +1,2 @@ + +fbntFlyByNightTechnology1000.01500.02000.02000.992500.0 \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/resources/mixedopen.xml b/sandbox/kgoodson/events/impl/src/test/resources/mixedopen.xml new file mode 100644 index 0000000000..21a62ef2d0 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/mixedopen.xml @@ -0,0 +1,13 @@ + + + fbnt + FlyByNightTechnology + some text + 2000.0 + more text + 1000.0 + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/names.xsd b/sandbox/kgoodson/events/impl/src/test/resources/names.xsd new file mode 100644 index 0000000000..9096b2d62f --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/names.xsd @@ -0,0 +1,33 @@ + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/open.xml b/sandbox/kgoodson/events/impl/src/test/resources/open.xml new file mode 100644 index 0000000000..d4a5b92e0c --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/open.xml @@ -0,0 +1,8 @@ + + + s1 + + FlyByNightTechnology + + 1000.0 + \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/resources/open.xsd b/sandbox/kgoodson/events/impl/src/test/resources/open.xsd new file mode 100644 index 0000000000..803c0a9cee --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/open.xsd @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/open1any.xsd b/sandbox/kgoodson/events/impl/src/test/resources/open1any.xsd new file mode 100644 index 0000000000..00efaef5e0 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/open1any.xsd @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/open2.xml b/sandbox/kgoodson/events/impl/src/test/resources/open2.xml new file mode 100644 index 0000000000..ab992ccf74 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/open2.xml @@ -0,0 +1,9 @@ + + + s1 + + 1000.0 + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/openChangeSummary.xml b/sandbox/kgoodson/events/impl/src/test/resources/openChangeSummary.xml new file mode 100644 index 0000000000..4ef2dc5948 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/openChangeSummary.xml @@ -0,0 +1,24 @@ + + + FBNT + + 1500.0 + + + 2500.0 + + + 3000.0 + + + 4000.0 + + + + fbnt + + 2000.02000.99 + + + + \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/resources/openChangeSummaryUndone.xml b/sandbox/kgoodson/events/impl/src/test/resources/openChangeSummaryUndone.xml new file mode 100644 index 0000000000..9883a3824a --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/openChangeSummaryUndone.xml @@ -0,0 +1,17 @@ + + + fbnt + + 1500.0 + + + 2000.0 + + 2000.99 + + + + 2500.0 + + + \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/resources/openContentProperty.xml b/sandbox/kgoodson/events/impl/src/test/resources/openContentProperty.xml new file mode 100644 index 0000000000..03608365c0 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/openContentProperty.xml @@ -0,0 +1,12 @@ + + + s1 + + FlyByNightTechnology + + 1000.0 + 1100.0 + + mutual-1 + + \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/resources/po.xsd b/sandbox/kgoodson/events/impl/src/test/resources/po.xsd new file mode 100644 index 0000000000..5c53ac1905 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/po.xsd @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/prefix.xsd b/sandbox/kgoodson/events/impl/src/test/resources/prefix.xsd new file mode 100644 index 0000000000..af3d3283f5 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/prefix.xsd @@ -0,0 +1,24 @@ + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/quote.xml b/sandbox/kgoodson/events/impl/src/test/resources/quote.xml new file mode 100644 index 0000000000..d7b5969e23 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/quote.xml @@ -0,0 +1,14 @@ + + + fbnt + FlyByNightTechnology + 1000.0 + 1000.0 + 1000.0 + 1000.0 + 1000.0 + 1000.0 + + 2000.0 + + \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/resources/quoteInSOAP.xml b/sandbox/kgoodson/events/impl/src/test/resources/quoteInSOAP.xml new file mode 100644 index 0000000000..4ee083c90c --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/quoteInSOAP.xml @@ -0,0 +1,19 @@ + + + + + + fbnt + FlyByNightTechnology + 1000.0 + 1000.0 + 1000.0 + 1000.0 + 1000.0 + 1000.0 + + 2000.0 + + + + \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/resources/sdoModel.xsd b/sandbox/kgoodson/events/impl/src/test/resources/sdoModel.xsd new file mode 100644 index 0000000000..645b7b700a --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/sdoModel.xsd @@ -0,0 +1,28 @@ + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/sdoannotations.xsd b/sandbox/kgoodson/events/impl/src/test/resources/sdoannotations.xsd new file mode 100644 index 0000000000..acdde2896a --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/sdoannotations.xsd @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/sdotypes.xsd b/sandbox/kgoodson/events/impl/src/test/resources/sdotypes.xsd new file mode 100644 index 0000000000..09c05bb671 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/sdotypes.xsd @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/shallowquote.xml b/sandbox/kgoodson/events/impl/src/test/resources/shallowquote.xml new file mode 100644 index 0000000000..a56f2fe2b7 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/shallowquote.xml @@ -0,0 +1,11 @@ + + + fbnt + FlyByNightTechnology + 1000.0 + 1000.0 + 1000.0 + 1000.0 + 1000.0 + 1000.0 + \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/resources/shallowquote1.xml b/sandbox/kgoodson/events/impl/src/test/resources/shallowquote1.xml new file mode 100644 index 0000000000..5931826628 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/shallowquote1.xml @@ -0,0 +1,11 @@ + + + fbnt + FlyByNightTechnology + 1000.0 + 1000.0 + 1000.0 + 1000.0 + 1000.0 + 1000.0 + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/simple.xsd b/sandbox/kgoodson/events/impl/src/test/resources/simple.xsd new file mode 100644 index 0000000000..661259e57a --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/simple.xsd @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/simple2.xsd b/sandbox/kgoodson/events/impl/src/test/resources/simple2.xsd new file mode 100644 index 0000000000..4be4bac95b --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/simple2.xsd @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/simple3.xsd b/sandbox/kgoodson/events/impl/src/test/resources/simple3.xsd new file mode 100644 index 0000000000..6ff14a85d2 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/simple3.xsd @@ -0,0 +1,34 @@ + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/simpleWithChangeSummary.xml b/sandbox/kgoodson/events/impl/src/test/resources/simpleWithChangeSummary.xml new file mode 100644 index 0000000000..d8ecf8f398 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/simpleWithChangeSummary.xml @@ -0,0 +1,28 @@ + + + FBNT + FlyByNightTechnology + 999.0 + 1000.0 + + 1500.0 + + + 2500.0 + + + 3000.0 + + + 4000.0 + + + + fbnt + 1000.0 + + 2000.02000.99 + + + + \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/resources/simpleWithChangeSummary.xsd b/sandbox/kgoodson/events/impl/src/test/resources/simpleWithChangeSummary.xsd new file mode 100644 index 0000000000..1df0f69196 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/simpleWithChangeSummary.xsd @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/simpleWithChangeSummaryUndone.xml b/sandbox/kgoodson/events/impl/src/test/resources/simpleWithChangeSummaryUndone.xml new file mode 100644 index 0000000000..e2bbc56d2d --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/simpleWithChangeSummaryUndone.xml @@ -0,0 +1,19 @@ + + + fbnt + FlyByNightTechnology + 1000.0 + + 1500.0 + + + 2000.0 + + 2000.99 + + + + 2500.0 + + + \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/resources/simplechangesummary.xml b/sandbox/kgoodson/events/impl/src/test/resources/simplechangesummary.xml new file mode 100644 index 0000000000..134e2f7de5 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/simplechangesummary.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + fbnt + FlyByNightTechnology + 1000.0 + 1000.0 + 1000.0 + 1000.0 + 1000.0 + 1000.0 + + 2000.0 + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/substitutionValues1.xml b/sandbox/kgoodson/events/impl/src/test/resources/substitutionValues1.xml new file mode 100644 index 0000000000..e891cb1073 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/substitutionValues1.xml @@ -0,0 +1,5 @@ + + + gm + ngh + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/substitutionValues2.xml b/sandbox/kgoodson/events/impl/src/test/resources/substitutionValues2.xml new file mode 100644 index 0000000000..97033de147 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/substitutionValues2.xml @@ -0,0 +1,5 @@ + + + gh + ngh + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/xpath.xml b/sandbox/kgoodson/events/impl/src/test/resources/xpath.xml new file mode 100644 index 0000000000..3b3e2ffbb4 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/xpath.xml @@ -0,0 +1,51 @@ + + + + Folder00000000000 + marries inflamed apprehended beseeming bustle + + + + Brian + rw + + + Fuhwei + r + + + + + Hasan + + + Frank + + + + + + Folder00000000011 + Mumbling Jumblin Pink Panther goofs it up + + + + Imad + x + + + Robbie + rwx + + + + + Yang + + + Art + + + + + \ No newline at end of file diff --git a/sandbox/kgoodson/events/impl/src/test/resources/xpath.xsd b/sandbox/kgoodson/events/impl/src/test/resources/xpath.xsd new file mode 100644 index 0000000000..0b817d425d --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/xpath.xsd @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/impl/src/test/resources/xsdCorners.xsd b/sandbox/kgoodson/events/impl/src/test/resources/xsdCorners.xsd new file mode 100644 index 0000000000..b62bfcae56 --- /dev/null +++ b/sandbox/kgoodson/events/impl/src/test/resources/xsdCorners.xsd @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + diff --git a/sandbox/kgoodson/events/lib/pom.xml b/sandbox/kgoodson/events/lib/pom.xml new file mode 100644 index 0000000000..d9c7ee3aa6 --- /dev/null +++ b/sandbox/kgoodson/events/lib/pom.xml @@ -0,0 +1,96 @@ + + + + + org.apache.tuscany.sdo + tuscany-sdo + 1.0-incubating-SNAPSHOT + + 4.0.0 + tuscany-sdo-lib + Tuscany SDO Library + Tuscany SDO implementation library. + jar + kgoodson-sandbox + + + + codehaus + Codehaus maven repository + http://repository.codehaus.org/ + + + + + + org.apache.tuscany.sdo + tuscany-sdo-api-r${specVersion} + + + + + stax + stax-api + 1.0.1 + provided + true + + + + + junit + junit + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + src/main/resources/META-INF/MANIFEST.MF + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + ${basedir}/src/main/java/org/apache/tuscany/sdo/api/overview.html + 2.0 + 1.4 + org.apache.tuscany.sdo.lib:org.apache.tuscany.sdo.spi + + + + package + package + + jar + + + + + + + + diff --git a/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/Event.java b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/Event.java new file mode 100644 index 0000000000..e38b465df4 --- /dev/null +++ b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/Event.java @@ -0,0 +1,61 @@ +package org.apache.tuscany.sdo.api; + +import commonj.sdo.Property; + +public interface Event { + + Object getNotifier(); + + int SET = 1; + int UNSET = 2; + int ADD = 3; + int REMOVE = 4; + int ADD_MANY = 5; + int REMOVE_MANY = 6; + int MOVE = 7; + + int getEventType(); + + + int NO_FEATURE_ID = -1; + + + Property getProperty(); + Object getOldValue(); + Object getNewValue(); + boolean wasSet(); + boolean isTouch(); + + + int NO_INDEX = -1; + int getPosition(); + + + boolean getOldBooleanValue(); + boolean getNewBooleanValue(); + + byte getOldByteValue(); + byte getNewByteValue(); + + char getOldCharValue(); + char getNewCharValue(); + + double getOldDoubleValue(); + double getNewDoubleValue(); + + float getOldFloatValue(); + float getNewFloatValue(); + + int getOldIntValue(); + int getNewIntValue(); + + long getOldLongValue(); + long getNewLongValue(); + + short getOldShortValue(); + short getNewShortValue(); + + String getOldStringValue(); + String getNewStringValue(); + } + diff --git a/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/EventListener.java b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/EventListener.java new file mode 100644 index 0000000000..8bfdde46ba --- /dev/null +++ b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/EventListener.java @@ -0,0 +1,8 @@ +package org.apache.tuscany.sdo.api; + + +public interface EventListener { + + public void eventNotification(Event e); + +} diff --git a/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/SDOHelper.java b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/SDOHelper.java new file mode 100644 index 0000000000..838770dc18 --- /dev/null +++ b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/SDOHelper.java @@ -0,0 +1,413 @@ +/** + * + * 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.api; + +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.sdo.api.XMLStreamHelper; + +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.HelperContext; +import commonj.sdo.helper.TypeHelper; + +/** + * This interface provides helper functions which are not included in the SDO specification itself. + * Use of the functions in this interface is recommended, instead of resorting to low-level + * implementation-specific APIs. + */ +public interface SDOHelper +{ + /** + * Create a non-extensible HelperContext to provide access to a consistent set of Helpers which make use + * of a new TypeHelper instance to provide scope for type definitions. + * @return the new HelperContext + * @see #createHelperContext(boolean) + */ + public HelperContext createHelperContext(); + + /** + * Create a non-extensible HelperContext to provide access to a consistent set of Helpers which make use + * of a new TypeHelper instance to provide scope for type definitions. + * @param options Map of default XMLOptions + * @return the new HelperContext + * @see #createHelperContext(boolean) + */ + public HelperContext createHelperContext(boolean extensibleNamespaces, Map options); + + /** + * Create a HelperContext to provide access to a consistent set of Helpers which make use of a new + * TypeHelper instance to provide scope for type definitions. + * @param extensibleNamespaces true if the contents of a namespaces should be incrementally modifiable over time + * @return the new HelperContext + */ + public HelperContext createHelperContext(boolean extensibleNamespaces); + + /** + * create a non-extensible HelperContext with default load/save options + * @param options default load/save options from XMLOptions + * @return the new HelperContext + */ + public HelperContext createHelperContext(Map options); + + /** + * 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 Object createFromString(Type dataType, String 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 String convertToString(Type dataType, Object value); + + /** + * 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 DataObject createDataTypeWrapper(Type dataType, Object 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 Type getXSDSDOType(String xsdType); + + /** + * 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 Sequence getSubstitutionValues(DataObject dataObject, Property head); + + /** + * 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 Type getJavaSDOType(Class javaClass); + + /** + * 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 boolean isRequired(Property property); + + /** + * Return the upper bound of the specified property or -1 if unbounded. + * @param the property in question. + * @return the upper bound. + */ + public int getUpperBound(Property property); + + /** + * 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 boolean isMany(Property property, DataObject context); + + /** + * Create an empty data graph. + * @return the new data graph instance. + */ + public DataGraph 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 void setRootObject(DataGraph dataGraph, DataObject 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. + * @param hc the HelperContext in which to register deserialized Types and to find Types when + * creating DataObject instances, or null for default HelperContext. + * @return the de-serialized data graph. + * @throws IOException + */ + public DataGraph loadDataGraph(InputStream inputStream, Map options, HelperContext hc) throws IOException; + + /** + * 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 void saveDataGraph(DataGraph dataGraph, OutputStream outputStream, Map options) throws IOException; + + /** + * 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 void registerDataGraphTypes(DataGraph dataGraph, List/*Type*/types); + + /** + * Create a new cross scope CopyHelper. + * @param hc the HelperContext containing the Types to use to create the copy objects. + * @return the new CopyHelper. + */ + public CopyHelper createCrossScopeCopyHelper(HelperContext targetScope); + + + /** + * Create a new XMLStreamHelper, with visibility to types in the specified HelperContext scope. + * @param hc the HelperContext to use for locating types. + * @return the new XMLStreamHelper. + */ + public XMLStreamHelper createXMLStreamHelper(HelperContext hc); + + /** + * Create a new ObjectInputStream in the specifice HelperContext scope. + * @param inputStream the inputStream with which to create the ObjectInputStream. + * @param helperContext the HelperContext scope. + * @return the new ObjectInputStream. + */ + public ObjectInputStream createObjectInputStream(InputStream inputStream, HelperContext helperContext) throws IOException; + + /** + * Create a new ObjectOutputStream in the specifice HelperContext scope. + * @param outputStream the outputStream with which to create the ObjectOutputStream. + * @param helperContext the HelperContext scope. + * @return the new ObjectOutputStream. + */ + public ObjectOutputStream createObjectOutputStream(OutputStream outputStream, HelperContext helperContext) throws IOException; + + /** + * Gets all of the types associated with a uri. + * @param hc the HelperContext to use for locating types. + * @param uri the URI of the Types + * @return a List containing instances of Type, null if uri is not found. + */ + public List getTypes(HelperContext hc, String uri); + + /** + * Gets the open content subset of the specified DataObject's instance properties. + * @param dataObject the DataObject instance + * @return a List containing any open content properties of the DataObject + */ + public List getOpenContentProperties(DataObject dataObject); + + /** + * Return true if the specified type is a special DocumentRoot Type. + * @param type the Type in question + * @return true if type is a DocumentRoot + */ + public boolean isDocumentRoot(Type type); + + /** + * Return an XPath from the containment root to the specified DataObject. + * @param dataObject a DataObject + * @return the XPath from the containment root. + */ + public String getXPath(DataObject dataObject); + + /** + * Gets a MetaDataBuilder which can be used to programatically create SDO Types and Properties. + * @return a MetaDataBuilder instance + */ + public MetaDataBuilder getMetaDataBuilder(); + + /** + * This interface provides methods which can be used to programatically create SDO Types and Properties. + * It provides a lower level and more efficient API then the DataObject-based one of TypeHelper.define(). + */ + public interface MetaDataBuilder + { + + /** + * Create a Type in the specified TypeHelper scope. + * @return the new Type. + */ + public Type createType(HelperContext hc, String uri, String name, boolean isDataType); + + /** + * Add a baseType to the specified type. + */ + public void addBaseType(Type type, Type baseType); + + /** + * Add an aliasName to the specified type. + */ + public void addAliasName(Type type, String aliasName); + + /** + * Set the isOpen value of the specified type. + */ + public void setOpen(Type type, boolean isOpen); + + /** + * Set the isSequenced value of the specified type. + */ + public void setSequenced(Type type, boolean isSequenced); + + /** + * Set the isAbstract value of the specified type. + */ + public void setAbstract(Type type, boolean isAbstract); + + /** + * Set the isAbstract value of the specified type. + */ + public void setJavaClassName(Type type, String javaClassName); + + /** + * Create a new property in the specified containingType. + */ + public Property createProperty(Type containingType, String name, Type propertyType); + + /** + * Set a SDO property to become an XSD element or attribute + */ + public void setPropertyXMLKind(Property property, boolean isXmlElement); + + /** + * Create a new open content property in the specified TypeHelper scope. + */ + public Property createOpenContentProperty(HelperContext hc, String uri, String name, Type type); + + /** + * Add an aliasName to the specified property. + */ + public void addAliasName(Property property, String aliasName); + + /** + * Set the isMany value of the specified property. + */ + public void setMany(Property property, boolean isMany); + + /** + * Set the isContainment value of the specified property. + */ + public void setContainment(Property property, boolean isContainment); + + /** + * Set the default value of the specified property. + */ + public void setDefault(Property property, String defaultValue); + + /** + * Set the isReadOnly value of the specified property. + */ + public void setReadOnly(Property property, boolean isReadOnly); + + /** + * Set the opposite value of the specified property. + */ + public void setOpposite(Property property, Property opposite); + + /** + * Add an instance property to the specified type. + */ + public void addTypeInstanceProperty(Type definedType, Property instanceProperty, Object value); + + /** + * Add anf instance property to the specified property. + */ + public void addPropertyInstanceProperty(Property definedProperty, Property instanceProperty, Object value); + } + + /** + * This interface contains options that can be passed to the XMLHelper load() and save() methods. + */ + public interface XMLOptions + { + /** + * Line Break String such as "\n", "\r\n", "\r" and "", absence/null is the default (line.separator System Property) + */ + final String XML_SAVE_LINE_BREAK = "LineBreak"; + + /** + * Indent String such as "\t", "", etc. absence/null is the default (" ") + */ + final String XML_SAVE_INDENT = "indent"; + + /** + * Margin String such as " ", "\t\t", etc. Absence/null/"" is the default (no margin) + */ + final String XML_SAVE_MARGIN = "margin"; + + /** + * Attribute formatting that exceeds the specified width as Integer will cause a line break so that formatting will continue indented on the next line + */ + final String XML_SAVE_LINE_WIDTH = "LINE_WIDTH"; + + /** + * Boolean to save a doctype declaration + */ + final String XML_SAVE_DOCTYPE = "SAVE_DOCTYPE"; + + /** + * Boolean to process the schemaLocation/noNamespaceSchemaLocation attributes occurring in the instance document to {@link XSDHelper#define convert XSD(s) to Types} + */ + final String XML_LOAD_SCHEMA = "ProcessSchemaLocations"; + + /** + * To tolerate malformed elements and attributes (default unless set by System property XML.load.form.lax). 0 not to. + */ + final String XML_LOAD_LAX_FORM = "load malform"; + + /** + * Allows you to record unknown features during deserialization/loading. + * The default is Boolean.FALSE unless set to Boolean.TRUE explicitly. + */ + final String XML_LOAD_UNKNOWN_PROPERTIES = "load unknown properties"; + } + + public void addChangeListener(DataObject quote, EventListener listener); + +} diff --git a/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/SDOUtil.java b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/SDOUtil.java new file mode 100644 index 0000000000..17ce7ce28c --- /dev/null +++ b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/SDOUtil.java @@ -0,0 +1,412 @@ +/** + * + * 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.api; + +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.OutputStream; +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.sdo.spi.HelperProviderBase; + +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.HelperContext; +import commonj.sdo.helper.TypeHelper; +import commonj.sdo.impl.HelperProvider; + +/** + * This class provides convenient static utility functions for calling the default SDOHelper. + */ +public final class SDOUtil +{ + protected static SDOHelper defaultSDOHelper = ((HelperProviderBase)HelperProvider.INSTANCE).sdoHelper(); + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#createDataTypeWrapper(Type, Object)}. + */ + public static DataObject createDataTypeWrapper(Type dataType, Object value) + { + return defaultSDOHelper.createDataTypeWrapper(dataType, value); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#createFromString(Type, String)}. + */ + public static Object createFromString(Type dataType, String literal) + { + return defaultSDOHelper.createFromString(dataType, literal); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#convertToString(Type, Object)}. + */ + public static String convertToString(Type dataType, Object value) + { + return defaultSDOHelper.convertToString(dataType, value); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#getXSDSDOType(String)}. + */ + public static Type getXSDSDOType(String xsdType) + { + return defaultSDOHelper.getXSDSDOType(xsdType); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#getSubstitutionValues(DataObject, Property)}. + */ + public static Sequence getSubstitutionValues(DataObject dataObject, Property head) + { + return defaultSDOHelper.getSubstitutionValues(dataObject, head); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#getJavaSDOType(Class)}. + */ + public static Type getJavaSDOType(Class javaClass) + { + return defaultSDOHelper.getJavaSDOType(javaClass); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#isRequired(Property)}. + */ + public static boolean isRequired(Property property) + { + return defaultSDOHelper.isRequired(property); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#getUpperBound(Property)}. + */ + public static int getUpperBound(Property property) + { + return defaultSDOHelper.getUpperBound(property); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#isMany(Property, DataObject)}. + */ + public static boolean isMany(Property property, DataObject context) + { + return defaultSDOHelper.isMany(property, context); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#createDataGraph}. + */ + public static DataGraph createDataGraph() + { + return defaultSDOHelper.createDataGraph(); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#setRootObject(DataGraph, DataObject)}. + */ + public static void setRootObject(DataGraph dataGraph, DataObject rootObject) + { + defaultSDOHelper.setRootObject(dataGraph, rootObject); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#loadDataGraph(InputStream, Map, TypeHelper)}. + */ + public static DataGraph loadDataGraph(InputStream inputStream, Map options) throws IOException + { + return defaultSDOHelper.loadDataGraph(inputStream, options, (HelperContext)null); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#loadDataGraph(InputStream, Map, HelperContext)}. + */ + public static DataGraph loadDataGraph(InputStream inputStream, Map options, HelperContext hc) throws IOException + { + return defaultSDOHelper.loadDataGraph(inputStream, options, hc); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#saveDataGraph(DataGraph, OutputStream, Map)}. + */ + public static void saveDataGraph(DataGraph dataGraph, OutputStream outputStream, Map options) throws IOException + { + defaultSDOHelper.saveDataGraph(dataGraph, outputStream, options); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#registerDataGraphTypes(DataGraph, List)}. + */ + public static void registerDataGraphTypes(DataGraph dataGraph, List/*Type*/ types) + { + defaultSDOHelper.registerDataGraphTypes(dataGraph, types); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#createHelperContext(boolean,Map)}. + */ + public static HelperContext createHelperContext(boolean extensibleNamespaces,Map options){ + return defaultSDOHelper.createHelperContext(extensibleNamespaces, options); + } + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#createHelperContext(boolean)}. + */ + public static HelperContext createHelperContext(boolean extensibleNamespaces) + { + return defaultSDOHelper.createHelperContext(extensibleNamespaces); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#createHelperContext}. + */ + public static HelperContext createHelperContext(Map options) + { + return defaultSDOHelper.createHelperContext(options); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#createHelperContext}. + */ + public static HelperContext createHelperContext() + { + return defaultSDOHelper.createHelperContext(); + } + + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#createCrossScopeCopyHelper(HelperContext)}. + */ + public static CopyHelper createCrossScopeCopyHelper(HelperContext hc) + { + return defaultSDOHelper.createCrossScopeCopyHelper(hc); + } + + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#createXMLStreamHelper(HelperContext)}. + */ + public static XMLStreamHelper createXMLStreamHelper(HelperContext hc) + { + return defaultSDOHelper.createXMLStreamHelper(hc); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#createObjectInputStream(InputStream, HelperContext)}. + */ + public static ObjectInputStream createObjectInputStream(InputStream inputStream, HelperContext helperContext) throws IOException + { + return defaultSDOHelper.createObjectInputStream(inputStream, helperContext); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#createObjectOutputStream(OutputStream, HelperContext)}. + */ + public static ObjectOutputStream createObjectOutputStream(OutputStream outputStream, HelperContext helperContext) throws IOException + { + return defaultSDOHelper.createObjectOutputStream(outputStream, helperContext); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#getTypes(HelperContext, String)}. + */ + public static List getTypes(HelperContext hc, String uri) { + + return defaultSDOHelper.getTypes(hc, uri); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#getOpenContentProperties(DataObject)}. + */ + public static List getOpenContentProperties(DataObject dataObject) + { + return defaultSDOHelper.getOpenContentProperties(dataObject); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#isDocumentRoot(Type)}. + */ + public static boolean isDocumentRoot(Type type) + { + return defaultSDOHelper.isDocumentRoot(type); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper#getXPath(DataObject)}. + */ + public static String getXPath(DataObject dataObject) + { + return defaultSDOHelper.getXPath(dataObject); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#createType(HelperContext, String, String, boolean)}. + */ + public static Type createType(HelperContext hc, String uri, String name, boolean isDataType) + { + return defaultSDOHelper.getMetaDataBuilder().createType(hc, uri, name, isDataType); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#addBaseType(Type, Type)}. + */ + public static void addBaseType(Type type, Type baseType) + { + defaultSDOHelper.getMetaDataBuilder().addBaseType(type, baseType); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#addAliasName(Type, String)}. + */ + public static void addAliasName(Type type, String aliasName) + { + defaultSDOHelper.getMetaDataBuilder().addAliasName(type, aliasName); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#setOpen(Type, boolean)}. + */ + public static void setOpen(Type type, boolean isOpen) + { + defaultSDOHelper.getMetaDataBuilder().setOpen(type, isOpen); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#setSequenced(Type, boolean)}. + */ + public static void setSequenced(Type type, boolean isSequenced) + { + defaultSDOHelper.getMetaDataBuilder().setSequenced(type, isSequenced); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#setAbstract(Type, boolean)}. + */ + public static void setAbstract(Type type, boolean isAbstract) + { + defaultSDOHelper.getMetaDataBuilder().setAbstract(type, isAbstract); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#setJavaClassName(Type, String)}. + */ + public static void setJavaClassName(Type type, String javaClassName) + { + defaultSDOHelper.getMetaDataBuilder().setJavaClassName(type, javaClassName); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#createProperty(Type, String, Type)}. + */ + public static Property createProperty(Type containingType, String name, Type propertyType) + { + return defaultSDOHelper.getMetaDataBuilder().createProperty(containingType, name, propertyType); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#setPropertyXMLKind(Property, boolean)}. + */ + public static void setPropertyXMLKind(Property property, boolean isXmlElement) { + defaultSDOHelper.getMetaDataBuilder().setPropertyXMLKind(property, isXmlElement); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#createOpenContentProperty(TypeHelper, String, String, Type)}. + */ + public static Property createOpenContentProperty(HelperContext hc, String uri, String name, Type type) + { + return defaultSDOHelper.getMetaDataBuilder().createOpenContentProperty(hc, uri, name, type); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#addAliasName(Property, String)}. + */ + public static void addAliasName(Property property, String aliasName) + { + defaultSDOHelper.getMetaDataBuilder().addAliasName(property, aliasName); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#setMany(Property, boolean)}. + */ + public static void setMany(Property property, boolean isMany) + { + defaultSDOHelper.getMetaDataBuilder().setMany(property, isMany); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#setContainment(Property, boolean)}. + */ + public static void setContainment(Property property, boolean isContainment) + { + defaultSDOHelper.getMetaDataBuilder().setContainment(property, isContainment); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#setDefault(Property, String)}. + */ + public static void setDefault(Property property, String defaultValue) + { + defaultSDOHelper.getMetaDataBuilder().setDefault(property, defaultValue); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#setReadOnly(Property, boolean)}. + */ + public static void setReadOnly(Property property, boolean isReadOnly) + { + defaultSDOHelper.getMetaDataBuilder().setReadOnly(property, isReadOnly); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#setOpposite(Property, Property)}. + */ + public static void setOpposite(Property property, Property opposite) + { + defaultSDOHelper.getMetaDataBuilder().setOpposite(property, opposite); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#addTypeInstanceProperty(Type, Property, Object)}. + */ + public static void addTypeInstanceProperty(Type definedType, Property property, Object value) + { + defaultSDOHelper.getMetaDataBuilder().addTypeInstanceProperty(definedType, property, value); + } + + /** + * @see {@link org.apache.tuscany.sdo.api.SDOHelper.MetaDataBuilder#addPropertyInstanceProperty(Property, Property, Object)}. + */ + public static void addPropertyInstanceProperty(Property definedProperty, Property property, Object value) + { + defaultSDOHelper.getMetaDataBuilder().addPropertyInstanceProperty(definedProperty, property, value); + } + + public static void addChangeListener(DataObject quote, EventListener l) { + defaultSDOHelper.addChangeListener(quote, l); + } + +} diff --git a/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/XMLStreamHelper.java b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/XMLStreamHelper.java new file mode 100644 index 0000000000..094f05a703 --- /dev/null +++ b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/XMLStreamHelper.java @@ -0,0 +1,125 @@ +/** + * + * 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.api; + +import java.util.Map; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamReader; +import javax.xml.stream.XMLStreamWriter; + +import commonj.sdo.DataObject; +import commonj.sdo.helper.HelperContext; +import commonj.sdo.helper.XMLDocument; + +/** + * Helper interface for reading and writing SDO DataObjects from XML streams + * (StAX). + * + * @version $Rev: 503913 $ $Date: 2007-02-05 17:53:34 -0500 (Mon, 05 Feb 2007) $ + */ +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; + + void save(XMLDocument document, XMLStreamWriter writer, Map options) 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; + + /** + * Default Type to load DataObject if the element is unqualified/local + * without xsi:type or the qualified/global element or xsi:type fail to + * resolve. Can be null. + */ + String OPTION_DEFAULT_ROOT_TYPE = "default root type"; + + /** + * 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 + * @param options {@link OPTION_DEFAULT_ROOT_TYPE}; can be null or empty + * @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, Map options) 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; + + void saveObject(DataObject sdo, XMLStreamWriter writer, Map options) 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); + + HelperContext getHelperContext(); +} diff --git a/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/overview.html b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/overview.html new file mode 100644 index 0000000000..c6bd255b8f --- /dev/null +++ b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/api/overview.html @@ -0,0 +1,38 @@ + + + + Tuscany API extensions to Service Data Objects (SDO) + + +

      Tuscany API extensions to Service Data Objects (SDO)

      +

      Overview

      +

      +The "org.apache.tuscany.sdo.api" package represents Tuscany API for SDO Java +above and beyond what is offered by the SDO API itself. The contents of this +project provide a means to achieve operations that are not currently addressed +by the SDO API. +

      +

      +The SDOUtil class simply provides a set of static convenince methods for +exercising the methods of a default instance of the SDOHelper interface. +

      + + diff --git a/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectInputStream.java b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectInputStream.java new file mode 100644 index 0000000000..44987f9d7b --- /dev/null +++ b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectInputStream.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.lib; + +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; + +import commonj.sdo.helper.HelperContext; + +/** + * This subclass of ObjectInputStream provides a place to store the scope in which + * it was created. + */ +public class SDOObjectInputStream extends ObjectInputStream { + + private HelperContext helperContext; + + public SDOObjectInputStream(InputStream in, HelperContext helperContext) throws IOException{ + super(in); + this.helperContext = helperContext; + } + + public HelperContext getHelperContext() { + return helperContext; + } + + public void setHelperContext(HelperContext helperContext) { + this.helperContext = helperContext; + } + +} diff --git a/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectOutputStream.java b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectOutputStream.java new file mode 100644 index 0000000000..1610e1c6de --- /dev/null +++ b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectOutputStream.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.lib; + +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.io.OutputStream; + +import commonj.sdo.helper.HelperContext; + +/** + * This subclass of ObjectOutputStream provides a place to store the scope in which + * it was created. + */ +public class SDOObjectOutputStream extends ObjectOutputStream { + + private HelperContext helperContext; + + public SDOObjectOutputStream(OutputStream os, HelperContext helperContext) throws IOException{ + super(os); + this.helperContext = helperContext; + } + + public HelperContext getHelperContext() { + return helperContext; + } + + public void setHelperContext(HelperContext helperContext) { + this.helperContext = helperContext; + } + +} diff --git a/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/spi/HelperProviderBase.java b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/spi/HelperProviderBase.java new file mode 100644 index 0000000000..163feb4522 --- /dev/null +++ b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/spi/HelperProviderBase.java @@ -0,0 +1,245 @@ +/** + * + * 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.spi; + +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.api.SDOHelper; +import org.apache.tuscany.sdo.api.SDOUtil; +import org.apache.tuscany.sdo.api.XMLStreamHelper; +import org.apache.tuscany.sdo.lib.SDOObjectInputStream; + +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.HelperContext; +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 helpers + */ +public abstract class HelperProviderBase extends HelperProvider +{ + protected CopyHelper copyHelper; + + protected DataFactory dataFactory; + + protected DataHelper dataHelper; + + protected EqualityHelper equalityHelper; + + protected TypeHelper typeHelper; + + protected XMLHelper xmlHelper; + + protected XSDHelper xsdHelper; + + protected SDOHelper sdoHelper; // Tuscany extension APIs + + protected XMLStreamHelper xmlStreamHelper; + /** + * Subclasses must implement this method to initialize the above Helper instance variables + */ + protected abstract HelperContext createDefaultHelpers(); + + public HelperProviderBase() + { + defaultContext = createDefaultHelpers(); + } + + public SDOHelper sdoHelper() + { + return sdoHelper; + } + + 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 XMLStreamHelper xmlStreamHelper() + { + return xmlStreamHelper; + } + 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(SDOUtil.getXPath(dataObject)); + objectOutput.writeObject(dataGraph); + } + else if (dataObject.getContainer() != null) + { + objectOutput.writeByte(0); + objectOutput.writeUTF(SDOUtil.getXPath(dataObject)); + objectOutput.writeObject(dataObject.getRootObject()); + } + else + { + // Root object + objectOutput.writeByte(1); + + ByteArrayOutputStream compressedByteArrayOutputStream = new ByteArrayOutputStream(); + GZIPOutputStream gzipOutputStream = new GZIPOutputStream(compressedByteArrayOutputStream); + XMLHelper xmlHelperLocal = xmlHelper; + if(objectOutput instanceof SDOObjectInputStream) + { + xmlHelperLocal = ((SDOObjectInputStream)objectOutput).getHelperContext().getXMLHelper(); + } + xmlHelperLocal.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]; + + int index = 0; + int bytesRead; + while (index < length) { + if ((bytesRead = objectInput.read(compressedBytes, index, length-index)) == -1) { + break; + } + index += bytesRead; + } + + GZIPInputStream gzipInputStream = new GZIPInputStream(new ByteArrayInputStream(compressedBytes)); + XMLHelper xmlHelperLocal = xmlHelper; + if (objectInput instanceof SDOObjectInputStream) + { + xmlHelperLocal = ((SDOObjectInputStream)objectInput).getHelperContext().getXMLHelper(); + } + XMLDocument doc = xmlHelperLocal.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/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/spi/SDOHelperBase.java b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/spi/SDOHelperBase.java new file mode 100644 index 0000000000..43c379256c --- /dev/null +++ b/sandbox/kgoodson/events/lib/src/main/java/org/apache/tuscany/sdo/spi/SDOHelperBase.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.spi; + +/** + * Base class for an implementation of the SDOHelper and SDOHelper.MetaDataBuilder interfaces. + */ +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.OutputStream; +import java.math.BigDecimal; +import java.math.BigInteger; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.tuscany.sdo.api.SDOHelper; +import org.apache.tuscany.sdo.api.SDOUtil; +import org.apache.tuscany.sdo.lib.SDOObjectInputStream; +import org.apache.tuscany.sdo.lib.SDOObjectOutputStream; + +import commonj.sdo.DataObject; +import commonj.sdo.Property; +import commonj.sdo.helper.HelperContext; + +public abstract class SDOHelperBase implements SDOHelper, SDOHelper.MetaDataBuilder +{ + public HelperContext createHelperContext() + { + return createHelperContext(false); + } + + public ObjectInputStream createObjectInputStream(InputStream inputStream, HelperContext helperContext) throws IOException + { + return new SDOObjectInputStream(inputStream, helperContext); + } + + public ObjectOutputStream createObjectOutputStream(OutputStream outputStream, HelperContext helperContext) throws IOException + { + return new SDOObjectOutputStream(outputStream, helperContext); + } + + public String getXPath(DataObject dataObject) + { + StringBuffer path = getXPath(dataObject, new StringBuffer(), dataObject); + return path.toString(); + } + + protected StringBuffer getXPath(DataObject dataObject, StringBuffer path, DataObject root) + { + DataObject container = dataObject.getContainer(); + if (container == null) + return path; + + if (container == root) + throw new IllegalStateException("There is a cycle in the containment hierarchy of " + root); + + boolean first = path.length() == 0; + Property property = dataObject.getContainmentProperty(); + if (SDOUtil.isMany(property, dataObject)) + { + 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, root); + } + + public MetaDataBuilder getMetaDataBuilder() + { + return this; + } + + //Java instance class to SDO mappings (section 8.1 of the SDO spec) + protected 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 (section 9.4 of the SDO spec) + protected static Map xsdToSdoMappings = new HashMap(); + static { + xsdToSdoMappings.put("anySimpleType", "Object"); + xsdToSdoMappings.put("anyType", "DataObject"); + xsdToSdoMappings.put("anyURI", "URI"); + 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"); + } + +} diff --git a/sandbox/kgoodson/events/lib/src/main/resources/META-INF/DISCLAIMER b/sandbox/kgoodson/events/lib/src/main/resources/META-INF/DISCLAIMER new file mode 100644 index 0000000000..a65af91c5a --- /dev/null +++ b/sandbox/kgoodson/events/lib/src/main/resources/META-INF/DISCLAIMER @@ -0,0 +1,7 @@ +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. \ No newline at end of file diff --git a/sandbox/kgoodson/events/lib/src/main/resources/META-INF/LICENSE.txt b/sandbox/kgoodson/events/lib/src/main/resources/META-INF/LICENSE.txt new file mode 100644 index 0000000000..e55ca67ba9 --- /dev/null +++ b/sandbox/kgoodson/events/lib/src/main/resources/META-INF/LICENSE.txt @@ -0,0 +1,207 @@ + + 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. + + + + + diff --git a/sandbox/kgoodson/events/lib/src/main/resources/META-INF/MANIFEST.MF b/sandbox/kgoodson/events/lib/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..fc4233db53 --- /dev/null +++ b/sandbox/kgoodson/events/lib/src/main/resources/META-INF/MANIFEST.MF @@ -0,0 +1,16 @@ +Manifest-Version: 1.0 +Extension-Name: tuscany-sdo-lib +Specification-Title: Tuscany SDO Implementation Library +Specification-Vendor: Apache Software Foundation +Implementation-Vendor: Apache Software Foundation +Implementation-Vendor-Id: org.apache +Implementation-Title: tuscany-sdo-lib +Implementation-Version: incubating-M3 +Bundle-ManifestVersion: 2 +Bundle-Name: Tuscany SDO Implementation Library +Bundle-SymbolicName: org.apache.tuscany.sdo.lib +Bundle-Version: 1.0.0 +Bundle-Vendor: Apache Software Foundation +Require-Bundle: org.apache.tuscany.sdo.spec;visibility:=reexport +Export-Package: org.apache.tuscany.sdo.api, + org.apache.tuscany.sdo.rtlib diff --git a/sandbox/kgoodson/events/lib/src/main/resources/META-INF/NOTICE b/sandbox/kgoodson/events/lib/src/main/resources/META-INF/NOTICE new file mode 100644 index 0000000000..cb303cf8b5 --- /dev/null +++ b/sandbox/kgoodson/events/lib/src/main/resources/META-INF/NOTICE @@ -0,0 +1,14 @@ +Apache Tuscany +Copyright (c) 2005 - 2007 The Apache Software Foundation + +========================================================================= +== NOTICE file corresponding to the section 4 d of == +== the Apache License, Version 2.0, == +== in this case for the Apache Tuscany distribution. == +========================================================================= + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). + +Please see the LICENSE file present in the META-INF directory of this archive. + diff --git a/sandbox/kgoodson/events/lib/src/main/resources/META-INF/README.txt b/sandbox/kgoodson/events/lib/src/main/resources/META-INF/README.txt new file mode 100644 index 0000000000..43759129b7 --- /dev/null +++ b/sandbox/kgoodson/events/lib/src/main/resources/META-INF/README.txt @@ -0,0 +1,23 @@ +Apache Tuscany 1.0-incubating build (July 2007) +=============================================== + +http://incubator.apache.org/tuscany/ + +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/kgoodson/events/play/pom.xml b/sandbox/kgoodson/events/play/pom.xml new file mode 100644 index 0000000000..b98621178d --- /dev/null +++ b/sandbox/kgoodson/events/play/pom.xml @@ -0,0 +1,33 @@ + + 4.0.0 + com.example + play + jar + kgoodson_sandbox + play + http://maven.apache.org + + + junit + junit + 3.8.1 + test + + + org.apache.tuscany.sdo + tuscany-sdo-lib + kgoodson-sandbox + + + org.apache.tuscany.sdo + tuscany-sdo-impl + kgoodson-sandbox + + + org.apache.tuscany.sdo + tuscany-sdo-api-r2.1 + 1.0-incubating-SNAPSHOT + + + diff --git a/sandbox/kgoodson/events/play/src/main/java/com/example/ComExampleObserver.java b/sandbox/kgoodson/events/play/src/main/java/com/example/ComExampleObserver.java new file mode 100644 index 0000000000..909713dfc4 --- /dev/null +++ b/sandbox/kgoodson/events/play/src/main/java/com/example/ComExampleObserver.java @@ -0,0 +1,13 @@ +package com.example; + +import org.apache.tuscany.sdo.api.Event; +import org.apache.tuscany.sdo.api.ListenerBase; + +public class ComExampleObserver extends ListenerBase { + + public void eventNotification(Event e) { + System.out.println("Hi I changed"); + + } + +} diff --git a/sandbox/kgoodson/events/play/src/test/java/com/example/TestChanges.java b/sandbox/kgoodson/events/play/src/test/java/com/example/TestChanges.java new file mode 100644 index 0000000000..09aec7f046 --- /dev/null +++ b/sandbox/kgoodson/events/play/src/test/java/com/example/TestChanges.java @@ -0,0 +1,41 @@ +package com.example; + + +import java.io.InputStream; +import java.net.URL; + +import org.apache.tuscany.sdo.api.SDOUtil; +import junit.framework.TestCase; + + +import com.example.ComExampleObserver; + +import commonj.sdo.DataObject; +import commonj.sdo.helper.HelperContext; + +public class TestChanges extends TestCase { + + HelperContext scope; + private final String TEST_MODEL = "/simple.xsd"; + + + public void setUp() throws Exception { + scope = SDOUtil.createHelperContext(); + URL url = getClass().getResource(TEST_MODEL); + InputStream inputStream = url.openStream(); + scope.getXSDHelper().define(inputStream, url.toString()); + inputStream.close(); + + } + + public void tearDown() throws Exception { + } + + public void testChange1() + { + DataObject quote = scope.getDataFactory().create("http://www.example.com/simple", "Quote"); + SDOUtil.addChangeListener(quote, new ComExampleObserver()); + + quote.setString("symbol","foo"); + } +} diff --git a/sandbox/kgoodson/events/play/src/test/resources/simple.xsd b/sandbox/kgoodson/events/play/src/test/resources/simple.xsd new file mode 100644 index 0000000000..3beb0ca496 --- /dev/null +++ b/sandbox/kgoodson/events/play/src/test/resources/simple.xsd @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3