/*******************************************************************************
* Copyright (c) 2011 Guillaume Hillairet.
* 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:
* Guillaume Hillairet - initial API and implementation
*******************************************************************************/
package com.emf4sw.rdf.impl;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;
import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import com.emf4sw.rdf.DocumentGraph;
import com.emf4sw.rdf.Namespace;
import com.emf4sw.rdf.RDFPackage;
/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Namespace</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link com.emf4sw.rdf.impl.NamespaceImpl#getPrefix <em>Prefix</em>}</li>
* <li>{@link com.emf4sw.rdf.impl.NamespaceImpl#getGraph <em>Graph</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class NamespaceImpl extends URIElementImpl implements Namespace {
/**
* The default value of the '{@link #getPrefix() <em>Prefix</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getPrefix()
* @generated
* @ordered
*/
protected static final String PREFIX_EDEFAULT = null;
/**
* The cached value of the '{@link #getPrefix() <em>Prefix</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getPrefix()
* @generated
* @ordered
*/
protected String prefix = PREFIX_EDEFAULT;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected NamespaceImpl() {
super();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return RDFPackage.Literals.NAMESPACE;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getPrefix() {
return prefix;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setPrefix(String newPrefix) {
String oldPrefix = prefix;
prefix = newPrefix;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, RDFPackage.NAMESPACE__PREFIX, oldPrefix, prefix));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public DocumentGraph getGraph() {
if (eContainerFeatureID() != RDFPackage.NAMESPACE__GRAPH) return null;
return (DocumentGraph)eContainer();
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetGraph(DocumentGraph newGraph, NotificationChain msgs) {
msgs = eBasicSetContainer((InternalEObject)newGraph, RDFPackage.NAMESPACE__GRAPH, msgs);
return msgs;
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setGraph(DocumentGraph newGraph) {
if (newGraph != eInternalContainer() || (eContainerFeatureID() != RDFPackage.NAMESPACE__GRAPH && newGraph != null)) {
if (EcoreUtil.isAncestor(this, newGraph))
throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
NotificationChain msgs = null;
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
if (newGraph != null)
msgs = ((InternalEObject)newGraph).eInverseAdd(this, RDFPackage.DOCUMENT_GRAPH__NAMESPACES, DocumentGraph.class, msgs);
msgs = basicSetGraph(newGraph, msgs);
if (msgs != null) msgs.dispatch();
}
else if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, RDFPackage.NAMESPACE__GRAPH, newGraph, newGraph));
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case RDFPackage.NAMESPACE__GRAPH:
if (eInternalContainer() != null)
msgs = eBasicRemoveFromContainer(msgs);
return basicSetGraph((DocumentGraph)otherEnd, msgs);
}
return super.eInverseAdd(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
switch (featureID) {
case RDFPackage.NAMESPACE__GRAPH:
return basicSetGraph(null, msgs);
}
return super.eInverseRemove(otherEnd, featureID, msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
switch (eContainerFeatureID()) {
case RDFPackage.NAMESPACE__GRAPH:
return eInternalContainer().eInverseRemove(this, RDFPackage.DOCUMENT_GRAPH__NAMESPACES, DocumentGraph.class, msgs);
}
return super.eBasicRemoveFromContainerFeature(msgs);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case RDFPackage.NAMESPACE__PREFIX:
return getPrefix();
case RDFPackage.NAMESPACE__GRAPH:
return getGraph();
}
return super.eGet(featureID, resolve, coreType);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case RDFPackage.NAMESPACE__PREFIX:
setPrefix((String)newValue);
return;
case RDFPackage.NAMESPACE__GRAPH:
setGraph((DocumentGraph)newValue);
return;
}
super.eSet(featureID, newValue);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case RDFPackage.NAMESPACE__PREFIX:
setPrefix(PREFIX_EDEFAULT);
return;
case RDFPackage.NAMESPACE__GRAPH:
setGraph((DocumentGraph)null);
return;
}
super.eUnset(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case RDFPackage.NAMESPACE__PREFIX:
return PREFIX_EDEFAULT == null ? prefix != null : !PREFIX_EDEFAULT.equals(prefix);
case RDFPackage.NAMESPACE__GRAPH:
return getGraph() != null;
}
return super.eIsSet(featureID);
}
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();
return prefix+" : <"+uri+">";
}
} //NamespaceImpl