From 36436b71b9977d6b5940cb6285d5335708ef9bfa Mon Sep 17 00:00:00 2001 From: lresende Date: Sat, 21 Nov 2009 07:55:20 +0000 Subject: Moving 1.x tags git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@882851 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tuscany/sdo/generate/JavaGenerator.java | 535 ++++++++++++ .../tools/src/main/resources/META-INF/MANIFEST.MF | 13 + .../src/test/java/com/example/simple/Quote.java | 307 +++++++ .../java/com/example/simple/SimpleFactory.java | 46 ++ .../java/com/example/simple/impl/QuoteImpl.java | 712 ++++++++++++++++ .../com/example/simple/impl/SimpleFactoryImpl.java | 138 ++++ .../com/example/simple/impl/SimplePackageImpl.java | 908 +++++++++++++++++++++ .../apache/tuscany/sdo/test/SimpleStaticTest.java | 64 ++ .../sdo/tools/src/test/resources/enum.xsd | 32 + .../sdo/tools/src/test/resources/simple.xsd | 23 + 10 files changed, 2778 insertions(+) create mode 100644 sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/JavaGenerator.java create mode 100644 sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/main/resources/META-INF/MANIFEST.MF create mode 100644 sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/com/example/simple/Quote.java create mode 100644 sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/com/example/simple/SimpleFactory.java create mode 100644 sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/com/example/simple/impl/QuoteImpl.java create mode 100644 sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/com/example/simple/impl/SimpleFactoryImpl.java create mode 100644 sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/com/example/simple/impl/SimplePackageImpl.java create mode 100644 sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/SimpleStaticTest.java create mode 100644 sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/resources/enum.xsd create mode 100644 sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/resources/simple.xsd (limited to 'sca-java-1.x/tags/java-stable-20060304/sdo/tools/src') diff --git a/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/JavaGenerator.java b/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/JavaGenerator.java new file mode 100644 index 0000000000..517f150c09 --- /dev/null +++ b/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/main/java/org/apache/tuscany/sdo/generate/JavaGenerator.java @@ -0,0 +1,535 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.generate; + + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.StringTokenizer; + +import org.apache.tuscany.sdo.helper.XSDHelperImpl; +import org.apache.tuscany.sdo.util.DataObjectUtil; +import org.eclipse.emf.codegen.ecore.genmodel.GenClass; +import org.eclipse.emf.codegen.ecore.genmodel.GenDelegationKind; +import org.eclipse.emf.codegen.ecore.genmodel.GenModel; +import org.eclipse.emf.codegen.ecore.genmodel.GenModelFactory; +import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; +import org.eclipse.emf.codegen.ecore.genmodel.GenResourceKind; +import org.eclipse.emf.codegen.util.CodeGenUtil; +import org.eclipse.emf.common.util.BasicMonitor; +import org.eclipse.emf.common.util.Diagnostic; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.impl.EPackageRegistryImpl; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.util.BasicExtendedMetaData; +import org.eclipse.emf.ecore.util.Diagnostician; +import org.eclipse.emf.ecore.util.ExtendedMetaData; +import org.eclipse.xsd.XSDSchema; +import org.eclipse.xsd.util.XSDResourceImpl; + +import commonj.sdo.helper.XSDHelper; + + +public class JavaGenerator +{ + public static int OPTION_NO_INTERFACES=0x1; + public static int OPTION_SPARSE_PATTERN=0x2; + public static int OPTION_STORE_PATTERN=0x4; + public static int OPTION_NO_CONTAINMENT=0x8; + public static int OPTION_NO_NOTIFICATION=0x10; + public static int OPTION_ARRAY_ACCESSORS=0x20; + public static int OPTION_GENERATE_LOADER=0x40; + public static int OPTION_NO_UNSETTABLE=0x80; + //FIXME Temporary, I need this option for now to get Switch classes generated for the SCDL models + public static int OPTION_GENERATE_SWITCH=0x100; + + /** + * Generate static SDOs from XML Schema + * + * Usage arguments: + * + * [ -targetDirectory ] + * [ -javaPackage ] + * [ -prefix ] + * [ -sparsePattern | -storePattern ] + * [ -noInterfaces ] + * [ -noContainment ] + * [ -noNotification ] + * [ -arrayAccessors ] + * [ -generateLoader ] + * [ -noUnsettable ] + * | + * + * For example: + * + * generate somedir/somefile.xsd + * + * Basic options: + * + * -targetDirectory + * Generates the Java source code in the specified directory. By default, the code is generated + * in the same directory as the input xsd or wsdl file. + * -javaPackage + * Overrides the Java package for the generated classes. By default the package name is derived + * from the targetNamespace of the XML schema being generated. For example, if the targetNamespace is + * "http://www.example.com/simple", the default package will be "com.example.simple". + * -prefix + * Specifies the prefix string to use for naming the generated factory. For example "-prefix Foo" will + * result in a factory interface with the name "FooFactory". + * -sparsePattern + * For SDO metamodels that have classes with many properties of which only a few are typically set at + * runtime, this option can be used to produce a space-optimized implementation (at the expense of speed). + * -storePattern + * This option can be used to generate static classes that work with a Store-based DataObject + * implementation. It changes the generator pattern to generate accessors which delegate to the + * reflective methods (as opposed to the other way around) and changes the DataObject base class + * to org.apache.tuscany.sdo.impl.StoreDataObjectImpl. Note that this option generates classes that + * require a Store implementation to be provided before they can be run. + * + * The following options can be used to increase performance, but with some loss of SDO functionality: + * + * -noInterfaces + * By default, each DataObject generates both a Java interface and a corresponding implementation + * class. If an SDO metamodel does not use multiple inheritance (which is always the case for + * XML Schema derived models), then this option can be used to eliminate the interface and to generate + * only an implementation class. + * + * Following are planned but not supported yet: + * + * -noNotification + * This option eliminates all change notification overhead in the generated classes. Changes to + * DataObjects generated using this option cannot be recorded, and consequently the classes cannot + * be used with an SDO ChangeSummary or DataGraph. + * -noContainment + * Turns off container management for containment properties. DataObject.getContainer() will always + * return null for data objects generated with this option, even if a containment reference is set. + * Setting a containment reference will also not automatically remove the target object from its + * previous container, if it had one, so it will need to be explicitly removed by the client. Use + * of this option is only recommended for scenarios where this kind of container movement/management + * is not necessary. + * -arrayAccessors + * Generates Java array getters/setters for multiplicity-many properties. With this option, + * the set of "standard" JavaBean array accessor methods (e.g., Foo[] getFoo(), Foo getFoo(int), + * int getFooLength(), setFoo(Foo[]), and void setFoo(int, Foo)) are generated. The normal + * List-returning accessor is renamed with the suffix "List" (e.g., List getFooList()). The array + * returned by the generated method is not a copy, but instead a pointer to the underlying storage + * array, so directly modifying it can have undesirable consequences and should be avoided. + * -generateLoader + * Generate a fast XML parser/loader for instances of the model. The details of this option are + * subject to change, but currently it generates two additional classes in a "util" package: + * ResourceImpl and ResourceFactoryImpl. To use the generated loader at runtime, + * you need to pass an option to the XMLHelper.load() method like this: + * Map options = new HashMap(); + * options.put("GENERATED_LOADER", ResourceFactoryImpl.class); + * XMLDocument doc = XMLHelper.INSTANCE.load(new FileInputStream("somefile.xml"), null, options); + * Note: this option currently only works for simple schemas without substitution groups or wildcards. + * -noUnsettable + * By default, some XML constructs result in SDO property implementations that maintain additional + * state information to record when the property has been set to the "default value", as opposed to + * being truly unset (see DataObject.isSet() and DataObject.unset()). The SDO specification allows an + * implementation to choose to provide this behavior or not. With this option, all generated properties + * will not record their unset state. The generated isSet() methods simply returns whether the current + * value is equal to the property's "default value". + */ + public static void main(String args[]) + { + if (args.length == 0) + { + printUsage(); + return; + } + + String targetDirectory = null; + String javaPackage = null; + String prefix = null; + + int genOptions = 0; + + int index = 0; + for (; index < args.length && args[index].startsWith("-"); ++index) + { + if (args[index].equalsIgnoreCase("-targetDirectory")) + { + targetDirectory = args[++index]; + } + else if (args[index].equalsIgnoreCase("-javaPackage")) + { + javaPackage = args[++index]; + } + else if (args[index].equalsIgnoreCase("-prefix")) + { + prefix = args[++index]; + } + else if (args[index].equalsIgnoreCase("-noInterfaces")) + { + genOptions |= OPTION_NO_INTERFACES; + } + else if (args[index].equalsIgnoreCase("-sparsePattern")) + { + genOptions |= OPTION_SPARSE_PATTERN; + } + else if (args[index].equalsIgnoreCase("-storePattern")) + { + genOptions |= OPTION_STORE_PATTERN; + } + else if (args[index].equalsIgnoreCase("-noContainment")) + { + genOptions |= OPTION_NO_CONTAINMENT; + } + else if (args[index].equalsIgnoreCase("-noNotification")) + { + genOptions |= OPTION_NO_NOTIFICATION; + } + else if (args[index].equalsIgnoreCase("-arrayAccessors")) + { + genOptions |= OPTION_ARRAY_ACCESSORS; + } + else if (args[index].equalsIgnoreCase("-generateLoader")) + { + genOptions |= OPTION_GENERATE_LOADER; + } + else if (args[index].equalsIgnoreCase("-noUnsettable")) + { + genOptions |= OPTION_NO_UNSETTABLE; + } + //else if (...) + else + { + printUsage(); + return; + } + } + + String xsdFileName = args[index]; + + generateFromXMLSchema(xsdFileName, targetDirectory, javaPackage, prefix, genOptions); + } + + public static void generateFromXMLSchema(String xsdFileName, String targetDirectory, String javaPackage, String prefix, int genOptions) + { + DataObjectUtil.initRuntime(); + EPackage.Registry packageRegistry = new EPackageRegistryImpl(EPackage.Registry.INSTANCE) + { + public EPackage firstPackage = null; + + }; + ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(packageRegistry); + XSDHelper xsdHelper = new XSDHelperImpl(extendedMetaData); + + try + { + File inputFile = new File(xsdFileName).getAbsoluteFile(); + InputStream inputStream = new FileInputStream(inputFile); + xsdHelper.define(inputStream, inputFile.toURI().toString()); + + if (targetDirectory == null) + { + targetDirectory = new File(xsdFileName).getCanonicalFile().getParent(); + } + else + { + targetDirectory = new File(targetDirectory).getCanonicalPath(); + } + + if (!packageRegistry.values().isEmpty()) + { + String packageURI = getSchemaNamespace(xsdFileName); + ResourceSet resourceSet = DataObjectUtil.createResourceSet(); + + List usedGenPackages = new ArrayList(); + GenModel genModel = null; + + for (Iterator iter = packageRegistry.values().iterator(); iter.hasNext();) + { + EPackage currentEPackage = (EPackage)iter.next(); + String currentBasePackage = extractBasePackageName(currentEPackage, javaPackage); + String currentPrefix = prefix == null ? CodeGenUtil.capName(currentEPackage.getName()) : prefix; + + GenPackage currentGenPackage = createGenPackage(currentEPackage, currentBasePackage, currentPrefix, genOptions, resourceSet); + if (currentEPackage.getNsURI().equals(packageURI)) + { + genModel = currentGenPackage.getGenModel(); + } + else + { + usedGenPackages.add(currentGenPackage); + } + } + + genModel.getUsedGenPackages().addAll(usedGenPackages); + generateFromGenModel(genModel, targetDirectory); + } + + /* + for (Iterator iter = packageRegistry.values().iterator(); iter.hasNext();) + { + EPackage ePackage = (EPackage)iter.next(); + String basePackage = extractBasePackageName(ePackage, javaPackage); + if (prefix == null) + { + prefix = CodeGenUtil.capName(ePackage.getName()); + } + generateFromEPackage(ePackage, targetDirectory, basePackage, prefix, genOptions); + } + */ + } + catch (IOException e) + { + e.printStackTrace(); + } + } + + public static String getSchemaNamespace(String xsdFileName) + { + File inputFile = new File(xsdFileName).getAbsoluteFile(); + ResourceSet resourceSet = DataObjectUtil.createResourceSet(); + Resource model = resourceSet.createResource(URI.createURI(inputFile.toURI().toString())); + try { + InputStream inputStream = new FileInputStream(inputFile); + ((XSDResourceImpl)model).load(inputStream, null); + } + catch (Exception e) {} + XSDSchema schema = (XSDSchema)model.getContents().get(0); + return schema.getTargetNamespace(); + + } + + public static GenPackage createGenPackage(EPackage ePackage, String basePackage, String prefix, int genOptions, ResourceSet resourceSet) + { + GenModel genModel = ecore2GenModel(ePackage, basePackage, prefix, genOptions); + + URI ecoreURI = URI.createURI("file:///" + ePackage.getName() + ".ecore"); + URI genModelURI = ecoreURI.trimFileExtension().appendFileExtension("genmodel"); + + Resource ecoreResource = resourceSet.createResource(ecoreURI); + ecoreResource.getContents().add(ePackage); + + Resource genModelResource = resourceSet.createResource(genModelURI); + genModelResource.getContents().add(genModel); + + return (GenPackage)genModel.getGenPackages().get(0); + } + + public static void generateFromEPackage(EPackage ePackage, String targetDirectory, String basePackage, String prefix, int genOptions) + { + GenModel genModel = ecore2GenModel(ePackage, basePackage, prefix, genOptions); + + ResourceSet resourceSet = DataObjectUtil.createResourceSet(); + URI ecoreURI = URI.createURI("file:///temp.ecore"); + URI genModelURI = ecoreURI.trimFileExtension().appendFileExtension("genmodel"); + + Resource ecoreResource = resourceSet.createResource(ecoreURI); + ecoreResource.getContents().add(ePackage); + + Resource genModelResource = resourceSet.createResource(genModelURI); + genModelResource.getContents().add(genModel); + + generateFromGenModel(genModel, targetDirectory); + } + + public static void generateFromGenModel(GenModel genModel, String targetDirectory) + { + Resource resource = genModel.eResource(); + + if (targetDirectory != null) + { + resource.getResourceSet().getURIConverter().getURIMap().put( + URI.createURI("platform:/resource/TargetProject/"), + URI.createFileURI(targetDirectory + "/")); + genModel.setModelDirectory("/TargetProject"); + } + + genModel.gen(new BasicMonitor.Printing(System.out)); + + for (Iterator j = resource.getContents().iterator(); j.hasNext();) + { + EObject eObject = (EObject)j.next(); + Diagnostic diagnostic = Diagnostician.INSTANCE.validate(eObject); + if (diagnostic.getSeverity() != Diagnostic.OK) + { + printDiagnostic(diagnostic, ""); + } + } + } + + public static GenModel ecore2GenModel(EPackage ePackage, String basePackage, String prefix, int genOptions) + { + GenModel genModel = GenModelFactory.eINSTANCE.createGenModel(); + genModel.initialize(Collections.singleton(ePackage)); + + genModel.setRootExtendsInterface(""); + genModel.setRootImplementsInterface("commonj.sdo.DataObject"); + genModel.setRootExtendsClass("org.apache.tuscany.sdo.impl.DataObjectImpl"); + genModel.setFeatureMapWrapperInterface("commonj.sdo.Sequence"); + genModel.setFeatureMapWrapperInternalInterface("org.apache.tuscany.sdo.util.BasicSequence"); + genModel.setFeatureMapWrapperClass("org.apache.tuscany.sdo.util.BasicSequence"); + genModel.setSuppressEMFTypes(true); + genModel.setSuppressEMFMetaData(true); + genModel.setSuppressEMFModelTags(true); + genModel.setCanGenerate(true); + //FIXME workaround java.lang.NoClassDefFoundError: org/eclipse/jdt/core/jdom/IDOMNode with 02162006 build + genModel.setFacadeHelperClass("Hack"); + genModel.setForceOverwrite(true); + + if ((genOptions & OPTION_NO_INTERFACES) != 0) + { + genModel.setSuppressInterfaces(true); + } + + if ((genOptions & OPTION_SPARSE_PATTERN) != 0) + { + genModel.setFeatureDelegation(GenDelegationKind.VIRTUAL_LITERAL); + } + else if ((genOptions & OPTION_STORE_PATTERN) != 0) + { + genModel.setFeatureDelegation(GenDelegationKind.REFLECTIVE_LITERAL); + genModel.setRootExtendsClass("org.apache.tuscany.sdo.impl.StoreDataObjectImpl"); + } + + if ((genOptions & OPTION_NO_CONTAINMENT) != 0) + { + genModel.setSuppressContainment(true); + } + + if ((genOptions & OPTION_NO_NOTIFICATION) != 0) + { + genModel.setSuppressNotification(true); + } + + if ((genOptions & OPTION_ARRAY_ACCESSORS) != 0) + { + genModel.setArrayAccessors(true); + } + + if ((genOptions & OPTION_NO_UNSETTABLE) != 0) + { + genModel.setSuppressUnsettable(true); + } + + GenPackage genPackage = (GenPackage)genModel.getGenPackages().get(0); + + if (basePackage != null) + { + genPackage.setBasePackage(basePackage); + } + if (prefix != null) + { + genPackage.setPrefix(prefix); + } + + //FIXME Temporary, I need this option for now to get Switch classes generated for the SCDL models + if ((genOptions & OPTION_GENERATE_SWITCH) == 0) + { + genPackage.setAdapterFactory(false); + } + + if ((genOptions & OPTION_GENERATE_LOADER) != 0) + { + //FIXME workaround compile error with 02162006 build, generated code references non-existent EcoreResourceImpl class + genPackage.setResource(GenResourceKind.XML_LITERAL); + //genPackage.setDataTypeConverters(true); + } + else + { + genPackage.setResource(GenResourceKind.NONE_LITERAL); + for (Iterator iter = genPackage.getGenClasses().iterator(); iter.hasNext();) + { + GenClass genClass = (GenClass)iter.next(); + if ("DocumentRoot".equals(genClass.getName())) + { + genClass.setDynamic(true); // Don't generate DocumentRoot class + break; + } + } + } + + return genModel; + } + + public static String extractBasePackageName(EPackage ePackage, String javaPackage) + { + String qualifiedName = javaPackage != null ? javaPackage : ePackage.getName(); + String name = /*CodeGenUtil.*/shortName(qualifiedName); + String baseName = qualifiedName.substring(0, qualifiedName.length() - name.length()); + if (javaPackage != null || !name.equals(qualifiedName)) + { + ePackage.setName(name); + } + return baseName != null ? /*CodeGenUtil.*/safeQualifiedName(baseName) : null; + } + + public static String shortName(String qualifiedName) + { + int index = qualifiedName.lastIndexOf("."); + return index != -1 ? qualifiedName.substring(index + 1) : qualifiedName; + } + + public static String safeQualifiedName(String qualifiedName) + { + StringBuffer safeQualifiedName = new StringBuffer(); + for (StringTokenizer stringTokenizer = new StringTokenizer(qualifiedName, "."); stringTokenizer.hasMoreTokens();) + { + String name = stringTokenizer.nextToken(); + safeQualifiedName.append(CodeGenUtil.safeName(name)); + if (stringTokenizer.hasMoreTokens()) + { + safeQualifiedName.append('.'); + } + } + return safeQualifiedName.toString(); + } + + protected static void printDiagnostic(Diagnostic diagnostic, String indent) + { + System.out.print(indent); + System.out.println(diagnostic.getMessage()); + for (Iterator i = diagnostic.getChildren().iterator(); i.hasNext();) + { + printDiagnostic((Diagnostic)i.next(), indent + " "); + } + } + + protected static void printUsage() + { + System.out.println("Usage arguments:"); + System.out.println(" [ -targetDirectory ]"); + System.out.println(" [ -javaPackage ]"); + System.out.println(" [ -prefix ]"); + System.out.println(" [ -sparsePattern | -storePattern ]"); + System.out.println(" [ -noInterfaces ]"); + System.out.println(" [ -noContainment ]"); + System.out.println(" [ -noNotification ]"); + System.out.println(" [ -arrayAccessors ]"); + System.out.println(" [ -generateLoader ]"); + System.out.println(" [ -noUnsettable ]"); + System.out.println(" | "); + System.out.println(""); + System.out.println("For example:"); + System.out.println(""); + System.out.println(" generate somedir/somefile.xsd"); + } + +} diff --git a/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/main/resources/META-INF/MANIFEST.MF b/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..59c4a00c07 --- /dev/null +++ b/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/main/resources/META-INF/MANIFEST.MF @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: SDO Tools +Bundle-SymbolicName: org.apache.tuscany.sdo.tools +Bundle-Version: 1.0.0 +Bundle-Localization: plugin +Bundle-Vendor: Apache +Require-Bundle: org.apache.tuscany.sdo.impl, + org.eclipse.emf.codegen.ecore, + org.eclipse.emf.common, + org.eclipse.emf.ecore, + org.eclipse.emf.ecore.xmi, + org.eclipse.xsd diff --git a/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/com/example/simple/Quote.java b/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/com/example/simple/Quote.java new file mode 100644 index 0000000000..57b12ef331 --- /dev/null +++ b/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/com/example/simple/Quote.java @@ -0,0 +1,307 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.example.simple; + +import java.math.BigDecimal; + +import java.util.List; + +/** + * + * A representation of the model object 'Quote'. + * + * + *

+ * The following features are supported: + *

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

+ * + * @return the value of the 'Quotes' containment reference list. + * @generated + */ + List getQuotes(); + +} // Quote diff --git a/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/com/example/simple/SimpleFactory.java b/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/com/example/simple/SimpleFactory.java new file mode 100644 index 0000000000..9203976521 --- /dev/null +++ b/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/com/example/simple/SimpleFactory.java @@ -0,0 +1,46 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.example.simple; + + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @generated + */ +public interface SimpleFactory +{ + /** + * The singleton instance of the factory. + * + * + * @generated + */ + SimpleFactory INSTANCE = com.example.simple.impl.SimpleFactoryImpl.eINSTANCE; + + /** + * Returns a new object of class 'Quote'. + * + * + * @return a new object of class 'Quote'. + * @generated + */ + Quote createQuote(); + +} //SimpleFactory diff --git a/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/com/example/simple/impl/QuoteImpl.java b/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/com/example/simple/impl/QuoteImpl.java new file mode 100644 index 0000000000..5b407dd311 --- /dev/null +++ b/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/com/example/simple/impl/QuoteImpl.java @@ -0,0 +1,712 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.example.simple.impl; + +import com.example.simple.Quote; + +import java.math.BigDecimal; + +import java.util.Collection; +import java.util.List; + +import org.apache.tuscany.sdo.impl.DataObjectImpl; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; + +import org.eclipse.emf.ecore.util.EObjectContainmentEList; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * + * An implementation of the model object 'Quote'. + * + *

+ * The following features are implemented: + *

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

+ * + * @generated + */ +public class QuoteImpl extends DataObjectImpl implements Quote +{ + /** + * The default value of the '{@link #getSymbol() Symbol}' attribute. + * + * + * @see #getSymbol() + * @generated + * @ordered + */ + protected static final String SYMBOL_EDEFAULT = null; + + /** + * The cached value of the '{@link #getSymbol() Symbol}' attribute. + * + * + * @see #getSymbol() + * @generated + * @ordered + */ + protected String symbol = SYMBOL_EDEFAULT; + + /** + * The default value of the '{@link #getCompanyName() Company Name}' attribute. + * + * + * @see #getCompanyName() + * @generated + * @ordered + */ + protected static final String COMPANY_NAME_EDEFAULT = null; + + /** + * The cached value of the '{@link #getCompanyName() Company Name}' attribute. + * + * + * @see #getCompanyName() + * @generated + * @ordered + */ + protected String companyName = COMPANY_NAME_EDEFAULT; + + /** + * The default value of the '{@link #getPrice() Price}' attribute. + * + * + * @see #getPrice() + * @generated + * @ordered + */ + protected static final BigDecimal PRICE_EDEFAULT = null; + + /** + * The cached value of the '{@link #getPrice() Price}' attribute. + * + * + * @see #getPrice() + * @generated + * @ordered + */ + protected BigDecimal price = PRICE_EDEFAULT; + + /** + * The default value of the '{@link #getOpen1() Open1}' attribute. + * + * + * @see #getOpen1() + * @generated + * @ordered + */ + protected static final BigDecimal OPEN1_EDEFAULT = null; + + /** + * The cached value of the '{@link #getOpen1() Open1}' attribute. + * + * + * @see #getOpen1() + * @generated + * @ordered + */ + protected BigDecimal open1 = OPEN1_EDEFAULT; + + /** + * The default value of the '{@link #getHigh() High}' attribute. + * + * + * @see #getHigh() + * @generated + * @ordered + */ + protected static final BigDecimal HIGH_EDEFAULT = null; + + /** + * The cached value of the '{@link #getHigh() High}' attribute. + * + * + * @see #getHigh() + * @generated + * @ordered + */ + protected BigDecimal high = HIGH_EDEFAULT; + + /** + * The default value of the '{@link #getLow() Low}' attribute. + * + * + * @see #getLow() + * @generated + * @ordered + */ + protected static final BigDecimal LOW_EDEFAULT = null; + + /** + * The cached value of the '{@link #getLow() Low}' attribute. + * + * + * @see #getLow() + * @generated + * @ordered + */ + protected BigDecimal low = LOW_EDEFAULT; + + /** + * The default value of the '{@link #getVolume() Volume}' attribute. + * + * + * @see #getVolume() + * @generated + * @ordered + */ + protected static final double VOLUME_EDEFAULT = 0.0; + + /** + * The cached value of the '{@link #getVolume() Volume}' attribute. + * + * + * @see #getVolume() + * @generated + * @ordered + */ + protected double volume = VOLUME_EDEFAULT; + + /** + * This is true if the Volume attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean volumeESet = false; + + /** + * The default value of the '{@link #getChange1() Change1}' attribute. + * + * + * @see #getChange1() + * @generated + * @ordered + */ + protected static final double CHANGE1_EDEFAULT = 0.0; + + /** + * The cached value of the '{@link #getChange1() Change1}' attribute. + * + * + * @see #getChange1() + * @generated + * @ordered + */ + protected double change1 = CHANGE1_EDEFAULT; + + /** + * This is true if the Change1 attribute has been set. + * + * + * @generated + * @ordered + */ + protected boolean change1ESet = false; + + /** + * The cached value of the '{@link #getQuotes() Quotes}' containment reference list. + * + * + * @see #getQuotes() + * @generated + * @ordered + */ + protected EList quotes = null; + + /** + * + * + * @generated + */ + protected QuoteImpl() + { + super(); + } + + /** + * + * + * @generated + */ + protected EClass eStaticClass() + { + return SimplePackageImpl.Literals.QUOTE; + } + + /** + * + * + * @generated + */ + public String getSymbol() + { + return symbol; + } + + /** + * + * + * @generated + */ + public void setSymbol(String newSymbol) + { + String oldSymbol = symbol; + symbol = newSymbol; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SimplePackageImpl.QUOTE__SYMBOL, oldSymbol, symbol)); + } + + /** + * + * + * @generated + */ + public String getCompanyName() + { + return companyName; + } + + /** + * + * + * @generated + */ + public void setCompanyName(String newCompanyName) + { + String oldCompanyName = companyName; + companyName = newCompanyName; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SimplePackageImpl.QUOTE__COMPANY_NAME, oldCompanyName, companyName)); + } + + /** + * + * + * @generated + */ + public BigDecimal getPrice() + { + return price; + } + + /** + * + * + * @generated + */ + public void setPrice(BigDecimal newPrice) + { + BigDecimal oldPrice = price; + price = newPrice; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SimplePackageImpl.QUOTE__PRICE, oldPrice, price)); + } + + /** + * + * + * @generated + */ + public BigDecimal getOpen1() + { + return open1; + } + + /** + * + * + * @generated + */ + public void setOpen1(BigDecimal newOpen1) + { + BigDecimal oldOpen1 = open1; + open1 = newOpen1; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SimplePackageImpl.QUOTE__OPEN1, oldOpen1, open1)); + } + + /** + * + * + * @generated + */ + public BigDecimal getHigh() + { + return high; + } + + /** + * + * + * @generated + */ + public void setHigh(BigDecimal newHigh) + { + BigDecimal oldHigh = high; + high = newHigh; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SimplePackageImpl.QUOTE__HIGH, oldHigh, high)); + } + + /** + * + * + * @generated + */ + public BigDecimal getLow() + { + return low; + } + + /** + * + * + * @generated + */ + public void setLow(BigDecimal newLow) + { + BigDecimal oldLow = low; + low = newLow; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SimplePackageImpl.QUOTE__LOW, oldLow, low)); + } + + /** + * + * + * @generated + */ + public double getVolume() + { + return volume; + } + + /** + * + * + * @generated + */ + public void setVolume(double newVolume) + { + double oldVolume = volume; + volume = newVolume; + boolean oldVolumeESet = volumeESet; + volumeESet = true; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SimplePackageImpl.QUOTE__VOLUME, oldVolume, volume, !oldVolumeESet)); + } + + /** + * + * + * @generated + */ + public void unsetVolume() + { + double oldVolume = volume; + boolean oldVolumeESet = volumeESet; + volume = VOLUME_EDEFAULT; + volumeESet = false; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.UNSET, SimplePackageImpl.QUOTE__VOLUME, oldVolume, VOLUME_EDEFAULT, oldVolumeESet)); + } + + /** + * + * + * @generated + */ + public boolean isSetVolume() + { + return volumeESet; + } + + /** + * + * + * @generated + */ + public double getChange1() + { + return change1; + } + + /** + * + * + * @generated + */ + public void setChange1(double newChange1) + { + double oldChange1 = change1; + change1 = newChange1; + boolean oldChange1ESet = change1ESet; + change1ESet = true; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, SimplePackageImpl.QUOTE__CHANGE1, oldChange1, change1, !oldChange1ESet)); + } + + /** + * + * + * @generated + */ + public void unsetChange1() + { + double oldChange1 = change1; + boolean oldChange1ESet = change1ESet; + change1 = CHANGE1_EDEFAULT; + change1ESet = false; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.UNSET, SimplePackageImpl.QUOTE__CHANGE1, oldChange1, CHANGE1_EDEFAULT, oldChange1ESet)); + } + + /** + * + * + * @generated + */ + public boolean isSetChange1() + { + return change1ESet; + } + + /** + * + * + * @generated + */ + public List getQuotes() + { + if (quotes == null) + { + quotes = new EObjectContainmentEList(Quote.class, this, SimplePackageImpl.QUOTE__QUOTES); + } + return quotes; + } + + /** + * + * + * @generated + */ + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) + { + switch (featureID) + { + case SimplePackageImpl.QUOTE__QUOTES: + return ((InternalEList)getQuotes()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + public Object eGet(int featureID, boolean resolve, boolean coreType) + { + switch (featureID) + { + case SimplePackageImpl.QUOTE__SYMBOL: + return getSymbol(); + case SimplePackageImpl.QUOTE__COMPANY_NAME: + return getCompanyName(); + case SimplePackageImpl.QUOTE__PRICE: + return getPrice(); + case SimplePackageImpl.QUOTE__OPEN1: + return getOpen1(); + case SimplePackageImpl.QUOTE__HIGH: + return getHigh(); + case SimplePackageImpl.QUOTE__LOW: + return getLow(); + case SimplePackageImpl.QUOTE__VOLUME: + return new Double(getVolume()); + case SimplePackageImpl.QUOTE__CHANGE1: + return new Double(getChange1()); + case SimplePackageImpl.QUOTE__QUOTES: + return getQuotes(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + public void eSet(int featureID, Object newValue) + { + switch (featureID) + { + case SimplePackageImpl.QUOTE__SYMBOL: + setSymbol((String)newValue); + return; + case SimplePackageImpl.QUOTE__COMPANY_NAME: + setCompanyName((String)newValue); + return; + case SimplePackageImpl.QUOTE__PRICE: + setPrice((BigDecimal)newValue); + return; + case SimplePackageImpl.QUOTE__OPEN1: + setOpen1((BigDecimal)newValue); + return; + case SimplePackageImpl.QUOTE__HIGH: + setHigh((BigDecimal)newValue); + return; + case SimplePackageImpl.QUOTE__LOW: + setLow((BigDecimal)newValue); + return; + case SimplePackageImpl.QUOTE__VOLUME: + setVolume(((Double)newValue).doubleValue()); + return; + case SimplePackageImpl.QUOTE__CHANGE1: + setChange1(((Double)newValue).doubleValue()); + return; + case SimplePackageImpl.QUOTE__QUOTES: + getQuotes().clear(); + getQuotes().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + public void eUnset(int featureID) + { + switch (featureID) + { + case SimplePackageImpl.QUOTE__SYMBOL: + setSymbol(SYMBOL_EDEFAULT); + return; + case SimplePackageImpl.QUOTE__COMPANY_NAME: + setCompanyName(COMPANY_NAME_EDEFAULT); + return; + case SimplePackageImpl.QUOTE__PRICE: + setPrice(PRICE_EDEFAULT); + return; + case SimplePackageImpl.QUOTE__OPEN1: + setOpen1(OPEN1_EDEFAULT); + return; + case SimplePackageImpl.QUOTE__HIGH: + setHigh(HIGH_EDEFAULT); + return; + case SimplePackageImpl.QUOTE__LOW: + setLow(LOW_EDEFAULT); + return; + case SimplePackageImpl.QUOTE__VOLUME: + unsetVolume(); + return; + case SimplePackageImpl.QUOTE__CHANGE1: + unsetChange1(); + return; + case SimplePackageImpl.QUOTE__QUOTES: + getQuotes().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + public boolean eIsSet(int featureID) + { + switch (featureID) + { + case SimplePackageImpl.QUOTE__SYMBOL: + return SYMBOL_EDEFAULT == null ? symbol != null : !SYMBOL_EDEFAULT.equals(symbol); + case SimplePackageImpl.QUOTE__COMPANY_NAME: + return COMPANY_NAME_EDEFAULT == null ? companyName != null : !COMPANY_NAME_EDEFAULT.equals(companyName); + case SimplePackageImpl.QUOTE__PRICE: + return PRICE_EDEFAULT == null ? price != null : !PRICE_EDEFAULT.equals(price); + case SimplePackageImpl.QUOTE__OPEN1: + return OPEN1_EDEFAULT == null ? open1 != null : !OPEN1_EDEFAULT.equals(open1); + case SimplePackageImpl.QUOTE__HIGH: + return HIGH_EDEFAULT == null ? high != null : !HIGH_EDEFAULT.equals(high); + case SimplePackageImpl.QUOTE__LOW: + return LOW_EDEFAULT == null ? low != null : !LOW_EDEFAULT.equals(low); + case SimplePackageImpl.QUOTE__VOLUME: + return isSetVolume(); + case SimplePackageImpl.QUOTE__CHANGE1: + return isSetChange1(); + case SimplePackageImpl.QUOTE__QUOTES: + return quotes != null && !quotes.isEmpty(); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + public String toString() + { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (symbol: "); + result.append(symbol); + result.append(", companyName: "); + result.append(companyName); + result.append(", price: "); + result.append(price); + result.append(", open1: "); + result.append(open1); + result.append(", high: "); + result.append(high); + result.append(", low: "); + result.append(low); + result.append(", volume: "); + if (volumeESet) result.append(volume); else result.append(""); + result.append(", change1: "); + if (change1ESet) result.append(change1); else result.append(""); + result.append(')'); + return result.toString(); + } + +} //QuoteImpl diff --git a/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/com/example/simple/impl/SimpleFactoryImpl.java b/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/com/example/simple/impl/SimpleFactoryImpl.java new file mode 100644 index 0000000000..06b0e3891e --- /dev/null +++ b/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/com/example/simple/impl/SimpleFactoryImpl.java @@ -0,0 +1,138 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.example.simple.impl; + +import com.example.simple.*; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +/** + * + * An implementation of the model Factory. + * + * @generated + */ +public class SimpleFactoryImpl extends EFactoryImpl implements SimpleFactory +{ + /** + * The singleton instance of the factory. + * + * + * @generated + */ + public static final SimpleFactoryImpl eINSTANCE = init(); + + /** + * Creates the default factory implementation. + * + * + * @generated + */ + public static SimpleFactoryImpl init() + { + try + { + SimpleFactoryImpl theSimpleFactory = (SimpleFactoryImpl)EPackage.Registry.INSTANCE.getEFactory("http://www.example.com/simple"); + if (theSimpleFactory != null) + { + return theSimpleFactory; + } + } + catch (Exception exception) + { + EcorePlugin.INSTANCE.log(exception); + } + return new SimpleFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public SimpleFactoryImpl() + { + super(); + } + + /** + * + * + * @generated + */ + public EObject create(EClass eClass) + { + switch (eClass.getClassifierID()) + { + case SimplePackageImpl.DOCUMENT_ROOT: return (EObject)createDocumentRoot(); + case SimplePackageImpl.QUOTE: return (EObject)createQuote(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + public EObject createDocumentRoot() + { + EObject documentRoot = super.create(SimplePackageImpl.Literals.DOCUMENT_ROOT); + return documentRoot; + } + + /** + * + * + * @generated + */ + public Quote createQuote() + { + QuoteImpl quote = new QuoteImpl(); + return quote; + } + + /** + * + * + * @generated + */ + public SimplePackageImpl getSimplePackageImpl() + { + return (SimplePackageImpl)getEPackage(); + } + + /** + * + * + * @deprecated + * @generated + */ + public static SimplePackageImpl getPackage() + { + return SimplePackageImpl.eINSTANCE; + } + +} //SimpleFactoryImpl diff --git a/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/com/example/simple/impl/SimplePackageImpl.java b/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/com/example/simple/impl/SimplePackageImpl.java new file mode 100644 index 0000000000..e8fe40c24d --- /dev/null +++ b/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/com/example/simple/impl/SimplePackageImpl.java @@ -0,0 +1,908 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.example.simple.impl; + +import com.example.simple.Quote; +import com.example.simple.SimpleFactory; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EFactory; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +import org.eclipse.emf.ecore.xml.type.XMLTypePackage; + +/** + * + * The Package for the model. + * It contains accessors for the meta objects to represent + *
    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @see com.example.simple.SimpleFactory + * @generated + */ +public class SimplePackageImpl extends EPackageImpl +{ + /** + * The package name. + * + * + * @generated + */ + public static final String eNAME = "simple"; + + /** + * The package namespace URI. + * + * + * @generated + */ + public static final String eNS_URI = "http://www.example.com/simple"; + + /** + * The package namespace name. + * + * + * @generated + */ + public static final String eNS_PREFIX = "simple"; + + /** + * The singleton instance of the package. + * + * + * @generated + */ + public static final SimplePackageImpl eINSTANCE = com.example.simple.impl.SimplePackageImpl.init(); + + /** + * The meta object id for the '{@link com.example.simple.impl.DocumentRootImpl Document Root}' class. + * + * + * @see com.example.simple.impl.DocumentRootImpl + * @see com.example.simple.impl.SimplePackageImpl#getDocumentRoot() + * @generated + */ + public static final int DOCUMENT_ROOT = 0; + + /** + * The feature id for the 'Mixed' attribute list. + * + * + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__MIXED = 0; + + /** + * The feature id for the 'XMLNS Prefix Map' map. + * + * + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__XMLNS_PREFIX_MAP = 1; + + /** + * The feature id for the 'XSI Schema Location' map. + * + * + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__XSI_SCHEMA_LOCATION = 2; + + /** + * The feature id for the 'Stock Quote' containment reference. + * + * + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT__STOCK_QUOTE = 3; + + /** + * The number of structural features of the 'Document Root' class. + * + * + * @generated + * @ordered + */ + public static final int DOCUMENT_ROOT_FEATURE_COUNT = 4; + + /** + * The meta object id for the '{@link com.example.simple.impl.QuoteImpl Quote}' class. + * + * + * @see com.example.simple.impl.QuoteImpl + * @see com.example.simple.impl.SimplePackageImpl#getQuote() + * @generated + */ + public static final int QUOTE = 1; + + /** + * The feature id for the 'Symbol' attribute. + * + * + * @generated + * @ordered + */ + public static final int QUOTE__SYMBOL = 0; + + /** + * The feature id for the 'Company Name' attribute. + * + * + * @generated + * @ordered + */ + public static final int QUOTE__COMPANY_NAME = 1; + + /** + * The feature id for the 'Price' attribute. + * + * + * @generated + * @ordered + */ + public static final int QUOTE__PRICE = 2; + + /** + * The feature id for the 'Open1' attribute. + * + * + * @generated + * @ordered + */ + public static final int QUOTE__OPEN1 = 3; + + /** + * The feature id for the 'High' attribute. + * + * + * @generated + * @ordered + */ + public static final int QUOTE__HIGH = 4; + + /** + * The feature id for the 'Low' attribute. + * + * + * @generated + * @ordered + */ + public static final int QUOTE__LOW = 5; + + /** + * The feature id for the 'Volume' attribute. + * + * + * @generated + * @ordered + */ + public static final int QUOTE__VOLUME = 6; + + /** + * The feature id for the 'Change1' attribute. + * + * + * @generated + * @ordered + */ + public static final int QUOTE__CHANGE1 = 7; + + /** + * The feature id for the 'Quotes' containment reference list. + * + * + * @generated + * @ordered + */ + public static final int QUOTE__QUOTES = 8; + + /** + * The number of structural features of the 'Quote' class. + * + * + * @generated + * @ordered + */ + public static final int QUOTE_FEATURE_COUNT = 9; + + /** + * + * + * @generated + */ + private EClass documentRootEClass = null; + + /** + * + * + * @generated + */ + private EClass quoteEClass = null; + + /** + * Creates an instance of the model Package, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + *

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

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

Invocation of this method will not affect any packages that have + * already been initialized. + * + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static SimplePackageImpl init() + { + if (isInited) return (SimplePackageImpl)EPackage.Registry.INSTANCE.getEPackage(SimplePackageImpl.eNS_URI); + + // Obtain or create and register package + SimplePackageImpl theSimplePackageImpl = (SimplePackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof SimplePackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new SimplePackageImpl()); + + isInited = true; + + // Initialize simple dependencies + XMLTypePackage.eINSTANCE.eClass(); + + // Create package meta-data objects + theSimplePackageImpl.createPackageContents(); + + // Initialize created meta-data + theSimplePackageImpl.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + theSimplePackageImpl.freeze(); + + return theSimplePackageImpl; + } + + + /** + * Returns the meta object for class '{@link org.eclipse.emf.ecore.EObject Document Root}'. + * + * + * @return the meta object for class 'Document Root'. + * @see org.eclipse.emf.ecore.EObject + * @generated + */ + public EClass getDocumentRoot() + { + return documentRootEClass; + } + + /** + * Returns the meta object for the attribute list '{@link org.eclipse.emf.ecore.EObject#getMixed Mixed}'. + * + * + * @return the meta object for the attribute list 'Mixed'. + * @see org.eclipse.emf.ecore.EObject#getMixed() + * @see #getDocumentRoot() + * @generated + */ + public EAttribute getDocumentRoot_Mixed() + { + return (EAttribute)documentRootEClass.getEStructuralFeatures().get(0); + } + + /** + * Returns the meta object for the map '{@link org.eclipse.emf.ecore.EObject#getXMLNSPrefixMap XMLNS Prefix Map}'. + * + * + * @return the meta object for the map 'XMLNS Prefix Map'. + * @see org.eclipse.emf.ecore.EObject#getXMLNSPrefixMap() + * @see #getDocumentRoot() + * @generated + */ + public EReference getDocumentRoot_XMLNSPrefixMap() + { + return (EReference)documentRootEClass.getEStructuralFeatures().get(1); + } + + /** + * Returns the meta object for the map '{@link org.eclipse.emf.ecore.EObject#getXSISchemaLocation XSI Schema Location}'. + * + * + * @return the meta object for the map 'XSI Schema Location'. + * @see org.eclipse.emf.ecore.EObject#getXSISchemaLocation() + * @see #getDocumentRoot() + * @generated + */ + public EReference getDocumentRoot_XSISchemaLocation() + { + return (EReference)documentRootEClass.getEStructuralFeatures().get(2); + } + + /** + * Returns the meta object for the containment reference '{@link org.eclipse.emf.ecore.EObject#getStockQuote Stock Quote}'. + * + * + * @return the meta object for the containment reference 'Stock Quote'. + * @see org.eclipse.emf.ecore.EObject#getStockQuote() + * @see #getDocumentRoot() + * @generated + */ + public EReference getDocumentRoot_StockQuote() + { + return (EReference)documentRootEClass.getEStructuralFeatures().get(3); + } + + /** + * Returns the meta object for class '{@link com.example.simple.Quote Quote}'. + * + * + * @return the meta object for class 'Quote'. + * @see com.example.simple.Quote + * @generated + */ + public EClass getQuote() + { + return quoteEClass; + } + + /** + * Returns the meta object for the attribute '{@link com.example.simple.Quote#getSymbol Symbol}'. + * + * + * @return the meta object for the attribute 'Symbol'. + * @see com.example.simple.Quote#getSymbol() + * @see #getQuote() + * @generated + */ + public EAttribute getQuote_Symbol() + { + return (EAttribute)quoteEClass.getEStructuralFeatures().get(0); + } + + /** + * Returns the meta object for the attribute '{@link com.example.simple.Quote#getCompanyName Company Name}'. + * + * + * @return the meta object for the attribute 'Company Name'. + * @see com.example.simple.Quote#getCompanyName() + * @see #getQuote() + * @generated + */ + public EAttribute getQuote_CompanyName() + { + return (EAttribute)quoteEClass.getEStructuralFeatures().get(1); + } + + /** + * Returns the meta object for the attribute '{@link com.example.simple.Quote#getPrice Price}'. + * + * + * @return the meta object for the attribute 'Price'. + * @see com.example.simple.Quote#getPrice() + * @see #getQuote() + * @generated + */ + public EAttribute getQuote_Price() + { + return (EAttribute)quoteEClass.getEStructuralFeatures().get(2); + } + + /** + * Returns the meta object for the attribute '{@link com.example.simple.Quote#getOpen1 Open1}'. + * + * + * @return the meta object for the attribute 'Open1'. + * @see com.example.simple.Quote#getOpen1() + * @see #getQuote() + * @generated + */ + public EAttribute getQuote_Open1() + { + return (EAttribute)quoteEClass.getEStructuralFeatures().get(3); + } + + /** + * Returns the meta object for the attribute '{@link com.example.simple.Quote#getHigh High}'. + * + * + * @return the meta object for the attribute 'High'. + * @see com.example.simple.Quote#getHigh() + * @see #getQuote() + * @generated + */ + public EAttribute getQuote_High() + { + return (EAttribute)quoteEClass.getEStructuralFeatures().get(4); + } + + /** + * Returns the meta object for the attribute '{@link com.example.simple.Quote#getLow Low}'. + * + * + * @return the meta object for the attribute 'Low'. + * @see com.example.simple.Quote#getLow() + * @see #getQuote() + * @generated + */ + public EAttribute getQuote_Low() + { + return (EAttribute)quoteEClass.getEStructuralFeatures().get(5); + } + + /** + * Returns the meta object for the attribute '{@link com.example.simple.Quote#getVolume Volume}'. + * + * + * @return the meta object for the attribute 'Volume'. + * @see com.example.simple.Quote#getVolume() + * @see #getQuote() + * @generated + */ + public EAttribute getQuote_Volume() + { + return (EAttribute)quoteEClass.getEStructuralFeatures().get(6); + } + + /** + * Returns the meta object for the attribute '{@link com.example.simple.Quote#getChange1 Change1}'. + * + * + * @return the meta object for the attribute 'Change1'. + * @see com.example.simple.Quote#getChange1() + * @see #getQuote() + * @generated + */ + public EAttribute getQuote_Change1() + { + return (EAttribute)quoteEClass.getEStructuralFeatures().get(7); + } + + /** + * Returns the meta object for the containment reference list '{@link com.example.simple.Quote#getQuotes Quotes}'. + * + * + * @return the meta object for the containment reference list 'Quotes'. + * @see com.example.simple.Quote#getQuotes() + * @see #getQuote() + * @generated + */ + public EReference getQuote_Quotes() + { + return (EReference)quoteEClass.getEStructuralFeatures().get(8); + } + + /** + * Returns the factory that creates the instances of the model. + * + * + * @return the factory that creates the instances of the model. + * @generated + */ + public SimpleFactory getSimpleFactory() + { + return (SimpleFactory)getEFactoryInstance(); + } + + /** + * + * + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void createPackageContents() + { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + documentRootEClass = createEClass(DOCUMENT_ROOT); + createEAttribute(documentRootEClass, DOCUMENT_ROOT__MIXED); + createEReference(documentRootEClass, DOCUMENT_ROOT__XMLNS_PREFIX_MAP); + createEReference(documentRootEClass, DOCUMENT_ROOT__XSI_SCHEMA_LOCATION); + createEReference(documentRootEClass, DOCUMENT_ROOT__STOCK_QUOTE); + + quoteEClass = createEClass(QUOTE); + createEAttribute(quoteEClass, QUOTE__SYMBOL); + createEAttribute(quoteEClass, QUOTE__COMPANY_NAME); + createEAttribute(quoteEClass, QUOTE__PRICE); + createEAttribute(quoteEClass, QUOTE__OPEN1); + createEAttribute(quoteEClass, QUOTE__HIGH); + createEAttribute(quoteEClass, QUOTE__LOW); + createEAttribute(quoteEClass, QUOTE__VOLUME); + createEAttribute(quoteEClass, QUOTE__CHANGE1); + createEReference(quoteEClass, QUOTE__QUOTES); + } + + /** + * + * + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void initializePackageContents() + { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Obtain other dependent packages + XMLTypePackage theXMLTypePackage = (XMLTypePackage)EPackage.Registry.INSTANCE.getEPackage(XMLTypePackage.eNS_URI); + + // Add supertypes to classes + + // Initialize classes and features; add operations and parameters + initEClass(documentRootEClass, null, "DocumentRoot", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getDocumentRoot_Mixed(), ecorePackage.getEFeatureMapEntry(), "mixed", null, 0, -1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getDocumentRoot_XMLNSPrefixMap(), ecorePackage.getEStringToStringMapEntry(), null, "xMLNSPrefixMap", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getDocumentRoot_XSISchemaLocation(), ecorePackage.getEStringToStringMapEntry(), null, "xSISchemaLocation", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getDocumentRoot_StockQuote(), this.getQuote(), null, "stockQuote", null, 0, -2, null, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED); + + initEClass(quoteEClass, Quote.class, "Quote", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getQuote_Symbol(), theXMLTypePackage.getString(), "symbol", null, 1, 1, Quote.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getQuote_CompanyName(), theXMLTypePackage.getString(), "companyName", null, 1, 1, Quote.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getQuote_Price(), theXMLTypePackage.getDecimal(), "price", null, 1, 1, Quote.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getQuote_Open1(), theXMLTypePackage.getDecimal(), "open1", null, 1, 1, Quote.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getQuote_High(), theXMLTypePackage.getDecimal(), "high", null, 1, 1, Quote.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getQuote_Low(), theXMLTypePackage.getDecimal(), "low", null, 1, 1, Quote.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getQuote_Volume(), theXMLTypePackage.getDouble(), "volume", null, 1, 1, Quote.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getQuote_Change1(), theXMLTypePackage.getDouble(), "change1", null, 1, 1, Quote.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getQuote_Quotes(), this.getQuote(), null, "quotes", null, 0, -1, Quote.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Create resource + createResource(eNS_URI); + + // Create annotations + // http:///org/eclipse/emf/ecore/util/ExtendedMetaData + createExtendedMetaDataAnnotations(); + } + + /** + * Initializes the annotations for http:///org/eclipse/emf/ecore/util/ExtendedMetaData. + * + * + * @generated + */ + protected void createExtendedMetaDataAnnotations() + { + String source = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData"; + addAnnotation + (documentRootEClass, + source, + new String[] + { + "name", "", + "kind", "mixed" + }); + addAnnotation + (getDocumentRoot_Mixed(), + source, + new String[] + { + "kind", "elementWildcard", + "name", ":mixed" + }); + addAnnotation + (getDocumentRoot_XMLNSPrefixMap(), + source, + new String[] + { + "kind", "attribute", + "name", "xmlns:prefix" + }); + addAnnotation + (getDocumentRoot_XSISchemaLocation(), + source, + new String[] + { + "kind", "attribute", + "name", "xsi:schemaLocation" + }); + addAnnotation + (getDocumentRoot_StockQuote(), + source, + new String[] + { + "kind", "element", + "name", "stockQuote", + "namespace", "##targetNamespace" + }); + addAnnotation + (quoteEClass, + source, + new String[] + { + "name", "Quote", + "kind", "elementOnly" + }); + addAnnotation + (getQuote_Symbol(), + source, + new String[] + { + "kind", "element", + "name", "symbol" + }); + addAnnotation + (getQuote_CompanyName(), + source, + new String[] + { + "kind", "element", + "name", "companyName" + }); + addAnnotation + (getQuote_Price(), + source, + new String[] + { + "kind", "element", + "name", "price" + }); + addAnnotation + (getQuote_Open1(), + source, + new String[] + { + "kind", "element", + "name", "open1" + }); + addAnnotation + (getQuote_High(), + source, + new String[] + { + "kind", "element", + "name", "high" + }); + addAnnotation + (getQuote_Low(), + source, + new String[] + { + "kind", "element", + "name", "low" + }); + addAnnotation + (getQuote_Volume(), + source, + new String[] + { + "kind", "element", + "name", "volume" + }); + addAnnotation + (getQuote_Change1(), + source, + new String[] + { + "kind", "element", + "name", "change1" + }); + addAnnotation + (getQuote_Quotes(), + source, + new String[] + { + "kind", "element", + "name", "quotes" + }); + } + + /** + * + * Defines literals for the meta objects that represent + *

    + *
  • each class,
  • + *
  • each feature of each class,
  • + *
  • each enum,
  • + *
  • and each data type
  • + *
+ * + * @generated + */ + public interface Literals + { + /** + * The meta object literal for the '{@link com.example.simple.impl.DocumentRootImpl Document Root}' class. + * + * + * @see com.example.simple.impl.DocumentRootImpl + * @see com.example.simple.impl.SimplePackageImpl#getDocumentRoot() + * @generated + */ + public static final EClass DOCUMENT_ROOT = eINSTANCE.getDocumentRoot(); + + /** + * The meta object literal for the 'Mixed' attribute list feature. + * + * + * @generated + */ + public static final EAttribute DOCUMENT_ROOT__MIXED = eINSTANCE.getDocumentRoot_Mixed(); + + /** + * The meta object literal for the 'XMLNS Prefix Map' map feature. + * + * + * @generated + */ + public static final EReference DOCUMENT_ROOT__XMLNS_PREFIX_MAP = eINSTANCE.getDocumentRoot_XMLNSPrefixMap(); + + /** + * The meta object literal for the 'XSI Schema Location' map feature. + * + * + * @generated + */ + public static final EReference DOCUMENT_ROOT__XSI_SCHEMA_LOCATION = eINSTANCE.getDocumentRoot_XSISchemaLocation(); + + /** + * The meta object literal for the 'Stock Quote' containment reference feature. + * + * + * @generated + */ + public static final EReference DOCUMENT_ROOT__STOCK_QUOTE = eINSTANCE.getDocumentRoot_StockQuote(); + + /** + * The meta object literal for the '{@link com.example.simple.impl.QuoteImpl Quote}' class. + * + * + * @see com.example.simple.impl.QuoteImpl + * @see com.example.simple.impl.SimplePackageImpl#getQuote() + * @generated + */ + public static final EClass QUOTE = eINSTANCE.getQuote(); + + /** + * The meta object literal for the 'Symbol' attribute feature. + * + * + * @generated + */ + public static final EAttribute QUOTE__SYMBOL = eINSTANCE.getQuote_Symbol(); + + /** + * The meta object literal for the 'Company Name' attribute feature. + * + * + * @generated + */ + public static final EAttribute QUOTE__COMPANY_NAME = eINSTANCE.getQuote_CompanyName(); + + /** + * The meta object literal for the 'Price' attribute feature. + * + * + * @generated + */ + public static final EAttribute QUOTE__PRICE = eINSTANCE.getQuote_Price(); + + /** + * The meta object literal for the 'Open1' attribute feature. + * + * + * @generated + */ + public static final EAttribute QUOTE__OPEN1 = eINSTANCE.getQuote_Open1(); + + /** + * The meta object literal for the 'High' attribute feature. + * + * + * @generated + */ + public static final EAttribute QUOTE__HIGH = eINSTANCE.getQuote_High(); + + /** + * The meta object literal for the 'Low' attribute feature. + * + * + * @generated + */ + public static final EAttribute QUOTE__LOW = eINSTANCE.getQuote_Low(); + + /** + * The meta object literal for the 'Volume' attribute feature. + * + * + * @generated + */ + public static final EAttribute QUOTE__VOLUME = eINSTANCE.getQuote_Volume(); + + /** + * The meta object literal for the 'Change1' attribute feature. + * + * + * @generated + */ + public static final EAttribute QUOTE__CHANGE1 = eINSTANCE.getQuote_Change1(); + + /** + * The meta object literal for the 'Quotes' containment reference list feature. + * + * + * @generated + */ + public static final EReference QUOTE__QUOTES = eINSTANCE.getQuote_Quotes(); + + } + +} //SimplePackageImpl diff --git a/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/SimpleStaticTest.java b/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/SimpleStaticTest.java new file mode 100644 index 0000000000..520cf707e7 --- /dev/null +++ b/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/java/org/apache/tuscany/sdo/test/SimpleStaticTest.java @@ -0,0 +1,64 @@ +/** + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.tuscany.sdo.test; + +import java.math.BigDecimal; + +import org.apache.tuscany.sdo.util.SDOUtil; + +import com.example.simple.Quote; +import com.example.simple.SimpleFactory; +import commonj.sdo.DataObject; +import commonj.sdo.helper.XMLHelper; + + +public class SimpleStaticTest +{ + /** + * Simple Static SDO 2 test. + */ + public static void main(String[] args) + { + try + { + SDOUtil.registerStaticTypes(SimpleFactory.class); + + //Quote quote = (Quote)DataFactory.INSTANCE.create(Quote.class); + Quote quote = SimpleFactory.INSTANCE.createQuote(); + + quote.setSymbol("fbnt"); + quote.setCompanyName("FlyByNightTechnology"); + quote.setPrice(new BigDecimal("1000.0")); + quote.setOpen1(new BigDecimal("1000.0")); + quote.setHigh(new BigDecimal("1000.0")); + quote.setLow(new BigDecimal("1000.0")); + quote.setVolume(1000); + quote.setChange1(1000); + + //Quote child = (Quote)((DataObject)quote).createDataObject(8); + Quote child = SimpleFactory.INSTANCE.createQuote(); + quote.getQuotes().add(child); + child.setPrice(new BigDecimal("2000.0")); + + XMLHelper.INSTANCE.save((DataObject)quote, "http://www.example.com/simple", "stockQuote", System.out); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/resources/enum.xsd b/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/resources/enum.xsd new file mode 100644 index 0000000000..4cbde32849 --- /dev/null +++ b/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/resources/enum.xsd @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/resources/simple.xsd b/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/resources/simple.xsd new file mode 100644 index 0000000000..c15028544e --- /dev/null +++ b/sca-java-1.x/tags/java-stable-20060304/sdo/tools/src/test/resources/simple.xsd @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3