Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2010-10-08 18:17:41 +0000
committerEike Stepper2010-10-08 18:17:41 +0000
commita4091c5cf1daaed59a8c9a2f051f7a5d0d4ffe89 (patch)
tree90b31d9ffde5742b03f734aaec51dd93db7d4b77 /plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util
parenta3b25774e957f1277023af52a658803d763eaedf (diff)
downloadcdo-a4091c5cf1daaed59a8c9a2f051f7a5d0d4ffe89.tar.gz
cdo-a4091c5cf1daaed59a8c9a2f051f7a5d0d4ffe89.tar.xz
cdo-a4091c5cf1daaed59a8c9a2f051f7a5d0d4ffe89.zip
[256931] Provide common query language (OCL)
https://bugs.eclipse.org/bugs/show_bug.cgi?id=256931
Diffstat (limited to 'plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util')
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java244
1 files changed, 0 insertions, 244 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
deleted file mode 100644
index 731f879041..0000000000
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/FSMUtil.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/**
- * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
- * 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:
- * Eike Stepper - initial API and implementation
- * Simon McDuff - bug 246705
- */
-package org.eclipse.emf.internal.cdo.util;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.CDOState;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
-import org.eclipse.emf.cdo.util.LegacyModeNotEnabledException;
-import org.eclipse.emf.cdo.view.CDOView;
-
-import org.eclipse.emf.internal.cdo.CDOLegacyAdapter;
-import org.eclipse.emf.internal.cdo.CDOMetaWrapper;
-import org.eclipse.emf.internal.cdo.CDOObjectImpl;
-import org.eclipse.emf.internal.cdo.messages.Messages;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EGenericType;
-import org.eclipse.emf.ecore.EModelElement;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.spi.cdo.InternalCDOObject;
-import org.eclipse.emf.spi.cdo.InternalCDOView;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-/**
- * @author Eike Stepper
- */
-public final class FSMUtil
-{
- private FSMUtil()
- {
- }
-
- public static boolean isTransient(CDOObject object)
- {
- CDOState state = object.cdoState();
- return state == CDOState.TRANSIENT || state == CDOState.PREPARED;
- }
-
- public static boolean isInvalid(CDOObject object)
- {
- CDOState state = object.cdoState();
- return state == CDOState.INVALID || state == CDOState.INVALID_CONFLICT;
- }
-
- public static boolean isConflict(CDOObject object)
- {
- CDOState state = object.cdoState();
- return state == CDOState.CONFLICT || state == CDOState.INVALID_CONFLICT;
- }
-
- public static boolean isNew(CDOObject object)
- {
- CDOState state = object.cdoState();
- return state == CDOState.NEW;
- }
-
- public static boolean isMeta(Object object)
- {
- if (object instanceof EModelElement || object instanceof EGenericType)
- {
- EClass eClass = ((EObject)object).eClass();
- if (eClass == null)
- {
- return false;
- }
-
- EPackage ePackage = eClass.getEPackage();
- if (ePackage == null)
- {
- return false;
- }
-
- return ePackage.getNsURI() == EcorePackage.eNS_URI;
- }
-
- return object instanceof org.eclipse.emf.ecore.impl.EStringToStringMapEntryImpl;
- }
-
- public static boolean isNative(EObject eObject)
- {
- return eObject instanceof CDOObjectImpl;
- }
-
- /**
- * @param view
- * Only needed if object is a meta instance.
- */
- public static InternalCDOObject adapt(Object object, CDOView view)
- {
- if (view.isClosed())
- {
- throw new IllegalStateException(Messages.getString("FSMUtil.0")); //$NON-NLS-1$
- }
-
- if (object instanceof InternalCDOObject)
- {
- return (InternalCDOObject)object;
- }
-
- if (object == null)
- {
- throw new IllegalArgumentException(Messages.getString("FSMUtil.1")); //$NON-NLS-1$
- }
-
- if (isMeta(object))
- {
- return adaptMeta((InternalEObject)object, view);
- }
-
- if (object instanceof InternalEObject)
- {
- if (!view.isLegacyModeEnabled())
- {
- throw new LegacyModeNotEnabledException();
- }
-
- return adaptLegacy((InternalEObject)object);
- }
-
- return null;
- }
-
- public static InternalCDOObject adaptMeta(InternalEObject object, CDOView view)
- {
- if (view == null)
- {
- throw new IllegalArgumentException(Messages.getString("FSMUtil.2")); //$NON-NLS-1$
- }
-
- if (object.eIsProxy())
- {
- object = (InternalEObject)EcoreUtil.resolve(object, view.getResourceSet());
- }
-
- try
- {
- InternalCDOPackageRegistry packageRegistry = (InternalCDOPackageRegistry)view.getSession().getPackageRegistry();
- CDOID id = packageRegistry.getMetaInstanceMapper().lookupMetaInstanceID(object);
- return new CDOMetaWrapper((InternalCDOView)view, object, id);
- }
- catch (RuntimeException ex)
- {
- return null;
- }
- }
-
- /*
- * IMPORTANT: Compile errors in this method might indicate an old version of EMF. Legacy support is only enabled for
- * EMF with fixed bug #247130. These compile errors do not affect native models!
- */
- public static InternalCDOObject adaptLegacy(InternalEObject object)
- {
- EList<Adapter> adapters = object.eAdapters();
- CDOLegacyAdapter adapter = getLegacyAdapter(adapters);
- if (adapter == null)
- {
- adapter = new CDOLegacyAdapter(object);
- }
-
- return adapter;
-
- // EList<InternalEObject.EReadListener> readListeners = object.eReadListeners();
- // CDOLegacyWrapper wrapper = getLegacyWrapper(readListeners);
- // if (wrapper == null)
- // {
- // wrapper = new CDOLegacyWrapper(object);
- // // TODO Only Load/Attach transitions should actually *add* the wrappers!
- // readListeners.add(0, wrapper);
- // object.eWriteListeners().add(0, wrapper);
- // }
- //
- // return wrapper;
- }
-
- public static CDOLegacyAdapter getLegacyAdapter(EList<Adapter> adapters)
- {
- return (CDOLegacyAdapter)EcoreUtil.getAdapter(adapters, CDOLegacyAdapter.class);
- }
-
- // public static CDOLegacyWrapper getLegacyWrapper(EList<?> listeners)
- // {
- // for (Object listener : listeners)
- // {
- // if (listener.getClass() == CDOLegacyWrapper.class)
- // {
- // return (CDOLegacyWrapper)listener;
- // }
- // }
- //
- // return null;
- // }
-
- public static Iterator<InternalCDOObject> iterator(final Iterator<?> delegate, final InternalCDOView view)
- {
- return new Iterator<InternalCDOObject>()
- {
- private Object next;
-
- public boolean hasNext()
- {
- if (delegate.hasNext())
- {
- next = adapt(delegate.next(), view);
- return true;
- }
-
- return false;
- }
-
- public InternalCDOObject next()
- {
- return (InternalCDOObject)next;
- }
-
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
- };
- }
-
- public static Iterator<InternalCDOObject> iterator(Collection<?> instances, final InternalCDOView view)
- {
- return iterator(instances.iterator(), view);
- }
-}

Back to the top