diff options
Diffstat (limited to 'jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml')
9 files changed, 0 insertions, 1757 deletions
diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/AbstractJpaEObject.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/AbstractJpaEObject.java deleted file mode 100644 index 748a248790..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/AbstractJpaEObject.java +++ /dev/null @@ -1,332 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.resource.xml; - -import java.util.HashSet; -import java.util.Hashtable; -import java.util.Set; -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.impl.EObjectImpl; -import org.eclipse.jpt.common.core.utility.AbstractTextRange; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.text.edits.DeleteEdit; -import org.eclipse.wst.common.internal.emf.resource.EMF2DOMAdapter; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.w3c.dom.Text; - -/** - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - * - * @version 3.0 - * @since 2.2 - */ -public abstract class AbstractJpaEObject - extends EObjectImpl - implements JpaEObject -{ - protected IDOMNode node; - - /** - * Sets of "insignificant" feature ids, keyed by class. - * This is built up lazily, as the objects are modified. - */ - private static final Hashtable<Class<? extends AbstractJpaEObject>, HashSet<Integer>> insignificantFeatureIdSets = new Hashtable<Class<? extends AbstractJpaEObject>, HashSet<Integer>>(); - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected AbstractJpaEObject() { - super(); - } - - - // ********** JpaEObject implementation ********** - - public boolean isUnset() { - for (EStructuralFeature feature : this.eClass().getEAllStructuralFeatures()) { - if (this.eIsSet(feature)) { - return false; - } - } - return true; - } - - - // ********** change notification ********** - - /** - * override to build a custom list for the adapters - */ - @Override - public EList<Adapter> eAdapters() { - if (this.eAdapters == null) { - this.eAdapters = new XmlEAdapterList<Adapter>(this); - } - return this.eAdapters; - } - - /** - * override to prevent notification when the object's state is unchanged - */ - @Override - public void eNotify(Notification notification) { - if ( ! notification.isTouch()) { - super.eNotify(notification); - this.featureChanged(notification.getFeatureID(this.getClass())); - } - } - - protected void featureChanged(int featureId) { - if (this.featureIsSignificant(featureId)) { - this.getXmlResource().resourceModelChanged(); - } - } - - protected JpaXmlResource getXmlResource() { - return (JpaXmlResource) this.eResource(); - } - - protected boolean featureIsSignificant(int featureId) { - return ! this.featureIsInsignificant(featureId); - } - - protected boolean featureIsInsignificant(int featureId) { - return this.insignificantFeatureIds().contains(Integer.valueOf(featureId)); - } - - /** - * Return a set of the object's "insignificant" feature ids. - * These are the EMF features that will not be used to determine if all - * the features are unset. We use this to determine when to remove - * an element from the xml. - * - * If you need instance-based calculation of your xml "insignificant" aspects, - * override this method. If class-based calculation is sufficient, - * override #addInsignificantXmlFeatureIdsTo(Set). - * - * @see #isUnset() - */ - protected Set<Integer> insignificantFeatureIds() { - synchronized (insignificantFeatureIdSets) { - HashSet<Integer> insignificantXmlFeatureIds = insignificantFeatureIdSets.get(this.getClass()); - if (insignificantXmlFeatureIds == null) { - insignificantXmlFeatureIds = new HashSet<Integer>(); - this.addInsignificantXmlFeatureIdsTo(insignificantXmlFeatureIds); - insignificantFeatureIdSets.put(this.getClass(), insignificantXmlFeatureIds); - } - return insignificantXmlFeatureIds; - } - } - - /** - * Add the object's "insignificant" feature ids to the specified set. - * These are the EMF features that, when they change, will NOT cause the - * object (or its containing tree) to be updated, i.e. defaults calculated. - * If class-based calculation of your "insignificant" features is sufficient, - * override this method. If you need instance-based calculation, - * override #insignificantXmlFeatureIds(). - */ - protected void addInsignificantXmlFeatureIdsTo(@SuppressWarnings("unused") Set<Integer> insignificantXmlFeatureIds) { - // when you override this method, don't forget to include: - // super.addInsignificantXmlFeatureIdsTo(insignificantXmlFeatureIds); - } - - - // ********** text ranges ********** - - /** - * Return a text range for the "text" node. - * If the text node does not exist, return a text range for this object's node - */ - protected TextRange getTextTextRange() { - IDOMNode textNode = this.getTextNode(); - return (textNode != null) ? buildTextRange(textNode) : this.getValidationTextRange(); - } - - protected IDOMNode getTextNode() { - // virtual objects have no node - return (this.node == null) ? null : getTextNode(this.node); - } - - protected static IDOMNode getTextNode(IDOMNode node) { - NodeList children = node.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - IDOMNode child = (IDOMNode) children.item(i); - if (child.getNodeType() == Node.TEXT_NODE) { - return child; - } - } - return null; - } - - /** - * Return a text range for the specified attribute node. - * If the attribute node does not exist, return a text range for this object's - * node - */ - protected TextRange getAttributeTextRange(String attributeName) { - IDOMNode attributeNode = this.getAttributeNode(attributeName); - return (attributeNode != null) ? buildTextRange(attributeNode) : this.getValidationTextRange(); - } - - protected IDOMAttr getAttributeNode(String attributeName) { - return (this.node == null) ? // virtual objects have no node - null : (IDOMAttr) this.node.getAttributes().getNamedItem(attributeName); - } - - /** - * Return a text range for the specified element node. - * If the element node does not exist, return a text range for this object's - * node - */ - protected TextRange getElementTextRange(String elementName) { - IDOMNode elementNode = this.getElementNode(elementName); - return (elementNode != null) ? buildTextRange(elementNode) : this.getValidationTextRange(); - } - - /** - * Returns the first element node with the given name, if one exists - */ - protected IDOMNode getElementNode(String elementName) { - if (this.node == null) return null; // virtual objects have no node - NodeList children = this.node.getChildNodes(); - for (int i = 0; i < children.getLength(); i ++) { - IDOMNode child = (IDOMNode) children.item(i); - if ((child.getNodeType() == Node.ELEMENT_NODE) - && elementName.equals(child.getNodeName())) { - return child; - } - } - return null; - } - - public TextRange getValidationTextRange() { - return this.getFullTextRange(); - } - - public TextRange getSelectionTextRange() { - return this.getFullTextRange(); - } - - protected TextRange getFullTextRange() { - return buildTextRange(this.node); - } - - protected static TextRange buildTextRange(IDOMNode domNode) { - return (domNode == null) ? null : new DOMNodeTextRange(domNode); - } - - public boolean containsOffset(int textOffset) { - return (this.node == null) ? false : this.node.contains(textOffset); - } - - - // ********** Refactoring TextEdits ********** - - public DeleteEdit createDeleteEdit() { - int deletionOffset = getDeletionOffset(); - int deletionLength = this.node.getEndOffset() - deletionOffset; - return new DeleteEdit(deletionOffset, deletionLength); - } - - public int getNodeEndOffset() { - return this.node.getEndOffset(); - } - - /** - * deletion offset needs to include any text that is before the node - */ - protected int getDeletionOffset() { - int emptyTextLength = 0; - Node previousSibling = this.node.getPreviousSibling(); - if (previousSibling != null && previousSibling.getNodeType() == Node.TEXT_NODE) { - emptyTextLength = ((Text) previousSibling).getLength(); - } - return this.node.getStartOffset() - emptyTextLength; - } - - - // ********** custom adapter list ********** - - protected static class XmlEAdapterList<E extends Object & Adapter> - extends EAdapterList<E> - { - public XmlEAdapterList(AbstractJpaEObject jpaEObject) { - super(jpaEObject); - } - - @Override - protected void didAdd(int index, E newObject) { - super.didAdd(index, newObject); - if (newObject instanceof EMF2DOMAdapter) { - Object n = ((EMF2DOMAdapter) newObject).getNode(); - if (n instanceof IDOMNode) { - ((AbstractJpaEObject) this.notifier).node = (IDOMNode) n; - } - } - } - - @Override - protected void didRemove(int index, E oldObject) { - if ((oldObject instanceof EMF2DOMAdapter) && - (((EMF2DOMAdapter) oldObject).getNode() == ((AbstractJpaEObject) this.notifier).node)) { - ((AbstractJpaEObject) this.notifier).node = null; - } - super.didRemove(index, oldObject); - } - } - - - // ********** DOM node text range ********** - - /** - * Adapt an IDOMNode to the TextRange interface. - */ - protected static class DOMNodeTextRange - extends AbstractTextRange - { - private final IDOMNode node; - - DOMNodeTextRange(IDOMNode node) { - super(); - this.node = node; - } - - public int getOffset() { - return this.node.getStartOffset(); - } - - public int getLength() { - if (this.node.getNodeType() == Node.ELEMENT_NODE) { - return ((IDOMElement) this.node).getStartEndOffset() - this.node.getStartOffset(); - } - return this.node.getLength(); - } - - public int getLineNumber() { - return this.node.getStructuredDocument().getLineOfOffset(this.getOffset()) + 1; - } - - } - -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/AbstractJpaRootEObject.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/AbstractJpaRootEObject.java deleted file mode 100644 index df72ac8864..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/AbstractJpaRootEObject.java +++ /dev/null @@ -1,335 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jpt.jpa.core.resource.xml; - -import java.util.Map; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.impl.ENotificationImpl; -import org.eclipse.jpt.common.core.internal.utility.translators.EnumeratedValueTranslator; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.jpt.common.utility.internal.iterables.TransformationIterable; -import org.eclipse.wst.common.internal.emf.resource.ConstantAttributeTranslator; -import org.eclipse.wst.common.internal.emf.resource.Translator; - -/** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>Abstract Jpa Root EObject</b></em>'. - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - * <!-- end-user-doc --> - * - * - * @see org.eclipse.jpt.jpa.core.resource.xml.CommonPackage#getAbstractJpaRootEObject() - * @model kind="class" abstract="true" - * @generated - */ -public abstract class AbstractJpaRootEObject extends AbstractJpaEObject implements JpaRootEObject -{ - /** - * The default value of the '{@link #getVersion() <em>Version</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getVersion() - * @generated - * @ordered - */ - protected static final String VERSION_EDEFAULT = null; - - /** - * The cached value of the '{@link #getVersion() <em>Version</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getVersion() - * @generated - * @ordered - */ - protected String version = VERSION_EDEFAULT; - - /** - * The default value of the '{@link #getSchemaLocation() <em>Schema Location</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getSchemaLocation() - * @generated - * @ordered - */ - protected static final String SCHEMA_LOCATION_EDEFAULT = null; - - /** - * The cached value of the '{@link #getSchemaLocation() <em>Schema Location</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #getSchemaLocation() - * @generated - * @ordered - */ - protected String schemaLocation = SCHEMA_LOCATION_EDEFAULT; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - protected AbstractJpaRootEObject() - { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - protected EClass eStaticClass() - { - return CommonPackage.Literals.ABSTRACT_JPA_ROOT_EOBJECT; - } - - /** - * Returns the value of the '<em><b>Version</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Version</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Version</em>' attribute. - * @see #setVersion(String) - * @see org.eclipse.jpt.jpa.core.resource.xml.CommonPackage#getJpaRootEObject_Version() - * @model required="true" - * @generated - */ - public String getVersion() - { - return version; - } - - /** - * Sets the value of the '{@link org.eclipse.jpt.jpa.core.resource.xml.AbstractJpaRootEObject#getVersion <em>Version</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Version</em>' attribute. - * @see #getVersion() - * @generated - */ - protected void setVersionGen(String newVersion) - { - String oldVersion = version; - version = newVersion; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, CommonPackage.ABSTRACT_JPA_ROOT_EOBJECT__VERSION, oldVersion, version)); - } - - public void setVersion(String newVersion) { - setVersionGen(newVersion); - setSchemaLocation(buildSchemaLocationString(getNamespace(), getSchemaLocationForVersion(newVersion))); - } - - /** - * Returns the value of the '<em><b>Schema Location</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Schema 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>Schema Location</em>' attribute. - * @see #setSchemaLocation(String) - * @see org.eclipse.jpt.jpa.core.resource.xml.CommonPackage#getJpaRootEObject_SchemaLocation() - * @model required="true" - * @generated - */ - public String getSchemaLocation() - { - return schemaLocation; - } - - /** - * Sets the value of the '{@link org.eclipse.jpt.jpa.core.resource.xml.AbstractJpaRootEObject#getSchemaLocation <em>Schema Location</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Schema Location</em>' attribute. - * @see #getSchemaLocation() - * @generated - */ - public void setSchemaLocation(String newSchemaLocation) - { - String oldSchemaLocation = schemaLocation; - schemaLocation = newSchemaLocation; - if (eNotificationRequired()) - eNotify(new ENotificationImpl(this, Notification.SET, CommonPackage.ABSTRACT_JPA_ROOT_EOBJECT__SCHEMA_LOCATION, oldSchemaLocation, schemaLocation)); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public Object eGet(int featureID, boolean resolve, boolean coreType) - { - switch (featureID) - { - case CommonPackage.ABSTRACT_JPA_ROOT_EOBJECT__VERSION: - return getVersion(); - case CommonPackage.ABSTRACT_JPA_ROOT_EOBJECT__SCHEMA_LOCATION: - return getSchemaLocation(); - } - return super.eGet(featureID, resolve, coreType); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void eSet(int featureID, Object newValue) - { - switch (featureID) - { - case CommonPackage.ABSTRACT_JPA_ROOT_EOBJECT__VERSION: - setVersion((String)newValue); - return; - case CommonPackage.ABSTRACT_JPA_ROOT_EOBJECT__SCHEMA_LOCATION: - setSchemaLocation((String)newValue); - return; - } - super.eSet(featureID, newValue); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public void eUnset(int featureID) - { - switch (featureID) - { - case CommonPackage.ABSTRACT_JPA_ROOT_EOBJECT__VERSION: - setVersion(VERSION_EDEFAULT); - return; - case CommonPackage.ABSTRACT_JPA_ROOT_EOBJECT__SCHEMA_LOCATION: - setSchemaLocation(SCHEMA_LOCATION_EDEFAULT); - return; - } - super.eUnset(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public boolean eIsSet(int featureID) - { - switch (featureID) - { - case CommonPackage.ABSTRACT_JPA_ROOT_EOBJECT__VERSION: - return VERSION_EDEFAULT == null ? version != null : !VERSION_EDEFAULT.equals(version); - case CommonPackage.ABSTRACT_JPA_ROOT_EOBJECT__SCHEMA_LOCATION: - return SCHEMA_LOCATION_EDEFAULT == null ? schemaLocation != null : !SCHEMA_LOCATION_EDEFAULT.equals(schemaLocation); - } - return super.eIsSet(featureID); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public String toString() - { - if (eIsProxy()) return super.toString(); - - StringBuffer result = new StringBuffer(super.toString()); - result.append(" (version: "); - result.append(version); - result.append(", schemaLocation: "); - result.append(schemaLocation); - result.append(')'); - return result.toString(); - } - - - // **************** validation ******************************************** - - public TextRange getVersionTextRange() { - return getAttributeTextRange(XML.VERSION); - } - - - // **************** version -> schema location mapping ******************** - - protected abstract String getNamespace(); - - protected abstract String getSchemaLocationForVersion(String version); - - private static String buildSchemaLocationString(String namespace, String schemaLocation) { - return namespace + ' ' + schemaLocation; - } - - - // **************** translators ******************************************* - - protected static Translator buildVersionTranslator(final Map<String, String> versionsToSchemaLocations) { - return new EnumeratedValueTranslator( - XML.VERSION, - CommonPackage.eINSTANCE.getJpaRootEObject_Version(), - Translator.DOM_ATTRIBUTE) { - - @Override - protected Iterable<String> getEnumeratedObjectValues() { - return versionsToSchemaLocations.keySet(); - } - }; - } - - protected static Translator buildNamespaceTranslator(String namespace) { - return new ConstantAttributeTranslator(XML.NAMESPACE, namespace); - } - - protected static Translator buildSchemaNamespaceTranslator() { - return new ConstantAttributeTranslator(XML.NAMESPACE_XSI, XML.XSI_NAMESPACE_URL); - } - - protected static Translator buildSchemaLocationTranslator( - final String namespace, - final Map<String, String> versionsToSchemaLocations) { - - return new EnumeratedValueTranslator( - XML.XSI_SCHEMA_LOCATION, - CommonPackage.eINSTANCE.getJpaRootEObject_SchemaLocation(), - Translator.DOM_ATTRIBUTE) { - - @Override - protected Iterable<String> getEnumeratedObjectValues() { - return new TransformationIterable<String, String>(versionsToSchemaLocations.values()) { - @Override - protected String transform(String next) { - return buildSchemaLocationString(namespace, next); - } - }; - } - }; - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/CommonFactory.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/CommonFactory.java deleted file mode 100644 index 335de1d84a..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/CommonFactory.java +++ /dev/null @@ -1,115 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jpt.jpa.core.resource.xml; - -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 --> - * The <b>Factory</b> for the model. - * It provides a create method for each non-abstract class of the model. - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - * <!-- end-user-doc --> - * @see org.eclipse.jpt.jpa.core.resource.xml.CommonPackage - * @generated - */ -public class CommonFactory extends EFactoryImpl -{ - /** - * The singleton instance of the factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final CommonFactory eINSTANCE = init(); - - /** - * Creates the default factory implementation. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static CommonFactory init() - { - try - { - CommonFactory theCommonFactory = (CommonFactory)EPackage.Registry.INSTANCE.getEFactory("jpt.common.xmi"); - if (theCommonFactory != null) - { - return theCommonFactory; - } - } - catch (Exception exception) - { - EcorePlugin.INSTANCE.log(exception); - } - return new CommonFactory(); - } - - /** - * Creates an instance of the factory. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public CommonFactory() - { - super(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - @Override - public EObject create(EClass eClass) - { - switch (eClass.getClassifierID()) - { - default: - throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); - } - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public CommonPackage getCommonPackage() - { - return (CommonPackage)getEPackage(); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @deprecated - * @generated - */ - @Deprecated - public static CommonPackage getPackage() - { - return CommonPackage.eINSTANCE; - } - -} //CommonFactory diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/CommonPackage.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/CommonPackage.java deleted file mode 100644 index b633baded5..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/CommonPackage.java +++ /dev/null @@ -1,436 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jpt.jpa.core.resource.xml; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EcorePackage; -import org.eclipse.emf.ecore.impl.EPackageImpl; -import org.eclipse.jpt.jpa.core.resource.orm.OrmPackage; -import org.eclipse.jpt.jpa.core.resource.orm.v2_0.OrmV2_0Package; -import org.eclipse.jpt.jpa.core.resource.persistence.PersistencePackage; -import org.eclipse.jpt.jpa.core.resource.persistence.v2_0.PersistenceV2_0Package; - -/** - * <!-- 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> - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - * <!-- end-user-doc --> - * @see org.eclipse.jpt.jpa.core.resource.xml.CommonFactory - * @model kind="package" - * @generated - */ -public class CommonPackage extends EPackageImpl -{ - /** - * The package name. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String eNAME = "xml"; - - /** - * The package namespace URI. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String eNS_URI = "jpt.common.xmi"; - - /** - * The package namespace name. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final String eNS_PREFIX = "org.eclipse.jpt.jpa.core.resource.xml"; - - /** - * The singleton instance of the package. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final CommonPackage eINSTANCE = org.eclipse.jpt.jpa.core.resource.xml.CommonPackage.init(); - - /** - * The meta object id for the '{@link org.eclipse.jpt.jpa.core.resource.xml.JpaRootEObject <em>Jpa Root EObject</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jpt.jpa.core.resource.xml.JpaRootEObject - * @see org.eclipse.jpt.jpa.core.resource.xml.CommonPackage#getJpaRootEObject() - * @generated - */ - public static final int JPA_ROOT_EOBJECT = 1; - - /** - * The feature id for the '<em><b>Version</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public static final int JPA_ROOT_EOBJECT__VERSION = 0; - - /** - * The feature id for the '<em><b>Schema Location</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public static final int JPA_ROOT_EOBJECT__SCHEMA_LOCATION = 1; - - /** - * The number of structural features of the '<em>Jpa Root EObject</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public static final int JPA_ROOT_EOBJECT_FEATURE_COUNT = 2; - - /** - * The meta object id for the '{@link org.eclipse.jpt.jpa.core.resource.xml.AbstractJpaRootEObject <em>Abstract Jpa Root EObject</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jpt.jpa.core.resource.xml.AbstractJpaRootEObject - * @see org.eclipse.jpt.jpa.core.resource.xml.CommonPackage#getAbstractJpaRootEObject() - * @generated - */ - public static final int ABSTRACT_JPA_ROOT_EOBJECT = 0; - - /** - * The feature id for the '<em><b>Version</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public static final int ABSTRACT_JPA_ROOT_EOBJECT__VERSION = JPA_ROOT_EOBJECT__VERSION; - - /** - * The feature id for the '<em><b>Schema Location</b></em>' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public static final int ABSTRACT_JPA_ROOT_EOBJECT__SCHEMA_LOCATION = JPA_ROOT_EOBJECT__SCHEMA_LOCATION; - - /** - * The number of structural features of the '<em>Abstract Jpa Root EObject</em>' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - * @ordered - */ - public static final int ABSTRACT_JPA_ROOT_EOBJECT_FEATURE_COUNT = JPA_ROOT_EOBJECT_FEATURE_COUNT + 0; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass abstractJpaRootEObjectEClass = null; - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private EClass jpaRootEObjectEClass = 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.eclipse.jpt.jpa.core.resource.xml.CommonPackage#eNS_URI - * @see #init() - * @generated - */ - private CommonPackage() - { - super(eNS_URI, CommonFactory.eINSTANCE); - } - - /** - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - private static boolean isInited = false; - - /** - * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends. - * - * <p>This method is used to initialize {@link CommonPackage#eINSTANCE} when that field is accessed. - * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see #eNS_URI - * @see #createPackageContents() - * @see #initializePackageContents() - * @generated - */ - public static CommonPackage init() - { - if (isInited) return (CommonPackage)EPackage.Registry.INSTANCE.getEPackage(CommonPackage.eNS_URI); - - // Obtain or create and register package - CommonPackage theCommonPackage = (CommonPackage)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof CommonPackage ? EPackage.Registry.INSTANCE.get(eNS_URI) : new CommonPackage()); - - isInited = true; - - // Initialize simple dependencies - EcorePackage.eINSTANCE.eClass(); - - // Obtain or create and register interdependencies - OrmPackage theOrmPackage = (OrmPackage)(EPackage.Registry.INSTANCE.getEPackage(OrmPackage.eNS_URI) instanceof OrmPackage ? EPackage.Registry.INSTANCE.getEPackage(OrmPackage.eNS_URI) : OrmPackage.eINSTANCE); - OrmV2_0Package theOrmV2_0Package = (OrmV2_0Package)(EPackage.Registry.INSTANCE.getEPackage(OrmV2_0Package.eNS_URI) instanceof OrmV2_0Package ? EPackage.Registry.INSTANCE.getEPackage(OrmV2_0Package.eNS_URI) : OrmV2_0Package.eINSTANCE); - PersistencePackage thePersistencePackage = (PersistencePackage)(EPackage.Registry.INSTANCE.getEPackage(PersistencePackage.eNS_URI) instanceof PersistencePackage ? EPackage.Registry.INSTANCE.getEPackage(PersistencePackage.eNS_URI) : PersistencePackage.eINSTANCE); - PersistenceV2_0Package thePersistenceV2_0Package = (PersistenceV2_0Package)(EPackage.Registry.INSTANCE.getEPackage(PersistenceV2_0Package.eNS_URI) instanceof PersistenceV2_0Package ? EPackage.Registry.INSTANCE.getEPackage(PersistenceV2_0Package.eNS_URI) : PersistenceV2_0Package.eINSTANCE); - - // Create package meta-data objects - theCommonPackage.createPackageContents(); - theOrmPackage.createPackageContents(); - theOrmV2_0Package.createPackageContents(); - thePersistencePackage.createPackageContents(); - thePersistenceV2_0Package.createPackageContents(); - - // Initialize created meta-data - theCommonPackage.initializePackageContents(); - theOrmPackage.initializePackageContents(); - theOrmV2_0Package.initializePackageContents(); - thePersistencePackage.initializePackageContents(); - thePersistenceV2_0Package.initializePackageContents(); - - // Mark meta-data to indicate it can't be changed - theCommonPackage.freeze(); - - - // Update the registry and return the package - EPackage.Registry.INSTANCE.put(CommonPackage.eNS_URI, theCommonPackage); - return theCommonPackage; - } - - - /** - * Returns the meta object for class '{@link org.eclipse.jpt.jpa.core.resource.xml.AbstractJpaRootEObject <em>Abstract Jpa Root EObject</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>Abstract Jpa Root EObject</em>'. - * @see org.eclipse.jpt.jpa.core.resource.xml.AbstractJpaRootEObject - * @generated - */ - public EClass getAbstractJpaRootEObject() - { - return abstractJpaRootEObjectEClass; - } - - - /** - * Returns the meta object for class '{@link org.eclipse.jpt.jpa.core.resource.xml.JpaRootEObject <em>Jpa Root EObject</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for class '<em>Jpa Root EObject</em>'. - * @see org.eclipse.jpt.jpa.core.resource.xml.JpaRootEObject - * @generated - */ - public EClass getJpaRootEObject() - { - return jpaRootEObjectEClass; - } - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jpt.jpa.core.resource.xml.JpaRootEObject#getVersion <em>Version</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Version</em>'. - * @see org.eclipse.jpt.jpa.core.resource.xml.JpaRootEObject#getVersion() - * @see #getJpaRootEObject() - * @generated - */ - public EAttribute getJpaRootEObject_Version() - { - return (EAttribute)jpaRootEObjectEClass.getEStructuralFeatures().get(0); - } - - /** - * Returns the meta object for the attribute '{@link org.eclipse.jpt.jpa.core.resource.xml.JpaRootEObject#getSchemaLocation <em>Schema Location</em>}'. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @return the meta object for the attribute '<em>Schema Location</em>'. - * @see org.eclipse.jpt.jpa.core.resource.xml.JpaRootEObject#getSchemaLocation() - * @see #getJpaRootEObject() - * @generated - */ - public EAttribute getJpaRootEObject_SchemaLocation() - { - return (EAttribute)jpaRootEObjectEClass.getEStructuralFeatures().get(1); - } - - - /** - * 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 CommonFactory getCommonFactory() - { - return (CommonFactory)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 - abstractJpaRootEObjectEClass = createEClass(ABSTRACT_JPA_ROOT_EOBJECT); - - jpaRootEObjectEClass = createEClass(JPA_ROOT_EOBJECT); - createEAttribute(jpaRootEObjectEClass, JPA_ROOT_EOBJECT__VERSION); - createEAttribute(jpaRootEObjectEClass, JPA_ROOT_EOBJECT__SCHEMA_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); - - // Create type parameters - - // Set bounds for type parameters - - // Add supertypes to classes - abstractJpaRootEObjectEClass.getESuperTypes().add(this.getJpaRootEObject()); - - // Initialize classes and features; add operations and parameters - initEClass(abstractJpaRootEObjectEClass, AbstractJpaRootEObject.class, "AbstractJpaRootEObject", IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - - initEClass(jpaRootEObjectEClass, JpaRootEObject.class, "JpaRootEObject", IS_ABSTRACT, IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); - initEAttribute(getJpaRootEObject_Version(), ecorePackage.getEString(), "version", null, 1, 1, JpaRootEObject.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getJpaRootEObject_SchemaLocation(), ecorePackage.getEString(), "schemaLocation", null, 1, 1, JpaRootEObject.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - - // Create resource - createResource(eNS_URI); - } - - /** - * <!-- 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.eclipse.jpt.jpa.core.resource.xml.AbstractJpaRootEObject <em>Abstract Jpa Root EObject</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jpt.jpa.core.resource.xml.AbstractJpaRootEObject - * @see org.eclipse.jpt.jpa.core.resource.xml.CommonPackage#getAbstractJpaRootEObject() - * @generated - */ - public static final EClass ABSTRACT_JPA_ROOT_EOBJECT = eINSTANCE.getAbstractJpaRootEObject(); - - /** - * The meta object literal for the '{@link org.eclipse.jpt.jpa.core.resource.xml.JpaRootEObject <em>Jpa Root EObject</em>}' class. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @see org.eclipse.jpt.jpa.core.resource.xml.JpaRootEObject - * @see org.eclipse.jpt.jpa.core.resource.xml.CommonPackage#getJpaRootEObject() - * @generated - */ - public static final EClass JPA_ROOT_EOBJECT = eINSTANCE.getJpaRootEObject(); - - /** - * The meta object literal for the '<em><b>Version</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final EAttribute JPA_ROOT_EOBJECT__VERSION = eINSTANCE.getJpaRootEObject_Version(); - - /** - * The meta object literal for the '<em><b>Schema Location</b></em>' attribute feature. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @generated - */ - public static final EAttribute JPA_ROOT_EOBJECT__SCHEMA_LOCATION = eINSTANCE.getJpaRootEObject_SchemaLocation(); - - } - -} //CommonPackage diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/EmfTools.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/EmfTools.java deleted file mode 100644 index 6a4656a939..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/EmfTools.java +++ /dev/null @@ -1,40 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.resource.xml; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EFactory; -import org.eclipse.emf.ecore.EObject; - -/** - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - * - * @version 2.3 - * @since 2.3 - */ -public class EmfTools { - - public static <T extends EObject> T create(EFactory eFactory, EClass eClass, Class<T> javaClass) { - for (EClassifier factoryEClassifier : eFactory.getEPackage().getEClassifiers()) { - if (factoryEClassifier instanceof EClass) { - EClass factoryEClass = (EClass) factoryEClassifier; - if (eClass.isSuperTypeOf(factoryEClass)) { - return javaClass.cast(eFactory.create(factoryEClass)); - } - } - } - throw new IllegalArgumentException("Factory does not support objects of type \'" + eClass.getName() + '\''); //$NON-NLS-1$ - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/JpaEObject.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/JpaEObject.java deleted file mode 100644 index 97b4dbbb3f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/JpaEObject.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jpt.jpa.core.resource.xml; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.jpt.common.core.utility.TextRange; -import org.eclipse.text.edits.DeleteEdit; - -/** - * Common Dali behavior for EMF objects. - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - * - * @version 3.0 - * @since 2.2 - */ -public interface JpaEObject - extends EObject -{ - /** - * Return whether all the object's EMF features are "unset". - */ - boolean isUnset(); - - /** - * Return true if this object's text representation contains the text offset - */ - boolean containsOffset(int textOffset); - - /** - * Return the text range to be used for validation. This is the source - * range that will be highlighted for a validation error. - */ - TextRange getValidationTextRange(); - - /** - * Return the text range to be used for selection. This is the source - * range that will be highlighted when selecting in the structure view. - */ - TextRange getSelectionTextRange(); - - - // ********** refactoring ********** - - /** - * Create a text DeleteEdit for deleting the entire IDOMNode and any text that precedes it. - */ - DeleteEdit createDeleteEdit(); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/JpaRootEObject.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/JpaRootEObject.java deleted file mode 100644 index 57aa329d20..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/JpaRootEObject.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Oracle - initial API and implementation - *******************************************************************************/ - -package org.eclipse.jpt.jpa.core.resource.xml; - -import org.eclipse.jpt.common.core.utility.TextRange; - - -/** - * <!-- begin-user-doc --> - * A representation of the model object '<em><b>Jpa Root EObject</b></em>'. - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - * <!-- end-user-doc --> - * - * <p> - * The following features are supported: - * <ul> - * <li>{@link org.eclipse.jpt.jpa.core.resource.xml.JpaRootEObject#getVersion <em>Version</em>}</li> - * <li>{@link org.eclipse.jpt.jpa.core.resource.xml.JpaRootEObject#getSchemaLocation <em>Schema Location</em>}</li> - * </ul> - * </p> - * - * @see org.eclipse.jpt.jpa.core.resource.xml.CommonPackage#getJpaRootEObject() - * @model kind="class" interface="true" abstract="true" - * @extends JpaEObject - * @generated - */ -public interface JpaRootEObject extends JpaEObject -{ - /** - * Returns the value of the '<em><b>Version</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Version</em>' attribute isn't clear, - * there really should be more of a description here... - * </p> - * <!-- end-user-doc --> - * @return the value of the '<em>Version</em>' attribute. - * @see #setVersion(String) - * @see org.eclipse.jpt.jpa.core.resource.xml.CommonPackage#getJpaRootEObject_Version() - * @model required="true" - * @generated - */ - String getVersion(); - - /** - * Sets the value of the '{@link org.eclipse.jpt.jpa.core.resource.xml.JpaRootEObject#getVersion <em>Version</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Version</em>' attribute. - * @see #getVersion() - * @generated - */ - void setVersion(String value); - - /** - * Returns the value of the '<em><b>Schema Location</b></em>' attribute. - * <!-- begin-user-doc --> - * <p> - * If the meaning of the '<em>Schema 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>Schema Location</em>' attribute. - * @see #setSchemaLocation(String) - * @see org.eclipse.jpt.jpa.core.resource.xml.CommonPackage#getJpaRootEObject_SchemaLocation() - * @model required="true" - * @generated - */ - String getSchemaLocation(); - - /** - * Sets the value of the '{@link org.eclipse.jpt.jpa.core.resource.xml.JpaRootEObject#getSchemaLocation <em>Schema Location</em>}' attribute. - * <!-- begin-user-doc --> - * <!-- end-user-doc --> - * @param value the new value of the '<em>Schema Location</em>' attribute. - * @see #getSchemaLocation() - * @generated - */ - void setSchemaLocation(String value); - - TextRange getVersionTextRange(); -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/JpaXmlResource.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/JpaXmlResource.java deleted file mode 100644 index 0a4e29b098..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/JpaXmlResource.java +++ /dev/null @@ -1,307 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.resource.xml; - -import java.io.IOException; -import java.util.Collections; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.content.IContentType; -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.jem.util.emf.workbench.WorkbenchResourceHelperBase; -import org.eclipse.jem.util.plugin.JEMUtilPlugin; -import org.eclipse.jpt.common.core.JptResourceModel; -import org.eclipse.jpt.common.core.JptResourceModelListener; -import org.eclipse.jpt.common.core.JptResourceType; -import org.eclipse.jpt.common.utility.internal.ListenerList; -import org.eclipse.jpt.common.utility.internal.StringTools; -import org.eclipse.jpt.jpa.core.JptJpaCorePlugin; -import org.eclipse.jst.j2ee.internal.xml.J2EEXmlDtDEntityResolver; -import org.eclipse.wst.common.internal.emf.resource.Renderer; -import org.eclipse.wst.common.internal.emf.resource.Translator; -import org.eclipse.wst.common.internal.emf.resource.TranslatorResourceImpl; -import org.xml.sax.EntityResolver; - -/** - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - * - * @version 2.3 - * @since 2.2 - */ -public class JpaXmlResource - extends TranslatorResourceImpl - implements JptResourceModel -{ - /** - * cache the content type - if the content type changes, the JPA project - * will throw out the JPA file holding the xml resource and build a new one - */ - protected final IContentType contentType; - - protected final Translator rootTranslator; - - protected final ListenerList<JptResourceModelListener> resourceModelListenerList = - new ListenerList<JptResourceModelListener>(JptResourceModelListener.class); - - - public JpaXmlResource(URI uri, Renderer renderer, IContentType contentType, Translator rootTranslator) { - super(uri, renderer); - this.contentType = contentType; - this.rootTranslator = rootTranslator; - } - - public IContentType getContentType() { - return this.contentType; - } - - public String getVersion() { - JpaRootEObject root = this.getRootObject(); - return (root == null) ? null : root.getVersion(); - } - - /** - * Build a new resource type every time(?). - */ - public JptResourceType getResourceType() { - String version = this.getVersion(); - return ((this.contentType == null) || (version == null)) ? - null : - new JptResourceType(this.contentType, version); - } - - - // ********** BasicNotifierImpl override ********** - - /** - * Override to fire notification only when:<ul> - * <li>the resource's state has actually changed; and - * <li>the resource is loaded; and - * <li>the resource's resource set is still present (EMF will fire an - * notification when the resource set is set to 'null', just before - * the resource is "unloaded" - we want to swallow this notification) - * </ul> - */ - @Override - public void eNotify(Notification notification) { - // unload events can happen before the resource set is removed - should always react to unload events - if (this.loadedFlagCleared(notification)) { - super.eNotify(notification); - if (this.isReverting()) { - this.resourceModelReverted(); - } else { - this.resourceModelUnloaded(); - } - } - else if ( ! notification.isTouch() && this.isLoaded() && (this.resourceSet != null)) { - super.eNotify(notification); - this.resourceModelChanged(); - } - } - - /** - * Return whether the specified notification indicates the resource has been - * unloaded. - * we could use this method to suppress some notifications; or we could just - * check whether 'resourceSet' is 'null' (which is what we do) - */ - protected boolean loadedFlagCleared(Notification notification) { - return (notification.getNotifier() == this) && - (notification.getEventType() == Notification.SET) && - (notification.getFeatureID(Resource.class) == RESOURCE__IS_LOADED) && - ( ! notification.getNewBooleanValue()); - } - - /** - * Return whether the specified notification indicates the resource's - * resource set was cleared. - * We could use this method to suppress some resource set notifications; - * or we could just check whether <code>resourceSet</code> is - * <code>null</code> (which is what we do)/ - */ - protected boolean resultSetCleared(Notification notification) { - return (notification.getNotifier() == this) && - (notification.getEventType() == Notification.SET) && - (notification.getFeatureID(Resource.class) == RESOURCE__RESOURCE_SET) && - (notification.getNewValue() == null); - } - - - // ********** TranslatorResource implementation ********** - - /** - * only applicable for DTD-based files - */ - public String getDoctype() { - return null; - } - - public Translator getRootTranslator() { - return this.rootTranslator; - } - - - // ********** TranslatorResourceImpl implementation ********** - - /** - * only applicable for DTD-based files - */ - @Override - protected String getDefaultPublicId() { - return null; - } - - /** - * only applicable for DTD-based files - */ - @Override - protected String getDefaultSystemId() { - return null; - } - - /** - * this seems to be the default version of the spec for this doc - * and the id 10 maps to the version 1.0 - */ - @Override - protected int getDefaultVersionID() { - return 10; - } - - @Override - public JpaRootEObject getRootObject() { - EObject root = super.getRootObject(); - try { - return (JpaRootEObject) root; - } catch (ClassCastException ex) { - throw new IllegalStateException("The root object of a JPA XML resource must implement JpaRootEObject: " + root, ex); //$NON-NLS-1$ - } - } - - //296544 - override this to avoid internet access finding the schema during tests - @Override - public EntityResolver getEntityResolver() { - return J2EEXmlDtDEntityResolver.INSTANCE; - } - - - // ********** convenience methods ********** - - public boolean fileExists() { - return this.getFile().exists(); - } - - public IFile getFile() { - IFile file = this.getFile(this.uri); - return (file != null) ? file : this.getConvertedURIFile(); - } - - protected IFile getConvertedURIFile() { - if (this.resourceSet == null) { - return null; - } - URI convertedURI = this.resourceSet.getURIConverter().normalize(this.uri); - return this.uri.equals(convertedURI) ? null : this.getFile(convertedURI); - } - - /** - * Return the Eclipse file for the specified URI. - * This URI is assumed to be absolute in the following format: - * platform:/resource/.... - */ - protected IFile getFile(URI fileURI) { - if ( ! WorkbenchResourceHelperBase.isPlatformResourceURI(fileURI)) { - return null; - } - String fileName = URI.decode(fileURI.path()).substring(JEMUtilPlugin.PLATFORM_RESOURCE.length() + 1); - return ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(fileName)); - } - - public IProject getProject() { - return this.getFile().getProject(); - } - - public void modify(Runnable runnable) { - try { - runnable.run(); - try { - save(Collections.EMPTY_MAP); - } catch (IOException ex) { - JptJpaCorePlugin.log(ex); - } - } catch (Exception ex) { - JptJpaCorePlugin.log(ex); - } - } - - @Override - public String toString() { - // implementation in TranslatorResourceImpl is a bit off... - return StringTools.buildToStringFor(this, this.getURI()); - } - - - // ********** JptResourceModel implementation ********** - - public void addResourceModelListener(JptResourceModelListener listener) { - this.resourceModelListenerList.add(listener); - } - - public void removeResourceModelListener(JptResourceModelListener listener) { - this.resourceModelListenerList.remove(listener); - } - - - // ********** listener notifications ********** - - protected void resourceModelChanged() { - for (JptResourceModelListener listener : this.resourceModelListenerList.getListeners()) { - listener.resourceModelChanged(this); - } - } - - protected void resourceModelReverted() { - for (JptResourceModelListener listener : this.resourceModelListenerList.getListeners()) { - listener.resourceModelReverted(this); - } - } - - protected void resourceModelUnloaded() { - for (JptResourceModelListener listener : this.resourceModelListenerList.getListeners()) { - listener.resourceModelUnloaded(this); - } - } - - - // ********** cast things back to what they are in EMF ********** - - @SuppressWarnings("unchecked") - @Override - public EList<Adapter> eAdapters() { - return super.eAdapters(); - } - - @SuppressWarnings("unchecked") - @Override - public EList<EObject> getContents() { - return super.getContents(); - } -} diff --git a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/XML.java b/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/XML.java deleted file mode 100644 index 53e161227f..0000000000 --- a/jpa/plugins/org.eclipse.jpt.jpa.core/src/org/eclipse/jpt/jpa/core/resource/xml/XML.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 Oracle. All rights reserved. - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0, which accompanies this distribution - * and is available at http://www.eclipse.org/legal/epl-v10.html. - * - * Contributors: - * Oracle - initial API and implementation - ******************************************************************************/ -package org.eclipse.jpt.jpa.core.resource.xml; - -/** - * XML-related stuff. - * - * Provisional API: This interface is part of an interim API that is still - * under development and expected to change significantly before reaching - * stability. It is available at this early stage to solicit feedback from - * pioneering adopters on the understanding that any code that uses this API - * will almost certainly be broken (repeatedly) as the API evolves. - * - * @version 2.3 - * @since 2.2 - */ -@SuppressWarnings("nls") -public interface XML -{ - String VERSION = "version"; - - String NAMESPACE = "xmlns"; - - String NAMESPACE_XSI = "xmlns:xsi"; - String XSI_NAMESPACE_URL = "http://www.w3.org/2001/XMLSchema-instance"; - - String XSI_SCHEMA_LOCATION = "xsi:schemaLocation"; -} |