summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkelvingoodson <kelvingoodson@13f79535-47bb-0310-9956-ffa450edef68>2008-07-28 14:30:12 +0000
committerkelvingoodson <kelvingoodson@13f79535-47bb-0310-9956-ffa450edef68>2008-07-28 14:30:12 +0000
commitf1e99ea09209f97d2c2081e6f9a25900a38c8c90 (patch)
tree248882ce689ccb786cc79e31ac33f5cee4c5969f
parentae0049c24386c0a2e2c276a41f23bc17c5408e7c (diff)
merge of commit 643011 from 1.1 branch
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@680370 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/sdo/distribution/src/main/assembly/src.xml1
-rw-r--r--java/sdo/distribution/src/main/release/bin/README46
-rw-r--r--java/sdo/distribution/src/main/release/bin/samples/README22
-rw-r--r--java/sdo/impl/pom.xml13
-rw-r--r--java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/BaseSDOExtendedMetaDataImpl.java334
-rw-r--r--java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/BaseSDOXSDEcoreBuilder.java3542
-rw-r--r--java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/CrossScopeCopyHelperImpl.java510
-rw-r--r--java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DefaultHelperContextImpl.java144
-rw-r--r--java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOHelperImpl.java1060
-rw-r--r--java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/EventImpl.java156
-rw-r--r--java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ListenerBase.java66
-rw-r--r--java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/internal/InternalFactory.java104
-rw-r--r--java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/internal/impl/InternalFactoryImpl.java592
-rw-r--r--java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/xml/XMLFactory.java122
-rw-r--r--java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/xml/XMLInfo.java184
-rw-r--r--java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/xml/impl/XMLFactoryImpl.java682
-rw-r--r--java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/xml/impl/XMLInfoImpl.java512
-rw-r--r--java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/StreamDeserializer.java184
-rw-r--r--java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/VirtualSequence.java1560
-rw-r--r--java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/ChangeSummaryStreamDeserializer.java1326
-rw-r--r--java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/ChangeSummaryStreamSerializer.java1380
-rw-r--r--java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/RecordedEventXMLStreamReader.java1736
-rw-r--r--java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDODeserializer.java680
-rw-r--r--java/sdo/impl/src/main/resources/META-INF/NOTICE1
-rw-r--r--java/sdo/impl/src/main/resources/META-INF/README.txt4
-rw-r--r--java/sdo/impl/src/main/resources/xml/sdoInternal.xsd66
-rw-r--r--java/sdo/impl/src/main/resources/xml/sdoModelChangeSummary.xsd56
-rw-r--r--java/sdo/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionFactory.java140
-rw-r--r--java/sdo/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionType.java1572
-rw-r--r--java/sdo/impl/src/test/java/com/example/ExpectedException/SequenceReadOnlyType.java316
-rw-r--r--java/sdo/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionFactoryImpl.java1158
-rw-r--r--java/sdo/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionTypeImpl.java3364
-rw-r--r--java/sdo/impl/src/test/java/com/example/ExpectedException/impl/SequenceReadOnlyTypeImpl.java708
-rw-r--r--java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/BoundsTestCase.java156
-rw-r--r--java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryPropertyTestCase.java438
-rw-r--r--java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/CrossScopeCopyTestCase.java948
-rw-r--r--java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataObjectGetListTestCase.java258
-rw-r--r--java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineOpenContentPropertyTestCase.java266
-rw-r--r--java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DeserializationNoSchemaTestCase.java248
-rw-r--r--java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DupElementTestCase.java198
-rw-r--r--java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DynamicTypesComparisonTestCase.java512
-rw-r--r--java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ExpectedExceptionsTestCase.java3754
-rw-r--r--java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/JavaSerializeDeserializeTestCase.java594
-rw-r--r--java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MetadataInstancePropertiesTestCase.java486
-rw-r--r--java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/NeverStaleChangeSummaryTestCase.java150
-rw-r--r--java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/NotificationTestCase.java372
-rw-r--r--java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SequenceTestCase.java200
-rw-r--r--java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SerializeTypesTestCase.java380
-rw-r--r--java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeHelperTestCase.java90
-rw-r--r--java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLLoadOptionsTestCase.java384
-rw-r--r--java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLSaveOptionsTestCase.java294
-rw-r--r--java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLUnknownPropertiesTestCase.java264
-rw-r--r--java/sdo/impl/src/test/resources/TypePropertyMetadataInfo.xsd194
-rw-r--r--java/sdo/impl/src/test/resources/bounds.xsd90
-rw-r--r--java/sdo/impl/src/test/resources/dupelement.xsd78
-rw-r--r--java/sdo/impl/src/test/resources/expectedExceptions.xsd134
-rw-r--r--java/sdo/impl/src/test/resources/openContentProperty.xml22
-rw-r--r--java/sdo/impl/src/test/resources/sdoModel.xsd56
-rw-r--r--java/sdo/impl/src/test/resources/shallowquote1.xml58
-rw-r--r--java/sdo/impl/src/test/resources/simple2.xsd82
-rw-r--r--java/sdo/impl/src/test/resources/simpleWithChangeSummary.xml54
-rw-r--r--java/sdo/impl/src/test/resources/simpleWithChangeSummaryUndone.xml36
-rw-r--r--java/sdo/impl/src/test/resources/substitutionValues1.xml46
-rw-r--r--java/sdo/impl/src/test/resources/substitutionValues2.xml46
-rw-r--r--java/sdo/java5tools/src/main/resources/META-INF/README.txt4
-rw-r--r--java/sdo/lib/src/main/java/org/apache/tuscany/sdo/api/SDOHelper.java904
-rw-r--r--java/sdo/lib/src/main/java/org/apache/tuscany/sdo/api/SDOUtil.java890
-rw-r--r--java/sdo/lib/src/main/java/org/apache/tuscany/sdo/api/XMLStreamHelper.java250
-rw-r--r--java/sdo/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectInputStream.java98
-rw-r--r--java/sdo/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectOutputStream.java98
-rw-r--r--java/sdo/lib/src/main/java/org/apache/tuscany/sdo/lib/UnknownPropertyList.java140
-rw-r--r--java/sdo/lib/src/main/java/org/apache/tuscany/sdo/spi/HelperProviderBase.java492
-rw-r--r--java/sdo/lib/src/main/java/org/apache/tuscany/sdo/spi/SDOHelperBase.java352
-rw-r--r--java/sdo/lib/src/main/resources/META-INF/LICENSE.txt414
-rw-r--r--java/sdo/lib/src/main/resources/META-INF/MANIFEST.MF4
-rw-r--r--java/sdo/plugin/pom.xml37
-rw-r--r--java/sdo/plugin/src/main/resources/META-INF/NOTICE1
-rw-r--r--java/sdo/plugin/src/main/resources/META-INF/README.txt4
-rw-r--r--java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/MedicalScenario.java848
-rw-r--r--java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/MedicalScenarioWithChangeMonitoring.java898
-rw-r--r--java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/PrintDataGraph.java996
-rw-r--r--java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/internal/DocumentSamples.java436
-rw-r--r--java/sdo/sample/src/main/resources/META-INF/LICENSE.txt414
-rw-r--r--java/sdo/sample/src/main/resources/MedicalTest.xsd114
-rw-r--r--java/sdo/sample/src/main/resources/MedicalTest_CS.xsd116
-rw-r--r--java/sdo/sample/src/main/resources/People.xsd140
-rw-r--r--java/sdo/sdo-api/pom.xml18
-rw-r--r--java/sdo/sdo-api/src/main/java/commonj/sdo/helper/HelperContext.java134
-rw-r--r--java/sdo/tools/pom.xml13
-rw-r--r--java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/adapter/SDOGenModelGeneratorAdapter.java76
-rw-r--r--java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/util/SDOGenUtil.java652
-rw-r--r--java/sdo/tools/src/main/resources/META-INF/NOTICE1
-rw-r--r--java/sdo/tools/src/main/resources/META-INF/README.txt4
-rw-r--r--java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/GeneratedPackagesTestCase.java140
-rw-r--r--java/sdo/tools/src/test/resources/sdoModel.xsd56
95 files changed, 21021 insertions, 20952 deletions
diff --git a/java/sdo/distribution/src/main/assembly/src.xml b/java/sdo/distribution/src/main/assembly/src.xml
index 4043e744e2..37a0d02caf 100644
--- a/java/sdo/distribution/src/main/assembly/src.xml
+++ b/java/sdo/distribution/src/main/assembly/src.xml
@@ -50,6 +50,7 @@
<exclude>**/var/journal</exclude>
<exclude>**/build.out*</exclude>
<exclude>impl/.felix</exclude>
+ <exclude>impl/.felix/**/*</exclude>
</excludes>
</fileSet>
</fileSets>
diff --git a/java/sdo/distribution/src/main/release/bin/README b/java/sdo/distribution/src/main/release/bin/README
index fc82c39310..adf9ee9c2d 100644
--- a/java/sdo/distribution/src/main/release/bin/README
+++ b/java/sdo/distribution/src/main/release/bin/README
@@ -1,23 +1,23 @@
-Tuscany SDO for ${sdo.version} Binary Distribution Readme File
-
-See the LICENSE, DISCLAIMER and NOTICE files for legal information concerning this distribution.
-
-See the RELEASE_NOTES file for a summary of what's new with this release.
-
-See the INSTALL file for instructions on how to use Tuscany SDO Java provided in this binary distribution.
-
-See the docs/javadoc/sdo-samples/index.html file for instructions on how to run the sample programs.
-
-Documentation
-
-For general documentation about the Tuscany project and the SDO for Java, see the Tuscany website
-http://incubator.apache.org/tuscany
-
-This distribution contains javadoc for the SDO 2.1 API, the Tuscany SDO extensions API, and the Tuscany SDO samples.
-
-Samples
-
-Sample source code is included with this binary distribution.
-
-
-
+Tuscany SDO for ${sdo.version} Binary Distribution Readme File
+
+See the LICENSE, DISCLAIMER and NOTICE files for legal information concerning this distribution.
+
+See the RELEASE_NOTES file for a summary of what's new with this release.
+
+See the INSTALL file for instructions on how to use Tuscany SDO Java provided in this binary distribution.
+
+See the docs/javadoc/sdo-samples/index.html file for instructions on how to run the sample programs.
+
+Documentation
+
+For general documentation about the Tuscany project and the SDO for Java, see the Tuscany website
+http://incubator.apache.org/tuscany
+
+This distribution contains javadoc for the SDO 2.1 API, the Tuscany SDO extensions API, and the Tuscany SDO samples.
+
+Samples
+
+Sample source code is included with this binary distribution.
+
+
+
diff --git a/java/sdo/distribution/src/main/release/bin/samples/README b/java/sdo/distribution/src/main/release/bin/samples/README
index d669e0b2b2..a19704ccd2 100644
--- a/java/sdo/distribution/src/main/release/bin/samples/README
+++ b/java/sdo/distribution/src/main/release/bin/samples/README
@@ -1,11 +1,11 @@
-Apache Tuscany SDO Java Sample Programs
-
-Documentation for these samples may be found in the docs/javadoc/sdo-samples directory
-of this distribution.
-
-The runsamples.sh and runsamples.bat scripts in their unedited form
-provide a way to run all of the samples sequentially. If you run these scripts
-from within the directory they are found in, they will run correctly.
-If you run them from elsewhere you will need to edit the scripts and set the
-BINARY_BASE variable to the path in your filesystem where you unpacked the
-SDO distribution.
+Apache Tuscany SDO Java Sample Programs
+
+Documentation for these samples may be found in the docs/javadoc/sdo-samples directory
+of this distribution.
+
+The runsamples.sh and runsamples.bat scripts in their unedited form
+provide a way to run all of the samples sequentially. If you run these scripts
+from within the directory they are found in, they will run correctly.
+If you run them from elsewhere you will need to edit the scripts and set the
+BINARY_BASE variable to the path in your filesystem where you unpacked the
+SDO distribution.
diff --git a/java/sdo/impl/pom.xml b/java/sdo/impl/pom.xml
index 2d2896613a..ba0549cce6 100644
--- a/java/sdo/impl/pom.xml
+++ b/java/sdo/impl/pom.xml
@@ -122,6 +122,19 @@
<build>
<plugins>
<plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestEntries>
+ <Implementation-Vendor-Id>org.apache</Implementation-Vendor-Id>
+ <Implementation-Version>1.1-incubating</Implementation-Version>
+ <X-Compile-Source-JDK>1.4</X-Compile-Source-JDK>
+ <X-Compile-Target-JDK>1.4</X-Compile-Target-JDK>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.1</version>
diff --git a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/BaseSDOExtendedMetaDataImpl.java b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/BaseSDOExtendedMetaDataImpl.java
index 422f5342d8..88c714f8bf 100644
--- a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/BaseSDOExtendedMetaDataImpl.java
+++ b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/BaseSDOExtendedMetaDataImpl.java
@@ -1,167 +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.helper;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-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.util.BasicExtendedMetaData;
-import org.eclipse.emf.ecore.util.ExtendedMetaData;
-import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
-
-/**
- * A BasicExtendedMetaData that uses a supplied (SDO) ecore factory to create properties and types.
- */
-public class BaseSDOExtendedMetaDataImpl extends BasicExtendedMetaData
-{
- protected EcoreFactory ecoreFactory = EcoreFactory.eINSTANCE;
- protected DemandMetaData demandMetaData = new DemandMetaData();
-
- public static class DemandMetaData {
- EClassifier getEObject() { return EcorePackage.eINSTANCE.getEObject(); }
- EClassifier getAnyType() { return XMLTypePackage.eINSTANCE.getAnyType(); }
- EClassifier getAnySimpleType() { return XMLTypePackage.eINSTANCE.getAnySimpleType(); }
- EClassifier getXMLTypeDocumentRoot() { return XMLTypePackage.eINSTANCE.getXMLTypeDocumentRoot(); }
- }
-
- public BaseSDOExtendedMetaDataImpl(EPackage.Registry registry)
- {
- super(registry);
- }
-
- public EPackage demandPackage(String namespace)
- {
- EPackage ePackage = demandRegistry.getEPackage(namespace);
- if (ePackage == null)
- {
- ePackage = ecoreFactory.createEPackage();
- ePackage.setNsURI(namespace);
- setQualified(ePackage, namespace != null);
- if (namespace != null)
- {
- ePackage.setNsPrefix
- (namespace.equals(ExtendedMetaData.XMLNS_URI) ?
- namespace.equals(ExtendedMetaData.XML_URI) ?
- "xml" :
- "xmlns" :
- computePrefix(namespace));
- }
- demandRegistry.put(namespace, ePackage);
-
- // demandDocumentRoot(ePackage);
-
- EClass documentRootEClass = ecoreFactory.createEClass();
- documentRootEClass.getESuperTypes().add(demandMetaData.getXMLTypeDocumentRoot());
- documentRootEClass.setName("DocumentRoot");
- ePackage.getEClassifiers().add(documentRootEClass);
- setDocumentRoot(documentRootEClass);
- }
- return ePackage;
- }
-
- public EClassifier demandType(String namespace, String name)
- {
- EPackage ePackage = demandPackage(namespace);
- EClassifier eClassifier = getType(ePackage, name);
- if (eClassifier != null)
- {
- return eClassifier;
- }
- else
- {
- EClass eClass = ecoreFactory.createEClass();
- eClass.setName(name);
- eClass.getESuperTypes().add(demandMetaData.getAnyType());
- setContentKind(eClass, MIXED_CONTENT);
- ePackage.getEClassifiers().add(eClass);
- return eClass;
- }
- }
-
- public EStructuralFeature demandFeature(String namespace, String name, boolean isElement, boolean isReference)
- {
- EPackage ePackage = demandPackage(namespace);
- EClass documentRootEClass = getDocumentRoot(ePackage);
- EStructuralFeature eStructuralFeature =
- isElement ?
- getLocalElement(documentRootEClass, namespace, name) :
- getLocalAttribute(documentRootEClass, namespace, name);
- if (eStructuralFeature != null)
- {
- return eStructuralFeature;
- }
- else
- {
- if (isReference)
- {
- EReference eReference = ecoreFactory.createEReference();
- eReference.setContainment(isElement);
- eReference.setEType(demandMetaData.getEObject());
- eReference.setName(name);
- eReference.setDerived(true);
- eReference.setTransient(true);
- eReference.setVolatile(true);
- documentRootEClass.getEStructuralFeatures().add(eReference);
-
- setFeatureKind(eReference, isElement ? ELEMENT_FEATURE : ATTRIBUTE_FEATURE);
- setNamespace(eReference, namespace);
-
- // 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.
- //
- if (isElement)
- {
- eReference.setUpperBound(ETypedElement.UNSPECIFIED_MULTIPLICITY);
- }
-
- return eReference;
- }
- else
- {
- EAttribute eAttribute = ecoreFactory.createEAttribute();
- eAttribute.setName(name);
- eAttribute.setEType(demandMetaData.getAnySimpleType());
- eAttribute.setDerived(true);
- eAttribute.setTransient(true);
- eAttribute.setVolatile(true);
- documentRootEClass.getEStructuralFeatures().add(eAttribute);
-
- setFeatureKind(eAttribute, isElement ? ELEMENT_FEATURE : ATTRIBUTE_FEATURE);
- setNamespace(eAttribute, namespace);
-
- // 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.
- //
- if (isElement)
- {
- eAttribute.setUpperBound(ETypedElement.UNSPECIFIED_MULTIPLICITY);
- }
-
- return eAttribute;
- }
- }
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+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.util.BasicExtendedMetaData;
+import org.eclipse.emf.ecore.util.ExtendedMetaData;
+import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
+
+/**
+ * A BasicExtendedMetaData that uses a supplied (SDO) ecore factory to create properties and types.
+ */
+public class BaseSDOExtendedMetaDataImpl extends BasicExtendedMetaData
+{
+ protected EcoreFactory ecoreFactory = EcoreFactory.eINSTANCE;
+ protected DemandMetaData demandMetaData = new DemandMetaData();
+
+ public static class DemandMetaData {
+ EClassifier getEObject() { return EcorePackage.eINSTANCE.getEObject(); }
+ EClassifier getAnyType() { return XMLTypePackage.eINSTANCE.getAnyType(); }
+ EClassifier getAnySimpleType() { return XMLTypePackage.eINSTANCE.getAnySimpleType(); }
+ EClassifier getXMLTypeDocumentRoot() { return XMLTypePackage.eINSTANCE.getXMLTypeDocumentRoot(); }
+ }
+
+ public BaseSDOExtendedMetaDataImpl(EPackage.Registry registry)
+ {
+ super(registry);
+ }
+
+ public EPackage demandPackage(String namespace)
+ {
+ EPackage ePackage = demandRegistry.getEPackage(namespace);
+ if (ePackage == null)
+ {
+ ePackage = ecoreFactory.createEPackage();
+ ePackage.setNsURI(namespace);
+ setQualified(ePackage, namespace != null);
+ if (namespace != null)
+ {
+ ePackage.setNsPrefix
+ (namespace.equals(ExtendedMetaData.XMLNS_URI) ?
+ namespace.equals(ExtendedMetaData.XML_URI) ?
+ "xml" :
+ "xmlns" :
+ computePrefix(namespace));
+ }
+ demandRegistry.put(namespace, ePackage);
+
+ // demandDocumentRoot(ePackage);
+
+ EClass documentRootEClass = ecoreFactory.createEClass();
+ documentRootEClass.getESuperTypes().add(demandMetaData.getXMLTypeDocumentRoot());
+ documentRootEClass.setName("DocumentRoot");
+ ePackage.getEClassifiers().add(documentRootEClass);
+ setDocumentRoot(documentRootEClass);
+ }
+ return ePackage;
+ }
+
+ public EClassifier demandType(String namespace, String name)
+ {
+ EPackage ePackage = demandPackage(namespace);
+ EClassifier eClassifier = getType(ePackage, name);
+ if (eClassifier != null)
+ {
+ return eClassifier;
+ }
+ else
+ {
+ EClass eClass = ecoreFactory.createEClass();
+ eClass.setName(name);
+ eClass.getESuperTypes().add(demandMetaData.getAnyType());
+ setContentKind(eClass, MIXED_CONTENT);
+ ePackage.getEClassifiers().add(eClass);
+ return eClass;
+ }
+ }
+
+ public EStructuralFeature demandFeature(String namespace, String name, boolean isElement, boolean isReference)
+ {
+ EPackage ePackage = demandPackage(namespace);
+ EClass documentRootEClass = getDocumentRoot(ePackage);
+ EStructuralFeature eStructuralFeature =
+ isElement ?
+ getLocalElement(documentRootEClass, namespace, name) :
+ getLocalAttribute(documentRootEClass, namespace, name);
+ if (eStructuralFeature != null)
+ {
+ return eStructuralFeature;
+ }
+ else
+ {
+ if (isReference)
+ {
+ EReference eReference = ecoreFactory.createEReference();
+ eReference.setContainment(isElement);
+ eReference.setEType(demandMetaData.getEObject());
+ eReference.setName(name);
+ eReference.setDerived(true);
+ eReference.setTransient(true);
+ eReference.setVolatile(true);
+ documentRootEClass.getEStructuralFeatures().add(eReference);
+
+ setFeatureKind(eReference, isElement ? ELEMENT_FEATURE : ATTRIBUTE_FEATURE);
+ setNamespace(eReference, namespace);
+
+ // 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.
+ //
+ if (isElement)
+ {
+ eReference.setUpperBound(ETypedElement.UNSPECIFIED_MULTIPLICITY);
+ }
+
+ return eReference;
+ }
+ else
+ {
+ EAttribute eAttribute = ecoreFactory.createEAttribute();
+ eAttribute.setName(name);
+ eAttribute.setEType(demandMetaData.getAnySimpleType());
+ eAttribute.setDerived(true);
+ eAttribute.setTransient(true);
+ eAttribute.setVolatile(true);
+ documentRootEClass.getEStructuralFeatures().add(eAttribute);
+
+ setFeatureKind(eAttribute, isElement ? ELEMENT_FEATURE : ATTRIBUTE_FEATURE);
+ setNamespace(eAttribute, namespace);
+
+ // 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.
+ //
+ if (isElement)
+ {
+ eAttribute.setUpperBound(ETypedElement.UNSPECIFIED_MULTIPLICITY);
+ }
+
+ return eAttribute;
+ }
+ }
+ }
+}
diff --git a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/BaseSDOXSDEcoreBuilder.java b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/BaseSDOXSDEcoreBuilder.java
index f21a3398b7..3d297fa671 100644
--- a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/BaseSDOXSDEcoreBuilder.java
+++ b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/BaseSDOXSDEcoreBuilder.java
@@ -1,1771 +1,1771 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * 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.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-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.EEnum;
-import org.eclipse.emf.ecore.EOperation;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EParameter;
-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.util.EcoreUtil;
-import org.eclipse.emf.ecore.util.ExtendedMetaData;
-import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
-import org.eclipse.xsd.XSDAnnotation;
-import org.eclipse.xsd.XSDAttributeDeclaration;
-import org.eclipse.xsd.XSDAttributeUse;
-import org.eclipse.xsd.XSDComplexTypeContent;
-import org.eclipse.xsd.XSDComplexTypeDefinition;
-import org.eclipse.xsd.XSDComponent;
-import org.eclipse.xsd.XSDContentTypeCategory;
-import org.eclipse.xsd.XSDDerivationMethod;
-import org.eclipse.xsd.XSDElementDeclaration;
-import org.eclipse.xsd.XSDFeature;
-import org.eclipse.xsd.XSDLengthFacet;
-import org.eclipse.xsd.XSDMaxLengthFacet;
-import org.eclipse.xsd.XSDMinLengthFacet;
-import org.eclipse.xsd.XSDModelGroup;
-import org.eclipse.xsd.XSDModelGroupDefinition;
-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.XSDVariety;
-import org.eclipse.xsd.XSDWildcard;
-import org.eclipse.xsd.ecore.XSDEcoreBuilder;
-import org.eclipse.xsd.util.XSDConstants;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * An XSDEcoreBuilder that uses a supplied (SDO) ecore factory to create properties and types.
- */
-public class BaseSDOXSDEcoreBuilder extends XSDEcoreBuilder
-{
- protected EcorePackage ecorePackage = EcorePackage.eINSTANCE;
- protected EcoreFactory ecoreFactory = EcoreFactory.eINSTANCE;
-
- public BaseSDOXSDEcoreBuilder(ExtendedMetaData extendedMetaData)
- {
- super(extendedMetaData);
- }
-
- private void createDocumentRoot(XSDSchema xsdSchema, EPackage ePackage) {
- EClass documentEClass = ecoreFactory.createEClass();
- String name = getEcoreAttribute(xsdSchema, "documentRoot");
- if (name == null)
- {
- name = "DocumentRoot";
- }
- documentEClass.setName(name);
-
- extendedMetaData.setDocumentRoot(documentEClass);
-
- ePackage.getEClassifiers().add(documentEClass);
-
- createFeature
- (documentEClass,
- "mixed",
- ecorePackage.getEFeatureMapEntry(),
- null,
- 0,
- -1);
-
- EStructuralFeature xmlnsPrefixMapFeature =
- createFeature
- (documentEClass,
- "xMLNSPrefixMap",
- ecorePackage.getEStringToStringMapEntry(),
- null,
- 0,
- -1);
- extendedMetaData.setName(xmlnsPrefixMapFeature, "xmlns:prefix");
-
- EStructuralFeature xsiSchemaLocationMapFeature =
- createFeature
- (documentEClass,
- "xSISchemaLocation",
- ecorePackage.getEStringToStringMapEntry(),
- null,
- 0,
- -1);
- extendedMetaData.setName(xsiSchemaLocationMapFeature, "xsi:schemaLocation");
- }
-
- public EPackage getEPackage(XSDNamedComponent xsdNamedComponent)
- {
- XSDSchema containingXSDSchema = xsdNamedComponent.getSchema();
- if (containingXSDSchema != null && !xsdSchemas.contains(containingXSDSchema))
- {
- xsdSchemas.add(containingXSDSchema);
- addInput(containingXSDSchema);
- validate(containingXSDSchema);
- }
-
- String targetNamespace =
- containingXSDSchema == null ?
- xsdNamedComponent.getTargetNamespace() :
- containingXSDSchema.getTargetNamespace();
- EPackage ePackage = (EPackage)targetNamespaceToEPackageMap.get(targetNamespace);
- if (ePackage == null)
- {
- ePackage = ecoreFactory.createEPackage();
- setAnnotations(ePackage, containingXSDSchema);
- addOutput(ePackage);
- if (targetNamespace == null)
- {
- if (containingXSDSchema == null)
- {
- containingXSDSchema = rootSchema;
- }
- ePackage.setName(validName(containingXSDSchema.eResource().getURI().trimFileExtension().lastSegment(), true));
- ePackage.setNsURI(containingXSDSchema.eResource().getURI().toString());
-
- // Also register against the nsURI for the case that the target namespace is null.
- //
- // extendedMetaData.putPackage(ePackage.getNsURI(), ePackage);
- }
- else
- {
- String qualifiedPackageName = qualifiedPackageName(targetNamespace);
- ePackage.setName(qualifiedPackageName);
- ePackage.setNsURI(targetNamespace);
- }
-
- String nsPrefix = ePackage.getName();
- int index = nsPrefix.lastIndexOf('.');
- nsPrefix = index == -1 ? nsPrefix : nsPrefix.substring(index + 1);
-
- // http://www.w3.org/TR/REC-xml-names/#xmlReserved
- // Namespace Constraint: Leading "XML"
- // Prefixes beginning with the three-letter sequence x, m, l, in any case combination,
- // are reserved for use by XML and XML-related specifications.
- //
- if (nsPrefix.toLowerCase().startsWith("xml"))
- {
- nsPrefix = "_" + nsPrefix;
- }
- ePackage.setNsPrefix(nsPrefix);
-
- extendedMetaData.setQualified(ePackage, targetNamespace != null);
- extendedMetaData.putPackage(targetNamespace, ePackage);
-
- targetNamespaceToEPackageMap.put(targetNamespace, ePackage);
-
- createDocumentRoot(xsdNamedComponent.getSchema(), ePackage);
- }
-
- return ePackage;
- }
-
- protected EClassifier computeEClassifier(XSDTypeDefinition xsdTypeDefinition)
- {
- if (xsdTypeDefinition == null)
- {
- return getBuiltInEClassifier(rootSchema.getSchemaForSchemaNamespace(), "anySimpleType");
- }
- else if (xsdTypeDefinition instanceof XSDSimpleTypeDefinition)
- {
- return computeEDataType((XSDSimpleTypeDefinition)xsdTypeDefinition);
- }
- else
- {
- return computeEClass((XSDComplexTypeDefinition)xsdTypeDefinition);
- }
- }
-
- protected EDataType computeEDataType(XSDSimpleTypeDefinition xsdSimpleTypeDefinition)
- {
- if (xsdSimpleTypeDefinition == null)
- {
- return (EDataType)getBuiltInEClassifier(rootSchema.getSchemaForSchemaNamespace(), "anySimpleType");
- }
- else if (XSDConstants.isSchemaForSchemaNamespace(xsdSimpleTypeDefinition.getTargetNamespace()))
- {
- String name = xsdSimpleTypeDefinition.getName();
- if (name != null)
- {
- EDataType result = (EDataType)getBuiltInEClassifier(xsdSimpleTypeDefinition.getTargetNamespace(), "anyType".equals(name) ? "anySimpleType" : name);
- if (result != null)
- {
- return result;
- }
- }
- }
- else if (xsdSimpleTypeDefinition.getContainer() == null)
- {
- return (EDataType)getBuiltInEClassifier(rootSchema.getSchemaForSchemaNamespace(), "anySimpleType");
- }
-
- String explicitInstanceClassName = getEcoreAttribute(xsdSimpleTypeDefinition, "instanceClass");
- if (explicitInstanceClassName != null)
- {
- EDataType eDataType = ecoreFactory.createEDataType();
- setAnnotations(eDataType, xsdSimpleTypeDefinition);
-
- String aliasName = getEcoreAttribute(xsdSimpleTypeDefinition, "name");
- if (aliasName == null)
- {
- aliasName = validAliasName(xsdSimpleTypeDefinition, true);
- }
- eDataType.setName(aliasName);
- extendedMetaData.setName(eDataType, xsdSimpleTypeDefinition.getAliasName());
-
- eDataType.setInstanceClassName(explicitInstanceClassName);
-
- EPackage ePackage = getEPackage(xsdSimpleTypeDefinition);
- addToSortedList(ePackage.getEClassifiers(), eDataType);
-
- checkForPrimitive(xsdSimpleTypeDefinition, eDataType);
-
- handleFacets(xsdSimpleTypeDefinition, eDataType);
-
- String constraints = getEcoreAttribute(xsdSimpleTypeDefinition, "constraints");
- if (constraints != null)
- {
- EcoreUtil.setAnnotation(eDataType, EcorePackage.eNS_URI, "constraints", constraints);
- }
-
- if ("false".equals(getEcoreAttribute(xsdSimpleTypeDefinition, "serializable")))
- {
- eDataType.setSerializable(false);
- }
- return eDataType;
- }
- else
- {
- EEnum eEnum = computeEEnum(xsdSimpleTypeDefinition);
- if (eEnum != null)
- {
- return eEnum;
- }
- else
- {
- XSDSimpleTypeDefinition baseTypeDefinition = xsdSimpleTypeDefinition.getBaseTypeDefinition();
- if (baseTypeDefinition != null)
- {
- EDataType eDataType = ecoreFactory.createEDataType();
- setAnnotations(eDataType, xsdSimpleTypeDefinition);
-
- String name = getEcoreAttribute(xsdSimpleTypeDefinition, "name");
- if (name == null)
- {
- name = validAliasName(xsdSimpleTypeDefinition, true);
- }
-
- eDataType.setName(name);
- extendedMetaData.setName(eDataType, xsdSimpleTypeDefinition.getAliasName());
-
- EPackage ePackage = getEPackage(xsdSimpleTypeDefinition);
- addToSortedList(ePackage.getEClassifiers(), eDataType);
-
- if (baseTypeDefinition.getVariety() != xsdSimpleTypeDefinition.getVariety())
- {
- if (xsdSimpleTypeDefinition.getVariety() == XSDVariety.LIST_LITERAL)
- {
- EDataType itemEDataType = getEDataType(xsdSimpleTypeDefinition.getItemTypeDefinition());
- extendedMetaData.setItemType(eDataType, itemEDataType);
- eDataType.setInstanceClassName("java.util.List");
- }
- else
- {
- String instanceClassName = null;
- List memberTypes = new ArrayList();
- for (Iterator i = xsdSimpleTypeDefinition.getMemberTypeDefinitions().iterator(); i.hasNext(); )
- {
- XSDSimpleTypeDefinition memberTypeDefinition = (XSDSimpleTypeDefinition)i.next();
- EDataType memberEDataType = getEDataType(memberTypeDefinition);
- memberTypes.add(memberEDataType);
- String memberInstanceClassName = memberEDataType.getInstanceClassName();
- if (memberInstanceClassName == null && memberEDataType instanceof EEnum)
- {
- memberInstanceClassName = "org.eclipse.emf.common.util.Enumerator";
- }
- if (instanceClassName == null)
- {
- instanceClassName = memberInstanceClassName;
- }
- else if (instanceClassName != memberInstanceClassName)
- {
- instanceClassName = "java.lang.Object";
- }
- }
- extendedMetaData.setMemberTypes(eDataType, memberTypes);
- eDataType.setInstanceClassName(instanceClassName);
- }
- }
- else
- {
- EDataType baseEDataType = getEDataType(baseTypeDefinition);
- extendedMetaData.setBaseType(eDataType, baseEDataType);
- String instanceClassName = getInstanceClassName(xsdSimpleTypeDefinition, baseEDataType);
- eDataType.setInstanceClassName
- (instanceClassName == null ?
- "org.eclipse.emf.common.util.Enumerator" :
- instanceClassName);
- }
-
- checkForPrimitive(xsdSimpleTypeDefinition, eDataType);
- handleFacets(xsdSimpleTypeDefinition, eDataType);
-
- String constraints = getEcoreAttribute(xsdSimpleTypeDefinition, "constraints");
- if (constraints != null)
- {
- EcoreUtil.setAnnotation(eDataType, EcorePackage.eNS_URI, "constraints", constraints);
- }
-
- if ("false".equals(getEcoreAttribute(xsdSimpleTypeDefinition, "serializable")))
- {
- eDataType.setSerializable(false);
- }
-
- return eDataType;
- }
- }
- return (EDataType)getBuiltInEClassifier(rootSchema.getSchemaForSchemaNamespace(), "anySimpleType");
- }
- }
-
- protected void checkForPrimitive(EDataType eDataType)
- {
- int index = PRIMITIVES.indexOf(eDataType.getInstanceClassName());
- if (index != -1 || eDataType instanceof EEnum)
- {
- EDataType eDataTypeObject = ecoreFactory.createEDataType();
- eDataTypeObject.setName(eDataType.getName() + "Object");
- if (index != -1)
- {
- eDataTypeObject.setInstanceClassName(PRIMITIVE_WRAPPERS[index]);
- }
- else
- {
- eDataTypeObject.setInstanceClassName("org.eclipse.emf.common.util.Enumerator");
- }
- extendedMetaData.setName(eDataTypeObject, extendedMetaData.getName(eDataType) + ":Object");
- addToSortedList(eDataType.getEPackage().getEClassifiers(), eDataTypeObject);
- extendedMetaData.setBaseType(eDataTypeObject, eDataType);
-
- typeToTypeObjectMap.put(eDataType, eDataTypeObject);
- }
- }
-
- public EClass computeEClass(XSDComplexTypeDefinition xsdComplexTypeDefinition)
- {
- if (xsdComplexTypeDefinition == null)
- {
- return (EClass)getBuiltInEClassifier(rootSchema.getSchemaForSchemaNamespace(), "anyType");
- }
- else if (XSDConstants.isSchemaForSchemaNamespace(xsdComplexTypeDefinition.getTargetNamespace()))
- {
- String name = xsdComplexTypeDefinition.getName();
- if (name != null)
- {
- EClass result = (EClass)getBuiltInEClassifier(xsdComplexTypeDefinition.getTargetNamespace(), name);
- if (result != null)
- {
- return result;
- }
- }
- }
- else if (xsdComplexTypeDefinition.getContainer() == null)
- {
- return (EClass)getBuiltInEClassifier(rootSchema.getSchemaForSchemaNamespace(), "anyType");
- }
-
- EClass eClass = ecoreFactory.createEClass();
- setAnnotations(eClass, xsdComplexTypeDefinition);
- // Do this early to prevent recursive loop.
- xsdComponentToEModelElementMap.put(xsdComplexTypeDefinition, eClass);
-
- if ("true".equals(getEcoreAttribute(xsdComplexTypeDefinition, "interface")))
- {
- eClass.setInterface(true);
- }
-
- String instanceClassName = getEcoreAttribute(xsdComplexTypeDefinition, "instanceClass");
- if (instanceClassName != null)
- {
- eClass.setInstanceClassName(instanceClassName);
- }
-
- String aliasName = getEcoreAttribute(xsdComplexTypeDefinition, "name");
- if (aliasName == null)
- {
- aliasName = validAliasName(xsdComplexTypeDefinition, true);
- }
- eClass.setName(aliasName);
- extendedMetaData.setName(eClass, xsdComplexTypeDefinition.getAliasName());
-
- String constraints = getEcoreAttribute(xsdComplexTypeDefinition, "constraints");
- if (constraints != null)
- {
- EcoreUtil.setAnnotation(eClass, EcorePackage.eNS_URI, "constraints", constraints);
- }
-
- EPackage ePackage = getEPackage(xsdComplexTypeDefinition);
- addToSortedList(ePackage.getEClassifiers(), eClass);
-
- if (xsdComplexTypeDefinition.isAbstract())
- {
- eClass.setAbstract(true);
- }
-
- EClass baseClass = null;
- XSDTypeDefinition baseTypeDefinition = xsdComplexTypeDefinition.getBaseTypeDefinition();
- if (!baseTypeDefinition.isCircular())
- {
- EClassifier baseType = getEClassifier(baseTypeDefinition);
- if (baseType instanceof EClass && baseType != ecorePackage.getEObject())
- {
- eClass.getESuperTypes().add(baseClass = (EClass)baseType);
- }
- }
-
- boolean isRestriction =
- !eClass.getESuperTypes().isEmpty() &&
- xsdComplexTypeDefinition.getDerivationMethod() == XSDDerivationMethod.RESTRICTION_LITERAL;
-
- for (Iterator i = getEcoreTypeQNamesAttribute(xsdComplexTypeDefinition, "implements").iterator(); i.hasNext(); )
- {
- XSDTypeDefinition mixin = (XSDTypeDefinition)i.next();
- if (!XSDConstants.isURType(mixin))
- {
- EClassifier mixinType = getEClassifier(mixin);
- if (mixinType instanceof EClass && mixinType != ecorePackage.getEObject())
- {
- eClass.getESuperTypes().add(mixinType);
- }
- }
- }
-
- // 51210
- // EAnnotation contentParticle = null;
-
- if (xsdComplexTypeDefinition.getContentTypeCategory() == XSDContentTypeCategory.SIMPLE_LITERAL)
- {
- extendedMetaData.setContentKind(eClass, ExtendedMetaData.SIMPLE_CONTENT);
- if (!"SimpleAnyType".equals(eClass.getName()) || !XMLTypePackage.eNS_URI.equals(eClass.getEPackage().getNsURI()))
- {
- if (eClass.getEAllStructuralFeatures().isEmpty())
- {
- XSDComplexTypeContent xsdComplexTypeContent = xsdComplexTypeDefinition.getContent();
- String name = getEcoreAttribute(xsdComplexTypeContent, "name");
- if (name == null)
- {
- name = "value";
- }
- createFeature
- (eClass,
- null,
- name,
- xsdComplexTypeContent,
- false);
- }
- else
- {
- XSDSimpleTypeDefinition xsdSimpleTypeDefinition = xsdComplexTypeDefinition.getSimpleType();
- getEClassifier(xsdSimpleTypeDefinition);
- }
- }
- }
- else
- {
- EStructuralFeature globalGroup = null;
- boolean isMixed = xsdComplexTypeDefinition.getContentTypeCategory() == XSDContentTypeCategory.MIXED_LITERAL;
- String featureMapName = getEcoreAttribute(xsdComplexTypeDefinition, "featureMap");
- if (eClass.getESuperTypes().isEmpty() ?
- "true".equals(getEcoreAttribute(xsdComplexTypeDefinition, "mixed")) :
- extendedMetaData.getMixedFeature((EClass)eClass.getESuperTypes().get(0)) != null)
- {
- isMixed = true;
- }
- extendedMetaData.setContentKind
- (eClass,
- isMixed ?
- ExtendedMetaData.MIXED_CONTENT :
- xsdComplexTypeDefinition.getContentTypeCategory() == XSDContentTypeCategory.EMPTY_LITERAL ?
- ExtendedMetaData.EMPTY_CONTENT :
- ExtendedMetaData.ELEMENT_ONLY_CONTENT);
- if (isMixed)
- {
- EStructuralFeature mixedFeature = extendedMetaData.getMixedFeature(eClass);
- if (mixedFeature == null)
- {
- if (featureMapName == null)
- {
- featureMapName = "mixed";
- }
- mixedFeature =
- createFeature
- (eClass,
- featureMapName,
- ecorePackage.getEFeatureMapEntry(),
- null,
- 0,
- -1);
- extendedMetaData.setName(mixedFeature, ":mixed");
- }
- }
- else
- {
- globalGroup = extendedMetaData.getElement(eClass, null, ":group");
- if (globalGroup == null && featureMapName != null && eClass.getESuperTypes().isEmpty())
- {
- globalGroup =
- createFeature
- (eClass,
- featureMapName,
- ecorePackage.getEFeatureMapEntry(),
- null,
- 0,
- -1);
- extendedMetaData.setName(globalGroup, ":group");
- extendedMetaData.setFeatureKind(globalGroup, ExtendedMetaData.GROUP_FEATURE);
- }
- }
-
- if (xsdComplexTypeDefinition.getContent() != null)
- {
- // 51210
- // Map particleMap = new HashMap();
- Map groups = new HashMap();
- List particleInformation = collectParticles((XSDParticle)xsdComplexTypeDefinition.getContent());
- for (Iterator i = particleInformation.iterator(); i.hasNext(); )
- {
- EffectiveOccurrence effectiveOccurrence = (EffectiveOccurrence)i.next();
- XSDParticle xsdParticle = effectiveOccurrence.xsdParticle;
- EStructuralFeature group = (EStructuralFeature)groups.get(effectiveOccurrence.xsdModelGroup);
- XSDTerm xsdTerm = xsdParticle.getTerm();
- EStructuralFeature eStructuralFeature = null;
- String name = getEcoreAttribute(xsdParticle, "name");
- if (xsdTerm instanceof XSDModelGroup)
- {
- if (!isRestriction)
- {
- XSDModelGroup xsdModelGroup = (XSDModelGroup)xsdTerm;
- if (name == null)
- {
- name = getEcoreAttribute(xsdParticle, "featureMap");
- if (name == null)
- {
- name = getEcoreAttribute(xsdModelGroup, "name");
- if (name == null)
- {
- name = getEcoreAttribute(xsdModelGroup, "featureMap");
- if (name == null)
- {
- if (xsdModelGroup.getContainer() instanceof XSDModelGroupDefinition)
- {
- XSDModelGroupDefinition xsdModelGroupDefinition = (XSDModelGroupDefinition)xsdModelGroup.getContainer();
- name = getEcoreAttribute(xsdModelGroupDefinition, "name");
- if (name == null)
- {
- name = validName(xsdModelGroupDefinition.getName(), true);
- }
- }
- else
- {
- name = "group";
- }
- }
- }
- }
- }
-
- eStructuralFeature =
- createFeature
- (eClass,
- name,
- ecorePackage.getEFeatureMapEntry(),
- xsdParticle,
- 0,
- -1);
- groups.put(xsdTerm, eStructuralFeature);
- extendedMetaData.setName(eStructuralFeature, name + ":" + eClass.getEAllStructuralFeatures().indexOf(eStructuralFeature));
- }
- }
- else if (xsdTerm instanceof XSDWildcard)
- {
- if (!isRestriction)
- {
- if (name == null)
- {
- name = getEcoreAttribute(xsdTerm, "name");
- if (name == null)
- {
- name = "any";
- }
- }
- eStructuralFeature =
- createFeature
- (eClass,
- name,
- ecorePackage.getEFeatureMapEntry(),
- xsdParticle,
- effectiveOccurrence.minOccurs,
- effectiveOccurrence.maxOccurs);
- // 51210
- // particleMap.put(xsdParticle, eStructuralFeature);
- }
- }
- else
- {
- XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration)xsdTerm;
-
- boolean isRedundant = false;
- if (isRestriction)
- {
- isRedundant =
- extendedMetaData.getElement
- (baseClass, xsdElementDeclaration.getTargetNamespace(), xsdElementDeclaration.getName()) != null;
-
- if (!isRedundant)
- {
- group =
- extendedMetaData.getElementWildcardAffiliation
- (baseClass, xsdElementDeclaration.getTargetNamespace(), xsdElementDeclaration.getName());
- }
- }
-
- if (!isRedundant)
- {
- if (name == null)
- {
- name = getEcoreAttribute(xsdElementDeclaration, "name");
- if (name == null)
- {
- name = validName(xsdElementDeclaration.getName(), true);
- }
- }
-
- String groupName = getEcoreAttribute(xsdParticle, "featureMap");
- if (groupName == null)
- {
- groupName = getEcoreAttribute(xsdElementDeclaration, "featureMap");
- }
-
- if (!"".equals(groupName) &&
- (groupName != null ||
- xsdElementDeclaration.isAbstract() ||
- xsdElementDeclaration.getSubstitutionGroup().size() > 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 || xsdComponent instanceof XSDSimpleTypeDefinition)
- {
- extendedMetaData.setName(eReference, ":" + eClass.getEAllStructuralFeatures().indexOf(eReference));
- extendedMetaData.setFeatureKind(eReference, ExtendedMetaData.SIMPLE_FEATURE);
- eReference.setResolveProxies(!isLocalReferenceType((XSDSimpleTypeDefinition)xsdComponent));
- }
- 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 || xsdComponent instanceof XSDSimpleTypeDefinition)
- {
- 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 XSDTypeDefinition getEffectiveTypeDefinition(XSDComponent xsdComponent, XSDFeature xsdFeature)
- {
- return xsdFeature == null ?
- ((XSDComplexTypeDefinition)xsdComponent.eContainer()).getSimpleType() : xsdFeature.getType();
- }
-
- 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;
- }
- }
-
- protected EStructuralFeature createFeature
- (EClass eClass, XSDAttributeDeclaration xsdAttributeDeclaration, String name, XSDComponent xsdComponent, boolean isRequired)
- {
- XSDSimpleTypeDefinition attributeTypeDefinition = (XSDSimpleTypeDefinition)getEffectiveTypeDefinition(xsdComponent, xsdAttributeDeclaration);
- if (attributeTypeDefinition == null)
- {
- attributeTypeDefinition = xsdComponent.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("anySimpleType");
- }
-
- XSDTypeDefinition referenceType = getEcoreTypeQNameAttribute(xsdComponent, "reference");
- if (referenceType == null && xsdAttributeDeclaration != null)
- {
- referenceType = getEcoreTypeQNameAttribute(xsdAttributeDeclaration, "reference");
- }
- if (referenceType != null)
- {
- int lowerBound = isRequired ? 1 : 0;
- int upperBound = 1;
- if (attributeTypeDefinition.getVariety() == XSDVariety.LIST_LITERAL)
- {
- XSDLengthFacet xsdLengthFacet = attributeTypeDefinition.getEffectiveLengthFacet();
- if (isRequired)
- {
- if (xsdLengthFacet != null)
- {
- lowerBound = xsdLengthFacet.getValue();
- }
- else
- {
- XSDMinLengthFacet xsdMinLengthFacet = attributeTypeDefinition.getEffectiveMinLengthFacet();
- if (xsdMinLengthFacet != null)
- {
- lowerBound = xsdMinLengthFacet.getValue();
- }
- }
- }
- if (xsdLengthFacet != null)
- {
- upperBound = xsdLengthFacet.getValue();
- }
- else
- {
- XSDMaxLengthFacet xsdMaxLengthFacet = attributeTypeDefinition.getEffectiveMaxLengthFacet();
- if (xsdMaxLengthFacet != null)
- {
- upperBound = xsdMaxLengthFacet.getValue();
- }
- else
- {
- upperBound = -1;
- }
- }
- }
-
- EClassifier referenceClassifier = getEClassifier(referenceType);
- EStructuralFeature result =
- createFeature
- (eClass,
- name,
- referenceClassifier,
- xsdComponent,
- lowerBound,
- upperBound);
- initialize(result, xsdAttributeDeclaration, xsdComponent);
- return result;
- }
- else
- {
- boolean isMany =
- attributeTypeDefinition.getVariety() == XSDVariety.LIST_LITERAL &&
- xsdComponent instanceof XSDAttributeUse &&
- "true".equals(getEcoreAttribute(xsdComponent, "many"));
- if (isMany)
- {
- EDataType eDataType = getEDataType(attributeTypeDefinition.getItemTypeDefinition());
- XSDLengthFacet xsdLengthFacet = attributeTypeDefinition.getEffectiveLengthFacet();
- int lowerBound = isRequired ? 1 : 0;
- int upperBound = -1;
- if (isRequired)
- {
- if (xsdLengthFacet != null)
- {
- lowerBound = xsdLengthFacet.getValue();
- }
- else
- {
- XSDMinLengthFacet xsdMinLengthFacet = attributeTypeDefinition.getEffectiveMinLengthFacet();
- if (xsdMinLengthFacet != null)
- {
- lowerBound = xsdMinLengthFacet.getValue();
- }
- }
- }
- if (xsdLengthFacet != null)
- {
- upperBound = xsdLengthFacet.getValue();
- }
- else
- {
- XSDMaxLengthFacet xsdMaxLengthFacet = attributeTypeDefinition.getEffectiveMaxLengthFacet();
- if (xsdMaxLengthFacet != null)
- {
- upperBound = xsdMaxLengthFacet.getValue();
- }
- }
- EStructuralFeature result =
- createFeature
- (eClass,
- name,
- eDataType,
- xsdComponent,
- lowerBound,
- upperBound);
- initialize(result, xsdAttributeDeclaration, xsdComponent);
- return result;
- }
- else
- {
- EDataType eDataType = getEDataType(attributeTypeDefinition);
- EStructuralFeature result =
- createFeature
- (eClass,
- name,
- eDataType,
- xsdComponent,
- isRequired ? 1 : 0,
- 1);
- initialize(result, xsdAttributeDeclaration, 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();
- }
-
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+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.EEnum;
+import org.eclipse.emf.ecore.EOperation;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EParameter;
+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.util.EcoreUtil;
+import org.eclipse.emf.ecore.util.ExtendedMetaData;
+import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
+import org.eclipse.xsd.XSDAnnotation;
+import org.eclipse.xsd.XSDAttributeDeclaration;
+import org.eclipse.xsd.XSDAttributeUse;
+import org.eclipse.xsd.XSDComplexTypeContent;
+import org.eclipse.xsd.XSDComplexTypeDefinition;
+import org.eclipse.xsd.XSDComponent;
+import org.eclipse.xsd.XSDContentTypeCategory;
+import org.eclipse.xsd.XSDDerivationMethod;
+import org.eclipse.xsd.XSDElementDeclaration;
+import org.eclipse.xsd.XSDFeature;
+import org.eclipse.xsd.XSDLengthFacet;
+import org.eclipse.xsd.XSDMaxLengthFacet;
+import org.eclipse.xsd.XSDMinLengthFacet;
+import org.eclipse.xsd.XSDModelGroup;
+import org.eclipse.xsd.XSDModelGroupDefinition;
+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.XSDVariety;
+import org.eclipse.xsd.XSDWildcard;
+import org.eclipse.xsd.ecore.XSDEcoreBuilder;
+import org.eclipse.xsd.util.XSDConstants;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * An XSDEcoreBuilder that uses a supplied (SDO) ecore factory to create properties and types.
+ */
+public class BaseSDOXSDEcoreBuilder extends XSDEcoreBuilder
+{
+ protected EcorePackage ecorePackage = EcorePackage.eINSTANCE;
+ protected EcoreFactory ecoreFactory = EcoreFactory.eINSTANCE;
+
+ public BaseSDOXSDEcoreBuilder(ExtendedMetaData extendedMetaData)
+ {
+ super(extendedMetaData);
+ }
+
+ private void createDocumentRoot(XSDSchema xsdSchema, EPackage ePackage) {
+ EClass documentEClass = ecoreFactory.createEClass();
+ String name = getEcoreAttribute(xsdSchema, "documentRoot");
+ if (name == null)
+ {
+ name = "DocumentRoot";
+ }
+ documentEClass.setName(name);
+
+ extendedMetaData.setDocumentRoot(documentEClass);
+
+ ePackage.getEClassifiers().add(documentEClass);
+
+ createFeature
+ (documentEClass,
+ "mixed",
+ ecorePackage.getEFeatureMapEntry(),
+ null,
+ 0,
+ -1);
+
+ EStructuralFeature xmlnsPrefixMapFeature =
+ createFeature
+ (documentEClass,
+ "xMLNSPrefixMap",
+ ecorePackage.getEStringToStringMapEntry(),
+ null,
+ 0,
+ -1);
+ extendedMetaData.setName(xmlnsPrefixMapFeature, "xmlns:prefix");
+
+ EStructuralFeature xsiSchemaLocationMapFeature =
+ createFeature
+ (documentEClass,
+ "xSISchemaLocation",
+ ecorePackage.getEStringToStringMapEntry(),
+ null,
+ 0,
+ -1);
+ extendedMetaData.setName(xsiSchemaLocationMapFeature, "xsi:schemaLocation");
+ }
+
+ public EPackage getEPackage(XSDNamedComponent xsdNamedComponent)
+ {
+ XSDSchema containingXSDSchema = xsdNamedComponent.getSchema();
+ if (containingXSDSchema != null && !xsdSchemas.contains(containingXSDSchema))
+ {
+ xsdSchemas.add(containingXSDSchema);
+ addInput(containingXSDSchema);
+ validate(containingXSDSchema);
+ }
+
+ String targetNamespace =
+ containingXSDSchema == null ?
+ xsdNamedComponent.getTargetNamespace() :
+ containingXSDSchema.getTargetNamespace();
+ EPackage ePackage = (EPackage)targetNamespaceToEPackageMap.get(targetNamespace);
+ if (ePackage == null)
+ {
+ ePackage = ecoreFactory.createEPackage();
+ setAnnotations(ePackage, containingXSDSchema);
+ addOutput(ePackage);
+ if (targetNamespace == null)
+ {
+ if (containingXSDSchema == null)
+ {
+ containingXSDSchema = rootSchema;
+ }
+ ePackage.setName(validName(containingXSDSchema.eResource().getURI().trimFileExtension().lastSegment(), true));
+ ePackage.setNsURI(containingXSDSchema.eResource().getURI().toString());
+
+ // Also register against the nsURI for the case that the target namespace is null.
+ //
+ // extendedMetaData.putPackage(ePackage.getNsURI(), ePackage);
+ }
+ else
+ {
+ String qualifiedPackageName = qualifiedPackageName(targetNamespace);
+ ePackage.setName(qualifiedPackageName);
+ ePackage.setNsURI(targetNamespace);
+ }
+
+ String nsPrefix = ePackage.getName();
+ int index = nsPrefix.lastIndexOf('.');
+ nsPrefix = index == -1 ? nsPrefix : nsPrefix.substring(index + 1);
+
+ // http://www.w3.org/TR/REC-xml-names/#xmlReserved
+ // Namespace Constraint: Leading "XML"
+ // Prefixes beginning with the three-letter sequence x, m, l, in any case combination,
+ // are reserved for use by XML and XML-related specifications.
+ //
+ if (nsPrefix.toLowerCase().startsWith("xml"))
+ {
+ nsPrefix = "_" + nsPrefix;
+ }
+ ePackage.setNsPrefix(nsPrefix);
+
+ extendedMetaData.setQualified(ePackage, targetNamespace != null);
+ extendedMetaData.putPackage(targetNamespace, ePackage);
+
+ targetNamespaceToEPackageMap.put(targetNamespace, ePackage);
+
+ createDocumentRoot(xsdNamedComponent.getSchema(), ePackage);
+ }
+
+ return ePackage;
+ }
+
+ protected EClassifier computeEClassifier(XSDTypeDefinition xsdTypeDefinition)
+ {
+ if (xsdTypeDefinition == null)
+ {
+ return getBuiltInEClassifier(rootSchema.getSchemaForSchemaNamespace(), "anySimpleType");
+ }
+ else if (xsdTypeDefinition instanceof XSDSimpleTypeDefinition)
+ {
+ return computeEDataType((XSDSimpleTypeDefinition)xsdTypeDefinition);
+ }
+ else
+ {
+ return computeEClass((XSDComplexTypeDefinition)xsdTypeDefinition);
+ }
+ }
+
+ protected EDataType computeEDataType(XSDSimpleTypeDefinition xsdSimpleTypeDefinition)
+ {
+ if (xsdSimpleTypeDefinition == null)
+ {
+ return (EDataType)getBuiltInEClassifier(rootSchema.getSchemaForSchemaNamespace(), "anySimpleType");
+ }
+ else if (XSDConstants.isSchemaForSchemaNamespace(xsdSimpleTypeDefinition.getTargetNamespace()))
+ {
+ String name = xsdSimpleTypeDefinition.getName();
+ if (name != null)
+ {
+ EDataType result = (EDataType)getBuiltInEClassifier(xsdSimpleTypeDefinition.getTargetNamespace(), "anyType".equals(name) ? "anySimpleType" : name);
+ if (result != null)
+ {
+ return result;
+ }
+ }
+ }
+ else if (xsdSimpleTypeDefinition.getContainer() == null)
+ {
+ return (EDataType)getBuiltInEClassifier(rootSchema.getSchemaForSchemaNamespace(), "anySimpleType");
+ }
+
+ String explicitInstanceClassName = getEcoreAttribute(xsdSimpleTypeDefinition, "instanceClass");
+ if (explicitInstanceClassName != null)
+ {
+ EDataType eDataType = ecoreFactory.createEDataType();
+ setAnnotations(eDataType, xsdSimpleTypeDefinition);
+
+ String aliasName = getEcoreAttribute(xsdSimpleTypeDefinition, "name");
+ if (aliasName == null)
+ {
+ aliasName = validAliasName(xsdSimpleTypeDefinition, true);
+ }
+ eDataType.setName(aliasName);
+ extendedMetaData.setName(eDataType, xsdSimpleTypeDefinition.getAliasName());
+
+ eDataType.setInstanceClassName(explicitInstanceClassName);
+
+ EPackage ePackage = getEPackage(xsdSimpleTypeDefinition);
+ addToSortedList(ePackage.getEClassifiers(), eDataType);
+
+ checkForPrimitive(xsdSimpleTypeDefinition, eDataType);
+
+ handleFacets(xsdSimpleTypeDefinition, eDataType);
+
+ String constraints = getEcoreAttribute(xsdSimpleTypeDefinition, "constraints");
+ if (constraints != null)
+ {
+ EcoreUtil.setAnnotation(eDataType, EcorePackage.eNS_URI, "constraints", constraints);
+ }
+
+ if ("false".equals(getEcoreAttribute(xsdSimpleTypeDefinition, "serializable")))
+ {
+ eDataType.setSerializable(false);
+ }
+ return eDataType;
+ }
+ else
+ {
+ EEnum eEnum = computeEEnum(xsdSimpleTypeDefinition);
+ if (eEnum != null)
+ {
+ return eEnum;
+ }
+ else
+ {
+ XSDSimpleTypeDefinition baseTypeDefinition = xsdSimpleTypeDefinition.getBaseTypeDefinition();
+ if (baseTypeDefinition != null)
+ {
+ EDataType eDataType = ecoreFactory.createEDataType();
+ setAnnotations(eDataType, xsdSimpleTypeDefinition);
+
+ String name = getEcoreAttribute(xsdSimpleTypeDefinition, "name");
+ if (name == null)
+ {
+ name = validAliasName(xsdSimpleTypeDefinition, true);
+ }
+
+ eDataType.setName(name);
+ extendedMetaData.setName(eDataType, xsdSimpleTypeDefinition.getAliasName());
+
+ EPackage ePackage = getEPackage(xsdSimpleTypeDefinition);
+ addToSortedList(ePackage.getEClassifiers(), eDataType);
+
+ if (baseTypeDefinition.getVariety() != xsdSimpleTypeDefinition.getVariety())
+ {
+ if (xsdSimpleTypeDefinition.getVariety() == XSDVariety.LIST_LITERAL)
+ {
+ EDataType itemEDataType = getEDataType(xsdSimpleTypeDefinition.getItemTypeDefinition());
+ extendedMetaData.setItemType(eDataType, itemEDataType);
+ eDataType.setInstanceClassName("java.util.List");
+ }
+ else
+ {
+ String instanceClassName = null;
+ List memberTypes = new ArrayList();
+ for (Iterator i = xsdSimpleTypeDefinition.getMemberTypeDefinitions().iterator(); i.hasNext(); )
+ {
+ XSDSimpleTypeDefinition memberTypeDefinition = (XSDSimpleTypeDefinition)i.next();
+ EDataType memberEDataType = getEDataType(memberTypeDefinition);
+ memberTypes.add(memberEDataType);
+ String memberInstanceClassName = memberEDataType.getInstanceClassName();
+ if (memberInstanceClassName == null && memberEDataType instanceof EEnum)
+ {
+ memberInstanceClassName = "org.eclipse.emf.common.util.Enumerator";
+ }
+ if (instanceClassName == null)
+ {
+ instanceClassName = memberInstanceClassName;
+ }
+ else if (instanceClassName != memberInstanceClassName)
+ {
+ instanceClassName = "java.lang.Object";
+ }
+ }
+ extendedMetaData.setMemberTypes(eDataType, memberTypes);
+ eDataType.setInstanceClassName(instanceClassName);
+ }
+ }
+ else
+ {
+ EDataType baseEDataType = getEDataType(baseTypeDefinition);
+ extendedMetaData.setBaseType(eDataType, baseEDataType);
+ String instanceClassName = getInstanceClassName(xsdSimpleTypeDefinition, baseEDataType);
+ eDataType.setInstanceClassName
+ (instanceClassName == null ?
+ "org.eclipse.emf.common.util.Enumerator" :
+ instanceClassName);
+ }
+
+ checkForPrimitive(xsdSimpleTypeDefinition, eDataType);
+ handleFacets(xsdSimpleTypeDefinition, eDataType);
+
+ String constraints = getEcoreAttribute(xsdSimpleTypeDefinition, "constraints");
+ if (constraints != null)
+ {
+ EcoreUtil.setAnnotation(eDataType, EcorePackage.eNS_URI, "constraints", constraints);
+ }
+
+ if ("false".equals(getEcoreAttribute(xsdSimpleTypeDefinition, "serializable")))
+ {
+ eDataType.setSerializable(false);
+ }
+
+ return eDataType;
+ }
+ }
+ return (EDataType)getBuiltInEClassifier(rootSchema.getSchemaForSchemaNamespace(), "anySimpleType");
+ }
+ }
+
+ protected void checkForPrimitive(EDataType eDataType)
+ {
+ int index = PRIMITIVES.indexOf(eDataType.getInstanceClassName());
+ if (index != -1 || eDataType instanceof EEnum)
+ {
+ EDataType eDataTypeObject = ecoreFactory.createEDataType();
+ eDataTypeObject.setName(eDataType.getName() + "Object");
+ if (index != -1)
+ {
+ eDataTypeObject.setInstanceClassName(PRIMITIVE_WRAPPERS[index]);
+ }
+ else
+ {
+ eDataTypeObject.setInstanceClassName("org.eclipse.emf.common.util.Enumerator");
+ }
+ extendedMetaData.setName(eDataTypeObject, extendedMetaData.getName(eDataType) + ":Object");
+ addToSortedList(eDataType.getEPackage().getEClassifiers(), eDataTypeObject);
+ extendedMetaData.setBaseType(eDataTypeObject, eDataType);
+
+ typeToTypeObjectMap.put(eDataType, eDataTypeObject);
+ }
+ }
+
+ public EClass computeEClass(XSDComplexTypeDefinition xsdComplexTypeDefinition)
+ {
+ if (xsdComplexTypeDefinition == null)
+ {
+ return (EClass)getBuiltInEClassifier(rootSchema.getSchemaForSchemaNamespace(), "anyType");
+ }
+ else if (XSDConstants.isSchemaForSchemaNamespace(xsdComplexTypeDefinition.getTargetNamespace()))
+ {
+ String name = xsdComplexTypeDefinition.getName();
+ if (name != null)
+ {
+ EClass result = (EClass)getBuiltInEClassifier(xsdComplexTypeDefinition.getTargetNamespace(), name);
+ if (result != null)
+ {
+ return result;
+ }
+ }
+ }
+ else if (xsdComplexTypeDefinition.getContainer() == null)
+ {
+ return (EClass)getBuiltInEClassifier(rootSchema.getSchemaForSchemaNamespace(), "anyType");
+ }
+
+ EClass eClass = ecoreFactory.createEClass();
+ setAnnotations(eClass, xsdComplexTypeDefinition);
+ // Do this early to prevent recursive loop.
+ xsdComponentToEModelElementMap.put(xsdComplexTypeDefinition, eClass);
+
+ if ("true".equals(getEcoreAttribute(xsdComplexTypeDefinition, "interface")))
+ {
+ eClass.setInterface(true);
+ }
+
+ String instanceClassName = getEcoreAttribute(xsdComplexTypeDefinition, "instanceClass");
+ if (instanceClassName != null)
+ {
+ eClass.setInstanceClassName(instanceClassName);
+ }
+
+ String aliasName = getEcoreAttribute(xsdComplexTypeDefinition, "name");
+ if (aliasName == null)
+ {
+ aliasName = validAliasName(xsdComplexTypeDefinition, true);
+ }
+ eClass.setName(aliasName);
+ extendedMetaData.setName(eClass, xsdComplexTypeDefinition.getAliasName());
+
+ String constraints = getEcoreAttribute(xsdComplexTypeDefinition, "constraints");
+ if (constraints != null)
+ {
+ EcoreUtil.setAnnotation(eClass, EcorePackage.eNS_URI, "constraints", constraints);
+ }
+
+ EPackage ePackage = getEPackage(xsdComplexTypeDefinition);
+ addToSortedList(ePackage.getEClassifiers(), eClass);
+
+ if (xsdComplexTypeDefinition.isAbstract())
+ {
+ eClass.setAbstract(true);
+ }
+
+ EClass baseClass = null;
+ XSDTypeDefinition baseTypeDefinition = xsdComplexTypeDefinition.getBaseTypeDefinition();
+ if (!baseTypeDefinition.isCircular())
+ {
+ EClassifier baseType = getEClassifier(baseTypeDefinition);
+ if (baseType instanceof EClass && baseType != ecorePackage.getEObject())
+ {
+ eClass.getESuperTypes().add(baseClass = (EClass)baseType);
+ }
+ }
+
+ boolean isRestriction =
+ !eClass.getESuperTypes().isEmpty() &&
+ xsdComplexTypeDefinition.getDerivationMethod() == XSDDerivationMethod.RESTRICTION_LITERAL;
+
+ for (Iterator i = getEcoreTypeQNamesAttribute(xsdComplexTypeDefinition, "implements").iterator(); i.hasNext(); )
+ {
+ XSDTypeDefinition mixin = (XSDTypeDefinition)i.next();
+ if (!XSDConstants.isURType(mixin))
+ {
+ EClassifier mixinType = getEClassifier(mixin);
+ if (mixinType instanceof EClass && mixinType != ecorePackage.getEObject())
+ {
+ eClass.getESuperTypes().add(mixinType);
+ }
+ }
+ }
+
+ // 51210
+ // EAnnotation contentParticle = null;
+
+ if (xsdComplexTypeDefinition.getContentTypeCategory() == XSDContentTypeCategory.SIMPLE_LITERAL)
+ {
+ extendedMetaData.setContentKind(eClass, ExtendedMetaData.SIMPLE_CONTENT);
+ if (!"SimpleAnyType".equals(eClass.getName()) || !XMLTypePackage.eNS_URI.equals(eClass.getEPackage().getNsURI()))
+ {
+ if (eClass.getEAllStructuralFeatures().isEmpty())
+ {
+ XSDComplexTypeContent xsdComplexTypeContent = xsdComplexTypeDefinition.getContent();
+ String name = getEcoreAttribute(xsdComplexTypeContent, "name");
+ if (name == null)
+ {
+ name = "value";
+ }
+ createFeature
+ (eClass,
+ null,
+ name,
+ xsdComplexTypeContent,
+ false);
+ }
+ else
+ {
+ XSDSimpleTypeDefinition xsdSimpleTypeDefinition = xsdComplexTypeDefinition.getSimpleType();
+ getEClassifier(xsdSimpleTypeDefinition);
+ }
+ }
+ }
+ else
+ {
+ EStructuralFeature globalGroup = null;
+ boolean isMixed = xsdComplexTypeDefinition.getContentTypeCategory() == XSDContentTypeCategory.MIXED_LITERAL;
+ String featureMapName = getEcoreAttribute(xsdComplexTypeDefinition, "featureMap");
+ if (eClass.getESuperTypes().isEmpty() ?
+ "true".equals(getEcoreAttribute(xsdComplexTypeDefinition, "mixed")) :
+ extendedMetaData.getMixedFeature((EClass)eClass.getESuperTypes().get(0)) != null)
+ {
+ isMixed = true;
+ }
+ extendedMetaData.setContentKind
+ (eClass,
+ isMixed ?
+ ExtendedMetaData.MIXED_CONTENT :
+ xsdComplexTypeDefinition.getContentTypeCategory() == XSDContentTypeCategory.EMPTY_LITERAL ?
+ ExtendedMetaData.EMPTY_CONTENT :
+ ExtendedMetaData.ELEMENT_ONLY_CONTENT);
+ if (isMixed)
+ {
+ EStructuralFeature mixedFeature = extendedMetaData.getMixedFeature(eClass);
+ if (mixedFeature == null)
+ {
+ if (featureMapName == null)
+ {
+ featureMapName = "mixed";
+ }
+ mixedFeature =
+ createFeature
+ (eClass,
+ featureMapName,
+ ecorePackage.getEFeatureMapEntry(),
+ null,
+ 0,
+ -1);
+ extendedMetaData.setName(mixedFeature, ":mixed");
+ }
+ }
+ else
+ {
+ globalGroup = extendedMetaData.getElement(eClass, null, ":group");
+ if (globalGroup == null && featureMapName != null && eClass.getESuperTypes().isEmpty())
+ {
+ globalGroup =
+ createFeature
+ (eClass,
+ featureMapName,
+ ecorePackage.getEFeatureMapEntry(),
+ null,
+ 0,
+ -1);
+ extendedMetaData.setName(globalGroup, ":group");
+ extendedMetaData.setFeatureKind(globalGroup, ExtendedMetaData.GROUP_FEATURE);
+ }
+ }
+
+ if (xsdComplexTypeDefinition.getContent() != null)
+ {
+ // 51210
+ // Map particleMap = new HashMap();
+ Map groups = new HashMap();
+ List particleInformation = collectParticles((XSDParticle)xsdComplexTypeDefinition.getContent());
+ for (Iterator i = particleInformation.iterator(); i.hasNext(); )
+ {
+ EffectiveOccurrence effectiveOccurrence = (EffectiveOccurrence)i.next();
+ XSDParticle xsdParticle = effectiveOccurrence.xsdParticle;
+ EStructuralFeature group = (EStructuralFeature)groups.get(effectiveOccurrence.xsdModelGroup);
+ XSDTerm xsdTerm = xsdParticle.getTerm();
+ EStructuralFeature eStructuralFeature = null;
+ String name = getEcoreAttribute(xsdParticle, "name");
+ if (xsdTerm instanceof XSDModelGroup)
+ {
+ if (!isRestriction)
+ {
+ XSDModelGroup xsdModelGroup = (XSDModelGroup)xsdTerm;
+ if (name == null)
+ {
+ name = getEcoreAttribute(xsdParticle, "featureMap");
+ if (name == null)
+ {
+ name = getEcoreAttribute(xsdModelGroup, "name");
+ if (name == null)
+ {
+ name = getEcoreAttribute(xsdModelGroup, "featureMap");
+ if (name == null)
+ {
+ if (xsdModelGroup.getContainer() instanceof XSDModelGroupDefinition)
+ {
+ XSDModelGroupDefinition xsdModelGroupDefinition = (XSDModelGroupDefinition)xsdModelGroup.getContainer();
+ name = getEcoreAttribute(xsdModelGroupDefinition, "name");
+ if (name == null)
+ {
+ name = validName(xsdModelGroupDefinition.getName(), true);
+ }
+ }
+ else
+ {
+ name = "group";
+ }
+ }
+ }
+ }
+ }
+
+ eStructuralFeature =
+ createFeature
+ (eClass,
+ name,
+ ecorePackage.getEFeatureMapEntry(),
+ xsdParticle,
+ 0,
+ -1);
+ groups.put(xsdTerm, eStructuralFeature);
+ extendedMetaData.setName(eStructuralFeature, name + ":" + eClass.getEAllStructuralFeatures().indexOf(eStructuralFeature));
+ }
+ }
+ else if (xsdTerm instanceof XSDWildcard)
+ {
+ if (!isRestriction)
+ {
+ if (name == null)
+ {
+ name = getEcoreAttribute(xsdTerm, "name");
+ if (name == null)
+ {
+ name = "any";
+ }
+ }
+ eStructuralFeature =
+ createFeature
+ (eClass,
+ name,
+ ecorePackage.getEFeatureMapEntry(),
+ xsdParticle,
+ effectiveOccurrence.minOccurs,
+ effectiveOccurrence.maxOccurs);
+ // 51210
+ // particleMap.put(xsdParticle, eStructuralFeature);
+ }
+ }
+ else
+ {
+ XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration)xsdTerm;
+
+ boolean isRedundant = false;
+ if (isRestriction)
+ {
+ isRedundant =
+ extendedMetaData.getElement
+ (baseClass, xsdElementDeclaration.getTargetNamespace(), xsdElementDeclaration.getName()) != null;
+
+ if (!isRedundant)
+ {
+ group =
+ extendedMetaData.getElementWildcardAffiliation
+ (baseClass, xsdElementDeclaration.getTargetNamespace(), xsdElementDeclaration.getName());
+ }
+ }
+
+ if (!isRedundant)
+ {
+ if (name == null)
+ {
+ name = getEcoreAttribute(xsdElementDeclaration, "name");
+ if (name == null)
+ {
+ name = validName(xsdElementDeclaration.getName(), true);
+ }
+ }
+
+ String groupName = getEcoreAttribute(xsdParticle, "featureMap");
+ if (groupName == null)
+ {
+ groupName = getEcoreAttribute(xsdElementDeclaration, "featureMap");
+ }
+
+ if (!"".equals(groupName) &&
+ (groupName != null ||
+ xsdElementDeclaration.isAbstract() ||
+ xsdElementDeclaration.getSubstitutionGroup().size() > 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 || xsdComponent instanceof XSDSimpleTypeDefinition)
+ {
+ extendedMetaData.setName(eReference, ":" + eClass.getEAllStructuralFeatures().indexOf(eReference));
+ extendedMetaData.setFeatureKind(eReference, ExtendedMetaData.SIMPLE_FEATURE);
+ eReference.setResolveProxies(!isLocalReferenceType((XSDSimpleTypeDefinition)xsdComponent));
+ }
+ 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 || xsdComponent instanceof XSDSimpleTypeDefinition)
+ {
+ 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 XSDTypeDefinition getEffectiveTypeDefinition(XSDComponent xsdComponent, XSDFeature xsdFeature)
+ {
+ return xsdFeature == null ?
+ ((XSDComplexTypeDefinition)xsdComponent.eContainer()).getSimpleType() : xsdFeature.getType();
+ }
+
+ 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;
+ }
+ }
+
+ protected EStructuralFeature createFeature
+ (EClass eClass, XSDAttributeDeclaration xsdAttributeDeclaration, String name, XSDComponent xsdComponent, boolean isRequired)
+ {
+ XSDSimpleTypeDefinition attributeTypeDefinition = (XSDSimpleTypeDefinition)getEffectiveTypeDefinition(xsdComponent, xsdAttributeDeclaration);
+ if (attributeTypeDefinition == null)
+ {
+ attributeTypeDefinition = xsdComponent.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("anySimpleType");
+ }
+
+ XSDTypeDefinition referenceType = getEcoreTypeQNameAttribute(xsdComponent, "reference");
+ if (referenceType == null && xsdAttributeDeclaration != null)
+ {
+ referenceType = getEcoreTypeQNameAttribute(xsdAttributeDeclaration, "reference");
+ }
+ if (referenceType != null)
+ {
+ int lowerBound = isRequired ? 1 : 0;
+ int upperBound = 1;
+ if (attributeTypeDefinition.getVariety() == XSDVariety.LIST_LITERAL)
+ {
+ XSDLengthFacet xsdLengthFacet = attributeTypeDefinition.getEffectiveLengthFacet();
+ if (isRequired)
+ {
+ if (xsdLengthFacet != null)
+ {
+ lowerBound = xsdLengthFacet.getValue();
+ }
+ else
+ {
+ XSDMinLengthFacet xsdMinLengthFacet = attributeTypeDefinition.getEffectiveMinLengthFacet();
+ if (xsdMinLengthFacet != null)
+ {
+ lowerBound = xsdMinLengthFacet.getValue();
+ }
+ }
+ }
+ if (xsdLengthFacet != null)
+ {
+ upperBound = xsdLengthFacet.getValue();
+ }
+ else
+ {
+ XSDMaxLengthFacet xsdMaxLengthFacet = attributeTypeDefinition.getEffectiveMaxLengthFacet();
+ if (xsdMaxLengthFacet != null)
+ {
+ upperBound = xsdMaxLengthFacet.getValue();
+ }
+ else
+ {
+ upperBound = -1;
+ }
+ }
+ }
+
+ EClassifier referenceClassifier = getEClassifier(referenceType);
+ EStructuralFeature result =
+ createFeature
+ (eClass,
+ name,
+ referenceClassifier,
+ xsdComponent,
+ lowerBound,
+ upperBound);
+ initialize(result, xsdAttributeDeclaration, xsdComponent);
+ return result;
+ }
+ else
+ {
+ boolean isMany =
+ attributeTypeDefinition.getVariety() == XSDVariety.LIST_LITERAL &&
+ xsdComponent instanceof XSDAttributeUse &&
+ "true".equals(getEcoreAttribute(xsdComponent, "many"));
+ if (isMany)
+ {
+ EDataType eDataType = getEDataType(attributeTypeDefinition.getItemTypeDefinition());
+ XSDLengthFacet xsdLengthFacet = attributeTypeDefinition.getEffectiveLengthFacet();
+ int lowerBound = isRequired ? 1 : 0;
+ int upperBound = -1;
+ if (isRequired)
+ {
+ if (xsdLengthFacet != null)
+ {
+ lowerBound = xsdLengthFacet.getValue();
+ }
+ else
+ {
+ XSDMinLengthFacet xsdMinLengthFacet = attributeTypeDefinition.getEffectiveMinLengthFacet();
+ if (xsdMinLengthFacet != null)
+ {
+ lowerBound = xsdMinLengthFacet.getValue();
+ }
+ }
+ }
+ if (xsdLengthFacet != null)
+ {
+ upperBound = xsdLengthFacet.getValue();
+ }
+ else
+ {
+ XSDMaxLengthFacet xsdMaxLengthFacet = attributeTypeDefinition.getEffectiveMaxLengthFacet();
+ if (xsdMaxLengthFacet != null)
+ {
+ upperBound = xsdMaxLengthFacet.getValue();
+ }
+ }
+ EStructuralFeature result =
+ createFeature
+ (eClass,
+ name,
+ eDataType,
+ xsdComponent,
+ lowerBound,
+ upperBound);
+ initialize(result, xsdAttributeDeclaration, xsdComponent);
+ return result;
+ }
+ else
+ {
+ EDataType eDataType = getEDataType(attributeTypeDefinition);
+ EStructuralFeature result =
+ createFeature
+ (eClass,
+ name,
+ eDataType,
+ xsdComponent,
+ isRequired ? 1 : 0,
+ 1);
+ initialize(result, xsdAttributeDeclaration, 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/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/CrossScopeCopyHelperImpl.java b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/CrossScopeCopyHelperImpl.java
index b7a5534800..3f51876035 100644
--- a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/CrossScopeCopyHelperImpl.java
+++ b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/CrossScopeCopyHelperImpl.java
@@ -1,255 +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);
- }
- }
- }
- }
- }
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DefaultHelperContextImpl.java b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DefaultHelperContextImpl.java
index a8804e9e5d..f7ac22632a 100644
--- a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DefaultHelperContextImpl.java
+++ b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/DefaultHelperContextImpl.java
@@ -1,72 +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);
- }
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOHelperImpl.java b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOHelperImpl.java
index 3efd8d03b7..922f092845 100644
--- a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOHelperImpl.java
+++ b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/helper/SDOHelperImpl.java
@@ -1,530 +1,530 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * 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.SDOHelper;
-import org.apache.tuscany.sdo.api.XMLStreamHelper;
-import org.apache.tuscany.sdo.api.EventListener;
-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.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;
-
-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 int getLowerBound(Property property) {
- return ((EStructuralFeature)property).getLowerBound();
- }
-
- public List getEnumerationFacet(Type type) {
- List instProps = type.getInstanceProperties();
- String propertyName = "enumeration";
- Property enumProperty = null;
-
- for (int i = 0; i < instProps.size(); i++)
- {
- Property prop = (Property)instProps.get(i);
- if (propertyName.equals(prop.getName()))
- enumProperty = prop;
- }
-
- return (List)DataObjectUtil.getMetaObjectInstanceProperty((EModelElement)type, enumProperty);
- }
-
- public List getPatternFacet(Type type) {
- List instProps = type.getInstanceProperties();
- String propertyName = "pattern";
- Property patternProperty = null;
-
- for (int i = 0; i < instProps.size(); i++)
- {
- Property prop = (Property)instProps.get(i);
- if (propertyName.equals(prop.getName()))
- patternProperty = prop;
- }
-
- return (List)DataObjectUtil.getMetaObjectInstanceProperty((EModelElement)type, patternProperty);
- }
-
- 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 dob, EventListener listener) {
- // Adapter l = (Adapter)listener;
- ((Notifier)dob).eAdapters().add(listener);
- }
-
- public void removeChangeListener(DataObject dob, EventListener listener) {
- ((Notifier)dob).eAdapters().remove(listener);
- }
-
-
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.SDOHelper;
+import org.apache.tuscany.sdo.api.XMLStreamHelper;
+import org.apache.tuscany.sdo.api.EventListener;
+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.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;
+
+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 int getLowerBound(Property property) {
+ return ((EStructuralFeature)property).getLowerBound();
+ }
+
+ public List getEnumerationFacet(Type type) {
+ List instProps = type.getInstanceProperties();
+ String propertyName = "enumeration";
+ Property enumProperty = null;
+
+ for (int i = 0; i < instProps.size(); i++)
+ {
+ Property prop = (Property)instProps.get(i);
+ if (propertyName.equals(prop.getName()))
+ enumProperty = prop;
+ }
+
+ return (List)DataObjectUtil.getMetaObjectInstanceProperty((EModelElement)type, enumProperty);
+ }
+
+ public List getPatternFacet(Type type) {
+ List instProps = type.getInstanceProperties();
+ String propertyName = "pattern";
+ Property patternProperty = null;
+
+ for (int i = 0; i < instProps.size(); i++)
+ {
+ Property prop = (Property)instProps.get(i);
+ if (propertyName.equals(prop.getName()))
+ patternProperty = prop;
+ }
+
+ return (List)DataObjectUtil.getMetaObjectInstanceProperty((EModelElement)type, patternProperty);
+ }
+
+ 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 dob, EventListener listener) {
+ // Adapter l = (Adapter)listener;
+ ((Notifier)dob).eAdapters().add(listener);
+ }
+
+ public void removeChangeListener(DataObject dob, EventListener listener) {
+ ((Notifier)dob).eAdapters().remove(listener);
+ }
+
+
+}
diff --git a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/EventImpl.java b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/EventImpl.java
index a99ccb6ebe..206a3c1fbf 100644
--- a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/EventImpl.java
+++ b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/EventImpl.java
@@ -1,78 +1,78 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sdo.impl;
-
-import org.apache.tuscany.sdo.api.Event;
-import org.eclipse.emf.common.notify.Notification;
-
-import commonj.sdo.Property;
-
-
-public class EventImpl implements Event {
-
- protected Notification emfEvent;
- protected Object notifier;
-
- public EventImpl(Notification notification)
- {
- this.emfEvent = notification;
- }
-
- public Object getNotifier()
- {
- return notifier == null ? emfEvent.getNotifier() : notifier;
- }
-
- public int getEventType()
- {
- return emfEvent.getEventType();
- }
-
-
- public Property getProperty()
- {
- return (Property)emfEvent.getFeature();
- }
-
- public Object getOldValue()
- {
- return emfEvent.getOldValue();
- }
-
- public Object getNewValue()
- {
- return emfEvent.getNewValue();
- }
-
- public boolean wasSet()
- {
- return emfEvent.wasSet();
- }
-
- public boolean isTouch()
- {
- return emfEvent.isTouch();
- }
-
- public int getPosition()
- {
- return emfEvent.getPosition();
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.impl;
+
+import org.apache.tuscany.sdo.api.Event;
+import org.eclipse.emf.common.notify.Notification;
+
+import commonj.sdo.Property;
+
+
+public class EventImpl implements Event {
+
+ protected Notification emfEvent;
+ protected Object notifier;
+
+ public EventImpl(Notification notification)
+ {
+ this.emfEvent = notification;
+ }
+
+ public Object getNotifier()
+ {
+ return notifier == null ? emfEvent.getNotifier() : notifier;
+ }
+
+ public int getEventType()
+ {
+ return emfEvent.getEventType();
+ }
+
+
+ public Property getProperty()
+ {
+ return (Property)emfEvent.getFeature();
+ }
+
+ public Object getOldValue()
+ {
+ return emfEvent.getOldValue();
+ }
+
+ public Object getNewValue()
+ {
+ return emfEvent.getNewValue();
+ }
+
+ public boolean wasSet()
+ {
+ return emfEvent.wasSet();
+ }
+
+ public boolean isTouch()
+ {
+ return emfEvent.isTouch();
+ }
+
+ public int getPosition()
+ {
+ return emfEvent.getPosition();
+ }
+}
diff --git a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ListenerBase.java b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ListenerBase.java
index db840b11ff..986628bbc9 100644
--- a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ListenerBase.java
+++ b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/impl/ListenerBase.java
@@ -1,33 +1,33 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sdo.impl;
-
-import org.apache.tuscany.sdo.api.Event;
-import org.apache.tuscany.sdo.api.EventListener;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-
-public abstract class ListenerBase extends AdapterImpl implements EventListener {
-
- public void notifyChanged(Notification msg) {
- Event e = new EventImpl(msg);
- eventNotification(e);
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.impl;
+
+import org.apache.tuscany.sdo.api.Event;
+import org.apache.tuscany.sdo.api.EventListener;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.impl.AdapterImpl;
+
+public abstract class ListenerBase extends AdapterImpl implements EventListener {
+
+ public void notifyChanged(Notification msg) {
+ Event e = new EventImpl(msg);
+ eventNotification(e);
+ }
+}
diff --git a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/internal/InternalFactory.java b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/internal/InternalFactory.java
index 4776cb958f..061d082b1d 100644
--- a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/internal/InternalFactory.java
+++ b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/internal/InternalFactory.java
@@ -1,52 +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;
-
-
-/**
- * <!-- begin-user-doc -->
- * The <b>Factory</b> for the model.
- * It provides a create method for each non-abstract class of the model.
- * <!-- end-user-doc -->
- * @generated
- */
-public interface InternalFactory
-{
-
- /**
- * The singleton instance of the factory.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- InternalFactory INSTANCE = org.apache.tuscany.sdo.model.internal.impl.InternalFactoryImpl.init();
-
- /**
- * Registers the types supported by this Factory within the supplied scope.argument
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param scope an instance of HelperContext used to manage the scoping of types.
- * @generated
- */
- public void register(HelperContext scope);
-
-} //InternalFactory
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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;
+
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Factory</b> for the model.
+ * It provides a create method for each non-abstract class of the model.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public interface InternalFactory
+{
+
+ /**
+ * The singleton instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ InternalFactory INSTANCE = org.apache.tuscany.sdo.model.internal.impl.InternalFactoryImpl.init();
+
+ /**
+ * Registers the types supported by this Factory within the supplied scope.argument
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param scope an instance of HelperContext used to manage the scoping of types.
+ * @generated
+ */
+ public void register(HelperContext scope);
+
+} //InternalFactory
diff --git a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/internal/impl/InternalFactoryImpl.java b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/internal/impl/InternalFactoryImpl.java
index 4517f4a2a9..06d002ea74 100644
--- a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/internal/impl/InternalFactoryImpl.java
+++ b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/internal/impl/InternalFactoryImpl.java
@@ -1,296 +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;
-
-/**
- * <!-- begin-user-doc -->
- * 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 <temp-dir> -javaPackage org.apache.tuscany.sdo.model.internal <tuscany-sdo-impl-dir>/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.
- * <!-- end-user-doc -->
- * @generated
- */
-public class InternalFactoryImpl extends FactoryBase implements InternalFactory
-{
-
- /**
- * The package namespace URI.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final String NAMESPACE_URI = "http://www.apache.org/tuscany/commonj.sdo.internal";
-
- /**
- * The package namespace name.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final String NAMESPACE_PREFIX = "internal";
-
- /**
- * The version of the generator pattern used to generate this class.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public DataObject create(int typeNumber)
- {
- switch (typeNumber)
- {
- default:
- return super.create(typeNumber);
- }
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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");
- }
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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"
- });
-
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated NOT
- */
- public byte[] createBase64BytesFromString(String initialValue)
- {
- return XMLTypeFactory.eINSTANCE.createBase64Binary(initialValue);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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());
- }
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public String createQNameFromString(String initialValue)
- {
- return (String)super.createFromString(QNAME, initialValue);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public String convertQNameToString(Object instanceValue)
- {
- return super.convertToString(QNAME, instanceValue);
- }
-
-} //InternalFactoryImpl
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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;
+
+/**
+ * <!-- begin-user-doc -->
+ * 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 <temp-dir> -javaPackage org.apache.tuscany.sdo.model.internal <tuscany-sdo-impl-dir>/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.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class InternalFactoryImpl extends FactoryBase implements InternalFactory
+{
+
+ /**
+ * The package namespace URI.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String NAMESPACE_URI = "http://www.apache.org/tuscany/commonj.sdo.internal";
+
+ /**
+ * The package namespace name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String NAMESPACE_PREFIX = "internal";
+
+ /**
+ * The version of the generator pattern used to generate this class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public DataObject create(int typeNumber)
+ {
+ switch (typeNumber)
+ {
+ default:
+ return super.create(typeNumber);
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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");
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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"
+ });
+
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated NOT
+ */
+ public byte[] createBase64BytesFromString(String initialValue)
+ {
+ return XMLTypeFactory.eINSTANCE.createBase64Binary(initialValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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());
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String createQNameFromString(String initialValue)
+ {
+ return (String)super.createFromString(QNAME, initialValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String convertQNameToString(Object instanceValue)
+ {
+ return super.convertToString(QNAME, instanceValue);
+ }
+
+} //InternalFactoryImpl
diff --git a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/xml/XMLFactory.java b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/xml/XMLFactory.java
index 84a60cf849..39119a1c77 100644
--- a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/xml/XMLFactory.java
+++ b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/xml/XMLFactory.java
@@ -1,61 +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;
-
-
-/**
- * <!-- begin-user-doc -->
- * The <b>Factory</b> for the model.
- * It provides a create method for each non-abstract class of the model.
- * <!-- end-user-doc -->
- * @generated
- */
-public interface XMLFactory
-{
-
- /**
- * The singleton instance of the factory.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- XMLFactory INSTANCE = org.apache.tuscany.sdo.model.xml.impl.XMLFactoryImpl.init();
-
- /**
- * Returns a new object of class '<em>Info</em>'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return a new object of class '<em>Info</em>'.
- * @generated
- */
- XMLInfo createXMLInfo();
-
- /**
- * Registers the types supported by this Factory within the supplied scope.argument
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param scope an instance of HelperContext used to manage the scoping of types.
- * @generated
- */
- public void register(HelperContext scope);
-
-} //XMLFactory
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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;
+
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Factory</b> for the model.
+ * It provides a create method for each non-abstract class of the model.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public interface XMLFactory
+{
+
+ /**
+ * The singleton instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ XMLFactory INSTANCE = org.apache.tuscany.sdo.model.xml.impl.XMLFactoryImpl.init();
+
+ /**
+ * Returns a new object of class '<em>Info</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>Info</em>'.
+ * @generated
+ */
+ XMLInfo createXMLInfo();
+
+ /**
+ * Registers the types supported by this Factory within the supplied scope.argument
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param scope an instance of HelperContext used to manage the scoping of types.
+ * @generated
+ */
+ public void register(HelperContext scope);
+
+} //XMLFactory
diff --git a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/xml/XMLInfo.java b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/xml/XMLInfo.java
index 85cad641c9..6f438bc3e2 100644
--- a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/xml/XMLInfo.java
+++ b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/xml/XMLInfo.java
@@ -1,92 +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;
-
-/**
- * <!-- begin-user-doc -->
- * A representation of the model object '<em><b>Info</b></em>'.
- * <!-- end-user-doc -->
- *
- * <p>
- * The following features are supported:
- * <ul>
- * <li>{@link org.apache.tuscany.sdo.model.xml.XMLInfo#isXmlElement <em>Xml Element</em>}</li>
- * </ul>
- * </p>
- *
- * @extends Serializable
- * @generated
- */
-public interface XMLInfo extends Serializable
-{
- /**
- * Returns the value of the '<em><b>Xml Element</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Xml Element</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Xml Element</em>' 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 <em>Xml Element</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Xml Element</em>' 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 <em>Xml Element</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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 <em>Xml Element</em>}' attribute is set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return whether the value of the '<em>Xml Element</em>' attribute is set.
- * @see #unsetXmlElement()
- * @see #isXmlElement()
- * @see #setXmlElement(boolean)
- * @generated
- */
- boolean isSetXmlElement();
-
-} // XMLInfo
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Info</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link org.apache.tuscany.sdo.model.xml.XMLInfo#isXmlElement <em>Xml Element</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @extends Serializable
+ * @generated
+ */
+public interface XMLInfo extends Serializable
+{
+ /**
+ * Returns the value of the '<em><b>Xml Element</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Xml Element</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Xml Element</em>' 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 <em>Xml Element</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Xml Element</em>' 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 <em>Xml Element</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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 <em>Xml Element</em>}' attribute is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>Xml Element</em>' attribute is set.
+ * @see #unsetXmlElement()
+ * @see #isXmlElement()
+ * @see #setXmlElement(boolean)
+ * @generated
+ */
+ boolean isSetXmlElement();
+
+} // XMLInfo
diff --git a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/xml/impl/XMLFactoryImpl.java b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/xml/impl/XMLFactoryImpl.java
index 293a7b0398..f07d8b7f3c 100644
--- a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/xml/impl/XMLFactoryImpl.java
+++ b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/xml/impl/XMLFactoryImpl.java
@@ -1,341 +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.*;
-
-/**
- * <!-- begin-user-doc -->
- * 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 <temp-dir> -javaPackage org.apache.tuscany.sdo.model.xml <sdo-api-dir>/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.
- * <!-- end-user-doc -->
- * @generated
- */
-public class XMLFactoryImpl extends FactoryBase implements XMLFactory
-{
-
- /**
- * The package namespace URI.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final String NAMESPACE_URI = "commonj.sdo/xml";
-
- /**
- * The package namespace name.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final String NAMESPACE_PREFIX = "sdoXML";
-
- /**
- * The version of the generator pattern used to generate this class.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final String PATTERN_VERSION = "1.2";
-
- public static final int XML_INFO = 1;
-
- /**
- * Creates an instance of the factory.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public DataObject create(int typeNumber)
- {
- switch (typeNumber)
- {
- case XML_INFO: return (DataObject)createXMLInfo();
- default:
- return super.create(typeNumber);
- }
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.*;
+
+/**
+ * <!-- begin-user-doc -->
+ * 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 <temp-dir> -javaPackage org.apache.tuscany.sdo.model.xml <sdo-api-dir>/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.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class XMLFactoryImpl extends FactoryBase implements XMLFactory
+{
+
+ /**
+ * The package namespace URI.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String NAMESPACE_URI = "commonj.sdo/xml";
+
+ /**
+ * The package namespace name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String NAMESPACE_PREFIX = "sdoXML";
+
+ /**
+ * The version of the generator pattern used to generate this class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String PATTERN_VERSION = "1.2";
+
+ public static final int XML_INFO = 1;
+
+ /**
+ * Creates an instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public DataObject create(int typeNumber)
+ {
+ switch (typeNumber)
+ {
+ case XML_INFO: return (DataObject)createXMLInfo();
+ default:
+ return super.create(typeNumber);
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/xml/impl/XMLInfoImpl.java b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/xml/impl/XMLInfoImpl.java
index a0906e32c1..83d8a6725a 100644
--- a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/xml/impl/XMLInfoImpl.java
+++ b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/model/xml/impl/XMLInfoImpl.java
@@ -1,256 +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;
-
-/**
- * <!-- begin-user-doc -->
- * An implementation of the model object '<em><b>Info</b></em>'.
- * <!-- end-user-doc -->
- * <p>
- * The following features are implemented:
- * <ul>
- * <li>{@link org.apache.tuscany.sdo.model.xml.impl.XMLInfoImpl#isXmlElement <em>Xml Element</em>}</li>
- * </ul>
- * </p>
- *
- * @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 '<em><b>Xml Element</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public final static int INTERNAL_XML_ELEMENT = 0;
-
- /**
- * The number of properties for this type.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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() <em>Xml Element</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #isXmlElement()
- * @generated
- * @ordered
- */
- protected static final boolean XML_ELEMENT_DEFAULT_ = false;
-
- /**
- * The cached value of the '{@link #isXmlElement() <em>Xml Element</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #isXmlElement()
- * @generated
- * @ordered
- */
- protected boolean xmlElement = XML_ELEMENT_DEFAULT_;
-
- /**
- * This is true if the Xml Element attribute has been set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- protected boolean xmlElement_set_ = false;
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public XMLInfoImpl()
- {
- super();
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public Type getStaticType()
- {
- return ((XMLFactoryImpl)XMLFactory.INSTANCE).getXMLInfo();
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean isXmlElement()
- {
- return xmlElement;
- }
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean isSetXmlElement()
- {
- return xmlElement_set_;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public Object get(int propertyIndex, boolean resolve)
- {
- switch (propertyIndex)
- {
- case XML_ELEMENT:
- return isXmlElement() ? Boolean.TRUE : Boolean.FALSE;
- }
- return super.get(propertyIndex, resolve);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public void set(int propertyIndex, Object newValue)
- {
- switch (propertyIndex)
- {
- case XML_ELEMENT:
- setXmlElement(((Boolean)newValue).booleanValue());
- return;
- }
- super.set(propertyIndex, newValue);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public void unset(int propertyIndex)
- {
- switch (propertyIndex)
- {
- case XML_ELEMENT:
- unsetXmlElement();
- return;
- }
- super.unset(propertyIndex);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean isSet(int propertyIndex)
- {
- switch (propertyIndex)
- {
- case XML_ELEMENT:
- return isSetXmlElement();
- }
- return super.isSet(propertyIndex);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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("<unset>");
- result.append(')');
- return result.toString();
- }
-
-} //XMLInfoImpl
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Info</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link org.apache.tuscany.sdo.model.xml.impl.XMLInfoImpl#isXmlElement <em>Xml Element</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @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 '<em><b>Xml Element</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_XML_ELEMENT = 0;
+
+ /**
+ * The number of properties for this type.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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() <em>Xml Element</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isXmlElement()
+ * @generated
+ * @ordered
+ */
+ protected static final boolean XML_ELEMENT_DEFAULT_ = false;
+
+ /**
+ * The cached value of the '{@link #isXmlElement() <em>Xml Element</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isXmlElement()
+ * @generated
+ * @ordered
+ */
+ protected boolean xmlElement = XML_ELEMENT_DEFAULT_;
+
+ /**
+ * This is true if the Xml Element attribute has been set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ protected boolean xmlElement_set_ = false;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public XMLInfoImpl()
+ {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Type getStaticType()
+ {
+ return ((XMLFactoryImpl)XMLFactory.INSTANCE).getXMLInfo();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isXmlElement()
+ {
+ return xmlElement;
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetXmlElement()
+ {
+ return xmlElement_set_;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Object get(int propertyIndex, boolean resolve)
+ {
+ switch (propertyIndex)
+ {
+ case XML_ELEMENT:
+ return isXmlElement() ? Boolean.TRUE : Boolean.FALSE;
+ }
+ return super.get(propertyIndex, resolve);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void set(int propertyIndex, Object newValue)
+ {
+ switch (propertyIndex)
+ {
+ case XML_ELEMENT:
+ setXmlElement(((Boolean)newValue).booleanValue());
+ return;
+ }
+ super.set(propertyIndex, newValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void unset(int propertyIndex)
+ {
+ switch (propertyIndex)
+ {
+ case XML_ELEMENT:
+ unsetXmlElement();
+ return;
+ }
+ super.unset(propertyIndex);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSet(int propertyIndex)
+ {
+ switch (propertyIndex)
+ {
+ case XML_ELEMENT:
+ return isSetXmlElement();
+ }
+ return super.isSet(propertyIndex);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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("<unset>");
+ result.append(')');
+ return result.toString();
+ }
+
+} //XMLInfoImpl
diff --git a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/StreamDeserializer.java b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/StreamDeserializer.java
index 5d7bee9c3f..9e1492c9fd 100644
--- a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/StreamDeserializer.java
+++ b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/StreamDeserializer.java
@@ -1,92 +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;
- }
- };
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/VirtualSequence.java b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/VirtualSequence.java
index 2f86fa9d12..a5982ceb35 100644
--- a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/VirtualSequence.java
+++ b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/VirtualSequence.java
@@ -1,780 +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();
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/ChangeSummaryStreamDeserializer.java b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/ChangeSummaryStreamDeserializer.java
index 6dc461a2fe..697de1c7ad 100644
--- a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/ChangeSummaryStreamDeserializer.java
+++ b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/ChangeSummaryStreamDeserializer.java
@@ -1,663 +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;
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/ChangeSummaryStreamSerializer.java b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/ChangeSummaryStreamSerializer.java
index bb598bea54..ef5af8ab57 100644
--- a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/ChangeSummaryStreamSerializer.java
+++ b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/ChangeSummaryStreamSerializer.java
@@ -1,690 +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();
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/RecordedEventXMLStreamReader.java b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/RecordedEventXMLStreamReader.java
index b2b3036692..a0da5d2609 100644
--- a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/RecordedEventXMLStreamReader.java
+++ b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/RecordedEventXMLStreamReader.java
@@ -1,868 +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");
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDODeserializer.java b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDODeserializer.java
index af14f13319..01c043b074 100644
--- a/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDODeserializer.java
+++ b/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/resource/SDODeserializer.java
@@ -1,340 +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();
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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/java/sdo/impl/src/main/resources/META-INF/NOTICE b/java/sdo/impl/src/main/resources/META-INF/NOTICE
index 6901a96038..9f9572a167 100644
--- a/java/sdo/impl/src/main/resources/META-INF/NOTICE
+++ b/java/sdo/impl/src/main/resources/META-INF/NOTICE
@@ -4,5 +4,4 @@ Copyright (c) 2005 - 2008 The Apache Software Foundation
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/java/sdo/impl/src/main/resources/META-INF/README.txt b/java/sdo/impl/src/main/resources/META-INF/README.txt
index b6d11e9008..c658fee5d5 100644
--- a/java/sdo/impl/src/main/resources/META-INF/README.txt
+++ b/java/sdo/impl/src/main/resources/META-INF/README.txt
@@ -1,5 +1,5 @@
-Apache Tuscany 1.1-incubating build February 2008)
-===============================================
+Apache Tuscany 1.1-incubating build April 2008
+==============================================
http://incubator.apache.org/tuscany/
diff --git a/java/sdo/impl/src/main/resources/xml/sdoInternal.xsd b/java/sdo/impl/src/main/resources/xml/sdoInternal.xsd
index c1616ad7fe..b606caf424 100644
--- a/java/sdo/impl/src/main/resources/xml/sdoInternal.xsd
+++ b/java/sdo/impl/src/main/resources/xml/sdoInternal.xsd
@@ -1,33 +1,33 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- -->
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:sdoJava="commonj.sdo/java"
- xmlns:internal="http://www.apache.org/tuscany/commonj.sdo.internal"
- targetNamespace="http://www.apache.org/tuscany/commonj.sdo.internal">
-
- <xsd:simpleType name="Base64Bytes" sdoJava:instanceClass="byte[]">
- <xsd:restriction base="xsd:base64Binary"/>
- </xsd:simpleType>
-
- <xsd:simpleType name="QName" sdoJava:instanceClass="java.lang.String">
- <xsd:restriction base="xsd:QName"/>
- </xsd:simpleType>
-
-</xsd:schema>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:sdoJava="commonj.sdo/java"
+ xmlns:internal="http://www.apache.org/tuscany/commonj.sdo.internal"
+ targetNamespace="http://www.apache.org/tuscany/commonj.sdo.internal">
+
+ <xsd:simpleType name="Base64Bytes" sdoJava:instanceClass="byte[]">
+ <xsd:restriction base="xsd:base64Binary"/>
+ </xsd:simpleType>
+
+ <xsd:simpleType name="QName" sdoJava:instanceClass="java.lang.String">
+ <xsd:restriction base="xsd:QName"/>
+ </xsd:simpleType>
+
+</xsd:schema>
diff --git a/java/sdo/impl/src/main/resources/xml/sdoModelChangeSummary.xsd b/java/sdo/impl/src/main/resources/xml/sdoModelChangeSummary.xsd
index 645b7b700a..6b596c5b36 100644
--- a/java/sdo/impl/src/main/resources/xml/sdoModelChangeSummary.xsd
+++ b/java/sdo/impl/src/main/resources/xml/sdoModelChangeSummary.xsd
@@ -1,28 +1,28 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- -->
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sdo="commonj.sdo" xmlns:sdoJava="commonj.sdo/java" targetNamespace="commonj.sdo">
-
- <!-- Dummy XSD definition of special SDO ChangeSummaryType -->
- <xsd:simpleType name="ChangeSummaryType" sdoJava:instanceClass="commonj.sdo.ChangeSummary">
- <xsd:restriction base="xsd:string"/>
- </xsd:simpleType>
-
-
-</xsd:schema>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sdo="commonj.sdo" xmlns:sdoJava="commonj.sdo/java" targetNamespace="commonj.sdo">
+
+ <!-- Dummy XSD definition of special SDO ChangeSummaryType -->
+ <xsd:simpleType name="ChangeSummaryType" sdoJava:instanceClass="commonj.sdo.ChangeSummary">
+ <xsd:restriction base="xsd:string"/>
+ </xsd:simpleType>
+
+
+</xsd:schema>
diff --git a/java/sdo/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionFactory.java b/java/sdo/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionFactory.java
index 0ba0d7037e..938c4b25d2 100644
--- a/java/sdo/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionFactory.java
+++ b/java/sdo/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionFactory.java
@@ -1,70 +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;
-
-
-/**
- * <!-- begin-user-doc -->
- * The <b>Factory</b> for the model.
- * It provides a create method for each non-abstract class of the model.
- * <!-- end-user-doc -->
- * @generated
- */
-public interface ExpectedExceptionFactory
-{
-
- /**
- * The singleton instance of the factory.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- ExpectedExceptionFactory INSTANCE = com.example.ExpectedException.impl.ExpectedExceptionFactoryImpl.init();
-
- /**
- * Returns a new object of class '<em>Type</em>'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return a new object of class '<em>Type</em>'.
- * @generated
- */
- ExpectedExceptionType createExpectedExceptionType();
-
- /**
- * Returns a new object of class '<em>Sequence Read Only Type</em>'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return a new object of class '<em>Sequence Read Only Type</em>'.
- * @generated
- */
- SequenceReadOnlyType createSequenceReadOnlyType();
-
- /**
- * Registers the types supported by this Factory within the supplied scope.argument
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param scope an instance of HelperContext used to manage the scoping of types.
- * @generated
- */
- public void register(HelperContext scope);
-
-} //ExpectedExceptionFactory
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES 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;
+
+
+/**
+ * <!-- begin-user-doc -->
+ * The <b>Factory</b> for the model.
+ * It provides a create method for each non-abstract class of the model.
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public interface ExpectedExceptionFactory
+{
+
+ /**
+ * The singleton instance of the factory.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ ExpectedExceptionFactory INSTANCE = com.example.ExpectedException.impl.ExpectedExceptionFactoryImpl.init();
+
+ /**
+ * Returns a new object of class '<em>Type</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>Type</em>'.
+ * @generated
+ */
+ ExpectedExceptionType createExpectedExceptionType();
+
+ /**
+ * Returns a new object of class '<em>Sequence Read Only Type</em>'.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return a new object of class '<em>Sequence Read Only Type</em>'.
+ * @generated
+ */
+ SequenceReadOnlyType createSequenceReadOnlyType();
+
+ /**
+ * Registers the types supported by this Factory within the supplied scope.argument
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param scope an instance of HelperContext used to manage the scoping of types.
+ * @generated
+ */
+ public void register(HelperContext scope);
+
+} //ExpectedExceptionFactory
diff --git a/java/sdo/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionType.java b/java/sdo/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionType.java
index 2f3e1ba63a..80159443dc 100644
--- a/java/sdo/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionType.java
+++ b/java/sdo/impl/src/test/java/com/example/ExpectedException/ExpectedExceptionType.java
@@ -1,786 +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;
-
-/**
- * <!-- begin-user-doc -->
- * A representation of the model object '<em><b>Type</b></em>'.
- * <!-- end-user-doc -->
- *
- * <p>
- * The following features are supported:
- * <ul>
- * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getStringVal <em>String Val</em>}</li>
- * <li>{@link com.example.ExpectedException.ExpectedExceptionType#isBooleanVal <em>Boolean Val</em>}</li>
- * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getByteVal <em>Byte Val</em>}</li>
- * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getDecimalVal <em>Decimal Val</em>}</li>
- * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getIntVal <em>Int Val</em>}</li>
- * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getFloatVal <em>Float Val</em>}</li>
- * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getDoubleVal <em>Double Val</em>}</li>
- * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getDateVal <em>Date Val</em>}</li>
- * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getShortVal <em>Short Val</em>}</li>
- * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getLongVal <em>Long Val</em>}</li>
- * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getListVal <em>List Val</em>}</li>
- * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getBytesVal <em>Bytes Val</em>}</li>
- * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getIntegerVal <em>Integer Val</em>}</li>
- * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getCharVal <em>Char Val</em>}</li>
- * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getReadOnlyVal <em>Read Only Val</em>}</li>
- * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getReadOnlyListVal <em>Read Only List Val</em>}</li>
- * </ul>
- * </p>
- *
- * @extends Serializable
- * @generated
- */
-public interface ExpectedExceptionType extends Serializable
-{
- /**
- * Returns the value of the '<em><b>String Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>String Val</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>String Val</em>' attribute.
- * @see #isSetStringVal()
- * @see #unsetStringVal()
- * @see #setStringVal(String)
- * @generated
- */
- String getStringVal();
-
- /**
- * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getStringVal <em>String Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>String Val</em>' attribute.
- * @see #isSetStringVal()
- * @see #unsetStringVal()
- * @see #getStringVal()
- * @generated
- */
- void setStringVal(String value);
-
- /**
- * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getStringVal <em>String Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #isSetStringVal()
- * @see #getStringVal()
- * @see #setStringVal(String)
- * @generated
- */
- void unsetStringVal();
-
- /**
- * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getStringVal <em>String Val</em>}' attribute is set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return whether the value of the '<em>String Val</em>' attribute is set.
- * @see #unsetStringVal()
- * @see #getStringVal()
- * @see #setStringVal(String)
- * @generated
- */
- boolean isSetStringVal();
-
- /**
- * Returns the value of the '<em><b>Boolean Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Boolean Val</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Boolean Val</em>' attribute.
- * @see #isSetBooleanVal()
- * @see #unsetBooleanVal()
- * @see #setBooleanVal(boolean)
- * @generated
- */
- boolean isBooleanVal();
-
- /**
- * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#isBooleanVal <em>Boolean Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Boolean Val</em>' attribute.
- * @see #isSetBooleanVal()
- * @see #unsetBooleanVal()
- * @see #isBooleanVal()
- * @generated
- */
- void setBooleanVal(boolean value);
-
- /**
- * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#isBooleanVal <em>Boolean Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #isSetBooleanVal()
- * @see #isBooleanVal()
- * @see #setBooleanVal(boolean)
- * @generated
- */
- void unsetBooleanVal();
-
- /**
- * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#isBooleanVal <em>Boolean Val</em>}' attribute is set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return whether the value of the '<em>Boolean Val</em>' attribute is set.
- * @see #unsetBooleanVal()
- * @see #isBooleanVal()
- * @see #setBooleanVal(boolean)
- * @generated
- */
- boolean isSetBooleanVal();
-
- /**
- * Returns the value of the '<em><b>Byte Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Byte Val</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Byte Val</em>' attribute.
- * @see #isSetByteVal()
- * @see #unsetByteVal()
- * @see #setByteVal(byte)
- * @generated
- */
- byte getByteVal();
-
- /**
- * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getByteVal <em>Byte Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Byte Val</em>' attribute.
- * @see #isSetByteVal()
- * @see #unsetByteVal()
- * @see #getByteVal()
- * @generated
- */
- void setByteVal(byte value);
-
- /**
- * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getByteVal <em>Byte Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #isSetByteVal()
- * @see #getByteVal()
- * @see #setByteVal(byte)
- * @generated
- */
- void unsetByteVal();
-
- /**
- * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getByteVal <em>Byte Val</em>}' attribute is set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return whether the value of the '<em>Byte Val</em>' attribute is set.
- * @see #unsetByteVal()
- * @see #getByteVal()
- * @see #setByteVal(byte)
- * @generated
- */
- boolean isSetByteVal();
-
- /**
- * Returns the value of the '<em><b>Decimal Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Decimal Val</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Decimal Val</em>' attribute.
- * @see #isSetDecimalVal()
- * @see #unsetDecimalVal()
- * @see #setDecimalVal(BigDecimal)
- * @generated
- */
- BigDecimal getDecimalVal();
-
- /**
- * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDecimalVal <em>Decimal Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Decimal Val</em>' attribute.
- * @see #isSetDecimalVal()
- * @see #unsetDecimalVal()
- * @see #getDecimalVal()
- * @generated
- */
- void setDecimalVal(BigDecimal value);
-
- /**
- * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDecimalVal <em>Decimal Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #isSetDecimalVal()
- * @see #getDecimalVal()
- * @see #setDecimalVal(BigDecimal)
- * @generated
- */
- void unsetDecimalVal();
-
- /**
- * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDecimalVal <em>Decimal Val</em>}' attribute is set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return whether the value of the '<em>Decimal Val</em>' attribute is set.
- * @see #unsetDecimalVal()
- * @see #getDecimalVal()
- * @see #setDecimalVal(BigDecimal)
- * @generated
- */
- boolean isSetDecimalVal();
-
- /**
- * Returns the value of the '<em><b>Int Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Int Val</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Int Val</em>' attribute.
- * @see #isSetIntVal()
- * @see #unsetIntVal()
- * @see #setIntVal(int)
- * @generated
- */
- int getIntVal();
-
- /**
- * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntVal <em>Int Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Int Val</em>' attribute.
- * @see #isSetIntVal()
- * @see #unsetIntVal()
- * @see #getIntVal()
- * @generated
- */
- void setIntVal(int value);
-
- /**
- * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntVal <em>Int Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #isSetIntVal()
- * @see #getIntVal()
- * @see #setIntVal(int)
- * @generated
- */
- void unsetIntVal();
-
- /**
- * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntVal <em>Int Val</em>}' attribute is set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return whether the value of the '<em>Int Val</em>' attribute is set.
- * @see #unsetIntVal()
- * @see #getIntVal()
- * @see #setIntVal(int)
- * @generated
- */
- boolean isSetIntVal();
-
- /**
- * Returns the value of the '<em><b>Float Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Float Val</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Float Val</em>' attribute.
- * @see #isSetFloatVal()
- * @see #unsetFloatVal()
- * @see #setFloatVal(float)
- * @generated
- */
- float getFloatVal();
-
- /**
- * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getFloatVal <em>Float Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Float Val</em>' attribute.
- * @see #isSetFloatVal()
- * @see #unsetFloatVal()
- * @see #getFloatVal()
- * @generated
- */
- void setFloatVal(float value);
-
- /**
- * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getFloatVal <em>Float Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #isSetFloatVal()
- * @see #getFloatVal()
- * @see #setFloatVal(float)
- * @generated
- */
- void unsetFloatVal();
-
- /**
- * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getFloatVal <em>Float Val</em>}' attribute is set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return whether the value of the '<em>Float Val</em>' attribute is set.
- * @see #unsetFloatVal()
- * @see #getFloatVal()
- * @see #setFloatVal(float)
- * @generated
- */
- boolean isSetFloatVal();
-
- /**
- * Returns the value of the '<em><b>Double Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Double Val</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Double Val</em>' attribute.
- * @see #isSetDoubleVal()
- * @see #unsetDoubleVal()
- * @see #setDoubleVal(double)
- * @generated
- */
- double getDoubleVal();
-
- /**
- * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDoubleVal <em>Double Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Double Val</em>' attribute.
- * @see #isSetDoubleVal()
- * @see #unsetDoubleVal()
- * @see #getDoubleVal()
- * @generated
- */
- void setDoubleVal(double value);
-
- /**
- * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDoubleVal <em>Double Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #isSetDoubleVal()
- * @see #getDoubleVal()
- * @see #setDoubleVal(double)
- * @generated
- */
- void unsetDoubleVal();
-
- /**
- * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDoubleVal <em>Double Val</em>}' attribute is set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return whether the value of the '<em>Double Val</em>' attribute is set.
- * @see #unsetDoubleVal()
- * @see #getDoubleVal()
- * @see #setDoubleVal(double)
- * @generated
- */
- boolean isSetDoubleVal();
-
- /**
- * Returns the value of the '<em><b>Date Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Date Val</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Date Val</em>' attribute.
- * @see #isSetDateVal()
- * @see #unsetDateVal()
- * @see #setDateVal(String)
- * @generated
- */
- String getDateVal();
-
- /**
- * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDateVal <em>Date Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Date Val</em>' attribute.
- * @see #isSetDateVal()
- * @see #unsetDateVal()
- * @see #getDateVal()
- * @generated
- */
- void setDateVal(String value);
-
- /**
- * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDateVal <em>Date Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #isSetDateVal()
- * @see #getDateVal()
- * @see #setDateVal(String)
- * @generated
- */
- void unsetDateVal();
-
- /**
- * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDateVal <em>Date Val</em>}' attribute is set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return whether the value of the '<em>Date Val</em>' attribute is set.
- * @see #unsetDateVal()
- * @see #getDateVal()
- * @see #setDateVal(String)
- * @generated
- */
- boolean isSetDateVal();
-
- /**
- * Returns the value of the '<em><b>Short Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Short Val</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Short Val</em>' attribute.
- * @see #isSetShortVal()
- * @see #unsetShortVal()
- * @see #setShortVal(short)
- * @generated
- */
- short getShortVal();
-
- /**
- * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getShortVal <em>Short Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Short Val</em>' attribute.
- * @see #isSetShortVal()
- * @see #unsetShortVal()
- * @see #getShortVal()
- * @generated
- */
- void setShortVal(short value);
-
- /**
- * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getShortVal <em>Short Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #isSetShortVal()
- * @see #getShortVal()
- * @see #setShortVal(short)
- * @generated
- */
- void unsetShortVal();
-
- /**
- * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getShortVal <em>Short Val</em>}' attribute is set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return whether the value of the '<em>Short Val</em>' attribute is set.
- * @see #unsetShortVal()
- * @see #getShortVal()
- * @see #setShortVal(short)
- * @generated
- */
- boolean isSetShortVal();
-
- /**
- * Returns the value of the '<em><b>Long Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Long Val</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Long Val</em>' attribute.
- * @see #isSetLongVal()
- * @see #unsetLongVal()
- * @see #setLongVal(long)
- * @generated
- */
- long getLongVal();
-
- /**
- * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getLongVal <em>Long Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Long Val</em>' attribute.
- * @see #isSetLongVal()
- * @see #unsetLongVal()
- * @see #getLongVal()
- * @generated
- */
- void setLongVal(long value);
-
- /**
- * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getLongVal <em>Long Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #isSetLongVal()
- * @see #getLongVal()
- * @see #setLongVal(long)
- * @generated
- */
- void unsetLongVal();
-
- /**
- * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getLongVal <em>Long Val</em>}' attribute is set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return whether the value of the '<em>Long Val</em>' attribute is set.
- * @see #unsetLongVal()
- * @see #getLongVal()
- * @see #setLongVal(long)
- * @generated
- */
- boolean isSetLongVal();
-
- /**
- * Returns the value of the '<em><b>List Val</b></em>' attribute list.
- * The list contents are of type {@link java.lang.String}.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>List Val</em>' attribute list isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>List Val</em>' attribute list.
- * @generated
- */
- List getListVal();
-
- /**
- * Returns the value of the '<em><b>Bytes Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Bytes Val</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Bytes Val</em>' attribute.
- * @see #isSetBytesVal()
- * @see #unsetBytesVal()
- * @see #setBytesVal(byte[])
- * @generated
- */
- byte[] getBytesVal();
-
- /**
- * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getBytesVal <em>Bytes Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Bytes Val</em>' attribute.
- * @see #isSetBytesVal()
- * @see #unsetBytesVal()
- * @see #getBytesVal()
- * @generated
- */
- void setBytesVal(byte[] value);
-
- /**
- * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getBytesVal <em>Bytes Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #isSetBytesVal()
- * @see #getBytesVal()
- * @see #setBytesVal(byte[])
- * @generated
- */
- void unsetBytesVal();
-
- /**
- * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getBytesVal <em>Bytes Val</em>}' attribute is set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return whether the value of the '<em>Bytes Val</em>' attribute is set.
- * @see #unsetBytesVal()
- * @see #getBytesVal()
- * @see #setBytesVal(byte[])
- * @generated
- */
- boolean isSetBytesVal();
-
- /**
- * Returns the value of the '<em><b>Integer Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Integer Val</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Integer Val</em>' attribute.
- * @see #isSetIntegerVal()
- * @see #unsetIntegerVal()
- * @see #setIntegerVal(BigInteger)
- * @generated
- */
- BigInteger getIntegerVal();
-
- /**
- * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntegerVal <em>Integer Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Integer Val</em>' attribute.
- * @see #isSetIntegerVal()
- * @see #unsetIntegerVal()
- * @see #getIntegerVal()
- * @generated
- */
- void setIntegerVal(BigInteger value);
-
- /**
- * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntegerVal <em>Integer Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #isSetIntegerVal()
- * @see #getIntegerVal()
- * @see #setIntegerVal(BigInteger)
- * @generated
- */
- void unsetIntegerVal();
-
- /**
- * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntegerVal <em>Integer Val</em>}' attribute is set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return whether the value of the '<em>Integer Val</em>' attribute is set.
- * @see #unsetIntegerVal()
- * @see #getIntegerVal()
- * @see #setIntegerVal(BigInteger)
- * @generated
- */
- boolean isSetIntegerVal();
-
- /**
- * Returns the value of the '<em><b>Char Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Char Val</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Char Val</em>' attribute.
- * @see #isSetCharVal()
- * @see #unsetCharVal()
- * @see #setCharVal(String)
- * @generated
- */
- String getCharVal();
-
- /**
- * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getCharVal <em>Char Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Char Val</em>' attribute.
- * @see #isSetCharVal()
- * @see #unsetCharVal()
- * @see #getCharVal()
- * @generated
- */
- void setCharVal(String value);
-
- /**
- * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getCharVal <em>Char Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #isSetCharVal()
- * @see #getCharVal()
- * @see #setCharVal(String)
- * @generated
- */
- void unsetCharVal();
-
- /**
- * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getCharVal <em>Char Val</em>}' attribute is set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return whether the value of the '<em>Char Val</em>' attribute is set.
- * @see #unsetCharVal()
- * @see #getCharVal()
- * @see #setCharVal(String)
- * @generated
- */
- boolean isSetCharVal();
-
- /**
- * Returns the value of the '<em><b>Read Only Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Read Only Val</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Read Only Val</em>' attribute.
- * @see #isSetReadOnlyVal()
- * @generated
- */
- String getReadOnlyVal();
-
- /**
- * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getReadOnlyVal <em>Read Only Val</em>}' attribute is set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return whether the value of the '<em>Read Only Val</em>' attribute is set.
- * @see #getReadOnlyVal()
- * @generated
- */
- boolean isSetReadOnlyVal();
-
- /**
- * Returns the value of the '<em><b>Read Only List Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Read Only List Val</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Read Only List Val</em>' attribute.
- * @see #isSetReadOnlyListVal()
- * @generated
- */
- String getReadOnlyListVal();
-
- /**
- * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getReadOnlyListVal <em>Read Only List Val</em>}' attribute is set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return whether the value of the '<em>Read Only List Val</em>' attribute is set.
- * @see #getReadOnlyListVal()
- * @generated
- */
- boolean isSetReadOnlyListVal();
-
-} // ExpectedExceptionType
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES 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;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Type</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getStringVal <em>String Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.ExpectedExceptionType#isBooleanVal <em>Boolean Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getByteVal <em>Byte Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getDecimalVal <em>Decimal Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getIntVal <em>Int Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getFloatVal <em>Float Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getDoubleVal <em>Double Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getDateVal <em>Date Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getShortVal <em>Short Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getLongVal <em>Long Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getListVal <em>List Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getBytesVal <em>Bytes Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getIntegerVal <em>Integer Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getCharVal <em>Char Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getReadOnlyVal <em>Read Only Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.ExpectedExceptionType#getReadOnlyListVal <em>Read Only List Val</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @extends Serializable
+ * @generated
+ */
+public interface ExpectedExceptionType extends Serializable
+{
+ /**
+ * Returns the value of the '<em><b>String Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>String Val</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>String Val</em>' attribute.
+ * @see #isSetStringVal()
+ * @see #unsetStringVal()
+ * @see #setStringVal(String)
+ * @generated
+ */
+ String getStringVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getStringVal <em>String Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>String Val</em>' attribute.
+ * @see #isSetStringVal()
+ * @see #unsetStringVal()
+ * @see #getStringVal()
+ * @generated
+ */
+ void setStringVal(String value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getStringVal <em>String Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isSetStringVal()
+ * @see #getStringVal()
+ * @see #setStringVal(String)
+ * @generated
+ */
+ void unsetStringVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getStringVal <em>String Val</em>}' attribute is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>String Val</em>' attribute is set.
+ * @see #unsetStringVal()
+ * @see #getStringVal()
+ * @see #setStringVal(String)
+ * @generated
+ */
+ boolean isSetStringVal();
+
+ /**
+ * Returns the value of the '<em><b>Boolean Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Boolean Val</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Boolean Val</em>' attribute.
+ * @see #isSetBooleanVal()
+ * @see #unsetBooleanVal()
+ * @see #setBooleanVal(boolean)
+ * @generated
+ */
+ boolean isBooleanVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#isBooleanVal <em>Boolean Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Boolean Val</em>' attribute.
+ * @see #isSetBooleanVal()
+ * @see #unsetBooleanVal()
+ * @see #isBooleanVal()
+ * @generated
+ */
+ void setBooleanVal(boolean value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#isBooleanVal <em>Boolean Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isSetBooleanVal()
+ * @see #isBooleanVal()
+ * @see #setBooleanVal(boolean)
+ * @generated
+ */
+ void unsetBooleanVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#isBooleanVal <em>Boolean Val</em>}' attribute is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>Boolean Val</em>' attribute is set.
+ * @see #unsetBooleanVal()
+ * @see #isBooleanVal()
+ * @see #setBooleanVal(boolean)
+ * @generated
+ */
+ boolean isSetBooleanVal();
+
+ /**
+ * Returns the value of the '<em><b>Byte Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Byte Val</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Byte Val</em>' attribute.
+ * @see #isSetByteVal()
+ * @see #unsetByteVal()
+ * @see #setByteVal(byte)
+ * @generated
+ */
+ byte getByteVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getByteVal <em>Byte Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Byte Val</em>' attribute.
+ * @see #isSetByteVal()
+ * @see #unsetByteVal()
+ * @see #getByteVal()
+ * @generated
+ */
+ void setByteVal(byte value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getByteVal <em>Byte Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isSetByteVal()
+ * @see #getByteVal()
+ * @see #setByteVal(byte)
+ * @generated
+ */
+ void unsetByteVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getByteVal <em>Byte Val</em>}' attribute is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>Byte Val</em>' attribute is set.
+ * @see #unsetByteVal()
+ * @see #getByteVal()
+ * @see #setByteVal(byte)
+ * @generated
+ */
+ boolean isSetByteVal();
+
+ /**
+ * Returns the value of the '<em><b>Decimal Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Decimal Val</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Decimal Val</em>' attribute.
+ * @see #isSetDecimalVal()
+ * @see #unsetDecimalVal()
+ * @see #setDecimalVal(BigDecimal)
+ * @generated
+ */
+ BigDecimal getDecimalVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDecimalVal <em>Decimal Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Decimal Val</em>' attribute.
+ * @see #isSetDecimalVal()
+ * @see #unsetDecimalVal()
+ * @see #getDecimalVal()
+ * @generated
+ */
+ void setDecimalVal(BigDecimal value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDecimalVal <em>Decimal Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isSetDecimalVal()
+ * @see #getDecimalVal()
+ * @see #setDecimalVal(BigDecimal)
+ * @generated
+ */
+ void unsetDecimalVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDecimalVal <em>Decimal Val</em>}' attribute is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>Decimal Val</em>' attribute is set.
+ * @see #unsetDecimalVal()
+ * @see #getDecimalVal()
+ * @see #setDecimalVal(BigDecimal)
+ * @generated
+ */
+ boolean isSetDecimalVal();
+
+ /**
+ * Returns the value of the '<em><b>Int Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Int Val</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Int Val</em>' attribute.
+ * @see #isSetIntVal()
+ * @see #unsetIntVal()
+ * @see #setIntVal(int)
+ * @generated
+ */
+ int getIntVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntVal <em>Int Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Int Val</em>' attribute.
+ * @see #isSetIntVal()
+ * @see #unsetIntVal()
+ * @see #getIntVal()
+ * @generated
+ */
+ void setIntVal(int value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntVal <em>Int Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isSetIntVal()
+ * @see #getIntVal()
+ * @see #setIntVal(int)
+ * @generated
+ */
+ void unsetIntVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntVal <em>Int Val</em>}' attribute is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>Int Val</em>' attribute is set.
+ * @see #unsetIntVal()
+ * @see #getIntVal()
+ * @see #setIntVal(int)
+ * @generated
+ */
+ boolean isSetIntVal();
+
+ /**
+ * Returns the value of the '<em><b>Float Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Float Val</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Float Val</em>' attribute.
+ * @see #isSetFloatVal()
+ * @see #unsetFloatVal()
+ * @see #setFloatVal(float)
+ * @generated
+ */
+ float getFloatVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getFloatVal <em>Float Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Float Val</em>' attribute.
+ * @see #isSetFloatVal()
+ * @see #unsetFloatVal()
+ * @see #getFloatVal()
+ * @generated
+ */
+ void setFloatVal(float value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getFloatVal <em>Float Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isSetFloatVal()
+ * @see #getFloatVal()
+ * @see #setFloatVal(float)
+ * @generated
+ */
+ void unsetFloatVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getFloatVal <em>Float Val</em>}' attribute is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>Float Val</em>' attribute is set.
+ * @see #unsetFloatVal()
+ * @see #getFloatVal()
+ * @see #setFloatVal(float)
+ * @generated
+ */
+ boolean isSetFloatVal();
+
+ /**
+ * Returns the value of the '<em><b>Double Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Double Val</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Double Val</em>' attribute.
+ * @see #isSetDoubleVal()
+ * @see #unsetDoubleVal()
+ * @see #setDoubleVal(double)
+ * @generated
+ */
+ double getDoubleVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDoubleVal <em>Double Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Double Val</em>' attribute.
+ * @see #isSetDoubleVal()
+ * @see #unsetDoubleVal()
+ * @see #getDoubleVal()
+ * @generated
+ */
+ void setDoubleVal(double value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDoubleVal <em>Double Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isSetDoubleVal()
+ * @see #getDoubleVal()
+ * @see #setDoubleVal(double)
+ * @generated
+ */
+ void unsetDoubleVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDoubleVal <em>Double Val</em>}' attribute is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>Double Val</em>' attribute is set.
+ * @see #unsetDoubleVal()
+ * @see #getDoubleVal()
+ * @see #setDoubleVal(double)
+ * @generated
+ */
+ boolean isSetDoubleVal();
+
+ /**
+ * Returns the value of the '<em><b>Date Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Date Val</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Date Val</em>' attribute.
+ * @see #isSetDateVal()
+ * @see #unsetDateVal()
+ * @see #setDateVal(String)
+ * @generated
+ */
+ String getDateVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDateVal <em>Date Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Date Val</em>' attribute.
+ * @see #isSetDateVal()
+ * @see #unsetDateVal()
+ * @see #getDateVal()
+ * @generated
+ */
+ void setDateVal(String value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDateVal <em>Date Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isSetDateVal()
+ * @see #getDateVal()
+ * @see #setDateVal(String)
+ * @generated
+ */
+ void unsetDateVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getDateVal <em>Date Val</em>}' attribute is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>Date Val</em>' attribute is set.
+ * @see #unsetDateVal()
+ * @see #getDateVal()
+ * @see #setDateVal(String)
+ * @generated
+ */
+ boolean isSetDateVal();
+
+ /**
+ * Returns the value of the '<em><b>Short Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Short Val</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Short Val</em>' attribute.
+ * @see #isSetShortVal()
+ * @see #unsetShortVal()
+ * @see #setShortVal(short)
+ * @generated
+ */
+ short getShortVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getShortVal <em>Short Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Short Val</em>' attribute.
+ * @see #isSetShortVal()
+ * @see #unsetShortVal()
+ * @see #getShortVal()
+ * @generated
+ */
+ void setShortVal(short value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getShortVal <em>Short Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isSetShortVal()
+ * @see #getShortVal()
+ * @see #setShortVal(short)
+ * @generated
+ */
+ void unsetShortVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getShortVal <em>Short Val</em>}' attribute is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>Short Val</em>' attribute is set.
+ * @see #unsetShortVal()
+ * @see #getShortVal()
+ * @see #setShortVal(short)
+ * @generated
+ */
+ boolean isSetShortVal();
+
+ /**
+ * Returns the value of the '<em><b>Long Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Long Val</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Long Val</em>' attribute.
+ * @see #isSetLongVal()
+ * @see #unsetLongVal()
+ * @see #setLongVal(long)
+ * @generated
+ */
+ long getLongVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getLongVal <em>Long Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Long Val</em>' attribute.
+ * @see #isSetLongVal()
+ * @see #unsetLongVal()
+ * @see #getLongVal()
+ * @generated
+ */
+ void setLongVal(long value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getLongVal <em>Long Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isSetLongVal()
+ * @see #getLongVal()
+ * @see #setLongVal(long)
+ * @generated
+ */
+ void unsetLongVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getLongVal <em>Long Val</em>}' attribute is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>Long Val</em>' attribute is set.
+ * @see #unsetLongVal()
+ * @see #getLongVal()
+ * @see #setLongVal(long)
+ * @generated
+ */
+ boolean isSetLongVal();
+
+ /**
+ * Returns the value of the '<em><b>List Val</b></em>' attribute list.
+ * The list contents are of type {@link java.lang.String}.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>List Val</em>' attribute list isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>List Val</em>' attribute list.
+ * @generated
+ */
+ List getListVal();
+
+ /**
+ * Returns the value of the '<em><b>Bytes Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Bytes Val</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Bytes Val</em>' attribute.
+ * @see #isSetBytesVal()
+ * @see #unsetBytesVal()
+ * @see #setBytesVal(byte[])
+ * @generated
+ */
+ byte[] getBytesVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getBytesVal <em>Bytes Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Bytes Val</em>' attribute.
+ * @see #isSetBytesVal()
+ * @see #unsetBytesVal()
+ * @see #getBytesVal()
+ * @generated
+ */
+ void setBytesVal(byte[] value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getBytesVal <em>Bytes Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isSetBytesVal()
+ * @see #getBytesVal()
+ * @see #setBytesVal(byte[])
+ * @generated
+ */
+ void unsetBytesVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getBytesVal <em>Bytes Val</em>}' attribute is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>Bytes Val</em>' attribute is set.
+ * @see #unsetBytesVal()
+ * @see #getBytesVal()
+ * @see #setBytesVal(byte[])
+ * @generated
+ */
+ boolean isSetBytesVal();
+
+ /**
+ * Returns the value of the '<em><b>Integer Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Integer Val</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Integer Val</em>' attribute.
+ * @see #isSetIntegerVal()
+ * @see #unsetIntegerVal()
+ * @see #setIntegerVal(BigInteger)
+ * @generated
+ */
+ BigInteger getIntegerVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntegerVal <em>Integer Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Integer Val</em>' attribute.
+ * @see #isSetIntegerVal()
+ * @see #unsetIntegerVal()
+ * @see #getIntegerVal()
+ * @generated
+ */
+ void setIntegerVal(BigInteger value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntegerVal <em>Integer Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isSetIntegerVal()
+ * @see #getIntegerVal()
+ * @see #setIntegerVal(BigInteger)
+ * @generated
+ */
+ void unsetIntegerVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getIntegerVal <em>Integer Val</em>}' attribute is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>Integer Val</em>' attribute is set.
+ * @see #unsetIntegerVal()
+ * @see #getIntegerVal()
+ * @see #setIntegerVal(BigInteger)
+ * @generated
+ */
+ boolean isSetIntegerVal();
+
+ /**
+ * Returns the value of the '<em><b>Char Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Char Val</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Char Val</em>' attribute.
+ * @see #isSetCharVal()
+ * @see #unsetCharVal()
+ * @see #setCharVal(String)
+ * @generated
+ */
+ String getCharVal();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getCharVal <em>Char Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Char Val</em>' attribute.
+ * @see #isSetCharVal()
+ * @see #unsetCharVal()
+ * @see #getCharVal()
+ * @generated
+ */
+ void setCharVal(String value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getCharVal <em>Char Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isSetCharVal()
+ * @see #getCharVal()
+ * @see #setCharVal(String)
+ * @generated
+ */
+ void unsetCharVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getCharVal <em>Char Val</em>}' attribute is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>Char Val</em>' attribute is set.
+ * @see #unsetCharVal()
+ * @see #getCharVal()
+ * @see #setCharVal(String)
+ * @generated
+ */
+ boolean isSetCharVal();
+
+ /**
+ * Returns the value of the '<em><b>Read Only Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Read Only Val</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Read Only Val</em>' attribute.
+ * @see #isSetReadOnlyVal()
+ * @generated
+ */
+ String getReadOnlyVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getReadOnlyVal <em>Read Only Val</em>}' attribute is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>Read Only Val</em>' attribute is set.
+ * @see #getReadOnlyVal()
+ * @generated
+ */
+ boolean isSetReadOnlyVal();
+
+ /**
+ * Returns the value of the '<em><b>Read Only List Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Read Only List Val</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Read Only List Val</em>' attribute.
+ * @see #isSetReadOnlyListVal()
+ * @generated
+ */
+ String getReadOnlyListVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.ExpectedExceptionType#getReadOnlyListVal <em>Read Only List Val</em>}' attribute is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>Read Only List Val</em>' attribute is set.
+ * @see #getReadOnlyListVal()
+ * @generated
+ */
+ boolean isSetReadOnlyListVal();
+
+} // ExpectedExceptionType
diff --git a/java/sdo/impl/src/test/java/com/example/ExpectedException/SequenceReadOnlyType.java b/java/sdo/impl/src/test/java/com/example/ExpectedException/SequenceReadOnlyType.java
index 2a2ae0db02..a87511df28 100644
--- a/java/sdo/impl/src/test/java/com/example/ExpectedException/SequenceReadOnlyType.java
+++ b/java/sdo/impl/src/test/java/com/example/ExpectedException/SequenceReadOnlyType.java
@@ -1,158 +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;
-
-/**
- * <!-- begin-user-doc -->
- * A representation of the model object '<em><b>Sequence Read Only Type</b></em>'.
- * <!-- end-user-doc -->
- *
- * <p>
- * The following features are supported:
- * <ul>
- * <li>{@link com.example.ExpectedException.SequenceReadOnlyType#getMixed <em>Mixed</em>}</li>
- * <li>{@link com.example.ExpectedException.SequenceReadOnlyType#getReadOnlyVal <em>Read Only Val</em>}</li>
- * <li>{@link com.example.ExpectedException.SequenceReadOnlyType#getReadOnlyListVal <em>Read Only List Val</em>}</li>
- * <li>{@link com.example.ExpectedException.SequenceReadOnlyType#getUniqueName <em>Unique Name</em>}</li>
- * </ul>
- * </p>
- *
- * @extends Serializable
- * @generated
- */
-public interface SequenceReadOnlyType extends Serializable
-{
- /**
- * Returns the value of the '<em><b>Mixed</b></em>' attribute list.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Mixed</em>' attribute list isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Mixed</em>' attribute list.
- * @generated
- */
- Sequence getMixed();
-
- /**
- * Returns the value of the '<em><b>Read Only Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Read Only Val</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Read Only Val</em>' attribute.
- * @see #isSetReadOnlyVal()
- * @generated
- */
- String getReadOnlyVal();
-
- /**
- * Returns whether the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getReadOnlyVal <em>Read Only Val</em>}' attribute is set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return whether the value of the '<em>Read Only Val</em>' attribute is set.
- * @see #getReadOnlyVal()
- * @generated
- */
- boolean isSetReadOnlyVal();
-
- /**
- * Returns the value of the '<em><b>Read Only List Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Read Only List Val</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Read Only List Val</em>' attribute.
- * @see #isSetReadOnlyListVal()
- * @generated
- */
- String getReadOnlyListVal();
-
- /**
- * Returns whether the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getReadOnlyListVal <em>Read Only List Val</em>}' attribute is set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return whether the value of the '<em>Read Only List Val</em>' attribute is set.
- * @see #getReadOnlyListVal()
- * @generated
- */
- boolean isSetReadOnlyListVal();
-
- /**
- * Returns the value of the '<em><b>Unique Name</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Unique Name</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Unique Name</em>' attribute.
- * @see #isSetUniqueName()
- * @see #unsetUniqueName()
- * @see #setUniqueName(String)
- * @generated
- */
- String getUniqueName();
-
- /**
- * Sets the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getUniqueName <em>Unique Name</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Unique Name</em>' attribute.
- * @see #isSetUniqueName()
- * @see #unsetUniqueName()
- * @see #getUniqueName()
- * @generated
- */
- void setUniqueName(String value);
-
- /**
- * Unsets the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getUniqueName <em>Unique Name</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #isSetUniqueName()
- * @see #getUniqueName()
- * @see #setUniqueName(String)
- * @generated
- */
- void unsetUniqueName();
-
- /**
- * Returns whether the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getUniqueName <em>Unique Name</em>}' attribute is set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return whether the value of the '<em>Unique Name</em>' attribute is set.
- * @see #unsetUniqueName()
- * @see #getUniqueName()
- * @see #setUniqueName(String)
- * @generated
- */
- boolean isSetUniqueName();
-
-} // SequenceReadOnlyType
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES 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;
+
+/**
+ * <!-- begin-user-doc -->
+ * A representation of the model object '<em><b>Sequence Read Only Type</b></em>'.
+ * <!-- end-user-doc -->
+ *
+ * <p>
+ * The following features are supported:
+ * <ul>
+ * <li>{@link com.example.ExpectedException.SequenceReadOnlyType#getMixed <em>Mixed</em>}</li>
+ * <li>{@link com.example.ExpectedException.SequenceReadOnlyType#getReadOnlyVal <em>Read Only Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.SequenceReadOnlyType#getReadOnlyListVal <em>Read Only List Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.SequenceReadOnlyType#getUniqueName <em>Unique Name</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @extends Serializable
+ * @generated
+ */
+public interface SequenceReadOnlyType extends Serializable
+{
+ /**
+ * Returns the value of the '<em><b>Mixed</b></em>' attribute list.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Mixed</em>' attribute list isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Mixed</em>' attribute list.
+ * @generated
+ */
+ Sequence getMixed();
+
+ /**
+ * Returns the value of the '<em><b>Read Only Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Read Only Val</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Read Only Val</em>' attribute.
+ * @see #isSetReadOnlyVal()
+ * @generated
+ */
+ String getReadOnlyVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getReadOnlyVal <em>Read Only Val</em>}' attribute is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>Read Only Val</em>' attribute is set.
+ * @see #getReadOnlyVal()
+ * @generated
+ */
+ boolean isSetReadOnlyVal();
+
+ /**
+ * Returns the value of the '<em><b>Read Only List Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Read Only List Val</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Read Only List Val</em>' attribute.
+ * @see #isSetReadOnlyListVal()
+ * @generated
+ */
+ String getReadOnlyListVal();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getReadOnlyListVal <em>Read Only List Val</em>}' attribute is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>Read Only List Val</em>' attribute is set.
+ * @see #getReadOnlyListVal()
+ * @generated
+ */
+ boolean isSetReadOnlyListVal();
+
+ /**
+ * Returns the value of the '<em><b>Unique Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <p>
+ * If the meaning of the '<em>Unique Name</em>' attribute isn't clear,
+ * there really should be more of a description here...
+ * </p>
+ * <!-- end-user-doc -->
+ * @return the value of the '<em>Unique Name</em>' attribute.
+ * @see #isSetUniqueName()
+ * @see #unsetUniqueName()
+ * @see #setUniqueName(String)
+ * @generated
+ */
+ String getUniqueName();
+
+ /**
+ * Sets the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getUniqueName <em>Unique Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @param value the new value of the '<em>Unique Name</em>' attribute.
+ * @see #isSetUniqueName()
+ * @see #unsetUniqueName()
+ * @see #getUniqueName()
+ * @generated
+ */
+ void setUniqueName(String value);
+
+ /**
+ * Unsets the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getUniqueName <em>Unique Name</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isSetUniqueName()
+ * @see #getUniqueName()
+ * @see #setUniqueName(String)
+ * @generated
+ */
+ void unsetUniqueName();
+
+ /**
+ * Returns whether the value of the '{@link com.example.ExpectedException.SequenceReadOnlyType#getUniqueName <em>Unique Name</em>}' attribute is set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @return whether the value of the '<em>Unique Name</em>' attribute is set.
+ * @see #unsetUniqueName()
+ * @see #getUniqueName()
+ * @see #setUniqueName(String)
+ * @generated
+ */
+ boolean isSetUniqueName();
+
+} // SequenceReadOnlyType
diff --git a/java/sdo/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionFactoryImpl.java b/java/sdo/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionFactoryImpl.java
index 791c5a4604..68280749c4 100644
--- a/java/sdo/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionFactoryImpl.java
+++ b/java/sdo/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionFactoryImpl.java
@@ -1,579 +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;
-
-/**
- * <!-- begin-user-doc -->
- * An implementation of the model <b>Factory</b>.
- * Generator information:
- * patternVersion=1.2; -prefix ExpectedException
- * <!-- end-user-doc -->
- * @generated
- */
-public class ExpectedExceptionFactoryImpl extends FactoryBase implements ExpectedExceptionFactory
-{
-
- /**
- * The package namespace URI.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final String NAMESPACE_URI = "http://example.com/ExpectedException";
-
- /**
- * The package namespace name.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final String NAMESPACE_PREFIX = "expect";
-
- /**
- * The version of the generator pattern used to generate this class.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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);
- }
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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");
- }
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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");
- }
- }
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public ExpectedExceptionType createExpectedExceptionType()
- {
- ExpectedExceptionTypeImpl expectedExceptionType = new ExpectedExceptionTypeImpl();
- return expectedExceptionType;
- }
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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"
- });
-
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public String createcharFromString(String initialValue)
- {
- return (String)((ModelFactoryImpl)ModelFactory.INSTANCE).createStringFromString(initialValue);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public String convertcharToString(Object instanceValue)
- {
- return ((ModelFactoryImpl)ModelFactory.INSTANCE).convertStringToString(instanceValue);
- }
-
-} //ExpectedExceptionFactoryImpl
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES 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;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model <b>Factory</b>.
+ * Generator information:
+ * patternVersion=1.2; -prefix ExpectedException
+ * <!-- end-user-doc -->
+ * @generated
+ */
+public class ExpectedExceptionFactoryImpl extends FactoryBase implements ExpectedExceptionFactory
+{
+
+ /**
+ * The package namespace URI.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String NAMESPACE_URI = "http://example.com/ExpectedException";
+
+ /**
+ * The package namespace name.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public static final String NAMESPACE_PREFIX = "expect";
+
+ /**
+ * The version of the generator pattern used to generate this class.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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);
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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");
+ }
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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");
+ }
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ExpectedExceptionType createExpectedExceptionType()
+ {
+ ExpectedExceptionTypeImpl expectedExceptionType = new ExpectedExceptionTypeImpl();
+ return expectedExceptionType;
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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"
+ });
+
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String createcharFromString(String initialValue)
+ {
+ return (String)((ModelFactoryImpl)ModelFactory.INSTANCE).createStringFromString(initialValue);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String convertcharToString(Object instanceValue)
+ {
+ return ((ModelFactoryImpl)ModelFactory.INSTANCE).convertStringToString(instanceValue);
+ }
+
+} //ExpectedExceptionFactoryImpl
diff --git a/java/sdo/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionTypeImpl.java b/java/sdo/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionTypeImpl.java
index 9021e52c18..df7bdbd66e 100644
--- a/java/sdo/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionTypeImpl.java
+++ b/java/sdo/impl/src/test/java/com/example/ExpectedException/impl/ExpectedExceptionTypeImpl.java
@@ -1,1682 +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;
-
-/**
- * <!-- begin-user-doc -->
- * An implementation of the model object '<em><b>Type</b></em>'.
- * <!-- end-user-doc -->
- * <p>
- * The following features are implemented:
- * <ul>
- * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getStringVal <em>String Val</em>}</li>
- * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#isBooleanVal <em>Boolean Val</em>}</li>
- * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getByteVal <em>Byte Val</em>}</li>
- * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getDecimalVal <em>Decimal Val</em>}</li>
- * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getIntVal <em>Int Val</em>}</li>
- * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getFloatVal <em>Float Val</em>}</li>
- * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getDoubleVal <em>Double Val</em>}</li>
- * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getDateVal <em>Date Val</em>}</li>
- * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getShortVal <em>Short Val</em>}</li>
- * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getLongVal <em>Long Val</em>}</li>
- * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getListVal <em>List Val</em>}</li>
- * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getBytesVal <em>Bytes Val</em>}</li>
- * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getIntegerVal <em>Integer Val</em>}</li>
- * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getCharVal <em>Char Val</em>}</li>
- * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getReadOnlyVal <em>Read Only Val</em>}</li>
- * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getReadOnlyListVal <em>Read Only List Val</em>}</li>
- * </ul>
- * </p>
- *
- * @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 '<em><b>String Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public final static int INTERNAL_STRING_VAL = 0;
-
- /**
- * The internal feature id for the '<em><b>Boolean Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public final static int INTERNAL_BOOLEAN_VAL = 1;
-
- /**
- * The internal feature id for the '<em><b>Byte Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public final static int INTERNAL_BYTE_VAL = 2;
-
- /**
- * The internal feature id for the '<em><b>Decimal Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public final static int INTERNAL_DECIMAL_VAL = 3;
-
- /**
- * The internal feature id for the '<em><b>Int Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public final static int INTERNAL_INT_VAL = 4;
-
- /**
- * The internal feature id for the '<em><b>Float Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public final static int INTERNAL_FLOAT_VAL = 5;
-
- /**
- * The internal feature id for the '<em><b>Double Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public final static int INTERNAL_DOUBLE_VAL = 6;
-
- /**
- * The internal feature id for the '<em><b>Date Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public final static int INTERNAL_DATE_VAL = 7;
-
- /**
- * The internal feature id for the '<em><b>Short Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public final static int INTERNAL_SHORT_VAL = 8;
-
- /**
- * The internal feature id for the '<em><b>Long Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public final static int INTERNAL_LONG_VAL = 9;
-
- /**
- * The internal feature id for the '<em><b>List Val</b></em>' attribute list.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public final static int INTERNAL_LIST_VAL = 10;
-
- /**
- * The internal feature id for the '<em><b>Bytes Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public final static int INTERNAL_BYTES_VAL = 11;
-
- /**
- * The internal feature id for the '<em><b>Integer Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public final static int INTERNAL_INTEGER_VAL = 12;
-
- /**
- * The internal feature id for the '<em><b>Char Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public final static int INTERNAL_CHAR_VAL = 13;
-
- /**
- * The internal feature id for the '<em><b>Read Only Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public final static int INTERNAL_READ_ONLY_VAL = 14;
-
- /**
- * The internal feature id for the '<em><b>Read Only List Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public final static int INTERNAL_READ_ONLY_LIST_VAL = 15;
-
- /**
- * The number of properties for this type.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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() <em>String Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getStringVal()
- * @generated
- * @ordered
- */
- protected static final String STRING_VAL_DEFAULT_ = null;
-
- /**
- * The cached value of the '{@link #getStringVal() <em>String Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getStringVal()
- * @generated
- * @ordered
- */
- protected String stringVal = STRING_VAL_DEFAULT_;
-
- /**
- * This is true if the String Val attribute has been set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- protected boolean stringVal_set_ = false;
-
- /**
- * The default value of the '{@link #isBooleanVal() <em>Boolean Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #isBooleanVal()
- * @generated
- * @ordered
- */
- protected static final boolean BOOLEAN_VAL_DEFAULT_ = false;
-
- /**
- * The cached value of the '{@link #isBooleanVal() <em>Boolean Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #isBooleanVal()
- * @generated
- * @ordered
- */
- protected boolean booleanVal = BOOLEAN_VAL_DEFAULT_;
-
- /**
- * This is true if the Boolean Val attribute has been set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- protected boolean booleanVal_set_ = false;
-
- /**
- * The default value of the '{@link #getByteVal() <em>Byte Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getByteVal()
- * @generated
- * @ordered
- */
- protected static final byte BYTE_VAL_DEFAULT_ = 0;
-
- /**
- * The cached value of the '{@link #getByteVal() <em>Byte Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getByteVal()
- * @generated
- * @ordered
- */
- protected byte byteVal = BYTE_VAL_DEFAULT_;
-
- /**
- * This is true if the Byte Val attribute has been set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- protected boolean byteVal_set_ = false;
-
- /**
- * The default value of the '{@link #getDecimalVal() <em>Decimal Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getDecimalVal()
- * @generated
- * @ordered
- */
- protected static final BigDecimal DECIMAL_VAL_DEFAULT_ = null;
-
- /**
- * The cached value of the '{@link #getDecimalVal() <em>Decimal Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getDecimalVal()
- * @generated
- * @ordered
- */
- protected BigDecimal decimalVal = DECIMAL_VAL_DEFAULT_;
-
- /**
- * This is true if the Decimal Val attribute has been set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- protected boolean decimalVal_set_ = false;
-
- /**
- * The default value of the '{@link #getIntVal() <em>Int Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getIntVal()
- * @generated
- * @ordered
- */
- protected static final int INT_VAL_DEFAULT_ = 0;
-
- /**
- * The cached value of the '{@link #getIntVal() <em>Int Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getIntVal()
- * @generated
- * @ordered
- */
- protected int intVal = INT_VAL_DEFAULT_;
-
- /**
- * This is true if the Int Val attribute has been set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- protected boolean intVal_set_ = false;
-
- /**
- * The default value of the '{@link #getFloatVal() <em>Float Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getFloatVal()
- * @generated
- * @ordered
- */
- protected static final float FLOAT_VAL_DEFAULT_ = 0.0F;
-
- /**
- * The cached value of the '{@link #getFloatVal() <em>Float Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getFloatVal()
- * @generated
- * @ordered
- */
- protected float floatVal = FLOAT_VAL_DEFAULT_;
-
- /**
- * This is true if the Float Val attribute has been set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- protected boolean floatVal_set_ = false;
-
- /**
- * The default value of the '{@link #getDoubleVal() <em>Double Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getDoubleVal()
- * @generated
- * @ordered
- */
- protected static final double DOUBLE_VAL_DEFAULT_ = 0.0;
-
- /**
- * The cached value of the '{@link #getDoubleVal() <em>Double Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getDoubleVal()
- * @generated
- * @ordered
- */
- protected double doubleVal = DOUBLE_VAL_DEFAULT_;
-
- /**
- * This is true if the Double Val attribute has been set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- protected boolean doubleVal_set_ = false;
-
- /**
- * The default value of the '{@link #getDateVal() <em>Date Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getDateVal()
- * @generated
- * @ordered
- */
- protected static final String DATE_VAL_DEFAULT_ = null;
-
- /**
- * The cached value of the '{@link #getDateVal() <em>Date Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getDateVal()
- * @generated
- * @ordered
- */
- protected String dateVal = DATE_VAL_DEFAULT_;
-
- /**
- * This is true if the Date Val attribute has been set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- protected boolean dateVal_set_ = false;
-
- /**
- * The default value of the '{@link #getShortVal() <em>Short Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getShortVal()
- * @generated
- * @ordered
- */
- protected static final short SHORT_VAL_DEFAULT_ = 0;
-
- /**
- * The cached value of the '{@link #getShortVal() <em>Short Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getShortVal()
- * @generated
- * @ordered
- */
- protected short shortVal = SHORT_VAL_DEFAULT_;
-
- /**
- * This is true if the Short Val attribute has been set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- protected boolean shortVal_set_ = false;
-
- /**
- * The default value of the '{@link #getLongVal() <em>Long Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getLongVal()
- * @generated
- * @ordered
- */
- protected static final long LONG_VAL_DEFAULT_ = 0L;
-
- /**
- * The cached value of the '{@link #getLongVal() <em>Long Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getLongVal()
- * @generated
- * @ordered
- */
- protected long longVal = LONG_VAL_DEFAULT_;
-
- /**
- * This is true if the Long Val attribute has been set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- protected boolean longVal_set_ = false;
-
- /**
- * The cached value of the '{@link #getListVal() <em>List Val</em>}' attribute list.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getListVal()
- * @generated
- * @ordered
- */
-
- protected List listVal = null;
-
- /**
- * The default value of the '{@link #getBytesVal() <em>Bytes Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getBytesVal()
- * @generated
- * @ordered
- */
- protected static final byte[] BYTES_VAL_DEFAULT_ = null;
-
- /**
- * The cached value of the '{@link #getBytesVal() <em>Bytes Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getBytesVal()
- * @generated
- * @ordered
- */
- protected byte[] bytesVal = BYTES_VAL_DEFAULT_;
-
- /**
- * This is true if the Bytes Val attribute has been set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- protected boolean bytesVal_set_ = false;
-
- /**
- * The default value of the '{@link #getIntegerVal() <em>Integer Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getIntegerVal()
- * @generated
- * @ordered
- */
- protected static final BigInteger INTEGER_VAL_DEFAULT_ = null;
-
- /**
- * The cached value of the '{@link #getIntegerVal() <em>Integer Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getIntegerVal()
- * @generated
- * @ordered
- */
- protected BigInteger integerVal = INTEGER_VAL_DEFAULT_;
-
- /**
- * This is true if the Integer Val attribute has been set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- protected boolean integerVal_set_ = false;
-
- /**
- * The default value of the '{@link #getCharVal() <em>Char Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getCharVal()
- * @generated
- * @ordered
- */
- protected static final String CHAR_VAL_DEFAULT_ = null;
-
- /**
- * The cached value of the '{@link #getCharVal() <em>Char Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getCharVal()
- * @generated
- * @ordered
- */
- protected String charVal = CHAR_VAL_DEFAULT_;
-
- /**
- * This is true if the Char Val attribute has been set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- protected boolean charVal_set_ = false;
-
- /**
- * The default value of the '{@link #getReadOnlyVal() <em>Read Only Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getReadOnlyVal()
- * @generated
- * @ordered
- */
- protected static final String READ_ONLY_VAL_DEFAULT_ = null;
-
- /**
- * The cached value of the '{@link #getReadOnlyVal() <em>Read Only Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getReadOnlyVal()
- * @generated
- * @ordered
- */
- protected String readOnlyVal = READ_ONLY_VAL_DEFAULT_;
-
- /**
- * This is true if the Read Only Val attribute has been set.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- protected boolean readOnlyVal_set_ = false;
-
- /**
- * The default value of the '{@link #getReadOnlyListVal() <em>Read Only List Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getReadOnlyListVal()
- * @generated
- * @ordered
- */
- protected static final String READ_ONLY_LIST_VAL_DEFAULT_ = null;
-
- /**
- * The cached value of the '{@link #getReadOnlyListVal() <em>Read Only List Val</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- protected boolean readOnlyListVal_set_ = false;
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public ExpectedExceptionTypeImpl()
- {
- super();
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public Type getStaticType()
- {
- return ((ExpectedExceptionFactoryImpl)ExpectedExceptionFactory.INSTANCE).getExpectedExceptionType();
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public String getStringVal()
- {
- return stringVal;
- }
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean isSetStringVal()
- {
- return stringVal_set_;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean isBooleanVal()
- {
- return booleanVal;
- }
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean isSetBooleanVal()
- {
- return booleanVal_set_;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public byte getByteVal()
- {
- return byteVal;
- }
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean isSetByteVal()
- {
- return byteVal_set_;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public BigDecimal getDecimalVal()
- {
- return decimalVal;
- }
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean isSetDecimalVal()
- {
- return decimalVal_set_;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public int getIntVal()
- {
- return intVal;
- }
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean isSetIntVal()
- {
- return intVal_set_;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public float getFloatVal()
- {
- return floatVal;
- }
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean isSetFloatVal()
- {
- return floatVal_set_;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public double getDoubleVal()
- {
- return doubleVal;
- }
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean isSetDoubleVal()
- {
- return doubleVal_set_;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public String getDateVal()
- {
- return dateVal;
- }
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean isSetDateVal()
- {
- return dateVal_set_;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public short getShortVal()
- {
- return shortVal;
- }
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean isSetShortVal()
- {
- return shortVal_set_;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public long getLongVal()
- {
- return longVal;
- }
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean isSetLongVal()
- {
- return longVal_set_;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public List getListVal()
- {
- if (listVal == null)
- {
- listVal = createPropertyList(ListKind.DATATYPE, String.class, LIST_VAL, 0);
- }
- return listVal;
- }
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public byte[] getBytesVal()
- {
- return bytesVal;
- }
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean isSetBytesVal()
- {
- return bytesVal_set_;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public BigInteger getIntegerVal()
- {
- return integerVal;
- }
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean isSetIntegerVal()
- {
- return integerVal_set_;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public String getCharVal()
- {
- return charVal;
- }
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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_);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean isSetCharVal()
- {
- return charVal_set_;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public String getReadOnlyVal()
- {
- return readOnlyVal;
- }
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean isSetReadOnlyVal()
- {
- return readOnlyVal_set_;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public String getReadOnlyListVal()
- {
- return readOnlyListVal;
- }
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean isSetReadOnlyListVal()
- {
- return readOnlyListVal_set_;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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("<unset>");
- result.append(", booleanVal: ");
- if (booleanVal_set_) result.append(booleanVal); else result.append("<unset>");
- result.append(", byteVal: ");
- if (byteVal_set_) result.append(byteVal); else result.append("<unset>");
- result.append(", decimalVal: ");
- if (decimalVal_set_) result.append(decimalVal); else result.append("<unset>");
- result.append(", intVal: ");
- if (intVal_set_) result.append(intVal); else result.append("<unset>");
- result.append(", floatVal: ");
- if (floatVal_set_) result.append(floatVal); else result.append("<unset>");
- result.append(", doubleVal: ");
- if (doubleVal_set_) result.append(doubleVal); else result.append("<unset>");
- result.append(", dateVal: ");
- if (dateVal_set_) result.append(dateVal); else result.append("<unset>");
- result.append(", shortVal: ");
- if (shortVal_set_) result.append(shortVal); else result.append("<unset>");
- result.append(", longVal: ");
- if (longVal_set_) result.append(longVal); else result.append("<unset>");
- result.append(", listVal: ");
- result.append(listVal);
- result.append(", bytesVal: ");
- if (bytesVal_set_) result.append(bytesVal); else result.append("<unset>");
- result.append(", integerVal: ");
- if (integerVal_set_) result.append(integerVal); else result.append("<unset>");
- result.append(", charVal: ");
- if (charVal_set_) result.append(charVal); else result.append("<unset>");
- result.append(", readOnlyVal: ");
- if (readOnlyVal_set_) result.append(readOnlyVal); else result.append("<unset>");
- result.append(", readOnlyListVal: ");
- if (readOnlyListVal_set_) result.append(readOnlyListVal); else result.append("<unset>");
- result.append(')');
- return result.toString();
- }
-
-} //ExpectedExceptionTypeImpl
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES 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;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Type</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getStringVal <em>String Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#isBooleanVal <em>Boolean Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getByteVal <em>Byte Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getDecimalVal <em>Decimal Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getIntVal <em>Int Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getFloatVal <em>Float Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getDoubleVal <em>Double Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getDateVal <em>Date Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getShortVal <em>Short Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getLongVal <em>Long Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getListVal <em>List Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getBytesVal <em>Bytes Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getIntegerVal <em>Integer Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getCharVal <em>Char Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getReadOnlyVal <em>Read Only Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.impl.ExpectedExceptionTypeImpl#getReadOnlyListVal <em>Read Only List Val</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @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 '<em><b>String Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_STRING_VAL = 0;
+
+ /**
+ * The internal feature id for the '<em><b>Boolean Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_BOOLEAN_VAL = 1;
+
+ /**
+ * The internal feature id for the '<em><b>Byte Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_BYTE_VAL = 2;
+
+ /**
+ * The internal feature id for the '<em><b>Decimal Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_DECIMAL_VAL = 3;
+
+ /**
+ * The internal feature id for the '<em><b>Int Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_INT_VAL = 4;
+
+ /**
+ * The internal feature id for the '<em><b>Float Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_FLOAT_VAL = 5;
+
+ /**
+ * The internal feature id for the '<em><b>Double Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_DOUBLE_VAL = 6;
+
+ /**
+ * The internal feature id for the '<em><b>Date Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_DATE_VAL = 7;
+
+ /**
+ * The internal feature id for the '<em><b>Short Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_SHORT_VAL = 8;
+
+ /**
+ * The internal feature id for the '<em><b>Long Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_LONG_VAL = 9;
+
+ /**
+ * The internal feature id for the '<em><b>List Val</b></em>' attribute list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_LIST_VAL = 10;
+
+ /**
+ * The internal feature id for the '<em><b>Bytes Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_BYTES_VAL = 11;
+
+ /**
+ * The internal feature id for the '<em><b>Integer Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_INTEGER_VAL = 12;
+
+ /**
+ * The internal feature id for the '<em><b>Char Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_CHAR_VAL = 13;
+
+ /**
+ * The internal feature id for the '<em><b>Read Only Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_READ_ONLY_VAL = 14;
+
+ /**
+ * The internal feature id for the '<em><b>Read Only List Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_READ_ONLY_LIST_VAL = 15;
+
+ /**
+ * The number of properties for this type.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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() <em>String Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getStringVal()
+ * @generated
+ * @ordered
+ */
+ protected static final String STRING_VAL_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getStringVal() <em>String Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getStringVal()
+ * @generated
+ * @ordered
+ */
+ protected String stringVal = STRING_VAL_DEFAULT_;
+
+ /**
+ * This is true if the String Val attribute has been set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ protected boolean stringVal_set_ = false;
+
+ /**
+ * The default value of the '{@link #isBooleanVal() <em>Boolean Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isBooleanVal()
+ * @generated
+ * @ordered
+ */
+ protected static final boolean BOOLEAN_VAL_DEFAULT_ = false;
+
+ /**
+ * The cached value of the '{@link #isBooleanVal() <em>Boolean Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #isBooleanVal()
+ * @generated
+ * @ordered
+ */
+ protected boolean booleanVal = BOOLEAN_VAL_DEFAULT_;
+
+ /**
+ * This is true if the Boolean Val attribute has been set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ protected boolean booleanVal_set_ = false;
+
+ /**
+ * The default value of the '{@link #getByteVal() <em>Byte Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getByteVal()
+ * @generated
+ * @ordered
+ */
+ protected static final byte BYTE_VAL_DEFAULT_ = 0;
+
+ /**
+ * The cached value of the '{@link #getByteVal() <em>Byte Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getByteVal()
+ * @generated
+ * @ordered
+ */
+ protected byte byteVal = BYTE_VAL_DEFAULT_;
+
+ /**
+ * This is true if the Byte Val attribute has been set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ protected boolean byteVal_set_ = false;
+
+ /**
+ * The default value of the '{@link #getDecimalVal() <em>Decimal Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getDecimalVal()
+ * @generated
+ * @ordered
+ */
+ protected static final BigDecimal DECIMAL_VAL_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getDecimalVal() <em>Decimal Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getDecimalVal()
+ * @generated
+ * @ordered
+ */
+ protected BigDecimal decimalVal = DECIMAL_VAL_DEFAULT_;
+
+ /**
+ * This is true if the Decimal Val attribute has been set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ protected boolean decimalVal_set_ = false;
+
+ /**
+ * The default value of the '{@link #getIntVal() <em>Int Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getIntVal()
+ * @generated
+ * @ordered
+ */
+ protected static final int INT_VAL_DEFAULT_ = 0;
+
+ /**
+ * The cached value of the '{@link #getIntVal() <em>Int Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getIntVal()
+ * @generated
+ * @ordered
+ */
+ protected int intVal = INT_VAL_DEFAULT_;
+
+ /**
+ * This is true if the Int Val attribute has been set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ protected boolean intVal_set_ = false;
+
+ /**
+ * The default value of the '{@link #getFloatVal() <em>Float Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getFloatVal()
+ * @generated
+ * @ordered
+ */
+ protected static final float FLOAT_VAL_DEFAULT_ = 0.0F;
+
+ /**
+ * The cached value of the '{@link #getFloatVal() <em>Float Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getFloatVal()
+ * @generated
+ * @ordered
+ */
+ protected float floatVal = FLOAT_VAL_DEFAULT_;
+
+ /**
+ * This is true if the Float Val attribute has been set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ protected boolean floatVal_set_ = false;
+
+ /**
+ * The default value of the '{@link #getDoubleVal() <em>Double Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getDoubleVal()
+ * @generated
+ * @ordered
+ */
+ protected static final double DOUBLE_VAL_DEFAULT_ = 0.0;
+
+ /**
+ * The cached value of the '{@link #getDoubleVal() <em>Double Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getDoubleVal()
+ * @generated
+ * @ordered
+ */
+ protected double doubleVal = DOUBLE_VAL_DEFAULT_;
+
+ /**
+ * This is true if the Double Val attribute has been set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ protected boolean doubleVal_set_ = false;
+
+ /**
+ * The default value of the '{@link #getDateVal() <em>Date Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getDateVal()
+ * @generated
+ * @ordered
+ */
+ protected static final String DATE_VAL_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getDateVal() <em>Date Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getDateVal()
+ * @generated
+ * @ordered
+ */
+ protected String dateVal = DATE_VAL_DEFAULT_;
+
+ /**
+ * This is true if the Date Val attribute has been set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ protected boolean dateVal_set_ = false;
+
+ /**
+ * The default value of the '{@link #getShortVal() <em>Short Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getShortVal()
+ * @generated
+ * @ordered
+ */
+ protected static final short SHORT_VAL_DEFAULT_ = 0;
+
+ /**
+ * The cached value of the '{@link #getShortVal() <em>Short Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getShortVal()
+ * @generated
+ * @ordered
+ */
+ protected short shortVal = SHORT_VAL_DEFAULT_;
+
+ /**
+ * This is true if the Short Val attribute has been set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ protected boolean shortVal_set_ = false;
+
+ /**
+ * The default value of the '{@link #getLongVal() <em>Long Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getLongVal()
+ * @generated
+ * @ordered
+ */
+ protected static final long LONG_VAL_DEFAULT_ = 0L;
+
+ /**
+ * The cached value of the '{@link #getLongVal() <em>Long Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getLongVal()
+ * @generated
+ * @ordered
+ */
+ protected long longVal = LONG_VAL_DEFAULT_;
+
+ /**
+ * This is true if the Long Val attribute has been set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ protected boolean longVal_set_ = false;
+
+ /**
+ * The cached value of the '{@link #getListVal() <em>List Val</em>}' attribute list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getListVal()
+ * @generated
+ * @ordered
+ */
+
+ protected List listVal = null;
+
+ /**
+ * The default value of the '{@link #getBytesVal() <em>Bytes Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getBytesVal()
+ * @generated
+ * @ordered
+ */
+ protected static final byte[] BYTES_VAL_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getBytesVal() <em>Bytes Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getBytesVal()
+ * @generated
+ * @ordered
+ */
+ protected byte[] bytesVal = BYTES_VAL_DEFAULT_;
+
+ /**
+ * This is true if the Bytes Val attribute has been set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ protected boolean bytesVal_set_ = false;
+
+ /**
+ * The default value of the '{@link #getIntegerVal() <em>Integer Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getIntegerVal()
+ * @generated
+ * @ordered
+ */
+ protected static final BigInteger INTEGER_VAL_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getIntegerVal() <em>Integer Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getIntegerVal()
+ * @generated
+ * @ordered
+ */
+ protected BigInteger integerVal = INTEGER_VAL_DEFAULT_;
+
+ /**
+ * This is true if the Integer Val attribute has been set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ protected boolean integerVal_set_ = false;
+
+ /**
+ * The default value of the '{@link #getCharVal() <em>Char Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getCharVal()
+ * @generated
+ * @ordered
+ */
+ protected static final String CHAR_VAL_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getCharVal() <em>Char Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getCharVal()
+ * @generated
+ * @ordered
+ */
+ protected String charVal = CHAR_VAL_DEFAULT_;
+
+ /**
+ * This is true if the Char Val attribute has been set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ protected boolean charVal_set_ = false;
+
+ /**
+ * The default value of the '{@link #getReadOnlyVal() <em>Read Only Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getReadOnlyVal()
+ * @generated
+ * @ordered
+ */
+ protected static final String READ_ONLY_VAL_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getReadOnlyVal() <em>Read Only Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getReadOnlyVal()
+ * @generated
+ * @ordered
+ */
+ protected String readOnlyVal = READ_ONLY_VAL_DEFAULT_;
+
+ /**
+ * This is true if the Read Only Val attribute has been set.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ protected boolean readOnlyVal_set_ = false;
+
+ /**
+ * The default value of the '{@link #getReadOnlyListVal() <em>Read Only List Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getReadOnlyListVal()
+ * @generated
+ * @ordered
+ */
+ protected static final String READ_ONLY_LIST_VAL_DEFAULT_ = null;
+
+ /**
+ * The cached value of the '{@link #getReadOnlyListVal() <em>Read Only List Val</em>}' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ protected boolean readOnlyListVal_set_ = false;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public ExpectedExceptionTypeImpl()
+ {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Type getStaticType()
+ {
+ return ((ExpectedExceptionFactoryImpl)ExpectedExceptionFactory.INSTANCE).getExpectedExceptionType();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getStringVal()
+ {
+ return stringVal;
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetStringVal()
+ {
+ return stringVal_set_;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isBooleanVal()
+ {
+ return booleanVal;
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetBooleanVal()
+ {
+ return booleanVal_set_;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public byte getByteVal()
+ {
+ return byteVal;
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetByteVal()
+ {
+ return byteVal_set_;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public BigDecimal getDecimalVal()
+ {
+ return decimalVal;
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetDecimalVal()
+ {
+ return decimalVal_set_;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public int getIntVal()
+ {
+ return intVal;
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetIntVal()
+ {
+ return intVal_set_;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public float getFloatVal()
+ {
+ return floatVal;
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetFloatVal()
+ {
+ return floatVal_set_;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public double getDoubleVal()
+ {
+ return doubleVal;
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetDoubleVal()
+ {
+ return doubleVal_set_;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getDateVal()
+ {
+ return dateVal;
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetDateVal()
+ {
+ return dateVal_set_;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public short getShortVal()
+ {
+ return shortVal;
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetShortVal()
+ {
+ return shortVal_set_;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public long getLongVal()
+ {
+ return longVal;
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetLongVal()
+ {
+ return longVal_set_;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public List getListVal()
+ {
+ if (listVal == null)
+ {
+ listVal = createPropertyList(ListKind.DATATYPE, String.class, LIST_VAL, 0);
+ }
+ return listVal;
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public byte[] getBytesVal()
+ {
+ return bytesVal;
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetBytesVal()
+ {
+ return bytesVal_set_;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public BigInteger getIntegerVal()
+ {
+ return integerVal;
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetIntegerVal()
+ {
+ return integerVal_set_;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getCharVal()
+ {
+ return charVal;
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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_);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetCharVal()
+ {
+ return charVal_set_;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getReadOnlyVal()
+ {
+ return readOnlyVal;
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetReadOnlyVal()
+ {
+ return readOnlyVal_set_;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getReadOnlyListVal()
+ {
+ return readOnlyListVal;
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetReadOnlyListVal()
+ {
+ return readOnlyListVal_set_;
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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("<unset>");
+ result.append(", booleanVal: ");
+ if (booleanVal_set_) result.append(booleanVal); else result.append("<unset>");
+ result.append(", byteVal: ");
+ if (byteVal_set_) result.append(byteVal); else result.append("<unset>");
+ result.append(", decimalVal: ");
+ if (decimalVal_set_) result.append(decimalVal); else result.append("<unset>");
+ result.append(", intVal: ");
+ if (intVal_set_) result.append(intVal); else result.append("<unset>");
+ result.append(", floatVal: ");
+ if (floatVal_set_) result.append(floatVal); else result.append("<unset>");
+ result.append(", doubleVal: ");
+ if (doubleVal_set_) result.append(doubleVal); else result.append("<unset>");
+ result.append(", dateVal: ");
+ if (dateVal_set_) result.append(dateVal); else result.append("<unset>");
+ result.append(", shortVal: ");
+ if (shortVal_set_) result.append(shortVal); else result.append("<unset>");
+ result.append(", longVal: ");
+ if (longVal_set_) result.append(longVal); else result.append("<unset>");
+ result.append(", listVal: ");
+ result.append(listVal);
+ result.append(", bytesVal: ");
+ if (bytesVal_set_) result.append(bytesVal); else result.append("<unset>");
+ result.append(", integerVal: ");
+ if (integerVal_set_) result.append(integerVal); else result.append("<unset>");
+ result.append(", charVal: ");
+ if (charVal_set_) result.append(charVal); else result.append("<unset>");
+ result.append(", readOnlyVal: ");
+ if (readOnlyVal_set_) result.append(readOnlyVal); else result.append("<unset>");
+ result.append(", readOnlyListVal: ");
+ if (readOnlyListVal_set_) result.append(readOnlyListVal); else result.append("<unset>");
+ result.append(')');
+ return result.toString();
+ }
+
+} //ExpectedExceptionTypeImpl
diff --git a/java/sdo/impl/src/test/java/com/example/ExpectedException/impl/SequenceReadOnlyTypeImpl.java b/java/sdo/impl/src/test/java/com/example/ExpectedException/impl/SequenceReadOnlyTypeImpl.java
index 4ac8a19807..048cb439db 100644
--- a/java/sdo/impl/src/test/java/com/example/ExpectedException/impl/SequenceReadOnlyTypeImpl.java
+++ b/java/sdo/impl/src/test/java/com/example/ExpectedException/impl/SequenceReadOnlyTypeImpl.java
@@ -1,354 +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;
-
-/**
- * <!-- begin-user-doc -->
- * An implementation of the model object '<em><b>Sequence Read Only Type</b></em>'.
- * <!-- end-user-doc -->
- * <p>
- * The following features are implemented:
- * <ul>
- * <li>{@link com.example.ExpectedException.impl.SequenceReadOnlyTypeImpl#getMixed <em>Mixed</em>}</li>
- * <li>{@link com.example.ExpectedException.impl.SequenceReadOnlyTypeImpl#getReadOnlyVal <em>Read Only Val</em>}</li>
- * <li>{@link com.example.ExpectedException.impl.SequenceReadOnlyTypeImpl#getReadOnlyListVal <em>Read Only List Val</em>}</li>
- * <li>{@link com.example.ExpectedException.impl.SequenceReadOnlyTypeImpl#getUniqueName <em>Unique Name</em>}</li>
- * </ul>
- * </p>
- *
- * @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 '<em><b>Mixed</b></em>' attribute list.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public final static int INTERNAL_MIXED = 0;
-
- /**
- * The internal feature id for the '<em><b>Read Only Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public final static int INTERNAL_READ_ONLY_VAL = 1;
-
- /**
- * The internal feature id for the '<em><b>Read Only List Val</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public final static int INTERNAL_READ_ONLY_LIST_VAL = 2;
-
- /**
- * The internal feature id for the '<em><b>Unique Name</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public final static int INTERNAL_UNIQUE_NAME = 3;
-
- /**
- * The number of properties for this type.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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() <em>Mixed</em>}' attribute list.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getMixed()
- * @generated
- * @ordered
- */
-
- protected Sequence mixed = null;
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public SequenceReadOnlyTypeImpl()
- {
- super();
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public Type getStaticType()
- {
- return ((ExpectedExceptionFactoryImpl)ExpectedExceptionFactory.INSTANCE).getSequenceReadOnlyType();
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public Sequence getMixed()
- {
- if (mixed == null)
- {
- mixed = createSequence(INTERNAL_MIXED);
- }
- return mixed;
- }
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public String getReadOnlyVal()
- {
- return (String)get(getMixed(), getType(), INTERNAL_READ_ONLY_VAL);
- }
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean isSetReadOnlyVal()
- {
- return isSet(getMixed(), getType(), INTERNAL_READ_ONLY_VAL);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public String getReadOnlyListVal()
- {
- return (String)get(getMixed(), getType(), INTERNAL_READ_ONLY_LIST_VAL);
- }
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean isSetReadOnlyListVal()
- {
- return isSet(getMixed(), getType(), INTERNAL_READ_ONLY_LIST_VAL);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public String getUniqueName()
- {
- return (String)get(getMixed(), getType(), INTERNAL_UNIQUE_NAME);
- }
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public void setUniqueName(String newUniqueName)
- {
- set(getMixed(), getType(), INTERNAL_UNIQUE_NAME, newUniqueName);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public void unsetUniqueName()
- {
- unset(getMixed(), getType(), INTERNAL_UNIQUE_NAME);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean isSetUniqueName()
- {
- return isSet(getMixed(), getType(), INTERNAL_UNIQUE_NAME);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public void unset(int propertyIndex)
- {
- switch (propertyIndex)
- {
- case MIXED:
- unsetSequence(getMixed());
- return;
- case UNIQUE_NAME:
- unsetUniqueName();
- return;
- }
- super.unset(propertyIndex);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @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
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES 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;
+
+/**
+ * <!-- begin-user-doc -->
+ * An implementation of the model object '<em><b>Sequence Read Only Type</b></em>'.
+ * <!-- end-user-doc -->
+ * <p>
+ * The following features are implemented:
+ * <ul>
+ * <li>{@link com.example.ExpectedException.impl.SequenceReadOnlyTypeImpl#getMixed <em>Mixed</em>}</li>
+ * <li>{@link com.example.ExpectedException.impl.SequenceReadOnlyTypeImpl#getReadOnlyVal <em>Read Only Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.impl.SequenceReadOnlyTypeImpl#getReadOnlyListVal <em>Read Only List Val</em>}</li>
+ * <li>{@link com.example.ExpectedException.impl.SequenceReadOnlyTypeImpl#getUniqueName <em>Unique Name</em>}</li>
+ * </ul>
+ * </p>
+ *
+ * @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 '<em><b>Mixed</b></em>' attribute list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_MIXED = 0;
+
+ /**
+ * The internal feature id for the '<em><b>Read Only Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_READ_ONLY_VAL = 1;
+
+ /**
+ * The internal feature id for the '<em><b>Read Only List Val</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_READ_ONLY_LIST_VAL = 2;
+
+ /**
+ * The internal feature id for the '<em><b>Unique Name</b></em>' attribute.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ * @ordered
+ */
+ public final static int INTERNAL_UNIQUE_NAME = 3;
+
+ /**
+ * The number of properties for this type.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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() <em>Mixed</em>}' attribute list.
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @see #getMixed()
+ * @generated
+ * @ordered
+ */
+
+ protected Sequence mixed = null;
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public SequenceReadOnlyTypeImpl()
+ {
+ super();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Type getStaticType()
+ {
+ return ((ExpectedExceptionFactoryImpl)ExpectedExceptionFactory.INSTANCE).getSequenceReadOnlyType();
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public Sequence getMixed()
+ {
+ if (mixed == null)
+ {
+ mixed = createSequence(INTERNAL_MIXED);
+ }
+ return mixed;
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getReadOnlyVal()
+ {
+ return (String)get(getMixed(), getType(), INTERNAL_READ_ONLY_VAL);
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetReadOnlyVal()
+ {
+ return isSet(getMixed(), getType(), INTERNAL_READ_ONLY_VAL);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getReadOnlyListVal()
+ {
+ return (String)get(getMixed(), getType(), INTERNAL_READ_ONLY_LIST_VAL);
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetReadOnlyListVal()
+ {
+ return isSet(getMixed(), getType(), INTERNAL_READ_ONLY_LIST_VAL);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public String getUniqueName()
+ {
+ return (String)get(getMixed(), getType(), INTERNAL_UNIQUE_NAME);
+ }
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void setUniqueName(String newUniqueName)
+ {
+ set(getMixed(), getType(), INTERNAL_UNIQUE_NAME, newUniqueName);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void unsetUniqueName()
+ {
+ unset(getMixed(), getType(), INTERNAL_UNIQUE_NAME);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public boolean isSetUniqueName()
+ {
+ return isSet(getMixed(), getType(), INTERNAL_UNIQUE_NAME);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @generated
+ */
+ public void unset(int propertyIndex)
+ {
+ switch (propertyIndex)
+ {
+ case MIXED:
+ unsetSequence(getMixed());
+ return;
+ case UNIQUE_NAME:
+ unsetUniqueName();
+ return;
+ }
+ super.unset(propertyIndex);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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);
+ }
+
+ /**
+ * <!-- begin-user-doc -->
+ * <!-- end-user-doc -->
+ * @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/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/BoundsTestCase.java b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/BoundsTestCase.java
index 35c9b87b2c..7f176fe033 100644
--- a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/BoundsTestCase.java
+++ b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/BoundsTestCase.java
@@ -1,79 +1,79 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * 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.api.SDOUtil;
-import org.apache.tuscany.sdo.api.SDOHelper;
-
-import junit.framework.TestCase;
-
-import commonj.sdo.*;
-import commonj.sdo.helper.*;
-
-public class BoundsTestCase extends TestCase {
- private final String TEST_MODEL = "/bounds.xsd";
- private final String TEST_NAMESPACE = "http://www.example.com/bounds";
-
- private TypeHelper typeHelper;
- private XSDHelper xsdHelper;
- private DataFactory dataFactory;
-
- public void testBounds() {
- Property priceProperty = typeHelper.getOpenContentProperty(TEST_NAMESPACE, "price");
- assertTrue(priceProperty.isOpenContent());
- assertEquals(SDOHelper.UNSPECIFIED, SDOUtil.getUpperBound(priceProperty));
- assertEquals(0, SDOUtil.getLowerBound(priceProperty));
-
- Type quoteType = typeHelper.getType(TEST_NAMESPACE, "OpenQuote");
- DataObject quote = dataFactory.create(quoteType);
- assertEquals(2, SDOUtil.getUpperBound(quote.getInstanceProperty("symbol")));
- assertEquals(0, SDOUtil.getLowerBound(quote.getInstanceProperty("symbol")));
-
- //XSD default value of maxOccurs and minOccurs is 1, unbounded returns -1 for maxOccurs
- Type quoteType2 = typeHelper.getType(TEST_NAMESPACE, "OpenQuote2");
- DataObject quote2 = dataFactory.create(quoteType2);
- assertEquals(SDOHelper.UNBOUNDED, SDOUtil.getUpperBound(quote2.getInstanceProperty("symbol")));
- assertEquals(1, SDOUtil.getLowerBound(quote2.getInstanceProperty("symbol")));
-
- //XSD default value of maxOccurs and minOccurs is 1
- Type quoteType3 = typeHelper.getType(TEST_NAMESPACE, "OpenQuote3");
- DataObject quote3 = dataFactory.create(quoteType3);
- assertEquals(1, SDOUtil.getUpperBound(quote3.getInstanceProperty("symbol")));
- assertEquals(1, SDOUtil.getLowerBound(quote3.getInstanceProperty("symbol")));
- }
-
- protected void setUp() throws Exception {
- super.setUp();
-
- HelperContext hc = SDOUtil.createHelperContext();
- typeHelper = hc.getTypeHelper();
- dataFactory = hc.getDataFactory();
- xsdHelper = hc.getXSDHelper();
-
- // Populate the meta data for the test (Stock Quote) model
- URL url = getClass().getResource(TEST_MODEL);
- InputStream inputStream = url.openStream();
- xsdHelper.define(inputStream, url.toString());
- inputStream.close();
- }
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.api.SDOUtil;
+import org.apache.tuscany.sdo.api.SDOHelper;
+
+import junit.framework.TestCase;
+
+import commonj.sdo.*;
+import commonj.sdo.helper.*;
+
+public class BoundsTestCase extends TestCase {
+ private final String TEST_MODEL = "/bounds.xsd";
+ private final String TEST_NAMESPACE = "http://www.example.com/bounds";
+
+ private TypeHelper typeHelper;
+ private XSDHelper xsdHelper;
+ private DataFactory dataFactory;
+
+ public void testBounds() {
+ Property priceProperty = typeHelper.getOpenContentProperty(TEST_NAMESPACE, "price");
+ assertTrue(priceProperty.isOpenContent());
+ assertEquals(SDOHelper.UNSPECIFIED, SDOUtil.getUpperBound(priceProperty));
+ assertEquals(0, SDOUtil.getLowerBound(priceProperty));
+
+ Type quoteType = typeHelper.getType(TEST_NAMESPACE, "OpenQuote");
+ DataObject quote = dataFactory.create(quoteType);
+ assertEquals(2, SDOUtil.getUpperBound(quote.getInstanceProperty("symbol")));
+ assertEquals(0, SDOUtil.getLowerBound(quote.getInstanceProperty("symbol")));
+
+ //XSD default value of maxOccurs and minOccurs is 1, unbounded returns -1 for maxOccurs
+ Type quoteType2 = typeHelper.getType(TEST_NAMESPACE, "OpenQuote2");
+ DataObject quote2 = dataFactory.create(quoteType2);
+ assertEquals(SDOHelper.UNBOUNDED, SDOUtil.getUpperBound(quote2.getInstanceProperty("symbol")));
+ assertEquals(1, SDOUtil.getLowerBound(quote2.getInstanceProperty("symbol")));
+
+ //XSD default value of maxOccurs and minOccurs is 1
+ Type quoteType3 = typeHelper.getType(TEST_NAMESPACE, "OpenQuote3");
+ DataObject quote3 = dataFactory.create(quoteType3);
+ assertEquals(1, SDOUtil.getUpperBound(quote3.getInstanceProperty("symbol")));
+ assertEquals(1, SDOUtil.getLowerBound(quote3.getInstanceProperty("symbol")));
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ HelperContext hc = SDOUtil.createHelperContext();
+ typeHelper = hc.getTypeHelper();
+ dataFactory = hc.getDataFactory();
+ xsdHelper = hc.getXSDHelper();
+
+ // Populate the meta data for the test (Stock Quote) model
+ URL url = getClass().getResource(TEST_MODEL);
+ InputStream inputStream = url.openStream();
+ xsdHelper.define(inputStream, url.toString());
+ inputStream.close();
+ }
} \ No newline at end of file
diff --git a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryPropertyTestCase.java b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryPropertyTestCase.java
index 4a62ec6135..ace509d1b4 100644
--- a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryPropertyTestCase.java
+++ b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ChangeSummaryPropertyTestCase.java
@@ -1,219 +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");
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/CrossScopeCopyTestCase.java b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/CrossScopeCopyTestCase.java
index bba7fb4c1b..4a8ed34477 100644
--- a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/CrossScopeCopyTestCase.java
+++ b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/CrossScopeCopyTestCase.java
@@ -1,474 +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 <indent; i++) System.out.print(" ");
- }
- */
-
- protected void constructSourceTree(DataFactory df)
- {
- // Create Instances
- bankSDO = df.create(TEST_NAMESPACE, BANK_TYPE );
- branchSDO1 = df.create(TEST_NAMESPACE, BRANCH_TYPE );
- branchSDO2 = df.create(TEST_NAMESPACE, BRANCH_TYPE );
- serviceSDO1 = df.create(TEST_NAMESPACE, SERVICE_TYPE );
- serviceSDO2 = df.create(TEST_NAMESPACE, SERVICE_TYPE );
- serviceSDO3 = df.create(TEST_NAMESPACE, SERVICE_TYPE );
- customerSDO1 = df.create(TEST_NAMESPACE, CUSTOMER_TYPE );
- customerSDO2 = df.create(TEST_NAMESPACE, CUSTOMER_TYPE );
- customerSDO3 = df.create(TEST_NAMESPACE, CUSTOMER_TYPE );
- customerSDO4 = df.create(TEST_NAMESPACE, CUSTOMER_TYPE );
-
- // Populate the Bank Instance
- bankSDO.set("name", "Fourth National");
- Vector v = new Vector();
- v.add(branchSDO1);
- v.add(branchSDO2);
- bankSDO.set("Branch",v);
- v.removeAllElements();
- v.add(serviceSDO1);
- v.add(serviceSDO2);
- v.add(serviceSDO3);
- bankSDO.set("Service",v);
- v.removeAllElements();
- v.add(customerSDO1);
- v.add(customerSDO2);
- v.add(customerSDO3);
- v.add(customerSDO4);
- bankSDO.set("Customer",v);
- v.removeAllElements();
-
- // Populate Branch Instances
- // Branch 1
- branchSDO1.set("ID", "BR100");
- DataObject addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE );
- addr.set("Street", "1302 Money Street");
- addr.set("City", "Apex");
- addr.set("State", "NC");
- addr.set("Zip", "27502");
- branchSDO1.set("Address", addr);
- v.add("If you are north, head south");
- v.add("If you are south, head north");
- branchSDO1.set("Directions", v);
- v.removeAllElements();
- DataObject account1 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE );
- account1.set("ID", "0000 1200 0001");
- account1.set("Service", serviceSDO1 );
- account1.setBigDecimal("Balance", new BigDecimal("3124.12"));
- v.add(account1);
- DataObject account2 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE );
- account2.set("ID", "0000 8899 0001");
- account2.set("Service", serviceSDO1 );
- account2.setBigDecimal("Balance", new BigDecimal("20.00"));
- v.add(account2);
- DataObject account3 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE );
- account3.set("ID", "0000 3110 0020");
- account3.set("Service", serviceSDO3 );
- account3.setBigDecimal("Balance", new BigDecimal("5000.00"));
- v.add(account3);
- branchSDO1.set("Account", v);
- v.removeAllElements();
- // Branch 2
- branchSDO2.set("ID", "BR200");
- addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE );
- addr.set("Street", "1207 Cash Court");
- addr.set("City", "Raleigh");
- addr.set("State", "NC");
- addr.set("Zip", "27701");
- branchSDO2.set("Address", addr);
- v.add("If you are east, head west");
- v.add("If you are west, head east");
- branchSDO2.set("Directions", v);
- v.removeAllElements();
- DataObject account4 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE );
- account4.set("ID", "0000 0011 0001");
- account4.set("Service", serviceSDO1 );
- account4.setBigDecimal("Balance", new BigDecimal("99.12"));
- v.add(account4);
- DataObject account5 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE );
- account5.set("ID", "0000 9911 0001");
- account5.set("Service", serviceSDO2 );
- account5.setBigDecimal("Balance", new BigDecimal("820.00"));
- v.add(account5);
- DataObject account6 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE );
- account6.set("ID", "0000 0001 0020");
- account6.set("Service", serviceSDO3 );
- account6.setBigDecimal("Balance", new BigDecimal("9000.00"));
- v.add(account6);
- branchSDO2.set("Account", v);
- v.removeAllElements();
-
- // Populate Service Instances
- serviceSDO1.set("ID", "SRV01");
- serviceSDO1.set("Name", "Checking");
- serviceSDO1.setBigDecimal("Fee", new BigDecimal("0.00"));
- serviceSDO2.set("ID", "SRV02");
- serviceSDO2.set("Name", "Savings");
- serviceSDO2.setBigDecimal("Fee", new BigDecimal("0.00"));
- serviceSDO3.set("ID", "SRV03");
- serviceSDO3.set("Name", "Loan");
- serviceSDO3.setBigDecimal("Fee", new BigDecimal("0.00"));
-
- // Populate Customer Instances
- // Customer 1
- customerSDO1.set("ID", "CUST01");
- customerSDO1.set("First", "James");
- customerSDO1.set("Last", "Madison");
- addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE );
- addr.set("Street", "1234 Easy Street");
- addr.set("City", "New York");
- addr.set("State", "NY");
- addr.set("Zip", "27511");
- customerSDO1.set("Address", addr);
- customerSDO1.set("HomeBranch", branchSDO1);
- v.add(account1);
- customerSDO1.set("Account", v);
- v.removeAllElements();
- v.add(customerSDO2);
- v.add(customerSDO3);
- customerSDO1.set("Related", v);
- v.removeAllElements();
- // Customer 2
- customerSDO2.set("ID", "CUST02");
- customerSDO2.set("First", "George");
- customerSDO2.set("Last", "Washington");
- addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE );
- addr.set("Street", "1776 Potomac Avenue");
- addr.set("City", "Washington");
- addr.set("State", "DC");
- addr.set("Zip", "50555");
- customerSDO2.set("Address", addr);
- customerSDO2.set("HomeBranch", branchSDO1);
- v.add(account2);
- v.add(account3);
- customerSDO2.set("Account", v);
- v.removeAllElements();
- // Customer 3
- customerSDO3.set("ID", "CUST03");
- customerSDO3.set("First", "Thomas");
- customerSDO3.set("Last", "Jefferson");
- addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE );
- addr.set("Street", "1492 Columbus Avenue");
- addr.set("City", "Charlottesville");
- addr.set("State", "VA");
- addr.set("Zip", "20121");
- customerSDO3.set("Address", addr);
- customerSDO3.set("HomeBranch", branchSDO2);
- v.add(account4);
- customerSDO3.set("Account", v);
- v.removeAllElements();
- // Customer 4
- customerSDO4.set("ID", "CUST04");
- customerSDO4.set("First", "Benjamin");
- customerSDO4.set("Last", "Franklin");
- addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE );
- addr.set("Street", "99 Light Street");
- addr.set("City", "Philadelphia");
- addr.set("State", "PA");
- addr.set("Zip", "19251");
- customerSDO4.set("Address", addr);
- customerSDO4.set("HomeBranch", branchSDO2);
- v.add(account5);
- v.add(account6);
- customerSDO4.set("Account", v);
- v.removeAllElements();
-
- }
-
- private void populateScopeWithDynamicTypes(TypeHelper scope)
- {
- Type stringType = scope.getType("commonj.sdo", "String");
- DataObject customerType = DataFactory.INSTANCE.create("commonj.sdo", "Type");
- customerType.set("uri", TEST_NAMESPACE);
- customerType.set("name", DYNAMIC_TYPE );
- DataObject custNumProperty = customerType.createDataObject("property");
- custNumProperty.set("name", "custNum");
- custNumProperty.set("type", stringType);
- DataObject firstNameProperty = customerType.createDataObject("property");
- firstNameProperty.set("name", "firstName");
- firstNameProperty.set("type", stringType);
- DataObject lastNameProperty = customerType.createDataObject("property");
- lastNameProperty.set("name", "lastName");
- lastNameProperty.set("type", stringType);
- scope.define(customerType);
- }
-
- /*
- private void dumpObject(DataObject sdo, String node )
- {
- try
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- SDOUtil.createXMLHelper(scopeA).save(sdo, TEST_NAMESPACE,
- node, baos);
- System.out.println(baos.toString());
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- }
- */
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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 <indent; i++) System.out.print(" ");
+ }
+ */
+
+ protected void constructSourceTree(DataFactory df)
+ {
+ // Create Instances
+ bankSDO = df.create(TEST_NAMESPACE, BANK_TYPE );
+ branchSDO1 = df.create(TEST_NAMESPACE, BRANCH_TYPE );
+ branchSDO2 = df.create(TEST_NAMESPACE, BRANCH_TYPE );
+ serviceSDO1 = df.create(TEST_NAMESPACE, SERVICE_TYPE );
+ serviceSDO2 = df.create(TEST_NAMESPACE, SERVICE_TYPE );
+ serviceSDO3 = df.create(TEST_NAMESPACE, SERVICE_TYPE );
+ customerSDO1 = df.create(TEST_NAMESPACE, CUSTOMER_TYPE );
+ customerSDO2 = df.create(TEST_NAMESPACE, CUSTOMER_TYPE );
+ customerSDO3 = df.create(TEST_NAMESPACE, CUSTOMER_TYPE );
+ customerSDO4 = df.create(TEST_NAMESPACE, CUSTOMER_TYPE );
+
+ // Populate the Bank Instance
+ bankSDO.set("name", "Fourth National");
+ Vector v = new Vector();
+ v.add(branchSDO1);
+ v.add(branchSDO2);
+ bankSDO.set("Branch",v);
+ v.removeAllElements();
+ v.add(serviceSDO1);
+ v.add(serviceSDO2);
+ v.add(serviceSDO3);
+ bankSDO.set("Service",v);
+ v.removeAllElements();
+ v.add(customerSDO1);
+ v.add(customerSDO2);
+ v.add(customerSDO3);
+ v.add(customerSDO4);
+ bankSDO.set("Customer",v);
+ v.removeAllElements();
+
+ // Populate Branch Instances
+ // Branch 1
+ branchSDO1.set("ID", "BR100");
+ DataObject addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE );
+ addr.set("Street", "1302 Money Street");
+ addr.set("City", "Apex");
+ addr.set("State", "NC");
+ addr.set("Zip", "27502");
+ branchSDO1.set("Address", addr);
+ v.add("If you are north, head south");
+ v.add("If you are south, head north");
+ branchSDO1.set("Directions", v);
+ v.removeAllElements();
+ DataObject account1 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE );
+ account1.set("ID", "0000 1200 0001");
+ account1.set("Service", serviceSDO1 );
+ account1.setBigDecimal("Balance", new BigDecimal("3124.12"));
+ v.add(account1);
+ DataObject account2 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE );
+ account2.set("ID", "0000 8899 0001");
+ account2.set("Service", serviceSDO1 );
+ account2.setBigDecimal("Balance", new BigDecimal("20.00"));
+ v.add(account2);
+ DataObject account3 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE );
+ account3.set("ID", "0000 3110 0020");
+ account3.set("Service", serviceSDO3 );
+ account3.setBigDecimal("Balance", new BigDecimal("5000.00"));
+ v.add(account3);
+ branchSDO1.set("Account", v);
+ v.removeAllElements();
+ // Branch 2
+ branchSDO2.set("ID", "BR200");
+ addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE );
+ addr.set("Street", "1207 Cash Court");
+ addr.set("City", "Raleigh");
+ addr.set("State", "NC");
+ addr.set("Zip", "27701");
+ branchSDO2.set("Address", addr);
+ v.add("If you are east, head west");
+ v.add("If you are west, head east");
+ branchSDO2.set("Directions", v);
+ v.removeAllElements();
+ DataObject account4 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE );
+ account4.set("ID", "0000 0011 0001");
+ account4.set("Service", serviceSDO1 );
+ account4.setBigDecimal("Balance", new BigDecimal("99.12"));
+ v.add(account4);
+ DataObject account5 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE );
+ account5.set("ID", "0000 9911 0001");
+ account5.set("Service", serviceSDO2 );
+ account5.setBigDecimal("Balance", new BigDecimal("820.00"));
+ v.add(account5);
+ DataObject account6 = df.create(TEST_NAMESPACE, ACCOUNT_TYPE );
+ account6.set("ID", "0000 0001 0020");
+ account6.set("Service", serviceSDO3 );
+ account6.setBigDecimal("Balance", new BigDecimal("9000.00"));
+ v.add(account6);
+ branchSDO2.set("Account", v);
+ v.removeAllElements();
+
+ // Populate Service Instances
+ serviceSDO1.set("ID", "SRV01");
+ serviceSDO1.set("Name", "Checking");
+ serviceSDO1.setBigDecimal("Fee", new BigDecimal("0.00"));
+ serviceSDO2.set("ID", "SRV02");
+ serviceSDO2.set("Name", "Savings");
+ serviceSDO2.setBigDecimal("Fee", new BigDecimal("0.00"));
+ serviceSDO3.set("ID", "SRV03");
+ serviceSDO3.set("Name", "Loan");
+ serviceSDO3.setBigDecimal("Fee", new BigDecimal("0.00"));
+
+ // Populate Customer Instances
+ // Customer 1
+ customerSDO1.set("ID", "CUST01");
+ customerSDO1.set("First", "James");
+ customerSDO1.set("Last", "Madison");
+ addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE );
+ addr.set("Street", "1234 Easy Street");
+ addr.set("City", "New York");
+ addr.set("State", "NY");
+ addr.set("Zip", "27511");
+ customerSDO1.set("Address", addr);
+ customerSDO1.set("HomeBranch", branchSDO1);
+ v.add(account1);
+ customerSDO1.set("Account", v);
+ v.removeAllElements();
+ v.add(customerSDO2);
+ v.add(customerSDO3);
+ customerSDO1.set("Related", v);
+ v.removeAllElements();
+ // Customer 2
+ customerSDO2.set("ID", "CUST02");
+ customerSDO2.set("First", "George");
+ customerSDO2.set("Last", "Washington");
+ addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE );
+ addr.set("Street", "1776 Potomac Avenue");
+ addr.set("City", "Washington");
+ addr.set("State", "DC");
+ addr.set("Zip", "50555");
+ customerSDO2.set("Address", addr);
+ customerSDO2.set("HomeBranch", branchSDO1);
+ v.add(account2);
+ v.add(account3);
+ customerSDO2.set("Account", v);
+ v.removeAllElements();
+ // Customer 3
+ customerSDO3.set("ID", "CUST03");
+ customerSDO3.set("First", "Thomas");
+ customerSDO3.set("Last", "Jefferson");
+ addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE );
+ addr.set("Street", "1492 Columbus Avenue");
+ addr.set("City", "Charlottesville");
+ addr.set("State", "VA");
+ addr.set("Zip", "20121");
+ customerSDO3.set("Address", addr);
+ customerSDO3.set("HomeBranch", branchSDO2);
+ v.add(account4);
+ customerSDO3.set("Account", v);
+ v.removeAllElements();
+ // Customer 4
+ customerSDO4.set("ID", "CUST04");
+ customerSDO4.set("First", "Benjamin");
+ customerSDO4.set("Last", "Franklin");
+ addr = df.create(TEST_NAMESPACE, ADDRESS_TYPE );
+ addr.set("Street", "99 Light Street");
+ addr.set("City", "Philadelphia");
+ addr.set("State", "PA");
+ addr.set("Zip", "19251");
+ customerSDO4.set("Address", addr);
+ customerSDO4.set("HomeBranch", branchSDO2);
+ v.add(account5);
+ v.add(account6);
+ customerSDO4.set("Account", v);
+ v.removeAllElements();
+
+ }
+
+ private void populateScopeWithDynamicTypes(TypeHelper scope)
+ {
+ Type stringType = scope.getType("commonj.sdo", "String");
+ DataObject customerType = DataFactory.INSTANCE.create("commonj.sdo", "Type");
+ customerType.set("uri", TEST_NAMESPACE);
+ customerType.set("name", DYNAMIC_TYPE );
+ DataObject custNumProperty = customerType.createDataObject("property");
+ custNumProperty.set("name", "custNum");
+ custNumProperty.set("type", stringType);
+ DataObject firstNameProperty = customerType.createDataObject("property");
+ firstNameProperty.set("name", "firstName");
+ firstNameProperty.set("type", stringType);
+ DataObject lastNameProperty = customerType.createDataObject("property");
+ lastNameProperty.set("name", "lastName");
+ lastNameProperty.set("type", stringType);
+ scope.define(customerType);
+ }
+
+ /*
+ private void dumpObject(DataObject sdo, String node )
+ {
+ try
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ SDOUtil.createXMLHelper(scopeA).save(sdo, TEST_NAMESPACE,
+ node, baos);
+ System.out.println(baos.toString());
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ */
+}
diff --git a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataObjectGetListTestCase.java b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataObjectGetListTestCase.java
index 036aeda790..a4312a9154 100644
--- a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataObjectGetListTestCase.java
+++ b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DataObjectGetListTestCase.java
@@ -1,129 +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.test;
-
-
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.tuscany.sdo.api.SDOUtil;
-
-import commonj.sdo.DataObject;
-import commonj.sdo.helper.HelperContext;
-import junit.framework.TestCase;
-
-public class DataObjectGetListTestCase extends TestCase {
- private HelperContext hc;
- private DataObject companyDataObject;
-
- private final String TEST_NAMESPACE = "http://www.example.com/getList";
-
- private String xsdString =
- "<xsd:schema " +
- "xmlns:getList=\"http://www.example.com/getList\" " +
- "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
- "targetNamespace=\"http://www.example.com/getList\">" +
-
- "<xsd:element name=\"company\" type=\"getList:Company\"/>" +
- "<xsd:element name=\"employee\" type=\"xsd:string\"/>" +
-
- "<xsd:complexType name=\"Company\">" +
- "<xsd:sequence>" +
- "<xsd:element name=\"openCompany\" type=\"getList:OpenCompany\"/>" +
- "<xsd:element name=\"closeCompany\" type=\"getList:CloseCompany\"/>" +
- "</xsd:sequence>" +
- "</xsd:complexType>" +
-
- "<xsd:complexType name=\"OpenCompany\">" +
- "<xsd:sequence>" +
- "<xsd:element name=\"company\" type=\"xsd:string\"/>" +
- "<xsd:element name=\"employees\" maxOccurs=\"unbounded\" type=\"xsd:string\"/>" +
- "<xsd:any maxOccurs=\"unbounded\" namespace=\"##any\"/>" +
- "</xsd:sequence>" +
- "</xsd:complexType>" +
-
- "<xsd:complexType name=\"CloseCompany\">" +
- "<xsd:sequence>" +
- "<xsd:element name=\"company\" type=\"xsd:string\"/>" +
- "<xsd:element name=\"employees\" maxOccurs=\"unbounded\" type=\"xsd:string\"/>" +
- "</xsd:sequence>" +
- "</xsd:complexType>" +
-
- "</xsd:schema>";
-
- /**
- * Test DataObject.getList() on open type
- */
- public void testUnknownPropertyOnOpenType() throws IOException {
- String companyName = companyDataObject.getString("openCompany/company");
- assertEquals(companyName, "OpenCompany");
- List unknownProperty = companyDataObject.getList("openCompany/unknownProperty");
- assertNotNull(unknownProperty);
- assertTrue(unknownProperty instanceof List);
-
- List unknownProperty2 = companyDataObject.getList("openCompany/unknownProperty");
- assertNotNull(unknownProperty2);
- assertTrue(unknownProperty2 instanceof List);
-
- // unknownProperty and unknownProperty2 are in fact the same value for the same property
-
- unknownProperty.add("employee1");
- assertTrue(unknownProperty.size() == 1);
-
- unknownProperty2.add("employee2");
- assertTrue(unknownProperty2.size() == 2);
-
- unknownProperty.remove(0);
- assertTrue(unknownProperty.size() == 1);
-
- assertEquals(unknownProperty.get(0), "employee2");
- }
-
- /**
- * Test DataObject.getList() on non-open type
- */
- public void testUnknownPropertyOnClosedType() throws IOException {
- String companyName = companyDataObject.getString("closeCompany/company");
- assertEquals(companyName, "CloseCompany");
- List unknownProperty = companyDataObject.getList("closeCompany/unknownProperty");
- assertNotNull(unknownProperty);
- assertTrue(unknownProperty instanceof List);
-
- try {
- unknownProperty.add("employee1");
- fail("An exception should have been thrown.");
- }
- catch (Exception e) {
- }
- }
-
- protected void setUp() throws Exception {
- super.setUp();
-
- hc = SDOUtil.createHelperContext();
- hc.getXSDHelper().define(xsdString);
-
- companyDataObject = hc.getDataFactory().create(TEST_NAMESPACE, "Company");
- DataObject openCompany = companyDataObject.createDataObject("openCompany");
- openCompany.setString("company", "OpenCompany");
- DataObject closeCompany = companyDataObject.createDataObject("closeCompany");
- closeCompany.setString("company", "CloseCompany");
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.List;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+import junit.framework.TestCase;
+
+public class DataObjectGetListTestCase extends TestCase {
+ private HelperContext hc;
+ private DataObject companyDataObject;
+
+ private final String TEST_NAMESPACE = "http://www.example.com/getList";
+
+ private String xsdString =
+ "<xsd:schema " +
+ "xmlns:getList=\"http://www.example.com/getList\" " +
+ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
+ "targetNamespace=\"http://www.example.com/getList\">" +
+
+ "<xsd:element name=\"company\" type=\"getList:Company\"/>" +
+ "<xsd:element name=\"employee\" type=\"xsd:string\"/>" +
+
+ "<xsd:complexType name=\"Company\">" +
+ "<xsd:sequence>" +
+ "<xsd:element name=\"openCompany\" type=\"getList:OpenCompany\"/>" +
+ "<xsd:element name=\"closeCompany\" type=\"getList:CloseCompany\"/>" +
+ "</xsd:sequence>" +
+ "</xsd:complexType>" +
+
+ "<xsd:complexType name=\"OpenCompany\">" +
+ "<xsd:sequence>" +
+ "<xsd:element name=\"company\" type=\"xsd:string\"/>" +
+ "<xsd:element name=\"employees\" maxOccurs=\"unbounded\" type=\"xsd:string\"/>" +
+ "<xsd:any maxOccurs=\"unbounded\" namespace=\"##any\"/>" +
+ "</xsd:sequence>" +
+ "</xsd:complexType>" +
+
+ "<xsd:complexType name=\"CloseCompany\">" +
+ "<xsd:sequence>" +
+ "<xsd:element name=\"company\" type=\"xsd:string\"/>" +
+ "<xsd:element name=\"employees\" maxOccurs=\"unbounded\" type=\"xsd:string\"/>" +
+ "</xsd:sequence>" +
+ "</xsd:complexType>" +
+
+ "</xsd:schema>";
+
+ /**
+ * Test DataObject.getList() on open type
+ */
+ public void testUnknownPropertyOnOpenType() throws IOException {
+ String companyName = companyDataObject.getString("openCompany/company");
+ assertEquals(companyName, "OpenCompany");
+ List unknownProperty = companyDataObject.getList("openCompany/unknownProperty");
+ assertNotNull(unknownProperty);
+ assertTrue(unknownProperty instanceof List);
+
+ List unknownProperty2 = companyDataObject.getList("openCompany/unknownProperty");
+ assertNotNull(unknownProperty2);
+ assertTrue(unknownProperty2 instanceof List);
+
+ // unknownProperty and unknownProperty2 are in fact the same value for the same property
+
+ unknownProperty.add("employee1");
+ assertTrue(unknownProperty.size() == 1);
+
+ unknownProperty2.add("employee2");
+ assertTrue(unknownProperty2.size() == 2);
+
+ unknownProperty.remove(0);
+ assertTrue(unknownProperty.size() == 1);
+
+ assertEquals(unknownProperty.get(0), "employee2");
+ }
+
+ /**
+ * Test DataObject.getList() on non-open type
+ */
+ public void testUnknownPropertyOnClosedType() throws IOException {
+ String companyName = companyDataObject.getString("closeCompany/company");
+ assertEquals(companyName, "CloseCompany");
+ List unknownProperty = companyDataObject.getList("closeCompany/unknownProperty");
+ assertNotNull(unknownProperty);
+ assertTrue(unknownProperty instanceof List);
+
+ try {
+ unknownProperty.add("employee1");
+ fail("An exception should have been thrown.");
+ }
+ catch (Exception e) {
+ }
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ hc = SDOUtil.createHelperContext();
+ hc.getXSDHelper().define(xsdString);
+
+ companyDataObject = hc.getDataFactory().create(TEST_NAMESPACE, "Company");
+ DataObject openCompany = companyDataObject.createDataObject("openCompany");
+ openCompany.setString("company", "OpenCompany");
+ DataObject closeCompany = companyDataObject.createDataObject("closeCompany");
+ closeCompany.setString("company", "CloseCompany");
+ }
+}
diff --git a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineOpenContentPropertyTestCase.java b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineOpenContentPropertyTestCase.java
index bbbad11f53..f6afd5c458 100644
--- a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineOpenContentPropertyTestCase.java
+++ b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DefineOpenContentPropertyTestCase.java
@@ -1,133 +1,133 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sdo.test;
-
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigDecimal;
-import java.net.URL;
-
-import org.apache.tuscany.sdo.util.SDOUtil;
-
-import commonj.sdo.DataObject;
-import commonj.sdo.Property;
-import commonj.sdo.Type;
-import commonj.sdo.helper.DataFactory;
-import commonj.sdo.helper.HelperContext;
-import commonj.sdo.helper.TypeHelper;
-import commonj.sdo.helper.XMLHelper;
-import commonj.sdo.helper.XSDHelper;
-import junit.framework.TestCase;
-
-
-public class DefineOpenContentPropertyTestCase extends TestCase {
- private final String TEST_MODEL = "/open.xsd";
- private final String TEST_NAMESPACE = "http://www.example.com/open";
- private final String TEST_DATA = "/openContentProperty.xml";
-
- private TypeHelper typeHelper;
- private XSDHelper xsdHelper;
- private XMLHelper xmlHelper;
- private DataFactory dataFactory;
-
- public void testDefineOpenContentProperty() throws IOException {
- Type quoteType = typeHelper.getType(TEST_NAMESPACE, "OpenQuote");
- DataObject quote = dataFactory.create(quoteType);
-
- Property symbolProperty = quoteType.getProperty("symbol");
- assertFalse(symbolProperty.isOpenContent());
-
- quote.setString(symbolProperty, "s1");
-
- Property companyProperty = typeHelper.getOpenContentProperty(TEST_NAMESPACE, "company");
- assertTrue(companyProperty.isOpenContent());
-
- DataObject company = quote.createDataObject(companyProperty);
- company.setString("name", "FlyByNightTechnology");
-
- Property priceProperty = typeHelper.getOpenContentProperty(TEST_NAMESPACE, "price");
- assertTrue(priceProperty.isOpenContent());
-
- quote.getList(priceProperty).add(new BigDecimal("1000.0"));
-
- // Define a new SDO open content property with simple type
- DataObject p = dataFactory.create("commonj.sdo", "Property");
- p.set("type", typeHelper.getType("commonj.sdo", "Decimal"));
- p.set("name", "highPrice");
- Property highPrice = typeHelper.defineOpenContentProperty(TEST_NAMESPACE, p);
- assertTrue(highPrice.isOpenContent());
-
- quote.setBigDecimal(highPrice, new BigDecimal("1100.0"));
-
- // Define a new SDO open content property with complex type
- DataObject mutualFundQuotePropertyDef = dataFactory.create("commonj.sdo", "Property");
- mutualFundQuotePropertyDef.set("type", quoteType);
- mutualFundQuotePropertyDef.set("name", "mutualFundQuote");
- mutualFundQuotePropertyDef.setBoolean("containment", true);
- Property mutualFundQuoteProperty = typeHelper.defineOpenContentProperty(TEST_NAMESPACE, mutualFundQuotePropertyDef);
- assertTrue(mutualFundQuoteProperty.isOpenContent());
-
- DataObject mutualFundQuote = quote.createDataObject(mutualFundQuoteProperty);
- mutualFundQuote.setString("symbol", "mutual-1");
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- xmlHelper.save(quote, TEST_NAMESPACE, "openStockQuote", baos);
-
- assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(TEST_DATA)));
-
- // validate existing property condition
- Property duplicateProp = typeHelper.defineOpenContentProperty(TEST_NAMESPACE, p);
- assertTrue(highPrice.equals(duplicateProp));
-
- // validate error condition, where new property exists with different type
- boolean errorCondition = false;
- try
- {
- p = dataFactory.create("commonj.sdo", "Property");
- p.set("type", typeHelper.getType("commonj.sdo", "String"));
- p.set("name", "highPrice");
- highPrice = typeHelper.defineOpenContentProperty(TEST_NAMESPACE, p);
- }
- catch( IllegalArgumentException ex )
- {
- errorCondition = true;
- }
- assertTrue(errorCondition);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
-
- HelperContext hc = SDOUtil.createHelperContext();
- typeHelper = hc.getTypeHelper();
- dataFactory = hc.getDataFactory();
- xsdHelper = hc.getXSDHelper();
- xmlHelper = hc.getXMLHelper();
-
- // Populate the meta data for the test (Stock Quote) model
- URL url = getClass().getResource(TEST_MODEL);
- InputStream inputStream = url.openStream();
- xsdHelper.define(inputStream, url.toString());
- inputStream.close();
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.test;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.net.URL;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Property;
+import commonj.sdo.Type;
+import commonj.sdo.helper.DataFactory;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLHelper;
+import commonj.sdo.helper.XSDHelper;
+import junit.framework.TestCase;
+
+
+public class DefineOpenContentPropertyTestCase extends TestCase {
+ private final String TEST_MODEL = "/open.xsd";
+ private final String TEST_NAMESPACE = "http://www.example.com/open";
+ private final String TEST_DATA = "/openContentProperty.xml";
+
+ private TypeHelper typeHelper;
+ private XSDHelper xsdHelper;
+ private XMLHelper xmlHelper;
+ private DataFactory dataFactory;
+
+ public void testDefineOpenContentProperty() throws IOException {
+ Type quoteType = typeHelper.getType(TEST_NAMESPACE, "OpenQuote");
+ DataObject quote = dataFactory.create(quoteType);
+
+ Property symbolProperty = quoteType.getProperty("symbol");
+ assertFalse(symbolProperty.isOpenContent());
+
+ quote.setString(symbolProperty, "s1");
+
+ Property companyProperty = typeHelper.getOpenContentProperty(TEST_NAMESPACE, "company");
+ assertTrue(companyProperty.isOpenContent());
+
+ DataObject company = quote.createDataObject(companyProperty);
+ company.setString("name", "FlyByNightTechnology");
+
+ Property priceProperty = typeHelper.getOpenContentProperty(TEST_NAMESPACE, "price");
+ assertTrue(priceProperty.isOpenContent());
+
+ quote.getList(priceProperty).add(new BigDecimal("1000.0"));
+
+ // Define a new SDO open content property with simple type
+ DataObject p = dataFactory.create("commonj.sdo", "Property");
+ p.set("type", typeHelper.getType("commonj.sdo", "Decimal"));
+ p.set("name", "highPrice");
+ Property highPrice = typeHelper.defineOpenContentProperty(TEST_NAMESPACE, p);
+ assertTrue(highPrice.isOpenContent());
+
+ quote.setBigDecimal(highPrice, new BigDecimal("1100.0"));
+
+ // Define a new SDO open content property with complex type
+ DataObject mutualFundQuotePropertyDef = dataFactory.create("commonj.sdo", "Property");
+ mutualFundQuotePropertyDef.set("type", quoteType);
+ mutualFundQuotePropertyDef.set("name", "mutualFundQuote");
+ mutualFundQuotePropertyDef.setBoolean("containment", true);
+ Property mutualFundQuoteProperty = typeHelper.defineOpenContentProperty(TEST_NAMESPACE, mutualFundQuotePropertyDef);
+ assertTrue(mutualFundQuoteProperty.isOpenContent());
+
+ DataObject mutualFundQuote = quote.createDataObject(mutualFundQuoteProperty);
+ mutualFundQuote.setString("symbol", "mutual-1");
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ xmlHelper.save(quote, TEST_NAMESPACE, "openStockQuote", baos);
+
+ assertTrue(TestUtil.equalXmlFiles(new ByteArrayInputStream(baos.toByteArray()), getClass().getResource(TEST_DATA)));
+
+ // validate existing property condition
+ Property duplicateProp = typeHelper.defineOpenContentProperty(TEST_NAMESPACE, p);
+ assertTrue(highPrice.equals(duplicateProp));
+
+ // validate error condition, where new property exists with different type
+ boolean errorCondition = false;
+ try
+ {
+ p = dataFactory.create("commonj.sdo", "Property");
+ p.set("type", typeHelper.getType("commonj.sdo", "String"));
+ p.set("name", "highPrice");
+ highPrice = typeHelper.defineOpenContentProperty(TEST_NAMESPACE, p);
+ }
+ catch( IllegalArgumentException ex )
+ {
+ errorCondition = true;
+ }
+ assertTrue(errorCondition);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ HelperContext hc = SDOUtil.createHelperContext();
+ typeHelper = hc.getTypeHelper();
+ dataFactory = hc.getDataFactory();
+ xsdHelper = hc.getXSDHelper();
+ xmlHelper = hc.getXMLHelper();
+
+ // Populate the meta data for the test (Stock Quote) model
+ URL url = getClass().getResource(TEST_MODEL);
+ InputStream inputStream = url.openStream();
+ xsdHelper.define(inputStream, url.toString());
+ inputStream.close();
+ }
+}
diff --git a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DeserializationNoSchemaTestCase.java b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DeserializationNoSchemaTestCase.java
index 5bde232a72..65a838bb52 100644
--- a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DeserializationNoSchemaTestCase.java
+++ b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DeserializationNoSchemaTestCase.java
@@ -1,124 +1,124 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * 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.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.net.URL;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sdo.util.SDOUtil;
-
-import commonj.sdo.DataObject;
-import commonj.sdo.helper.HelperContext;
-import commonj.sdo.helper.TypeHelper;
-import commonj.sdo.helper.XMLDocument;
-import commonj.sdo.helper.XMLHelper;
-
-
-public class DeserializationNoSchemaTestCase extends TestCase
-{
- HelperContext hc;
-
- TypeHelper th;
-
- private final String xmlStr =
- "<?xml version=\"1.0\" encoding=\"ASCII\"?> " +
- "<simple:stockQuote xmlns:simple=\"www.example.com/simple\"> " +
- "<symbol>fbnt</symbol> " +
- "<companyName>FlyByNightTechnology</companyName> " +
- "<price>1000.0</price> " +
- "<open1>1000.0</open1> " +
- "<high>1000.0</high> " +
- "<low>1000.0</low> " +
- "<volume>1000.0</volume> " +
- "<change1>1000.0</change1> " +
- "<quotes> " +
- "<price>2000.0</price> " +
- "</quotes> " +
- "</simple:stockQuote>";
-
- 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();
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.URL;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.util.SDOUtil;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+import commonj.sdo.helper.XMLDocument;
+import commonj.sdo.helper.XMLHelper;
+
+
+public class DeserializationNoSchemaTestCase extends TestCase
+{
+ HelperContext hc;
+
+ TypeHelper th;
+
+ private final String xmlStr =
+ "<?xml version=\"1.0\" encoding=\"ASCII\"?> " +
+ "<simple:stockQuote xmlns:simple=\"www.example.com/simple\"> " +
+ "<symbol>fbnt</symbol> " +
+ "<companyName>FlyByNightTechnology</companyName> " +
+ "<price>1000.0</price> " +
+ "<open1>1000.0</open1> " +
+ "<high>1000.0</high> " +
+ "<low>1000.0</low> " +
+ "<volume>1000.0</volume> " +
+ "<change1>1000.0</change1> " +
+ "<quotes> " +
+ "<price>2000.0</price> " +
+ "</quotes> " +
+ "</simple:stockQuote>";
+
+ 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/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DupElementTestCase.java b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DupElementTestCase.java
index 3fa8b7fb04..9c4f487b6a 100644
--- a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DupElementTestCase.java
+++ b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DupElementTestCase.java
@@ -1,99 +1,99 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sdo.test;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.List;
-//import java.util.regex.MatchResult;
-//import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import junit.framework.TestCase;
-
-import org.apache.tuscany.sdo.api.SDOUtil;
-
-import commonj.sdo.DataObject;
-import commonj.sdo.Type;
-import commonj.sdo.helper.HelperContext;
-
-public class DupElementTestCase extends TestCase {
- HelperContext hc;
-
- private final String TEST_MODEL = "/dupelement.xsd";
- private final String TEST_URI = "http://www.example.com/dupelement";
-
- protected void setUp() throws Exception {
- super.setUp();
-
- URL url = getClass().getResource(TEST_MODEL);
- InputStream inputStream = url.openStream();
-
- hc = SDOUtil.createHelperContext();
-
- hc.getXSDHelper().define(inputStream, url.toString());
-
- inputStream.close();
- }
-
-
- public void test() {
- Type quoteType = hc.getTypeHelper().getType(TEST_URI, "Quote");
-
- DataObject quote = hc.getDataFactory().create(quoteType);
- quote.set("symbol", "ACME");
- quote.set("companyName", "ACME Corp.");
-
- DataObject quote2 = hc.getDataFactory().create(quoteType);
-
- List quotes = quote.getList("quotes");
- quotes.add(quote2);
-
- try {
- quote.set("quotes.0/symbol", "ACME-CHILD");
- quote.set("quotes.0/companyName", "ACME subsidiary corp.");
- quote.setInt("quotes.0/companyNameInInt", 99);
- quote.setInt("quotes.0/symbolInInt", 55);
- }
- catch (Exception e) {
- fail("Set value on the wrong properties with the same name");
- }
- assert(quote.get("quotes.0/companyName") instanceof String);
- assert(quote.get("quotes.0/symbol") instanceof String);
- assert(quote.get("quotes.0/companyNameInInt") instanceof Integer);
- assert(quote.get("quotes.0/symbolInInt") instanceof Integer);
-
- String doc = hc.getXMLHelper().save(quote, "http://www.example.com/dupelement", "stockQuote");
- //System.out.println(doc);
- assertTrue(
- Pattern.matches("[\\s\\S]*<companyName>[\\s]*ACME Corp.[\\s]*</companyName>[\\s\\S]*",
- doc));
- assertTrue(
- Pattern.matches("[\\s\\S]*<companyName>[\\s]*99[\\s]*</companyName>[\\s\\S]*",
- doc));
- assertTrue(
- Pattern.matches("[\\s\\S]*symbol[\\s]*=[\\s]*\"55\"[\\s\\S]*",
- doc));
- assertTrue(
- Pattern.matches("[\\s\\S]*<symbol>[\\s]*ACME-CHILD[\\s]*</symbol>[\\s\\S]*",
- doc));
-
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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 java.util.regex.MatchResult;
+//import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+
+public class DupElementTestCase extends TestCase {
+ HelperContext hc;
+
+ private final String TEST_MODEL = "/dupelement.xsd";
+ private final String TEST_URI = "http://www.example.com/dupelement";
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ URL url = getClass().getResource(TEST_MODEL);
+ InputStream inputStream = url.openStream();
+
+ hc = SDOUtil.createHelperContext();
+
+ hc.getXSDHelper().define(inputStream, url.toString());
+
+ inputStream.close();
+ }
+
+
+ public void test() {
+ Type quoteType = hc.getTypeHelper().getType(TEST_URI, "Quote");
+
+ DataObject quote = hc.getDataFactory().create(quoteType);
+ quote.set("symbol", "ACME");
+ quote.set("companyName", "ACME Corp.");
+
+ DataObject quote2 = hc.getDataFactory().create(quoteType);
+
+ List quotes = quote.getList("quotes");
+ quotes.add(quote2);
+
+ try {
+ quote.set("quotes.0/symbol", "ACME-CHILD");
+ quote.set("quotes.0/companyName", "ACME subsidiary corp.");
+ quote.setInt("quotes.0/companyNameInInt", 99);
+ quote.setInt("quotes.0/symbolInInt", 55);
+ }
+ catch (Exception e) {
+ fail("Set value on the wrong properties with the same name");
+ }
+ assert(quote.get("quotes.0/companyName") instanceof String);
+ assert(quote.get("quotes.0/symbol") instanceof String);
+ assert(quote.get("quotes.0/companyNameInInt") instanceof Integer);
+ assert(quote.get("quotes.0/symbolInInt") instanceof Integer);
+
+ String doc = hc.getXMLHelper().save(quote, "http://www.example.com/dupelement", "stockQuote");
+ //System.out.println(doc);
+ assertTrue(
+ Pattern.matches("[\\s\\S]*<companyName>[\\s]*ACME Corp.[\\s]*</companyName>[\\s\\S]*",
+ doc));
+ assertTrue(
+ Pattern.matches("[\\s\\S]*<companyName>[\\s]*99[\\s]*</companyName>[\\s\\S]*",
+ doc));
+ assertTrue(
+ Pattern.matches("[\\s\\S]*symbol[\\s]*=[\\s]*\"55\"[\\s\\S]*",
+ doc));
+ assertTrue(
+ Pattern.matches("[\\s\\S]*<symbol>[\\s]*ACME-CHILD[\\s]*</symbol>[\\s\\S]*",
+ doc));
+
+ }
+}
diff --git a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DynamicTypesComparisonTestCase.java b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DynamicTypesComparisonTestCase.java
index 1a9deaf775..4c347867e0 100644
--- a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DynamicTypesComparisonTestCase.java
+++ b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/DynamicTypesComparisonTestCase.java
@@ -1,256 +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 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<xsd:schema\n"
- + " targetNamespace=\"http://www.example.com/dynamicTypesFromSchemaSimple\"\n"
- + " xmlns:dtfs=\"http://www.example.com/dynamicTypesFromSchemaSimple\"\n"
- + " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n" + " \n"
- + " <xsd:complexType name=\"TestType0\" mixed=\"true\">\n" + " <xsd:sequence>\n"
- + " <xsd:element name=\"aString\" minOccurs=\"0\" maxOccurs=\"unbounded\" type=\"xsd:string\"/>\n"
- + " <xsd:element name=\"aBoolean\" minOccurs=\"0\" maxOccurs=\"unbounded\" type=\"xsd:boolean\"/>\n"
- + " <xsd:element name=\"aFloat\" minOccurs=\"0\" maxOccurs=\"unbounded\" type=\"xsd:float\"/>\n"
- + " </xsd:sequence>\n" + " </xsd:complexType>\n" + " \n"
- + " <xsd:element name=\"testElement0\" type=\"dtfs:TestType0\"/>\n" + " \n" + "</xsd:schema>\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 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- + "<dtfs:testElement0 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
- + " xmlns:dtfs=\"http://www.example.com/dynamicTypesFromSchemaSimple\">\n"
- + " <aString>This is a repeated string.</aString>\n" + " <aString>This is a repeated string.</aString>\n"
- + " <aBoolean>true</aBoolean>\n" + " <aBoolean>false</aBoolean>\n" + " <aBoolean>true</aBoolean>\n"
- + " <aBoolean>1</aBoolean>\n" + " <aBoolean>0</aBoolean>\n" + " <aFloat>0</aFloat>\n"
- + " <aFloat>12.5</aFloat>\n" + " <aFloat>0</aFloat>\n" + "</dtfs:testElement0>\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);
- }
- }
- }
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<xsd:schema\n"
+ + " targetNamespace=\"http://www.example.com/dynamicTypesFromSchemaSimple\"\n"
+ + " xmlns:dtfs=\"http://www.example.com/dynamicTypesFromSchemaSimple\"\n"
+ + " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">\n" + " \n"
+ + " <xsd:complexType name=\"TestType0\" mixed=\"true\">\n" + " <xsd:sequence>\n"
+ + " <xsd:element name=\"aString\" minOccurs=\"0\" maxOccurs=\"unbounded\" type=\"xsd:string\"/>\n"
+ + " <xsd:element name=\"aBoolean\" minOccurs=\"0\" maxOccurs=\"unbounded\" type=\"xsd:boolean\"/>\n"
+ + " <xsd:element name=\"aFloat\" minOccurs=\"0\" maxOccurs=\"unbounded\" type=\"xsd:float\"/>\n"
+ + " </xsd:sequence>\n" + " </xsd:complexType>\n" + " \n"
+ + " <xsd:element name=\"testElement0\" type=\"dtfs:TestType0\"/>\n" + " \n" + "</xsd:schema>\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 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<dtfs:testElement0 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
+ + " xmlns:dtfs=\"http://www.example.com/dynamicTypesFromSchemaSimple\">\n"
+ + " <aString>This is a repeated string.</aString>\n" + " <aString>This is a repeated string.</aString>\n"
+ + " <aBoolean>true</aBoolean>\n" + " <aBoolean>false</aBoolean>\n" + " <aBoolean>true</aBoolean>\n"
+ + " <aBoolean>1</aBoolean>\n" + " <aBoolean>0</aBoolean>\n" + " <aFloat>0</aFloat>\n"
+ + " <aFloat>12.5</aFloat>\n" + " <aFloat>0</aFloat>\n" + "</dtfs:testElement0>\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/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ExpectedExceptionsTestCase.java b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ExpectedExceptionsTestCase.java
index 7674cda42b..af4bb4d928 100644
--- a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ExpectedExceptionsTestCase.java
+++ b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/ExpectedExceptionsTestCase.java
@@ -1,1878 +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<T>(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<T>(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<T>(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);
- }
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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<T>(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<T>(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<T>(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/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/JavaSerializeDeserializeTestCase.java b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/JavaSerializeDeserializeTestCase.java
index 56a293cde0..df69555d76 100644
--- a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/JavaSerializeDeserializeTestCase.java
+++ b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/JavaSerializeDeserializeTestCase.java
@@ -1,297 +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 = "<xsd:schema targetNamespace=\"http://www.example.com/simple\" " +
- "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
- "xmlns:simple=\"http://www.example.com/simple\">" +
- "<xsd:element name=\"company\" type=\"simple:Company\"/>" +
- "<xsd:complexType name=\"Company\">" +
- "<xsd:sequence>" +
- "<xsd:element name=\"symbol\" type=\"xsd:string\"/>" +
- "<xsd:element name=\"companyName\" type=\"xsd:string\"/>" +
- "<xsd:element name=\"employees\" type=\"simple:Employee\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>" +
- "</xsd:sequence>" +
- "</xsd:complexType>" +
-
- "<xsd:complexType name=\"Employee\">" +
- "<xsd:sequence>" +
- "<xsd:element name=\"employeeID\" type=\"xsd:string\"/>" +
- "<xsd:element name=\"employeeName\" type=\"xsd:string\"/>" +
- "</xsd:sequence>" +
- "</xsd:complexType>" +
- "</xsd:schema>";
-
- 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<Type> 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;
-
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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 = "<xsd:schema targetNamespace=\"http://www.example.com/simple\" " +
+ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
+ "xmlns:simple=\"http://www.example.com/simple\">" +
+ "<xsd:element name=\"company\" type=\"simple:Company\"/>" +
+ "<xsd:complexType name=\"Company\">" +
+ "<xsd:sequence>" +
+ "<xsd:element name=\"symbol\" type=\"xsd:string\"/>" +
+ "<xsd:element name=\"companyName\" type=\"xsd:string\"/>" +
+ "<xsd:element name=\"employees\" type=\"simple:Employee\" minOccurs=\"0\" maxOccurs=\"unbounded\"/>" +
+ "</xsd:sequence>" +
+ "</xsd:complexType>" +
+
+ "<xsd:complexType name=\"Employee\">" +
+ "<xsd:sequence>" +
+ "<xsd:element name=\"employeeID\" type=\"xsd:string\"/>" +
+ "<xsd:element name=\"employeeName\" type=\"xsd:string\"/>" +
+ "</xsd:sequence>" +
+ "</xsd:complexType>" +
+ "</xsd:schema>";
+
+ 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<Type> 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/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MetadataInstancePropertiesTestCase.java b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MetadataInstancePropertiesTestCase.java
index 4bb0f3a061..885153b62e 100644
--- a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MetadataInstancePropertiesTestCase.java
+++ b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/MetadataInstancePropertiesTestCase.java
@@ -1,243 +1,243 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * 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);
- }
-
- //Amita
- public void testEnumProperty()
- {
- Type type = typeHelper.getType(TEST_NAMESPACE, "ExampleRating");
- assertTrue(getInstanceProperty(type, "enumeration") != null);
- List enumFacet = SDOUtil.getEnumerationFacet(type);
- assertEquals(3, enumFacet.size());
- assertEquals("", enumFacet.get(0));
- assertEquals("Good", enumFacet.get(1));
- assertEquals("Bad", enumFacet.get(2));
- }
-
- //Amita
- public void testPatternProperty()
- {
- Type type = typeHelper.getType(TEST_NAMESPACE, "PhoneNumber");
- assertTrue(getInstanceProperty(type, "pattern") != null);
- List patternFacet = SDOUtil.getPatternFacet(type);
- assertEquals(2, patternFacet.size());
- assertEquals("\\d{3}-\\d{4}", patternFacet.get(0));
- assertEquals("\\d{6}-\\d{8}", patternFacet.get(1));
- }
-
- 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("**************************************");
- }
- }
-
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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);
+ }
+
+ //Amita
+ public void testEnumProperty()
+ {
+ Type type = typeHelper.getType(TEST_NAMESPACE, "ExampleRating");
+ assertTrue(getInstanceProperty(type, "enumeration") != null);
+ List enumFacet = SDOUtil.getEnumerationFacet(type);
+ assertEquals(3, enumFacet.size());
+ assertEquals("", enumFacet.get(0));
+ assertEquals("Good", enumFacet.get(1));
+ assertEquals("Bad", enumFacet.get(2));
+ }
+
+ //Amita
+ public void testPatternProperty()
+ {
+ Type type = typeHelper.getType(TEST_NAMESPACE, "PhoneNumber");
+ assertTrue(getInstanceProperty(type, "pattern") != null);
+ List patternFacet = SDOUtil.getPatternFacet(type);
+ assertEquals(2, patternFacet.size());
+ assertEquals("\\d{3}-\\d{4}", patternFacet.get(0));
+ assertEquals("\\d{6}-\\d{8}", patternFacet.get(1));
+ }
+
+ 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/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/NeverStaleChangeSummaryTestCase.java b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/NeverStaleChangeSummaryTestCase.java
index 69c8e447df..544672a8b1 100644
--- a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/NeverStaleChangeSummaryTestCase.java
+++ b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/NeverStaleChangeSummaryTestCase.java
@@ -1,76 +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();
- }
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/NotificationTestCase.java b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/NotificationTestCase.java
index 65765bd2d1..5d1637865b 100644
--- a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/NotificationTestCase.java
+++ b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/NotificationTestCase.java
@@ -1,186 +1,186 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * 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 junit.framework.TestCase;
-
-import org.apache.tuscany.sdo.api.SDOUtil;
-import org.apache.tuscany.sdo.api.Event;
-import org.apache.tuscany.sdo.impl.ListenerBase;
-
-import commonj.sdo.DataObject;
-import commonj.sdo.Type;
-import commonj.sdo.helper.HelperContext;
-import commonj.sdo.helper.TypeHelper;
-
-/**
- * Test DataObject Property value change notification
- */
-public class NotificationTestCase extends TestCase {
-
- HelperContext hc;
- TypeHelper th;
-
- private class Observer extends ListenerBase {
-
- private int notificationCount;
- private Event lastEvent;
-
- public int getNotificationCount() {
- return notificationCount;
- }
-
- public Event getLastEvent() {
- return lastEvent;
- }
-
- public Observer() {
- notificationCount = 0;
- }
-
- public void eventNotification(Event e) {
-
- if (e.getEventType() != Event.REMOVE_LISTENER) {
- notificationCount++;
- lastEvent = e;
- }
- }
-
- }
-
- public void testTransitions() throws IOException {
- final String TEST_MODEL = "/simple.xsd";
- final String TEST_NAMESPACE = "http://www.example.com/simple";
-
- // 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();
-
- Type quoteType = th.getType(TEST_NAMESPACE, "Quote");
- DataObject quote = hc.getDataFactory().create(quoteType);
- Observer o = new Observer();
- SDOUtil.addChangeListener(quote, o);
-
- Event e;
-
- String firstName = "FlyByNightTechnology";
-
- int changeCount = 0;
-
- quote.setString("companyName", firstName);
- assertEquals(++changeCount, o.getNotificationCount());
- e = o.getLastEvent();
- assertEquals(Event.SET, e.getEventType());
- assertEquals(null, e.getOldValue());
- assertFalse(e.wasSet());
-
- quote.setString("companyName", "FBNT");
- e = o.getLastEvent();
- assertTrue(e.wasSet());
-
- assertEquals(firstName, e.getOldValue());
- assertEquals(++changeCount, o.getNotificationCount());
- assertEquals("companyName", e.getProperty().getName());
-
- SDOUtil.removeChangeListener(quote, o);
-
- quote.setString("companyName", "3rdValue");
- e = o.getLastEvent();
-
- assertEquals(firstName, e.getOldValue());
- assertEquals(changeCount /* no ++ */, o.getNotificationCount());
-
- SDOUtil.addChangeListener(quote, o);
-
- quote.setString("companyName", "3rdValue");
- assertEquals(++changeCount, o.getNotificationCount());
- e = o.getLastEvent();
- assertTrue(e.isTouch());
- assertTrue(e.wasSet());
-
- quote.unset("companyName");
- assertEquals(++changeCount, o.getNotificationCount());
- e = o.getLastEvent();
- assertTrue(e.wasSet());
-
-
- quote.set("companyName", "4thValue");
- assertEquals(++changeCount, o.getNotificationCount());
- e = o.getLastEvent();
- assertFalse(e.wasSet());
-
- assertEquals(Event.NO_INDEX, e.getPosition());
-
- DataObject child = quote.createDataObject("quotes");
- assertEquals(++changeCount, o.getNotificationCount());
- e = o.getLastEvent();
- assertFalse(e.wasSet());
- assertEquals(0, e.getPosition());
- assertEquals(Event.ADD, e.getEventType());
-
- DataObject child2 = quote.createDataObject("quotes");
- assertEquals(++changeCount, o.getNotificationCount());
- e = o.getLastEvent();
- assertTrue(e.wasSet()); // the quotes property was previously set to a non empty list
- assertEquals(1, e.getPosition());
-
- child2.setString("companyName", "subsidiary");
-
- assertEquals(changeCount /* no ++ */, o.getNotificationCount()); // not monitoring the child
-
- quote.getList("quotes").clear();
- e = o.getLastEvent();
- assertEquals(++changeCount, o.getNotificationCount());
- assertEquals(Event.REMOVE_MANY, e.getEventType());
-
- List newList = new ArrayList();
-
- newList.add(hc.getDataFactory().create(quoteType));
- newList.add(hc.getDataFactory().create(quoteType));
-
- quote.getList("quotes").addAll(newList);
- e = o.getLastEvent();
- assertEquals(++changeCount, o.getNotificationCount());
- assertEquals(Event.ADD_MANY, e.getEventType());
-
-
-
-
- }
-
-
- protected void setUp() throws Exception {
- super.setUp();
-
- hc = SDOUtil.createHelperContext();
- th = hc.getTypeHelper();
-
- }
-
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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 junit.framework.TestCase;
+
+import org.apache.tuscany.sdo.api.SDOUtil;
+import org.apache.tuscany.sdo.api.Event;
+import org.apache.tuscany.sdo.impl.ListenerBase;
+
+import commonj.sdo.DataObject;
+import commonj.sdo.Type;
+import commonj.sdo.helper.HelperContext;
+import commonj.sdo.helper.TypeHelper;
+
+/**
+ * Test DataObject Property value change notification
+ */
+public class NotificationTestCase extends TestCase {
+
+ HelperContext hc;
+ TypeHelper th;
+
+ private class Observer extends ListenerBase {
+
+ private int notificationCount;
+ private Event lastEvent;
+
+ public int getNotificationCount() {
+ return notificationCount;
+ }
+
+ public Event getLastEvent() {
+ return lastEvent;
+ }
+
+ public Observer() {
+ notificationCount = 0;
+ }
+
+ public void eventNotification(Event e) {
+
+ if (e.getEventType() != Event.REMOVE_LISTENER) {
+ notificationCount++;
+ lastEvent = e;
+ }
+ }
+
+ }
+
+ public void testTransitions() throws IOException {
+ final String TEST_MODEL = "/simple.xsd";
+ final String TEST_NAMESPACE = "http://www.example.com/simple";
+
+ // 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();
+
+ Type quoteType = th.getType(TEST_NAMESPACE, "Quote");
+ DataObject quote = hc.getDataFactory().create(quoteType);
+ Observer o = new Observer();
+ SDOUtil.addChangeListener(quote, o);
+
+ Event e;
+
+ String firstName = "FlyByNightTechnology";
+
+ int changeCount = 0;
+
+ quote.setString("companyName", firstName);
+ assertEquals(++changeCount, o.getNotificationCount());
+ e = o.getLastEvent();
+ assertEquals(Event.SET, e.getEventType());
+ assertEquals(null, e.getOldValue());
+ assertFalse(e.wasSet());
+
+ quote.setString("companyName", "FBNT");
+ e = o.getLastEvent();
+ assertTrue(e.wasSet());
+
+ assertEquals(firstName, e.getOldValue());
+ assertEquals(++changeCount, o.getNotificationCount());
+ assertEquals("companyName", e.getProperty().getName());
+
+ SDOUtil.removeChangeListener(quote, o);
+
+ quote.setString("companyName", "3rdValue");
+ e = o.getLastEvent();
+
+ assertEquals(firstName, e.getOldValue());
+ assertEquals(changeCount /* no ++ */, o.getNotificationCount());
+
+ SDOUtil.addChangeListener(quote, o);
+
+ quote.setString("companyName", "3rdValue");
+ assertEquals(++changeCount, o.getNotificationCount());
+ e = o.getLastEvent();
+ assertTrue(e.isTouch());
+ assertTrue(e.wasSet());
+
+ quote.unset("companyName");
+ assertEquals(++changeCount, o.getNotificationCount());
+ e = o.getLastEvent();
+ assertTrue(e.wasSet());
+
+
+ quote.set("companyName", "4thValue");
+ assertEquals(++changeCount, o.getNotificationCount());
+ e = o.getLastEvent();
+ assertFalse(e.wasSet());
+
+ assertEquals(Event.NO_INDEX, e.getPosition());
+
+ DataObject child = quote.createDataObject("quotes");
+ assertEquals(++changeCount, o.getNotificationCount());
+ e = o.getLastEvent();
+ assertFalse(e.wasSet());
+ assertEquals(0, e.getPosition());
+ assertEquals(Event.ADD, e.getEventType());
+
+ DataObject child2 = quote.createDataObject("quotes");
+ assertEquals(++changeCount, o.getNotificationCount());
+ e = o.getLastEvent();
+ assertTrue(e.wasSet()); // the quotes property was previously set to a non empty list
+ assertEquals(1, e.getPosition());
+
+ child2.setString("companyName", "subsidiary");
+
+ assertEquals(changeCount /* no ++ */, o.getNotificationCount()); // not monitoring the child
+
+ quote.getList("quotes").clear();
+ e = o.getLastEvent();
+ assertEquals(++changeCount, o.getNotificationCount());
+ assertEquals(Event.REMOVE_MANY, e.getEventType());
+
+ List newList = new ArrayList();
+
+ newList.add(hc.getDataFactory().create(quoteType));
+ newList.add(hc.getDataFactory().create(quoteType));
+
+ quote.getList("quotes").addAll(newList);
+ e = o.getLastEvent();
+ assertEquals(++changeCount, o.getNotificationCount());
+ assertEquals(Event.ADD_MANY, e.getEventType());
+
+
+
+
+ }
+
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ hc = SDOUtil.createHelperContext();
+ th = hc.getTypeHelper();
+
+ }
+
+}
diff --git a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SequenceTestCase.java b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SequenceTestCase.java
index b547f45d1c..e02ace5d2a 100644
--- a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SequenceTestCase.java
+++ b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SequenceTestCase.java
@@ -1,100 +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 = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"testNS\" xmlns:tns=\"testNS\">"+
- "<element name=\"open\" type=\"string\"/>"+
- "<complexType name=\"Sequenced\">"+
- "<sequence>"+
- "<element name=\"localA\" type=\"string\" maxOccurs=\"unbounded\"/>"+
- "<choice maxOccurs=\"unbounded\">"+
- "<element name=\"choiceX\" type=\"string\"/>"+
- "<element name=\"choiceY\" type=\"string\"/>"+
- "</choice>"+
- "<element name=\"localB\" type=\"string\"/>"+
- "<any namespace=\"##any\" maxOccurs=\"unbounded\"/>"+
- "</sequence>"+
- "<anyAttribute/>"+
- "</complexType>"+
- "</schema>";
-
- 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");
- }
-
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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 = "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"testNS\" xmlns:tns=\"testNS\">"+
+ "<element name=\"open\" type=\"string\"/>"+
+ "<complexType name=\"Sequenced\">"+
+ "<sequence>"+
+ "<element name=\"localA\" type=\"string\" maxOccurs=\"unbounded\"/>"+
+ "<choice maxOccurs=\"unbounded\">"+
+ "<element name=\"choiceX\" type=\"string\"/>"+
+ "<element name=\"choiceY\" type=\"string\"/>"+
+ "</choice>"+
+ "<element name=\"localB\" type=\"string\"/>"+
+ "<any namespace=\"##any\" maxOccurs=\"unbounded\"/>"+
+ "</sequence>"+
+ "<anyAttribute/>"+
+ "</complexType>"+
+ "</schema>";
+
+ 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/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SerializeTypesTestCase.java b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SerializeTypesTestCase.java
index 7fe1196eb6..a8e00d5eb2 100644
--- a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SerializeTypesTestCase.java
+++ b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/SerializeTypesTestCase.java
@@ -1,190 +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 =
- "<xsd:schema targetNamespace=\"http://www.example.com/simple\" " +
- "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
- "xmlns:simple=\"http://www.example.com/simple\"> " +
- "<xsd:element name=\"bytesTypeTest\" type=\"simple:BytesTypeTest\"/> " +
- "<xsd:complexType name=\"BytesTypeTest\"> " +
- "<xsd:sequence> " +
- "<xsd:element name=\"base64Binary\" type=\"xsd:base64Binary\"/> " +
- "<xsd:element name=\"hexBinary\" type=\"xsd:hexBinary\"/> " +
- "</xsd:sequence> " +
- "</xsd:complexType> " +
- "</xsd:schema>";
-
-
- 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 = "<base64Binary>";
- String endTag = "</base64Binary>";
- 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 = "<hexBinary>";
- String endTag = "</hexBinary>";
- 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")));
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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 =
+ "<xsd:schema targetNamespace=\"http://www.example.com/simple\" " +
+ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" " +
+ "xmlns:simple=\"http://www.example.com/simple\"> " +
+ "<xsd:element name=\"bytesTypeTest\" type=\"simple:BytesTypeTest\"/> " +
+ "<xsd:complexType name=\"BytesTypeTest\"> " +
+ "<xsd:sequence> " +
+ "<xsd:element name=\"base64Binary\" type=\"xsd:base64Binary\"/> " +
+ "<xsd:element name=\"hexBinary\" type=\"xsd:hexBinary\"/> " +
+ "</xsd:sequence> " +
+ "</xsd:complexType> " +
+ "</xsd:schema>";
+
+
+ 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 = "<base64Binary>";
+ String endTag = "</base64Binary>";
+ 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 = "<hexBinary>";
+ String endTag = "</hexBinary>";
+ 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/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeHelperTestCase.java b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeHelperTestCase.java
index 8fad877d4b..60a484290f 100644
--- a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeHelperTestCase.java
+++ b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/TypeHelperTestCase.java
@@ -1,45 +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 );
- }
-
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLLoadOptionsTestCase.java b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLLoadOptionsTestCase.java
index ac8d04b683..d58b070a90 100644
--- a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLLoadOptionsTestCase.java
+++ b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLLoadOptionsTestCase.java
@@ -1,192 +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(
- "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"testNS\">"+
- "<element name=\"root\">"+
- "<complexType>"+
- "<sequence>"+
- "<element name=\"unqualifiedElement\" type=\"string\"/>"+
- "<element name=\"qualifiedElement\" form=\"qualified\" type=\"string\"/>"+
- "</sequence>"+
- "<attribute name=\"unqualifiedAttribute\" type=\"string\"/>"+
- "<attribute name=\"qualifiedAttribute\" form=\"qualified\" type=\"string\"/>"+
- "</complexType>"+
- "</element>"+
- "</schema>");
-
- final String xml="<p:root xmlns:p=\"testNS\">"+
- "<p:unqualifiedElement/>"+
-"</p:root>";
-
- /*
- * 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(
- "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"testNS\">"+
- "<element name=\"root\">"+
- "<complexType>"+
- "<sequence>"+
- "<element name=\"unqualifiedElement\" type=\"string\"/>"+
- "<element name=\"qualifiedElement\" form=\"qualified\" type=\"string\"/>"+
- "</sequence>"+
- "<attribute name=\"unqualifiedAttribute\" type=\"string\"/>"+
- "<attribute name=\"qualifiedAttribute\" form=\"qualified\" type=\"string\"/>"+
- "</complexType>"+
- "</element>"+
- "</schema>");
-
- final String xml="<p:root xmlns:p=\"testNS\" p:unqualifiedAttribute=\"u\" qualifiedAttribute=\"q\">"+
- "<p:unqualifiedElement/>"+
- "<qualifiedElement/>"+
- "</p:root>";
-
- /*
- * 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(
- "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"testNS\">"+
- "<element name=\"root\">"+
- "<complexType>"+
- "<sequence>"+
- "<element name=\"unqualifiedElement\" type=\"string\"/>"+
- "<element name=\"qualifiedElement\" form=\"qualified\" type=\"string\"/>"+
- "</sequence>"+
- "<attribute name=\"unqualifiedAttribute\" type=\"string\"/>"+
- "<attribute name=\"qualifiedAttribute\" form=\"qualified\" type=\"string\"/>"+
- "</complexType>"+
- "</element>"+
- "</schema>");
-
- final String xml="<p:root xmlns:p=\"testNS\" p:unqualifiedAttribute=\"u\" qualifiedAttribute=\"q\">"+
- "<p:unqualifiedElement/>"+
- "<qualifiedElement/>"+
- "</p:root>";
-
- 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);
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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(
+ "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"testNS\">"+
+ "<element name=\"root\">"+
+ "<complexType>"+
+ "<sequence>"+
+ "<element name=\"unqualifiedElement\" type=\"string\"/>"+
+ "<element name=\"qualifiedElement\" form=\"qualified\" type=\"string\"/>"+
+ "</sequence>"+
+ "<attribute name=\"unqualifiedAttribute\" type=\"string\"/>"+
+ "<attribute name=\"qualifiedAttribute\" form=\"qualified\" type=\"string\"/>"+
+ "</complexType>"+
+ "</element>"+
+ "</schema>");
+
+ final String xml="<p:root xmlns:p=\"testNS\">"+
+ "<p:unqualifiedElement/>"+
+"</p:root>";
+
+ /*
+ * 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(
+ "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"testNS\">"+
+ "<element name=\"root\">"+
+ "<complexType>"+
+ "<sequence>"+
+ "<element name=\"unqualifiedElement\" type=\"string\"/>"+
+ "<element name=\"qualifiedElement\" form=\"qualified\" type=\"string\"/>"+
+ "</sequence>"+
+ "<attribute name=\"unqualifiedAttribute\" type=\"string\"/>"+
+ "<attribute name=\"qualifiedAttribute\" form=\"qualified\" type=\"string\"/>"+
+ "</complexType>"+
+ "</element>"+
+ "</schema>");
+
+ final String xml="<p:root xmlns:p=\"testNS\" p:unqualifiedAttribute=\"u\" qualifiedAttribute=\"q\">"+
+ "<p:unqualifiedElement/>"+
+ "<qualifiedElement/>"+
+ "</p:root>";
+
+ /*
+ * 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(
+ "<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"testNS\">"+
+ "<element name=\"root\">"+
+ "<complexType>"+
+ "<sequence>"+
+ "<element name=\"unqualifiedElement\" type=\"string\"/>"+
+ "<element name=\"qualifiedElement\" form=\"qualified\" type=\"string\"/>"+
+ "</sequence>"+
+ "<attribute name=\"unqualifiedAttribute\" type=\"string\"/>"+
+ "<attribute name=\"qualifiedAttribute\" form=\"qualified\" type=\"string\"/>"+
+ "</complexType>"+
+ "</element>"+
+ "</schema>");
+
+ final String xml="<p:root xmlns:p=\"testNS\" p:unqualifiedAttribute=\"u\" qualifiedAttribute=\"q\">"+
+ "<p:unqualifiedElement/>"+
+ "<qualifiedElement/>"+
+ "</p:root>";
+
+ 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/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLSaveOptionsTestCase.java b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLSaveOptionsTestCase.java
index 49b4be48a9..27b750b0ff 100644
--- a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLSaveOptionsTestCase.java
+++ b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLSaveOptionsTestCase.java
@@ -1,147 +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+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +LINE_BREAK+
- MARGIN+ "<cs:stockQuote xmlns:cs=\"http://www.example.com/simpleCS\">" +LINE_BREAK+
- MARGIN+INDENT+ "<symbol>FBNT</symbol>" +LINE_BREAK+
- MARGIN+INDENT+ "<companyName>FlyByNightTechnology</companyName>" +LINE_BREAK+
- MARGIN+INDENT+ "<price>999.0</price>" +LINE_BREAK+
- MARGIN+INDENT+ "<volume>1000.0</volume>" +LINE_BREAK+
- MARGIN+INDENT+ "<quotes>" +LINE_BREAK+
- MARGIN+INDENT+INDENT+ "<price>1500.0</price>" +LINE_BREAK+
- MARGIN+INDENT+ "</quotes>" +LINE_BREAK+
- MARGIN+INDENT+ "<quotes>" +LINE_BREAK+
- MARGIN+INDENT+INDENT+ "<price>2500.0</price>" +LINE_BREAK+
- MARGIN+INDENT+ "</quotes>" +LINE_BREAK+
- MARGIN+INDENT+ "<quotes>" +LINE_BREAK+
- MARGIN+INDENT+INDENT+ "<price>3000.0</price>" +LINE_BREAK+
- MARGIN+INDENT+ "</quotes>" +LINE_BREAK+
- MARGIN+INDENT+ "<quotes>" +LINE_BREAK+
- MARGIN+INDENT+INDENT+ "<price>4000.0</price>" +LINE_BREAK+
- MARGIN+INDENT+ "</quotes>" +LINE_BREAK+
- MARGIN+INDENT+ "<changes create=\"#//quotes[3] #//quotes[4]\" delete=\"#//changes/stockQuote[1]/quotes[2]\" logging=\"false\" xmlns:sdo=\"commonj.sdo\">" +LINE_BREAK+
- MARGIN+INDENT+INDENT+ "<cs:stockQuote sdo:ref=\"#/stockQuote\" sdo:unset=\"volume\">" +LINE_BREAK+
- MARGIN+INDENT+INDENT+INDENT+ "<symbol>fbnt</symbol>" +LINE_BREAK+
- MARGIN+INDENT+INDENT+INDENT+ "<price>1000.0</price>" +LINE_BREAK+
- MARGIN+INDENT+INDENT+INDENT+ "<quotes sdo:ref=\"#//quotes[1]\" />" +LINE_BREAK+
- MARGIN+INDENT+INDENT+INDENT+ "<quotes><price>2000.0</price><quotes><price>2000.99</price></quotes></quotes>" +LINE_BREAK+
- MARGIN+INDENT+INDENT+INDENT+ "<quotes sdo:ref=\"#//quotes[2]\" />" +LINE_BREAK+
- MARGIN+INDENT+INDENT+ "</cs:stockQuote>" +LINE_BREAK+
- MARGIN+INDENT+ "</changes>" +LINE_BREAK+
- MARGIN+ "</cs:stockQuote>";
-
- String formatted2 =
- //MARGIN+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>" +LINE_BREAK+
- MARGIN+ "<p0:stockQuote xmlns:p0=\"http://www.example.com/simple\">" +LINE_BREAK+
- MARGIN+INDENT+"<symbol>fbnt</symbol>" +LINE_BREAK+
- MARGIN+INDENT+"<companyName>FlyByNightTechnology</companyName>" +LINE_BREAK+
- MARGIN+INDENT+"<price>1000.0</price>" +LINE_BREAK+
- MARGIN+INDENT+"<open1>1000.0</open1>" +LINE_BREAK+
- MARGIN+INDENT+"<high>1000.0</high>" +LINE_BREAK+
- MARGIN+INDENT+"<low>1000.0</low>" +LINE_BREAK+
- MARGIN+INDENT+"<volume>1000.0</volume>" +LINE_BREAK+
- MARGIN+INDENT+"<change1>1000.0</change1>" +LINE_BREAK+
- MARGIN+"</p0:stockQuote>" +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());
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +LINE_BREAK+
+ MARGIN+ "<cs:stockQuote xmlns:cs=\"http://www.example.com/simpleCS\">" +LINE_BREAK+
+ MARGIN+INDENT+ "<symbol>FBNT</symbol>" +LINE_BREAK+
+ MARGIN+INDENT+ "<companyName>FlyByNightTechnology</companyName>" +LINE_BREAK+
+ MARGIN+INDENT+ "<price>999.0</price>" +LINE_BREAK+
+ MARGIN+INDENT+ "<volume>1000.0</volume>" +LINE_BREAK+
+ MARGIN+INDENT+ "<quotes>" +LINE_BREAK+
+ MARGIN+INDENT+INDENT+ "<price>1500.0</price>" +LINE_BREAK+
+ MARGIN+INDENT+ "</quotes>" +LINE_BREAK+
+ MARGIN+INDENT+ "<quotes>" +LINE_BREAK+
+ MARGIN+INDENT+INDENT+ "<price>2500.0</price>" +LINE_BREAK+
+ MARGIN+INDENT+ "</quotes>" +LINE_BREAK+
+ MARGIN+INDENT+ "<quotes>" +LINE_BREAK+
+ MARGIN+INDENT+INDENT+ "<price>3000.0</price>" +LINE_BREAK+
+ MARGIN+INDENT+ "</quotes>" +LINE_BREAK+
+ MARGIN+INDENT+ "<quotes>" +LINE_BREAK+
+ MARGIN+INDENT+INDENT+ "<price>4000.0</price>" +LINE_BREAK+
+ MARGIN+INDENT+ "</quotes>" +LINE_BREAK+
+ MARGIN+INDENT+ "<changes create=\"#//quotes[3] #//quotes[4]\" delete=\"#//changes/stockQuote[1]/quotes[2]\" logging=\"false\" xmlns:sdo=\"commonj.sdo\">" +LINE_BREAK+
+ MARGIN+INDENT+INDENT+ "<cs:stockQuote sdo:ref=\"#/stockQuote\" sdo:unset=\"volume\">" +LINE_BREAK+
+ MARGIN+INDENT+INDENT+INDENT+ "<symbol>fbnt</symbol>" +LINE_BREAK+
+ MARGIN+INDENT+INDENT+INDENT+ "<price>1000.0</price>" +LINE_BREAK+
+ MARGIN+INDENT+INDENT+INDENT+ "<quotes sdo:ref=\"#//quotes[1]\" />" +LINE_BREAK+
+ MARGIN+INDENT+INDENT+INDENT+ "<quotes><price>2000.0</price><quotes><price>2000.99</price></quotes></quotes>" +LINE_BREAK+
+ MARGIN+INDENT+INDENT+INDENT+ "<quotes sdo:ref=\"#//quotes[2]\" />" +LINE_BREAK+
+ MARGIN+INDENT+INDENT+ "</cs:stockQuote>" +LINE_BREAK+
+ MARGIN+INDENT+ "</changes>" +LINE_BREAK+
+ MARGIN+ "</cs:stockQuote>";
+
+ String formatted2 =
+ //MARGIN+ "<?xml version=\"1.0\" encoding=\"ASCII\"?>" +LINE_BREAK+
+ MARGIN+ "<p0:stockQuote xmlns:p0=\"http://www.example.com/simple\">" +LINE_BREAK+
+ MARGIN+INDENT+"<symbol>fbnt</symbol>" +LINE_BREAK+
+ MARGIN+INDENT+"<companyName>FlyByNightTechnology</companyName>" +LINE_BREAK+
+ MARGIN+INDENT+"<price>1000.0</price>" +LINE_BREAK+
+ MARGIN+INDENT+"<open1>1000.0</open1>" +LINE_BREAK+
+ MARGIN+INDENT+"<high>1000.0</high>" +LINE_BREAK+
+ MARGIN+INDENT+"<low>1000.0</low>" +LINE_BREAK+
+ MARGIN+INDENT+"<volume>1000.0</volume>" +LINE_BREAK+
+ MARGIN+INDENT+"<change1>1000.0</change1>" +LINE_BREAK+
+ MARGIN+"</p0:stockQuote>" +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/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLUnknownPropertiesTestCase.java b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLUnknownPropertiesTestCase.java
index 63e92503c1..8824ae7f13 100644
--- a/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLUnknownPropertiesTestCase.java
+++ b/java/sdo/impl/src/test/java/org/apache/tuscany/sdo/test/XMLUnknownPropertiesTestCase.java
@@ -1,132 +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("<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"testNS\">" + "<element name=\"root\">"
- + "<complexType>"
- + "<sequence>"
- + "<element name=\"unqualifiedElement\" type=\"string\"/>"
- + "<element name=\"qualifiedElement\" form=\"qualified\" type=\"string\"/>"
- + "</sequence>"
- + "<attribute name=\"unqualifiedAttribute\" type=\"string\"/>"
- + "<attribute name=\"qualifiedAttribute\" form=\"qualified\" type=\"string\"/>"
- + "</complexType>"
- + "</element>"
- + "</schema>");
-
- final String xml =
- "<p:root xmlns:p=\"testNS\">" + "<unqualifiedElement/>"
- + "<telem>my test data0</telem>"
- + "<zap>my test data1</zap>"
- + "</p:root>";
-
- 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("<telem>my test data0</telem>") != -1);
- assertTrue(baos.toString().indexOf("<zap>my test data1</zap>") != -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("<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"testNS\">" + "<element name=\"root\">"
- + "<complexType>"
- + "<sequence>"
- + "<element name=\"unqualifiedElement\" type=\"string\"/>"
- + "<element name=\"qualifiedElement\" form=\"qualified\" type=\"string\"/>"
- + "</sequence>"
- + "<attribute name=\"unqualifiedAttribute\" type=\"string\"/>"
- + "<attribute name=\"qualifiedAttribute\" form=\"qualified\" type=\"string\"/>"
- + "</complexType>"
- + "</element>"
- + "</schema>");
-
- final String xml =
- "<p:root xmlns:p=\"testNS\">" + "<unqualifiedElement/>"
- + "<telem>my test data</telem>"
- + "<telem1>my test data</telem1>"
- + "</p:root>";
-
- 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);
- }
- }
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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("<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"testNS\">" + "<element name=\"root\">"
+ + "<complexType>"
+ + "<sequence>"
+ + "<element name=\"unqualifiedElement\" type=\"string\"/>"
+ + "<element name=\"qualifiedElement\" form=\"qualified\" type=\"string\"/>"
+ + "</sequence>"
+ + "<attribute name=\"unqualifiedAttribute\" type=\"string\"/>"
+ + "<attribute name=\"qualifiedAttribute\" form=\"qualified\" type=\"string\"/>"
+ + "</complexType>"
+ + "</element>"
+ + "</schema>");
+
+ final String xml =
+ "<p:root xmlns:p=\"testNS\">" + "<unqualifiedElement/>"
+ + "<telem>my test data0</telem>"
+ + "<zap>my test data1</zap>"
+ + "</p:root>";
+
+ 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("<telem>my test data0</telem>") != -1);
+ assertTrue(baos.toString().indexOf("<zap>my test data1</zap>") != -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("<schema xmlns=\"http://www.w3.org/2001/XMLSchema\" targetNamespace=\"testNS\">" + "<element name=\"root\">"
+ + "<complexType>"
+ + "<sequence>"
+ + "<element name=\"unqualifiedElement\" type=\"string\"/>"
+ + "<element name=\"qualifiedElement\" form=\"qualified\" type=\"string\"/>"
+ + "</sequence>"
+ + "<attribute name=\"unqualifiedAttribute\" type=\"string\"/>"
+ + "<attribute name=\"qualifiedAttribute\" form=\"qualified\" type=\"string\"/>"
+ + "</complexType>"
+ + "</element>"
+ + "</schema>");
+
+ final String xml =
+ "<p:root xmlns:p=\"testNS\">" + "<unqualifiedElement/>"
+ + "<telem>my test data</telem>"
+ + "<telem1>my test data</telem1>"
+ + "</p:root>";
+
+ 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/java/sdo/impl/src/test/resources/TypePropertyMetadataInfo.xsd b/java/sdo/impl/src/test/resources/TypePropertyMetadataInfo.xsd
index be5bc2c3e7..7a78772733 100644
--- a/java/sdo/impl/src/test/resources/TypePropertyMetadataInfo.xsd
+++ b/java/sdo/impl/src/test/resources/TypePropertyMetadataInfo.xsd
@@ -1,97 +1,97 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- -->
-<schema xmlns="http://www.w3.org/2001/XMLSchema"
- targetNamespace="http://www.example.com/metadata/retrievaltest"
- xmlns:metadata="http://www.example.com/metadata/retrievaltest">
-
-<annotation>
- <appinfo source="http://www.example.com/metadata/annotation">
- <p1:annotationSet xmlns:p1="http://www.example.com/metadata/annotation" name="test"/>
- </appinfo>
-</annotation>
-
-<complexType name="Example">
- <annotation>
- <appinfo source="http://www.example.com/metadata/annotation">
- <p1:example xmlns:p1="http://www.example.com/metadata/annotation">
- <p1:picture>forest.jpg</p1:picture>
- </p1:example>
- </appinfo>
- </annotation>
-
- <sequence>
- <element name="number" type="integer" minOccurs="0" maxOccurs="1">
- <annotation>
- <appinfo source="http://www.example.com/metadata/annotation">
- <p1:AttributeTypeMetadata xmlns:p1="http://www.example.com/metadata/annotation">
- <p1:getter>getNumber</p1:getter>
- <p1:setter>setNumber</p1:setter>
- </p1:AttributeTypeMetadata>
- </appinfo>
- </annotation>
- </element>
-
- <element name="Exampletype" type="string">
- <annotation>
- <appinfo source="http://www.example.com/metadata/annotation">
- <p1:AttributeTypeMetadata xmlns:p1="http://www.example.com/metadata/annotation">
- <p1:getter>getPhonetype</p1:getter>
- <p1:setter>setPhonetype</p1:setter>
- </p1:AttributeTypeMetadata>
- </appinfo>
- </annotation>
- </element>
- </sequence>
-</complexType>
-
-<simpleType name="ExampleNumber">
- <annotation>
- <appinfo source="http://www.example.com/metadata/annotation">
- This is the metadata for defining the ExampleNumber type.
- </appinfo>
- </annotation>
- <restriction base="integer">
- <minInclusive value="1"/>
- <maxInclusive value="29035"/>
- </restriction>
-</simpleType>
-
-<simpleType name="PhoneNumber">
- <annotation>
- <appinfo source="http://www.example.com/metadata/annotation">
- This is the metadata for defining the PhoneNumber type.
- </appinfo>
- </annotation>
- <restriction base="string">
- <length value="8"/>
- <pattern value="\d{3}-\d{4}"/>
- <pattern value="\d{6}-\d{8}"/>
- </restriction>
-</simpleType>
-
-<simpleType name="ExampleRating">
- <restriction base="string">
- <enumeration value=""/>
- <enumeration value="Good"/>
- <enumeration value="Bad"/>
- </restriction>
-</simpleType>
-
-</schema>
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.example.com/metadata/retrievaltest"
+ xmlns:metadata="http://www.example.com/metadata/retrievaltest">
+
+<annotation>
+ <appinfo source="http://www.example.com/metadata/annotation">
+ <p1:annotationSet xmlns:p1="http://www.example.com/metadata/annotation" name="test"/>
+ </appinfo>
+</annotation>
+
+<complexType name="Example">
+ <annotation>
+ <appinfo source="http://www.example.com/metadata/annotation">
+ <p1:example xmlns:p1="http://www.example.com/metadata/annotation">
+ <p1:picture>forest.jpg</p1:picture>
+ </p1:example>
+ </appinfo>
+ </annotation>
+
+ <sequence>
+ <element name="number" type="integer" minOccurs="0" maxOccurs="1">
+ <annotation>
+ <appinfo source="http://www.example.com/metadata/annotation">
+ <p1:AttributeTypeMetadata xmlns:p1="http://www.example.com/metadata/annotation">
+ <p1:getter>getNumber</p1:getter>
+ <p1:setter>setNumber</p1:setter>
+ </p1:AttributeTypeMetadata>
+ </appinfo>
+ </annotation>
+ </element>
+
+ <element name="Exampletype" type="string">
+ <annotation>
+ <appinfo source="http://www.example.com/metadata/annotation">
+ <p1:AttributeTypeMetadata xmlns:p1="http://www.example.com/metadata/annotation">
+ <p1:getter>getPhonetype</p1:getter>
+ <p1:setter>setPhonetype</p1:setter>
+ </p1:AttributeTypeMetadata>
+ </appinfo>
+ </annotation>
+ </element>
+ </sequence>
+</complexType>
+
+<simpleType name="ExampleNumber">
+ <annotation>
+ <appinfo source="http://www.example.com/metadata/annotation">
+ This is the metadata for defining the ExampleNumber type.
+ </appinfo>
+ </annotation>
+ <restriction base="integer">
+ <minInclusive value="1"/>
+ <maxInclusive value="29035"/>
+ </restriction>
+</simpleType>
+
+<simpleType name="PhoneNumber">
+ <annotation>
+ <appinfo source="http://www.example.com/metadata/annotation">
+ This is the metadata for defining the PhoneNumber type.
+ </appinfo>
+ </annotation>
+ <restriction base="string">
+ <length value="8"/>
+ <pattern value="\d{3}-\d{4}"/>
+ <pattern value="\d{6}-\d{8}"/>
+ </restriction>
+</simpleType>
+
+<simpleType name="ExampleRating">
+ <restriction base="string">
+ <enumeration value=""/>
+ <enumeration value="Good"/>
+ <enumeration value="Bad"/>
+ </restriction>
+</simpleType>
+
+</schema>
diff --git a/java/sdo/impl/src/test/resources/bounds.xsd b/java/sdo/impl/src/test/resources/bounds.xsd
index 31b621d575..4d92d6e1fe 100644
--- a/java/sdo/impl/src/test/resources/bounds.xsd
+++ b/java/sdo/impl/src/test/resources/bounds.xsd
@@ -1,45 +1,45 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- -->
-<xsd:schema
- xmlns:bounds="http://www.example.com/bounds"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- targetNamespace="http://www.example.com/bounds">
-
- <xsd:element name="price" type="xsd:decimal"/>
-
- <xsd:complexType name="OpenQuote">
- <xsd:sequence>
- <xsd:element name="symbol" type="xsd:string" maxOccurs="2" minOccurs="0" />
- </xsd:sequence>
- </xsd:complexType>
-
- <xsd:complexType name="OpenQuote2">
- <xsd:sequence>
- <xsd:element name="symbol" type="xsd:string" maxOccurs="unbounded" />
- </xsd:sequence>
- </xsd:complexType>
-
- <xsd:complexType name="OpenQuote3">
- <xsd:sequence>
- <xsd:element name="symbol" type="xsd:string"/>
- </xsd:sequence>
- </xsd:complexType>
-
-</xsd:schema>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+<xsd:schema
+ xmlns:bounds="http://www.example.com/bounds"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.example.com/bounds">
+
+ <xsd:element name="price" type="xsd:decimal"/>
+
+ <xsd:complexType name="OpenQuote">
+ <xsd:sequence>
+ <xsd:element name="symbol" type="xsd:string" maxOccurs="2" minOccurs="0" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="OpenQuote2">
+ <xsd:sequence>
+ <xsd:element name="symbol" type="xsd:string" maxOccurs="unbounded" />
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:complexType name="OpenQuote3">
+ <xsd:sequence>
+ <xsd:element name="symbol" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+</xsd:schema>
diff --git a/java/sdo/impl/src/test/resources/dupelement.xsd b/java/sdo/impl/src/test/resources/dupelement.xsd
index 9707a881c4..da2f6920d4 100644
--- a/java/sdo/impl/src/test/resources/dupelement.xsd
+++ b/java/sdo/impl/src/test/resources/dupelement.xsd
@@ -1,39 +1,39 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- -->
-<xsd:schema
- targetNamespace="http://www.example.com/dupelement"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:simple="http://www.example.com/dupelement"
- xmlns:sdoXML="commonj.sdo/xml">
-
- <xsd:element name="stockQuote" type="simple:Quote"/>
-
- <xsd:complexType name="Quote">
- <xsd:sequence>
- <xsd:element name="symbol" type="xsd:string"/>
- <xsd:element name="companyName" type="xsd:string"/>
- <xsd:element name="companyName" type="xsd:int" sdoXML:aliasName="companyNameInInt"/>
- <xsd:element name="quotes" type="simple:Quote" minOccurs="0" maxOccurs="unbounded"/>
- </xsd:sequence>
-
- <xsd:attribute name="symbol" type="xsd:int" sdoXML:aliasName="symbolInInt"/>
- </xsd:complexType>
-
-</xsd:schema>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+<xsd:schema
+ targetNamespace="http://www.example.com/dupelement"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:simple="http://www.example.com/dupelement"
+ xmlns:sdoXML="commonj.sdo/xml">
+
+ <xsd:element name="stockQuote" type="simple:Quote"/>
+
+ <xsd:complexType name="Quote">
+ <xsd:sequence>
+ <xsd:element name="symbol" type="xsd:string"/>
+ <xsd:element name="companyName" type="xsd:string"/>
+ <xsd:element name="companyName" type="xsd:int" sdoXML:aliasName="companyNameInInt"/>
+ <xsd:element name="quotes" type="simple:Quote" minOccurs="0" maxOccurs="unbounded"/>
+ </xsd:sequence>
+
+ <xsd:attribute name="symbol" type="xsd:int" sdoXML:aliasName="symbolInInt"/>
+ </xsd:complexType>
+
+</xsd:schema>
diff --git a/java/sdo/impl/src/test/resources/expectedExceptions.xsd b/java/sdo/impl/src/test/resources/expectedExceptions.xsd
index 79f90d311d..cd12447cd9 100644
--- a/java/sdo/impl/src/test/resources/expectedExceptions.xsd
+++ b/java/sdo/impl/src/test/resources/expectedExceptions.xsd
@@ -1,67 +1,67 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- -->
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:sdo="commonj.sdo"
- xmlns:sdoXML="commonj.sdo/xml"
- xmlns:expect="http://example.com/ExpectedException"
- targetNamespace="http://example.com/ExpectedException">
-
- <xsd:import namespace="commonj.sdo" schemaLocation="sdoModel.xsd"/>
- <xsd:import namespace="commonj.sdo/xml" schemaLocation="sdoModel.xsd"/>
-
- <xsd:element name="expectedExceptionsElem" type="expect:ExpectedExceptionType"/>
-
- <xsd:complexType name="ExpectedExceptionType">
- <xsd:sequence>
- <xsd:element name="stringVal" type="xsd:string"/>
- <xsd:element name="booleanVal" type="xsd:boolean"/>
- <xsd:element name="byteVal" type="xsd:byte"/>
- <xsd:element name="decimalVal" type="xsd:decimal"/>
- <xsd:element name="intVal" type="xsd:int"/>
- <xsd:element name="floatVal" type="xsd:float"/>
- <xsd:element name="doubleVal" type="xsd:double"/>
- <xsd:element name="dateVal" type="xsd:dateTime"/>
- <xsd:element name="shortVal" type="xsd:short"/>
- <xsd:element name="longVal" type="xsd:long"/>
- <xsd:element maxOccurs="unbounded" minOccurs="0" name="listVal" type="xsd:string"/>
- <xsd:element name="bytesVal" type="xsd:hexBinary"/>
- <xsd:element name="integerVal" type="xsd:integer"/>
- <xsd:element name="charVal" type="expect:char"/>
- <xsd:element name="readOnlyVal" sdoXML:readOnly="true" type="xsd:string"/>
- <xsd:element name="readOnlyListVal" sdoXML:readOnly="true" type="xsd:string"/>
- </xsd:sequence>
- </xsd:complexType>
-
- <xsd:simpleType name="char">
- <xsd:restriction base="xsd:string">
- <xsd:length value="1"/>
- </xsd:restriction>
- </xsd:simpleType>
-
- <xsd:element name="sequencedReadOnlyElem" type="expect:SequenceReadOnlyType"/>
-
- <xsd:complexType mixed="true" name="SequenceReadOnlyType">
- <xsd:sequence>
- <xsd:element name="readOnlyVal" sdoXML:readOnly="true" type="xsd:string"/>
- <xsd:element name="readOnlyListVal" sdoXML:readOnly = "true" type="xsd:string"/>
- <xsd:element name="uniqueName" type="xsd:string"/>
- </xsd:sequence>
- </xsd:complexType>
-</xsd:schema>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:sdo="commonj.sdo"
+ xmlns:sdoXML="commonj.sdo/xml"
+ xmlns:expect="http://example.com/ExpectedException"
+ targetNamespace="http://example.com/ExpectedException">
+
+ <xsd:import namespace="commonj.sdo" schemaLocation="sdoModel.xsd"/>
+ <xsd:import namespace="commonj.sdo/xml" schemaLocation="sdoModel.xsd"/>
+
+ <xsd:element name="expectedExceptionsElem" type="expect:ExpectedExceptionType"/>
+
+ <xsd:complexType name="ExpectedExceptionType">
+ <xsd:sequence>
+ <xsd:element name="stringVal" type="xsd:string"/>
+ <xsd:element name="booleanVal" type="xsd:boolean"/>
+ <xsd:element name="byteVal" type="xsd:byte"/>
+ <xsd:element name="decimalVal" type="xsd:decimal"/>
+ <xsd:element name="intVal" type="xsd:int"/>
+ <xsd:element name="floatVal" type="xsd:float"/>
+ <xsd:element name="doubleVal" type="xsd:double"/>
+ <xsd:element name="dateVal" type="xsd:dateTime"/>
+ <xsd:element name="shortVal" type="xsd:short"/>
+ <xsd:element name="longVal" type="xsd:long"/>
+ <xsd:element maxOccurs="unbounded" minOccurs="0" name="listVal" type="xsd:string"/>
+ <xsd:element name="bytesVal" type="xsd:hexBinary"/>
+ <xsd:element name="integerVal" type="xsd:integer"/>
+ <xsd:element name="charVal" type="expect:char"/>
+ <xsd:element name="readOnlyVal" sdoXML:readOnly="true" type="xsd:string"/>
+ <xsd:element name="readOnlyListVal" sdoXML:readOnly="true" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+
+ <xsd:simpleType name="char">
+ <xsd:restriction base="xsd:string">
+ <xsd:length value="1"/>
+ </xsd:restriction>
+ </xsd:simpleType>
+
+ <xsd:element name="sequencedReadOnlyElem" type="expect:SequenceReadOnlyType"/>
+
+ <xsd:complexType mixed="true" name="SequenceReadOnlyType">
+ <xsd:sequence>
+ <xsd:element name="readOnlyVal" sdoXML:readOnly="true" type="xsd:string"/>
+ <xsd:element name="readOnlyListVal" sdoXML:readOnly = "true" type="xsd:string"/>
+ <xsd:element name="uniqueName" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+</xsd:schema>
diff --git a/java/sdo/impl/src/test/resources/openContentProperty.xml b/java/sdo/impl/src/test/resources/openContentProperty.xml
index 03608365c0..68f4c116eb 100644
--- a/java/sdo/impl/src/test/resources/openContentProperty.xml
+++ b/java/sdo/impl/src/test/resources/openContentProperty.xml
@@ -1,12 +1,12 @@
-<?xml version="1.0" encoding="ASCII"?>
-<open:openStockQuote xmlns:open="http://www.example.com/open">
- <symbol>s1</symbol>
- <open:company>
- <name>FlyByNightTechnology</name>
- </open:company>
- <open:price>1000.0</open:price>
- <open:highPrice>1100.0</open:highPrice>
- <open:mutualFundQuote>
- <symbol>mutual-1</symbol>
- </open:mutualFundQuote>
+<?xml version="1.0" encoding="ASCII"?>
+<open:openStockQuote xmlns:open="http://www.example.com/open">
+ <symbol>s1</symbol>
+ <open:company>
+ <name>FlyByNightTechnology</name>
+ </open:company>
+ <open:price>1000.0</open:price>
+ <open:highPrice>1100.0</open:highPrice>
+ <open:mutualFundQuote>
+ <symbol>mutual-1</symbol>
+ </open:mutualFundQuote>
</open:openStockQuote> \ No newline at end of file
diff --git a/java/sdo/impl/src/test/resources/sdoModel.xsd b/java/sdo/impl/src/test/resources/sdoModel.xsd
index 645b7b700a..6b596c5b36 100644
--- a/java/sdo/impl/src/test/resources/sdoModel.xsd
+++ b/java/sdo/impl/src/test/resources/sdoModel.xsd
@@ -1,28 +1,28 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- -->
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sdo="commonj.sdo" xmlns:sdoJava="commonj.sdo/java" targetNamespace="commonj.sdo">
-
- <!-- Dummy XSD definition of special SDO ChangeSummaryType -->
- <xsd:simpleType name="ChangeSummaryType" sdoJava:instanceClass="commonj.sdo.ChangeSummary">
- <xsd:restriction base="xsd:string"/>
- </xsd:simpleType>
-
-
-</xsd:schema>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sdo="commonj.sdo" xmlns:sdoJava="commonj.sdo/java" targetNamespace="commonj.sdo">
+
+ <!-- Dummy XSD definition of special SDO ChangeSummaryType -->
+ <xsd:simpleType name="ChangeSummaryType" sdoJava:instanceClass="commonj.sdo.ChangeSummary">
+ <xsd:restriction base="xsd:string"/>
+ </xsd:simpleType>
+
+
+</xsd:schema>
diff --git a/java/sdo/impl/src/test/resources/shallowquote1.xml b/java/sdo/impl/src/test/resources/shallowquote1.xml
index 0cdb2fbce8..a9bb2bf330 100644
--- a/java/sdo/impl/src/test/resources/shallowquote1.xml
+++ b/java/sdo/impl/src/test/resources/shallowquote1.xml
@@ -1,29 +1,29 @@
-<?xml version="1.0" encoding="ASCII"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
--->
-<simple:stockQuote xmlns:simple="http://www.example.com/simple">
- <symbol>fbnt</symbol>
- <companyName>FlyByNightTechnology</companyName>
- <price>1000.0</price>
- <open1>1000.0</open1>
- <high>1000.0</high>
- <low>1000.0</low>
- <volume>1000.0</volume>
- <change1>1000.0</change1>
- </simple:stockQuote>
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<simple:stockQuote xmlns:simple="http://www.example.com/simple">
+ <symbol>fbnt</symbol>
+ <companyName>FlyByNightTechnology</companyName>
+ <price>1000.0</price>
+ <open1>1000.0</open1>
+ <high>1000.0</high>
+ <low>1000.0</low>
+ <volume>1000.0</volume>
+ <change1>1000.0</change1>
+ </simple:stockQuote>
diff --git a/java/sdo/impl/src/test/resources/simple2.xsd b/java/sdo/impl/src/test/resources/simple2.xsd
index 4be4bac95b..53bace49b5 100644
--- a/java/sdo/impl/src/test/resources/simple2.xsd
+++ b/java/sdo/impl/src/test/resources/simple2.xsd
@@ -1,41 +1,41 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- -->
-<xsd:schema xmlns:simple="http://www.example.com/simple" xmlns:simple2="http://www.example.com/simple2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/simple2">
-
- <xsd:import namespace="http://www.example.com/simple"/>
-
- <xsd:element name="stockQuote" type="simple2:Quote2"/>
-
- <xsd:complexType name="Quote2">
- <xsd:sequence>
- <xsd:element name="symbol" type="xsd:string"/>
- <xsd:element name="companyName" type="xsd:string"/>
- <xsd:element name="price" type="xsd:decimal"/>
- <xsd:element name="open1" type="xsd:decimal"/>
- <xsd:element name="high" type="xsd:decimal"/>
- <xsd:element name="low" type="xsd:decimal"/>
- <xsd:element name="volume" type="xsd:double"/>
- <xsd:element name="change1" type="xsd:double"/>
- <!-- temporarily removing this until we find a way to do this test without causing eclipse to light up
- due to missing import -->
- <!-- <xsd:element maxOccurs="unbounded" minOccurs="0" name="quotes" type="simple:Quote"/> -->
- </xsd:sequence>
- </xsd:complexType>
-
-</xsd:schema>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+<xsd:schema xmlns:simple="http://www.example.com/simple" xmlns:simple2="http://www.example.com/simple2" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.com/simple2">
+
+ <xsd:import namespace="http://www.example.com/simple"/>
+
+ <xsd:element name="stockQuote" type="simple2:Quote2"/>
+
+ <xsd:complexType name="Quote2">
+ <xsd:sequence>
+ <xsd:element name="symbol" type="xsd:string"/>
+ <xsd:element name="companyName" type="xsd:string"/>
+ <xsd:element name="price" type="xsd:decimal"/>
+ <xsd:element name="open1" type="xsd:decimal"/>
+ <xsd:element name="high" type="xsd:decimal"/>
+ <xsd:element name="low" type="xsd:decimal"/>
+ <xsd:element name="volume" type="xsd:double"/>
+ <xsd:element name="change1" type="xsd:double"/>
+ <!-- temporarily removing this until we find a way to do this test without causing eclipse to light up
+ due to missing import -->
+ <!-- <xsd:element maxOccurs="unbounded" minOccurs="0" name="quotes" type="simple:Quote"/> -->
+ </xsd:sequence>
+ </xsd:complexType>
+
+</xsd:schema>
diff --git a/java/sdo/impl/src/test/resources/simpleWithChangeSummary.xml b/java/sdo/impl/src/test/resources/simpleWithChangeSummary.xml
index d8ecf8f398..2f29fc00f0 100644
--- a/java/sdo/impl/src/test/resources/simpleWithChangeSummary.xml
+++ b/java/sdo/impl/src/test/resources/simpleWithChangeSummary.xml
@@ -1,28 +1,28 @@
-<?xml version="1.0" encoding="ASCII"?>
-<cs:stockQuote xmlns:cs="http://www.example.com/simpleCS">
- <symbol>FBNT</symbol>
- <companyName>FlyByNightTechnology</companyName>
- <price>999.0</price>
- <volume>1000.0</volume>
- <quotes>
- <price>1500.0</price>
- </quotes>
- <quotes>
- <price>2500.0</price>
- </quotes>
- <quotes>
- <price>3000.0</price>
- </quotes>
- <quotes>
- <price>4000.0</price>
- </quotes>
- <changes create="#//quotes[3] #//quotes[4]" delete="#//changes/stockQuote[1]/quotes[2]" logging="false" xmlns:sdo="commonj.sdo">
- <cs:stockQuote sdo:ref="#/stockQuote" sdo:unset="volume">
- <symbol>fbnt</symbol>
- <price>1000.0</price>
- <quotes sdo:ref="#//quotes[1]" />
- <quotes><price>2000.0</price><quotes><price>2000.99</price></quotes></quotes>
- <quotes sdo:ref="#//quotes[2]" />
- </cs:stockQuote>
- </changes>
+<?xml version="1.0" encoding="ASCII"?>
+<cs:stockQuote xmlns:cs="http://www.example.com/simpleCS">
+ <symbol>FBNT</symbol>
+ <companyName>FlyByNightTechnology</companyName>
+ <price>999.0</price>
+ <volume>1000.0</volume>
+ <quotes>
+ <price>1500.0</price>
+ </quotes>
+ <quotes>
+ <price>2500.0</price>
+ </quotes>
+ <quotes>
+ <price>3000.0</price>
+ </quotes>
+ <quotes>
+ <price>4000.0</price>
+ </quotes>
+ <changes create="#//quotes[3] #//quotes[4]" delete="#//changes/stockQuote[1]/quotes[2]" logging="false" xmlns:sdo="commonj.sdo">
+ <cs:stockQuote sdo:ref="#/stockQuote" sdo:unset="volume">
+ <symbol>fbnt</symbol>
+ <price>1000.0</price>
+ <quotes sdo:ref="#//quotes[1]" />
+ <quotes><price>2000.0</price><quotes><price>2000.99</price></quotes></quotes>
+ <quotes sdo:ref="#//quotes[2]" />
+ </cs:stockQuote>
+ </changes>
</cs:stockQuote> \ No newline at end of file
diff --git a/java/sdo/impl/src/test/resources/simpleWithChangeSummaryUndone.xml b/java/sdo/impl/src/test/resources/simpleWithChangeSummaryUndone.xml
index e2bbc56d2d..a9c675b6c3 100644
--- a/java/sdo/impl/src/test/resources/simpleWithChangeSummaryUndone.xml
+++ b/java/sdo/impl/src/test/resources/simpleWithChangeSummaryUndone.xml
@@ -1,19 +1,19 @@
-<?xml version="1.0" encoding="ASCII"?>
-<cs:stockQuote xmlns:cs="http://www.example.com/simpleCS">
- <symbol>fbnt</symbol>
- <companyName>FlyByNightTechnology</companyName>
- <price>1000.0</price>
- <quotes>
- <price>1500.0</price>
- </quotes>
- <quotes>
- <price>2000.0</price>
- <quotes>
- <price>2000.99</price>
- </quotes>
- </quotes>
- <quotes>
- <price>2500.0</price>
- </quotes>
- <changes logging="false" />
+<?xml version="1.0" encoding="ASCII"?>
+<cs:stockQuote xmlns:cs="http://www.example.com/simpleCS">
+ <symbol>fbnt</symbol>
+ <companyName>FlyByNightTechnology</companyName>
+ <price>1000.0</price>
+ <quotes>
+ <price>1500.0</price>
+ </quotes>
+ <quotes>
+ <price>2000.0</price>
+ <quotes>
+ <price>2000.99</price>
+ </quotes>
+ </quotes>
+ <quotes>
+ <price>2500.0</price>
+ </quotes>
+ <changes logging="false" />
</cs:stockQuote> \ No newline at end of file
diff --git a/java/sdo/impl/src/test/resources/substitutionValues1.xml b/java/sdo/impl/src/test/resources/substitutionValues1.xml
index cc10d9a435..c534eb9370 100644
--- a/java/sdo/impl/src/test/resources/substitutionValues1.xml
+++ b/java/sdo/impl/src/test/resources/substitutionValues1.xml
@@ -1,23 +1,23 @@
-<?xml version="1.0" encoding="ASCII"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
--->
-<sv:testObject xmlns:sv="http://www.apache.org/tuscany/SubstitutionValues">
- <sv:groupMember>gm</sv:groupMember>
- <sv:nonGroupHead>ngh</sv:nonGroupHead>
-</sv:testObject>
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<sv:testObject xmlns:sv="http://www.apache.org/tuscany/SubstitutionValues">
+ <sv:groupMember>gm</sv:groupMember>
+ <sv:nonGroupHead>ngh</sv:nonGroupHead>
+</sv:testObject>
diff --git a/java/sdo/impl/src/test/resources/substitutionValues2.xml b/java/sdo/impl/src/test/resources/substitutionValues2.xml
index d3870bf140..d90d0f3a0c 100644
--- a/java/sdo/impl/src/test/resources/substitutionValues2.xml
+++ b/java/sdo/impl/src/test/resources/substitutionValues2.xml
@@ -1,23 +1,23 @@
-<?xml version="1.0" encoding="ASCII"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
--->
-<sv:testObject xmlns:sv="http://www.apache.org/tuscany/SubstitutionValues">
- <sv:groupHead>gh</sv:groupHead>
- <sv:nonGroupHead>ngh</sv:nonGroupHead>
-</sv:testObject>
+<?xml version="1.0" encoding="ASCII"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<sv:testObject xmlns:sv="http://www.apache.org/tuscany/SubstitutionValues">
+ <sv:groupHead>gh</sv:groupHead>
+ <sv:nonGroupHead>ngh</sv:nonGroupHead>
+</sv:testObject>
diff --git a/java/sdo/java5tools/src/main/resources/META-INF/README.txt b/java/sdo/java5tools/src/main/resources/META-INF/README.txt
index 0ad57411e2..1b8144f7c5 100644
--- a/java/sdo/java5tools/src/main/resources/META-INF/README.txt
+++ b/java/sdo/java5tools/src/main/resources/META-INF/README.txt
@@ -1,5 +1,5 @@
-Apache Tuscany 1.0-incubating build (July 2007)
-===============================================
+Apache Tuscany 1.1-incubating build (April 2008)
+================================================
http://incubator.apache.org/tuscany/
diff --git a/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/api/SDOHelper.java b/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/api/SDOHelper.java
index 39d5902bf3..17d9a08a87 100644
--- a/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/api/SDOHelper.java
+++ b/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/api/SDOHelper.java
@@ -1,452 +1,452 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * 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 commonj.sdo.helper.XSDHelper;
-
-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
-{
- final int UNBOUNDED = -1; //return value from getUpperBound() when maxOccurs="unbounded"
- final int UNSPECIFIED = -2; //return value from getUpperBound() for global property
-
- /**
- * 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);
-
- /**
- * Return the lower bound of the specified property or 1 by default
- * @param the property in question.
- * @return the lower bound.
- */
- public int getLowerBound(Property property);
-
- /**
- * Return Enumeration facet
- * @param type
- * @return List of enum facets in a Type
- *///Amita
- public List getEnumerationFacet(Type type);
-
- /**
- * Return Pattern facet
- * @param type
- * @return List of pattern facets in a Type
- *///Amita
- public List getPatternFacet(Type type);
-
- /**
- * 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();
-
- /**
- * An experimental interface, subject to possible change that permits
- * registration of an event listener with a DataObject instance
- * @param dob DataObject
- * @param listener EventListener
- */
- public void addChangeListener(DataObject dob, EventListener listener);
-
- /**
- * An experimental interface, subject to possible change that permits
- * deregistration of an event listener with a DataObject instance
- * @param dob DataObject
- * @param listener EventListener
- */
- public void removeChangeListener(DataObject dob, EventListener listener);
-
- /**
- * 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";
- }
-
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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 commonj.sdo.helper.XSDHelper;
+
+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
+{
+ final int UNBOUNDED = -1; //return value from getUpperBound() when maxOccurs="unbounded"
+ final int UNSPECIFIED = -2; //return value from getUpperBound() for global property
+
+ /**
+ * 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);
+
+ /**
+ * Return the lower bound of the specified property or 1 by default
+ * @param the property in question.
+ * @return the lower bound.
+ */
+ public int getLowerBound(Property property);
+
+ /**
+ * Return Enumeration facet
+ * @param type
+ * @return List of enum facets in a Type
+ *///Amita
+ public List getEnumerationFacet(Type type);
+
+ /**
+ * Return Pattern facet
+ * @param type
+ * @return List of pattern facets in a Type
+ *///Amita
+ public List getPatternFacet(Type type);
+
+ /**
+ * 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();
+
+ /**
+ * An experimental interface, subject to possible change that permits
+ * registration of an event listener with a DataObject instance
+ * @param dob DataObject
+ * @param listener EventListener
+ */
+ public void addChangeListener(DataObject dob, EventListener listener);
+
+ /**
+ * An experimental interface, subject to possible change that permits
+ * deregistration of an event listener with a DataObject instance
+ * @param dob DataObject
+ * @param listener EventListener
+ */
+ public void removeChangeListener(DataObject dob, EventListener listener);
+
+ /**
+ * 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";
+ }
+
+}
diff --git a/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/api/SDOUtil.java b/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/api/SDOUtil.java
index 4046c80df3..54f86aafbd 100644
--- a/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/api/SDOUtil.java
+++ b/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/api/SDOUtil.java
@@ -1,445 +1,445 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * 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.EventListener;
-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#getLowerBound(Property)}.
- */
- public static int getLowerBound(Property property)
- {
- return defaultSDOHelper.getLowerBound(property);
- }
-
- public static List getEnumerationFacet(Type type) {
- return defaultSDOHelper.getEnumerationFacet(type);
- }
-
- public static List getPatternFacet(Type type) {
- return defaultSDOHelper.getPatternFacet(type);
- }
-
- /**
- * @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);
- }
-
-
- /**
- * @see SDOHelper#addChangeListener(DataObject, EventListener)
- * @param dob
- * @param l
- */
- public static void addChangeListener(DataObject dob, EventListener l) {
- defaultSDOHelper.addChangeListener(dob, l);
- }
-
- /**
- * @see SDOHelper#addChangeListener(DataObject, EventListener)
- * @param dob
- * @param l
- */
- public static void removeChangeListener(DataObject dob, EventListener l) {
- defaultSDOHelper.removeChangeListener(dob, l);
- }
-
-
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.EventListener;
+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#getLowerBound(Property)}.
+ */
+ public static int getLowerBound(Property property)
+ {
+ return defaultSDOHelper.getLowerBound(property);
+ }
+
+ public static List getEnumerationFacet(Type type) {
+ return defaultSDOHelper.getEnumerationFacet(type);
+ }
+
+ public static List getPatternFacet(Type type) {
+ return defaultSDOHelper.getPatternFacet(type);
+ }
+
+ /**
+ * @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);
+ }
+
+
+ /**
+ * @see SDOHelper#addChangeListener(DataObject, EventListener)
+ * @param dob
+ * @param l
+ */
+ public static void addChangeListener(DataObject dob, EventListener l) {
+ defaultSDOHelper.addChangeListener(dob, l);
+ }
+
+ /**
+ * @see SDOHelper#addChangeListener(DataObject, EventListener)
+ * @param dob
+ * @param l
+ */
+ public static void removeChangeListener(DataObject dob, EventListener l) {
+ defaultSDOHelper.removeChangeListener(dob, l);
+ }
+
+
+}
diff --git a/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/api/XMLStreamHelper.java b/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/api/XMLStreamHelper.java
index 094f05a703..bf283256fe 100644
--- a/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/api/XMLStreamHelper.java
+++ b/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/api/XMLStreamHelper.java
@@ -1,125 +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();
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectInputStream.java b/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectInputStream.java
index 44987f9d7b..606b4c8fc3 100644
--- a/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectInputStream.java
+++ b/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectInputStream.java
@@ -1,49 +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;
- }
-
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectOutputStream.java b/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectOutputStream.java
index 1610e1c6de..05f2105b97 100644
--- a/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectOutputStream.java
+++ b/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/lib/SDOObjectOutputStream.java
@@ -1,49 +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;
- }
-
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/lib/UnknownPropertyList.java b/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/lib/UnknownPropertyList.java
index d95ac681c9..95eabd4b82 100644
--- a/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/lib/UnknownPropertyList.java
+++ b/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/lib/UnknownPropertyList.java
@@ -1,70 +1,70 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sdo.lib;
-
-import java.util.AbstractList;
-import java.util.Collections;
-import java.util.List;
-
-import commonj.sdo.DataObject;
-
-public class UnknownPropertyList extends AbstractList {
- protected List delegateList = Collections.EMPTY_LIST;
- protected DataObject dataObject;
- protected String path;
-
- public UnknownPropertyList(DataObject dataObject, String path) {
- this.dataObject = dataObject;
- this.path = path;
- }
-
- public Object get(int index) {
- return getDelegateList().get(index);
- }
-
- public int size() {
- return getDelegateList().size();
- }
-
- public Object remove(int index) {
- return getDelegateList().remove(index);
- }
- public Object set(int index, Object element) {
- return getDelegateList().set(index, element);
- }
-
- public void add(int index, Object element) {
- if (getDelegateList() == Collections.EMPTY_LIST && index == 0) {
- dataObject.set(path, Collections.singletonList(element));
- delegateList = (List)dataObject.get(path);
- }
- else {
- delegateList.add(index, element);
- }
- }
-
- protected List getDelegateList() {
- if (delegateList == Collections.EMPTY_LIST) {
- List propertyList = (List)dataObject.get(path);
- if (propertyList != null) delegateList = propertyList;
- }
- return delegateList;
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.util.AbstractList;
+import java.util.Collections;
+import java.util.List;
+
+import commonj.sdo.DataObject;
+
+public class UnknownPropertyList extends AbstractList {
+ protected List delegateList = Collections.EMPTY_LIST;
+ protected DataObject dataObject;
+ protected String path;
+
+ public UnknownPropertyList(DataObject dataObject, String path) {
+ this.dataObject = dataObject;
+ this.path = path;
+ }
+
+ public Object get(int index) {
+ return getDelegateList().get(index);
+ }
+
+ public int size() {
+ return getDelegateList().size();
+ }
+
+ public Object remove(int index) {
+ return getDelegateList().remove(index);
+ }
+ public Object set(int index, Object element) {
+ return getDelegateList().set(index, element);
+ }
+
+ public void add(int index, Object element) {
+ if (getDelegateList() == Collections.EMPTY_LIST && index == 0) {
+ dataObject.set(path, Collections.singletonList(element));
+ delegateList = (List)dataObject.get(path);
+ }
+ else {
+ delegateList.add(index, element);
+ }
+ }
+
+ protected List getDelegateList() {
+ if (delegateList == Collections.EMPTY_LIST) {
+ List propertyList = (List)dataObject.get(path);
+ if (propertyList != null) delegateList = propertyList;
+ }
+ return delegateList;
+ }
+}
diff --git a/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/spi/HelperProviderBase.java b/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/spi/HelperProviderBase.java
index 377a348fff..375552497b 100644
--- a/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/spi/HelperProviderBase.java
+++ b/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/spi/HelperProviderBase.java
@@ -1,246 +1,246 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * 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 org.apache.tuscany.sdo.lib.SDOObjectOutputStream;
-
-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 SDOObjectOutputStream)
- {
- xmlHelperLocal = ((SDOObjectOutputStream)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);
- }
- }
- }
-
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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 org.apache.tuscany.sdo.lib.SDOObjectOutputStream;
+
+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 SDOObjectOutputStream)
+ {
+ xmlHelperLocal = ((SDOObjectOutputStream)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/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/spi/SDOHelperBase.java b/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/spi/SDOHelperBase.java
index 43c379256c..ce3678d81f 100644
--- a/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/spi/SDOHelperBase.java
+++ b/java/sdo/lib/src/main/java/org/apache/tuscany/sdo/spi/SDOHelperBase.java
@@ -1,176 +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");
- }
-
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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/java/sdo/lib/src/main/resources/META-INF/LICENSE.txt b/java/sdo/lib/src/main/resources/META-INF/LICENSE.txt
index e55ca67ba9..9a90d375bc 100644
--- a/java/sdo/lib/src/main/resources/META-INF/LICENSE.txt
+++ b/java/sdo/lib/src/main/resources/META-INF/LICENSE.txt
@@ -1,207 +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.
-
-
-
-
-
+
+ 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/java/sdo/lib/src/main/resources/META-INF/MANIFEST.MF b/java/sdo/lib/src/main/resources/META-INF/MANIFEST.MF
index b1ef8dad66..64cd082dc8 100644
--- a/java/sdo/lib/src/main/resources/META-INF/MANIFEST.MF
+++ b/java/sdo/lib/src/main/resources/META-INF/MANIFEST.MF
@@ -5,7 +5,7 @@ Specification-Vendor: Apache Software Foundation
Implementation-Vendor: Apache Software Foundation
Implementation-Vendor-Id: org.apache
Implementation-Title: tuscany-sdo-lib
-Implementation-Version: ${pom.version}
+Implementation-Version: 1.1-incubating
Bundle-ManifestVersion: 2
Bundle-Name: Tuscany SDO Implementation Library
Bundle-SymbolicName: org.apache.tuscany.sdo.lib
@@ -15,3 +15,5 @@ Require-Bundle: org.apache.tuscany.sdo.spec;visibility:=reexport
Export-Package: org.apache.tuscany.sdo.api,
org.apache.tuscany.sdo.spi,
org.apache.tuscany.sdo.lib
+X-Compile-Source-JDK: 1.4
+X-Compile-Target-JDK: 1.4
diff --git a/java/sdo/plugin/pom.xml b/java/sdo/plugin/pom.xml
index 25592fb43f..2807a277a4 100644
--- a/java/sdo/plugin/pom.xml
+++ b/java/sdo/plugin/pom.xml
@@ -66,4 +66,41 @@
<scope>compile</scope>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestEntries>
+ <X-Compile-Source-JDK>1.4</X-Compile-Source-JDK>
+ <X-Compile-Target-JDK>1.4</X-Compile-Target-JDK>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>2.1</version>
+ <configuration>
+ <archive>
+ <manifestEntries>
+ <Extension-Name>${project.artifactId}</Extension-Name>
+ <Specification-Title>${project.name}</Specification-Title>
+ <Specification-Vendor>${project.organization.name}</Specification-Vendor>
+ <Specification-Version>${version}</Specification-Version>
+ <Implementation-Title>${project.artifactId}</Implementation-Title>
+ <Implementation-Vendor>${project.organization.name}</Implementation-Vendor>
+ <Implementation-Vendor-Id>org.apache</Implementation-Vendor-Id>
+ <Implementation-Version>${project.version}</Implementation-Version>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
</project>
diff --git a/java/sdo/plugin/src/main/resources/META-INF/NOTICE b/java/sdo/plugin/src/main/resources/META-INF/NOTICE
index 6901a96038..9f9572a167 100644
--- a/java/sdo/plugin/src/main/resources/META-INF/NOTICE
+++ b/java/sdo/plugin/src/main/resources/META-INF/NOTICE
@@ -4,5 +4,4 @@ Copyright (c) 2005 - 2008 The Apache Software Foundation
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/java/sdo/plugin/src/main/resources/META-INF/README.txt b/java/sdo/plugin/src/main/resources/META-INF/README.txt
index 687f357105..1b8144f7c5 100644
--- a/java/sdo/plugin/src/main/resources/META-INF/README.txt
+++ b/java/sdo/plugin/src/main/resources/META-INF/README.txt
@@ -1,5 +1,5 @@
-Apache Tuscany 1.1-incubating build (February 2008)
-===============================================
+Apache Tuscany 1.1-incubating build (April 2008)
+================================================
http://incubator.apache.org/tuscany/
diff --git a/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/MedicalScenario.java b/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/MedicalScenario.java
index 1e288ccc48..916fe9405c 100644
--- a/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/MedicalScenario.java
+++ b/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/MedicalScenario.java
@@ -1,424 +1,424 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.samples.sdo.advanced;
-
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tuscany.samples.sdo.SampleBase;
-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;
-
-/**
- * This sample is based on a 2 part article by Kelvin Goodson and Geoffrey Winn.
- * See <A href="http://soa.sys-con.com/read/313547.htm">Part1</A> and <A
- * href="http://soa.sys-con.com/read/358059.htm">Part 2</A> of the article.
- * <p>
- * <h3>Running this Sample</h3> See <A HREF="../../../../../../index.html"
- * target="_top">the main overview</A> for instructions on how to run this
- * sample.
- */
-public class MedicalScenario extends SampleBase {
-
- private static final String sdoApiUri = "commonj.sdo";
-
- private static final String peopleURI = "www.example.org/people";
-
- private static final String medicalURI = "www.example.org/MedicalTest";
-
- boolean typesViaAPI = false;
-
- private static final String usage = " [-api |-xsd]\n"
- + " -api : define the types using the SDO API\n"
- + " -xsd : define the types using an XML schema file";
-
- public MedicalScenario(String[] args, Integer userLevel) {
-
- super(userLevel, SAMPLE_LEVEL_ADVANCED);
-
- if (args.length > 1) {
- printUsage(args);
- System.exit(-1);
- }
- if (args.length == 1) {
- if (args[0].equals("-xsd")) {
- typesViaAPI = false;
- } else if (args[0].equals("-api")) {
- typesViaAPI = true;
- } else {
- printUsage(args);
- System.exit(-1);
- }
- }
- }
-
- public MedicalScenario(Integer userLevel) {
- super(userLevel, SAMPLE_LEVEL_ADVANCED);
- }
-
-
- private void printUsage(String[] args) {
- System.out.println("Usage: " + this.getClass().getName() + usage);
- }
-
- /**
- * @param args
- * @throws Exception
- */
- public static void main(String[] args) throws Exception {
-
- MedicalScenario s = new MedicalScenario(args, COMMENTARY_FOR_NOVICE);
- s.run();
-
- }
-
- /*
- * metadata for the sample documenting the areas of SDO that are explored
- */
- public static int [] CORE_FUNCTION = {
- SDOFacets.CONTAINMENT,
- SDOFacets.CREATE_TYPES_USING_THE_SDO_API,
- SDOFacets.CREATE_TYPES_USING_XML_SCHEMA,
- SDOFacets.OPEN_CONTENT,
- SDOFacets.NON_CONTAINMENT
- };
-
- public static int [] SIGNIFICANT_FUNCTION = {
- SDOFacets.CREATE_DATAOBJECTS_BY_NAME,
- SDOFacets.ISMANY_PROPERTIES,
- SDOFacets.GENERIC_DATA_GRAPH_TRAVERSAL,
- SDOFacets.SAVING_DATA_TO_XML
- };
-
- public void runSample() throws Exception {
-
- HelperContext scope = SDOUtil.createHelperContext();
-
- if (typesViaAPI) {
-
- commentary("In this execution of the sample we use Types created\n"
- + "using the SDO API");
-
- createTypesViaAPI(scope);
-
- } else {
-
- commentary("In this execution of the sample we use Types created\n"
- + "by loading an XMLSchema");
-
- loadTypesFromXMLSchemaFile(scope, "MedicalTest.xsd");
-
- }
-
- commentary(
- COMMENTARY_FOR_NOVICE,
- "The DataFactory associated with the scope that the types were created within\n"
- + "can be used to create an instance of the Person Type\n\n"
- + "DataFactory dataFactory = scope.getDataFactory();\n"
- + "DataObject person1 = dataFactory.create(\"www.example.org/people\", \"Person\");");
-
- DataFactory dataFactory = scope.getDataFactory();
- DataObject person1 = dataFactory.create("www.example.org/people", "Person");
-
- commentary("The setString() of dataObject method is used to set the properties of the\n"
- + "new Person DataObject, including a unique identifier reference value\n"
- + "for the Person instance.\n\n"
- + "person1.setString(\"id\", \"1\");\n"
- + "person1.setString(\"name\", \"Joe Johnson Snr.\");\n"
- + "person1.setString(\"gender\", \"male\"););");
-
- person1.setString("id", "1");
- person1.setString("name", "Joe Johnson Snr.");
- person1.setString("gender", "male");
-
- commentary("An alternative approach to using the DataFactory directly to create\n"
- + "all DataObjects is to use a top-down approach, where we create the\n"
- + "root object for a data graph, and then use the createDataObject(String propertyName)\n"
- + "method to create the contained DataObjects. Here we create the overall\n"
- + "medical test DataObject, and then create the contained \"referrals\" DataObject\n\n"
- + "DataObject test = dataFactory.create(\"www.example.org/MedicalTest\", \"Test\");\n"
- + "DataObject referrals = test.createDataObject(\"referrals\");");
-
- DataObject test = dataFactory.create("www.example.org/MedicalTest", "Test");
- DataObject referrals = test.createDataObject("referrals");
-
- commentary("Now we can add the person we created earlier into the set of people who have\n"
- + "been referred for this medical test.\n\n"
- + "test.set(\"referrals\", referrals);\n"
- + "referrals.getList(\"person\").add(person1);");
-
- test.set("referrals", referrals);
- referrals.getList("person").add(person1);
-
- commentary("Let's take a look at how the current state of the data"
- + "graph is rendered in XML ...");
-
- System.out.println(scope.getXMLHelper().save(test,
- "www.example.org/MedicalTest", "test"));
-
- commentary("The scenario unfolds and the Joe Johnson Snr. becomes a patient\n\n"
- + "DataObject patients = test.createDataObject(\"patients\");\n"
- + "patients.getList(\"person\").add(person1);");
-
- DataObject patients = test.createDataObject("patients");
-
- patients.getList("person").add(person1);
-
- commentary("Having added Joe Johnson Snr. to the set of patients we can see\n"
- + "the way that SDO preserves a single containment hierarchy within a\n"
- + "datagraph. If we look at the XML rendering of the graph again, we will\n"
- + "see that by adding him to the set of patients he has been removed from the\n"
- + "containment property associated with the referrals set ...");
-
- System.out.println(scope.getXMLHelper().save(test,
- "www.example.org/MedicalTest", "test"));
-
- commentary("The 'Person' Type we are making use of here has been designed to be\n"
- + "multi-purpose, in that the type has been declared to be 'Open'.\n"
- + "That means that we can make use of 'Open Content' Properties\n"
- + "(If the type system has been defined using an XML schema\n"
- + "then these properties will derive from global elements)\n"
- + "We can look up open content Properties using the TypeHelper\n\n"
- + "Property conditionProperty = scope.getTypeHelper().getOpenContentProperty(\n"
- + " \"www.example.org/MedicalTest\", \"condition\");");
-
- Property conditionProperty = scope.getTypeHelper().getOpenContentProperty(
- "www.example.org/MedicalTest", "condition");
-
- commentary("We can create a value of the appropriate Type for this open\n"
- + "content Property\n\n"
- + "DataObject condition = dataFactory.create(conditionProperty.getType());\n"
- + "condition.setString(\"name\", \"Panar Syndrome\");");
-
- DataObject condition = dataFactory.create(conditionProperty.getType());
- condition.setString("name", "Panar Syndrome");
-
- commentary("If you ask a DataObject that has an 'Open' Type for its list of\n"
- + "values associated with an open content Property, and the DataObject\n"
- + "doesn't currently have any values for the Property, it will return\n"
- + "an empty list. We can use the list to add values for the Property\n\n"
- + "List conditions = person1.getList(conditionProperty);\n"
- + "conditions.add(condition);");
-
- List conditions = person1.getList(conditionProperty);
- conditions.add(condition);
-
- commentary("A further look at the data graph in XML form shows\n"
- + "the presence of the new condition Property's value ...");
-
- System.out.println(scope.getXMLHelper().save(test,
- "www.example.org/MedicalTest", "test"));
-
- commentary("Having looked at the way SDO handles Open content\n"
- + "We now turn our attention to 'non-containment' relationships.\n"
- + "To do this we first create the set of people in the test that\n"
- + "constitute the blood relatives of patients -- 'relatives'\n"
- + "and define a new person to be Joe Johnson Snr's child.\n\n"
- + "DataObject relatives = test.createDataObject(\"relatives\");\n"
- + "DataObject person2 = relatives.createDataObject(\"person\");\n"
- + "person2.setString(\"id\", \"2\");\n"
- + "person2.setString(\"name\", \"Joe Johnson Jnr.\");\n"
- + "person2.setString(\"gender\", \"male\");");
-
- DataObject relatives = test.createDataObject("relatives");
- DataObject person2 = relatives.createDataObject("person");
-
- person2.setString("id", "2");
- person2.setString("name", "Joe Johnson Jnr.");
- person2.setString("gender", "male");
-
- commentary("Another quick look at the XML rendering of the graph confirms that\n"
- + "the set of relatives now includes Joe Johnson Jnr, but we haven't yet\n"
- + "defined who he is related to, or how.");
-
- System.out.println(scope.getXMLHelper().save(test,
- "www.example.org/MedicalTest", "test"));
-
- commentary("The Person type has a Property 'relative'\n"
- + "so we create a relative for Joe Johnson Snr.\n\n"
- + "DataObject relation = person1.createDataObject(\"relative\");\n"
- + "relation.set(\"target\", person2);\n"
- + "relation.set(\"relationship\", \"child\");");
-
- DataObject relation = person1.createDataObject("relative");
- relation.set("target", person2);
- relation.set("relationship", "child");
-
- commentary("Now when we look at the XML rendering of the data graph\n"
- + "we can see that the action of setting the 'target' of the\n"
- + "relationship to Joe Johnson Jnr didn't displace him from the\n"
- + "set of 'relatives', because the 'target' Property is a\n"
- + "non-containment Property. This non-containment relationship\n"
- + "is reflected in the XML by a reference to the Person DataObject\n"
- + "describing Joe Johnson Jnr, \"2\" ...\n"
- + "If the Type system has been created from an XML schema then the\n"
- + "unique ID of the target can be used in the serialization.\n"
- + "If however the type system was defined dynamically, then the reference\n"
- + "will be represented as an XPath from the root of the data graph.");
-
- System.out.println(scope.getXMLHelper().save(test,
- "www.example.org/MedicalTest", "test"));
-
- commentary("Now that the graph is complete we can use the PrintDataGraph sample utility\n" +
- "to reveal the full SDO nature of the final data graph\n\n" +
- "");
-
- PrintDataGraph printer = new PrintDataGraph(COMMENTARY_FOR_ADVANCED);
- printer.printDataObject(test);
- System.out.println(printer.getBuf());
- }
-
- /**
- * @throws Exception
- * @throws FileNotFoundException
- */
- private void createTypesViaAPI(HelperContext scope) throws Exception {
-
- List typeDeclarations = new ArrayList();
-
- TypeHelper typeHelper = scope.getTypeHelper();
-
- Type stringType = typeHelper.getType(sdoApiUri, "String");
- Type dateType = typeHelper.getType(sdoApiUri, "Date");
- Type booleanType = typeHelper.getType(sdoApiUri, "Boolean");
-
- // <complexType name="Person">
- // <sequence>
- // <element name="dob" type="date"/>
- // <element name="relative" maxOccurs="unbounded" type="tns:Relative"/>
- // <any namespace="##other" processContents="lax" maxOccurs="unbounded"/>
- // </sequence>
- // <attribute name="id" type="ID"/>
- // <attribute name="name" type="string"/>
- // <attribute name="gender" type = "tns:Gender"/>
- // </complexType>
-
- DataObject personTypeDesc = createTypeDescription(scope, peopleURI,
- "Person");
- typeDeclarations.add(personTypeDesc);
-
- addPropertyDescription(personTypeDesc, stringType, "name");
- addPropertyDescription(personTypeDesc, dateType, "dob");
- addPropertyDescription(personTypeDesc, stringType, "id"); // set to unique
- // identifier?
- addPropertyDescription(personTypeDesc, stringType, "gender"); // restrict?
-
- DataObject relativeType = createTypeDescription(scope, peopleURI,
- "Relative"); // forward declare the Relative type
- typeDeclarations.add(relativeType);
-
- DataObject rp = addPropertyDescription(personTypeDesc, relativeType,
- "relative");
- rp.setBoolean("many", true);
- personTypeDesc.set("open", Boolean.TRUE);
-
- // <complexType name="Relative">
- // <attribute name="target" type="IDREF" sdoxml:propertyType="tns:Person"
- // use="required"/>
- // <attribute name="relationship" type="string" />
- // <attribute name="genetic" use="optional" type="boolean"/>
- // </complexType>
-
- addPropertyDescription(relativeType, stringType, "relationship");
- addPropertyDescription(relativeType, booleanType, "genetic");
- DataObject targetPersonProp = addPropertyDescription(relativeType,
- personTypeDesc, "target");
- targetPersonProp.setBoolean("containment", false);
-
- // <complexType name="PersonSet">
- // <sequence>
- // <element name="person" type="tns:Person" maxOccurs="unbounded"/>
- // </sequence>
- // </complexType>
-
- DataObject pSet = createTypeDescription(scope, peopleURI, "PersonSet");
- typeDeclarations.add(pSet);
- DataObject pSetProperty = addPropertyDescription(pSet, personTypeDesc,
- "person");
- pSetProperty.setBoolean("many", true);
-
- // <complexType name="Condition">
- // <sequence>
- // <element name="diagnosed" type="date" />
- // </sequence>
- // <attribute name="name" type="tns:ConditionName" />
- // </complexType>
-
- DataObject condition = createTypeDescription(scope, medicalURI, "Condition");
- typeDeclarations.add(condition);
- addPropertyDescription(condition, booleanType, "diagnosed");
- addPropertyDescription(condition, stringType, "name"); // constrain?
-
- // <complexType name="Test">
- // <sequence>
- // <element name="referrals" type="people:PersonSet" />
- // <element name="patients" type="people:PersonSet" />
- // <element name="relatives" type="people:PersonSet" />
- // </sequence>
- // </complexType>
-
- DataObject testType = createTypeDescription(scope, medicalURI, "Test");
- typeDeclarations.add(testType);
- addPropertyDescription(testType, pSet, "referrals");
- addPropertyDescription(testType, pSet, "patients");
- addPropertyDescription(testType, pSet, "relatives");
-
- List types = typeHelper.define(typeDeclarations);
-
- DataObject p = scope.getDataFactory().create("commonj.sdo", "Property");
- p.set("type", typeHelper.getType(medicalURI, "Condition"));
- p.set("name", "condition");
- p.setBoolean("many", true);
- p.setBoolean("containment", true); // why is this not the default?
-
- typeHelper.defineOpenContentProperty(medicalURI, p);
-
- }
-
- /**
- * @param uri
- * @param name
- * @return
- */
- private DataObject createTypeDescription(HelperContext scope, String uri,
- String name) {
- DataObject typeDesc = scope.getDataFactory().create(sdoApiUri, "Type");
- typeDesc.set("name", name);
- typeDesc.set("uri", uri);
- return typeDesc;
- }
-
- private DataObject addPropertyDescription(
- DataObject containerTypeDescription, Object propertyType,
- String propertyName) {
- DataObject property = containerTypeDescription.createDataObject("property");
- property.set("type", propertyType);
- property.setString("name", propertyName);
- property.setBoolean("containment", true);
- return property;
- }
-
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.samples.sdo.advanced;
+
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.samples.sdo.SampleBase;
+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;
+
+/**
+ * This sample is based on a 2 part article by Kelvin Goodson and Geoffrey Winn.
+ * See <A href="http://soa.sys-con.com/read/313547.htm">Part1</A> and <A
+ * href="http://soa.sys-con.com/read/358059.htm">Part 2</A> of the article.
+ * <p>
+ * <h3>Running this Sample</h3> See <A HREF="../../../../../../index.html"
+ * target="_top">the main overview</A> for instructions on how to run this
+ * sample.
+ */
+public class MedicalScenario extends SampleBase {
+
+ private static final String sdoApiUri = "commonj.sdo";
+
+ private static final String peopleURI = "www.example.org/people";
+
+ private static final String medicalURI = "www.example.org/MedicalTest";
+
+ boolean typesViaAPI = false;
+
+ private static final String usage = " [-api |-xsd]\n"
+ + " -api : define the types using the SDO API\n"
+ + " -xsd : define the types using an XML schema file";
+
+ public MedicalScenario(String[] args, Integer userLevel) {
+
+ super(userLevel, SAMPLE_LEVEL_ADVANCED);
+
+ if (args.length > 1) {
+ printUsage(args);
+ System.exit(-1);
+ }
+ if (args.length == 1) {
+ if (args[0].equals("-xsd")) {
+ typesViaAPI = false;
+ } else if (args[0].equals("-api")) {
+ typesViaAPI = true;
+ } else {
+ printUsage(args);
+ System.exit(-1);
+ }
+ }
+ }
+
+ public MedicalScenario(Integer userLevel) {
+ super(userLevel, SAMPLE_LEVEL_ADVANCED);
+ }
+
+
+ private void printUsage(String[] args) {
+ System.out.println("Usage: " + this.getClass().getName() + usage);
+ }
+
+ /**
+ * @param args
+ * @throws Exception
+ */
+ public static void main(String[] args) throws Exception {
+
+ MedicalScenario s = new MedicalScenario(args, COMMENTARY_FOR_NOVICE);
+ s.run();
+
+ }
+
+ /*
+ * metadata for the sample documenting the areas of SDO that are explored
+ */
+ public static int [] CORE_FUNCTION = {
+ SDOFacets.CONTAINMENT,
+ SDOFacets.CREATE_TYPES_USING_THE_SDO_API,
+ SDOFacets.CREATE_TYPES_USING_XML_SCHEMA,
+ SDOFacets.OPEN_CONTENT,
+ SDOFacets.NON_CONTAINMENT
+ };
+
+ public static int [] SIGNIFICANT_FUNCTION = {
+ SDOFacets.CREATE_DATAOBJECTS_BY_NAME,
+ SDOFacets.ISMANY_PROPERTIES,
+ SDOFacets.GENERIC_DATA_GRAPH_TRAVERSAL,
+ SDOFacets.SAVING_DATA_TO_XML
+ };
+
+ public void runSample() throws Exception {
+
+ HelperContext scope = SDOUtil.createHelperContext();
+
+ if (typesViaAPI) {
+
+ commentary("In this execution of the sample we use Types created\n"
+ + "using the SDO API");
+
+ createTypesViaAPI(scope);
+
+ } else {
+
+ commentary("In this execution of the sample we use Types created\n"
+ + "by loading an XMLSchema");
+
+ loadTypesFromXMLSchemaFile(scope, "MedicalTest.xsd");
+
+ }
+
+ commentary(
+ COMMENTARY_FOR_NOVICE,
+ "The DataFactory associated with the scope that the types were created within\n"
+ + "can be used to create an instance of the Person Type\n\n"
+ + "DataFactory dataFactory = scope.getDataFactory();\n"
+ + "DataObject person1 = dataFactory.create(\"www.example.org/people\", \"Person\");");
+
+ DataFactory dataFactory = scope.getDataFactory();
+ DataObject person1 = dataFactory.create("www.example.org/people", "Person");
+
+ commentary("The setString() of dataObject method is used to set the properties of the\n"
+ + "new Person DataObject, including a unique identifier reference value\n"
+ + "for the Person instance.\n\n"
+ + "person1.setString(\"id\", \"1\");\n"
+ + "person1.setString(\"name\", \"Joe Johnson Snr.\");\n"
+ + "person1.setString(\"gender\", \"male\"););");
+
+ person1.setString("id", "1");
+ person1.setString("name", "Joe Johnson Snr.");
+ person1.setString("gender", "male");
+
+ commentary("An alternative approach to using the DataFactory directly to create\n"
+ + "all DataObjects is to use a top-down approach, where we create the\n"
+ + "root object for a data graph, and then use the createDataObject(String propertyName)\n"
+ + "method to create the contained DataObjects. Here we create the overall\n"
+ + "medical test DataObject, and then create the contained \"referrals\" DataObject\n\n"
+ + "DataObject test = dataFactory.create(\"www.example.org/MedicalTest\", \"Test\");\n"
+ + "DataObject referrals = test.createDataObject(\"referrals\");");
+
+ DataObject test = dataFactory.create("www.example.org/MedicalTest", "Test");
+ DataObject referrals = test.createDataObject("referrals");
+
+ commentary("Now we can add the person we created earlier into the set of people who have\n"
+ + "been referred for this medical test.\n\n"
+ + "test.set(\"referrals\", referrals);\n"
+ + "referrals.getList(\"person\").add(person1);");
+
+ test.set("referrals", referrals);
+ referrals.getList("person").add(person1);
+
+ commentary("Let's take a look at how the current state of the data"
+ + "graph is rendered in XML ...");
+
+ System.out.println(scope.getXMLHelper().save(test,
+ "www.example.org/MedicalTest", "test"));
+
+ commentary("The scenario unfolds and the Joe Johnson Snr. becomes a patient\n\n"
+ + "DataObject patients = test.createDataObject(\"patients\");\n"
+ + "patients.getList(\"person\").add(person1);");
+
+ DataObject patients = test.createDataObject("patients");
+
+ patients.getList("person").add(person1);
+
+ commentary("Having added Joe Johnson Snr. to the set of patients we can see\n"
+ + "the way that SDO preserves a single containment hierarchy within a\n"
+ + "datagraph. If we look at the XML rendering of the graph again, we will\n"
+ + "see that by adding him to the set of patients he has been removed from the\n"
+ + "containment property associated with the referrals set ...");
+
+ System.out.println(scope.getXMLHelper().save(test,
+ "www.example.org/MedicalTest", "test"));
+
+ commentary("The 'Person' Type we are making use of here has been designed to be\n"
+ + "multi-purpose, in that the type has been declared to be 'Open'.\n"
+ + "That means that we can make use of 'Open Content' Properties\n"
+ + "(If the type system has been defined using an XML schema\n"
+ + "then these properties will derive from global elements)\n"
+ + "We can look up open content Properties using the TypeHelper\n\n"
+ + "Property conditionProperty = scope.getTypeHelper().getOpenContentProperty(\n"
+ + " \"www.example.org/MedicalTest\", \"condition\");");
+
+ Property conditionProperty = scope.getTypeHelper().getOpenContentProperty(
+ "www.example.org/MedicalTest", "condition");
+
+ commentary("We can create a value of the appropriate Type for this open\n"
+ + "content Property\n\n"
+ + "DataObject condition = dataFactory.create(conditionProperty.getType());\n"
+ + "condition.setString(\"name\", \"Panar Syndrome\");");
+
+ DataObject condition = dataFactory.create(conditionProperty.getType());
+ condition.setString("name", "Panar Syndrome");
+
+ commentary("If you ask a DataObject that has an 'Open' Type for its list of\n"
+ + "values associated with an open content Property, and the DataObject\n"
+ + "doesn't currently have any values for the Property, it will return\n"
+ + "an empty list. We can use the list to add values for the Property\n\n"
+ + "List conditions = person1.getList(conditionProperty);\n"
+ + "conditions.add(condition);");
+
+ List conditions = person1.getList(conditionProperty);
+ conditions.add(condition);
+
+ commentary("A further look at the data graph in XML form shows\n"
+ + "the presence of the new condition Property's value ...");
+
+ System.out.println(scope.getXMLHelper().save(test,
+ "www.example.org/MedicalTest", "test"));
+
+ commentary("Having looked at the way SDO handles Open content\n"
+ + "We now turn our attention to 'non-containment' relationships.\n"
+ + "To do this we first create the set of people in the test that\n"
+ + "constitute the blood relatives of patients -- 'relatives'\n"
+ + "and define a new person to be Joe Johnson Snr's child.\n\n"
+ + "DataObject relatives = test.createDataObject(\"relatives\");\n"
+ + "DataObject person2 = relatives.createDataObject(\"person\");\n"
+ + "person2.setString(\"id\", \"2\");\n"
+ + "person2.setString(\"name\", \"Joe Johnson Jnr.\");\n"
+ + "person2.setString(\"gender\", \"male\");");
+
+ DataObject relatives = test.createDataObject("relatives");
+ DataObject person2 = relatives.createDataObject("person");
+
+ person2.setString("id", "2");
+ person2.setString("name", "Joe Johnson Jnr.");
+ person2.setString("gender", "male");
+
+ commentary("Another quick look at the XML rendering of the graph confirms that\n"
+ + "the set of relatives now includes Joe Johnson Jnr, but we haven't yet\n"
+ + "defined who he is related to, or how.");
+
+ System.out.println(scope.getXMLHelper().save(test,
+ "www.example.org/MedicalTest", "test"));
+
+ commentary("The Person type has a Property 'relative'\n"
+ + "so we create a relative for Joe Johnson Snr.\n\n"
+ + "DataObject relation = person1.createDataObject(\"relative\");\n"
+ + "relation.set(\"target\", person2);\n"
+ + "relation.set(\"relationship\", \"child\");");
+
+ DataObject relation = person1.createDataObject("relative");
+ relation.set("target", person2);
+ relation.set("relationship", "child");
+
+ commentary("Now when we look at the XML rendering of the data graph\n"
+ + "we can see that the action of setting the 'target' of the\n"
+ + "relationship to Joe Johnson Jnr didn't displace him from the\n"
+ + "set of 'relatives', because the 'target' Property is a\n"
+ + "non-containment Property. This non-containment relationship\n"
+ + "is reflected in the XML by a reference to the Person DataObject\n"
+ + "describing Joe Johnson Jnr, \"2\" ...\n"
+ + "If the Type system has been created from an XML schema then the\n"
+ + "unique ID of the target can be used in the serialization.\n"
+ + "If however the type system was defined dynamically, then the reference\n"
+ + "will be represented as an XPath from the root of the data graph.");
+
+ System.out.println(scope.getXMLHelper().save(test,
+ "www.example.org/MedicalTest", "test"));
+
+ commentary("Now that the graph is complete we can use the PrintDataGraph sample utility\n" +
+ "to reveal the full SDO nature of the final data graph\n\n" +
+ "");
+
+ PrintDataGraph printer = new PrintDataGraph(COMMENTARY_FOR_ADVANCED);
+ printer.printDataObject(test);
+ System.out.println(printer.getBuf());
+ }
+
+ /**
+ * @throws Exception
+ * @throws FileNotFoundException
+ */
+ private void createTypesViaAPI(HelperContext scope) throws Exception {
+
+ List typeDeclarations = new ArrayList();
+
+ TypeHelper typeHelper = scope.getTypeHelper();
+
+ Type stringType = typeHelper.getType(sdoApiUri, "String");
+ Type dateType = typeHelper.getType(sdoApiUri, "Date");
+ Type booleanType = typeHelper.getType(sdoApiUri, "Boolean");
+
+ // <complexType name="Person">
+ // <sequence>
+ // <element name="dob" type="date"/>
+ // <element name="relative" maxOccurs="unbounded" type="tns:Relative"/>
+ // <any namespace="##other" processContents="lax" maxOccurs="unbounded"/>
+ // </sequence>
+ // <attribute name="id" type="ID"/>
+ // <attribute name="name" type="string"/>
+ // <attribute name="gender" type = "tns:Gender"/>
+ // </complexType>
+
+ DataObject personTypeDesc = createTypeDescription(scope, peopleURI,
+ "Person");
+ typeDeclarations.add(personTypeDesc);
+
+ addPropertyDescription(personTypeDesc, stringType, "name");
+ addPropertyDescription(personTypeDesc, dateType, "dob");
+ addPropertyDescription(personTypeDesc, stringType, "id"); // set to unique
+ // identifier?
+ addPropertyDescription(personTypeDesc, stringType, "gender"); // restrict?
+
+ DataObject relativeType = createTypeDescription(scope, peopleURI,
+ "Relative"); // forward declare the Relative type
+ typeDeclarations.add(relativeType);
+
+ DataObject rp = addPropertyDescription(personTypeDesc, relativeType,
+ "relative");
+ rp.setBoolean("many", true);
+ personTypeDesc.set("open", Boolean.TRUE);
+
+ // <complexType name="Relative">
+ // <attribute name="target" type="IDREF" sdoxml:propertyType="tns:Person"
+ // use="required"/>
+ // <attribute name="relationship" type="string" />
+ // <attribute name="genetic" use="optional" type="boolean"/>
+ // </complexType>
+
+ addPropertyDescription(relativeType, stringType, "relationship");
+ addPropertyDescription(relativeType, booleanType, "genetic");
+ DataObject targetPersonProp = addPropertyDescription(relativeType,
+ personTypeDesc, "target");
+ targetPersonProp.setBoolean("containment", false);
+
+ // <complexType name="PersonSet">
+ // <sequence>
+ // <element name="person" type="tns:Person" maxOccurs="unbounded"/>
+ // </sequence>
+ // </complexType>
+
+ DataObject pSet = createTypeDescription(scope, peopleURI, "PersonSet");
+ typeDeclarations.add(pSet);
+ DataObject pSetProperty = addPropertyDescription(pSet, personTypeDesc,
+ "person");
+ pSetProperty.setBoolean("many", true);
+
+ // <complexType name="Condition">
+ // <sequence>
+ // <element name="diagnosed" type="date" />
+ // </sequence>
+ // <attribute name="name" type="tns:ConditionName" />
+ // </complexType>
+
+ DataObject condition = createTypeDescription(scope, medicalURI, "Condition");
+ typeDeclarations.add(condition);
+ addPropertyDescription(condition, booleanType, "diagnosed");
+ addPropertyDescription(condition, stringType, "name"); // constrain?
+
+ // <complexType name="Test">
+ // <sequence>
+ // <element name="referrals" type="people:PersonSet" />
+ // <element name="patients" type="people:PersonSet" />
+ // <element name="relatives" type="people:PersonSet" />
+ // </sequence>
+ // </complexType>
+
+ DataObject testType = createTypeDescription(scope, medicalURI, "Test");
+ typeDeclarations.add(testType);
+ addPropertyDescription(testType, pSet, "referrals");
+ addPropertyDescription(testType, pSet, "patients");
+ addPropertyDescription(testType, pSet, "relatives");
+
+ List types = typeHelper.define(typeDeclarations);
+
+ DataObject p = scope.getDataFactory().create("commonj.sdo", "Property");
+ p.set("type", typeHelper.getType(medicalURI, "Condition"));
+ p.set("name", "condition");
+ p.setBoolean("many", true);
+ p.setBoolean("containment", true); // why is this not the default?
+
+ typeHelper.defineOpenContentProperty(medicalURI, p);
+
+ }
+
+ /**
+ * @param uri
+ * @param name
+ * @return
+ */
+ private DataObject createTypeDescription(HelperContext scope, String uri,
+ String name) {
+ DataObject typeDesc = scope.getDataFactory().create(sdoApiUri, "Type");
+ typeDesc.set("name", name);
+ typeDesc.set("uri", uri);
+ return typeDesc;
+ }
+
+ private DataObject addPropertyDescription(
+ DataObject containerTypeDescription, Object propertyType,
+ String propertyName) {
+ DataObject property = containerTypeDescription.createDataObject("property");
+ property.set("type", propertyType);
+ property.setString("name", propertyName);
+ property.setBoolean("containment", true);
+ return property;
+ }
+
+}
diff --git a/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/MedicalScenarioWithChangeMonitoring.java b/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/MedicalScenarioWithChangeMonitoring.java
index 0dc93b0008..32d63f4335 100644
--- a/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/MedicalScenarioWithChangeMonitoring.java
+++ b/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/MedicalScenarioWithChangeMonitoring.java
@@ -1,449 +1,449 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.samples.sdo.advanced;
-
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tuscany.samples.sdo.SampleBase;
-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;
-
-/**
- * This sample is based on a 2 part article by Kelvin Goodson and Geoffrey Winn.
- * In this variant of the sample the model for the test includes change monitoring.
- * The facility for undoing changes on the basis of the change monitoring is
- * demonstrated.
- * See <A href="http://soa.sys-con.com/read/313547.htm">Part1</A> and <A
- * href="http://soa.sys-con.com/read/358059.htm">Part 2</A> of the article.
- * <p>
- * <h3>Running this Sample</h3> See <A HREF="../../../../../../index.html"
- * target="_top">the main overview</A> for instructions on how to run this
- * sample.
- */
-public class MedicalScenarioWithChangeMonitoring extends SampleBase {
-
- private static final String sdoApiUri = "commonj.sdo";
-
- private static final String peopleURI = "www.example.org/people";
-
- private static final String medicalURI = "www.example.org/MedicalTest";
-
- boolean typesViaAPI = false;
-
- private static final String usage = " [-api |-xsd]\n"
- + " -api : define the types using the SDO API\n"
- + " -xsd : define the types using an XML schema file";
-
- public MedicalScenarioWithChangeMonitoring(String[] args, Integer userLevel) {
-
- super(userLevel, SAMPLE_LEVEL_ADVANCED);
-
- if (args.length > 1) {
- printUsage(args);
- System.exit(-1);
- }
- if (args.length == 1) {
- if (args[0].equals("-xsd")) {
- typesViaAPI = false;
- } else if (args[0].equals("-api")) {
- typesViaAPI = true;
- } else {
- printUsage(args);
- System.exit(-1);
- }
- }
- }
-
- public MedicalScenarioWithChangeMonitoring(Integer userLevel) {
- super(userLevel, SAMPLE_LEVEL_ADVANCED);
- }
-
-
- private void printUsage(String[] args) {
- System.out.println("Usage: " + this.getClass().getName() + usage);
- }
-
- /**
- * @param args
- * @throws Exception
- */
- public static void main(String[] args) throws Exception {
-
- MedicalScenarioWithChangeMonitoring s = new MedicalScenarioWithChangeMonitoring(args, COMMENTARY_FOR_NOVICE);
- s.run();
-
- }
-
- /*
- * metadata for the sample documenting the areas of SDO that are explored
- */
- public static int [] CORE_FUNCTION = {
- SDOFacets.CONTAINMENT,
- SDOFacets.CREATE_TYPES_USING_THE_SDO_API,
- SDOFacets.CREATE_TYPES_USING_XML_SCHEMA,
- SDOFacets.OPEN_CONTENT,
- SDOFacets.NON_CONTAINMENT,
- SDOFacets.CHANGE_MONITORING_USING_A_CHANGESUMMARY_PROPERTY_ON_A_DATAOBJECT
- };
-
- public static int [] SIGNIFICANT_FUNCTION = {
- SDOFacets.CREATE_DATAOBJECTS_BY_NAME,
- SDOFacets.ISMANY_PROPERTIES,
- SDOFacets.GENERIC_DATA_GRAPH_TRAVERSAL,
- SDOFacets.SAVING_DATA_TO_XML
- };
-
- public void runSample() throws Exception {
-
- HelperContext scope = SDOUtil.createHelperContext();
-
- if (typesViaAPI) {
-
- commentary("In this execution of the sample we use Types created\n"
- + "using the SDO API");
-
- createTypesViaAPI(scope);
-
- } else {
-
- commentary("In this execution of the sample we use Types created\n"
- + "by loading a variant of the XMLSchema that includes a change summary Property");
-
- loadTypesFromXMLSchemaFile(scope, "MedicalTest_CS.xsd");
-
- }
-
- commentary(
- COMMENTARY_FOR_NOVICE,
- "The DataFactory associated with the scope that the types were created within\n"
- + "can be used to create an instance of the Person Type\n\n"
- + "DataFactory dataFactory = scope.getDataFactory();\n"
- + "DataObject person1 = dataFactory.create(\"www.example.org/people\", \"Person\");");
-
- DataFactory dataFactory = scope.getDataFactory();
- DataObject person1 = dataFactory.create("www.example.org/people", "Person");
-
- commentary("The setString() of dataObject method is used to set the properties of the\n"
- + "new Person DataObject, including a unique identifier reference value\n"
- + "for the Person instance.\n\n"
- + "person1.setString(\"id\", \"1\");\n"
- + "person1.setString(\"name\", \"Joe Johnson Snr.\");\n"
- + "person1.setString(\"gender\", \"male\"););");
-
- person1.setString("id", "1");
- person1.setString("name", "Joe Johnson Snr.");
- person1.setString("gender", "male");
-
- commentary("An alternative approach to using the DataFactory directly to create\n"
- + "all DataObjects is to use a top-down approach, where we create the\n"
- + "root object for a data graph, and then use the createDataObject(String propertyName)\n"
- + "method to create the contained DataObjects. Here we create the overall\n"
- + "medical test DataObject, and then create the contained \"referrals\" DataObject\n\n"
- + "DataObject test = dataFactory.create(\"www.example.org/MedicalTest\", \"Test\");\n"
- + "DataObject referrals = test.createDataObject(\"referrals\");");
-
- DataObject test = dataFactory.create("www.example.org/MedicalTest", "Test");
-
- DataObject referrals = test.createDataObject("referrals");
-
- commentary("The default state for monitoring changes for the DataObject when created in this\n" +
- "way is the monitoring is switched off, so we switch it on. (Note that if you\n" +
- "get your data graphs from a data Access Service then this service may turn on\n" +
- "change monitoring be default\n\n" +
- "test.getChangeSummary().beginLogging();");
- test.getChangeSummary().beginLogging();
-
- commentary("We'll repeat the whole of the MedicalScenario sample, but then at the \n" +
- "last minute we'll decide it was all wrong and roll back the changes......");
-
- commentary("Now we can add the person we created earlier into the set of people who have\n"
- + "been referred for this medical test.\n\n"
- + "test.set(\"referrals\", referrals);\n"
- + "referrals.getList(\"person\").add(person1);");
-
- test.set("referrals", referrals);
- referrals.getList("person").add(person1);
-
- commentary("Let's take a look at how the current state of the data"
- + "graph is rendered in XML ...");
-
- System.out.println(scope.getXMLHelper().save(test,
- "www.example.org/MedicalTest", "test"));
-
- commentary("The scenario unfolds and the Joe Johnson Snr. becomes a patient\n\n"
- + "DataObject patients = test.createDataObject(\"patients\");\n"
- + "patients.getList(\"person\").add(person1);");
-
- DataObject patients = test.createDataObject("patients");
-
- patients.getList("person").add(person1);
-
- commentary("Having added Joe Johnson Snr. to the set of patients we can see\n"
- + "the way that SDO preserves a single containment hierarchy within a\n"
- + "datagraph. If we look at the XML rendering of the graph again, we will\n"
- + "see that by adding him to the set of patients he has been removed from the\n"
- + "containment property associated with the referrals set ...");
-
- System.out.println(scope.getXMLHelper().save(test,
- "www.example.org/MedicalTest", "test"));
-
- commentary("The 'Person' Type we are making use of here has been designed to be\n"
- + "multi-purpose, in that the type has been declared to be 'Open'.\n"
- + "That means that we can make use of 'Open Content' Properties\n"
- + "(If the type system has been defined using an XML schema\n"
- + "then these properties will derive from global elements)\n"
- + "We can look up open content Properties using the TypeHelper\n\n"
- + "Property conditionProperty = scope.getTypeHelper().getOpenContentProperty(\n"
- + " \"www.example.org/MedicalTest\", \"condition\");");
-
- Property conditionProperty = scope.getTypeHelper().getOpenContentProperty(
- "www.example.org/MedicalTest", "condition");
-
- commentary("We can create a value of the appropriate Type for this open\n"
- + "content Property\n\n"
- + "DataObject condition = dataFactory.create(conditionProperty.getType());\n"
- + "condition.setString(\"name\", \"Panar Syndrome\");");
-
- DataObject condition = dataFactory.create(conditionProperty.getType());
- condition.setString("name", "Panar Syndrome");
-
- commentary("If you ask a DataObject that has an 'Open' Type for its list of\n"
- + "values associated with an open content Property, and the DataObject\n"
- + "doesn't currently have any values for the Property, it will return\n"
- + "an empty list. We can use the list to add values for the Property\n\n"
- + "List conditions = person1.getList(conditionProperty);\n"
- + "conditions.add(condition);");
-
- List conditions = person1.getList(conditionProperty);
- conditions.add(condition);
-
- commentary("A further look at the data graph in XML form shows\n"
- + "the presence of the new condition Property's value ...");
-
- System.out.println(scope.getXMLHelper().save(test,
- "www.example.org/MedicalTest", "test"));
-
- commentary("Having looked at the way SDO handles Open content\n"
- + "We now turn our attention to 'non-containment' relationships.\n"
- + "To do this we first create the set of people in the test that\n"
- + "constitute the blood relatives of patients -- 'relatives'\n"
- + "and define a new person to be Joe Johnson Snr's child.\n\n"
- + "DataObject relatives = test.createDataObject(\"relatives\");\n"
- + "DataObject person2 = relatives.createDataObject(\"person\");\n"
- + "person2.setString(\"id\", \"2\");\n"
- + "person2.setString(\"name\", \"Joe Johnson Jnr.\");\n"
- + "person2.setString(\"gender\", \"male\");");
-
- DataObject relatives = test.createDataObject("relatives");
- DataObject person2 = relatives.createDataObject("person");
-
- person2.setString("id", "2");
- person2.setString("name", "Joe Johnson Jnr.");
- person2.setString("gender", "male");
-
- commentary("Another quick look at the XML rendering of the graph confirms that\n"
- + "the set of relatives now includes Joe Johnson Jnr, but we haven't yet\n"
- + "defined who he is related to, or how.");
-
- System.out.println(scope.getXMLHelper().save(test,
- "www.example.org/MedicalTest", "test"));
-
- commentary("The Person type has a Property 'relative'\n"
- + "so we create a relative for Joe Johnson Snr.\n\n"
- + "DataObject relation = person1.createDataObject(\"relative\");\n"
- + "relation.set(\"target\", person2);\n"
- + "relation.set(\"relationship\", \"child\");");
-
- DataObject relation = person1.createDataObject("relative");
- relation.set("target", person2);
- relation.set("relationship", "child");
-
- commentary("Now when we look at the XML rendering of the data graph\n"
- + "we can see that the action of setting the 'target' of the\n"
- + "relationship to Joe Johnson Jnr didn't displace him from the\n"
- + "set of 'relatives', because the 'target' Property is a\n"
- + "non-containment Property. This non-containment relationship\n"
- + "is reflected in the XML by a reference to the Person DataObject\n"
- + "describing Joe Johnson Jnr, \"2\" ...\n"
- + "If the Type system has been created from an XML schema then the\n"
- + "unique ID of the target can be used in the serialization.\n"
- + "If however the type system was defined dynamically, then the reference\n"
- + "will be represented as an XPath from the root of the data graph.");
-
- System.out.println(scope.getXMLHelper().save(test,
- "www.example.org/MedicalTest", "test"));
-
- commentary("Now that the graph is complete we can use the PrintDataGraph sample utility\n" +
- "to reveal the full SDO nature of the final data graph\n\n" +
- "");
-
- PrintDataGraph printer = new PrintDataGraph(COMMENTARY_FOR_ADVANCED);
- printer.printDataObject(test);
- System.out.println(printer.getBuf());
-
- commentary("But Wait! it's all wrong. Let's go back to our checkpoint where we started monitoring changes\n\n" +
- "test.getChangeSummary().undoChanges();");
-
- test.getChangeSummary().undoChanges();
-
- printer.reset();
- printer.printDataObject(test);
- System.out.println(printer.getBuf());
-
- }
-
- /**
- * @throws Exception
- * @throws FileNotFoundException
- */
- private void createTypesViaAPI(HelperContext scope) throws Exception {
-
- List typeDeclarations = new ArrayList();
-
- TypeHelper typeHelper = scope.getTypeHelper();
-
- Type stringType = typeHelper.getType(sdoApiUri, "String");
- Type dateType = typeHelper.getType(sdoApiUri, "Date");
- Type booleanType = typeHelper.getType(sdoApiUri, "Boolean");
-
- // <complexType name="Person">
- // <sequence>
- // <element name="dob" type="date"/>
- // <element name="relative" maxOccurs="unbounded" type="tns:Relative"/>
- // <any namespace="##other" processContents="lax" maxOccurs="unbounded"/>
- // </sequence>
- // <attribute name="id" type="ID"/>
- // <attribute name="name" type="string"/>
- // <attribute name="gender" type = "tns:Gender"/>
- // </complexType>
-
- DataObject personTypeDesc = createTypeDescription(scope, peopleURI,
- "Person");
- typeDeclarations.add(personTypeDesc);
-
- addPropertyDescription(personTypeDesc, stringType, "name");
- addPropertyDescription(personTypeDesc, dateType, "dob");
- addPropertyDescription(personTypeDesc, stringType, "id"); // set to unique
- // identifier?
- addPropertyDescription(personTypeDesc, stringType, "gender"); // restrict?
-
- DataObject relativeType = createTypeDescription(scope, peopleURI,
- "Relative"); // forward declare the Relative type
- typeDeclarations.add(relativeType);
-
- DataObject rp = addPropertyDescription(personTypeDesc, relativeType,
- "relative");
- rp.setBoolean("many", true);
- personTypeDesc.set("open", Boolean.TRUE);
-
- // <complexType name="Relative">
- // <attribute name="target" type="IDREF" sdoxml:propertyType="tns:Person"
- // use="required"/>
- // <attribute name="relationship" type="string" />
- // <attribute name="genetic" use="optional" type="boolean"/>
- // </complexType>
-
- addPropertyDescription(relativeType, stringType, "relationship");
- addPropertyDescription(relativeType, booleanType, "genetic");
- DataObject targetPersonProp = addPropertyDescription(relativeType,
- personTypeDesc, "target");
- targetPersonProp.setBoolean("containment", false);
-
- // <complexType name="PersonSet">
- // <sequence>
- // <element name="person" type="tns:Person" maxOccurs="unbounded"/>
- // </sequence>
- // </complexType>
-
- DataObject pSet = createTypeDescription(scope, peopleURI, "PersonSet");
- typeDeclarations.add(pSet);
- DataObject pSetProperty = addPropertyDescription(pSet, personTypeDesc,
- "person");
- pSetProperty.setBoolean("many", true);
-
- // <complexType name="Condition">
- // <sequence>
- // <element name="diagnosed" type="date" />
- // </sequence>
- // <attribute name="name" type="tns:ConditionName" />
- // </complexType>
-
- DataObject condition = createTypeDescription(scope, medicalURI, "Condition");
- typeDeclarations.add(condition);
- addPropertyDescription(condition, booleanType, "diagnosed");
- addPropertyDescription(condition, stringType, "name"); // constrain?
-
- // <complexType name="Test">
- // <sequence>
- // <element name="referrals" type="people:PersonSet" />
- // <element name="patients" type="people:PersonSet" />
- // <element name="relatives" type="people:PersonSet" />
- // </sequence>
- // </complexType>
-
- DataObject testType = createTypeDescription(scope, medicalURI, "Test");
- typeDeclarations.add(testType);
- addPropertyDescription(testType, pSet, "referrals");
- addPropertyDescription(testType, pSet, "patients");
- addPropertyDescription(testType, pSet, "relatives");
-
- List types = typeHelper.define(typeDeclarations);
-
- DataObject p = scope.getDataFactory().create("commonj.sdo", "Property");
- p.set("type", typeHelper.getType(medicalURI, "Condition"));
- p.set("name", "condition");
- p.setBoolean("many", true);
- p.setBoolean("containment", true); // why is this not the default?
-
- typeHelper.defineOpenContentProperty(medicalURI, p);
-
- }
-
- /**
- * @param uri
- * @param name
- * @return
- */
- private DataObject createTypeDescription(HelperContext scope, String uri,
- String name) {
- DataObject typeDesc = scope.getDataFactory().create(sdoApiUri, "Type");
- typeDesc.set("name", name);
- typeDesc.set("uri", uri);
- return typeDesc;
- }
-
- private DataObject addPropertyDescription(
- DataObject containerTypeDescription, Object propertyType,
- String propertyName) {
- DataObject property = containerTypeDescription.createDataObject("property");
- property.set("type", propertyType);
- property.setString("name", propertyName);
- property.setBoolean("containment", true);
- return property;
- }
-
-}
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.samples.sdo.advanced;
+
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.samples.sdo.SampleBase;
+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;
+
+/**
+ * This sample is based on a 2 part article by Kelvin Goodson and Geoffrey Winn.
+ * In this variant of the sample the model for the test includes change monitoring.
+ * The facility for undoing changes on the basis of the change monitoring is
+ * demonstrated.
+ * See <A href="http://soa.sys-con.com/read/313547.htm">Part1</A> and <A
+ * href="http://soa.sys-con.com/read/358059.htm">Part 2</A> of the article.
+ * <p>
+ * <h3>Running this Sample</h3> See <A HREF="../../../../../../index.html"
+ * target="_top">the main overview</A> for instructions on how to run this
+ * sample.
+ */
+public class MedicalScenarioWithChangeMonitoring extends SampleBase {
+
+ private static final String sdoApiUri = "commonj.sdo";
+
+ private static final String peopleURI = "www.example.org/people";
+
+ private static final String medicalURI = "www.example.org/MedicalTest";
+
+ boolean typesViaAPI = false;
+
+ private static final String usage = " [-api |-xsd]\n"
+ + " -api : define the types using the SDO API\n"
+ + " -xsd : define the types using an XML schema file";
+
+ public MedicalScenarioWithChangeMonitoring(String[] args, Integer userLevel) {
+
+ super(userLevel, SAMPLE_LEVEL_ADVANCED);
+
+ if (args.length > 1) {
+ printUsage(args);
+ System.exit(-1);
+ }
+ if (args.length == 1) {
+ if (args[0].equals("-xsd")) {
+ typesViaAPI = false;
+ } else if (args[0].equals("-api")) {
+ typesViaAPI = true;
+ } else {
+ printUsage(args);
+ System.exit(-1);
+ }
+ }
+ }
+
+ public MedicalScenarioWithChangeMonitoring(Integer userLevel) {
+ super(userLevel, SAMPLE_LEVEL_ADVANCED);
+ }
+
+
+ private void printUsage(String[] args) {
+ System.out.println("Usage: " + this.getClass().getName() + usage);
+ }
+
+ /**
+ * @param args
+ * @throws Exception
+ */
+ public static void main(String[] args) throws Exception {
+
+ MedicalScenarioWithChangeMonitoring s = new MedicalScenarioWithChangeMonitoring(args, COMMENTARY_FOR_NOVICE);
+ s.run();
+
+ }
+
+ /*
+ * metadata for the sample documenting the areas of SDO that are explored
+ */
+ public static int [] CORE_FUNCTION = {
+ SDOFacets.CONTAINMENT,
+ SDOFacets.CREATE_TYPES_USING_THE_SDO_API,
+ SDOFacets.CREATE_TYPES_USING_XML_SCHEMA,
+ SDOFacets.OPEN_CONTENT,
+ SDOFacets.NON_CONTAINMENT,
+ SDOFacets.CHANGE_MONITORING_USING_A_CHANGESUMMARY_PROPERTY_ON_A_DATAOBJECT
+ };
+
+ public static int [] SIGNIFICANT_FUNCTION = {
+ SDOFacets.CREATE_DATAOBJECTS_BY_NAME,
+ SDOFacets.ISMANY_PROPERTIES,
+ SDOFacets.GENERIC_DATA_GRAPH_TRAVERSAL,
+ SDOFacets.SAVING_DATA_TO_XML
+ };
+
+ public void runSample() throws Exception {
+
+ HelperContext scope = SDOUtil.createHelperContext();
+
+ if (typesViaAPI) {
+
+ commentary("In this execution of the sample we use Types created\n"
+ + "using the SDO API");
+
+ createTypesViaAPI(scope);
+
+ } else {
+
+ commentary("In this execution of the sample we use Types created\n"
+ + "by loading a variant of the XMLSchema that includes a change summary Property");
+
+ loadTypesFromXMLSchemaFile(scope, "MedicalTest_CS.xsd");
+
+ }
+
+ commentary(
+ COMMENTARY_FOR_NOVICE,
+ "The DataFactory associated with the scope that the types were created within\n"
+ + "can be used to create an instance of the Person Type\n\n"
+ + "DataFactory dataFactory = scope.getDataFactory();\n"
+ + "DataObject person1 = dataFactory.create(\"www.example.org/people\", \"Person\");");
+
+ DataFactory dataFactory = scope.getDataFactory();
+ DataObject person1 = dataFactory.create("www.example.org/people", "Person");
+
+ commentary("The setString() of dataObject method is used to set the properties of the\n"
+ + "new Person DataObject, including a unique identifier reference value\n"
+ + "for the Person instance.\n\n"
+ + "person1.setString(\"id\", \"1\");\n"
+ + "person1.setString(\"name\", \"Joe Johnson Snr.\");\n"
+ + "person1.setString(\"gender\", \"male\"););");
+
+ person1.setString("id", "1");
+ person1.setString("name", "Joe Johnson Snr.");
+ person1.setString("gender", "male");
+
+ commentary("An alternative approach to using the DataFactory directly to create\n"
+ + "all DataObjects is to use a top-down approach, where we create the\n"
+ + "root object for a data graph, and then use the createDataObject(String propertyName)\n"
+ + "method to create the contained DataObjects. Here we create the overall\n"
+ + "medical test DataObject, and then create the contained \"referrals\" DataObject\n\n"
+ + "DataObject test = dataFactory.create(\"www.example.org/MedicalTest\", \"Test\");\n"
+ + "DataObject referrals = test.createDataObject(\"referrals\");");
+
+ DataObject test = dataFactory.create("www.example.org/MedicalTest", "Test");
+
+ DataObject referrals = test.createDataObject("referrals");
+
+ commentary("The default state for monitoring changes for the DataObject when created in this\n" +
+ "way is the monitoring is switched off, so we switch it on. (Note that if you\n" +
+ "get your data graphs from a data Access Service then this service may turn on\n" +
+ "change monitoring be default\n\n" +
+ "test.getChangeSummary().beginLogging();");
+ test.getChangeSummary().beginLogging();
+
+ commentary("We'll repeat the whole of the MedicalScenario sample, but then at the \n" +
+ "last minute we'll decide it was all wrong and roll back the changes......");
+
+ commentary("Now we can add the person we created earlier into the set of people who have\n"
+ + "been referred for this medical test.\n\n"
+ + "test.set(\"referrals\", referrals);\n"
+ + "referrals.getList(\"person\").add(person1);");
+
+ test.set("referrals", referrals);
+ referrals.getList("person").add(person1);
+
+ commentary("Let's take a look at how the current state of the data"
+ + "graph is rendered in XML ...");
+
+ System.out.println(scope.getXMLHelper().save(test,
+ "www.example.org/MedicalTest", "test"));
+
+ commentary("The scenario unfolds and the Joe Johnson Snr. becomes a patient\n\n"
+ + "DataObject patients = test.createDataObject(\"patients\");\n"
+ + "patients.getList(\"person\").add(person1);");
+
+ DataObject patients = test.createDataObject("patients");
+
+ patients.getList("person").add(person1);
+
+ commentary("Having added Joe Johnson Snr. to the set of patients we can see\n"
+ + "the way that SDO preserves a single containment hierarchy within a\n"
+ + "datagraph. If we look at the XML rendering of the graph again, we will\n"
+ + "see that by adding him to the set of patients he has been removed from the\n"
+ + "containment property associated with the referrals set ...");
+
+ System.out.println(scope.getXMLHelper().save(test,
+ "www.example.org/MedicalTest", "test"));
+
+ commentary("The 'Person' Type we are making use of here has been designed to be\n"
+ + "multi-purpose, in that the type has been declared to be 'Open'.\n"
+ + "That means that we can make use of 'Open Content' Properties\n"
+ + "(If the type system has been defined using an XML schema\n"
+ + "then these properties will derive from global elements)\n"
+ + "We can look up open content Properties using the TypeHelper\n\n"
+ + "Property conditionProperty = scope.getTypeHelper().getOpenContentProperty(\n"
+ + " \"www.example.org/MedicalTest\", \"condition\");");
+
+ Property conditionProperty = scope.getTypeHelper().getOpenContentProperty(
+ "www.example.org/MedicalTest", "condition");
+
+ commentary("We can create a value of the appropriate Type for this open\n"
+ + "content Property\n\n"
+ + "DataObject condition = dataFactory.create(conditionProperty.getType());\n"
+ + "condition.setString(\"name\", \"Panar Syndrome\");");
+
+ DataObject condition = dataFactory.create(conditionProperty.getType());
+ condition.setString("name", "Panar Syndrome");
+
+ commentary("If you ask a DataObject that has an 'Open' Type for its list of\n"
+ + "values associated with an open content Property, and the DataObject\n"
+ + "doesn't currently have any values for the Property, it will return\n"
+ + "an empty list. We can use the list to add values for the Property\n\n"
+ + "List conditions = person1.getList(conditionProperty);\n"
+ + "conditions.add(condition);");
+
+ List conditions = person1.getList(conditionProperty);
+ conditions.add(condition);
+
+ commentary("A further look at the data graph in XML form shows\n"
+ + "the presence of the new condition Property's value ...");
+
+ System.out.println(scope.getXMLHelper().save(test,
+ "www.example.org/MedicalTest", "test"));
+
+ commentary("Having looked at the way SDO handles Open content\n"
+ + "We now turn our attention to 'non-containment' relationships.\n"
+ + "To do this we first create the set of people in the test that\n"
+ + "constitute the blood relatives of patients -- 'relatives'\n"
+ + "and define a new person to be Joe Johnson Snr's child.\n\n"
+ + "DataObject relatives = test.createDataObject(\"relatives\");\n"
+ + "DataObject person2 = relatives.createDataObject(\"person\");\n"
+ + "person2.setString(\"id\", \"2\");\n"
+ + "person2.setString(\"name\", \"Joe Johnson Jnr.\");\n"
+ + "person2.setString(\"gender\", \"male\");");
+
+ DataObject relatives = test.createDataObject("relatives");
+ DataObject person2 = relatives.createDataObject("person");
+
+ person2.setString("id", "2");
+ person2.setString("name", "Joe Johnson Jnr.");
+ person2.setString("gender", "male");
+
+ commentary("Another quick look at the XML rendering of the graph confirms that\n"
+ + "the set of relatives now includes Joe Johnson Jnr, but we haven't yet\n"
+ + "defined who he is related to, or how.");
+
+ System.out.println(scope.getXMLHelper().save(test,
+ "www.example.org/MedicalTest", "test"));
+
+ commentary("The Person type has a Property 'relative'\n"
+ + "so we create a relative for Joe Johnson Snr.\n\n"
+ + "DataObject relation = person1.createDataObject(\"relative\");\n"
+ + "relation.set(\"target\", person2);\n"
+ + "relation.set(\"relationship\", \"child\");");
+
+ DataObject relation = person1.createDataObject("relative");
+ relation.set("target", person2);
+ relation.set("relationship", "child");
+
+ commentary("Now when we look at the XML rendering of the data graph\n"
+ + "we can see that the action of setting the 'target' of the\n"
+ + "relationship to Joe Johnson Jnr didn't displace him from the\n"
+ + "set of 'relatives', because the 'target' Property is a\n"
+ + "non-containment Property. This non-containment relationship\n"
+ + "is reflected in the XML by a reference to the Person DataObject\n"
+ + "describing Joe Johnson Jnr, \"2\" ...\n"
+ + "If the Type system has been created from an XML schema then the\n"
+ + "unique ID of the target can be used in the serialization.\n"
+ + "If however the type system was defined dynamically, then the reference\n"
+ + "will be represented as an XPath from the root of the data graph.");
+
+ System.out.println(scope.getXMLHelper().save(test,
+ "www.example.org/MedicalTest", "test"));
+
+ commentary("Now that the graph is complete we can use the PrintDataGraph sample utility\n" +
+ "to reveal the full SDO nature of the final data graph\n\n" +
+ "");
+
+ PrintDataGraph printer = new PrintDataGraph(COMMENTARY_FOR_ADVANCED);
+ printer.printDataObject(test);
+ System.out.println(printer.getBuf());
+
+ commentary("But Wait! it's all wrong. Let's go back to our checkpoint where we started monitoring changes\n\n" +
+ "test.getChangeSummary().undoChanges();");
+
+ test.getChangeSummary().undoChanges();
+
+ printer.reset();
+ printer.printDataObject(test);
+ System.out.println(printer.getBuf());
+
+ }
+
+ /**
+ * @throws Exception
+ * @throws FileNotFoundException
+ */
+ private void createTypesViaAPI(HelperContext scope) throws Exception {
+
+ List typeDeclarations = new ArrayList();
+
+ TypeHelper typeHelper = scope.getTypeHelper();
+
+ Type stringType = typeHelper.getType(sdoApiUri, "String");
+ Type dateType = typeHelper.getType(sdoApiUri, "Date");
+ Type booleanType = typeHelper.getType(sdoApiUri, "Boolean");
+
+ // <complexType name="Person">
+ // <sequence>
+ // <element name="dob" type="date"/>
+ // <element name="relative" maxOccurs="unbounded" type="tns:Relative"/>
+ // <any namespace="##other" processContents="lax" maxOccurs="unbounded"/>
+ // </sequence>
+ // <attribute name="id" type="ID"/>
+ // <attribute name="name" type="string"/>
+ // <attribute name="gender" type = "tns:Gender"/>
+ // </complexType>
+
+ DataObject personTypeDesc = createTypeDescription(scope, peopleURI,
+ "Person");
+ typeDeclarations.add(personTypeDesc);
+
+ addPropertyDescription(personTypeDesc, stringType, "name");
+ addPropertyDescription(personTypeDesc, dateType, "dob");
+ addPropertyDescription(personTypeDesc, stringType, "id"); // set to unique
+ // identifier?
+ addPropertyDescription(personTypeDesc, stringType, "gender"); // restrict?
+
+ DataObject relativeType = createTypeDescription(scope, peopleURI,
+ "Relative"); // forward declare the Relative type
+ typeDeclarations.add(relativeType);
+
+ DataObject rp = addPropertyDescription(personTypeDesc, relativeType,
+ "relative");
+ rp.setBoolean("many", true);
+ personTypeDesc.set("open", Boolean.TRUE);
+
+ // <complexType name="Relative">
+ // <attribute name="target" type="IDREF" sdoxml:propertyType="tns:Person"
+ // use="required"/>
+ // <attribute name="relationship" type="string" />
+ // <attribute name="genetic" use="optional" type="boolean"/>
+ // </complexType>
+
+ addPropertyDescription(relativeType, stringType, "relationship");
+ addPropertyDescription(relativeType, booleanType, "genetic");
+ DataObject targetPersonProp = addPropertyDescription(relativeType,
+ personTypeDesc, "target");
+ targetPersonProp.setBoolean("containment", false);
+
+ // <complexType name="PersonSet">
+ // <sequence>
+ // <element name="person" type="tns:Person" maxOccurs="unbounded"/>
+ // </sequence>
+ // </complexType>
+
+ DataObject pSet = createTypeDescription(scope, peopleURI, "PersonSet");
+ typeDeclarations.add(pSet);
+ DataObject pSetProperty = addPropertyDescription(pSet, personTypeDesc,
+ "person");
+ pSetProperty.setBoolean("many", true);
+
+ // <complexType name="Condition">
+ // <sequence>
+ // <element name="diagnosed" type="date" />
+ // </sequence>
+ // <attribute name="name" type="tns:ConditionName" />
+ // </complexType>
+
+ DataObject condition = createTypeDescription(scope, medicalURI, "Condition");
+ typeDeclarations.add(condition);
+ addPropertyDescription(condition, booleanType, "diagnosed");
+ addPropertyDescription(condition, stringType, "name"); // constrain?
+
+ // <complexType name="Test">
+ // <sequence>
+ // <element name="referrals" type="people:PersonSet" />
+ // <element name="patients" type="people:PersonSet" />
+ // <element name="relatives" type="people:PersonSet" />
+ // </sequence>
+ // </complexType>
+
+ DataObject testType = createTypeDescription(scope, medicalURI, "Test");
+ typeDeclarations.add(testType);
+ addPropertyDescription(testType, pSet, "referrals");
+ addPropertyDescription(testType, pSet, "patients");
+ addPropertyDescription(testType, pSet, "relatives");
+
+ List types = typeHelper.define(typeDeclarations);
+
+ DataObject p = scope.getDataFactory().create("commonj.sdo", "Property");
+ p.set("type", typeHelper.getType(medicalURI, "Condition"));
+ p.set("name", "condition");
+ p.setBoolean("many", true);
+ p.setBoolean("containment", true); // why is this not the default?
+
+ typeHelper.defineOpenContentProperty(medicalURI, p);
+
+ }
+
+ /**
+ * @param uri
+ * @param name
+ * @return
+ */
+ private DataObject createTypeDescription(HelperContext scope, String uri,
+ String name) {
+ DataObject typeDesc = scope.getDataFactory().create(sdoApiUri, "Type");
+ typeDesc.set("name", name);
+ typeDesc.set("uri", uri);
+ return typeDesc;
+ }
+
+ private DataObject addPropertyDescription(
+ DataObject containerTypeDescription, Object propertyType,
+ String propertyName) {
+ DataObject property = containerTypeDescription.createDataObject("property");
+ property.set("type", propertyType);
+ property.setString("name", propertyName);
+ property.setBoolean("containment", true);
+ return property;
+ }
+
+}
diff --git a/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/PrintDataGraph.java b/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/PrintDataGraph.java
index 6647f54501..7458eef76c 100644
--- a/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/PrintDataGraph.java
+++ b/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/advanced/PrintDataGraph.java
@@ -1,498 +1,498 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.samples.sdo.advanced;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.apache.tuscany.samples.sdo.SampleBase;
-import org.apache.tuscany.samples.sdo.internal.SampleInfrastructure;
-
-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.XMLDocument;
-import commonj.sdo.helper.XSDHelper;
-import commonj.sdo.impl.HelperProvider;
-
-/**
- *
- * This sample program traverses data graphs and builds up a text representation of the
- * data graph. As it traverses a graph it outputs commentary to the console
- * about what it has encountered and how it intends to process what it finds. At
- * the end of each traversal the text representation of the graph is printed to
- * the console.
- * <p>
- * <h3>Running this Sample</h3> See <A HREF="../../../../../../index.html"
- * target="_top">the main overview</A> for instructions on how to run this
- * sample.
- */
-public class PrintDataGraph extends SampleBase {
-
- StringBuffer buf = null;
- HelperContext scope = HelperProvider.getDefaultContext();
-
- private int indent;
-
- private int indentIncrement = 2;
-
- public PrintDataGraph(Integer userLevel) {
- super(userLevel, SAMPLE_LEVEL_ADVANCED);
- buf = new StringBuffer();
- }
-
- public static void main(String[] args) {
- PrintDataGraph sample = new PrintDataGraph(COMMENTARY_FOR_NOVICE);
- sample.run();
- }
-
- /*
- * metadata for the sample documenting the areas of SDO that are explored
- */
- public static int [] CORE_FUNCTION = {
- SDOFacets.GENERIC_DATA_GRAPH_TRAVERSAL
- };
-
- public static int [] SIGNIFICANT_FUNCTION = {
- SDOFacets.GET_SET_PROPERTIES_BY_INSTANCE_PROPERTIES,
- SDOFacets.ISMANY_PROPERTIES,
- SDOFacets.CREATE_TYPES_USING_THE_SDO_API,
- SDOFacets.ACCESSING_VALUES_IN_A_SEQUENCE,
- SDOFacets.NON_CONTAINMENT
- };
-
- public void runSample() throws Exception {
- commentary("This sample demonstrates a common pattern of traversing a data graph\n"
- + "and printing the values of its Properties. As the sample traverses a couple of\n"
- + "graphs it provides commentary about what it has found and what actions it\n"
- + "is taking, whilst building up a text representation of the graph. It then\n"
- + "shows you the results of its labours.");
-
- HelperContext scope = createScopeForTypes();
-
- commentary(
- COMMENTARY_ALWAYS,
- "First we look at a data graph of a Purchase Order which has a fairly simple XML schema\n"
- + "and the graph's containment hierarchy has a couple of levels of depth");
-
- loadTypesFromXMLSchemaFile(scope, SampleInfrastructure.PO_XSD_RESOURCE);
-
- XMLDocument purchaseOrder = getXMLDocumentFromFile(scope,
- SampleInfrastructure.PO_XML_RESOURCE);
-
- printXMLDocument(purchaseOrder);
-
- commentary(COMMENTARY_ALWAYS,
- "And here is the resultant view of the data graph\n\n");
- System.out.println(getBuf().toString());
-
- commentary(COMMENTARY_ALWAYS,
- "Next we look at a graph representing a form letter, where the Type of the\n"
- + "root data object is 'Sequenced'");
-
- loadTypesFromXMLSchemaFile(scope, "letter.xsd");
- DataObject letter = getDataObjectFromFile(scope, "letter.xml");
-
- reset();
- print(letter);
-
- commentary(COMMENTARY_ALWAYS,
- "And here is the resultant view of the data graph\n\n");
-
- System.out.println(getBuf().toString());
-
- }
-
- public void reset() {
- indent = 0;
- buf = new StringBuffer();
- }
-
- /*
- * a convenience method allowing untyped access to the print function for
- * selected SDO artifacts
- */
- public void print(Object sdoObject) throws Exception {
-
- if (sdoObject instanceof XMLDocument) {
- printXMLDocument((XMLDocument) sdoObject);
- } else if (sdoObject instanceof DataObject) {
- printDataObject((DataObject) sdoObject);
- }
-
- }
-
- public void printXMLDocument(XMLDocument xmlDocument) {
-
- commentary(
- COMMENTARY_FOR_NOVICE,
- "We are going to traverse a data graph that has been wrapped in an instance of XMLDocument\n"
- + "Amongst other things, the XMLDocument instance provides access to the root element name\n"
- + "and the root DataObject of the data graph.\n\n"
- + "xmlDocument.getRootElementName();\n"
- + "xmlDocument.getRootObject();",
-
- "Accessing another graph via an XMLDocument instance as we saw previously ...\n"
- + "xmlDocument.getRootElementName();\n"
- + "xmlDocument.getRootObject();");
-
- buf.append("XMLDocument: ").append(xmlDocument.getRootElementName());
- lineBreak();
- incrementIndent();
- printDataObject(xmlDocument.getRootObject());
- decrementIndent();
- }
-
- public void printDataObject(DataObject dataObject) {
-
- if (dataObject.getContainer() == null) {
- commentary(
- COMMENTARY_FOR_NOVICE,
- "We begin traversing the data graph by examining the root object of the graph's containment hierarchy,\n"
- + "making a record of the values of its Properties. As we inspect the values of the Properties of this object\n"
- + "if we encounter contained DataObjects, then we will recurs through the containment hierarchy of the\n"
- + "data graph in a depth first fashion, and create a text representation of the graph that we'll print\n"
- + "out after the graph traversal has been completed.",
-
- "We are beginning to traverse another data graph from its root object, in the same way that we saw previously");
- } else {
- commentary(
- COMMENTARY_FOR_NOVICE,
- "We have arrived at a contained dataObject in the graph, and will inspect its Property values,\n"
- + "recursing deeper if necessary",
-
- "Inspecting another contained dataObject");
- }
-
- lineBreak();
- indent();
- buf.append("DataObject: ");
- Type type = dataObject.getType();
- buf.append("Type: ").append(type.getURI()).append('#').append(
- type.getName());
- lineBreak();
-
- if (dataObject.getType().isSequenced()) {
-
- commentary(
- COMMENTARY_FOR_INTERMEDIATE,
- "We've encountered a DataObject in the graph for which the Type is 'Sequenced'\n"
- + "That is to say that the order of addition of Property values to the DataObject instance\n"
- + "is important, and is preserved by the DataObject\n\n"
- + "dataObject.getType().isSequenced();",
-
- "We've encountered another sequenced DataObject instance, and so will traverse the Property\n"
- + "values in the order preerved by the instance, as we saw before\n\n"
- + "dataObject.getType().isSequenced();");
-
- commentary(
- "There's a subtlety here which we must deal with if this sample code is to\n" +
- "handle both Type systems that derive from XML schema, and those that come from elsewhere,\n" +
- "e.g. using the SDO API. If a Sequenced DataObject has a Type that comes from XML schema\n" +
- "then its Properties that derive from XML attributes are not ordered, whereas those that\n" +
- "derive from XML elements are ordered. The SDO specification doesn't say whether\n" +
- "the attribute related Properties should appear at the start of a Sequence or not.\n" +
- "Currently in Tuscany we leave them out of the Sequence; other SDO implementations may\n" +
- "include the XML attributes in the Sequence. This sample code is written to deal with\n" +
- "either approach\n." +
- "We use the XSDHelper.isAttribute(Property) and isElement(Property) methods to distinguish\n" +
- "between the two kinds of Property",
-
- "Examining the xml attributes and elements of a Sequenced DataObject again."
- );
-
- XSDHelper xsdHelper = getScope().getXSDHelper();
- incrementIndent();
- for(Iterator it=dataObject.getInstanceProperties().iterator(); it.hasNext();) {
- Property property = (Property)it.next();
- if (xsdHelper.isAttribute(property)) {
- indent();
- buf.append("Property (XML Attribute): ").append(property.getName()).append(" - ").append(dataObject.get(property));
- lineBreak();
- }
-
- }
- decrementIndent();
- Sequence seq = dataObject.getSequence();
-
- commentary(
- "The Property/Value pairs of a Sequence can be accessed via the getProperty(int) and getValue(int)\n"
- + "accessor methods of the Sequence interface. The size() method of the Sequence tells us how many there are.\n"
- + "If the getProperty(int) method returns null, then the value is text. These text values may be encountered\n"
- + "when the DataObject's type is 'mixed' (dataObject.getType().isMixed() == true). A typical example of this\n"
- + "is when the data graph represents a form letter.",
-
- "Inspecting the Property/Value pairs of another Sequence");
-
- incrementIndent();
- indent();
- buf.append("Sequence: {\n");
-
- incrementIndent();
- for (int i = 0; i < seq.size(); i++) {
- Property p = seq.getProperty(i);
- if (p == null) {
- indent();
- buf.append("text: ").append(seq.getValue(i));
- lineBreak();
- } else if(!xsdHelper.isAttribute(p)){
- printPropertyValuePair(p, seq.getValue(i));
- }
- }
- decrementIndent();
-
- indent();
- buf.append("}\n");
- decrementIndent();
-
- } else {
- incrementIndent();
-
- commentary(
- COMMENTARY_FOR_INTERMEDIATE,
- "We access the Property values of this DataObject by first getting the list of 'Instance Properties'\n"
- + "from the DataObject. For many DataObjects, this will be the same set of Properties that are defined\n"
- + "by the DataObject's Type. However, if the DataObject's type is 'Open' then an instance of that Type\n"
- + "may contain more Properties than the type itself. The list of Instance Properties will always include\n"
- + "the Properties defined in the Type, but will also include any Properties that the instance has values for\n"
- + "by virtue of it's type being 'Open'\n\n"
- + "for (int i = 0; i < dataObject.getInstanceProperties().size(); i++) {\n"
- + " Property p = (Property) dataObject.getInstanceProperties().get(i);",
-
- "Traversing the instance Properties of this DataObject\n"
- + "for (int i = 0; i < dataObject.getInstanceProperties().size(); i++) {\n"
- + " Property p = (Property) dataObject.getInstanceProperties().get(i);"
-
- );
-
- for (int i = 0; i < dataObject.getInstanceProperties().size(); i++) {
- Property p = (Property) dataObject.getInstanceProperties().get(i);
- indent();
- printValueOfProperty(dataObject, p);
- }
-
- decrementIndent();
- }
-
- }
-
-
-
-
-
- private void printPropertyValuePair(Property p, Object value) {
-
- indent();
- buf.append("Property: ").append(p.getName()).append(": ");
- if(p.getType().isDataType()) {
- printSimpleValue(value);
- lineBreak();
- } else {
- if(p.isContainment()) {
- incrementIndent();
- printDataObject((DataObject)value);
- decrementIndent();
- } else {
- printReferencedDataObject((DataObject)value);
- }
- }
-
-
- }
-
- private void printValueOfProperty(DataObject dataObject, Property p) {
-
- commentary(
- COMMENTARY_FOR_INTERMEDIATE,
- "We are about to inspect the value of a Property, but we must\n"
- + "consider the nature of that Property in order to deal with it appropriately.\n"
- + "Firstly we see if the Property value has been set (dataObject.isSet(property))\n"
- + "Then we see if the Property is simple valued (property.isDataType() == true)\n"
- + "--if not then we know it's a DataObject and we must recurs deeper into the graph's\n"
- + "containment hierarchy\n"
- + "Whether or not the property value is a DataObject, is may be single or multi-valued\n"
- + "so we must either use one of the DataObject's get*(Property) accessors for single\n"
- + "valued Properties or the getList() method for multi-valued properties.\n"
- + "Another thing we must deal with when the Property is a DataObject, is whether or not the\n"
- + "Property is a 'containment' Property. If it isn't, then here we simply record the fact that\n"
- + "we have encountered this non-containment relationship, and move on to the next Property",
-
- "Inspecting another property to determine how to access its value, as we saw before");
-
- // TODO deal with nullable
-
- buf.append("Property ").append(p.getName()).append(": ").append(" - ");
-
- if (dataObject.isSet(p)) {
- if (p.getType().isDataType()) {
- if (p.isMany()) {
- printSimpleValues(dataObject.getList(p));
- } else {
- printSimpleValue(dataObject.get(p));
- }
- } else {
- if (p.isContainment()) {
- incrementIndent();
- if (p.isMany()) {
- printDataObjects(dataObject.getList(p));
- } else {
- printDataObject(dataObject.getDataObject(p));
- }
- decrementIndent();
- } else {
- if (p.isMany()) {
- printReferencedDataObjects(dataObject.getList(p));
- } else {
- printReferencedDataObject(dataObject.getDataObject(p));
- }
- }
- }
- } else {
- buf.append(" is not set");
- }
-
- lineBreak();
-
- }
-
- private void printReferencedDataObject(DataObject dataObject) {
-
- commentary(
- COMMENTARY_FOR_INTERMEDIATE,
- "We have encounted a non-containment reference to a DataObject, and so\n"
- + "we know that this DataObject will be fully inspected when encountered by the\n"
- + "traversal of the data graph's containment hierarchy.\n"
- + "We therefore record the fact that this association has been encountered by\n"
- + "establishing the path from the root object of the data graph to the referenced\n"
- + "DataObject",
-
- "Recording the fact that we have encountered another non-containment reference");
-
- List path = new ArrayList();
- DataObject current = dataObject;
- while (current != null) {
- Property containmentProperty = current.getContainmentProperty();
- if(containmentProperty != null) {
- if(containmentProperty.isMany()) {
- List pValues = current.getContainer().getList(containmentProperty);
- int index = pValues.indexOf(current)+1;
- path.add("["+index+"]");
- }
- path.add("/"+current.getContainmentProperty().getName());
- }
- current = current.getContainer();
- }
- buf.append("reference to: ");
- for (ListIterator i = path.listIterator(path.size()); i.hasPrevious();) {
- buf.append(i.previous());
- }
- }
-
- private void printReferencedDataObjects(List list) {
-
- commentary(
- COMMENTARY_FOR_NOVICE,
- "Traversing a list of DataObjects which represent the values of a multi-valued non-containment Property");
-
- indent();
- buf.append('[');
- for (Iterator i = list.iterator(); i.hasNext();) {
- printReferencedDataObject((DataObject) i.next());
- }
- indent();
- buf.append(']');
- }
-
- private void printDataObjects(List list) {
-
- commentary(
- COMMENTARY_FOR_NOVICE,
- "Traversing a list of DataObjects which represent the values of a multi-valued containment Property");
-
-
- lineBreak();
- indent();
- buf.append("[");
- incrementIndent();
- for (Iterator i = list.iterator(); i.hasNext();) {
- printDataObject((DataObject) i.next());
- }
- decrementIndent();
- indent();
- buf.append(']');
- }
-
- private void printSimpleValue(Object object) {
- buf.append(object);
- }
-
- private void printSimpleValues(List values) {
- buf.append('[');
- for (Iterator i = values.iterator(); i.hasNext();) {
- printSimpleValue(i.next());
- if (i.hasNext()) {
- buf.append(',');
- }
- }
- buf.append(']');
-
- }
-
- private void decrementIndent() {
- indent -= indentIncrement;
-
- }
-
- private void incrementIndent() {
- indent += indentIncrement;
-
- }
-
- private void indent() {
- for (int i = 0; i < indent; i++) {
- buf.append(' ');
- }
- }
-
- private void lineBreak() {
- buf.append('\n');
- }
-
- public StringBuffer getBuf() {
- return buf;
- }
-
- public void setBuf(StringBuffer b) {
- buf = b;
- }
-
- public HelperContext getScope() {
- return scope;
- }
-
- public void setScope(HelperContext scope) {
- this.scope = scope;
- }
-
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.samples.sdo.advanced;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+import org.apache.tuscany.samples.sdo.SampleBase;
+import org.apache.tuscany.samples.sdo.internal.SampleInfrastructure;
+
+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.XMLDocument;
+import commonj.sdo.helper.XSDHelper;
+import commonj.sdo.impl.HelperProvider;
+
+/**
+ *
+ * This sample program traverses data graphs and builds up a text representation of the
+ * data graph. As it traverses a graph it outputs commentary to the console
+ * about what it has encountered and how it intends to process what it finds. At
+ * the end of each traversal the text representation of the graph is printed to
+ * the console.
+ * <p>
+ * <h3>Running this Sample</h3> See <A HREF="../../../../../../index.html"
+ * target="_top">the main overview</A> for instructions on how to run this
+ * sample.
+ */
+public class PrintDataGraph extends SampleBase {
+
+ StringBuffer buf = null;
+ HelperContext scope = HelperProvider.getDefaultContext();
+
+ private int indent;
+
+ private int indentIncrement = 2;
+
+ public PrintDataGraph(Integer userLevel) {
+ super(userLevel, SAMPLE_LEVEL_ADVANCED);
+ buf = new StringBuffer();
+ }
+
+ public static void main(String[] args) {
+ PrintDataGraph sample = new PrintDataGraph(COMMENTARY_FOR_NOVICE);
+ sample.run();
+ }
+
+ /*
+ * metadata for the sample documenting the areas of SDO that are explored
+ */
+ public static int [] CORE_FUNCTION = {
+ SDOFacets.GENERIC_DATA_GRAPH_TRAVERSAL
+ };
+
+ public static int [] SIGNIFICANT_FUNCTION = {
+ SDOFacets.GET_SET_PROPERTIES_BY_INSTANCE_PROPERTIES,
+ SDOFacets.ISMANY_PROPERTIES,
+ SDOFacets.CREATE_TYPES_USING_THE_SDO_API,
+ SDOFacets.ACCESSING_VALUES_IN_A_SEQUENCE,
+ SDOFacets.NON_CONTAINMENT
+ };
+
+ public void runSample() throws Exception {
+ commentary("This sample demonstrates a common pattern of traversing a data graph\n"
+ + "and printing the values of its Properties. As the sample traverses a couple of\n"
+ + "graphs it provides commentary about what it has found and what actions it\n"
+ + "is taking, whilst building up a text representation of the graph. It then\n"
+ + "shows you the results of its labours.");
+
+ HelperContext scope = createScopeForTypes();
+
+ commentary(
+ COMMENTARY_ALWAYS,
+ "First we look at a data graph of a Purchase Order which has a fairly simple XML schema\n"
+ + "and the graph's containment hierarchy has a couple of levels of depth");
+
+ loadTypesFromXMLSchemaFile(scope, SampleInfrastructure.PO_XSD_RESOURCE);
+
+ XMLDocument purchaseOrder = getXMLDocumentFromFile(scope,
+ SampleInfrastructure.PO_XML_RESOURCE);
+
+ printXMLDocument(purchaseOrder);
+
+ commentary(COMMENTARY_ALWAYS,
+ "And here is the resultant view of the data graph\n\n");
+ System.out.println(getBuf().toString());
+
+ commentary(COMMENTARY_ALWAYS,
+ "Next we look at a graph representing a form letter, where the Type of the\n"
+ + "root data object is 'Sequenced'");
+
+ loadTypesFromXMLSchemaFile(scope, "letter.xsd");
+ DataObject letter = getDataObjectFromFile(scope, "letter.xml");
+
+ reset();
+ print(letter);
+
+ commentary(COMMENTARY_ALWAYS,
+ "And here is the resultant view of the data graph\n\n");
+
+ System.out.println(getBuf().toString());
+
+ }
+
+ public void reset() {
+ indent = 0;
+ buf = new StringBuffer();
+ }
+
+ /*
+ * a convenience method allowing untyped access to the print function for
+ * selected SDO artifacts
+ */
+ public void print(Object sdoObject) throws Exception {
+
+ if (sdoObject instanceof XMLDocument) {
+ printXMLDocument((XMLDocument) sdoObject);
+ } else if (sdoObject instanceof DataObject) {
+ printDataObject((DataObject) sdoObject);
+ }
+
+ }
+
+ public void printXMLDocument(XMLDocument xmlDocument) {
+
+ commentary(
+ COMMENTARY_FOR_NOVICE,
+ "We are going to traverse a data graph that has been wrapped in an instance of XMLDocument\n"
+ + "Amongst other things, the XMLDocument instance provides access to the root element name\n"
+ + "and the root DataObject of the data graph.\n\n"
+ + "xmlDocument.getRootElementName();\n"
+ + "xmlDocument.getRootObject();",
+
+ "Accessing another graph via an XMLDocument instance as we saw previously ...\n"
+ + "xmlDocument.getRootElementName();\n"
+ + "xmlDocument.getRootObject();");
+
+ buf.append("XMLDocument: ").append(xmlDocument.getRootElementName());
+ lineBreak();
+ incrementIndent();
+ printDataObject(xmlDocument.getRootObject());
+ decrementIndent();
+ }
+
+ public void printDataObject(DataObject dataObject) {
+
+ if (dataObject.getContainer() == null) {
+ commentary(
+ COMMENTARY_FOR_NOVICE,
+ "We begin traversing the data graph by examining the root object of the graph's containment hierarchy,\n"
+ + "making a record of the values of its Properties. As we inspect the values of the Properties of this object\n"
+ + "if we encounter contained DataObjects, then we will recurs through the containment hierarchy of the\n"
+ + "data graph in a depth first fashion, and create a text representation of the graph that we'll print\n"
+ + "out after the graph traversal has been completed.",
+
+ "We are beginning to traverse another data graph from its root object, in the same way that we saw previously");
+ } else {
+ commentary(
+ COMMENTARY_FOR_NOVICE,
+ "We have arrived at a contained dataObject in the graph, and will inspect its Property values,\n"
+ + "recursing deeper if necessary",
+
+ "Inspecting another contained dataObject");
+ }
+
+ lineBreak();
+ indent();
+ buf.append("DataObject: ");
+ Type type = dataObject.getType();
+ buf.append("Type: ").append(type.getURI()).append('#').append(
+ type.getName());
+ lineBreak();
+
+ if (dataObject.getType().isSequenced()) {
+
+ commentary(
+ COMMENTARY_FOR_INTERMEDIATE,
+ "We've encountered a DataObject in the graph for which the Type is 'Sequenced'\n"
+ + "That is to say that the order of addition of Property values to the DataObject instance\n"
+ + "is important, and is preserved by the DataObject\n\n"
+ + "dataObject.getType().isSequenced();",
+
+ "We've encountered another sequenced DataObject instance, and so will traverse the Property\n"
+ + "values in the order preerved by the instance, as we saw before\n\n"
+ + "dataObject.getType().isSequenced();");
+
+ commentary(
+ "There's a subtlety here which we must deal with if this sample code is to\n" +
+ "handle both Type systems that derive from XML schema, and those that come from elsewhere,\n" +
+ "e.g. using the SDO API. If a Sequenced DataObject has a Type that comes from XML schema\n" +
+ "then its Properties that derive from XML attributes are not ordered, whereas those that\n" +
+ "derive from XML elements are ordered. The SDO specification doesn't say whether\n" +
+ "the attribute related Properties should appear at the start of a Sequence or not.\n" +
+ "Currently in Tuscany we leave them out of the Sequence; other SDO implementations may\n" +
+ "include the XML attributes in the Sequence. This sample code is written to deal with\n" +
+ "either approach\n." +
+ "We use the XSDHelper.isAttribute(Property) and isElement(Property) methods to distinguish\n" +
+ "between the two kinds of Property",
+
+ "Examining the xml attributes and elements of a Sequenced DataObject again."
+ );
+
+ XSDHelper xsdHelper = getScope().getXSDHelper();
+ incrementIndent();
+ for(Iterator it=dataObject.getInstanceProperties().iterator(); it.hasNext();) {
+ Property property = (Property)it.next();
+ if (xsdHelper.isAttribute(property)) {
+ indent();
+ buf.append("Property (XML Attribute): ").append(property.getName()).append(" - ").append(dataObject.get(property));
+ lineBreak();
+ }
+
+ }
+ decrementIndent();
+ Sequence seq = dataObject.getSequence();
+
+ commentary(
+ "The Property/Value pairs of a Sequence can be accessed via the getProperty(int) and getValue(int)\n"
+ + "accessor methods of the Sequence interface. The size() method of the Sequence tells us how many there are.\n"
+ + "If the getProperty(int) method returns null, then the value is text. These text values may be encountered\n"
+ + "when the DataObject's type is 'mixed' (dataObject.getType().isMixed() == true). A typical example of this\n"
+ + "is when the data graph represents a form letter.",
+
+ "Inspecting the Property/Value pairs of another Sequence");
+
+ incrementIndent();
+ indent();
+ buf.append("Sequence: {\n");
+
+ incrementIndent();
+ for (int i = 0; i < seq.size(); i++) {
+ Property p = seq.getProperty(i);
+ if (p == null) {
+ indent();
+ buf.append("text: ").append(seq.getValue(i));
+ lineBreak();
+ } else if(!xsdHelper.isAttribute(p)){
+ printPropertyValuePair(p, seq.getValue(i));
+ }
+ }
+ decrementIndent();
+
+ indent();
+ buf.append("}\n");
+ decrementIndent();
+
+ } else {
+ incrementIndent();
+
+ commentary(
+ COMMENTARY_FOR_INTERMEDIATE,
+ "We access the Property values of this DataObject by first getting the list of 'Instance Properties'\n"
+ + "from the DataObject. For many DataObjects, this will be the same set of Properties that are defined\n"
+ + "by the DataObject's Type. However, if the DataObject's type is 'Open' then an instance of that Type\n"
+ + "may contain more Properties than the type itself. The list of Instance Properties will always include\n"
+ + "the Properties defined in the Type, but will also include any Properties that the instance has values for\n"
+ + "by virtue of it's type being 'Open'\n\n"
+ + "for (int i = 0; i < dataObject.getInstanceProperties().size(); i++) {\n"
+ + " Property p = (Property) dataObject.getInstanceProperties().get(i);",
+
+ "Traversing the instance Properties of this DataObject\n"
+ + "for (int i = 0; i < dataObject.getInstanceProperties().size(); i++) {\n"
+ + " Property p = (Property) dataObject.getInstanceProperties().get(i);"
+
+ );
+
+ for (int i = 0; i < dataObject.getInstanceProperties().size(); i++) {
+ Property p = (Property) dataObject.getInstanceProperties().get(i);
+ indent();
+ printValueOfProperty(dataObject, p);
+ }
+
+ decrementIndent();
+ }
+
+ }
+
+
+
+
+
+ private void printPropertyValuePair(Property p, Object value) {
+
+ indent();
+ buf.append("Property: ").append(p.getName()).append(": ");
+ if(p.getType().isDataType()) {
+ printSimpleValue(value);
+ lineBreak();
+ } else {
+ if(p.isContainment()) {
+ incrementIndent();
+ printDataObject((DataObject)value);
+ decrementIndent();
+ } else {
+ printReferencedDataObject((DataObject)value);
+ }
+ }
+
+
+ }
+
+ private void printValueOfProperty(DataObject dataObject, Property p) {
+
+ commentary(
+ COMMENTARY_FOR_INTERMEDIATE,
+ "We are about to inspect the value of a Property, but we must\n"
+ + "consider the nature of that Property in order to deal with it appropriately.\n"
+ + "Firstly we see if the Property value has been set (dataObject.isSet(property))\n"
+ + "Then we see if the Property is simple valued (property.isDataType() == true)\n"
+ + "--if not then we know it's a DataObject and we must recurs deeper into the graph's\n"
+ + "containment hierarchy\n"
+ + "Whether or not the property value is a DataObject, is may be single or multi-valued\n"
+ + "so we must either use one of the DataObject's get*(Property) accessors for single\n"
+ + "valued Properties or the getList() method for multi-valued properties.\n"
+ + "Another thing we must deal with when the Property is a DataObject, is whether or not the\n"
+ + "Property is a 'containment' Property. If it isn't, then here we simply record the fact that\n"
+ + "we have encountered this non-containment relationship, and move on to the next Property",
+
+ "Inspecting another property to determine how to access its value, as we saw before");
+
+ // TODO deal with nullable
+
+ buf.append("Property ").append(p.getName()).append(": ").append(" - ");
+
+ if (dataObject.isSet(p)) {
+ if (p.getType().isDataType()) {
+ if (p.isMany()) {
+ printSimpleValues(dataObject.getList(p));
+ } else {
+ printSimpleValue(dataObject.get(p));
+ }
+ } else {
+ if (p.isContainment()) {
+ incrementIndent();
+ if (p.isMany()) {
+ printDataObjects(dataObject.getList(p));
+ } else {
+ printDataObject(dataObject.getDataObject(p));
+ }
+ decrementIndent();
+ } else {
+ if (p.isMany()) {
+ printReferencedDataObjects(dataObject.getList(p));
+ } else {
+ printReferencedDataObject(dataObject.getDataObject(p));
+ }
+ }
+ }
+ } else {
+ buf.append(" is not set");
+ }
+
+ lineBreak();
+
+ }
+
+ private void printReferencedDataObject(DataObject dataObject) {
+
+ commentary(
+ COMMENTARY_FOR_INTERMEDIATE,
+ "We have encounted a non-containment reference to a DataObject, and so\n"
+ + "we know that this DataObject will be fully inspected when encountered by the\n"
+ + "traversal of the data graph's containment hierarchy.\n"
+ + "We therefore record the fact that this association has been encountered by\n"
+ + "establishing the path from the root object of the data graph to the referenced\n"
+ + "DataObject",
+
+ "Recording the fact that we have encountered another non-containment reference");
+
+ List path = new ArrayList();
+ DataObject current = dataObject;
+ while (current != null) {
+ Property containmentProperty = current.getContainmentProperty();
+ if(containmentProperty != null) {
+ if(containmentProperty.isMany()) {
+ List pValues = current.getContainer().getList(containmentProperty);
+ int index = pValues.indexOf(current)+1;
+ path.add("["+index+"]");
+ }
+ path.add("/"+current.getContainmentProperty().getName());
+ }
+ current = current.getContainer();
+ }
+ buf.append("reference to: ");
+ for (ListIterator i = path.listIterator(path.size()); i.hasPrevious();) {
+ buf.append(i.previous());
+ }
+ }
+
+ private void printReferencedDataObjects(List list) {
+
+ commentary(
+ COMMENTARY_FOR_NOVICE,
+ "Traversing a list of DataObjects which represent the values of a multi-valued non-containment Property");
+
+ indent();
+ buf.append('[');
+ for (Iterator i = list.iterator(); i.hasNext();) {
+ printReferencedDataObject((DataObject) i.next());
+ }
+ indent();
+ buf.append(']');
+ }
+
+ private void printDataObjects(List list) {
+
+ commentary(
+ COMMENTARY_FOR_NOVICE,
+ "Traversing a list of DataObjects which represent the values of a multi-valued containment Property");
+
+
+ lineBreak();
+ indent();
+ buf.append("[");
+ incrementIndent();
+ for (Iterator i = list.iterator(); i.hasNext();) {
+ printDataObject((DataObject) i.next());
+ }
+ decrementIndent();
+ indent();
+ buf.append(']');
+ }
+
+ private void printSimpleValue(Object object) {
+ buf.append(object);
+ }
+
+ private void printSimpleValues(List values) {
+ buf.append('[');
+ for (Iterator i = values.iterator(); i.hasNext();) {
+ printSimpleValue(i.next());
+ if (i.hasNext()) {
+ buf.append(',');
+ }
+ }
+ buf.append(']');
+
+ }
+
+ private void decrementIndent() {
+ indent -= indentIncrement;
+
+ }
+
+ private void incrementIndent() {
+ indent += indentIncrement;
+
+ }
+
+ private void indent() {
+ for (int i = 0; i < indent; i++) {
+ buf.append(' ');
+ }
+ }
+
+ private void lineBreak() {
+ buf.append('\n');
+ }
+
+ public StringBuffer getBuf() {
+ return buf;
+ }
+
+ public void setBuf(StringBuffer b) {
+ buf = b;
+ }
+
+ public HelperContext getScope() {
+ return scope;
+ }
+
+ public void setScope(HelperContext scope) {
+ this.scope = scope;
+ }
+
+}
diff --git a/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/internal/DocumentSamples.java b/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/internal/DocumentSamples.java
index 8d0cba0663..af20cb663a 100644
--- a/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/internal/DocumentSamples.java
+++ b/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/internal/DocumentSamples.java
@@ -1,218 +1,218 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.samples.sdo.internal;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.tuscany.samples.sdo.internal.SampleInfrastructure.SDOFacets;
-
-
-/**
- * Class to generate html documentation for the SDO Samples.
- * The program introspects the sample programs listed in the
- * {@link SampleInfrastructure#sampleClasses sample classes}
- * static constant, for the values of the static CORE_FUNCTION
- * and SIGNIFICANT_FUNCTION variables.
- * <P>
- * It builds indexes from
- * sample to function and from function to sample and creates
- * html output that displays these indexes.
- */
-public class DocumentSamples {
-
- private Map classToCoreFunction = new HashMap();
- private Map coreFunctionToClass = new HashMap();
- private Map classToSignificantFunction = new HashMap();
- private Map significantFunctionToClass = new HashMap();
-
- public static void main(String[] args) throws SecurityException,
- NoSuchMethodException, IllegalArgumentException, InstantiationException,
- IllegalAccessException, InvocationTargetException, IOException {
-
- DocumentSamples ds = new DocumentSamples();
- ds.run();
-
- }
-
- private static String HTML_HEADER =
- "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" +
- "<html>\n" +
- "<!-- Note: This file is GENERATED from the samples using the\n" +
- "Document Samples utility. Hand edits will be lost when regenerated! --> \n"+
- "<!-- \n"+
- "* \n"+
- "* Licensed to the Apache Software Foundation (ASF) under one \n"+
- "* or more contributor license agreements. See the NOTICE file\n"+
- "* distributed with this work for additional information \n"+
- "* regarding copyright ownership. The ASF licenses this file \n"+
- "* to you under the Apache License, Version 2.0 (the \n"+
- "* \"License\"); you may not use this file except in compliance \n"+
- "* with the License. You may obtain a copy of the License at \n"+
- "* \n"+
- "* http://www.apache.org/licenses/LICENSE-2.0 \n"+
- "* \n"+
- "* Unless required by applicable law or agreed to in writing, \n"+
- "* software distributed under the License is distributed on an \n"+
- "* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY \n"+
- "* KIND, either express or implied. See the License for the \n"+
- "* specific language governing permissions and limitations \n"+
- "* under the License. \n"+
- "--> \n"+
- "<head><title>SDO Samples</title></head><body>\n" +
- " <h1>SDO Samples</h1>\n" +
- "<P>\n" +
- "The samples provided in the Tuscany SDO distribution cover many areas of\n" +
- "the SDO API. Here we provide two indexes into the samples. The first lists\n" +
- "each sample in sequence and details the central theme(s) of the sample.\n" +
- "It also mentions if the sample significantly demonstrates other areas in passing.\n" +
- "The second index lists all the themes that are covered by these samples, and\n" +
- "indicates which of the samples has that subject area as a central theme or as\n" +
- "demonstrates the subject area significant as an incidental part of the sample.";
-
- private static String CLASSES_HEADING =
- "<H2>Index by Sample Program Name</H2>\n";
-
- private static String FUNCTION_HEADING =
- "<H2>Index by function</H2>\n";
-
- private static String HTML_FOOTER =
- "</body>\n</html>";
-
-
- private void run() throws IllegalAccessException {
- /*
- * gather the data
- */
- for (int i = 0; i < SampleInfrastructure.sampleClasses.length; i++) {
- Class c = SampleInfrastructure.sampleClasses[i];
- classToCoreFunction.put(c, new HashSet());
- try {
- Field coreFunction = c.getField("CORE_FUNCTION");
- recordFunction(c, coreFunction, coreFunctionToClass, classToCoreFunction);
- } catch (NoSuchFieldException e) {
- // no problem
- }
- try {
- Field sigFunction = c.getField("SIGNIFICANT_FUNCTION");
- recordFunction(c, sigFunction, significantFunctionToClass, classToSignificantFunction);
- } catch (NoSuchFieldException e) {
- // no problem
- }
- }
-
- /*
- * create the documentation
- */
- StringBuffer doc = new StringBuffer();
- doc.append(HTML_HEADER);
-
- doc.append(CLASSES_HEADING);
- Class [] classes = SampleInfrastructure.sampleClasses;
- for(int i=0; i < classes.length;i++) {
- doc.append("<h3>Sample Program " + getSimpleName(classes[i]) + "</h3>\n");
- doc.append("<b>Core function:</b><br/>\n");
- int [] functions = (int[])classToCoreFunction.get(classes[i]);
- for(int j=0;j<functions.length;j++) {
- doc.append("<a href=\"#facet")
- .append(functions[j])
- .append("\">")
- .append(SDOFacets.subject_areas[functions[j]])
- .append("</a><br/>\n"); }
- doc.append("<br/>");
- if(classToSignificantFunction.get(classes[i])!= null) {
- doc.append("<b>Also demonstrates:</b><br/>\n");
- functions = (int[])classToSignificantFunction.get(classes[i]);
- for(int j=0;j<functions.length;j++) {
- doc.append("<a href=\"#facet")
- .append(functions[j])
- .append("\">")
- .append(SDOFacets.subject_areas[functions[j]])
- .append("</a><br/>\n");
- }
- }
- }
-
- doc.append(FUNCTION_HEADING);
-
- String [] facets = SDOFacets.subject_areas;
- for(int f = 0; f<facets.length; f++) {
- Integer fobj = new Integer(f);
- doc.append("<a name=\"facet")
- .append(f)
- .append("\"/>\n<h3>")
- .append(SDOFacets.subject_areas[f])
- .append("</h3>\n");
- if(coreFunctionToClass.keySet().contains(fobj)) {
- doc.append("<b>Samples which demonstrate this as their core function</b><br/>\n");
- Set classesWithFunction = (Set)coreFunctionToClass.get(fobj);
- for(Iterator cwf = classesWithFunction.iterator(); cwf.hasNext();) {
- Class c = (Class)cwf.next();
- doc.append(getSimpleName(c)).append("<br/>\n");
- }
- }
- if(significantFunctionToClass.keySet().contains(fobj)) {
- doc.append("<b>Samples which demonstrate this in addition to their core function</b><br/>\n");
- Set classesWithFunction = (Set)significantFunctionToClass.get(fobj);
- for(Iterator cwf = classesWithFunction.iterator(); cwf.hasNext();) {
- Class c = (Class)cwf.next();
- doc.append(getSimpleName(c)).append("<br/>\n");
- }
- }
-
- }
-
- doc.append(HTML_FOOTER);
- System.out.println(doc);
- }
-
- private int[] recordFunction(Class c, Field functionIndices, Map ftoc, Map ctof)
- throws IllegalAccessException {
- int[] functions = (int[]) functionIndices.get(c);
- for (int j = 0; j < functions.length; j++) {
- addClassesToFunction(ftoc, functions[j], c);
- }
- ctof.put(c, functions);
- return functions;
- }
-
- private void addClassesToFunction(Map functionToClass, int i, Class c) {
- Integer iobj = new Integer(i);
- if (!functionToClass.containsKey(iobj)) {
- functionToClass.put(iobj, new HashSet());
- }
- ((Set) (functionToClass.get(iobj))).add(c);
- }
-
- private String getSimpleName(Class c) {
- String result = c.getName();
- int lastDot = result.lastIndexOf('.');
- if(lastDot != -1) {
- result = result.substring(lastDot+1);
- }
- return result;
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.samples.sdo.internal;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.tuscany.samples.sdo.internal.SampleInfrastructure.SDOFacets;
+
+
+/**
+ * Class to generate html documentation for the SDO Samples.
+ * The program introspects the sample programs listed in the
+ * {@link SampleInfrastructure#sampleClasses sample classes}
+ * static constant, for the values of the static CORE_FUNCTION
+ * and SIGNIFICANT_FUNCTION variables.
+ * <P>
+ * It builds indexes from
+ * sample to function and from function to sample and creates
+ * html output that displays these indexes.
+ */
+public class DocumentSamples {
+
+ private Map classToCoreFunction = new HashMap();
+ private Map coreFunctionToClass = new HashMap();
+ private Map classToSignificantFunction = new HashMap();
+ private Map significantFunctionToClass = new HashMap();
+
+ public static void main(String[] args) throws SecurityException,
+ NoSuchMethodException, IllegalArgumentException, InstantiationException,
+ IllegalAccessException, InvocationTargetException, IOException {
+
+ DocumentSamples ds = new DocumentSamples();
+ ds.run();
+
+ }
+
+ private static String HTML_HEADER =
+ "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n" +
+ "<html>\n" +
+ "<!-- Note: This file is GENERATED from the samples using the\n" +
+ "Document Samples utility. Hand edits will be lost when regenerated! --> \n"+
+ "<!-- \n"+
+ "* \n"+
+ "* Licensed to the Apache Software Foundation (ASF) under one \n"+
+ "* or more contributor license agreements. See the NOTICE file\n"+
+ "* distributed with this work for additional information \n"+
+ "* regarding copyright ownership. The ASF licenses this file \n"+
+ "* to you under the Apache License, Version 2.0 (the \n"+
+ "* \"License\"); you may not use this file except in compliance \n"+
+ "* with the License. You may obtain a copy of the License at \n"+
+ "* \n"+
+ "* http://www.apache.org/licenses/LICENSE-2.0 \n"+
+ "* \n"+
+ "* Unless required by applicable law or agreed to in writing, \n"+
+ "* software distributed under the License is distributed on an \n"+
+ "* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY \n"+
+ "* KIND, either express or implied. See the License for the \n"+
+ "* specific language governing permissions and limitations \n"+
+ "* under the License. \n"+
+ "--> \n"+
+ "<head><title>SDO Samples</title></head><body>\n" +
+ " <h1>SDO Samples</h1>\n" +
+ "<P>\n" +
+ "The samples provided in the Tuscany SDO distribution cover many areas of\n" +
+ "the SDO API. Here we provide two indexes into the samples. The first lists\n" +
+ "each sample in sequence and details the central theme(s) of the sample.\n" +
+ "It also mentions if the sample significantly demonstrates other areas in passing.\n" +
+ "The second index lists all the themes that are covered by these samples, and\n" +
+ "indicates which of the samples has that subject area as a central theme or as\n" +
+ "demonstrates the subject area significant as an incidental part of the sample.";
+
+ private static String CLASSES_HEADING =
+ "<H2>Index by Sample Program Name</H2>\n";
+
+ private static String FUNCTION_HEADING =
+ "<H2>Index by function</H2>\n";
+
+ private static String HTML_FOOTER =
+ "</body>\n</html>";
+
+
+ private void run() throws IllegalAccessException {
+ /*
+ * gather the data
+ */
+ for (int i = 0; i < SampleInfrastructure.sampleClasses.length; i++) {
+ Class c = SampleInfrastructure.sampleClasses[i];
+ classToCoreFunction.put(c, new HashSet());
+ try {
+ Field coreFunction = c.getField("CORE_FUNCTION");
+ recordFunction(c, coreFunction, coreFunctionToClass, classToCoreFunction);
+ } catch (NoSuchFieldException e) {
+ // no problem
+ }
+ try {
+ Field sigFunction = c.getField("SIGNIFICANT_FUNCTION");
+ recordFunction(c, sigFunction, significantFunctionToClass, classToSignificantFunction);
+ } catch (NoSuchFieldException e) {
+ // no problem
+ }
+ }
+
+ /*
+ * create the documentation
+ */
+ StringBuffer doc = new StringBuffer();
+ doc.append(HTML_HEADER);
+
+ doc.append(CLASSES_HEADING);
+ Class [] classes = SampleInfrastructure.sampleClasses;
+ for(int i=0; i < classes.length;i++) {
+ doc.append("<h3>Sample Program " + getSimpleName(classes[i]) + "</h3>\n");
+ doc.append("<b>Core function:</b><br/>\n");
+ int [] functions = (int[])classToCoreFunction.get(classes[i]);
+ for(int j=0;j<functions.length;j++) {
+ doc.append("<a href=\"#facet")
+ .append(functions[j])
+ .append("\">")
+ .append(SDOFacets.subject_areas[functions[j]])
+ .append("</a><br/>\n"); }
+ doc.append("<br/>");
+ if(classToSignificantFunction.get(classes[i])!= null) {
+ doc.append("<b>Also demonstrates:</b><br/>\n");
+ functions = (int[])classToSignificantFunction.get(classes[i]);
+ for(int j=0;j<functions.length;j++) {
+ doc.append("<a href=\"#facet")
+ .append(functions[j])
+ .append("\">")
+ .append(SDOFacets.subject_areas[functions[j]])
+ .append("</a><br/>\n");
+ }
+ }
+ }
+
+ doc.append(FUNCTION_HEADING);
+
+ String [] facets = SDOFacets.subject_areas;
+ for(int f = 0; f<facets.length; f++) {
+ Integer fobj = new Integer(f);
+ doc.append("<a name=\"facet")
+ .append(f)
+ .append("\"/>\n<h3>")
+ .append(SDOFacets.subject_areas[f])
+ .append("</h3>\n");
+ if(coreFunctionToClass.keySet().contains(fobj)) {
+ doc.append("<b>Samples which demonstrate this as their core function</b><br/>\n");
+ Set classesWithFunction = (Set)coreFunctionToClass.get(fobj);
+ for(Iterator cwf = classesWithFunction.iterator(); cwf.hasNext();) {
+ Class c = (Class)cwf.next();
+ doc.append(getSimpleName(c)).append("<br/>\n");
+ }
+ }
+ if(significantFunctionToClass.keySet().contains(fobj)) {
+ doc.append("<b>Samples which demonstrate this in addition to their core function</b><br/>\n");
+ Set classesWithFunction = (Set)significantFunctionToClass.get(fobj);
+ for(Iterator cwf = classesWithFunction.iterator(); cwf.hasNext();) {
+ Class c = (Class)cwf.next();
+ doc.append(getSimpleName(c)).append("<br/>\n");
+ }
+ }
+
+ }
+
+ doc.append(HTML_FOOTER);
+ System.out.println(doc);
+ }
+
+ private int[] recordFunction(Class c, Field functionIndices, Map ftoc, Map ctof)
+ throws IllegalAccessException {
+ int[] functions = (int[]) functionIndices.get(c);
+ for (int j = 0; j < functions.length; j++) {
+ addClassesToFunction(ftoc, functions[j], c);
+ }
+ ctof.put(c, functions);
+ return functions;
+ }
+
+ private void addClassesToFunction(Map functionToClass, int i, Class c) {
+ Integer iobj = new Integer(i);
+ if (!functionToClass.containsKey(iobj)) {
+ functionToClass.put(iobj, new HashSet());
+ }
+ ((Set) (functionToClass.get(iobj))).add(c);
+ }
+
+ private String getSimpleName(Class c) {
+ String result = c.getName();
+ int lastDot = result.lastIndexOf('.');
+ if(lastDot != -1) {
+ result = result.substring(lastDot+1);
+ }
+ return result;
+ }
+}
diff --git a/java/sdo/sample/src/main/resources/META-INF/LICENSE.txt b/java/sdo/sample/src/main/resources/META-INF/LICENSE.txt
index e55ca67ba9..9a90d375bc 100644
--- a/java/sdo/sample/src/main/resources/META-INF/LICENSE.txt
+++ b/java/sdo/sample/src/main/resources/META-INF/LICENSE.txt
@@ -1,207 +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.
-
-
-
-
-
+
+ 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/java/sdo/sample/src/main/resources/MedicalTest.xsd b/java/sdo/sample/src/main/resources/MedicalTest.xsd
index 0188fea46c..34ae528148 100644
--- a/java/sdo/sample/src/main/resources/MedicalTest.xsd
+++ b/java/sdo/sample/src/main/resources/MedicalTest.xsd
@@ -1,57 +1,57 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- -->
-<schema xmlns="http://www.w3.org/2001/XMLSchema"
- xmlns:people="www.example.org/people" xmlns:sdo="commonj.sdo"
- xmlns:sdoxml="commonj.sdo/xml"
- xmlns:tns="www.example.org/MedicalTest"
- targetNamespace="www.example.org/MedicalTest">
-
- <import namespace="www.example.org/people"
- schemaLocation="People.xsd" />
-
- <element name="test" type="tns:Test" />
- <element name="condition" type="tns:Condition" />
-
- <complexType name="Test">
- <sequence>
- <element name="referrals" type="people:PersonSet" />
- <element name="patients" type="people:PersonSet" />
- <element name="relatives" type="people:PersonSet" />
- </sequence>
- </complexType>
-
- <complexType name="Condition">
- <sequence>
- <element name="diagnosed" type="date" />
- </sequence>
- <attribute name="name" type="tns:ConditionName" />
- </complexType>
-
- <simpleType name="ConditionName">
- <restriction base="string">
- <enumeration value="Rigellian fever" />
- <enumeration value="Vegan choriomeningitis" />
- <enumeration value="Scrofungulus" />
- <enumeration value="Panar Syndrome" />
- </restriction>
- </simpleType>
-
-
-</schema>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:people="www.example.org/people" xmlns:sdo="commonj.sdo"
+ xmlns:sdoxml="commonj.sdo/xml"
+ xmlns:tns="www.example.org/MedicalTest"
+ targetNamespace="www.example.org/MedicalTest">
+
+ <import namespace="www.example.org/people"
+ schemaLocation="People.xsd" />
+
+ <element name="test" type="tns:Test" />
+ <element name="condition" type="tns:Condition" />
+
+ <complexType name="Test">
+ <sequence>
+ <element name="referrals" type="people:PersonSet" />
+ <element name="patients" type="people:PersonSet" />
+ <element name="relatives" type="people:PersonSet" />
+ </sequence>
+ </complexType>
+
+ <complexType name="Condition">
+ <sequence>
+ <element name="diagnosed" type="date" />
+ </sequence>
+ <attribute name="name" type="tns:ConditionName" />
+ </complexType>
+
+ <simpleType name="ConditionName">
+ <restriction base="string">
+ <enumeration value="Rigellian fever" />
+ <enumeration value="Vegan choriomeningitis" />
+ <enumeration value="Scrofungulus" />
+ <enumeration value="Panar Syndrome" />
+ </restriction>
+ </simpleType>
+
+
+</schema>
diff --git a/java/sdo/sample/src/main/resources/MedicalTest_CS.xsd b/java/sdo/sample/src/main/resources/MedicalTest_CS.xsd
index 62a6d2998d..668c023bc6 100644
--- a/java/sdo/sample/src/main/resources/MedicalTest_CS.xsd
+++ b/java/sdo/sample/src/main/resources/MedicalTest_CS.xsd
@@ -1,58 +1,58 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- -->
-<schema xmlns="http://www.w3.org/2001/XMLSchema"
- xmlns:people="www.example.org/people" xmlns:sdo="commonj.sdo"
- xmlns:sdoxml="commonj.sdo/xml"
- xmlns:tns="www.example.org/MedicalTest"
- targetNamespace="www.example.org/MedicalTest">
-
- <import namespace="www.example.org/people"
- schemaLocation="People.xsd" />
-
- <element name="test" type="tns:Test" />
- <element name="condition" type="tns:Condition" />
-
- <complexType name="Test">
- <sequence>
- <element name="referrals" type="people:PersonSet" />
- <element name="patients" type="people:PersonSet" />
- <element name="relatives" type="people:PersonSet" />
- <element name="changes" type="sdo:ChangeSummaryType" />
- </sequence>
- </complexType>
-
- <complexType name="Condition">
- <sequence>
- <element name="diagnosed" type="date" />
- </sequence>
- <attribute name="name" type="tns:ConditionName" />
- </complexType>
-
- <simpleType name="ConditionName">
- <restriction base="string">
- <enumeration value="Rigellian fever" />
- <enumeration value="Vegan choriomeningitis" />
- <enumeration value="Scrofungulus" />
- <enumeration value="Panar Syndrome" />
- </restriction>
- </simpleType>
-
-
-</schema>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ xmlns:people="www.example.org/people" xmlns:sdo="commonj.sdo"
+ xmlns:sdoxml="commonj.sdo/xml"
+ xmlns:tns="www.example.org/MedicalTest"
+ targetNamespace="www.example.org/MedicalTest">
+
+ <import namespace="www.example.org/people"
+ schemaLocation="People.xsd" />
+
+ <element name="test" type="tns:Test" />
+ <element name="condition" type="tns:Condition" />
+
+ <complexType name="Test">
+ <sequence>
+ <element name="referrals" type="people:PersonSet" />
+ <element name="patients" type="people:PersonSet" />
+ <element name="relatives" type="people:PersonSet" />
+ <element name="changes" type="sdo:ChangeSummaryType" />
+ </sequence>
+ </complexType>
+
+ <complexType name="Condition">
+ <sequence>
+ <element name="diagnosed" type="date" />
+ </sequence>
+ <attribute name="name" type="tns:ConditionName" />
+ </complexType>
+
+ <simpleType name="ConditionName">
+ <restriction base="string">
+ <enumeration value="Rigellian fever" />
+ <enumeration value="Vegan choriomeningitis" />
+ <enumeration value="Scrofungulus" />
+ <enumeration value="Panar Syndrome" />
+ </restriction>
+ </simpleType>
+
+
+</schema>
diff --git a/java/sdo/sample/src/main/resources/People.xsd b/java/sdo/sample/src/main/resources/People.xsd
index c0402bcc3b..b9e59701ae 100644
--- a/java/sdo/sample/src/main/resources/People.xsd
+++ b/java/sdo/sample/src/main/resources/People.xsd
@@ -1,70 +1,70 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- -->
-<schema xmlns="http://www.w3.org/2001/XMLSchema"
- targetNamespace="www.example.org/people"
- xmlns:sdo="commonj.sdo"
- xmlns:sdoxml="commonj.sdo/xml"
- xmlns:tns="www.example.org/people">
-
- <!-- <import namespace="commonj.sdo/xml" schemaLocation="sdoXML.xsd" /> -->
-
- <complexType name="Person">
- <sequence>
- <element name="dob" type="date"/>
- <element name="relative" maxOccurs="unbounded" type="tns:Relative"/>
- <any namespace="##other" processContents="lax" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="id" type="ID"/>
- <attribute name="name" type="string"/>
- <attribute name="gender" type = "tns:Gender"/>
- </complexType>
-
- <!-- <complexType name="Parent">
- <attribute name="parent" type="IDREF" sdoxml:propertyType="tns:Person" use="required"/>
- <attribute name="genetic" use="optional" type="boolean"/>
- </complexType> -->
-
- <complexType name="Relative">
- <attribute name="target" type="IDREF" sdoxml:propertyType="tns:Person" use="required"/>
- <attribute name="relationship" type="string" />
- <attribute name="genetic" use="optional" type="boolean"/>
- </complexType>
-
- <!-- <complexType name="GeneticParent">
- <complexContent>
- <extension base="tns:Parent">
- </extension>
- </complexContent>
- </complexType> -->
-
- <complexType name="PersonSet">
- <sequence>
- <element name="person" type="tns:Person" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
-
- <simpleType name="Gender">
- <restriction base="string">
- <enumeration value="male" />
- <enumeration value="female" />
- </restriction>
- </simpleType>
-
-</schema>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ -->
+<schema xmlns="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="www.example.org/people"
+ xmlns:sdo="commonj.sdo"
+ xmlns:sdoxml="commonj.sdo/xml"
+ xmlns:tns="www.example.org/people">
+
+ <!-- <import namespace="commonj.sdo/xml" schemaLocation="sdoXML.xsd" /> -->
+
+ <complexType name="Person">
+ <sequence>
+ <element name="dob" type="date"/>
+ <element name="relative" maxOccurs="unbounded" type="tns:Relative"/>
+ <any namespace="##other" processContents="lax" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="id" type="ID"/>
+ <attribute name="name" type="string"/>
+ <attribute name="gender" type = "tns:Gender"/>
+ </complexType>
+
+ <!-- <complexType name="Parent">
+ <attribute name="parent" type="IDREF" sdoxml:propertyType="tns:Person" use="required"/>
+ <attribute name="genetic" use="optional" type="boolean"/>
+ </complexType> -->
+
+ <complexType name="Relative">
+ <attribute name="target" type="IDREF" sdoxml:propertyType="tns:Person" use="required"/>
+ <attribute name="relationship" type="string" />
+ <attribute name="genetic" use="optional" type="boolean"/>
+ </complexType>
+
+ <!-- <complexType name="GeneticParent">
+ <complexContent>
+ <extension base="tns:Parent">
+ </extension>
+ </complexContent>
+ </complexType> -->
+
+ <complexType name="PersonSet">
+ <sequence>
+ <element name="person" type="tns:Person" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <simpleType name="Gender">
+ <restriction base="string">
+ <enumeration value="male" />
+ <enumeration value="female" />
+ </restriction>
+ </simpleType>
+
+</schema>
diff --git a/java/sdo/sdo-api/pom.xml b/java/sdo/sdo-api/pom.xml
index e3249d95a9..450bfa4b19 100644
--- a/java/sdo/sdo-api/pom.xml
+++ b/java/sdo/sdo-api/pom.xml
@@ -95,13 +95,19 @@
<target>1.4</target>
</configuration>
</plugin>
+
<plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
- </archive>
- </configuration>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestEntries>
+ <Implementation-Vendor-Id>org.apache</Implementation-Vendor-Id>
+ <Implementation-Version>1.1-incubating</Implementation-Version>
+ <X-Compile-Source-JDK>1.4</X-Compile-Source-JDK>
+ <X-Compile-Target-JDK>1.4</X-Compile-Target-JDK>
+ </manifestEntries>
+ </archive>
+ </configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
diff --git a/java/sdo/sdo-api/src/main/java/commonj/sdo/helper/HelperContext.java b/java/sdo/sdo-api/src/main/java/commonj/sdo/helper/HelperContext.java
index 058393f727..143b29de17 100644
--- a/java/sdo/sdo-api/src/main/java/commonj/sdo/helper/HelperContext.java
+++ b/java/sdo/sdo-api/src/main/java/commonj/sdo/helper/HelperContext.java
@@ -1,67 +1,67 @@
-/**
- * <copyright>
- *
- * Service Data Objects
- * Version 2.1.0
- * Licensed Materials
- *
- * (c) Copyright BEA Systems, Inc., International Business Machines Corporation,
- * Oracle Corporation, Primeton Technologies Ltd., Rogue Wave Software, SAP AG.,
- * Software AG., Sun Microsystems, Sybase Inc., Xcalia, Zend Technologies,
- * 2005, 2006. All rights reserved.
- *
- * </copyright>
- *
- */
-
-package commonj.sdo.helper;
-
-/**
- * This interface represents a helper execution context.
- * The set of helpers returned by the methods in this interface have visibility
- * to the same SDO metadata, that is, they execute in the same "scope".
- */
-public interface HelperContext
-{
- /**
- * Gets the CopyHelper to use in this context.
- * @return a CopyHelper object
- */
- CopyHelper getCopyHelper();
-
- /**
- * Gets the DataFactory to use in this context.
- * @return a DataFactory object
- */
- DataFactory getDataFactory();
-
- /**
- * Gets the DataHelper to use in this context.
- * @return a DataHelper object
- */
- DataHelper getDataHelper();
-
- /**
- * Gets the EqualityHelper to use in this context.
- * @return an EqualityHelper object
- */
- EqualityHelper getEqualityHelper();
-
- /**
- * Gets the TypeHelper to use in this context.
- * @return a TypeHelper object
- */
- TypeHelper getTypeHelper();
-
- /**
- * Gets the XMLHelper to use in this context.
- * @return an XMLHelper object
- */
- XMLHelper getXMLHelper();
-
- /**
- * Gets the XSDHelper to use in this context.
- * @return an XSDHelper object
- */
- XSDHelper getXSDHelper();
-}
+/**
+ * <copyright>
+ *
+ * Service Data Objects
+ * Version 2.1.0
+ * Licensed Materials
+ *
+ * (c) Copyright BEA Systems, Inc., International Business Machines Corporation,
+ * Oracle Corporation, Primeton Technologies Ltd., Rogue Wave Software, SAP AG.,
+ * Software AG., Sun Microsystems, Sybase Inc., Xcalia, Zend Technologies,
+ * 2005, 2006. All rights reserved.
+ *
+ * </copyright>
+ *
+ */
+
+package commonj.sdo.helper;
+
+/**
+ * This interface represents a helper execution context.
+ * The set of helpers returned by the methods in this interface have visibility
+ * to the same SDO metadata, that is, they execute in the same "scope".
+ */
+public interface HelperContext
+{
+ /**
+ * Gets the CopyHelper to use in this context.
+ * @return a CopyHelper object
+ */
+ CopyHelper getCopyHelper();
+
+ /**
+ * Gets the DataFactory to use in this context.
+ * @return a DataFactory object
+ */
+ DataFactory getDataFactory();
+
+ /**
+ * Gets the DataHelper to use in this context.
+ * @return a DataHelper object
+ */
+ DataHelper getDataHelper();
+
+ /**
+ * Gets the EqualityHelper to use in this context.
+ * @return an EqualityHelper object
+ */
+ EqualityHelper getEqualityHelper();
+
+ /**
+ * Gets the TypeHelper to use in this context.
+ * @return a TypeHelper object
+ */
+ TypeHelper getTypeHelper();
+
+ /**
+ * Gets the XMLHelper to use in this context.
+ * @return an XMLHelper object
+ */
+ XMLHelper getXMLHelper();
+
+ /**
+ * Gets the XSDHelper to use in this context.
+ * @return an XSDHelper object
+ */
+ XSDHelper getXSDHelper();
+}
diff --git a/java/sdo/tools/pom.xml b/java/sdo/tools/pom.xml
index 0a61744cb6..e40a8c55d9 100644
--- a/java/sdo/tools/pom.xml
+++ b/java/sdo/tools/pom.xml
@@ -95,6 +95,19 @@
<build>
<plugins>
+ <plugin>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestEntries>
+ <Implementation-Vendor-Id>org.apache</Implementation-Vendor-Id>
+ <Implementation-Version>1.1-incubating</Implementation-Version>
+ <X-Compile-Source-JDK>1.4</X-Compile-Source-JDK>
+ <X-Compile-Target-JDK>1.4</X-Compile-Target-JDK>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
diff --git a/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/adapter/SDOGenModelGeneratorAdapter.java b/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/adapter/SDOGenModelGeneratorAdapter.java
index c557d18431..16678e001b 100644
--- a/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/adapter/SDOGenModelGeneratorAdapter.java
+++ b/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/adapter/SDOGenModelGeneratorAdapter.java
@@ -1,38 +1,38 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sdo.generate.adapter;
-
-import org.eclipse.emf.codegen.ecore.generator.GeneratorAdapterFactory;
-import org.eclipse.emf.codegen.ecore.genmodel.generator.GenModelGeneratorAdapter;
-import org.eclipse.emf.common.util.Monitor;
-
-public class SDOGenModelGeneratorAdapter extends GenModelGeneratorAdapter {
-
- public SDOGenModelGeneratorAdapter(
- GeneratorAdapterFactory generatorAdapterFactory) {
- super(generatorAdapterFactory);
- }
-
- protected void ensureProjectExists(String workspacePath, Object object,
- Object projectType, boolean force, Monitor monitor) {
- // Do nothing -- this avoids differential behaviour according to whether we
- // are running in Eclipse or not
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.generate.adapter;
+
+import org.eclipse.emf.codegen.ecore.generator.GeneratorAdapterFactory;
+import org.eclipse.emf.codegen.ecore.genmodel.generator.GenModelGeneratorAdapter;
+import org.eclipse.emf.common.util.Monitor;
+
+public class SDOGenModelGeneratorAdapter extends GenModelGeneratorAdapter {
+
+ public SDOGenModelGeneratorAdapter(
+ GeneratorAdapterFactory generatorAdapterFactory) {
+ super(generatorAdapterFactory);
+ }
+
+ protected void ensureProjectExists(String workspacePath, Object object,
+ Object projectType, boolean force, Monitor monitor) {
+ // Do nothing -- this avoids differential behaviour according to whether we
+ // are running in Eclipse or not
+ }
+}
diff --git a/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/util/SDOGenUtil.java b/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/util/SDOGenUtil.java
index 6c4293f514..062580f4b8 100644
--- a/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/util/SDOGenUtil.java
+++ b/java/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/util/SDOGenUtil.java
@@ -1,326 +1,326 @@
-/**
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sdo.generate.util;
-
-import java.util.Iterator;
-
-import org.apache.tuscany.sdo.model.ModelFactory;
-import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl;
-import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
-import org.eclipse.emf.codegen.ecore.genmodel.GenClassifier;
-import org.eclipse.emf.codegen.ecore.genmodel.GenDataType;
-import org.eclipse.emf.codegen.ecore.genmodel.GenDelegationKind;
-import org.eclipse.emf.codegen.ecore.genmodel.GenFeature;
-import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
-import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
-import org.eclipse.emf.codegen.ecore.genmodel.impl.GenFeatureImpl;
-import org.eclipse.emf.codegen.ecore.genmodel.impl.Literals;
-import org.eclipse.emf.codegen.util.CodeGenUtil;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EcorePackage;
-
-import commonj.sdo.Type;
-
-public class SDOGenUtil {
-
- public static String getQualifiedTypeAccessor(GenClassifier genClassifier)
- {
- GenPackage genPackage = genClassifier.getGenPackage();
- return getFactoryImpl(genPackage) + ".get" + genClassifier.getClassifierAccessorName() + "()";
- }
-
- public static String getDependentFactoryArgumentList(GenPackage genPackage, boolean isFormalArguments)
- {
- StringBuffer result = new StringBuffer();
- for (Iterator iter = genPackage.getPackageInitializationDependencies().iterator(); iter.hasNext(); )
- {
- GenPackage dep = (GenPackage)iter.next();
- if (isFormalArguments)
- {
- result.append(dep.getImportedFactoryClassName());
- result.append(" ");
- }
- result.append(genPackage.getPackageInstanceVariable(dep));
- if (iter.hasNext()) result.append(", ");
- }
- return result.toString();
- }
-
- public static String getFactoryImpl(GenPackage genPackage)
- {
- return "((" + genPackage.getImportedFactoryClassName() + ")"
- + genPackage.getImportedFactoryInterfaceName() + ".INSTANCE)";
- }
-
- public static String getListKind(GenFeature genFeature, boolean suppressNotification )
- {
- boolean unsettable = genFeature.isUnsettable();
-
- if (suppressNotification)
- {
- return "ListKind.BASIC";
- }
- else if (genFeature.isEffectiveContains())
- {
- if (genFeature.isBidirectional())
- {
- if (genFeature.isResolveProxies())
- {
- if( unsettable )
- return "ListKind.CONTAINMENT_INVERSE_RESOLVING_UNSETTABLE";
- else
- return "ListKind.CONTAINMENT_INVERSE_RESOLVING";
- }
- else
- {
- if( unsettable )
- return "ListKind.CONTAINMENT_INVERSE_UNSETTABLE";
- else
- return "ListKind.CONTAINMENT_INVERSE";
- }
- }
- else
- {
- if (genFeature.isResolveProxies())
- {
- if( unsettable )
- return "ListKind.CONTAINMENT_RESOLVING_UNSETTABLE";
- else
- return "ListKind.CONTAINMENT_RESOLVING";
- }
- else
- {
- if( unsettable )
- return "ListKind.CONTAINMENT_UNSETTABLE";
- else
- return "ListKind.CONTAINMENT";
- }
- }
- }
- else if (genFeature.isReferenceType())
- {
- if (genFeature.isBidirectional())
- {
- GenFeature reverseFeature = genFeature.getReverse();
- if (genFeature.isResolveProxies())
- {
- if (reverseFeature.isListType())
- {
- if( unsettable )
- return "ListKind.NONCONTAINMENT_MANYINVERSE_RESOLVING_UNSETTABLE";
- else
- return "ListKind.NONCONTAINMENT_MANYINVERSE_RESOLVING";
- }
- else
- {
- if( unsettable )
- return "ListKind.NONCONTAINMENT_INVERSE_RESOLVING_UNSETTABLE";
- else
- return "ListKind.NONCONTAINMENT_INVERSE_RESOLVING";
- }
- }
- else
- {
- if (reverseFeature.isListType())
- {
- if( unsettable )
- return "ListKind.NONCONTAINMENT_MANYINVERSE_UNSETTABLE";
- else
- return "ListKind.NONCONTAINMENT_MANYINVERSE";
- }
- else
- {
- if( unsettable )
- return "ListKind.NONCONTAINMENT_INVERSE_UNSETTABLE";
- else
- return "ListKind.NONCONTAINMENT_INVERSE";
- }
- }
- }
- else
- {
- if (genFeature.isResolveProxies())
- {
- if( unsettable )
- return "ListKind.NONCONTAINMENT_RESOLVING_UNSETTABLE";
- else
- return "ListKind.NONCONTAINMENT_RESOLVING";
- }
- else
- {
- if( unsettable )
- return "ListKind.NONCONTAINMENT_UNSETTABLE";
- else
- return "ListKind.NONCONTAINMENT";
- }
- }
- }
- else
- { //datatype
- if (genFeature.isUnique())
- {
- if( unsettable )
- return "ListKind.DATATYPE_UNIQUE_UNSETTABLE";
- else
- return "ListKind.DATATYPE_UNIQUE";
- }
- else
- {
- if( unsettable )
- return "ListKind.DATATYPE_UNSETTABLE";
- else
- return "ListKind.DATATYPE";
- }
- }
- }
-
- public static boolean hasChangeSummaryProperty(GenClass genClass)
- {
- return getChangeSummaryProperty(genClass) != null;
- }
-
- public static String getQualifiedInternalPropertyID(GenFeature genFeature)
- {
- return genFeature.getGenClass().getImportedClassName() + ".INTERNAL_" + genFeature.getUpperName();
- }
-
- public static String getChangeSummaryProperty(GenClass genClass)
- {
- Type csType = ((ModelFactoryImpl)ModelFactory.INSTANCE).getChangeSummaryType();
- for (Iterator i = genClass.getGenFeatures().iterator(); i.hasNext(); )
- {
- GenFeature genFeature = (GenFeature)i.next();
- EClassifier eClassifier = genFeature.getEcoreFeature().getEType();
- if (eClassifier instanceof Type)
- {
- Type type = (Type)eClassifier;
- //if (csType == type)// this doesn't work when generating sdoModel.xsd
- if (csType.getName().equals(type.getName()) && csType.getURI().equals(type.getURI()))
- {
- return genFeature.getUpperName();
- }
- }
- }
- return null;
- }
-
- public static String printArguments(GenPackage genPackage, GenModel genModel) {
- StringBuffer result = new StringBuffer();
- if(!CodeGenUtil.capName(genPackage.getNSName()).equals(genPackage.getPrefix())) {
- result.append(" -prefix " + genPackage.getPrefix());
- }
- if (genModel.isSuppressInterfaces()) {
- result.append(" -noInterfaces");
- }
- if ( genModel.getFeatureDelegation() == GenDelegationKind.VIRTUAL_LITERAL) {
- result.append(" -sparsePattern");
- }
- if ("org.apache.tuscany.sdo.impl.StoreDataObjectImpl".equals(genModel.getRootExtendsClass())) {
- result.append(" -storePattern");
- }
- if (genModel.isSuppressNotification()) {
- result.append(" -noNotification");
- }
- if (genModel.isSuppressContainment()) {
- result.append(" -noContainment");
- }
- if (genModel.isArrayAccessors()) {
- result.append(" -arrayAccessors");
- }
- if (genModel.isSuppressUnsettable()) {
- result.append(" -noUnsettable");
- }
-
- return result.toString();
- }
-
- /*
- * EMF doesn't do what we want in all cases, so filter the cases we need to handle
- * and drop through to EMF for all others.
- */
- public static String getStaticDefaultValue(GenFeature genFeature) {
- String result = "null";
- boolean defaultFound = false;
-
- String defaultString = genFeature.getEcoreFeature()
- .getDefaultValueLiteral();
- EClassifier eType = genFeature.getEcoreFeature().getEType();
- if (eType instanceof EDataType) {
- GenPackage genPackage = ((GenFeatureImpl) genFeature)
- .findGenPackage(genFeature.getEcoreFeature().getEType().getEPackage());
- GenDataType gdt = null;
- if (genPackage != null) {
- for (Iterator iter = genPackage.getGenDataTypes().iterator(); iter
- .hasNext()
- && gdt == null;) {
- GenDataType genDataType = (GenDataType) iter.next();
- if (eType.getName().equals(genDataType.getEcoreDataType().getName())) {
- gdt = genDataType;
- }
- }
- }
- EClassifier eDataType = gdt.getEcoreDataType();
- if (eDataType.getEPackage() != EcorePackage.eINSTANCE
- && defaultString != null) {
- boolean replaced = false;
- for (Iterator i = EcorePackage.eINSTANCE.getEClassifiers().iterator(); i
- .hasNext();) {
- EClassifier eClassifier = (EClassifier) i.next();
- if (eClassifier instanceof EDataType
- && eClassifier.getInstanceClassName().equals(
- eDataType.getInstanceClassName())
- && ((EDataType) eClassifier).isSerializable()
- && eClassifier != EcorePackage.eINSTANCE.getEDate()) {
- replaced = true;
- eDataType = eClassifier;
- break;
- }
- }
- if (!replaced) {
- result = "((" + genPackage.getFactoryClassName() + ")"
- + genPackage.getFactoryInterfaceName() + "."
- + genPackage.getFactoryInstanceName() + ")." + "create"
- + gdt.getName() + "FromString("
- + Literals.toLiteral(defaultString) + ")";
-
-
- if (gdt.isPrimitiveType())
- {
- result = "((" + gdt.getObjectInstanceClassName() + ")" + result
- + ")." + gdt.getPrimitiveValueFunction() + "()";
- } else if (!gdt.isObjectType()) {
- result = "(" + gdt.getImportedInstanceClassName() + ")" + result;
- }
-
- defaultFound = true;
- }
- }
- }
-
- if (!defaultFound) {
- // the input didn't match any special case that we want to handle differently
- // from EMF's default approach, so go ahead and get EMF to do it
- result = genFeature.getStaticDefaultValue();
- }
-
- return result;
- }
-}
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tuscany.sdo.generate.util;
+
+import java.util.Iterator;
+
+import org.apache.tuscany.sdo.model.ModelFactory;
+import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl;
+import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
+import org.eclipse.emf.codegen.ecore.genmodel.GenClassifier;
+import org.eclipse.emf.codegen.ecore.genmodel.GenDataType;
+import org.eclipse.emf.codegen.ecore.genmodel.GenDelegationKind;
+import org.eclipse.emf.codegen.ecore.genmodel.GenFeature;
+import org.eclipse.emf.codegen.ecore.genmodel.GenModel;
+import org.eclipse.emf.codegen.ecore.genmodel.GenPackage;
+import org.eclipse.emf.codegen.ecore.genmodel.impl.GenFeatureImpl;
+import org.eclipse.emf.codegen.ecore.genmodel.impl.Literals;
+import org.eclipse.emf.codegen.util.CodeGenUtil;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EcorePackage;
+
+import commonj.sdo.Type;
+
+public class SDOGenUtil {
+
+ public static String getQualifiedTypeAccessor(GenClassifier genClassifier)
+ {
+ GenPackage genPackage = genClassifier.getGenPackage();
+ return getFactoryImpl(genPackage) + ".get" + genClassifier.getClassifierAccessorName() + "()";
+ }
+
+ public static String getDependentFactoryArgumentList(GenPackage genPackage, boolean isFormalArguments)
+ {
+ StringBuffer result = new StringBuffer();
+ for (Iterator iter = genPackage.getPackageInitializationDependencies().iterator(); iter.hasNext(); )
+ {
+ GenPackage dep = (GenPackage)iter.next();
+ if (isFormalArguments)
+ {
+ result.append(dep.getImportedFactoryClassName());
+ result.append(" ");
+ }
+ result.append(genPackage.getPackageInstanceVariable(dep));
+ if (iter.hasNext()) result.append(", ");
+ }
+ return result.toString();
+ }
+
+ public static String getFactoryImpl(GenPackage genPackage)
+ {
+ return "((" + genPackage.getImportedFactoryClassName() + ")"
+ + genPackage.getImportedFactoryInterfaceName() + ".INSTANCE)";
+ }
+
+ public static String getListKind(GenFeature genFeature, boolean suppressNotification )
+ {
+ boolean unsettable = genFeature.isUnsettable();
+
+ if (suppressNotification)
+ {
+ return "ListKind.BASIC";
+ }
+ else if (genFeature.isEffectiveContains())
+ {
+ if (genFeature.isBidirectional())
+ {
+ if (genFeature.isResolveProxies())
+ {
+ if( unsettable )
+ return "ListKind.CONTAINMENT_INVERSE_RESOLVING_UNSETTABLE";
+ else
+ return "ListKind.CONTAINMENT_INVERSE_RESOLVING";
+ }
+ else
+ {
+ if( unsettable )
+ return "ListKind.CONTAINMENT_INVERSE_UNSETTABLE";
+ else
+ return "ListKind.CONTAINMENT_INVERSE";
+ }
+ }
+ else
+ {
+ if (genFeature.isResolveProxies())
+ {
+ if( unsettable )
+ return "ListKind.CONTAINMENT_RESOLVING_UNSETTABLE";
+ else
+ return "ListKind.CONTAINMENT_RESOLVING";
+ }
+ else
+ {
+ if( unsettable )
+ return "ListKind.CONTAINMENT_UNSETTABLE";
+ else
+ return "ListKind.CONTAINMENT";
+ }
+ }
+ }
+ else if (genFeature.isReferenceType())
+ {
+ if (genFeature.isBidirectional())
+ {
+ GenFeature reverseFeature = genFeature.getReverse();
+ if (genFeature.isResolveProxies())
+ {
+ if (reverseFeature.isListType())
+ {
+ if( unsettable )
+ return "ListKind.NONCONTAINMENT_MANYINVERSE_RESOLVING_UNSETTABLE";
+ else
+ return "ListKind.NONCONTAINMENT_MANYINVERSE_RESOLVING";
+ }
+ else
+ {
+ if( unsettable )
+ return "ListKind.NONCONTAINMENT_INVERSE_RESOLVING_UNSETTABLE";
+ else
+ return "ListKind.NONCONTAINMENT_INVERSE_RESOLVING";
+ }
+ }
+ else
+ {
+ if (reverseFeature.isListType())
+ {
+ if( unsettable )
+ return "ListKind.NONCONTAINMENT_MANYINVERSE_UNSETTABLE";
+ else
+ return "ListKind.NONCONTAINMENT_MANYINVERSE";
+ }
+ else
+ {
+ if( unsettable )
+ return "ListKind.NONCONTAINMENT_INVERSE_UNSETTABLE";
+ else
+ return "ListKind.NONCONTAINMENT_INVERSE";
+ }
+ }
+ }
+ else
+ {
+ if (genFeature.isResolveProxies())
+ {
+ if( unsettable )
+ return "ListKind.NONCONTAINMENT_RESOLVING_UNSETTABLE";
+ else
+ return "ListKind.NONCONTAINMENT_RESOLVING";
+ }
+ else
+ {
+ if( unsettable )
+ return "ListKind.NONCONTAINMENT_UNSETTABLE";
+ else
+ return "ListKind.NONCONTAINMENT";
+ }
+ }
+ }
+ else
+ { //datatype
+ if (genFeature.isUnique())
+ {
+ if( unsettable )
+ return "ListKind.DATATYPE_UNIQUE_UNSETTABLE";
+ else
+ return "ListKind.DATATYPE_UNIQUE";
+ }
+ else
+ {
+ if( unsettable )
+ return "ListKind.DATATYPE_UNSETTABLE";
+ else
+ return "ListKind.DATATYPE";
+ }
+ }
+ }
+
+ public static boolean hasChangeSummaryProperty(GenClass genClass)
+ {
+ return getChangeSummaryProperty(genClass) != null;
+ }
+
+ public static String getQualifiedInternalPropertyID(GenFeature genFeature)
+ {
+ return genFeature.getGenClass().getImportedClassName() + ".INTERNAL_" + genFeature.getUpperName();
+ }
+
+ public static String getChangeSummaryProperty(GenClass genClass)
+ {
+ Type csType = ((ModelFactoryImpl)ModelFactory.INSTANCE).getChangeSummaryType();
+ for (Iterator i = genClass.getGenFeatures().iterator(); i.hasNext(); )
+ {
+ GenFeature genFeature = (GenFeature)i.next();
+ EClassifier eClassifier = genFeature.getEcoreFeature().getEType();
+ if (eClassifier instanceof Type)
+ {
+ Type type = (Type)eClassifier;
+ //if (csType == type)// this doesn't work when generating sdoModel.xsd
+ if (csType.getName().equals(type.getName()) && csType.getURI().equals(type.getURI()))
+ {
+ return genFeature.getUpperName();
+ }
+ }
+ }
+ return null;
+ }
+
+ public static String printArguments(GenPackage genPackage, GenModel genModel) {
+ StringBuffer result = new StringBuffer();
+ if(!CodeGenUtil.capName(genPackage.getNSName()).equals(genPackage.getPrefix())) {
+ result.append(" -prefix " + genPackage.getPrefix());
+ }
+ if (genModel.isSuppressInterfaces()) {
+ result.append(" -noInterfaces");
+ }
+ if ( genModel.getFeatureDelegation() == GenDelegationKind.VIRTUAL_LITERAL) {
+ result.append(" -sparsePattern");
+ }
+ if ("org.apache.tuscany.sdo.impl.StoreDataObjectImpl".equals(genModel.getRootExtendsClass())) {
+ result.append(" -storePattern");
+ }
+ if (genModel.isSuppressNotification()) {
+ result.append(" -noNotification");
+ }
+ if (genModel.isSuppressContainment()) {
+ result.append(" -noContainment");
+ }
+ if (genModel.isArrayAccessors()) {
+ result.append(" -arrayAccessors");
+ }
+ if (genModel.isSuppressUnsettable()) {
+ result.append(" -noUnsettable");
+ }
+
+ return result.toString();
+ }
+
+ /*
+ * EMF doesn't do what we want in all cases, so filter the cases we need to handle
+ * and drop through to EMF for all others.
+ */
+ public static String getStaticDefaultValue(GenFeature genFeature) {
+ String result = "null";
+ boolean defaultFound = false;
+
+ String defaultString = genFeature.getEcoreFeature()
+ .getDefaultValueLiteral();
+ EClassifier eType = genFeature.getEcoreFeature().getEType();
+ if (eType instanceof EDataType) {
+ GenPackage genPackage = ((GenFeatureImpl) genFeature)
+ .findGenPackage(genFeature.getEcoreFeature().getEType().getEPackage());
+ GenDataType gdt = null;
+ if (genPackage != null) {
+ for (Iterator iter = genPackage.getGenDataTypes().iterator(); iter
+ .hasNext()
+ && gdt == null;) {
+ GenDataType genDataType = (GenDataType) iter.next();
+ if (eType.getName().equals(genDataType.getEcoreDataType().getName())) {
+ gdt = genDataType;
+ }
+ }
+ }
+ EClassifier eDataType = gdt.getEcoreDataType();
+ if (eDataType.getEPackage() != EcorePackage.eINSTANCE
+ && defaultString != null) {
+ boolean replaced = false;
+ for (Iterator i = EcorePackage.eINSTANCE.getEClassifiers().iterator(); i
+ .hasNext();) {
+ EClassifier eClassifier = (EClassifier) i.next();
+ if (eClassifier instanceof EDataType
+ && eClassifier.getInstanceClassName().equals(
+ eDataType.getInstanceClassName())
+ && ((EDataType) eClassifier).isSerializable()
+ && eClassifier != EcorePackage.eINSTANCE.getEDate()) {
+ replaced = true;
+ eDataType = eClassifier;
+ break;
+ }
+ }
+ if (!replaced) {
+ result = "((" + genPackage.getFactoryClassName() + ")"
+ + genPackage.getFactoryInterfaceName() + "."
+ + genPackage.getFactoryInstanceName() + ")." + "create"
+ + gdt.getName() + "FromString("
+ + Literals.toLiteral(defaultString) + ")";
+
+
+ if (gdt.isPrimitiveType())
+ {
+ result = "((" + gdt.getObjectInstanceClassName() + ")" + result
+ + ")." + gdt.getPrimitiveValueFunction() + "()";
+ } else if (!gdt.isObjectType()) {
+ result = "(" + gdt.getImportedInstanceClassName() + ")" + result;
+ }
+
+ defaultFound = true;
+ }
+ }
+ }
+
+ if (!defaultFound) {
+ // the input didn't match any special case that we want to handle differently
+ // from EMF's default approach, so go ahead and get EMF to do it
+ result = genFeature.getStaticDefaultValue();
+ }
+
+ return result;
+ }
+}
diff --git a/java/sdo/tools/src/main/resources/META-INF/NOTICE b/java/sdo/tools/src/main/resources/META-INF/NOTICE
index 6901a96038..9f9572a167 100644
--- a/java/sdo/tools/src/main/resources/META-INF/NOTICE
+++ b/java/sdo/tools/src/main/resources/META-INF/NOTICE
@@ -4,5 +4,4 @@ Copyright (c) 2005 - 2008 The Apache Software Foundation
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/java/sdo/tools/src/main/resources/META-INF/README.txt b/java/sdo/tools/src/main/resources/META-INF/README.txt
index 687f357105..1b8144f7c5 100644
--- a/java/sdo/tools/src/main/resources/META-INF/README.txt
+++ b/java/sdo/tools/src/main/resources/META-INF/README.txt
@@ -1,5 +1,5 @@
-Apache Tuscany 1.1-incubating build (February 2008)
-===============================================
+Apache Tuscany 1.1-incubating build (April 2008)
+================================================
http://incubator.apache.org/tuscany/
diff --git a/java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/GeneratedPackagesTestCase.java b/java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/GeneratedPackagesTestCase.java
index 47be663e49..290f27338a 100644
--- a/java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/GeneratedPackagesTestCase.java
+++ b/java/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/GeneratedPackagesTestCase.java
@@ -1,70 +1,70 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sdo.test;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.tuscany.sdo.generate.XSD2JavaGenerator;
-
-import junit.framework.TestCase;
-
-
-public class GeneratedPackagesTestCase extends TestCase
-{
- static String expectedNamespace = "http://www.example.com/sequences";
-
- public void testPackageValidity()
- {
- XSD2JavaGenerator codeGen = new XSD2JavaGenerator();
- String [] genArgs = { "-schemaNamespace", "all", "-noGenerate", "src/test/resources/sequences.xsd" };
- codeGen.generateFromXMLSchema( genArgs );
- List packages = codeGen.getGeneratedPackageInfo();
-
- for (Iterator iter = packages.iterator(); iter.hasNext();)
- {
- XSD2JavaGenerator.GeneratedPackage packageInfo = (XSD2JavaGenerator.GeneratedPackage)iter.next();
- assertTrue(expectedNamespace.equals(packageInfo.getNamespace()));
-
- String name;
- boolean validatedMixedQuote = false;
- boolean validatedRC = false;
- for (Iterator iterClass = packageInfo.getClasses().iterator(); iterClass.hasNext();)
- {
- XSD2JavaGenerator.GeneratedPackage.PackageClassInfo classInfo = (XSD2JavaGenerator.GeneratedPackage.PackageClassInfo)iterClass.next();
- name = classInfo.getName();
-
- if( "mixedStockQuote".equals(name))
- {
- assertTrue("com.example.sequences.MixedQuote".equals(classInfo.getClassName()));
- validatedMixedQuote = true;
- }
-
- if( "rc".equals(name))
- {
- assertTrue("com.example.sequences.RepeatingChoice".equals(classInfo.getClassName()));
- validatedRC = true;
- }
- }
- assertTrue(validatedMixedQuote);
- assertTrue(validatedRC);
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * 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.Iterator;
+import java.util.List;
+
+import org.apache.tuscany.sdo.generate.XSD2JavaGenerator;
+
+import junit.framework.TestCase;
+
+
+public class GeneratedPackagesTestCase extends TestCase
+{
+ static String expectedNamespace = "http://www.example.com/sequences";
+
+ public void testPackageValidity()
+ {
+ XSD2JavaGenerator codeGen = new XSD2JavaGenerator();
+ String [] genArgs = { "-schemaNamespace", "all", "-noGenerate", "src/test/resources/sequences.xsd" };
+ codeGen.generateFromXMLSchema( genArgs );
+ List packages = codeGen.getGeneratedPackageInfo();
+
+ for (Iterator iter = packages.iterator(); iter.hasNext();)
+ {
+ XSD2JavaGenerator.GeneratedPackage packageInfo = (XSD2JavaGenerator.GeneratedPackage)iter.next();
+ assertTrue(expectedNamespace.equals(packageInfo.getNamespace()));
+
+ String name;
+ boolean validatedMixedQuote = false;
+ boolean validatedRC = false;
+ for (Iterator iterClass = packageInfo.getClasses().iterator(); iterClass.hasNext();)
+ {
+ XSD2JavaGenerator.GeneratedPackage.PackageClassInfo classInfo = (XSD2JavaGenerator.GeneratedPackage.PackageClassInfo)iterClass.next();
+ name = classInfo.getName();
+
+ if( "mixedStockQuote".equals(name))
+ {
+ assertTrue("com.example.sequences.MixedQuote".equals(classInfo.getClassName()));
+ validatedMixedQuote = true;
+ }
+
+ if( "rc".equals(name))
+ {
+ assertTrue("com.example.sequences.RepeatingChoice".equals(classInfo.getClassName()));
+ validatedRC = true;
+ }
+ }
+ assertTrue(validatedMixedQuote);
+ assertTrue(validatedRC);
+ }
+ }
+}
diff --git a/java/sdo/tools/src/test/resources/sdoModel.xsd b/java/sdo/tools/src/test/resources/sdoModel.xsd
index 645b7b700a..6b596c5b36 100644
--- a/java/sdo/tools/src/test/resources/sdoModel.xsd
+++ b/java/sdo/tools/src/test/resources/sdoModel.xsd
@@ -1,28 +1,28 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- -->
-<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sdo="commonj.sdo" xmlns:sdoJava="commonj.sdo/java" targetNamespace="commonj.sdo">
-
- <!-- Dummy XSD definition of special SDO ChangeSummaryType -->
- <xsd:simpleType name="ChangeSummaryType" sdoJava:instanceClass="commonj.sdo.ChangeSummary">
- <xsd:restriction base="xsd:string"/>
- </xsd:simpleType>
-
-
-</xsd:schema>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ -->
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:sdo="commonj.sdo" xmlns:sdoJava="commonj.sdo/java" targetNamespace="commonj.sdo">
+
+ <!-- Dummy XSD definition of special SDO ChangeSummaryType -->
+ <xsd:simpleType name="ChangeSummaryType" sdoJava:instanceClass="commonj.sdo.ChangeSummary">
+ <xsd:restriction base="xsd:string"/>
+ </xsd:simpleType>
+
+
+</xsd:schema>