| /** |
| * Copyright (c) 2010 Attensity Europe GmbH. 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 |
| */ |
| package org.eclipse.smila.processing.designer.model.record.impl; |
| |
| import org.eclipse.bpel.model.util.ReconciliationHelper; |
| import org.eclipse.emf.common.notify.Notification; |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.impl.ENotificationImpl; |
| import org.eclipse.smila.processing.designer.model.processor.util.DOMUtils; |
| import org.eclipse.smila.processing.designer.model.record.RecordPackage; |
| import org.eclipse.smila.processing.designer.model.record.RecordVal; |
| import org.eclipse.smila.processing.designer.model.record.util.RecordConstants; |
| import org.w3c.dom.Document; |
| import org.w3c.dom.Element; |
| |
| /** |
| * <!-- begin-user-doc --> An implementation of the model object '<em><b>Val</b></em>'. <!-- end-user-doc --> |
| * <p> |
| * The following features are implemented: |
| * <ul> |
| * <li>{@link org.eclipse.smila.processing.designer.model.record.impl.RecordValImpl#getValue <em>Value</em>}</li> |
| * </ul> |
| * </p> |
| * |
| * @generated |
| */ |
| public class RecordValImpl extends RecordAnyImpl implements RecordVal { |
| /** |
| * The default value of the '{@link #getValue() <em>Value</em>}' attribute. <!-- begin-user-doc --> <!-- end-user-doc |
| * --> |
| * |
| * @see #getValue() |
| * @generated |
| * @ordered |
| */ |
| protected static final Object VALUE_EDEFAULT = null; |
| |
| /** |
| * The cached value of the '{@link #getValue() <em>Value</em>}' attribute. <!-- begin-user-doc --> <!-- end-user-doc |
| * --> |
| * |
| * @see #getValue() |
| * @generated |
| * @ordered |
| */ |
| protected Object value = VALUE_EDEFAULT; |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| protected RecordValImpl() { |
| super(); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| protected EClass eStaticClass() { |
| return RecordPackage.Literals.RECORD_VAL; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public Object getValue() { |
| return value; |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * |
| * @customized |
| */ |
| @Override |
| public void setValue(Object newValue) { |
| Type type = Type.getType(newValue); |
| if (type == null) { |
| throw new IllegalArgumentException("That type is not allowed for a value!"); |
| } |
| |
| Object oldValue = value; |
| value = newValue; |
| |
| if (shouldReconcile()) { |
| try { |
| setUpdatingDOM(true); |
| DOMUtils.writeTextContent(getElement(), type.format(newValue)); |
| } finally { |
| setUpdatingDOM(false); |
| } |
| ReconciliationHelper.replaceAttribute(this, RecordConstants.ATT_TYPE, type == Type.STRING ? null : type |
| .toString().toLowerCase()); |
| } |
| |
| if (eNotificationRequired()) { |
| eNotify(new ENotificationImpl(this, Notification.SET, RecordPackage.RECORD_VAL__VALUE, oldValue, value)); |
| } |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public Object eGet(int featureID, boolean resolve, boolean coreType) { |
| switch (featureID) { |
| case RecordPackage.RECORD_VAL__VALUE: |
| return getValue(); |
| } |
| return super.eGet(featureID, resolve, coreType); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public void eSet(int featureID, Object newValue) { |
| switch (featureID) { |
| case RecordPackage.RECORD_VAL__VALUE: |
| setValue(newValue); |
| return; |
| } |
| super.eSet(featureID, newValue); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public void eUnset(int featureID) { |
| switch (featureID) { |
| case RecordPackage.RECORD_VAL__VALUE: |
| setValue(VALUE_EDEFAULT); |
| return; |
| } |
| super.eUnset(featureID); |
| } |
| |
| /** |
| * <!-- begin-user-doc --> <!-- end-user-doc --> |
| * |
| * @generated |
| */ |
| @Override |
| public boolean eIsSet(int featureID) { |
| switch (featureID) { |
| case RecordPackage.RECORD_VAL__VALUE: |
| return VALUE_EDEFAULT == null ? value != null : !VALUE_EDEFAULT.equals(value); |
| } |
| 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(" (value: "); |
| result.append(value); |
| result.append(')'); |
| return result.toString(); |
| } |
| |
| /** |
| * @see org.eclipse.smila.processing.designer.model.record.RecordAny#isVal() |
| */ |
| @Override |
| public boolean isVal() { |
| return true; |
| } |
| |
| /** |
| * @see RecordVal#getType() |
| */ |
| @Override |
| public Type getType() { |
| return value == null ? null : Type.getType(value); |
| } |
| |
| /** |
| * @see ExtensionElementImpl#createFixedElement(Document) |
| */ |
| @Override |
| protected Element createFixedElement(Document document) { |
| Element element = document.createElementNS(RecordConstants.NS_URI, RecordConstants.ELEMENT_VAL); |
| element.setPrefix(RecordConstants.NS_PREFIX); |
| if (getKey() != null) { |
| element.setAttribute(RecordConstants.ATT_KEY, getKey()); |
| } |
| Type type = getType(); |
| if (type != null) { |
| if (type != Type.STRING) { |
| element.setAttribute(RecordConstants.ATT_TYPE, type.name().toLowerCase()); |
| } |
| element.appendChild(document.createTextNode(type.format(getValue()))); |
| } |
| return element; |
| } |
| |
| } // RecordValImpl |