diff options
Diffstat (limited to 'tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util')
16 files changed, 0 insertions, 6614 deletions
diff --git a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/BasicSequence.java b/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/BasicSequence.java deleted file mode 100644 index 5a631dde77..0000000000 --- a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/BasicSequence.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.sdo.util; - -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.util.FeatureMap; -import org.eclipse.emf.ecore.util.FeatureMapUtil; -import org.eclipse.emf.ecore.xml.type.XMLTypePackage; - -import commonj.sdo.Property; -import commonj.sdo.Sequence; - -/** - * SDO Sequance implementation which delegates to a feature map. - */ -public class BasicSequence implements Sequence, FeatureMap.Internal.Wrapper -{ - protected FeatureMap.Internal featureMap; - - public BasicSequence(FeatureMap.Internal featureMap) - { - this.featureMap = featureMap; - featureMap.setWrapper(this); - } - - public FeatureMap featureMap() - { - return featureMap; - } - - public int size() - { - return featureMap.size(); - } - - public Property getProperty(int index) - { - EStructuralFeature feature = featureMap.getEStructuralFeature(index); - boolean isText = - feature == XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__TEXT || - feature == XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__CDATA || - feature == XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__COMMENT; - return isText ? null : (Property)feature; - } - - public Object getValue(int index) - { - return featureMap.getValue(index); - } - - public Object setValue(int index, Object value) - { - return featureMap.setValue(index, value); - } - - protected EStructuralFeature getEStructuralFeature(String propertyName) - { - return featureMap.getEObject().eClass().getEStructuralFeature(propertyName); - } - - protected EStructuralFeature getEStructuralFeature(int propertyIndex) - { - return featureMap.getEObject().eClass().getEStructuralFeature(propertyIndex); - } - - public boolean add(String propertyName, Object value) - { - return featureMap.add(getEStructuralFeature(propertyName), value); - } - - public boolean add(int propertyIndex, Object value) - { - return featureMap.add(getEStructuralFeature(propertyIndex), value); - } - - public boolean add(Property property, Object value) - { - return featureMap.add((EStructuralFeature)property, value); - } - - public void add(int index, String propertyName, Object value) - { - featureMap.add(index, getEStructuralFeature(propertyName), value); - } - - public void add(int index, int propertyIndex, Object value) - { - featureMap.add(index, getEStructuralFeature(propertyIndex), value); - } - - public void add(int index, Property property, Object value) - { - featureMap.add(index, (EStructuralFeature)property, value); - } - - public void add(String text) - { - FeatureMapUtil.addText(featureMap, text); - } - - public void add(int index, String text) - { - FeatureMapUtil.addText(featureMap, index, text); - } - - public void remove(int index) - { - featureMap.remove(index); - } - - public void move(int toIndex, int fromIndex) - { - featureMap.move(toIndex, fromIndex); - } - - public String toString() - { - return featureMap.toString(); - } -} diff --git a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataGraphResourceFactoryImpl.java b/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataGraphResourceFactoryImpl.java deleted file mode 100644 index 8f10b7f198..0000000000 --- a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataGraphResourceFactoryImpl.java +++ /dev/null @@ -1,644 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.sdo.util; - - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.apache.tuscany.sdo.SDOFactory; -import org.apache.tuscany.sdo.SDOPackage; -import org.apache.tuscany.sdo.impl.ChangeSummaryImpl; -import org.apache.tuscany.sdo.impl.DataGraphImpl; -import org.apache.tuscany.sdo.impl.DynamicDataObjectImpl; -import org.eclipse.emf.common.util.EMap; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EFactory; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.EcorePackage; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.ecore.util.ExtendedMetaData; -import org.eclipse.emf.ecore.xmi.EcoreBuilder; -import org.eclipse.emf.ecore.xmi.NameInfo; -import org.eclipse.emf.ecore.xmi.XMLHelper; -import org.eclipse.emf.ecore.xmi.XMLLoad; -import org.eclipse.emf.ecore.xmi.XMLResource; -import org.eclipse.emf.ecore.xmi.XMLSave; -import org.eclipse.emf.ecore.xmi.impl.SAXXMLHandler; -import org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl; -import org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl; -import org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl; -import org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl; -import org.eclipse.emf.ecore.xmi.util.DefaultEcoreBuilder; -import org.w3c.dom.Element; -import org.xml.sax.helpers.DefaultHandler; - -import commonj.sdo.ChangeSummary; - - -public class DataGraphResourceFactoryImpl extends ResourceFactoryImpl -{ - /** - * Constructor for DataGraphResourceFactoryImpl. - */ - public DataGraphResourceFactoryImpl() - { - super(); - } - - public Resource createResource(URI uri) - { - XMLResourceImpl result = new DataGraphResourceImpl(uri); - - result.setEncoding("UTF-8"); - - result.getDefaultLoadOptions().put(XMLResource.OPTION_USE_LEXICAL_HANDLER, Boolean.TRUE); - - result.getDefaultLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); - result.getDefaultSaveOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, Boolean.TRUE); - - result.getDefaultSaveOptions().put(XMLResource.OPTION_USE_ENCODED_ATTRIBUTE_STYLE, Boolean.TRUE); - result.getDefaultSaveOptions().put(XMLResource.OPTION_LINE_WIDTH, new Integer(80)); - - result.getDefaultLoadOptions().put(XMLResource.OPTION_ANY_TYPE, SDOPackage.eINSTANCE.getAnyTypeDataObject()); - result.getDefaultSaveOptions().put(XMLResource.OPTION_ANY_TYPE, SDOPackage.eINSTANCE.getAnyTypeDataObject()); - - result.getDefaultLoadOptions().put(XMLResource.OPTION_ANY_SIMPLE_TYPE, SDOPackage.eINSTANCE.getSimpleAnyTypeDataObject()); - result.getDefaultSaveOptions().put(XMLResource.OPTION_ANY_SIMPLE_TYPE, SDOPackage.eINSTANCE.getSimpleAnyTypeDataObject()); - - return result; - } - - public static class DataGraphResourceImpl extends XMLResourceImpl - { - public DataGraphResourceImpl(URI uri) - { - super(uri); - } - - public static class HelperImpl extends XMLHelperImpl - { - protected DataGraphImpl eDataGraph; - - protected List resources; - protected List uris; - - public HelperImpl(XMLResource xmlResource) - { - super(xmlResource); - } - - public void setResource(XMLResource resource) - { - super.setResource(resource); - if (!resource.getContents().isEmpty()) - { - eDataGraph = (DataGraphImpl)resource.getContents().get(0); - - resources = new ArrayList(); - uris = new ArrayList(); - - resources.add(eDataGraph.getRootResource()); - uris.add("#" + resource.getURIFragment(eDataGraph) + "/@eRootObject"); - - if (eDataGraph.getEChangeSummary() != null) - { - // Ensure that resource exists. - // - resources.add(((EObject)eDataGraph.getChangeSummary()).eResource()); - uris.add("#" + resource.getURIFragment(eDataGraph) + "/@eChangeSummary"); - } - - if (eDataGraph.eResource() != null && eDataGraph.eResource().getResourceSet() != null) - { - int count = 0; - for (Iterator i = eDataGraph.eResource().getResourceSet().getResources().iterator(); i.hasNext();) - { - Resource ePackageResource = (Resource)i.next(); - List resourceContents = ePackageResource.getContents(); - if (resourceContents.size() == 1 && resourceContents.get(0) instanceof EPackage) - { - resources.add(ePackageResource); - uris.add("#" + resource.getURIFragment(eDataGraph) + "/@models." + count++); - } - } - } - } - } - - public String getID(EObject eObject) - { - return super.getID(eObject); - } - - public String getIDREF(EObject eObject) - { - return super.getIDREF(eObject); - } - - public String getHREF(EObject eObject) - { - return super.getHREF(eObject); - } - - protected URI getHREF(Resource otherResource, EObject obj) - { - int index = resources.indexOf(otherResource); - if (index == -1) - { - return super.getHREF(otherResource, obj); - } - else - { - return createHREF((String)uris.get(index), otherResource.getURIFragment(obj)); - } - } - - protected URI createHREF(String baseURI, String fragment) - { - if (fragment.startsWith("/")) - { - return URI.createURI(baseURI + fragment.substring(1)); - } - else - { - return URI.createURI("#" + fragment); - } - } - - public void populateNameInfo(NameInfo nameInfo, EClass c) - { - if (c == SDOPackage.eINSTANCE.getDataGraph()) - { - if (extendedMetaData != null) - { - extendedMetaData.demandPackage("commonj.sdo").setNsPrefix("sdo"); - } - nameInfo.setQualifiedName(getQName("commonj.sdo", "datagraph")); - nameInfo.setNamespaceURI("commonj.sdo"); - nameInfo.setLocalPart("datagraph"); - } - else if (c == SDOPackage.eINSTANCE.getChangeSummary()) - { - if (extendedMetaData != null) - { - extendedMetaData.demandPackage("commonj.sdo").setNsPrefix("sdo"); - } - nameInfo.setQualifiedName("changeSummary"); - nameInfo.setNamespaceURI(null); - nameInfo.setLocalPart("changeSummary"); - } - else - { - super.populateNameInfo(nameInfo, c); - } - } - - public String getQName(EClass c) - { - if (c == SDOPackage.eINSTANCE.getDataGraph()) - { - if (extendedMetaData != null) - { - extendedMetaData.demandPackage("commonj.sdo").setNsPrefix("sdo"); - } - return getQName("commonj.sdo", "datagraph"); - } - else if (c == SDOPackage.eINSTANCE.getChangeSummary()) - { - if (extendedMetaData != null) - { - extendedMetaData.demandPackage("commonj.sdo").setNsPrefix("sdo"); - } - return getQName((String)null, "changeSummary"); - } - else - { - return super.getQName(c); - } - } - } - - protected XMLHelper createXMLHelper() - { - return new HelperImpl(this); - } - - protected EObject getEObjectByID(String id) - { - List contents = getContents(); - if (contents.size() >= 1) - { - Object rootObject = contents.get(0); - if (rootObject instanceof DataGraphImpl) - { - DataGraphImpl eDataGraph = (DataGraphImpl)rootObject; - EObject result = eDataGraph.getRootResource().getEObject(id); - if (result != null) - { - return result; - } - else - { - ChangeSummary eChangeSummary = eDataGraph.getEChangeSummary(); - if (eChangeSummary != null) - { - result = ((EObject)eDataGraph.getChangeSummary()).eResource().getEObject(id); - if (result != null) - { - return result; - } - } - } - } - } - return super.getEObjectByID(id); - } - - public static class SaveImpl extends XMLSaveImpl - { - protected DataGraphImpl eDataGraph; - - public SaveImpl(XMLHelper xmlHelper) - { - super(xmlHelper); - } - - public void traverse(List contents) - { - if (contents.size() >= 1 && contents.get(0) instanceof DataGraphImpl) - { - eDataGraph = (DataGraphImpl)contents.get(0); - - Object datagraphMark = null; - if (!toDOM) - { - if (declareXML) - { - doc.add("<?xml version=\"" + xmlVersion + "\" encoding=\"" + encoding + "\"?>"); - doc.addLine(); - } - String elementName = helper.getQName(eDataGraph.eClass()); - doc.startElement(elementName); - datagraphMark = doc.mark(); - } - else - { - helper.populateNameInfo(nameInfo, eDataGraph.eClass()); - currentNode = document.createElementNS(nameInfo.getNamespaceURI(), nameInfo.getQualifiedName()); - document.appendChild(currentNode); - // not calling handler since there is no corresponding EObject - } - - if (eDataGraph.eResource() != null && eDataGraph.eResource().getResourceSet() != null) - { - List ePackages = new ArrayList(); - for (Iterator i = eDataGraph.eResource().getResourceSet().getResources().iterator(); i.hasNext();) - { - List resourceContents = ((Resource)i.next()).getContents(); - if (resourceContents.size() == 1 && resourceContents.get(0) instanceof EPackage) - { - ePackages.add(resourceContents.get(0)); - } - } - if (!ePackages.isEmpty()) - { - if (!toDOM) - { - doc.startElement("models"); - doc.addAttribute("xmlns", ""); - } - else - { - currentNode = currentNode.appendChild(document.createElementNS(null, "models")); - ((Element)currentNode).setAttributeNS(ExtendedMetaData.XMLNS_URI, ExtendedMetaData.XMLNS_PREFIX, ""); - // not calling handler since there is no corresponding EObject - } - for (Iterator i = ePackages.iterator(); i.hasNext();) - { - writeTopObject((EPackage)i.next()); - } - if (!toDOM) - { - doc.endElement(); - } - else - { - currentNode = currentNode.getParentNode(); - } - } - } - - // use namespace declarations defined in the document (if any) - EObject eRootObject = eDataGraph.getERootObject(); - EReference xmlnsPrefixMapFeature = extendedMetaData.getXMLNSPrefixMapFeature(eRootObject.eClass()); - if (xmlnsPrefixMapFeature != null) - { - EMap xmlnsPrefixMap = (EMap)eRootObject.eGet(xmlnsPrefixMapFeature); - helper.setPrefixToNamespaceMap(xmlnsPrefixMap); - } - ChangeSummary changeSummary = eDataGraph.getEChangeSummary(); - - if (changeSummary != null) - { - helper.setMustHavePrefix(true); - if (changeSummary.isLogging()) - { - ((ChangeSummaryImpl)changeSummary).summarize(); - writeTopObject((EObject)changeSummary); - } - else - { - writeTopObject((EObject)changeSummary); - } - helper.setMustHavePrefix(false); - } - - if (eRootObject != null && writeTopObject(eRootObject) == null && !toDOM) - { - doc.addLine(); - doc.setMixed(false); - } - if (!toDOM) - { - doc.endElement(); - // reset to add namespace declarations - // - doc.resetToMark(datagraphMark); - } - else - { - currentNode = document.getFirstChild(); - } - addNamespaceDeclarations(); - } - else - { - super.traverse(contents); - } - } - - protected void writeTopAttributes(EObject top) - { - if (top == eDataGraph.getEChangeSummary()) - { - if (!toDOM) - { - doc.addAttribute("xmlns", ""); - } - else - { - ((Element)currentNode).setAttributeNS(ExtendedMetaData.XMLNS_URI, ExtendedMetaData.XMLNS_PREFIX, ""); - } - } - } - - protected EObject getSchemaLocationRoot(EObject eObject) - { - return eDataGraph.getERootObject(); - } - } - - protected XMLSave createXMLSave() - { - return new SaveImpl(createXMLHelper()); - } - - public static class LoadImpl extends XMLLoadImpl - { - public LoadImpl(XMLHelper xmlHelper) - { - super(xmlHelper); - } - - protected DefaultHandler makeDefaultHandler() - { - return new SAXXMLHandler(resource, helper, options) - { - protected DataGraphImpl eDataGraph; - - protected boolean isInModels; - - protected List ePackages = new ArrayList(); - - protected EMap recordNamespacesSchemaLocations(EObject root) - { - EObject dgroot = eDataGraph.getERootObject(); - if (dgroot == null) - { - return null; - } - EMap prefixToNamespaceMap = super.recordNamespacesSchemaLocations(dgroot); - if (prefixToNamespaceMap != null) - { - for (Iterator i = prefixToNamespaceMap.iterator(); i.hasNext();) - { - Map.Entry entry = (Map.Entry)i.next(); - String prefix = (String)entry.getKey(); - String namespace = (String)entry.getValue(); - if (namespace.equals("commonj.sdo")) - { - prefixToNamespaceMap.removeKey(prefix); - break; - } - } - } - return prefixToNamespaceMap; - } - - protected void handleFeature(String prefix, String name) - { - if (isInModels && objects.size() == 2) - { - EObject modelObject = createObjectByType(prefix, name, false); - processObject(modelObject); - ePackages.add(modelObject); - } - else if (objects.size() == 1) - { - eDataGraph = (DataGraphImpl)objects.peek(); - eDataGraph.getResourceSet(); - if ("".equals(prefix) && "changeSummary".equals(name)) - { - ChangeSummary eChangeSummary = (ChangeSummary)createObjectFromFactory(SDOFactory.eINSTANCE, "EChangeSummary"); - eDataGraph.setEChangeSummary(eChangeSummary); - processObject((EObject)eChangeSummary); - } - else if ("".equals(prefix) && "models".equals(name)) - { - isInModels = true; - types.push(OBJECT_TYPE); - objects.push(eDataGraph); - mixedTargets.push(null); - } - else if (eDataGraph.getERootObject() == null) - { - if (processAnyXML) - { - // Ensure that anything can be handled, even if it's not recognized. - // - String namespaceURI = helper.getURI(prefix); - if (extendedMetaData.getPackage(namespaceURI) == null) - { - EStructuralFeature rootFeature = extendedMetaData.demandFeature(namespaceURI, name, true); - rootFeature.getEContainingClass().getEPackage().setEFactoryInstance(new DynamicDataObjectImpl.FactoryImpl()); - } - } - - EObject rootObject = createObjectByType(prefix, name, false); - eDataGraph.setERootObject(rootObject); - processObject(rootObject); - if (rootObject != null - && rootObject.eClass() == ExtendedMetaData.INSTANCE.getDocumentRoot(rootObject.eClass().getEPackage())) - { - super.handleFeature(prefix, name); - - // Remove the document root from the stack. - // - Object mixedTarget = mixedTargets.pop(); - Object object = objects.pop(); - mixedTargets.pop(); - objects.pop(); - mixedTargets.push(mixedTarget); - objects.push(object); - } - } - } - else - { - super.handleFeature(prefix, name); - } - } - - public void endElement(String uri, String localName, String name) - { - if (isInModels && objects.size() == 2) - { - if (!ePackages.isEmpty()) - { - for (Iterator i = ePackages.iterator(); i.hasNext();) - { - EPackage ePackage = (EPackage)i.next(); - ePackage.setEFactoryInstance(new DynamicDataObjectImpl.FactoryImpl()); - Resource resource = resourceSet.createResource(URI.createURI("*.ecore")); - resource.getContents().add(ePackage); - if (ePackage.getNsURI() != null) - { - resource.setURI(URI.createURI(ePackage.getNsURI())); - } - - if (extendedMetaData != null) - { - extendedMetaData.putPackage(extendedMetaData.getNamespace(ePackage), ePackage); - } - else - { - packageRegistry.put(ePackage.getNsURI(), ePackage); - } - } - handleForwardReferences(); - } - isInModels = false; - } - super.endElement(uri, localName, name); - } - - protected EPackage getPackageForURI(String uriString) - { - if ("commonj.sdo".equals(uriString)) - { - return SDOPackage.eINSTANCE; - } - else - { - return super.getPackageForURI(uriString); - } - } - - protected EObject createObjectFromFactory(EFactory factory, String typeName) - { - if (factory == SDOFactory.eINSTANCE) - { - if ("datagraph".equals(typeName)) - { - return super.createObjectFromFactory(factory, "EDataGraph"); - } - } - return super.createObjectFromFactory(factory, typeName); - } - - protected EcoreBuilder createEcoreBuilder(Map options, ExtendedMetaData extendedMetaData) - { - return new DefaultEcoreBuilder(extendedMetaData) - { - public Collection generate(Map urisToLocations) throws Exception - { - Collection result = super.generate(urisToLocations); - return updateDynamicFactory(result); - } - - public Collection generate(Collection urisToLocations) throws Exception - { - Collection result = super.generate(urisToLocations); - return updateDynamicFactory(result); - } - - protected Collection updateDynamicFactory(Collection result) - { - for (Iterator i = result.iterator(); i.hasNext();) - { - Resource resource = (Resource)i.next(); - for (Iterator j = EcoreUtil.getObjectsByType(resource.getContents(), EcorePackage.eINSTANCE.getEPackage()).iterator(); j.hasNext();) - { - EPackage ePackage = (EPackage)j.next(); - ePackage.setEFactoryInstance(new DynamicDataObjectImpl.FactoryImpl()); - } - } - return result; - } - - }; - } - - protected EPackage handleMissingPackage(String uriString) - { - EPackage result = super.handleMissingPackage(uriString); - if (processAnyXML && objects.size() == 1) - { - result = extendedMetaData.demandPackage(uriString); - } - return result; - } - }; - } - } - - protected XMLLoad createXMLLoad() - { - return new LoadImpl(createXMLHelper()); - } - } -} diff --git a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java b/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java deleted file mode 100644 index 23df894b32..0000000000 --- a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/DataObjectUtil.java +++ /dev/null @@ -1,2564 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.sdo.util; - - -import java.io.InvalidObjectException; -import java.io.ObjectStreamException; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.apache.tuscany.sdo.SDOExtendedMetaData; -import org.apache.tuscany.sdo.impl.DataGraphImpl; -import org.apache.tuscany.sdo.impl.SDOFactoryImpl; -import org.eclipse.emf.common.util.BasicEList; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.common.util.UniqueEList; -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EFactory; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.EcoreFactory; -import org.eclipse.emf.ecore.EcorePackage; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.ecore.util.ExtendedMetaData; -import org.eclipse.emf.ecore.util.FeatureMap; -import org.eclipse.emf.ecore.util.FeatureMapUtil; -import org.eclipse.emf.ecore.xmi.impl.EMOFResourceFactoryImpl; -import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; -import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl; -import org.eclipse.emf.ecore.xml.type.internal.XMLCalendar; -import org.eclipse.xsd.util.XSDResourceFactoryImpl; - -import commonj.sdo.ChangeSummary; -import commonj.sdo.DataGraph; -import commonj.sdo.DataObject; -import commonj.sdo.Property; -import commonj.sdo.Sequence; -import commonj.sdo.Type; -import commonj.sdo.helper.TypeHelper; - - -public final class DataObjectUtil -{ - public static Object writeReplace(DataObject dataObject) throws ObjectStreamException - { - DataGraph dataGraph = dataObject.getDataGraph(); - if (dataGraph != null) - { - return ((DataGraphImpl)dataGraph).getWriteReplacement((EObject)dataObject); - } - else - { - throw new InvalidObjectException("The object must be in a datagraph to be serialized " + dataObject); - } - } - - public static void setString(DataObject dataObject, Property property, String value) { - dataObject.set(property, getSetValue(property, value)); - } - - public static void setShort(DataObject dataObject, Property property, short value) { - dataObject.set(property, getSetValue(property, value)); - } - - public static void setLong(DataObject dataObject, Property property, long value) { - dataObject.set(property, getSetValue(property, value)); - } - - public static void setList(DataObject dataObject, Property property, List value) { - dataObject.set(property, value); - } - - public static void setInt(DataObject dataObject, Property property, int value) { - dataObject.set(property, getSetValue(property, value)); - } - - public static void setFloat(DataObject dataObject, Property property, float value) { - dataObject.set(property, getSetValue(property, value)); - } - - public static void setDouble(DataObject dataObject, Property property, double value) { - dataObject.set(property, getSetValue(property, value)); - } - - public static void setDate(DataObject dataObject, Property property, Date value) { - dataObject.set(property, getSetValue(property, value)); - } - - public static void setDataObject(DataObject dataObject, Property property, DataObject value) { - dataObject.set(property, value); - } - - public static void setChar(DataObject dataObject, Property property, char value) { - dataObject.set(property, getSetValue(property, value)); - } - - public static void setBytes(DataObject dataObject, Property property, byte[] value) { - dataObject.set(property, getSetValue(property, value)); - } - - public static void setByte(DataObject dataObject, Property property, byte value) { - dataObject.set(property, getSetValue(property, value)); - } - - public static void setBoolean(DataObject dataObject, Property property, boolean value) { - dataObject.set(property, getSetValue(property, value)); - } - - public static void setBigInteger(DataObject dataObject, Property property, BigInteger value) - { - dataObject.set(property, getSetValue(property, value)); - } - - public static void setBigDecimal(DataObject dataObject, Property property, BigDecimal value) - { - dataObject.set(property, getSetValue(property, value)); - } - - public static String getString(DataObject dataObject, Property property) - { - return getString(dataObject.get(property)); - } - - public static short getShort(DataObject dataObject, Property property) - { - return getShort(dataObject.get(property)); - } - - public static Sequence getSequence(DataObject dataObject, Property property) - { - return (Sequence)dataObject.get(property); - } - - public static long getLong(DataObject dataObject, Property property) - { - return getLong(dataObject.get(property)); - } - - public static List getList(DataObject dataObject, Property property) - { - return (List)dataObject.get(property); - } - - public static int getInt(DataObject dataObject, Property property) - { - return getInt(dataObject.get(property)); - } - - public static float getFloat(DataObject dataObject, Property property) - { - return getFloat(dataObject.get(property)); - } - - public static double getDouble(DataObject dataObject, Property property) - { - return getDouble(dataObject.get(property)); - } - - public static Date getDate(DataObject dataObject, Property property) - { - return getDate(dataObject.get(property)); - } - - public static DataObject getDataObject(DataObject dataObject, Property property) - { - return (DataObject)dataObject.get(property); - } - - public static char getChar(DataObject dataObject, Property property) - { - return getChar(dataObject.get(property)); - } - - public static byte[] getBytes(DataObject dataObject, Property property) - { - return getBytes(dataObject.get(property)); - } - - public static byte getByte(DataObject dataObject, Property property) - { - return getByte(dataObject.get(property)); - } - - public static boolean getBoolean(DataObject dataObject, Property property) - { - return getBoolean(dataObject.get(property)); - } - - public static BigInteger getBigInteger(DataObject dataObject, Property property) - { - return getBigInteger(dataObject.get(property)); - } - - public static BigDecimal getBigDecimal(DataObject dataObject, Property property) - { - return getBigDecimal(dataObject.get(property)); - } - - - - private static Property getPropertyByIndex(DataObject dataObject, int propertyIndex) { - EObject eObject = (EObject) dataObject; - Property property = (Property)eObject.eClass().getEStructuralFeature(propertyIndex); - return property; - } - - public static void setString(DataObject dataObject, int propertyIndex, String value) { - dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); - } - - public static void setShort(DataObject dataObject, int propertyIndex, short value) { - dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); - } - - public static void setLong(DataObject dataObject, int propertyIndex, long value) { - dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); - } - - public static void setList(DataObject dataObject, int propertyIndex, List value) { - dataObject.set(propertyIndex, value); - } - - public static void setInt(DataObject dataObject, int propertyIndex, int value) { - dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); - } - - public static void setFloat(DataObject dataObject, int propertyIndex, float value) { - dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); - } - - public static void setDouble(DataObject dataObject, int propertyIndex, double value) { - dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); - } - - public static void setDate(DataObject dataObject, int propertyIndex, Date value) { - dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); - } - - public static void setDataObject(DataObject dataObject, int propertyIndex, DataObject value) { - dataObject.set(propertyIndex, value); - } - - public static void setChar(DataObject dataObject, int propertyIndex, char value) { - dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); - } - - public static void setBytes(DataObject dataObject, int propertyIndex, byte[] value) { - dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); - } - - public static void setByte(DataObject dataObject, int propertyIndex, byte value) { - dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); - } - - public static void setBoolean(DataObject dataObject, int propertyIndex, boolean value) { - dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); - } - - public static void setBigInteger(DataObject dataObject, int propertyIndex, BigInteger value) - { - dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); - } - - public static void setBigDecimal(DataObject dataObject, int propertyIndex, BigDecimal value) - { - dataObject.set(propertyIndex, getSetValue(getPropertyByIndex(dataObject, propertyIndex), value)); - } - - public static String getString(DataObject dataObject, int propertyIndex) - { - return getString(dataObject.get(propertyIndex)); - } - - public static short getShort(DataObject dataObject, int propertyIndex) - { - return getShort(dataObject.get(propertyIndex)); - } - - public static Sequence getSequence(DataObject dataObject, int propertyIndex) - { - return (Sequence)dataObject.get(propertyIndex); - } - - public static long getLong(DataObject dataObject, int propertyIndex) - { - return getLong(dataObject.get(propertyIndex)); - } - - public static List getList(DataObject dataObject, int propertyIndex) - { - return (List)dataObject.get(propertyIndex); - } - - public static int getInt(DataObject dataObject, int propertyIndex) - { - return getInt(dataObject.get(propertyIndex)); - } - - public static float getFloat(DataObject dataObject, int propertyIndex) - { - return getFloat(dataObject.get(propertyIndex)); - } - - public static double getDouble(DataObject dataObject, int propertyIndex) - { - return getDouble(dataObject.get(propertyIndex)); - } - - public static Date getDate(DataObject dataObject, int propertyIndex) - { - return getDate(dataObject.get(propertyIndex)); - } - - public static DataObject getDataObject(DataObject dataObject, int propertyIndex) - { - return (DataObject)dataObject.get(propertyIndex); - } - - public static char getChar(DataObject dataObject, int propertyIndex) - { - return getChar(dataObject.get(propertyIndex)); - } - - public static byte[] getBytes(DataObject dataObject, int propertyIndex) - { - return getBytes(dataObject.get(propertyIndex)); - } - - public static byte getByte(DataObject dataObject, int propertyIndex) - { - return getByte(dataObject.get(propertyIndex)); - } - - public static boolean getBoolean(DataObject dataObject, int propertyIndex) - { - return getBoolean(dataObject.get(propertyIndex)); - } - - public static BigInteger getBigInteger(DataObject dataObject, int propertyIndex) - { - return getBigInteger(dataObject.get(propertyIndex)); - } - - public static BigDecimal getBigDecimal(DataObject dataObject, int propertyIndex) - { - return getBigDecimal(dataObject.get(propertyIndex)); - } - - public static void detach(DataObject dataObject) { - EcoreUtil.remove((EObject)dataObject); - } - - public static DataObject getRootObject(DataObject dataObject) - { - return (DataObject)EcoreUtil.getRootContainer((EObject)dataObject); - } - - public static List getInstanceProperties(DataObject dataObject) - { - //TODO maybe optimize this to just return type.getProperties if type.isOpen (isOpen would need to be cached) - EObject eDataObject = (EObject) dataObject; - List result = new UniqueEList(eDataObject.eClass().getEAllStructuralFeatures()); - for (int i = 0, count = result.size(); i < count; ++i) - { - EStructuralFeature eStructuralFeature = (EStructuralFeature)result.get(i); - if (!eStructuralFeature.isDerived() && FeatureMapUtil.isFeatureMap(eStructuralFeature)) - { - List features = (List)eDataObject.eGet(eStructuralFeature); - for (int j = 0, size = features.size(); j < size; ++j) - { - FeatureMap.Entry entry = (FeatureMap.Entry)features.get(j); - EStructuralFeature entryFeature = entry.getEStructuralFeature(); - result.add(entryFeature); - } - } - } - return result; - } - - public static void delete(DataObject dataObject) - { - EObject eDataObject = (EObject)dataObject; - EcoreUtil.remove(eDataObject); - List contents = new ArrayList((eDataObject).eContents()); - for (int i = 0, size = contents.size(); i < size; ++i) - { - ((DataObject)contents.get(i)).delete(); - } - EClass eClass = eDataObject.eClass(); - for (int i = 0, size = eClass.getFeatureCount(); i < size; ++i) - { - EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature(i); - if (eStructuralFeature.isChangeable() && !eStructuralFeature.isDerived() && !((Property)eStructuralFeature).isReadOnly()) - { - eDataObject.eUnset(eStructuralFeature); - } - } - } - - public static DataObject createDataObject(DataObject dataObject, Property property, Type type) - { - if (!property.isContainment()) - { - throw new IllegalArgumentException("The property '" + property.getName() + "' of '" + property.getContainingType().getName() - + "' isn't a containment"); - } - DataObject result = DataObjectUtil.create(type); - if (FeatureMapUtil.isMany((EObject)dataObject, (EStructuralFeature)property)) - { - ((List)dataObject.get(property)).add(result); - } - else - { - dataObject.set(property, result); - } - return result; - } - - public static DataObject createDataObject(DataObject dataObject, int propertyIndex, String namespaceURI, String typeName) - { - Property property = DataObjectUtil.getProperty(dataObject, propertyIndex); - Type type = DataObjectUtil.getType(dataObject, namespaceURI, typeName); - return createDataObject(dataObject, property, type); - } - - public static DataObject createDataObject(DataObject dataObject, String propertyName, String namespaceURI, String typeName) - { - Property property = getProperty(dataObject, propertyName); - Type type = DataObjectUtil.getType(dataObject, namespaceURI, typeName); - return createDataObject(dataObject, property, type); - } - - public static DataObject createDataObject(DataObject dataObject, Property property) - { - Type type = property.getType(); - return createDataObject(dataObject, property, type); - } - - public static DataObject createDataObject(DataObject dataObject, int propertyIndex) - { - Property property = getProperty(dataObject, propertyIndex); - Type type = property.getType(); - return createDataObject(dataObject,property, type); - } - - public static DataObject createDataObject(DataObject dataObject, String propertyName) - { - Property property = (Property)getProperty(dataObject, propertyName); - Type type = property.getType(); - return createDataObject(dataObject,property, type); - } - - public static void setString(DataObject dataObject, String path, String value) - { - Property property = dataObject.getType().getProperty(path); - if (property != null) - { - dataObject.set(property, DataObjectUtil.getSetValue(property, value)); - } - else - { - DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); - accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); - } - } - - - public static void setShort(DataObject dataObject, String path, short value) - { - Property property = dataObject.getType().getProperty(path); - if (property != null) - { - dataObject.set(property, DataObjectUtil.getSetValue(property, value)); - } - else - { - DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); - accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); - } - } - - public static void setLong(DataObject dataObject, String path, long value) - { - Property property = dataObject.getType().getProperty(path); - if (property != null) - { - dataObject.set(property, DataObjectUtil.getSetValue(property, value)); - } - else - { - DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); - accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); - } - } - - public static void setList(DataObject dataObject, String path, List value) - { - dataObject.set(path, value); - } - - public static void setInt(DataObject dataObject, String path, int value) - { - Property property = dataObject.getType().getProperty(path); - if (property != null) - { - dataObject.set(property, DataObjectUtil.getSetValue(property, value)); - } - else - { - DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); - accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); - } - } - - public static void setFloat(DataObject dataObject, String path, float value) - { - Property property = dataObject.getType().getProperty(path); - if (property != null) - { - dataObject.set(property, DataObjectUtil.getSetValue(property, value)); - } - else - { - DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); - accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); - } - } - - public static void setDouble(DataObject dataObject, String path, double value) - { - Property property = dataObject.getType().getProperty(path); - if (property != null) - { - dataObject.set(property, DataObjectUtil.getSetValue(property, value)); - } - else - { - DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); - accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); - } - } - - public static void setDate(DataObject dataObject, String path, Date value) - { - Property property = dataObject.getType().getProperty(path); - if (property != null) - { - dataObject.set(property, DataObjectUtil.getSetValue(property, value)); - } - else - { - DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); - accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); - } - } - - public static void setDataObject(DataObject dataObject, String path, DataObject value) - { - dataObject.set(path, value); - } - - public static void setChar(DataObject dataObject, String path, char value) - { - Property property = dataObject.getType().getProperty(path); - if (property != null) - { - dataObject.set(property, DataObjectUtil.getSetValue(property, value)); - } - else - { - DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); - accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); - } - } - - public static void setBytes(DataObject dataObject, String path, byte[] value) - { - Property property = dataObject.getType().getProperty(path); - if (property != null) - { - dataObject.set(property, DataObjectUtil.getSetValue(property, value)); - } - else - { - DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); - accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); - } - } - - public static void setByte(DataObject dataObject, String path, byte value) - { - Property property = dataObject.getType().getProperty(path); - if (property != null) - { - dataObject.set(property, DataObjectUtil.getSetValue(property, value)); - } - else - { - DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); - accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); - } - } - - public static void setBoolean(DataObject dataObject, String path, boolean value) - { - Property property = dataObject.getType().getProperty(path); - if (property != null) - { - dataObject.set(property, DataObjectUtil.getSetValue(property, value)); - } - else - { - DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); - accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); - } - } - - public static void setBigInteger(DataObject dataObject, String path, BigInteger value) - { - Property property = dataObject.getType().getProperty(path); - if (property != null) - { - dataObject.set(property, DataObjectUtil.getSetValue(property, value)); - } - else - { - DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); - accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); - } - } - - public static void setBigDecimal(DataObject dataObject, String path, BigDecimal value) - { - Property property = dataObject.getType().getProperty(path); - if (property != null) - { - dataObject.set(property, DataObjectUtil.getSetValue(property, value)); - } - else - { - DataObjectUtil.Accessor accessor = DataObjectUtil.Accessor.create((EObject)dataObject, path); - accessor.setAndRecyle(DataObjectUtil.getSetValue(accessor.getProperty(), value)); - } - } - - public static DataGraph getDataGraph(DataObject dataObject) - { - Resource resource = ((EObject)dataObject).eResource(); - if (resource != null) - { - ResourceSet resourceSet = resource.getResourceSet(); - if (resourceSet != null) - { - return (DataGraphImpl)EcoreUtil.getAdapter(resourceSet.eAdapters(), DataGraph.class); - } - } - return null; - } - - public static ChangeSummary getChangeSummary(DataObject dataObject) - { - DataGraph dataGraph = getDataGraph(dataObject); - if (dataGraph != null) - { - return dataGraph.getChangeSummary(); - } - // TODO: handle ChangeSummary-type property - return null; - } - - public static void unset(DataObject dataObject, String path) - { - Property property = dataObject.getType().getProperty(path); - if (property != null) - { - dataObject.unset(property); - } - else - { - DataObjectUtil.Accessor.create((EObject)dataObject, path).unsetAndRecyle(); - } - } - - public static boolean isSet(DataObject dataObject, String path) - { - Property property = dataObject.getType().getProperty(path); - if (property != null) - { - return dataObject.isSet(property); - } - else - { - return DataObjectUtil.Accessor.create( - (EObject)dataObject, path).isSetAndRecyle(); - } - } - - public static void set(DataObject dataObject, String path, Object value) - { - Property property = dataObject.getType().getProperty(path); - if (property != null) - { - dataObject.set(property, value); - } - else - { - DataObjectUtil.Accessor.create( - (EObject)dataObject, path).setAndRecyle(value); - } - } - - public static Object get(DataObject dataObject, String path) - { - Property property = dataObject.getType().getProperty(path); - if (property != null) { - return dataObject.get(property); - } else { - return Accessor.create((EObject)dataObject, path).getAndRecyle(); - } - } - - public static BigDecimal getBigDecimal(Object value) - { - if (value instanceof BigDecimal) - { - return (BigDecimal)value; - } - - if (value instanceof BigInteger) - { - return new BigDecimal((BigInteger)value); - } - - if (value instanceof Number) - { - return new BigDecimal(((Number)value).doubleValue()); - } - - if (value instanceof String) - { - return new BigDecimal((String)value); - } - - if (value == null) - { - return null; - } - - throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to BigDecimal"); - } - - public static Object getSetValue(Property property, BigDecimal value) - { - EStructuralFeature eStructuralFeature = (EStructuralFeature)property; - EClassifier eType = eStructuralFeature.getEType(); - if (value == null) - { - return eType.getDefaultValue(); - } - - String name = eType.getInstanceClassName(); - if (name == "java.math.BigDecimal") - { - return value; - } - - if (name == "java.math.BigInteger") - { - return value.toBigInteger(); - } - - if (name == "java.lang.Byte" || name == "byte") - { - return new Byte(value.byteValue()); - } - - if (name == "java.lang.Double" || name == "double") - { - return new Double(value.doubleValue()); - } - - if (name == "java.lang.Float" || name == "float") - { - return new Float(value.floatValue()); - } - - if (name == "java.lang.Integer" || name == "int") - { - return new Integer(value.intValue()); - } - - if (name == "java.lang.Long" || name == "long") - { - return new Long(value.longValue()); - } - - if (name == "java.lang.Short" || name == "short") - { - return new Short(value.shortValue()); - } - - if (name == "java.lang.String") - { - return String.valueOf(value); - } - - //Instead of throwing an IllegalArgumentException we will pass the value to the property - return value; - } - - public static BigInteger getBigInteger(Object value) - { - if (value instanceof BigInteger) - { - return (BigInteger)value; - } - - if (value instanceof BigDecimal) - { - return ((BigDecimal)value).toBigInteger(); - } - - if (value instanceof Number) - { - return BigInteger.valueOf(((Number)value).longValue()); - } - - if (value instanceof String) - { - return new BigInteger((String)value); - } - - if (value instanceof byte[]) - { - return new BigInteger((byte[])value); - } - - if (value == null) - { - return null; - } - - throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to BigInteger"); - } - - public static Object getSetValue(Property property, BigInteger value) - { - EStructuralFeature eStructuralFeature = (EStructuralFeature)property; - EClassifier eType = eStructuralFeature.getEType(); - if (value == null) - { - return eType.getDefaultValue(); - } - - String name = eType.getInstanceClassName(); - if (name == "java.math.BigInteger") - { - return value; - } - - if (name == "java.math.BigDecimal") - { - return new BigDecimal(value); - } - - if (name == "java.lang.Byte" || name == "byte") - { - return new Byte(value.byteValue()); - } - - if (name == "java.lang.Double" || name == "double") - { - return new Double(value.doubleValue()); - } - - if (name == "java.lang.Float" || name == "float") - { - return new Float(value.floatValue()); - } - - if (name == "java.lang.Integer" || name == "int") - { - return new Integer(value.intValue()); - } - - if (name == "java.lang.Long" || name == "long") - { - return new Long(value.longValue()); - } - - if (name == "java.lang.Short" || name == "short") - { - return new Short(value.shortValue()); - } - - if (name == "java.lang.String") - { - return String.valueOf(value); - } - - if (name == "byte[]") - { - return value.toByteArray(); - } - - //Instead of throwing an IllegalArgumentException we will pass the value to the property - return value; - } - - public static boolean getBoolean(Object value) - { - if (value instanceof Boolean) - { - return ((Boolean)value).booleanValue(); - } - - if (value instanceof String) - { - return Boolean.valueOf((String)value).booleanValue(); - } - - if (value == null) - { - return false; - } - - throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to boolean"); - } - - public static Object getSetValue(Property property, boolean value) - { - EStructuralFeature eStructuralFeature = (EStructuralFeature)property; - String name = eStructuralFeature.getEType().getInstanceClassName(); - if (name == "java.lang.Boolean" || name == "boolean") - { - return value ? Boolean.TRUE : Boolean.FALSE; - } - - if (name == "java.lang.String") - { - return String.valueOf(value); - } - - //Instead of throwing an IllegalArgumentException we will pass the value to the property - return value ? Boolean.TRUE : Boolean.FALSE; - } - - public static byte getByte(Object value) - { - if (value instanceof Number) - { - return ((Number)value).byteValue(); - } - - if (value instanceof String) - { - return Byte.parseByte((String)value); - } - - if (value == null) - { - return 0; - } - - throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to byte"); - } - - public static Object getSetValue(Property property, byte value) - { - EStructuralFeature eStructuralFeature = (EStructuralFeature)property; - String name = eStructuralFeature.getEType().getInstanceClassName(); - if (name == "java.lang.Byte" || name == "byte") - { - return new Byte(value); - } - - if (name == "java.lang.Double" || name == "double") - { - return new Double(value); - } - - if (name == "java.lang.Float" || name == "float") - { - return new Float(value); - } - - if (name == "java.lang.Integer" || name == "int") - { - return new Integer(value); - } - - if (name == "java.lang.Long" || name == "long") - { - return new Long(value); - } - - if (name == "java.lang.Short" || name == "short") - { - return new Short(value); - } - - if (name == "java.math.BigDecimal") - { - return getBigDecimal(new Byte(value)); - } - - if (name == "java.math.BigInteger") - { - return getBigInteger(new Byte(value)); - } - - if (name == "java.lang.String") - { - return String.valueOf(value); - } - - //Instead of throwing an IllegalArgumentException we will pass the value to the property - return new Byte(value); - } - - public static byte[] getBytes(Object value) - { - if (value instanceof byte[]) - { - return (byte[])value; - } - - if (value instanceof BigInteger) - { - return ((BigInteger)value).toByteArray(); - } - - if (value == null) - { - return null; - } - - throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to byte array"); - } - - public static Object getSetValue(Property property, byte[] value) - { - EStructuralFeature eStructuralFeature = (EStructuralFeature)property; - EClassifier eType = eStructuralFeature.getEType(); - if (value == null) - { - return eType.getDefaultValue(); - } - - String name = eType.getInstanceClassName(); - if (name == "byte[]") - { - return value; - } - - if (name == "java.math.BigInteger") - { - return new BigInteger(value); - } - - //Instead of throwing an IllegalArgumentException we will pass the value to the property - return value; - } - - public static char getChar(Object value) - { - if (value instanceof Character) - { - return ((Character)value).charValue(); - } - - if (value instanceof String) - { - return ((String)value).charAt(0); - } - - if (value == null) - { - return 0; - } - - throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to char"); - } - - public static Object getSetValue(Property property, char value) - { - EStructuralFeature eStructuralFeature = (EStructuralFeature)property; - String name = eStructuralFeature.getEType().getInstanceClassName(); - if (name == "java.lang.Character" || name == "char") - { - return new Character(value); - } - - if (name == "java.lang.String") - { - return String.valueOf(value); - } - - //Instead of throwing an IllegalArgumentException we will pass the value to the property - return new Character(value); - } - - public static Date getDate(Object value) - { - if (value instanceof XMLCalendar) - { - return ((XMLCalendar)value).getDate(); - } - - if (value instanceof Date) - { - return (Date)value; - } - - if (value instanceof Long) - { - return new Date(((Long)value).longValue()); - } - - if (value == null) - { - return null; - } - - throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to Date"); - } - - public static Object getSetValue(Property property, Date value) - { - EStructuralFeature eStructuralFeature = (EStructuralFeature)property; - EClassifier eType = eStructuralFeature.getEType(); - if (value == null) - { - return eType.getDefaultValue(); - } - - String name = eType.getInstanceClassName(); - if (name == "java.lang.Object") - { - String typeName = getDateTypeName((EDataType)eType); - if ("Date".equals(typeName)) - { - return new XMLCalendar(value, XMLCalendar.DATE); - } - if ("DateTime".equals(typeName)) - { - return new XMLCalendar(value, XMLCalendar.DATETIME); - } - // Instead of throwing an IllegalArgumentException we will pass the value to the property - return value; - } - - if (name == "java.lang.Long" || name == "long") - { - return new Long(value.getTime()); - } - if (name == "java.lang.String") - { - return value.toString(); - } - - // Instead of throwing an IllegalArgumentException we will pass the value to the property - return value; - } - - protected static String getDateTypeName(EDataType eDataType) - { - String name = eDataType.getName(); - if (("DateTime".equals(name)) || ("Date".equals(name))) - { - return name; - } - - EDataType baseType = ExtendedMetaData.INSTANCE.getBaseType(eDataType); - if (baseType != null) - { - return getDateTypeName(baseType); - } - - List memberTypes = ExtendedMetaData.INSTANCE.getMemberTypes(eDataType); - if (!memberTypes.isEmpty()) - { - for (int i = 0, size = memberTypes.size(); i < size; ++i) - { - EDataType memberType = (EDataType)memberTypes.get(i); - String memberTypeName = getDateTypeName(memberType); - if (("DateTime".equals(memberTypeName)) || ("Date".equals(memberTypeName))) - { - return memberTypeName; - } - } - } - - return ""; - } - - public static double getDouble(Object value) - { - if (value instanceof Number) - { - return ((Number)value).doubleValue(); - } - - if (value instanceof String) - { - return Double.parseDouble((String)value); - } - - if (value == null) - { - return 0; - } - - throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to double"); - } - - public static Object getSetValue(Property property, double value) - { - EStructuralFeature eStructuralFeature = (EStructuralFeature)property; - String name = eStructuralFeature.getEType().getInstanceClassName(); - if (name == "java.lang.Byte" || name == "byte") - { - return new Byte((byte)value); - } - - if (name == "java.lang.Double" || name == "double") - { - return new Double(value); - } - - if (name == "java.lang.Float" || name == "float") - { - return new Float(value); - } - - if (name == "java.lang.Integer" || name == "int") - { - return new Integer((int)value); - } - - if (name == "java.lang.Long" || name == "long") - { - return new Long((long)value); - } - - if (name == "java.lang.Short" || name == "short") - { - return new Short((short)value); - } - - if (name == "java.math.BigDecimal") - { - return getBigDecimal(new Double(value)); - } - - if (name == "java.math.BigInteger") - { - return getBigInteger(new Double(value)); - } - - if (name == "java.lang.String") - { - return String.valueOf(value); - } - - //Instead of throwing an IllegalArgumentException we will pass the value to the property - return new Double(value); - } - - public static float getFloat(Object value) - { - if (value instanceof Number) - { - return ((Number)value).floatValue(); - } - - if (value instanceof String) - { - return Float.parseFloat((String)value); - } - - if (value == null) - { - return 0; - } - - throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to float"); - } - - public static Object getSetValue(Property property, float value) - { - EStructuralFeature eStructuralFeature = (EStructuralFeature)property; - String name = eStructuralFeature.getEType().getInstanceClassName(); - if (name == "java.lang.Byte" || name == "byte") - { - return new Byte((byte)value); - } - - if (name == "java.lang.Double" || name == "double") - { - return new Double(value); - } - - if (name == "java.lang.Float" || name == "float") - { - return new Float(value); - } - - if (name == "java.lang.Integer" || name == "int") - { - return new Integer((int)value); - } - - if (name == "java.lang.Long" || name == "long") - { - return new Long((long)value); - } - - if (name == "java.lang.Short" || name == "short") - { - return new Short((short)value); - } - - if (name == "java.math.BigDecimal") - { - return getBigDecimal(new Float(value)); - } - - if (name == "java.math.BigInteger") - { - return getBigInteger(new Float(value)); - } - - if (name == "java.lang.String") - { - return String.valueOf(value); - } - - // Instead of throwing an IllegalArgumentException we will pass the value to the property - return new Float(value); - } - - public static int getInt(Object value) - { - if (value instanceof Number) - { - return ((Number)value).intValue(); - } - - if (value instanceof String) - { - return Integer.parseInt((String)value); - } - - if (value == null) - { - return 0; - } - - throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to int"); - } - - public static Object getSetValue(Property property, int value) - { - EStructuralFeature eStructuralFeature = (EStructuralFeature)property; - String name = eStructuralFeature.getEType().getInstanceClassName(); - if (name == "java.lang.Byte" || name == "byte") - { - return new Byte((byte)value); - } - - if (name == "java.lang.Double" || name == "double") - { - return new Double(value); - } - - if (name == "java.lang.Float" || name == "float") - { - return new Float(value); - } - - if (name == "java.lang.Integer" || name == "int") - { - return new Integer(value); - } - - if (name == "java.lang.Long" || name == "long") - { - return new Long(value); - } - - if (name == "java.lang.Short" || name == "short") - { - return new Short((short)value); - } - - if (name == "java.math.BigDecimal") - { - return getBigDecimal(new Integer(value)); - } - - if (name == "java.math.BigInteger") - { - return getBigInteger(new Integer(value)); - } - - if (name == "java.lang.String") - { - return String.valueOf(value); - } - - // Instead of throwing an IllegalArgumentException we will pass the value to the property - return new Integer(value); - } - - public static long getLong(Object value) - { - if (value instanceof Number) - { - return ((Number)value).longValue(); - } - - if (value instanceof String) - { - return Long.parseLong((String)value); - } - - if (value instanceof Date) - { - return ((Date)value).getTime(); - } - - if (value == null) - { - return 0; - } - - throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to long"); - } - - public static Object getSetValue(Property property, long value) - { - EStructuralFeature eStructuralFeature = (EStructuralFeature)property; - String name = eStructuralFeature.getEType().getInstanceClassName(); - if (name == "java.lang.Byte" || name == "byte") - { - return new Byte((byte)value); - } - - if (name == "java.lang.Double" || name == "double") - { - return new Double(value); - } - - if (name == "java.lang.Float" || name == "float") - { - return new Float(value); - } - - if (name == "java.lang.Integer" || name == "int") - { - return new Integer((int)value); - } - - if (name == "java.lang.Long" || name == "long") - { - return new Long(value); - } - - if (name == "java.lang.Short" || name == "short") - { - return new Short((short)value); - } - - if (name == "java.math.BigDecimal") - { - return getBigDecimal(new Long(value)); - } - - if (name == "java.math.BigInteger") - { - return getBigInteger(new Long(value)); - } - - if (name == "java.lang.String") - { - return String.valueOf(value); - } - - if (name == "java.util.Date") - { - return new Date(value); - } - - // Instead of throwing an IllegalArgumentException we will pass the value to the property - return new Long(value); - } - - public static short getShort(Object value) - { - if (value instanceof Number) - { - return ((Number)value).shortValue(); - } - - if (value instanceof String) - { - return Short.parseShort((String)value); - } - - if (value == null) - { - return 0; - } - - throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to short"); - } - - public static Object getSetValue(Property property, short value) - { - EStructuralFeature eStructuralFeature = (EStructuralFeature)property; - String name = eStructuralFeature.getEType().getInstanceClassName(); - if (name == "java.lang.Byte" || name == "byte") - { - return new Byte((byte)value); - } - - if (name == "java.lang.Double" || name == "double") - { - return new Double(value); - } - - if (name == "java.lang.Float" || name == "float") - { - return new Float(value); - } - - if (name == "java.lang.Integer" || name == "int") - { - return new Integer(value); - } - - if (name == "java.lang.Long" || name == "long") - { - return new Long(value); - } - - if (name == "java.lang.Short" || name == "short") - { - return new Short(value); - } - - if (name == "java.math.BigDecimal") - { - return getBigDecimal(new Short(value)); - } - - if (name == "java.math.BigInteger") - { - return getBigInteger(new Short(value)); - } - - if (name == "java.lang.String") - { - return String.valueOf(value); - } - - // Instead of throwing an IllegalArgumentException we will pass the value to the property - return new Short(value); - } - - public static String getString(Object value) - { - if (value instanceof String) - { - return (String)value; - } - - if (value instanceof Number || value instanceof Boolean || value instanceof Character) - { - return String.valueOf(value); - } - - if (value == null) - { - return null; - } - - throw new IllegalArgumentException("The value of type '" + value.getClass().getName() + "' cannot be converted to String"); - } - - public static Object getSetValue(Property property, String value) - { - EStructuralFeature eStructuralFeature = (EStructuralFeature)property; - EClassifier eType = eStructuralFeature.getEType(); - if (value == null) - { - return eType.getDefaultValue(); - } - - String name = eType.getInstanceClassName(); - if (name == "java.lang.String") - { - return value; - } - - if (name == "java.lang.Byte" || name == "byte") - { - return Byte.valueOf(value); - } - - if (name == "java.lang.Double" || name == "double" || name == "java.lang.Number") - { - return Double.valueOf(value); - } - - if (name == "java.lang.Float" || name == "float") - { - return new Float(value); - } - - if (name == "java.lang.Integer" || name == "int") - { - return Integer.valueOf(value); - } - - if (name == "java.lang.Long" || name == "long") - { - return Long.valueOf(value); - } - - if (name == "java.lang.Short" || name == "short") - { - return Short.valueOf(value); - } - - if (name == "java.lang.Character" || name == "char") - { - return new Character(value.charAt(0)); - } - - if (name == "java.math.BigDecimal") - { - return getBigDecimal(value); - } - - if (name == "java.math.BigInteger") - { - return getBigInteger(value); - } - - if (name == "java.lang.Boolean" || name == "boolean") - { - return Boolean.valueOf(value); - } - - // Instead of throwing an IllegalArgumentException we will pass the value to the property - return value; - } - - public static EStructuralFeature getOpenFeature(EObject eObject, int featureID) - { - EClass eClass = eObject.eClass(); - int openFeatureCount = featureID - eClass.getFeatureCount(); - Set openFeatureSet = new HashSet(); - for (int i = 0, count = eClass.getEAllStructuralFeatures().size(); i < count; ++i) - { - EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature(i); - if (!eStructuralFeature.isDerived() && FeatureMapUtil.isFeatureMap(eStructuralFeature)) - { - List features = (List)eObject.eGet(eStructuralFeature); - for (int j = 0, size = features.size(); j < size; ++j) - { - FeatureMap.Entry entry = (FeatureMap.Entry)features.get(j); - EStructuralFeature entryFeature = entry.getEStructuralFeature(); - if (openFeatureSet.add(entryFeature)) - { - if (--openFeatureCount < 0) return entryFeature; - } - } - } - } - throw new IndexOutOfBoundsException(); - } - - public static EStructuralFeature getOpenFeature(EObject eObject, String featureName) - { - EClass eClass = eObject.eClass(); - Set openFeatureSet = new HashSet(); - for (int i = 0, count = eClass.getEAllStructuralFeatures().size(); i < count; ++i) - { - EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature(i); - if (/*!eStructuralFeature.isDerived() && */FeatureMapUtil.isFeatureMap(eStructuralFeature)) - { - List features = (List)eObject.eGet(eStructuralFeature); - for (int j = 0, size = features.size(); j < size; ++j) - { - FeatureMap.Entry entry = (FeatureMap.Entry)features.get(j); - EStructuralFeature entryFeature = entry.getEStructuralFeature(); - if (openFeatureSet.add(entryFeature)) - { - Property property = (Property)entryFeature; - if (property.getName().equals(featureName)) return entryFeature; - - List aliasNames = property.getAliasNames(); - for (int aliasCount = aliasNames.size(); aliasCount > 0; ) - { - if (aliasNames.get(--aliasCount).equals(featureName)) return entryFeature; - } - } - } - } - } - throw new IllegalArgumentException("Class '" + eObject.eClass().getName() + "' does not have a feature named '" + featureName + "'"); - } - - public static List getAliasNames(EStructuralFeature eStructuralFeature) - { - List list = SDOExtendedMetaData.INSTANCE.getAliasNames(eStructuralFeature); - if (list == null) { - list = new ArrayList(); - } - return list; - } - - public static List getAliasNames(EClassifier eClassifier) - { - List list = SDOExtendedMetaData.INSTANCE.getAliasNames(eClassifier); - if (list == null) { - list = new ArrayList(); - } - return list; - } - - /** - * Process the default EMF path and minimal XPath syntax. - * This design is still under review and construction. - * - * Syntax: - * - *<pre> - * path = /? (step '/')* step - * step = feature - * | feature '.' index_from_0 - * | feature '[' index_from_1 ']' - * | reference '[' attribute '=' value ']' - * | .. - * | '@' step - *</pre> - * - * feature = the name of an attribute or reference - * attribute = the name of an attribute - * reference = the name of a reference - * index = positive integer - * value = the string value of an attribute - * leading / begins at the root - * .. is containing object - * - * features must be multi-valued to use '.' and '[' operations. - * Only the last step may have an attribute as the feature. - */ - public static final class Accessor //TODO rewrite this using SDO APIs - { - /** - * Creates an accessor for the path of the object. - */ - public static Accessor create(EObject eObject, String path) - { - Accessor result = pool.get(); - result.init(eObject, path); - return result; - } - - /** - * Only the get and recycle methods should be call; they are the only synchronized methods. - */ - protected static class Pool extends BasicEList - { - protected Accessor[] accessors; - - public Pool() - { - super(10); - } - - protected Object[] newData(int capacity) - { - return accessors = new Accessor [capacity]; - } - - /** - * Returns a recyled instance or a new instance. - */ - public synchronized Accessor get() - { - if (size > 0) - { - return accessors[--size]; - } - else - { - return new Accessor(); - } - } - - /** Safely gives the accessor back for recycled use. - */ - public synchronized void recycle(Accessor accessor) - { - int minimumCapacity = size + 1; - if (minimumCapacity > data.length) - { - grow(minimumCapacity); - } - accessors[size++] = accessor; - } - } - - /** - * A static thread safe pool of Accessors. - */ - static final Pool pool = new Pool(); - - protected static final int NO_INDEX = -1; - - protected EObject eObject; - - protected EStructuralFeature feature; - - protected int index; - - protected Accessor() - { - } - - protected Accessor(EObject eObject, String path) - { - init(eObject, path); - } - - protected void init(EObject eObject, String path) - { - this.eObject = eObject; - - // This should only be called with a path right now. - // - //feature = getType(eObject).getProperty(path).getEStructuralFeature(); - //if (feature == null) - { - process(path); - } - //else - { - //index = NO_INDEX; - } - } - - public Object get() - { - if (feature == null) - { - return eObject; - } - else - { - Object value = eObject.eGet(feature, true); - if (index >= 0) - { - value = ((List)value).get(index); - if (value instanceof FeatureMap.Entry) - { - value = ((FeatureMap.Entry)value).getValue(); - } - } - else if (FeatureMapUtil.isFeatureMap(feature)) - { - value = new BasicSequence((FeatureMap.Internal)value); - } - return value; - } - } - - public Object getAndRecyle() - { - Object result = get(); - pool.recycle(this); - return result; - } - - public void set(Object newValue) - { - if (index >= 0) - { - List list = (List)eObject.eGet(feature, true); - list.set(index, newValue); - } - else - { - // EATM newValue = string2Enum(feature, newValue); - eObject.eSet(feature, newValue); - } - } - - public void setAndRecyle(Object newValue) - { - set(newValue); - pool.recycle(this); - } - - public boolean isSet() - { - return eObject.eIsSet(feature); - } - - public boolean isSetAndRecyle() - { - boolean result = isSet(); - pool.recycle(this); - return result; - } - - public void unset() - { - eObject.eUnset(feature); - } - - public void unsetAndRecyle() - { - unset(); - pool.recycle(this); - } - - public void recycle() - { - pool.recycle(this); - } - - public EObject getEObject() - { - return eObject; - } - - protected void setEObject(EObject eObject) - { - this.eObject = eObject; - feature = null; - index = NO_INDEX; - } - - public EStructuralFeature getEStructuralFeature() - { - return feature; - } - - public Property getProperty() - { - return (Property)feature; - } - - protected void setFeatureName(String name) - { - if (name != null) - { - feature = (EStructuralFeature)((DataObject)eObject).getProperty(name); - } - else - { - feature = null; - } - index = NO_INDEX; - } - - protected int getIndex() - { - return index; - } - - protected void setIndex(int index) - { - this.index = index; - if (!FeatureMapUtil.isMany(eObject, feature)) - { - throw new IndexOutOfBoundsException("Index applies only to multi-valued features."); - } - } - - protected void process(String pathString) - { - TokenList tokens = new TokenList(pathString.toCharArray()); - String token; - int size = tokens.size(); - int x = 0; - - if ("/".equals(tokens.peek(0))) - { - setEObject(EcoreUtil.getRootContainer(eObject)); - x++; - } - - for (; x < size; x++) - { - token = tokens.peek(x); - char c = token.charAt(0); - if ('/' == c) - { - setEObject((EObject)get()); - } - else if ("..".equals(token)) - { - EObject container = eObject.eContainer(); - if (container == null) - { - throw new IllegalArgumentException("No containing object for " + eObject); - } - setEObject(container); - } - else if ('.' == c) - { - x++; // skip . - token = tokens.peek(x); - int index = Integer.parseInt(token); - setIndex(index); - } - else if ('[' == c) - { - x++; // skip [ - token = tokens.peek(x); // name or index - char following = tokens.peek(x + 1).charAt(0); - if ('=' != following) - { - int index = Integer.parseInt(token) - 1; - setIndex(index); - x++; // skip ] - } - else - { - x++; // done name - x++; // skip = - String attributeValue = tokens.peek(x); // value - if ("\"".equals(attributeValue)) - { - x++; // skip " - attributeValue = tokens.peek(++x); - } - x++; // skip ] - int index = matchingIndex((List)get(), token, attributeValue); - if (index < 0) - { - setEObject(null); - } - else - { - setIndex(index); - } - } - } - else if ('@' == c) - { - x++; // skip @ - } - else - { - setFeatureName(token); - } - } - } - - protected static int matchingIndex(List eObjects, String attributeName, String attributeValue) - { - for (int i = 0, size = eObjects.size(); i < size; i++) - { - EObject eObject = (EObject)eObjects.get(i); - EStructuralFeature feature = (EStructuralFeature)((Type)eObject.eClass()).getProperty(attributeName); - if (feature != null) - { - Object test = eObject.eGet(feature, true); - if (test != null) - { - String testString = EcoreUtil.convertToString((EDataType)feature.getEType(), test); - if (attributeValue.equals(testString)) - { - return i; - } - } - } - } - return -1; - } - - protected static class TokenList extends BasicEList - { - public TokenList(char[] path) - { - super(4); - - int pathLength = path.length; - StringBuffer token = new StringBuffer(); - char cPrev; - char c = 0; - char cNext; - char stringConstant = 0; - for (int pos = 0; pos < pathLength; pos++) - { - cPrev = c; - c = path[pos]; - cNext = pos < pathLength - 1 ? path[pos + 1] : 0; - - if (stringConstant != 0) - { - if (c == stringConstant) - { - endToken(token, true); - stringConstant = 0; - } - else - { - token.append(c); - } - } - else - { - switch (c) - { - case ' ': - case 0xA: - case 0xD: - case 0x9: - if (cPrev != ' ') - { - endToken(token, false); - } - c = ' '; - break; - - case '"': - case '\'': - endToken(token, false); - stringConstant = c; - break; - - // double or single tokens - case '/': - case ':': - case '.': - if (cPrev != c) - { - endToken(token, false); - } - token.append(c); - if (cNext != c) - { - endToken(token, false); - } - break; - - // single tokens - case '*': - case '@': - case '[': - case ']': - case '(': - case ')': - case '|': - endToken(token, false); - add(String.valueOf(c)); - break; - - // TODO: < > <= >= + - != - case '!': - endToken(token, false); - token.append(c); - break; - - case '=': - endToken(token, false); - add(String.valueOf(c)); - break; - - default: - token.append(c); - } - } - } - endToken(token, false); - } - - public String peek() - { - return size > 0 ? (String)data[0] : " "; - } - - public String peek(int index) - { - return index < size ? (String)data[index] : " "; - } - - public TokenList pop() - { - remove(0); - return this; - } - - public TokenList pop(int count) - { - while (count-- > 0) - { - remove(count); - } - return this; - } - - protected void endToken(StringBuffer token, boolean includeEmpty) - { - if (includeEmpty || token.length() > 0) - { - add(token.toString()); - } - token.setLength(0); - } - - protected boolean canContainNull() - { - return false; - } - - protected Object[] newData(int capacity) - { - return new String [capacity]; - } - } - - public String toString() - { - StringBuffer result = new StringBuffer("Accessor (object:"); - result.append(eObject == null ? "null" : eObject.toString()); - result.append(", feature:"); - result.append(feature == null ? "null" : feature.getName()); - result.append(", index:"); - result.append(index); - result.append(")"); - return result.toString(); - } - } - - public static Type getType(DataObject dataObject, String namespaceURI, String typeName) - { - DataGraph dataGraph = dataObject.getDataGraph(); - if (dataGraph != null) - { - return dataGraph.getType(namespaceURI, typeName); - } - else - { - //TODO think about where else to find the type - return TypeHelper.INSTANCE.getType(namespaceURI, typeName); - } - } - - public static Property getProperty(DataObject dataObject, String propertyName) - { - Property property = dataObject.getType().getProperty(propertyName); - if (property == null) - { - property = (Property)DataObjectUtil.getOpenFeature((EObject)dataObject, propertyName); - //throw new IllegalArgumentException("Type '" + dataObject.getType().getName() + "' does not have a property named '" + propertyName + "'"); - } - - return property; - } - - public static Property getProperty(DataObject dataObject, int propertyIndex) - { - List typeProperties = dataObject.getType().getProperties(); - - Property property = propertyIndex < typeProperties.size() ? - (Property)typeProperties.get(propertyIndex) : - (Property)dataObject.getInstanceProperties().get(propertyIndex); - - //FB maybe should catch bad index exception and throw IllegalArgumentException? - return property; - } - - public static Property getContainmentProperty(Property property) - { - if (property.isContainment()) - { - return property; - } - throw new IllegalArgumentException("The property '" + property.getName() + "' of '" + property.getContainingType().getName() - + "' isn't a containment"); - } - - public static DataObject create(Type type) - { - return (DataObject)EcoreUtil.create((EClass)type); - } - - public static ResourceSet createResourceSet() - { - ResourceSet result = new ResourceSetImpl(); - configureResourceSet(result); - return result; - } - - protected static Map registrations; - - protected static Map getRegistrations() - { - if (registrations == null) - { - Map result = new HashMap(); - - if (!(Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.datagraph")) instanceof DataGraphResourceFactoryImpl)) - { - result.put("datagraph", new DataGraphResourceFactoryImpl()); - } - if (!(Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.ecore")) instanceof EcoreResourceFactoryImpl)) - { - result.put("ecore", new EcoreResourceFactoryImpl()); - } - - if (!(Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.emof")) instanceof EMOFResourceFactoryImpl)) - { - result.put("emof", new EMOFResourceFactoryImpl()); - } - - if (Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.xsd")) == null) - { - result.put("xsd", new XSDResourceFactoryImpl()); - } - - //FIXME ClassCastException in XSDHelper.define() if you give it a WSDL file - // Patch for JIRA TUSCANY-42 - if (Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.wsdl")) == null) - { - result.put("wsdl", new XSDResourceFactoryImpl()); - } - - if (Resource.Factory.Registry.INSTANCE.getFactory(URI.createURI("*.*")) == null) - { - result.put("*", new XMLResourceFactoryImpl()); - } - - registrations = result; - } - - return registrations; - } - - protected static void configureResourceSet(ResourceSet resourceSet) - { - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().putAll(getRegistrations()); - } - - public static EClass createDocumentRoot() - { - EClass documentRootEClass = EcoreFactory.eINSTANCE.createEClass(); - ExtendedMetaData.INSTANCE.setName(documentRootEClass, ""); - ExtendedMetaData.INSTANCE.setContentKind(documentRootEClass, ExtendedMetaData.MIXED_CONTENT); - - EAttribute mixed = EcoreFactory.eINSTANCE.createEAttribute(); - mixed.setName("mixed"); - mixed.setEType(EcorePackage.eINSTANCE.getEFeatureMapEntry()); - mixed.setUpperBound(EStructuralFeature.UNBOUNDED_MULTIPLICITY); - ExtendedMetaData.INSTANCE.setName(mixed, ":mixed"); - ExtendedMetaData.INSTANCE.setFeatureKind(mixed, ExtendedMetaData.ELEMENT_WILDCARD_FEATURE); - documentRootEClass.getEStructuralFeatures().add(mixed); - - EReference xmlnsPrefixMap = EcoreFactory.eINSTANCE.createEReference(); - xmlnsPrefixMap.setName("xMLNSPrefixMap"); - xmlnsPrefixMap.setEType(EcorePackage.eINSTANCE.getEStringToStringMapEntry()); - xmlnsPrefixMap.setUpperBound(EStructuralFeature.UNBOUNDED_MULTIPLICITY); - xmlnsPrefixMap.setContainment(true); - xmlnsPrefixMap.setTransient(true); - ExtendedMetaData.INSTANCE.setName(xmlnsPrefixMap, "xmlns:prefix"); - ExtendedMetaData.INSTANCE.setFeatureKind(xmlnsPrefixMap, ExtendedMetaData.ATTRIBUTE_FEATURE); - documentRootEClass.getEStructuralFeatures().add(xmlnsPrefixMap); - - EReference xsiSchemaLocation = EcoreFactory.eINSTANCE.createEReference(); - xsiSchemaLocation.setName("xSISchemaLocation"); - xsiSchemaLocation.setEType(EcorePackage.eINSTANCE.getEStringToStringMapEntry()); - xsiSchemaLocation.setUpperBound(EStructuralFeature.UNBOUNDED_MULTIPLICITY); - xsiSchemaLocation.setContainment(true); - xsiSchemaLocation.setTransient(true); - ExtendedMetaData.INSTANCE.setName(xsiSchemaLocation, "xsi:schemaLocation"); - ExtendedMetaData.INSTANCE.setFeatureKind(xsiSchemaLocation, ExtendedMetaData.ATTRIBUTE_FEATURE); - documentRootEClass.getEStructuralFeatures().add(xsiSchemaLocation); - - return documentRootEClass; - } - - /** - * Configure EMF to support the SDO runtime by registering a specialized Ecore factory, SDOEcoreFactory. - * This static initializion must run before any SDO metadata is created or loaded. - * As long as SDO helper classes (e.g., TypeHelper, XMLHelper, etc.) are accessed though their - * corresponding INSTANCE fields (e.g., TypeHelper.INSTANCE), or using the SDOUtil methods (e.g., - * SDOUtil.createTypeHelper(), this will always be the case. - */ - static - { - EPackage.Registry.INSTANCE.put(EcorePackage.eNS_URI, new EPackage.Descriptor() - { - public EPackage getEPackage() - { - return EcorePackage.eINSTANCE; - } - - public EFactory getEFactory() - { - return new SDOFactoryImpl.SDOEcoreFactory(); - } - }); - } - - public static void initRuntime() - { - // NOOP since init is done during static initialization of this class. See above. - } - - /* - public static Object get(org.apache.tuscany.sdo.model.Property property, int propertyIndex) { - switch(propertyIndex) - { - case ModelPackageImpl.PROPERTY__ALIAS_NAME: - return property.getAliasName(); - case ModelPackageImpl.PROPERTY__ANY: - return property.getAny(); - case ModelPackageImpl.PROPERTY__ANY_ATTRIBUTE: - return property.getAnyAttribute(); - case ModelPackageImpl.PROPERTY__CONTAINMENT: - return Boolean.valueOf(property.isContainment()); - case ModelPackageImpl.PROPERTY__DEFAULT: - return property.getDefault_(); - case ModelPackageImpl.PROPERTY__MANY: - return Boolean.valueOf(property.isMany()); - case ModelPackageImpl.PROPERTY__NAME: - return property.getName(); - case ModelPackageImpl.PROPERTY__OPPOSITE: - return property.getOpposite_(); - case ModelPackageImpl.PROPERTY__READ_ONLY: - return Boolean.valueOf(property.isReadOnly()); - case ModelPackageImpl.PROPERTY__TYPE: - return property.getType_(); - } - return null; - } - - public static boolean isSet(org.apache.tuscany.sdo.model.Property property, int propertyIndex) { - switch(propertyIndex) - { - case ModelPackageImpl.PROPERTY__ALIAS_NAME: - return !property.getAliasName().isEmpty(); - case ModelPackageImpl.PROPERTY__ANY: - return false; - case ModelPackageImpl.PROPERTY__ANY_ATTRIBUTE: - return false; - case ModelPackageImpl.PROPERTY__CONTAINMENT: - return property.isSetContainment(); - case ModelPackageImpl.PROPERTY__DEFAULT: - return property.getDefault_() != null; - case ModelPackageImpl.PROPERTY__MANY: - return property.isSetMany(); - case ModelPackageImpl.PROPERTY__NAME: - return property.getName() != null; - case ModelPackageImpl.PROPERTY__OPPOSITE: - return property.getOpposite_() != null; - case ModelPackageImpl.PROPERTY__READ_ONLY: - return property.isSetReadOnly(); - case ModelPackageImpl.PROPERTY__TYPE: - return property.getType_() != null; - } - return false; - } - - public static Object get(org.apache.tuscany.sdo.model.Type type, int propertyIndex) { - switch (propertyIndex) - { - case ModelPackageImpl.TYPE__BASE_TYPE: - return type.getBaseType(); - case ModelPackageImpl.TYPE__PROPERTY: - return type.getProperty(); - case ModelPackageImpl.TYPE__ALIAS_NAME: - return type.getAliasName(); - case ModelPackageImpl.TYPE__ANY: - return type.getAny(); - case ModelPackageImpl.TYPE__ABSTRACT: - return Boolean.valueOf(type.isAbstract()); - case ModelPackageImpl.TYPE__DATA_TYPE: - return Boolean.valueOf(type.isDataType()); - case ModelPackageImpl.TYPE__NAME: - return type.getName(); - case ModelPackageImpl.TYPE__OPEN: - return Boolean.valueOf(type.isOpen()); - case ModelPackageImpl.TYPE__SEQUENCED: - return Boolean.valueOf(type.isSequenced()); - case ModelPackageImpl.TYPE__URI: - return type.getUri(); - case ModelPackageImpl.TYPE__ANY_ATTRIBUTE: - return type.getAnyAttribute(); - } - return null; - } - - public static boolean isSet(org.apache.tuscany.sdo.model.Type type, int propertyIndex) { - //FB Note that this implementation has the undesirable effect of invoking lazy creation of feature lists - switch (propertyIndex) - { - case ModelPackageImpl.TYPE__BASE_TYPE: - return !type.getBaseType().isEmpty(); - case ModelPackageImpl.TYPE__PROPERTY: - return !type.getProperty().isEmpty(); - case ModelPackageImpl.TYPE__ALIAS_NAME: - return !type.getAliasName().isEmpty(); - case ModelPackageImpl.TYPE__ANY: - return false; - case ModelPackageImpl.TYPE__ABSTRACT: - return type.isSetAbstract(); - case ModelPackageImpl.TYPE__DATA_TYPE: - return type.isSetDataType(); - case ModelPackageImpl.TYPE__NAME: - return type.getName() != null; - case ModelPackageImpl.TYPE__OPEN: - return type.isSetOpen(); - case ModelPackageImpl.TYPE__SEQUENCED: - return type.isSetSequenced(); - case ModelPackageImpl.TYPE__URI: - return type.getUri() != null; - case ModelPackageImpl.TYPE__ANY_ATTRIBUTE: - return false; - } - return false; - } - */ - -} diff --git a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/SDOUtil.java b/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/SDOUtil.java deleted file mode 100644 index 834176bfab..0000000000 --- a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/SDOUtil.java +++ /dev/null @@ -1,543 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.sdo.util; - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.lang.reflect.Field; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.security.AccessController; -import java.security.PrivilegedExceptionAction; -import java.util.Collections; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -import org.apache.tuscany.sdo.SDOExtendedMetaData; -import org.apache.tuscany.sdo.SDOFactory; -import org.apache.tuscany.sdo.SDOPackage; -import org.apache.tuscany.sdo.SimpleAnyTypeDataObject; -import org.apache.tuscany.sdo.helper.DataFactoryImpl; -import org.apache.tuscany.sdo.helper.SDOExtendedMetaDataImpl; -import org.apache.tuscany.sdo.helper.TypeHelperImpl; -import org.apache.tuscany.sdo.helper.XMLHelperImpl; -import org.apache.tuscany.sdo.helper.XSDHelperImpl; -import org.apache.tuscany.sdo.impl.DataGraphImpl; -import org.apache.tuscany.sdo.impl.DynamicDataObjectImpl; -import org.apache.tuscany.sdo.model.impl.ModelPackageImpl; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.ETypedElement; -import org.eclipse.emf.ecore.EcoreFactory; -import org.eclipse.emf.ecore.EcorePackage; -import org.eclipse.emf.ecore.impl.EPackageRegistryImpl; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.ecore.util.ExtendedMetaData; -import org.eclipse.emf.ecore.xml.type.XMLTypePackage; - -import commonj.sdo.DataGraph; -import commonj.sdo.DataObject; -import commonj.sdo.Property; -import commonj.sdo.Type; -import commonj.sdo.helper.DataFactory; -import commonj.sdo.helper.TypeHelper; -import commonj.sdo.helper.XMLHelper; -import commonj.sdo.helper.XSDHelper; - -/** - * This class provides some useful static utility functions which are not specified in the SDO - * specification itself. Use of the functions in this class is recommended, instead of resorting - * to low-level implementation-specific APIs. - */ -public final class SDOUtil -{ - /** - * Create a DataObject wrapper for an instance of the specified dataType. - * This method is typically used to create a root object that can be passed to the XMLHelper.save() - * method when the root element to be serialized is an XMLSchema simpleType. - * @param dataType a Type for which isDataType() returns true. - * @param value the instance value. - * @return a DataObject wrapper for the specified value. - */ - public static DataObject createDataTypeWrapper(Type dataType, Object value) - { - SimpleAnyTypeDataObject simpleAnyType = SDOFactory.eINSTANCE.createSimpleAnyTypeDataObject(); - simpleAnyType.setInstanceType((EDataType)dataType); - simpleAnyType.setValue(value); - return simpleAnyType; - } - - /** - * Creates an instance of a data type from the specified string. - * @param dataType a Type, for which isDataType() returns true, to instantiate. - * @param literal the string value of the dataType. - * @return an instance of the dataType. - * @see #convertToString(Type, Object) - */ - public static Object createFromString(Type dataType, String literal) - { - return EcoreUtil.createFromString((EDataType)dataType, literal); - } - - /** - * Converts an instance of a data type to a string literal representation. - * @param dataType the Type, for which isDataType() returns true, of the value to convert. - * @param value a value of the dataType. - * @return the string literal representation of the value. - * @see #createFromString(Type, String) - */ - public static String convertToString(Type dataType, Object value) - { - return EcoreUtil.convertToString((EDataType)dataType, value); - } - - /** - * Get the SDO built-in type corresponding to the specified XSD type in the XML Schema - * namespace ("http://www.w3.org/2001/XMLSchema"). - * @param xsdType a type name in the XML Schema namespace. - * @return the SDO built-in Type corresponding to the specified XSD type. - */ - public static Type getXSDSDOType(String xsdType) - { - Type type = null; - if ("anyType".equals(xsdType)) { - type = (Type)SDOPackage.eINSTANCE.getDataObject(); - } else { - String name = (String)xsdToSdoMappings.get(xsdType); - if (name != null) { - type = (Type)ModelPackageImpl.eINSTANCE.getEClassifier(name); - } else { - type = (Type)SDOExtendedMetaData.INSTANCE.getType(XMLTypePackage.eINSTANCE, xsdType); - } - } - return type; - } - - /** - * Get the SDO built-in type corresponding to the specified Java instanceClass. - * @param javaClass the Java instanceClass of the type. - * @return the SDO built-in Type corresponding to the specified instanceClass. - */ - public static Type getJavaSDOType(Class javaClass) - { - String name = (String)javaToSdoMappings.get(javaClass); - if (name != null) - { - return (Type)ModelPackageImpl.eINSTANCE.getEClassifier(name); - } - return null; - } - - /** - * Create an empty data graph. - * @return the new data graph instance. - */ - public static DataGraph createDataGraph() - { - return SDOFactory.eINSTANCE.createDataGraph(); - } - - /** - * Load a serialized data graph from the specified insputStream. - * @param inputStream the inputStream of the data graph. - * @param options loader control options, or null. - * @return the de-serialized data graph. - * @throws IOException - */ - public static DataGraph loadDataGraph(InputStream inputStream, Map options) throws IOException - { - ResourceSet resourceSet = DataObjectUtil.createResourceSet(); - Resource resource = resourceSet.createResource(URI.createURI("all.datagraph")); - resource.load(inputStream, options); - return (DataGraph)resource.getContents().get(0); - } - - /** - * Serialize the specified data graph to the specified outputStream. - * @param dataGraph the data graph to save. - * @param outputStream the outputStream for the data graph. - * @param options serializer control options, or null. - * @throws IOException - */ - public static void saveDataGraph(DataGraph dataGraph, OutputStream outputStream, Map options) throws IOException - { - ((DataGraphImpl)dataGraph).getDataGraphResource().save(outputStream, options); - } - - /** - * Create a new TypeHelper instance. The returned type helper will have visibility of types registered - * directly by calling a define method on it or by calling define on an associated XSDHelper. It will - * also have visibility of static types registered by calling SDOUtil.registerStaticTypes in the - * same classLoader scope. - * @return the new TypeHelper. - */ - public static TypeHelper createTypeHelper() - { - EPackage.Registry registry = new EPackageRegistryImpl(EPackage.Registry.INSTANCE); - ExtendedMetaData extendedMetaData = new SDOExtendedMetaDataImpl(registry); //TODO create subclass that makes demand() methods synchronous - return new TypeHelperImpl(extendedMetaData); - } - - /** - * Create a new DataFactory, with visibility to types in the specified TypeHelper scope. - * @param scope the TypeHelper to use for locating types. - * @return the new DataFactory. - */ - public static DataFactory createDataFactory(TypeHelper scope) - { - return new DataFactoryImpl(scope); - } - - /** - * Create a new XMLHelper, with visibility to types in the specified TypeHelper scope. - * @param scope the TypeHelper to use for locating types. - * @return the new XMLHelper. - */ - public static XMLHelper createXMLHelper(TypeHelper scope) - { - return new XMLHelperImpl(scope); - } - - /** - * Create a new XSDHelper, with visibility to types in the specified TypeHelper scope. - * @param scope the TypeHelper to use for locating and populating types. - * @return the new XSDHelper. - */ - public static XSDHelper createXSDHelper(TypeHelper scope) - { - return new XSDHelperImpl(scope); - } - - public static Type createType(TypeHelper scope, String uri, String name, boolean isDataType) - { - ExtendedMetaData extendedMetaData = ((TypeHelperImpl)scope).getExtendedMetaData(); - - EPackage ePackage = extendedMetaData.getPackage(uri); - if (ePackage == null) - { - ePackage = EcoreFactory.eINSTANCE.createEPackage(); - ePackage.setEFactoryInstance(new DynamicDataObjectImpl.FactoryImpl()); - ePackage.setNsURI(uri); - String packagePrefix = URI.createURI(uri).trimFileExtension().lastSegment(); - ePackage.setName(packagePrefix); - ePackage.setNsPrefix(packagePrefix); - extendedMetaData.putPackage(uri, ePackage); - } - - EClassifier eClassifier = ePackage.getEClassifier(name); - if (eClassifier != null) - throw new IllegalArgumentException(); // already defined - - if (name != null) - { - eClassifier = isDataType ? (EClassifier)SDOFactory.eINSTANCE.createDataType() : (EClassifier)SDOFactory.eINSTANCE.createClass(); - eClassifier.setName(name); - } - else - { - eClassifier = DataObjectUtil.createDocumentRoot(); - } - - ePackage.getEClassifiers().add(eClassifier); - - return (Type)eClassifier; - } - - public static void addBaseType(Type type, Type baseType) - { - ((EClass)type).getESuperTypes().add(baseType); - } - - public static void addAliasName(Type type, String aliasName) - { - throw new UnsupportedOperationException(); // TODO: implement this method properly - //type.getAliasNames().add(aliasName); - } - - public static void setOpen(Type type, boolean isOpen) - { - if (isOpen == type.isOpen()) return; - - if (isOpen) - { - EAttribute eAttribute = EcoreFactory.eINSTANCE.createEAttribute(); - ((EClass)type).getEStructuralFeatures().add(eAttribute); - - eAttribute.setName("any"); - eAttribute.setUnique(false); - eAttribute.setUpperBound(ETypedElement.UNBOUNDED_MULTIPLICITY); - eAttribute.setEType(EcorePackage.eINSTANCE.getEFeatureMapEntry()); - ExtendedMetaData.INSTANCE.setFeatureKind(eAttribute, ExtendedMetaData.ELEMENT_WILDCARD_FEATURE); - ExtendedMetaData.INSTANCE.setProcessingKind(eAttribute, ExtendedMetaData.LAX_PROCESSING); - ExtendedMetaData.INSTANCE.setWildcards(eAttribute, Collections.singletonList("##any")); - - if (type.isSequenced()) { - eAttribute.setDerived(true); - eAttribute.setTransient(true); - eAttribute.setVolatile(true); - } - } - else - { - EClass eClass = (EClass)type; - EAttribute any = (EAttribute)eClass.getEStructuralFeature("any"); - eClass.getEStructuralFeatures().remove(any); - } - } - - public static void setSequenced(Type type, boolean isSequenced) - { - if (isSequenced == type.isSequenced()) return; - - // currently, we require setSequenced to be called first, before anything else is added to the type. - if (type.isDataType() || !type.getProperties().isEmpty()) - { - if (type.getName() != null) // document root is a special case - throw new IllegalArgumentException(); - } - - if (isSequenced) { - EClass eClass = (EClass)type; - ExtendedMetaData.INSTANCE.setContentKind(eClass, ExtendedMetaData.MIXED_CONTENT); - EAttribute mixedFeature = EcoreFactory.eINSTANCE.createEAttribute(); - mixedFeature.setName("mixed"); - mixedFeature.setUnique(false); - mixedFeature.setEType(EcorePackage.eINSTANCE.getEFeatureMapEntry()); - mixedFeature.setLowerBound(0); - mixedFeature.setUpperBound(-1); - eClass.getEStructuralFeatures().add(mixedFeature); - ExtendedMetaData.INSTANCE.setFeatureKind(mixedFeature, ExtendedMetaData.ELEMENT_WILDCARD_FEATURE); - ExtendedMetaData.INSTANCE.setName(mixedFeature, ":mixed"); - } - else - { - // nothing to do, because of current restriction that setSequence must be called first. - } - } - - public static void setAbstract(Type type, boolean isAbstract) - { - ((EClass)type).setAbstract(isAbstract); - } - - public static void setJavaClassName(Type type, String javaClassName) - { - ((EClassifier)type).setInstanceClassName(javaClassName); - } - - public static Property createProperty(Type containingType, String name, Type propertyType) - { - EStructuralFeature eStructuralFeature = propertyType.isDataType() ? (EStructuralFeature)SDOFactory.eINSTANCE.createAttribute() : (EStructuralFeature)SDOFactory.eINSTANCE.createReference(); - eStructuralFeature.setName(name); - eStructuralFeature.setEType((EClassifier)propertyType); - if (containingType.getName() == null) - { - ExtendedMetaData.INSTANCE.setFeatureKind(eStructuralFeature, ExtendedMetaData.ELEMENT_FEATURE); - } - ((EClass)containingType).getEStructuralFeatures().add(eStructuralFeature); - - if (containingType.isSequenced()) { - eStructuralFeature.setDerived(true); - eStructuralFeature.setTransient(true); - eStructuralFeature.setVolatile(true); - } - - return (Property)eStructuralFeature; - } - - public static void addAliasName(Property property, String aliasName) - { - throw new UnsupportedOperationException(); // TODO: implement this method properly - //property.getAliasNames().add(aliasName); - } - - public static void setMany(Property property, boolean isMany) - { - ((EStructuralFeature)property).setUpperBound(isMany ? EStructuralFeature.UNBOUNDED_MULTIPLICITY : 1); - } - - public static void setContainment(Property property, boolean isContainment) - { - ((EReference)property).setContainment(isContainment); - } - - public static void setDefault(Property property, String defaultValue) - { - ((EStructuralFeature)property).setDefaultValueLiteral(defaultValue); - } - - public static void setReadOnly(Property property, boolean isReadOnly) - { - ((EStructuralFeature)property).setChangeable(!isReadOnly); - } - - public static void setOpposite(Property property, Property opposite) - { - ((EReference)property).setEOpposite((EReference)opposite); - } - - /** - * Register and initialize the SDO types supported by the specified generated factory class. - * This function must be called before instances of the generated types can be created/used. - * The registered types will be visible in all TypeHelper's created in the same classLoader - * scope as the call to this function. - * @param factoryClass the generated factory class. - */ - public static void registerStaticTypes(Class factoryClass) - { - //TODO this implementation is temporary, until the SDO generated factory pattern is decided - // - String temp = factoryClass.getName().replaceFirst("Factory$", "PackageImpl"); - int lastDot = temp.lastIndexOf('.'); - String packageName = temp.substring(0, lastDot) + ".impl" + temp.substring(lastDot); - try // this case handles the current default generator pattern - { - Class javaClass = getPackageClass(factoryClass, packageName); - Field field = javaClass.getField("eINSTANCE"); - field.get(null); - } - catch (Exception e1) - { - packageName = factoryClass.getName().replaceFirst("Factory$", "Package"); - try // this case handles the -noInterfaces generator pattern - { - Class javaClass = getPackageClass(factoryClass, packageName); - Field field = javaClass.getField("eINSTANCE"); - field.get(null); - } - catch (Exception e2) - { - try // this case handles the -noEMF generator pattern - { - Field field = factoryClass.getField("INSTANCE"); - field.get(null); - } - catch (Exception e3) - { - e3.printStackTrace(); - } - } - } - } - - private static Class getPackageClass(Class factoryClass, String packageName) throws Exception - { - final Class factoryClassTemp = factoryClass; - final String packageNameTemp = packageName; - return (Class)AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Object run() throws Exception { - return factoryClassTemp.getClassLoader().loadClass(packageNameTemp); - } - }); - } - - //Java instance class to SDO mappings (p.69 - p.71 of the SDO spec) - private static Map javaToSdoMappings = new HashMap(); - static { - javaToSdoMappings.put(boolean.class, "Boolean"); - javaToSdoMappings.put(byte.class, "Byte"); - javaToSdoMappings.put(char.class, "Character"); - javaToSdoMappings.put(Date.class, "Date"); - javaToSdoMappings.put(BigDecimal.class, "Decimal"); - javaToSdoMappings.put(double.class, "Double"); - javaToSdoMappings.put(float.class, "Float"); - javaToSdoMappings.put(int.class, "Int"); - javaToSdoMappings.put(BigInteger.class, "Integer"); - javaToSdoMappings.put(long.class, "Long"); - javaToSdoMappings.put(Object.class, "Object"); - javaToSdoMappings.put(short.class, "Short"); - javaToSdoMappings.put(String.class, "String"); - javaToSdoMappings.put(Boolean.class, "BooleanObject"); - javaToSdoMappings.put(Byte.class, "ByteObject"); - javaToSdoMappings.put(Character.class, "CharacterObject"); - javaToSdoMappings.put(Double.class, "DoubleObject"); - javaToSdoMappings.put(Float.class, "FloatObject"); - javaToSdoMappings.put(Integer.class, "IntObject"); - javaToSdoMappings.put(Long.class, "LongObject"); - javaToSdoMappings.put(Short.class, "ShortObject"); - } - - //XSD to SDO mappings (p.95 of the SDO spec) - private static Map xsdToSdoMappings = new HashMap(); - static { - xsdToSdoMappings.put("anySimpleType", "Object"); - xsdToSdoMappings.put("anyType", "DataObject"); - xsdToSdoMappings.put("anyURI", "URI"); - xsdToSdoMappings.put("base64Binary", "Bytes"); - xsdToSdoMappings.put("boolean", "Boolean"); - xsdToSdoMappings.put("byte", "Byte"); - xsdToSdoMappings.put("date", "YearMonthDay"); - xsdToSdoMappings.put("dateTime", "DateTime"); - xsdToSdoMappings.put("decimal", "Decimal"); - xsdToSdoMappings.put("double", "Double"); - xsdToSdoMappings.put("duration", "Duration"); - xsdToSdoMappings.put("ENTITIES", "Strings"); - xsdToSdoMappings.put("ENTITY", "String"); - xsdToSdoMappings.put("float", "Float"); - xsdToSdoMappings.put("gDay", "Day"); - xsdToSdoMappings.put("gMonth", "Month"); - xsdToSdoMappings.put("gMonthDay", "MonthDay"); - xsdToSdoMappings.put("gYear", "Year"); - xsdToSdoMappings.put("gYearMonth", "YearMonth"); - xsdToSdoMappings.put("hexBinary", "Bytes"); - xsdToSdoMappings.put("ID","String"); - xsdToSdoMappings.put("IDREF","String"); - xsdToSdoMappings.put("IDREFS","Strings"); - xsdToSdoMappings.put("int","Int"); - xsdToSdoMappings.put("integer","Integer"); - xsdToSdoMappings.put("language","String"); - xsdToSdoMappings.put("long","Long"); - xsdToSdoMappings.put("Name","String"); - xsdToSdoMappings.put("NCName","String"); - xsdToSdoMappings.put("negativeInteger","Integer"); - xsdToSdoMappings.put("NMTOKEN","String"); - xsdToSdoMappings.put("NMTOKENS","Strings"); - xsdToSdoMappings.put("nonNegativeInteger","Integer"); - xsdToSdoMappings.put("nonPositiveInteger","Integer"); - xsdToSdoMappings.put("normalizedString","String"); - xsdToSdoMappings.put("NOTATION","String"); - xsdToSdoMappings.put("positiveInteger","Integer"); - xsdToSdoMappings.put("QName","URI"); - xsdToSdoMappings.put("short","Short"); - xsdToSdoMappings.put("string","String"); - xsdToSdoMappings.put("time","Time"); - xsdToSdoMappings.put("token","String"); - xsdToSdoMappings.put("unsignedByte","Short"); - xsdToSdoMappings.put("unsignedInt","Long"); - xsdToSdoMappings.put("unsignedLong","Integer"); - xsdToSdoMappings.put("unsignedShort","Int"); - } - - /** - * Initialize SDO runtime. - */ - static - { - DataObjectUtil.initRuntime(); - } - -} diff --git a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/StAX2SAXAdapter.java b/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/StAX2SAXAdapter.java deleted file mode 100644 index 858d445640..0000000000 --- a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/StAX2SAXAdapter.java +++ /dev/null @@ -1,242 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.sdo.util; - -import javax.xml.namespace.QName; -import javax.xml.stream.Location; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.xml.sax.Attributes; -import org.xml.sax.ContentHandler; -import org.xml.sax.Locator; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.AttributesImpl; - -/** - * Adapter that converts from StAX to SAX event streams. - * Currently the following SAX events are not generated: - * <ul> - * <li>ignorableWhitespace</li> - * <li>skippedEntity</li> - * <ul> - * Also the following StAX events are not mapped: - * <ul> - * <li>CDATA</li> - * <li>COMMENT</li> - * <li>DTD</li> - * <li>ENTITY_DECLARATION</li> - * <li>ENTITY_REFERENCE</li> - * <li>NOTATION_DECLARATION</li> - * <li>SPACE</li> - * </ul> - * StAX ATTRIBUTE events are ignored but the equivalent attributes (derived from the START_ELEMENT event) - * are supplied in the SAX startElement event's Attributes parameter. If the adaptor is configured to - * pass namespace prefixes then namespace information will also be included in the Attributes; - * StAX NAMESPACE events are ignored. - * - * @version $Rev$ $Date$ - */ -public class StAX2SAXAdapter { - private final boolean namespacePrefixes; - - /** - * Construct a new StAX to SAX adapter that will convert a StAX event stream into a SAX event stream. - * - * @param namespacePrefixes whether xmlns attributes should be included in startElement events; - */ - public StAX2SAXAdapter(boolean namespacePrefixes) { - this.namespacePrefixes = namespacePrefixes; - } - - /** - * Pull events from the StAX stream and dispatch to the SAX ContentHandler. - * The StAX stream would typically be located on a START_DOCUMENT or START_ELEMENT event - * and when this method returns it will be located on the associated END_DOCUMENT or - * END_ELEMENT event. Behaviour with other start events is undefined. - * - * @param reader StAX event source to read - * @param handler SAX ContentHandler for processing events - * @throws XMLStreamException if there was a problem reading the stream - * @throws SAXException passed through from the ContentHandler - */ - public void parse(XMLStreamReader reader, ContentHandler handler) throws XMLStreamException, SAXException { - handler.setDocumentLocator(new LocatorAdaptor(reader.getLocation())); - - // remembers the nest level of elements to know when we are done - int level = 0; - int event = reader.getEventType(); - while (true) { - switch (event) { - case XMLStreamConstants.START_DOCUMENT: - level++; - handler.startDocument(); - break; - case XMLStreamConstants.START_ELEMENT: - level++; - handleStartElement(reader, handler); - break; - case XMLStreamConstants.PROCESSING_INSTRUCTION: - handler.processingInstruction(reader.getPITarget(), reader.getPIData()); - break; - case XMLStreamConstants.CHARACTERS: - char[] chars = reader.getTextCharacters(); - handler.characters(chars, 0, chars.length); - break; - case XMLStreamConstants.END_ELEMENT: - handleEndElement(reader, handler); - level--; - if (level == 0) { - return; - } - break; - case XMLStreamConstants.END_DOCUMENT: - handler.endDocument(); - return; -/* uncomment to handle all events rather than just mapped ones - // StAX events that are not mapped to SAX - case XMLStreamConstants.COMMENT: - case XMLStreamConstants.SPACE: - case XMLStreamConstants.ENTITY_REFERENCE: - case XMLStreamConstants.DTD: - case XMLStreamConstants.CDATA: - case XMLStreamConstants.NOTATION_DECLARATION: - case XMLStreamConstants.ENTITY_DECLARATION: - break; - // StAX events handled in START_ELEMENT - case XMLStreamConstants.ATTRIBUTE: - case XMLStreamConstants.NAMESPACE: - break; - default: - throw new AssertionError("Unknown StAX event: " + event); -*/ - } - event = reader.next(); - } - } - - private void handleStartElement(XMLStreamReader reader, ContentHandler handler) throws SAXException { - // send startPrefixMapping events immediately before startElement event - int nsCount = reader.getNamespaceCount(); - for (int i = 0; i < nsCount; i++) { - String prefix = reader.getNamespacePrefix(i); - if (prefix == null) { // true for default namespace - prefix = ""; - } - handler.startPrefixMapping(prefix, reader.getNamespaceURI(i)); - } - - // fire startElement - QName qname = reader.getName(); - String prefix = qname.getPrefix(); - String rawname; - if (prefix == null || prefix.length() == 0) { - rawname = qname.getLocalPart(); - } else { - rawname = prefix + ':' + qname.getLocalPart(); - } - Attributes attrs = getAttributes(reader); - handler.startElement(qname.getNamespaceURI(), qname.getLocalPart(), rawname, attrs); - } - - private static void handleEndElement(XMLStreamReader reader, ContentHandler handler) throws SAXException { - // fire endElement - QName qname = reader.getName(); - handler.endElement(qname.getNamespaceURI(), qname.getLocalPart(), qname.toString()); - - // send endPrefixMapping events immediately after endElement event - // we send them in the opposite order to that returned but this is not actually required by SAX - int nsCount = reader.getNamespaceCount(); - for (int i = nsCount - 1; i >= 0; i--) { - String prefix = reader.getNamespacePrefix(i); - if (prefix == null) { // true for default namespace - prefix = ""; - } - handler.endPrefixMapping(prefix); - } - } - - /** - * Get the attributes associated with the current START_ELEMENT event. - * - * @return the StAX attributes converted to org.xml.sax.Attributes - */ - private Attributes getAttributes(XMLStreamReader reader) { - assert reader.getEventType() == XMLStreamConstants.START_ELEMENT; - - AttributesImpl attrs = new AttributesImpl(); - - // add namespace declarations if required - if (namespacePrefixes) { - for (int i = 0; i < reader.getNamespaceCount(); i++) { - String prefix = reader.getNamespacePrefix(i); - String uri = reader.getNamespaceURI(i); - attrs.addAttribute(null, prefix, "xmlns:" + prefix, "CDATA", uri); - } - } - - // Regular attributes - for (int i = 0; i < reader.getAttributeCount(); i++) { - String uri = reader.getAttributeNamespace(i); - if (uri == null) { - uri = ""; - } - String localName = reader.getAttributeLocalName(i); - String prefix = reader.getAttributePrefix(i); - String qname; - if (prefix == null || prefix.length() == 0) { - qname = localName; - } else { - qname = prefix + ':' + localName; - } - String type = reader.getAttributeType(i); - String value = reader.getAttributeValue(i); - - attrs.addAttribute(uri, localName, qname, type, value); - } - - return attrs; - } - - /** - * Adaptor for mapping Locator information. - */ - private static class LocatorAdaptor implements Locator { - private final Location location; - - private LocatorAdaptor(Location location) { - this.location = location; - } - - public int getColumnNumber() { - return location.getColumnNumber(); - } - - public int getLineNumber() { - return location.getLineNumber(); - } - - public String getPublicId() { - return location.getPublicId(); - } - - public String getSystemId() { - return location.getSystemId(); - } - } -}
\ No newline at end of file diff --git a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/JavaMetaData.java b/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/JavaMetaData.java deleted file mode 100644 index 4dd00c075d..0000000000 --- a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/JavaMetaData.java +++ /dev/null @@ -1,85 +0,0 @@ -/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tuscany.sdo.util.metadata;
-
-
-/**
- * <!-- begin-user-doc -->
- * A representation of the model object '<em><b>Java Meta Data</b></em>'.
- * <!-- end-user-doc -->
- *
- * <p>
- * The following features are supported:
- * <ul>
- * <li>{@link org.apache.tuscany.sdo.util.metadata.JavaMetaData#getFactoryInterface <em>Factory Interface</em>}</li>
- * <li>{@link org.apache.tuscany.sdo.util.metadata.JavaMetaData#getTypeInterface <em>Type Interface</em>}</li>
- * </ul>
- * </p>
- *
- * @generated
- */
-public interface JavaMetaData
-{
- /**
- * Returns the value of the '<em><b>Factory Interface</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Factory Interface</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Factory Interface</em>' attribute.
- * @see #setFactoryInterface(String)
- * @generated
- */
- String getFactoryInterface();
-
- /**
- * Sets the value of the '{@link org.apache.tuscany.sdo.util.metadata.JavaMetaData#getFactoryInterface <em>Factory Interface</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Factory Interface</em>' attribute.
- * @see #getFactoryInterface()
- * @generated
- */
- void setFactoryInterface(String value);
-
- /**
- * Returns the value of the '<em><b>Type Interface</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Type Interface</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Type Interface</em>' attribute.
- * @see #setTypeInterface(String)
- * @generated
- */
- String getTypeInterface();
-
- /**
- * Sets the value of the '{@link org.apache.tuscany.sdo.util.metadata.JavaMetaData#getTypeInterface <em>Type Interface</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Type Interface</em>' attribute.
- * @see #getTypeInterface()
- * @generated
- */
- void setTypeInterface(String value);
-
-} // JavaMetaData
\ No newline at end of file diff --git a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/MetadataFactory.java b/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/MetadataFactory.java deleted file mode 100644 index e2c33713d3..0000000000 --- a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/MetadataFactory.java +++ /dev/null @@ -1,73 +0,0 @@ -/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tuscany.sdo.util.metadata;
-
-
-/**
- * <!-- begin-user-doc -->
- * The <b>Factory</b> for the model.
- * It provides a create method for each non-abstract class of the model.
- * <!-- end-user-doc -->
- * @generated
- */
-public interface MetadataFactory
-{
- /**
- * The singleton instance of the factory.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- MetadataFactory INSTANCE = org.apache.tuscany.sdo.util.metadata.impl.MetadataFactoryImpl.eINSTANCE;
-
- /**
- * Returns a new object of class '<em>Java Meta Data</em>'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return a new object of class '<em>Java Meta Data</em>'.
- * @generated
- */
- JavaMetaData createJavaMetaData();
-
- /**
- * Returns a new object of class '<em>SDO Meta Data Group</em>'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return a new object of class '<em>SDO Meta Data Group</em>'.
- * @generated
- */
- SDOMetaDataGroup createSDOMetaDataGroup();
-
- /**
- * Returns a new object of class '<em>Type Meta Data</em>'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return a new object of class '<em>Type Meta Data</em>'.
- * @generated
- */
- TypeMetaData createTypeMetaData();
-
- /**
- * Returns a new object of class '<em>XSD Meta Data</em>'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return a new object of class '<em>XSD Meta Data</em>'.
- * @generated
- */
- XSDMetaData createXSDMetaData();
-
-} //MetadataFactory
diff --git a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/SDOMetaDataGroup.java b/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/SDOMetaDataGroup.java deleted file mode 100644 index 7cbeeda682..0000000000 --- a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/SDOMetaDataGroup.java +++ /dev/null @@ -1,86 +0,0 @@ -/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tuscany.sdo.util.metadata;
-
-import java.util.List;
-
-import commonj.sdo.helper.TypeHelper;
-
-/**
- * <!-- begin-user-doc -->
- * A representation of the model object '<em><b>SDO Meta Data Group</b></em>'.
- * <!-- end-user-doc -->
- *
- * <p>
- * The following features are supported:
- * <ul>
- * <li>{@link org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getJavaMetaData <em>Java Meta Data</em>}</li>
- * <li>{@link org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getXsdMetaData <em>Xsd Meta Data</em>}</li>
- * <li>{@link org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getTypeMetaData <em>Type Meta Data</em>}</li>
- * </ul>
- * </p>
- *
- * @generated
- */
-public interface SDOMetaDataGroup
-{
- /**
- * Returns the value of the '<em><b>Java Meta Data</b></em>' containment reference list.
- * The list contents are of type {@link org.apache.tuscany.sdo.util.metadata.JavaMetaData}.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Java Meta Data</em>' containment reference list isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Java Meta Data</em>' containment reference list.
- * @generated
- */
- List getJavaMetaData();
-
- /**
- * Returns the value of the '<em><b>Xsd Meta Data</b></em>' containment reference list.
- * The list contents are of type {@link org.apache.tuscany.sdo.util.metadata.XSDMetaData}.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Xsd Meta Data</em>' containment reference list isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Xsd Meta Data</em>' containment reference list.
- * @generated
- */
- List getXsdMetaData();
-
- /**
- * Returns the value of the '<em><b>Type Meta Data</b></em>' containment reference list.
- * The list contents are of type {@link org.apache.tuscany.sdo.util.metadata.TypeMetaData}.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Type Meta Data</em>' containment reference list isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Type Meta Data</em>' containment reference list.
- * @generated
- */
- List getTypeMetaData();
-
- void register(TypeHelper scope);
- void register(TypeHelper scope, ClassLoader classLoader);
-
-} // SDOMetaDataGroup
\ No newline at end of file diff --git a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/TypeMetaData.java b/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/TypeMetaData.java deleted file mode 100644 index bc311015ec..0000000000 --- a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/TypeMetaData.java +++ /dev/null @@ -1,60 +0,0 @@ -/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tuscany.sdo.util.metadata;
-
-
-/**
- * <!-- begin-user-doc -->
- * A representation of the model object '<em><b>Type Meta Data</b></em>'.
- * <!-- end-user-doc -->
- *
- * <p>
- * The following features are supported:
- * <ul>
- * <li>{@link org.apache.tuscany.sdo.util.metadata.TypeMetaData#getLocation <em>Location</em>}</li>
- * </ul>
- * </p>
- *
- * @generated
- */
-public interface TypeMetaData
-{
- /**
- * Returns the value of the '<em><b>Location</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Location</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Location</em>' attribute.
- * @see #setLocation(String)
- * @generated
- */
- String getLocation();
-
- /**
- * Sets the value of the '{@link org.apache.tuscany.sdo.util.metadata.TypeMetaData#getLocation <em>Location</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Location</em>' attribute.
- * @see #getLocation()
- * @generated
- */
- void setLocation(String value);
-
-} // TypeMetaData
\ No newline at end of file diff --git a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/XSDMetaData.java b/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/XSDMetaData.java deleted file mode 100644 index dc004a8f5e..0000000000 --- a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/XSDMetaData.java +++ /dev/null @@ -1,60 +0,0 @@ -/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tuscany.sdo.util.metadata;
-
-
-/**
- * <!-- begin-user-doc -->
- * A representation of the model object '<em><b>XSD Meta Data</b></em>'.
- * <!-- end-user-doc -->
- *
- * <p>
- * The following features are supported:
- * <ul>
- * <li>{@link org.apache.tuscany.sdo.util.metadata.XSDMetaData#getLocation <em>Location</em>}</li>
- * </ul>
- * </p>
- *
- * @generated
- */
-public interface XSDMetaData
-{
- /**
- * Returns the value of the '<em><b>Location</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <p>
- * If the meaning of the '<em>Location</em>' attribute isn't clear,
- * there really should be more of a description here...
- * </p>
- * <!-- end-user-doc -->
- * @return the value of the '<em>Location</em>' attribute.
- * @see #setLocation(String)
- * @generated
- */
- String getLocation();
-
- /**
- * Sets the value of the '{@link org.apache.tuscany.sdo.util.metadata.XSDMetaData#getLocation <em>Location</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @param value the new value of the '<em>Location</em>' attribute.
- * @see #getLocation()
- * @generated
- */
- void setLocation(String value);
-
-} // XSDMetaData
\ No newline at end of file diff --git a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/JavaMetaDataImpl.java b/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/JavaMetaDataImpl.java deleted file mode 100644 index b36d7fa8f9..0000000000 --- a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/JavaMetaDataImpl.java +++ /dev/null @@ -1,241 +0,0 @@ -/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tuscany.sdo.util.metadata.impl;
-
-import org.apache.tuscany.sdo.impl.DataObjectImpl;
-
-import org.apache.tuscany.sdo.util.metadata.JavaMetaData;
-
-import org.eclipse.emf.common.notify.Notification;
-
-import org.eclipse.emf.ecore.EClass;
-
-import org.eclipse.emf.ecore.impl.ENotificationImpl;
-
-/**
- * <!-- begin-user-doc -->
- * An implementation of the model object '<em><b>Java Meta Data</b></em>'.
- * <!-- end-user-doc -->
- * <p>
- * The following features are implemented:
- * <ul>
- * <li>{@link org.apache.tuscany.sdo.util.metadata.impl.JavaMetaDataImpl#getFactoryInterface <em>Factory Interface</em>}</li>
- * <li>{@link org.apache.tuscany.sdo.util.metadata.impl.JavaMetaDataImpl#getTypeInterface <em>Type Interface</em>}</li>
- * </ul>
- * </p>
- *
- * @generated
- */
-public class JavaMetaDataImpl extends DataObjectImpl implements JavaMetaData
-{
- /**
- * The default value of the '{@link #getFactoryInterface() <em>Factory Interface</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getFactoryInterface()
- * @generated
- * @ordered
- */
- protected static final String FACTORY_INTERFACE_EDEFAULT = null;
-
- /**
- * The cached value of the '{@link #getFactoryInterface() <em>Factory Interface</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getFactoryInterface()
- * @generated
- * @ordered
- */
- protected String factoryInterface = FACTORY_INTERFACE_EDEFAULT;
-
- /**
- * The default value of the '{@link #getTypeInterface() <em>Type Interface</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getTypeInterface()
- * @generated
- * @ordered
- */
- protected static final String TYPE_INTERFACE_EDEFAULT = null;
-
- /**
- * The cached value of the '{@link #getTypeInterface() <em>Type Interface</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getTypeInterface()
- * @generated
- * @ordered
- */
- protected String typeInterface = TYPE_INTERFACE_EDEFAULT;
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- protected JavaMetaDataImpl()
- {
- super();
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- protected EClass eStaticClass()
- {
- return MetadataPackageImpl.Literals.JAVA_META_DATA;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public String getFactoryInterface()
- {
- return factoryInterface;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public void setFactoryInterface(String newFactoryInterface)
- {
- String oldFactoryInterface = factoryInterface;
- factoryInterface = newFactoryInterface;
- if (eNotificationRequired())
- eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackageImpl.JAVA_META_DATA__FACTORY_INTERFACE, oldFactoryInterface, factoryInterface));
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public String getTypeInterface()
- {
- return typeInterface;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public void setTypeInterface(String newTypeInterface)
- {
- String oldTypeInterface = typeInterface;
- typeInterface = newTypeInterface;
- if (eNotificationRequired())
- eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackageImpl.JAVA_META_DATA__TYPE_INTERFACE, oldTypeInterface, typeInterface));
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public Object eGet(int featureID, boolean resolve, boolean coreType)
- {
- switch (featureID)
- {
- case MetadataPackageImpl.JAVA_META_DATA__FACTORY_INTERFACE:
- return getFactoryInterface();
- case MetadataPackageImpl.JAVA_META_DATA__TYPE_INTERFACE:
- return getTypeInterface();
- }
- return super.eGet(featureID, resolve, coreType);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public void eSet(int featureID, Object newValue)
- {
- switch (featureID)
- {
- case MetadataPackageImpl.JAVA_META_DATA__FACTORY_INTERFACE:
- setFactoryInterface((String)newValue);
- return;
- case MetadataPackageImpl.JAVA_META_DATA__TYPE_INTERFACE:
- setTypeInterface((String)newValue);
- return;
- }
- super.eSet(featureID, newValue);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public void eUnset(int featureID)
- {
- switch (featureID)
- {
- case MetadataPackageImpl.JAVA_META_DATA__FACTORY_INTERFACE:
- setFactoryInterface(FACTORY_INTERFACE_EDEFAULT);
- return;
- case MetadataPackageImpl.JAVA_META_DATA__TYPE_INTERFACE:
- setTypeInterface(TYPE_INTERFACE_EDEFAULT);
- return;
- }
- super.eUnset(featureID);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean eIsSet(int featureID)
- {
- switch (featureID)
- {
- case MetadataPackageImpl.JAVA_META_DATA__FACTORY_INTERFACE:
- return FACTORY_INTERFACE_EDEFAULT == null ? factoryInterface != null : !FACTORY_INTERFACE_EDEFAULT.equals(factoryInterface);
- case MetadataPackageImpl.JAVA_META_DATA__TYPE_INTERFACE:
- return TYPE_INTERFACE_EDEFAULT == null ? typeInterface != null : !TYPE_INTERFACE_EDEFAULT.equals(typeInterface);
- }
- return super.eIsSet(featureID);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public String toString()
- {
- if (eIsProxy()) return super.toString();
-
- StringBuffer result = new StringBuffer(super.toString());
- result.append(" (factoryInterface: ");
- result.append(factoryInterface);
- result.append(", typeInterface: ");
- result.append(typeInterface);
- result.append(')');
- return result.toString();
- }
-
-} //JavaMetaDataImpl
\ No newline at end of file diff --git a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/MetadataFactoryImpl.java b/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/MetadataFactoryImpl.java deleted file mode 100644 index e0e24fc9c2..0000000000 --- a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/MetadataFactoryImpl.java +++ /dev/null @@ -1,174 +0,0 @@ -/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tuscany.sdo.util.metadata.impl;
-
-import org.apache.tuscany.sdo.util.metadata.*;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-
-import org.eclipse.emf.ecore.impl.EFactoryImpl;
-
-import org.eclipse.emf.ecore.plugin.EcorePlugin;
-
-/**
- * <!-- begin-user-doc -->
- * An implementation of the model <b>Factory</b>.
- * <!-- end-user-doc -->
- * @generated
- */
-public class MetadataFactoryImpl extends EFactoryImpl implements MetadataFactory
-{
- /**
- * The singleton instance of the factory.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final MetadataFactoryImpl eINSTANCE = init();
-
- /**
- * Creates the default factory implementation.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static MetadataFactoryImpl init()
- {
- try
- {
- MetadataFactoryImpl theMetadataFactory = (MetadataFactoryImpl)EPackage.Registry.INSTANCE.getEFactory("org.apache.tuscany.sdo/metadata");
- if (theMetadataFactory != null)
- {
- return theMetadataFactory;
- }
- }
- catch (Exception exception)
- {
- EcorePlugin.INSTANCE.log(exception);
- }
- return new MetadataFactoryImpl();
- }
-
- /**
- * Creates an instance of the factory.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public MetadataFactoryImpl()
- {
- super();
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public EObject create(EClass eClass)
- {
- switch (eClass.getClassifierID())
- {
- case MetadataPackageImpl.DOCUMENT_ROOT: return (EObject)createDocumentRoot();
- case MetadataPackageImpl.JAVA_META_DATA: return (EObject)createJavaMetaData();
- case MetadataPackageImpl.SDO_META_DATA_GROUP: return (EObject)createSDOMetaDataGroup();
- case MetadataPackageImpl.TYPE_META_DATA: return (EObject)createTypeMetaData();
- case MetadataPackageImpl.XSD_META_DATA: return (EObject)createXSDMetaData();
- default:
- throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier");
- }
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public EObject createDocumentRoot()
- {
- EObject documentRoot = super.create(MetadataPackageImpl.Literals.DOCUMENT_ROOT);
- return documentRoot;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public JavaMetaData createJavaMetaData()
- {
- JavaMetaDataImpl javaMetaData = new JavaMetaDataImpl();
- return javaMetaData;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public SDOMetaDataGroup createSDOMetaDataGroup()
- {
- SDOMetaDataGroupImpl sdoMetaDataGroup = new SDOMetaDataGroupImpl();
- return sdoMetaDataGroup;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public TypeMetaData createTypeMetaData()
- {
- TypeMetaDataImpl typeMetaData = new TypeMetaDataImpl();
- return typeMetaData;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public XSDMetaData createXSDMetaData()
- {
- XSDMetaDataImpl xsdMetaData = new XSDMetaDataImpl();
- return xsdMetaData;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public MetadataPackageImpl getMetadataPackageImpl()
- {
- return (MetadataPackageImpl)getEPackage();
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @deprecated
- * @generated
- */
- public static MetadataPackageImpl getPackage()
- {
- return MetadataPackageImpl.eINSTANCE;
- }
-
-} //MetadataFactoryImpl
diff --git a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/MetadataPackageImpl.java b/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/MetadataPackageImpl.java deleted file mode 100644 index df1404ddd9..0000000000 --- a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/MetadataPackageImpl.java +++ /dev/null @@ -1,1015 +0,0 @@ -/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tuscany.sdo.util.metadata.impl;
-
-import org.apache.tuscany.sdo.impl.SDOPackageImpl;
-
-import org.apache.tuscany.sdo.model.impl.ModelPackageImpl;
-
-import org.apache.tuscany.sdo.util.metadata.JavaMetaData;
-import org.apache.tuscany.sdo.util.metadata.MetadataFactory;
-import org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup;
-import org.apache.tuscany.sdo.util.metadata.TypeMetaData;
-import org.apache.tuscany.sdo.util.metadata.XSDMetaData;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-
-import org.eclipse.emf.ecore.impl.EPackageImpl;
-
-/**
- * <!-- begin-user-doc -->
- * The <b>Package</b> for the model.
- * It contains accessors for the meta objects to represent
- * <ul>
- * <li>each class,</li>
- * <li>each feature of each class,</li>
- * <li>each enum,</li>
- * <li>and each data type</li>
- * </ul>
- * <!-- end-user-doc -->
- * @see org.apache.tuscany.sdo.util.metadata.MetadataFactory
- * @generated
- */
-public class MetadataPackageImpl extends EPackageImpl
-{
- /**
- * The package name.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final String eNAME = "metadata";
-
- /**
- * The package namespace URI.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final String eNS_URI = "org.apache.tuscany.sdo/metadata";
-
- /**
- * The package namespace name.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final String eNS_PREFIX = "metadata";
-
- /**
- * The singleton instance of the package.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final MetadataPackageImpl eINSTANCE = org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl.init();
-
- /**
- * The meta object id for the '{@link org.apache.tuscany.sdo.util.metadata.impl.DocumentRootImpl <em>Document Root</em>}' class.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see org.apache.tuscany.sdo.util.metadata.impl.DocumentRootImpl
- * @see org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl#getDocumentRoot()
- * @generated
- */
- public static final int DOCUMENT_ROOT = 0;
-
- /**
- * The feature id for the '<em><b>Mixed</b></em>' attribute list.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public static final int DOCUMENT_ROOT__MIXED = 0;
-
- /**
- * The feature id for the '<em><b>XMLNS Prefix Map</b></em>' map.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public static final int DOCUMENT_ROOT__XMLNS_PREFIX_MAP = 1;
-
- /**
- * The feature id for the '<em><b>XSI Schema Location</b></em>' map.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public static final int DOCUMENT_ROOT__XSI_SCHEMA_LOCATION = 2;
-
- /**
- * The feature id for the '<em><b>Sdo Meta Data Group</b></em>' containment reference.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public static final int DOCUMENT_ROOT__SDO_META_DATA_GROUP = 3;
-
- /**
- * The number of structural features of the '<em>Document Root</em>' class.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public static final int DOCUMENT_ROOT_FEATURE_COUNT = 4;
-
- /**
- * The meta object id for the '{@link org.apache.tuscany.sdo.util.metadata.impl.JavaMetaDataImpl <em>Java Meta Data</em>}' class.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see org.apache.tuscany.sdo.util.metadata.impl.JavaMetaDataImpl
- * @see org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl#getJavaMetaData()
- * @generated
- */
- public static final int JAVA_META_DATA = 1;
-
- /**
- * The feature id for the '<em><b>Factory Interface</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public static final int JAVA_META_DATA__FACTORY_INTERFACE = 0;
-
- /**
- * The feature id for the '<em><b>Type Interface</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public static final int JAVA_META_DATA__TYPE_INTERFACE = 1;
-
- /**
- * The number of structural features of the '<em>Java Meta Data</em>' class.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public static final int JAVA_META_DATA_FEATURE_COUNT = 2;
-
- /**
- * The meta object id for the '{@link org.apache.tuscany.sdo.util.metadata.impl.SDOMetaDataGroupImpl <em>SDO Meta Data Group</em>}' class.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see org.apache.tuscany.sdo.util.metadata.impl.SDOMetaDataGroupImpl
- * @see org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl#getSDOMetaDataGroup()
- * @generated
- */
- public static final int SDO_META_DATA_GROUP = 2;
-
- /**
- * The feature id for the '<em><b>Java Meta Data</b></em>' containment reference list.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public static final int SDO_META_DATA_GROUP__JAVA_META_DATA = 0;
-
- /**
- * The feature id for the '<em><b>Xsd Meta Data</b></em>' containment reference list.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public static final int SDO_META_DATA_GROUP__XSD_META_DATA = 1;
-
- /**
- * The feature id for the '<em><b>Type Meta Data</b></em>' containment reference list.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public static final int SDO_META_DATA_GROUP__TYPE_META_DATA = 2;
-
- /**
- * The number of structural features of the '<em>SDO Meta Data Group</em>' class.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public static final int SDO_META_DATA_GROUP_FEATURE_COUNT = 3;
-
- /**
- * The meta object id for the '{@link org.apache.tuscany.sdo.util.metadata.impl.TypeMetaDataImpl <em>Type Meta Data</em>}' class.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see org.apache.tuscany.sdo.util.metadata.impl.TypeMetaDataImpl
- * @see org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl#getTypeMetaData()
- * @generated
- */
- public static final int TYPE_META_DATA = 3;
-
- /**
- * The feature id for the '<em><b>Location</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public static final int TYPE_META_DATA__LOCATION = 0;
-
- /**
- * The number of structural features of the '<em>Type Meta Data</em>' class.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public static final int TYPE_META_DATA_FEATURE_COUNT = 1;
-
- /**
- * The meta object id for the '{@link org.apache.tuscany.sdo.util.metadata.impl.XSDMetaDataImpl <em>XSD Meta Data</em>}' class.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see org.apache.tuscany.sdo.util.metadata.impl.XSDMetaDataImpl
- * @see org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl#getXSDMetaData()
- * @generated
- */
- public static final int XSD_META_DATA = 4;
-
- /**
- * The feature id for the '<em><b>Location</b></em>' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public static final int XSD_META_DATA__LOCATION = 0;
-
- /**
- * The number of structural features of the '<em>XSD Meta Data</em>' class.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- * @ordered
- */
- public static final int XSD_META_DATA_FEATURE_COUNT = 1;
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- private EClass documentRootEClass = null;
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- private EClass javaMetaDataEClass = null;
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- private EClass sdoMetaDataGroupEClass = null;
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- private EClass typeMetaDataEClass = null;
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- private EClass xsdMetaDataEClass = null;
-
- /**
- * Creates an instance of the model <b>Package</b>, registered with
- * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package
- * package URI value.
- * <p>Note: the correct way to create the package is via the static
- * factory method {@link #init init()}, which also performs
- * initialization of the package, or returns the registered package,
- * if one already exists.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see org.eclipse.emf.ecore.EPackage.Registry
- * @see org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl#eNS_URI
- * @see #init()
- * @generated
- */
- private MetadataPackageImpl()
- {
- super(eNS_URI, ((EFactory)MetadataFactory.INSTANCE));
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- private static boolean isInited = false;
-
- /**
- * Creates, registers, and initializes the <b>Package</b> for this
- * model, and for any others upon which it depends. Simple
- * dependencies are satisfied by calling this method on all
- * dependent packages before doing anything else. This method drives
- * initialization for interdependent packages directly, in parallel
- * with this package, itself.
- * <p>Of this package and its interdependencies, all packages which
- * have not yet been registered by their URI values are first created
- * and registered. The packages are then initialized in two steps:
- * meta-model objects for all of the packages are created before any
- * are initialized, since one package's meta-model objects may refer to
- * those of another.
- * <p>Invocation of this method will not affect any packages that have
- * already been initialized.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #eNS_URI
- * @see #createPackageContents()
- * @see #initializePackageContents()
- * @generated
- */
- public static MetadataPackageImpl init()
- {
- if (isInited) return (MetadataPackageImpl)EPackage.Registry.INSTANCE.getEPackage(MetadataPackageImpl.eNS_URI);
-
- // Obtain or create and register package
- MetadataPackageImpl theMetadataPackageImpl = (MetadataPackageImpl)(EPackage.Registry.INSTANCE.getEPackage(eNS_URI) instanceof MetadataPackageImpl ? EPackage.Registry.INSTANCE.getEPackage(eNS_URI) : new MetadataPackageImpl());
-
- isInited = true;
-
- // Initialize simple dependencies
- SDOPackageImpl.eINSTANCE.eClass();
- ModelPackageImpl.eINSTANCE.eClass();
-
- // Create package meta-data objects
- theMetadataPackageImpl.createPackageContents();
-
- // Initialize created meta-data
- theMetadataPackageImpl.initializePackageContents();
-
- // Mark meta-data to indicate it can't be changed
- theMetadataPackageImpl.freeze();
-
- return theMetadataPackageImpl;
- }
-
-
- /**
- * Returns the meta object for class '{@link org.eclipse.emf.ecore.EObject <em>Document Root</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the meta object for class '<em>Document Root</em>'.
- * @see org.eclipse.emf.ecore.EObject
- * @generated
- */
- public EClass getDocumentRoot()
- {
- return documentRootEClass;
- }
-
- /**
- * Returns the meta object for the attribute list '{@link org.eclipse.emf.ecore.EObject#getMixed <em>Mixed</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the meta object for the attribute list '<em>Mixed</em>'.
- * @see org.eclipse.emf.ecore.EObject#getMixed()
- * @see #getDocumentRoot()
- * @generated
- */
- public EAttribute getDocumentRoot_Mixed()
- {
- return (EAttribute)documentRootEClass.getEStructuralFeatures().get(0);
- }
-
- /**
- * Returns the meta object for the map '{@link org.eclipse.emf.ecore.EObject#getXMLNSPrefixMap <em>XMLNS Prefix Map</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the meta object for the map '<em>XMLNS Prefix Map</em>'.
- * @see org.eclipse.emf.ecore.EObject#getXMLNSPrefixMap()
- * @see #getDocumentRoot()
- * @generated
- */
- public EReference getDocumentRoot_XMLNSPrefixMap()
- {
- return (EReference)documentRootEClass.getEStructuralFeatures().get(1);
- }
-
- /**
- * Returns the meta object for the map '{@link org.eclipse.emf.ecore.EObject#getXSISchemaLocation <em>XSI Schema Location</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the meta object for the map '<em>XSI Schema Location</em>'.
- * @see org.eclipse.emf.ecore.EObject#getXSISchemaLocation()
- * @see #getDocumentRoot()
- * @generated
- */
- public EReference getDocumentRoot_XSISchemaLocation()
- {
- return (EReference)documentRootEClass.getEStructuralFeatures().get(2);
- }
-
- /**
- * Returns the meta object for the containment reference '{@link org.eclipse.emf.ecore.EObject#getSdoMetaDataGroup <em>Sdo Meta Data Group</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the meta object for the containment reference '<em>Sdo Meta Data Group</em>'.
- * @see org.eclipse.emf.ecore.EObject#getSdoMetaDataGroup()
- * @see #getDocumentRoot()
- * @generated
- */
- public EReference getDocumentRoot_SdoMetaDataGroup()
- {
- return (EReference)documentRootEClass.getEStructuralFeatures().get(3);
- }
-
- /**
- * Returns the meta object for class '{@link org.apache.tuscany.sdo.util.metadata.JavaMetaData <em>Java Meta Data</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the meta object for class '<em>Java Meta Data</em>'.
- * @see org.apache.tuscany.sdo.util.metadata.JavaMetaData
- * @generated
- */
- public EClass getJavaMetaData()
- {
- return javaMetaDataEClass;
- }
-
- /**
- * Returns the meta object for the attribute '{@link org.apache.tuscany.sdo.util.metadata.JavaMetaData#getFactoryInterface <em>Factory Interface</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the meta object for the attribute '<em>Factory Interface</em>'.
- * @see org.apache.tuscany.sdo.util.metadata.JavaMetaData#getFactoryInterface()
- * @see #getJavaMetaData()
- * @generated
- */
- public EAttribute getJavaMetaData_FactoryInterface()
- {
- return (EAttribute)javaMetaDataEClass.getEStructuralFeatures().get(0);
- }
-
- /**
- * Returns the meta object for the attribute '{@link org.apache.tuscany.sdo.util.metadata.JavaMetaData#getTypeInterface <em>Type Interface</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the meta object for the attribute '<em>Type Interface</em>'.
- * @see org.apache.tuscany.sdo.util.metadata.JavaMetaData#getTypeInterface()
- * @see #getJavaMetaData()
- * @generated
- */
- public EAttribute getJavaMetaData_TypeInterface()
- {
- return (EAttribute)javaMetaDataEClass.getEStructuralFeatures().get(1);
- }
-
- /**
- * Returns the meta object for class '{@link org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup <em>SDO Meta Data Group</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the meta object for class '<em>SDO Meta Data Group</em>'.
- * @see org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup
- * @generated
- */
- public EClass getSDOMetaDataGroup()
- {
- return sdoMetaDataGroupEClass;
- }
-
- /**
- * Returns the meta object for the containment reference list '{@link org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getJavaMetaData <em>Java Meta Data</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the meta object for the containment reference list '<em>Java Meta Data</em>'.
- * @see org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getJavaMetaData()
- * @see #getSDOMetaDataGroup()
- * @generated
- */
- public EReference getSDOMetaDataGroup_JavaMetaData()
- {
- return (EReference)sdoMetaDataGroupEClass.getEStructuralFeatures().get(0);
- }
-
- /**
- * Returns the meta object for the containment reference list '{@link org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getXsdMetaData <em>Xsd Meta Data</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the meta object for the containment reference list '<em>Xsd Meta Data</em>'.
- * @see org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getXsdMetaData()
- * @see #getSDOMetaDataGroup()
- * @generated
- */
- public EReference getSDOMetaDataGroup_XsdMetaData()
- {
- return (EReference)sdoMetaDataGroupEClass.getEStructuralFeatures().get(1);
- }
-
- /**
- * Returns the meta object for the containment reference list '{@link org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getTypeMetaData <em>Type Meta Data</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the meta object for the containment reference list '<em>Type Meta Data</em>'.
- * @see org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup#getTypeMetaData()
- * @see #getSDOMetaDataGroup()
- * @generated
- */
- public EReference getSDOMetaDataGroup_TypeMetaData()
- {
- return (EReference)sdoMetaDataGroupEClass.getEStructuralFeatures().get(2);
- }
-
- /**
- * Returns the meta object for class '{@link org.apache.tuscany.sdo.util.metadata.TypeMetaData <em>Type Meta Data</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the meta object for class '<em>Type Meta Data</em>'.
- * @see org.apache.tuscany.sdo.util.metadata.TypeMetaData
- * @generated
- */
- public EClass getTypeMetaData()
- {
- return typeMetaDataEClass;
- }
-
- /**
- * Returns the meta object for the attribute '{@link org.apache.tuscany.sdo.util.metadata.TypeMetaData#getLocation <em>Location</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the meta object for the attribute '<em>Location</em>'.
- * @see org.apache.tuscany.sdo.util.metadata.TypeMetaData#getLocation()
- * @see #getTypeMetaData()
- * @generated
- */
- public EAttribute getTypeMetaData_Location()
- {
- return (EAttribute)typeMetaDataEClass.getEStructuralFeatures().get(0);
- }
-
- /**
- * Returns the meta object for class '{@link org.apache.tuscany.sdo.util.metadata.XSDMetaData <em>XSD Meta Data</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the meta object for class '<em>XSD Meta Data</em>'.
- * @see org.apache.tuscany.sdo.util.metadata.XSDMetaData
- * @generated
- */
- public EClass getXSDMetaData()
- {
- return xsdMetaDataEClass;
- }
-
- /**
- * Returns the meta object for the attribute '{@link org.apache.tuscany.sdo.util.metadata.XSDMetaData#getLocation <em>Location</em>}'.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the meta object for the attribute '<em>Location</em>'.
- * @see org.apache.tuscany.sdo.util.metadata.XSDMetaData#getLocation()
- * @see #getXSDMetaData()
- * @generated
- */
- public EAttribute getXSDMetaData_Location()
- {
- return (EAttribute)xsdMetaDataEClass.getEStructuralFeatures().get(0);
- }
-
- /**
- * Returns the factory that creates the instances of the model.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @return the factory that creates the instances of the model.
- * @generated
- */
- public MetadataFactory getMetadataFactory()
- {
- return (MetadataFactory)getEFactoryInstance();
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- private boolean isCreated = false;
-
- /**
- * Creates the meta-model objects for the package. This method is
- * guarded to have no affect on any invocation but its first.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public void createPackageContents()
- {
- if (isCreated) return;
- isCreated = true;
-
- // Create classes and their features
- documentRootEClass = createEClass(DOCUMENT_ROOT);
- createEAttribute(documentRootEClass, DOCUMENT_ROOT__MIXED);
- createEReference(documentRootEClass, DOCUMENT_ROOT__XMLNS_PREFIX_MAP);
- createEReference(documentRootEClass, DOCUMENT_ROOT__XSI_SCHEMA_LOCATION);
- createEReference(documentRootEClass, DOCUMENT_ROOT__SDO_META_DATA_GROUP);
-
- javaMetaDataEClass = createEClass(JAVA_META_DATA);
- createEAttribute(javaMetaDataEClass, JAVA_META_DATA__FACTORY_INTERFACE);
- createEAttribute(javaMetaDataEClass, JAVA_META_DATA__TYPE_INTERFACE);
-
- sdoMetaDataGroupEClass = createEClass(SDO_META_DATA_GROUP);
- createEReference(sdoMetaDataGroupEClass, SDO_META_DATA_GROUP__JAVA_META_DATA);
- createEReference(sdoMetaDataGroupEClass, SDO_META_DATA_GROUP__XSD_META_DATA);
- createEReference(sdoMetaDataGroupEClass, SDO_META_DATA_GROUP__TYPE_META_DATA);
-
- typeMetaDataEClass = createEClass(TYPE_META_DATA);
- createEAttribute(typeMetaDataEClass, TYPE_META_DATA__LOCATION);
-
- xsdMetaDataEClass = createEClass(XSD_META_DATA);
- createEAttribute(xsdMetaDataEClass, XSD_META_DATA__LOCATION);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- private boolean isInitialized = false;
-
- /**
- * Complete the initialization of the package and its meta-model. This
- * method is guarded to have no affect on any invocation but its first.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public void initializePackageContents()
- {
- if (isInitialized) return;
- isInitialized = true;
-
- // Initialize package
- setName(eNAME);
- setNsPrefix(eNS_PREFIX);
- setNsURI(eNS_URI);
-
- // Obtain other dependent packages
- ModelPackageImpl theModelPackageImpl = (ModelPackageImpl)EPackage.Registry.INSTANCE.getEPackage(ModelPackageImpl.eNS_URI);
-
- // Add supertypes to classes
-
- // Initialize classes and features; add operations and parameters
- initEClass(documentRootEClass, null, "DocumentRoot", !IS_ABSTRACT, !IS_INTERFACE, !IS_GENERATED_INSTANCE_CLASS);
- initEAttribute(getDocumentRoot_Mixed(), ecorePackage.getEFeatureMapEntry(), "mixed", null, 0, -1, null, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEReference(getDocumentRoot_XMLNSPrefixMap(), ecorePackage.getEStringToStringMapEntry(), null, "xMLNSPrefixMap", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEReference(getDocumentRoot_XSISchemaLocation(), ecorePackage.getEStringToStringMapEntry(), null, "xSISchemaLocation", null, 0, -1, null, IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEReference(getDocumentRoot_SdoMetaDataGroup(), this.getSDOMetaDataGroup(), null, "sdoMetaDataGroup", null, 0, -2, null, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED);
-
- initEClass(javaMetaDataEClass, JavaMetaData.class, "JavaMetaData", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
- initEAttribute(getJavaMetaData_FactoryInterface(), theModelPackageImpl.getString(), "factoryInterface", null, 0, 1, JavaMetaData.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEAttribute(getJavaMetaData_TypeInterface(), theModelPackageImpl.getString(), "typeInterface", null, 0, 1, JavaMetaData.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
-
- initEClass(sdoMetaDataGroupEClass, SDOMetaDataGroup.class, "SDOMetaDataGroup", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
- initEReference(getSDOMetaDataGroup_JavaMetaData(), this.getJavaMetaData(), null, "javaMetaData", null, 0, -1, SDOMetaDataGroup.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEReference(getSDOMetaDataGroup_XsdMetaData(), this.getXSDMetaData(), null, "xsdMetaData", null, 0, -1, SDOMetaDataGroup.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
- initEReference(getSDOMetaDataGroup_TypeMetaData(), this.getTypeMetaData(), null, "typeMetaData", null, 0, -1, SDOMetaDataGroup.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
-
- initEClass(typeMetaDataEClass, TypeMetaData.class, "TypeMetaData", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
- initEAttribute(getTypeMetaData_Location(), theModelPackageImpl.getString(), "location", null, 1, 1, TypeMetaData.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
-
- initEClass(xsdMetaDataEClass, XSDMetaData.class, "XSDMetaData", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
- initEAttribute(getXSDMetaData_Location(), theModelPackageImpl.getString(), "location", null, 1, 1, XSDMetaData.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, !IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
-
- // Create resource
- createResource(eNS_URI);
-
- // Create annotations
- // http:///org/eclipse/emf/ecore/util/ExtendedMetaData
- createExtendedMetaDataAnnotations();
- }
-
- /**
- * Initializes the annotations for <b>http:///org/eclipse/emf/ecore/util/ExtendedMetaData</b>.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- protected void createExtendedMetaDataAnnotations()
- {
- String source = "http:///org/eclipse/emf/ecore/util/ExtendedMetaData";
- addAnnotation
- (documentRootEClass,
- source,
- new String[]
- {
- "name", "",
- "kind", "mixed"
- });
- addAnnotation
- (getDocumentRoot_Mixed(),
- source,
- new String[]
- {
- "kind", "elementWildcard",
- "name", ":mixed"
- });
- addAnnotation
- (getDocumentRoot_XMLNSPrefixMap(),
- source,
- new String[]
- {
- "kind", "attribute",
- "name", "xmlns:prefix"
- });
- addAnnotation
- (getDocumentRoot_XSISchemaLocation(),
- source,
- new String[]
- {
- "kind", "attribute",
- "name", "xsi:schemaLocation"
- });
- addAnnotation
- (getDocumentRoot_SdoMetaDataGroup(),
- source,
- new String[]
- {
- "kind", "element",
- "name", "sdoMetaDataGroup",
- "namespace", "##targetNamespace"
- });
- addAnnotation
- (javaMetaDataEClass,
- source,
- new String[]
- {
- "name", "JavaMetaData",
- "kind", "empty"
- });
- addAnnotation
- (getJavaMetaData_FactoryInterface(),
- source,
- new String[]
- {
- "kind", "attribute",
- "name", "factoryInterface"
- });
- addAnnotation
- (getJavaMetaData_TypeInterface(),
- source,
- new String[]
- {
- "kind", "attribute",
- "name", "typeInterface"
- });
- addAnnotation
- (sdoMetaDataGroupEClass,
- source,
- new String[]
- {
- "name", "SDOMetaDataGroup",
- "kind", "elementOnly"
- });
- addAnnotation
- (getSDOMetaDataGroup_JavaMetaData(),
- source,
- new String[]
- {
- "kind", "element",
- "name", "javaMetaData"
- });
- addAnnotation
- (getSDOMetaDataGroup_XsdMetaData(),
- source,
- new String[]
- {
- "kind", "element",
- "name", "xsdMetaData"
- });
- addAnnotation
- (getSDOMetaDataGroup_TypeMetaData(),
- source,
- new String[]
- {
- "kind", "element",
- "name", "typeMetaData"
- });
- addAnnotation
- (typeMetaDataEClass,
- source,
- new String[]
- {
- "name", "TypeMetaData",
- "kind", "empty"
- });
- addAnnotation
- (getTypeMetaData_Location(),
- source,
- new String[]
- {
- "kind", "attribute",
- "name", "location"
- });
- addAnnotation
- (xsdMetaDataEClass,
- source,
- new String[]
- {
- "name", "XSDMetaData",
- "kind", "empty"
- });
- addAnnotation
- (getXSDMetaData_Location(),
- source,
- new String[]
- {
- "kind", "attribute",
- "name", "location"
- });
- }
-
- /**
- * <!-- begin-user-doc -->
- * Defines literals for the meta objects that represent
- * <ul>
- * <li>each class,</li>
- * <li>each feature of each class,</li>
- * <li>each enum,</li>
- * <li>and each data type</li>
- * </ul>
- * <!-- end-user-doc -->
- * @generated
- */
- public interface Literals
- {
- /**
- * The meta object literal for the '{@link org.apache.tuscany.sdo.util.metadata.impl.DocumentRootImpl <em>Document Root</em>}' class.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see org.apache.tuscany.sdo.util.metadata.impl.DocumentRootImpl
- * @see org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl#getDocumentRoot()
- * @generated
- */
- public static final EClass DOCUMENT_ROOT = eINSTANCE.getDocumentRoot();
-
- /**
- * The meta object literal for the '<em><b>Mixed</b></em>' attribute list feature.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final EAttribute DOCUMENT_ROOT__MIXED = eINSTANCE.getDocumentRoot_Mixed();
-
- /**
- * The meta object literal for the '<em><b>XMLNS Prefix Map</b></em>' map feature.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final EReference DOCUMENT_ROOT__XMLNS_PREFIX_MAP = eINSTANCE.getDocumentRoot_XMLNSPrefixMap();
-
- /**
- * The meta object literal for the '<em><b>XSI Schema Location</b></em>' map feature.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final EReference DOCUMENT_ROOT__XSI_SCHEMA_LOCATION = eINSTANCE.getDocumentRoot_XSISchemaLocation();
-
- /**
- * The meta object literal for the '<em><b>Sdo Meta Data Group</b></em>' containment reference feature.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final EReference DOCUMENT_ROOT__SDO_META_DATA_GROUP = eINSTANCE.getDocumentRoot_SdoMetaDataGroup();
-
- /**
- * The meta object literal for the '{@link org.apache.tuscany.sdo.util.metadata.impl.JavaMetaDataImpl <em>Java Meta Data</em>}' class.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see org.apache.tuscany.sdo.util.metadata.impl.JavaMetaDataImpl
- * @see org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl#getJavaMetaData()
- * @generated
- */
- public static final EClass JAVA_META_DATA = eINSTANCE.getJavaMetaData();
-
- /**
- * The meta object literal for the '<em><b>Factory Interface</b></em>' attribute feature.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final EAttribute JAVA_META_DATA__FACTORY_INTERFACE = eINSTANCE.getJavaMetaData_FactoryInterface();
-
- /**
- * The meta object literal for the '<em><b>Type Interface</b></em>' attribute feature.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final EAttribute JAVA_META_DATA__TYPE_INTERFACE = eINSTANCE.getJavaMetaData_TypeInterface();
-
- /**
- * The meta object literal for the '{@link org.apache.tuscany.sdo.util.metadata.impl.SDOMetaDataGroupImpl <em>SDO Meta Data Group</em>}' class.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see org.apache.tuscany.sdo.util.metadata.impl.SDOMetaDataGroupImpl
- * @see org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl#getSDOMetaDataGroup()
- * @generated
- */
- public static final EClass SDO_META_DATA_GROUP = eINSTANCE.getSDOMetaDataGroup();
-
- /**
- * The meta object literal for the '<em><b>Java Meta Data</b></em>' containment reference list feature.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final EReference SDO_META_DATA_GROUP__JAVA_META_DATA = eINSTANCE.getSDOMetaDataGroup_JavaMetaData();
-
- /**
- * The meta object literal for the '<em><b>Xsd Meta Data</b></em>' containment reference list feature.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final EReference SDO_META_DATA_GROUP__XSD_META_DATA = eINSTANCE.getSDOMetaDataGroup_XsdMetaData();
-
- /**
- * The meta object literal for the '<em><b>Type Meta Data</b></em>' containment reference list feature.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final EReference SDO_META_DATA_GROUP__TYPE_META_DATA = eINSTANCE.getSDOMetaDataGroup_TypeMetaData();
-
- /**
- * The meta object literal for the '{@link org.apache.tuscany.sdo.util.metadata.impl.TypeMetaDataImpl <em>Type Meta Data</em>}' class.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see org.apache.tuscany.sdo.util.metadata.impl.TypeMetaDataImpl
- * @see org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl#getTypeMetaData()
- * @generated
- */
- public static final EClass TYPE_META_DATA = eINSTANCE.getTypeMetaData();
-
- /**
- * The meta object literal for the '<em><b>Location</b></em>' attribute feature.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final EAttribute TYPE_META_DATA__LOCATION = eINSTANCE.getTypeMetaData_Location();
-
- /**
- * The meta object literal for the '{@link org.apache.tuscany.sdo.util.metadata.impl.XSDMetaDataImpl <em>XSD Meta Data</em>}' class.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see org.apache.tuscany.sdo.util.metadata.impl.XSDMetaDataImpl
- * @see org.apache.tuscany.sdo.util.metadata.impl.MetadataPackageImpl#getXSDMetaData()
- * @generated
- */
- public static final EClass XSD_META_DATA = eINSTANCE.getXSDMetaData();
-
- /**
- * The meta object literal for the '<em><b>Location</b></em>' attribute feature.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public static final EAttribute XSD_META_DATA__LOCATION = eINSTANCE.getXSDMetaData_Location();
-
- }
-
-} //MetadataPackageImpl
diff --git a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/SDOMetaDataGroupImpl.java b/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/SDOMetaDataGroupImpl.java deleted file mode 100644 index 5a668bb306..0000000000 --- a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/SDOMetaDataGroupImpl.java +++ /dev/null @@ -1,323 +0,0 @@ -/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tuscany.sdo.util.metadata.impl;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.tuscany.sdo.impl.DataObjectImpl;
-import org.apache.tuscany.sdo.model.Types;
-import org.apache.tuscany.sdo.util.SDOUtil;
-import org.apache.tuscany.sdo.util.metadata.JavaMetaData;
-import org.apache.tuscany.sdo.util.metadata.SDOMetaDataGroup;
-import org.apache.tuscany.sdo.util.metadata.TypeMetaData;
-import org.apache.tuscany.sdo.util.metadata.XSDMetaData;
-import org.eclipse.emf.common.notify.NotificationChain;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.util.EObjectContainmentEList;
-import org.eclipse.emf.ecore.util.InternalEList;
-
-import commonj.sdo.helper.TypeHelper;
-import commonj.sdo.helper.XMLDocument;
-import commonj.sdo.helper.XMLHelper;
-import commonj.sdo.helper.XSDHelper;
-
-/**
- * <!-- begin-user-doc -->
- * An implementation of the model object '<em><b>SDO Meta Data Group</b></em>'.
- * <!-- end-user-doc -->
- * <p>
- * The following features are implemented:
- * <ul>
- * <li>{@link org.apache.tuscany.sdo.util.metadata.impl.SDOMetaDataGroupImpl#getJavaMetaData <em>Java Meta Data</em>}</li>
- * <li>{@link org.apache.tuscany.sdo.util.metadata.impl.SDOMetaDataGroupImpl#getXsdMetaData <em>Xsd Meta Data</em>}</li>
- * <li>{@link org.apache.tuscany.sdo.util.metadata.impl.SDOMetaDataGroupImpl#getTypeMetaData <em>Type Meta Data</em>}</li>
- * </ul>
- * </p>
- *
- * @generated
- */
-public class SDOMetaDataGroupImpl extends DataObjectImpl implements SDOMetaDataGroup
-{
- public void register(TypeHelper typeHelper)
- {
- try
- {
- ClassLoader classLoader = (ClassLoader)AccessController.doPrivileged(new PrivilegedAction()
- {
- public Object run()
- {
- return Thread.currentThread().getContextClassLoader();
- }
- });
- register(typeHelper, classLoader);
- }
- catch (SecurityException e)
- {
- }
- }
-
- public void register(TypeHelper typeHelper, ClassLoader classLoader)
- {
- try
- {
- for (Iterator iter = getJavaMetaData().iterator(); iter.hasNext();)
- {
- JavaMetaData metadata = (JavaMetaData)iter.next();
- String factoryInterface = metadata.getFactoryInterface();
- if (factoryInterface != null)
- {
- Class factoryInterfaceClass = classLoader.loadClass(factoryInterface);
- SDOUtil.registerStaticTypes(factoryInterfaceClass);
- }
- else
- {
- String typeInterface = metadata.getTypeInterface();
- Class typeInterfaceClass = classLoader.loadClass(typeInterface);
- // TODO: introspect and register the type
- }
- }
-
- XSDHelper xsdHelper = SDOUtil.createXSDHelper(typeHelper);
- for (Iterator iter = getXsdMetaData().iterator(); iter.hasNext();)
- {
- XSDMetaData metadata = (XSDMetaData)iter.next();
- URL url = getClass().getResource(metadata.getLocation());
- InputStream inputStream = url.openStream();
- xsdHelper.define(inputStream, url.toString());
- }
-
- XMLHelper xmlHelper = SDOUtil.createXMLHelper(typeHelper);
- for (Iterator iter = getTypeMetaData().iterator(); iter.hasNext();)
- {
- TypeMetaData metadata = (TypeMetaData)iter.next();
- URL url = getClass().getResource(metadata.getLocation());
- InputStream inputStream = url.openStream();
- XMLDocument xmlDocument = xmlHelper.load(inputStream);
- Types types = (Types)xmlDocument.getRootObject();
- typeHelper.define(types.getTypeList());
- }
- }
- catch (Exception e)
- {
- }
- }
-
- /**
- * The cached value of the '{@link #getJavaMetaData() <em>Java Meta Data</em>}' containment reference list.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getJavaMetaData()
- * @generated
- * @ordered
- */
- protected EList javaMetaData = null;
-
- /**
- * The cached value of the '{@link #getXsdMetaData() <em>Xsd Meta Data</em>}' containment reference list.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getXsdMetaData()
- * @generated
- * @ordered
- */
- protected EList xsdMetaData = null;
-
- /**
- * The cached value of the '{@link #getTypeMetaData() <em>Type Meta Data</em>}' containment reference list.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getTypeMetaData()
- * @generated
- * @ordered
- */
- protected EList typeMetaData = null;
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- protected SDOMetaDataGroupImpl()
- {
- super();
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- protected EClass eStaticClass()
- {
- return MetadataPackageImpl.Literals.SDO_META_DATA_GROUP;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public List getJavaMetaData()
- {
- if (javaMetaData == null)
- {
- javaMetaData = new EObjectContainmentEList(JavaMetaData.class, this, MetadataPackageImpl.SDO_META_DATA_GROUP__JAVA_META_DATA);
- }
- return javaMetaData;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public List getXsdMetaData()
- {
- if (xsdMetaData == null)
- {
- xsdMetaData = new EObjectContainmentEList(XSDMetaData.class, this, MetadataPackageImpl.SDO_META_DATA_GROUP__XSD_META_DATA);
- }
- return xsdMetaData;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public List getTypeMetaData()
- {
- if (typeMetaData == null)
- {
- typeMetaData = new EObjectContainmentEList(TypeMetaData.class, this, MetadataPackageImpl.SDO_META_DATA_GROUP__TYPE_META_DATA);
- }
- return typeMetaData;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
- {
- switch (featureID)
- {
- case MetadataPackageImpl.SDO_META_DATA_GROUP__JAVA_META_DATA:
- return ((InternalEList)getJavaMetaData()).basicRemove(otherEnd, msgs);
- case MetadataPackageImpl.SDO_META_DATA_GROUP__XSD_META_DATA:
- return ((InternalEList)getXsdMetaData()).basicRemove(otherEnd, msgs);
- case MetadataPackageImpl.SDO_META_DATA_GROUP__TYPE_META_DATA:
- return ((InternalEList)getTypeMetaData()).basicRemove(otherEnd, msgs);
- }
- return super.eInverseRemove(otherEnd, featureID, msgs);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public Object eGet(int featureID, boolean resolve, boolean coreType)
- {
- switch (featureID)
- {
- case MetadataPackageImpl.SDO_META_DATA_GROUP__JAVA_META_DATA:
- return getJavaMetaData();
- case MetadataPackageImpl.SDO_META_DATA_GROUP__XSD_META_DATA:
- return getXsdMetaData();
- case MetadataPackageImpl.SDO_META_DATA_GROUP__TYPE_META_DATA:
- return getTypeMetaData();
- }
- return super.eGet(featureID, resolve, coreType);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public void eSet(int featureID, Object newValue)
- {
- switch (featureID)
- {
- case MetadataPackageImpl.SDO_META_DATA_GROUP__JAVA_META_DATA:
- getJavaMetaData().clear();
- getJavaMetaData().addAll((Collection)newValue);
- return;
- case MetadataPackageImpl.SDO_META_DATA_GROUP__XSD_META_DATA:
- getXsdMetaData().clear();
- getXsdMetaData().addAll((Collection)newValue);
- return;
- case MetadataPackageImpl.SDO_META_DATA_GROUP__TYPE_META_DATA:
- getTypeMetaData().clear();
- getTypeMetaData().addAll((Collection)newValue);
- return;
- }
- super.eSet(featureID, newValue);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public void eUnset(int featureID)
- {
- switch (featureID)
- {
- case MetadataPackageImpl.SDO_META_DATA_GROUP__JAVA_META_DATA:
- getJavaMetaData().clear();
- return;
- case MetadataPackageImpl.SDO_META_DATA_GROUP__XSD_META_DATA:
- getXsdMetaData().clear();
- return;
- case MetadataPackageImpl.SDO_META_DATA_GROUP__TYPE_META_DATA:
- getTypeMetaData().clear();
- return;
- }
- super.eUnset(featureID);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean eIsSet(int featureID)
- {
- switch (featureID)
- {
- case MetadataPackageImpl.SDO_META_DATA_GROUP__JAVA_META_DATA:
- return javaMetaData != null && !javaMetaData.isEmpty();
- case MetadataPackageImpl.SDO_META_DATA_GROUP__XSD_META_DATA:
- return xsdMetaData != null && !xsdMetaData.isEmpty();
- case MetadataPackageImpl.SDO_META_DATA_GROUP__TYPE_META_DATA:
- return typeMetaData != null && !typeMetaData.isEmpty();
- }
- return super.eIsSet(featureID);
- }
-
-} //SDOMetaDataGroupImpl
\ No newline at end of file diff --git a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/TypeMetaDataImpl.java b/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/TypeMetaDataImpl.java deleted file mode 100644 index a147b12053..0000000000 --- a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/TypeMetaDataImpl.java +++ /dev/null @@ -1,185 +0,0 @@ -/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tuscany.sdo.util.metadata.impl;
-
-import org.apache.tuscany.sdo.impl.DataObjectImpl;
-
-import org.apache.tuscany.sdo.util.metadata.TypeMetaData;
-
-import org.eclipse.emf.common.notify.Notification;
-
-import org.eclipse.emf.ecore.EClass;
-
-import org.eclipse.emf.ecore.impl.ENotificationImpl;
-
-/**
- * <!-- begin-user-doc -->
- * An implementation of the model object '<em><b>Type Meta Data</b></em>'.
- * <!-- end-user-doc -->
- * <p>
- * The following features are implemented:
- * <ul>
- * <li>{@link org.apache.tuscany.sdo.util.metadata.impl.TypeMetaDataImpl#getLocation <em>Location</em>}</li>
- * </ul>
- * </p>
- *
- * @generated
- */
-public class TypeMetaDataImpl extends DataObjectImpl implements TypeMetaData
-{
- /**
- * The default value of the '{@link #getLocation() <em>Location</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getLocation()
- * @generated
- * @ordered
- */
- protected static final String LOCATION_EDEFAULT = null;
-
- /**
- * The cached value of the '{@link #getLocation() <em>Location</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getLocation()
- * @generated
- * @ordered
- */
- protected String location = LOCATION_EDEFAULT;
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- protected TypeMetaDataImpl()
- {
- super();
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- protected EClass eStaticClass()
- {
- return MetadataPackageImpl.Literals.TYPE_META_DATA;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public String getLocation()
- {
- return location;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public void setLocation(String newLocation)
- {
- String oldLocation = location;
- location = newLocation;
- if (eNotificationRequired())
- eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackageImpl.TYPE_META_DATA__LOCATION, oldLocation, location));
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public Object eGet(int featureID, boolean resolve, boolean coreType)
- {
- switch (featureID)
- {
- case MetadataPackageImpl.TYPE_META_DATA__LOCATION:
- return getLocation();
- }
- return super.eGet(featureID, resolve, coreType);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public void eSet(int featureID, Object newValue)
- {
- switch (featureID)
- {
- case MetadataPackageImpl.TYPE_META_DATA__LOCATION:
- setLocation((String)newValue);
- return;
- }
- super.eSet(featureID, newValue);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public void eUnset(int featureID)
- {
- switch (featureID)
- {
- case MetadataPackageImpl.TYPE_META_DATA__LOCATION:
- setLocation(LOCATION_EDEFAULT);
- return;
- }
- super.eUnset(featureID);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean eIsSet(int featureID)
- {
- switch (featureID)
- {
- case MetadataPackageImpl.TYPE_META_DATA__LOCATION:
- return LOCATION_EDEFAULT == null ? location != null : !LOCATION_EDEFAULT.equals(location);
- }
- return super.eIsSet(featureID);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public String toString()
- {
- if (eIsProxy()) return super.toString();
-
- StringBuffer result = new StringBuffer(super.toString());
- result.append(" (location: ");
- result.append(location);
- result.append(')');
- return result.toString();
- }
-
-} //TypeMetaDataImpl
\ No newline at end of file diff --git a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/XSDMetaDataImpl.java b/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/XSDMetaDataImpl.java deleted file mode 100644 index 1bfdc9d465..0000000000 --- a/tags/java-M1-final/java/sdo/impl/src/main/java/org/apache/tuscany/sdo/util/metadata/impl/XSDMetaDataImpl.java +++ /dev/null @@ -1,185 +0,0 @@ -/**
- *
- * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tuscany.sdo.util.metadata.impl;
-
-import org.apache.tuscany.sdo.impl.DataObjectImpl;
-
-import org.apache.tuscany.sdo.util.metadata.XSDMetaData;
-
-import org.eclipse.emf.common.notify.Notification;
-
-import org.eclipse.emf.ecore.EClass;
-
-import org.eclipse.emf.ecore.impl.ENotificationImpl;
-
-/**
- * <!-- begin-user-doc -->
- * An implementation of the model object '<em><b>XSD Meta Data</b></em>'.
- * <!-- end-user-doc -->
- * <p>
- * The following features are implemented:
- * <ul>
- * <li>{@link org.apache.tuscany.sdo.util.metadata.impl.XSDMetaDataImpl#getLocation <em>Location</em>}</li>
- * </ul>
- * </p>
- *
- * @generated
- */
-public class XSDMetaDataImpl extends DataObjectImpl implements XSDMetaData
-{
- /**
- * The default value of the '{@link #getLocation() <em>Location</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getLocation()
- * @generated
- * @ordered
- */
- protected static final String LOCATION_EDEFAULT = null;
-
- /**
- * The cached value of the '{@link #getLocation() <em>Location</em>}' attribute.
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @see #getLocation()
- * @generated
- * @ordered
- */
- protected String location = LOCATION_EDEFAULT;
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- protected XSDMetaDataImpl()
- {
- super();
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- protected EClass eStaticClass()
- {
- return MetadataPackageImpl.Literals.XSD_META_DATA;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public String getLocation()
- {
- return location;
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public void setLocation(String newLocation)
- {
- String oldLocation = location;
- location = newLocation;
- if (eNotificationRequired())
- eNotify(new ENotificationImpl(this, Notification.SET, MetadataPackageImpl.XSD_META_DATA__LOCATION, oldLocation, location));
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public Object eGet(int featureID, boolean resolve, boolean coreType)
- {
- switch (featureID)
- {
- case MetadataPackageImpl.XSD_META_DATA__LOCATION:
- return getLocation();
- }
- return super.eGet(featureID, resolve, coreType);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public void eSet(int featureID, Object newValue)
- {
- switch (featureID)
- {
- case MetadataPackageImpl.XSD_META_DATA__LOCATION:
- setLocation((String)newValue);
- return;
- }
- super.eSet(featureID, newValue);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public void eUnset(int featureID)
- {
- switch (featureID)
- {
- case MetadataPackageImpl.XSD_META_DATA__LOCATION:
- setLocation(LOCATION_EDEFAULT);
- return;
- }
- super.eUnset(featureID);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public boolean eIsSet(int featureID)
- {
- switch (featureID)
- {
- case MetadataPackageImpl.XSD_META_DATA__LOCATION:
- return LOCATION_EDEFAULT == null ? location != null : !LOCATION_EDEFAULT.equals(location);
- }
- return super.eIsSet(featureID);
- }
-
- /**
- * <!-- begin-user-doc -->
- * <!-- end-user-doc -->
- * @generated
- */
- public String toString()
- {
- if (eIsProxy()) return super.toString();
-
- StringBuffer result = new StringBuffer(super.toString());
- result.append(" (location: ");
- result.append(location);
- result.append(')');
- return result.toString();
- }
-
-} //XSDMetaDataImpl
\ No newline at end of file |