| /******************************************************************************* |
| * 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>Column Impl</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.XmlColumn#getLength <em>Length</em>}</li> |
| * <li>{@link org.eclipse.jpt.jpa.core.resource.orm.XmlColumn#getPrecision <em>Precision</em>}</li> |
| * <li>{@link org.eclipse.jpt.jpa.core.resource.orm.XmlColumn#getScale <em>Scale</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @see org.eclipse.jpt.jpa.core.resource.orm.OrmPackage#getXmlColumn() |
| * @model kind="class" |
| * @generated |
| */ |
| public class XmlColumn extends AbstractXmlColumn |
| { |
| /** |
| * 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; |
| |
| /** |
| * The default value of the '{@link #getPrecision() <em>Precision</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getPrecision() |
| * @generated |
| * @ordered |
| */ |
| protected static final Integer PRECISION_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getPrecision() <em>Precision</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getPrecision() |
| * @generated |
| * @ordered |
| */ |
| protected Integer precision = PRECISION_EDEFAULT; |
| |
| /** |
| * The default value of the '{@link #getScale() <em>Scale</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getScale() |
| * @generated |
| * @ordered |
| */ |
| protected static final Integer SCALE_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getScale() <em>Scale</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @see #getScale() |
| * @generated |
| * @ordered |
| */ |
| protected Integer scale = SCALE_EDEFAULT; |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| protected XmlColumn() |
| { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() |
| { |
| return OrmPackage.Literals.XML_COLUMN; |
| } |
| |
| /** |
| * 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#getXmlColumn_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.XmlColumn#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_COLUMN__LENGTH, oldLength, length)); |
| } |
| |
| /** |
| * Returns the value of the '<em><b>Precision</b></em>' attribute. |
| * <!-- begin-user-doc --> |
| * <p> |
| * If the meaning of the '<em>Precision</em>' attribute isn't clear, |
| * there really should be more of a description here... |
| * </p> |
| * <!-- end-user-doc --> |
| * @return the value of the '<em>Precision</em>' attribute. |
| * @see #setPrecision(Integer) |
| * @see org.eclipse.jpt.jpa.core.resource.orm.OrmPackage#getXmlColumn_Precision() |
| * @model dataType="org.eclipse.emf.ecore.xml.type.IntObject" |
| * @generated |
| */ |
| public Integer getPrecision() |
| { |
| return precision; |
| } |
| |
| /** |
| * Sets the value of the '{@link org.eclipse.jpt.jpa.core.resource.orm.XmlColumn#getPrecision <em>Precision</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @param value the new value of the '<em>Precision</em>' attribute. |
| * @see #getPrecision() |
| * @generated |
| */ |
| public void setPrecision(Integer newPrecision) |
| { |
| Integer oldPrecision = precision; |
| precision = newPrecision; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_COLUMN__PRECISION, oldPrecision, precision)); |
| } |
| |
| /** |
| * Returns the value of the '<em><b>Scale</b></em>' attribute. |
| * <!-- begin-user-doc --> |
| * <p> |
| * If the meaning of the '<em>Scale</em>' attribute isn't clear, |
| * there really should be more of a description here... |
| * </p> |
| * <!-- end-user-doc --> |
| * @return the value of the '<em>Scale</em>' attribute. |
| * @see #setScale(Integer) |
| * @see org.eclipse.jpt.jpa.core.resource.orm.OrmPackage#getXmlColumn_Scale() |
| * @model dataType="org.eclipse.emf.ecore.xml.type.IntObject" |
| * @generated |
| */ |
| public Integer getScale() |
| { |
| return scale; |
| } |
| |
| /** |
| * Sets the value of the '{@link org.eclipse.jpt.jpa.core.resource.orm.XmlColumn#getScale <em>Scale</em>}' attribute. |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @param value the new value of the '<em>Scale</em>' attribute. |
| * @see #getScale() |
| * @generated |
| */ |
| public void setScale(Integer newScale) |
| { |
| Integer oldScale = scale; |
| scale = newScale; |
| if (eNotificationRequired()) |
| eNotify(new ENotificationImpl(this, Notification.SET, OrmPackage.XML_COLUMN__SCALE, oldScale, scale)); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) |
| { |
| switch (featureID) |
| { |
| case OrmPackage.XML_COLUMN__LENGTH: |
| return getLength(); |
| case OrmPackage.XML_COLUMN__PRECISION: |
| return getPrecision(); |
| case OrmPackage.XML_COLUMN__SCALE: |
| return getScale(); |
| } |
| 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_COLUMN__LENGTH: |
| setLength((Integer)newValue); |
| return; |
| case OrmPackage.XML_COLUMN__PRECISION: |
| setPrecision((Integer)newValue); |
| return; |
| case OrmPackage.XML_COLUMN__SCALE: |
| setScale((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_COLUMN__LENGTH: |
| setLength(LENGTH_EDEFAULT); |
| return; |
| case OrmPackage.XML_COLUMN__PRECISION: |
| setPrecision(PRECISION_EDEFAULT); |
| return; |
| case OrmPackage.XML_COLUMN__SCALE: |
| setScale(SCALE_EDEFAULT); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> |
| * <!-- end-user-doc --> |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) |
| { |
| switch (featureID) |
| { |
| case OrmPackage.XML_COLUMN__LENGTH: |
| return LENGTH_EDEFAULT == null ? length != null : !LENGTH_EDEFAULT.equals(length); |
| case OrmPackage.XML_COLUMN__PRECISION: |
| return PRECISION_EDEFAULT == null ? precision != null : !PRECISION_EDEFAULT.equals(precision); |
| case OrmPackage.XML_COLUMN__SCALE: |
| return SCALE_EDEFAULT == null ? scale != null : !SCALE_EDEFAULT.equals(scale); |
| } |
| 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(" (length: "); |
| result.append(length); |
| result.append(", precision: "); |
| result.append(precision); |
| result.append(", scale: "); |
| result.append(scale); |
| 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(), |
| buildUniqueTranslator(), |
| buildNullableTranslator(), |
| buildInsertableTranslator(), |
| buildUpdatableTranslator(), |
| buildColumnDefinitionTranslator(), |
| buildTableTranslator(), |
| buildLengthTranslator(), |
| buildPrecisionTranslator(), |
| buildScaleTranslator(), |
| }; |
| } |
| |
| protected static Translator buildLengthTranslator() { |
| return new Translator(JPA.LENGTH, OrmPackage.eINSTANCE.getXmlColumn_Length(), Translator.DOM_ATTRIBUTE); |
| } |
| |
| protected static Translator buildPrecisionTranslator() { |
| return new Translator(JPA.PRECISION, OrmPackage.eINSTANCE.getXmlColumn_Precision(), Translator.DOM_ATTRIBUTE); |
| } |
| |
| protected static Translator buildScaleTranslator() { |
| return new Translator(JPA.SCALE, OrmPackage.eINSTANCE.getXmlColumn_Scale(), Translator.DOM_ATTRIBUTE); |
| } |
| } // ColumnImpl |