| /******************************************************************************* |
| * Copyright (c) 2007, 2009 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.orm; |
| |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.EStructuralFeature; |
| import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| import org.eclipse.jpt.common.core.internal.utility.translators.SimpleTranslator; |
| import org.eclipse.wst.common.internal.emf.resource.Translator; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * A representation of the model object '<em><b>Discriminator Column</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.orm.XmlDiscriminatorColumn#getDiscriminatorType <em>Discriminator Type</em>}</li> |
| * <li>{@link org.eclipse.jpt.jpa.core.resource.orm.XmlDiscriminatorColumn#getLength <em>Length</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @see org.eclipse.jpt.jpa.core.resource.orm.OrmPackage#getXmlDiscriminatorColumn() |
| * @model kind="class" |
| * @generated |
| */ |
| public class XmlDiscriminatorColumn extends AbstractXmlNamedColumn |
| { |
| /** |
| * changed this to null and removed the generated flag so emf won't generate over it |
| * we don't want a default for enums, just null if the tag does not exist |
| */ |
| protected static final DiscriminatorType DISCRIMINATOR_TYPE_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getDiscriminatorType() <em>Discriminator Type</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getDiscriminatorType() |
| * @generated |
| * @ordered |
| */ |
| protected DiscriminatorType discriminatorType = DISCRIMINATOR_TYPE_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #getLength() <em>Length</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getLength() |
| * @generated |
| * @ordered |
| */ |
| protected static final Integer LENGTH_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getLength() <em>Length</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getLength() |
| * @generated |
| * @ordered |
| */ |
| protected Integer length = LENGTH_EDEFAULT; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected XmlDiscriminatorColumn() |
| { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() |
| { |
| return OrmPackage.Literals.XML_DISCRIMINATOR_COLUMN; |
| } |
| |
| /** |
| * Returns the value of the '<em><b>Discriminator Type</b></em>' attribute. |
| * The default value is <code>"STRING"</code>. |
| * The literals are from the enumeration {@link org.eclipse.jpt.jpa.core.resource.orm.DiscriminatorType}. |
| * <!-- begin-user-doc --> |
| * <p> |
| * If the meaning of the '<em>Discriminator Type</em>' attribute isn't clear, |
| * there really should be more of a description here... |
| * </p> |
| * <!-- end-user-doc --> |
| * @return the value of the '<em>Discriminator Type</em>' attribute. |
| * @see org.eclipse.jpt.jpa.core.resource.orm.DiscriminatorType |
| * @see #setDiscriminatorType(DiscriminatorType) |
| * @see org.eclipse.jpt.jpa.core.resource.orm.OrmPackage#getXmlDiscriminatorColumn_DiscriminatorType() |
| * @model default="STRING" |
| * @generated |
| */ |
| public DiscriminatorType getDiscriminatorType() |
| { |
| return discriminatorType; |
| } |
| |
| /** |
| * Sets the value of the '{@link org.eclipse.jpt.jpa.core.resource.orm.XmlDiscriminatorColumn#getDiscriminatorType <em>Discriminator Type</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @param value the new value of the '<em>Discriminator Type</em>' attribute. |
| * @see org.eclipse.jpt.jpa.core.resource.orm.DiscriminatorType |
| * @see #getDiscriminatorType() |
| * @generated |
| */ |
| public void setDiscriminatorType(DiscriminatorType newDiscriminatorType) |
| { |
| DiscriminatorType oldDiscriminatorType = discriminatorType; |
| discriminatorType = newDiscriminatorType == null ? DISCRIMINATOR_TYPE_EDEFAULT : newDiscriminatorType; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_DISCRIMINATOR_COLUMN__DISCRIMINATOR_TYPE, oldDiscriminatorType, discriminatorType)); |
| } |
| |
| /** |
| * Returns the value of the '<em><b>Length</b></em>' attribute. |
| * <!-- begin-user-doc --> |
| * <p> |
| * If the meaning of the '<em>Length</em>' attribute isn't clear, |
| * there really should be more of a description here... |
| * </p> |
| * <!-- end-user-doc --> |
| * @return the value of the '<em>Length</em>' attribute. |
| * @see #setLength(Integer) |
| * @see org.eclipse.jpt.jpa.core.resource.orm.OrmPackage#getXmlDiscriminatorColumn_Length() |
| * @model dataType="org.eclipse.emf.ecore.xml.type.IntObject" |
| * @generated |
| */ |
| public Integer getLength() |
| { |
| return length; |
| } |
| |
| /** |
| * Sets the value of the '{@link org.eclipse.jpt.jpa.core.resource.orm.XmlDiscriminatorColumn#getLength <em>Length</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @param value the new value of the '<em>Length</em>' attribute. |
| * @see #getLength() |
| * @generated |
| */ |
| public void setLength(Integer newLength) |
| { |
| Integer oldLength = length; |
| length = newLength; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_DISCRIMINATOR_COLUMN__LENGTH, oldLength, length)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) |
| { |
| switch (featureID) |
| { |
| case OrmPackage.XML_DISCRIMINATOR_COLUMN__DISCRIMINATOR_TYPE: |
| return getDiscriminatorType(); |
| case OrmPackage.XML_DISCRIMINATOR_COLUMN__LENGTH: |
| return getLength(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eSet(int featureID, Object newValue) |
| { |
| switch (featureID) |
| { |
| case OrmPackage.XML_DISCRIMINATOR_COLUMN__DISCRIMINATOR_TYPE: |
| setDiscriminatorType((DiscriminatorType)newValue); |
| return; |
| case OrmPackage.XML_DISCRIMINATOR_COLUMN__LENGTH: |
| setLength((Integer)newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) |
| { |
| switch (featureID) |
| { |
| case OrmPackage.XML_DISCRIMINATOR_COLUMN__DISCRIMINATOR_TYPE: |
| setDiscriminatorType(DISCRIMINATOR_TYPE_EDEFAULT); |
| return; |
| case OrmPackage.XML_DISCRIMINATOR_COLUMN__LENGTH: |
| setLength(LENGTH_EDEFAULT); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) |
| { |
| switch (featureID) |
| { |
| case OrmPackage.XML_DISCRIMINATOR_COLUMN__DISCRIMINATOR_TYPE: |
| return discriminatorType != DISCRIMINATOR_TYPE_EDEFAULT; |
| case OrmPackage.XML_DISCRIMINATOR_COLUMN__LENGTH: |
| return LENGTH_EDEFAULT == null ? length != null : !LENGTH_EDEFAULT.equals(length); |
| } |
| 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(" (discriminatorType: "); |
| result.append(discriminatorType); |
| result.append(", length: "); |
| result.append(length); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| // ********** translators ********** |
| |
| public static Translator buildTranslator(String elementName, EStructuralFeature structuralFeature) { |
| return new SimpleTranslator( |
| elementName, |
| structuralFeature, |
| Translator.END_TAG_NO_INDENT, |
| buildTranslatorChildren() |
| ); |
| } |
| |
| private static Translator[] buildTranslatorChildren() { |
| return new Translator[] { |
| buildNameTranslator(), |
| buildDiscrminiatorTypeTranslator(), |
| buildColumnDefinitionTranslator(), |
| buildLengthTranslator() |
| }; |
| } |
| |
| protected static Translator buildDiscrminiatorTypeTranslator() { |
| return new Translator(JPA.DISCRIMINATOR_TYPE, OrmPackage.eINSTANCE.getXmlDiscriminatorColumn_DiscriminatorType(), Translator.DOM_ATTRIBUTE); |
| } |
| |
| protected static Translator buildLengthTranslator() { |
| return new Translator(JPA.LENGTH, OrmPackage.eINSTANCE.getXmlDiscriminatorColumn_Length(), Translator.DOM_ATTRIBUTE); |
| } |
| } // DiscriminatorColumn |