diff options
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common')
117 files changed, 9411 insertions, 9411 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOCommonRepository.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOCommonRepository.java index 1d63fa854d..782d4d99aa 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOCommonRepository.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOCommonRepository.java @@ -1,176 +1,176 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common; - -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.util.CDOTimeProvider; - -import org.eclipse.net4j.util.event.IEvent; - -import java.util.Set; - -/** - * Abstracts the information about CDO repositories that is common to both client and server side. - * <p> - * A CDOCommonRepository can fire the following events: - * <ul> - * <li> {@link TypeChangedEvent} after the {@link #getType() repository type} has changed in a fail-over cluster. - * <li> {@link StateChangedEvent} after the {@link #getState() repository state} has changed in a replicating deployment. - * </ul> - * - * @author Eike Stepper - * @since 3.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.landmark - * @apiviz.has {@link CDOCommonRepository.IDGenerationLocation} - * @apiviz.has {@link CDOCommonRepository.Type} - * @apiviz.has {@link CDOCommonRepository.State} - * @apiviz.uses {@link CDOCommonRepository.TypeChangedEvent} - - fires - * @apiviz.uses {@link CDOCommonRepository.StateChangedEvent} - - fires - */ -public interface CDOCommonRepository extends CDOTimeProvider -{ - /** - * Returns the name of this repository. - */ - public String getName(); - - /** - * Returns the UUID of this repository. - */ - public String getUUID(); - - /** - * Returns the type of this repository. - */ - public Type getType(); - - /** - * Returns the state of this repository. - */ - public State getState(); - - /** - * Returns the creation time of this repository. - */ - public long getCreationTime(); - - /** - * Returns the type of the store of this repository. - */ - public String getStoreType(); - - /** - * Returns the type of CDOIDs created by the store of this repository. - */ - public Set<CDOID.ObjectType> getObjectIDTypes(); - - /** - * @since 4.1 - */ - public IDGenerationLocation getIDGenerationLocation(); - - /** - * Returns the ID of the root resource of this repository. - */ - public CDOID getRootResourceID(); - - /** - * Returns <code>true</code> if this repository supports auditing, <code>false</code> otherwise. - */ - public boolean isSupportingAudits(); - - /** - * Returns <code>true</code> if this repository supports branching, <code>false</code> otherwise. - */ - public boolean isSupportingBranches(); - - /** - * Returns <code>true</code> if this repository supports instances of Ecore, <code>false</code> otherwise. - * - * @since 4.0 - */ - public boolean isSupportingEcore(); - - /** - * Returns <code>true</code> if this repository ensures referential integrity, <code>false</code> otherwise. - * - * @since 4.0 - */ - public boolean isEnsuringReferentialIntegrity(); - - /** - * Enumerates the possible {@link CDOCommonRepository#getIDGenerationLocation() ID generation locations} of a CDO - * repository. - * - * @author Eike Stepper - * @since 4.1 - */ - public enum IDGenerationLocation - { - STORE, CLIENT - } - - /** - * Enumerates the possible {@link CDOCommonRepository#getType() types} of a CDO repository. - * - * @author Eike Stepper - */ - public enum Type - { - MASTER, BACKUP, CLONE - } - - /** - * Enumerates the possible {@link CDOCommonRepository#getState() states} of a CDO repository. - * - * @author Eike Stepper - */ - public static enum State - { - INITIAL, OFFLINE, SYNCING, ONLINE; - - public boolean isConnected() - { - return this == SYNCING || this == ONLINE; - } - } - - /** - * An {@link IEvent event} fired when the {@link Type type} of a CDO repository has changed. This usually happens only - * for repository fail-over participants. - * - * @author Eike Stepper - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ - public interface TypeChangedEvent extends IEvent - { - public Type getOldType(); - - public Type getNewType(); - } - - /** - * An {@link IEvent event} fired when the {@link State state} of a CDO repository has changed. - * - * @author Eike Stepper - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ - public interface StateChangedEvent extends IEvent - { - public State getOldState(); - - public State getNewState(); - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.util.CDOTimeProvider;
+
+import org.eclipse.net4j.util.event.IEvent;
+
+import java.util.Set;
+
+/**
+ * Abstracts the information about CDO repositories that is common to both client and server side.
+ * <p>
+ * A CDOCommonRepository can fire the following events:
+ * <ul>
+ * <li> {@link TypeChangedEvent} after the {@link #getType() repository type} has changed in a fail-over cluster.
+ * <li> {@link StateChangedEvent} after the {@link #getState() repository state} has changed in a replicating deployment.
+ * </ul>
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.landmark
+ * @apiviz.has {@link CDOCommonRepository.IDGenerationLocation}
+ * @apiviz.has {@link CDOCommonRepository.Type}
+ * @apiviz.has {@link CDOCommonRepository.State}
+ * @apiviz.uses {@link CDOCommonRepository.TypeChangedEvent} - - fires
+ * @apiviz.uses {@link CDOCommonRepository.StateChangedEvent} - - fires
+ */
+public interface CDOCommonRepository extends CDOTimeProvider
+{
+ /**
+ * Returns the name of this repository.
+ */
+ public String getName();
+
+ /**
+ * Returns the UUID of this repository.
+ */
+ public String getUUID();
+
+ /**
+ * Returns the type of this repository.
+ */
+ public Type getType();
+
+ /**
+ * Returns the state of this repository.
+ */
+ public State getState();
+
+ /**
+ * Returns the creation time of this repository.
+ */
+ public long getCreationTime();
+
+ /**
+ * Returns the type of the store of this repository.
+ */
+ public String getStoreType();
+
+ /**
+ * Returns the type of CDOIDs created by the store of this repository.
+ */
+ public Set<CDOID.ObjectType> getObjectIDTypes();
+
+ /**
+ * @since 4.1
+ */
+ public IDGenerationLocation getIDGenerationLocation();
+
+ /**
+ * Returns the ID of the root resource of this repository.
+ */
+ public CDOID getRootResourceID();
+
+ /**
+ * Returns <code>true</code> if this repository supports auditing, <code>false</code> otherwise.
+ */
+ public boolean isSupportingAudits();
+
+ /**
+ * Returns <code>true</code> if this repository supports branching, <code>false</code> otherwise.
+ */
+ public boolean isSupportingBranches();
+
+ /**
+ * Returns <code>true</code> if this repository supports instances of Ecore, <code>false</code> otherwise.
+ *
+ * @since 4.0
+ */
+ public boolean isSupportingEcore();
+
+ /**
+ * Returns <code>true</code> if this repository ensures referential integrity, <code>false</code> otherwise.
+ *
+ * @since 4.0
+ */
+ public boolean isEnsuringReferentialIntegrity();
+
+ /**
+ * Enumerates the possible {@link CDOCommonRepository#getIDGenerationLocation() ID generation locations} of a CDO
+ * repository.
+ *
+ * @author Eike Stepper
+ * @since 4.1
+ */
+ public enum IDGenerationLocation
+ {
+ STORE, CLIENT
+ }
+
+ /**
+ * Enumerates the possible {@link CDOCommonRepository#getType() types} of a CDO repository.
+ *
+ * @author Eike Stepper
+ */
+ public enum Type
+ {
+ MASTER, BACKUP, CLONE
+ }
+
+ /**
+ * Enumerates the possible {@link CDOCommonRepository#getState() states} of a CDO repository.
+ *
+ * @author Eike Stepper
+ */
+ public static enum State
+ {
+ INITIAL, OFFLINE, SYNCING, ONLINE;
+
+ public boolean isConnected()
+ {
+ return this == SYNCING || this == ONLINE;
+ }
+ }
+
+ /**
+ * An {@link IEvent event} fired when the {@link Type type} of a CDO repository has changed. This usually happens only
+ * for repository fail-over participants.
+ *
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+ public interface TypeChangedEvent extends IEvent
+ {
+ public Type getOldType();
+
+ public Type getNewType();
+ }
+
+ /**
+ * An {@link IEvent event} fired when the {@link State state} of a CDO repository has changed.
+ *
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+ public interface StateChangedEvent extends IEvent
+ {
+ public State getOldState();
+
+ public State getNewState();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOCommonSession.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOCommonSession.java index 2c8751b5d7..c5a68c63c8 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOCommonSession.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOCommonSession.java @@ -1,187 +1,187 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common; - -import org.eclipse.net4j.util.collection.Closeable; -import org.eclipse.net4j.util.options.IOptions; -import org.eclipse.net4j.util.options.IOptionsContainer; -import org.eclipse.net4j.util.options.IOptionsEvent; -import org.eclipse.net4j.util.security.IUserAware; - -/** - * Abstracts the information about CDO sessions that is common to both client and server side. - * - * @author Eike Stepper - * @since 2.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.landmark - * @apiviz.composedOf {@link CDOCommonView} - - views - * @apiviz.has {@link CDOCommonSession.Options} - * @apiviz.uses {@link CDOCommonRepository} - - connectsTo - */ -public interface CDOCommonSession extends IUserAware, IOptionsContainer, Closeable -{ - public int getSessionID(); - - public CDOCommonView[] getViews(); - - public CDOCommonView getView(int viewID); - - /** - * Returns the {@link Options options} of this session. - */ - public Options options(); - - /** - * Encapsulates the configuration options of CDO sessions that are common to both client and server side. - * - * @author Simon McDuff - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.has CDOCommonSession.Options.PassiveUpdateMode - * @apiviz.has CDOCommonSession.Options.LockNotificationMode - */ - public interface Options extends IOptions - { - /** - * Returns the {@link CDOCommonSession session} of this options object. - * - * @since 4.0 - */ - public CDOCommonSession getContainer(); - - public boolean isPassiveUpdateEnabled(); - - /** - * Specifies whether objects will be invalidated due by other users changes. - * <p> - * Example: - * <p> - * <code>session.setPassiveUpdateEnabled(false);</code> - * <p> - * By default this property is enabled. If this property is disabled the latest versions of objects can still be - * obtained by calling refresh(). - * <p> - * Passive update can be disabled in cases where more performance is needed and/or more control over when objects - * will be refreshed. - * <p> - * When enabled again, a refresh will be automatically performed to be in sync with the server. - * - * @since 3.0 - */ - public void setPassiveUpdateEnabled(boolean enabled); - - /** - * @since 3.0 - */ - public PassiveUpdateMode getPassiveUpdateMode(); - - /** - * @since 3.0 - */ - public void setPassiveUpdateMode(PassiveUpdateMode mode); - - /** - * @since 4.1 - */ - public LockNotificationMode getLockNotificationMode(); - - /** - * @since 4.1 - */ - public void setLockNotificationMode(LockNotificationMode mode); - - /** - * Enumerates the possible {@link CDOCommonSession.Options#getPassiveUpdateMode() passive update modes} of a CDO - * session. - * - * @author Eike Stepper - * @since 3.0 - */ - public enum PassiveUpdateMode - { - /** - * This mode delivers change deltas only for change subscriptions, invalidation information for all other objects. - */ - INVALIDATIONS, - - /** - * This mode delivers change deltas for all changed objects, whether they have change subscriptions or not. - * Revisions for new objects are not delivered. - */ - CHANGES, - - /** - * This mode delivers change deltas for all changed objects, whether they have change subscriptions or not. In - * addition full revisions for new objects are delivered. - */ - ADDITIONS - } - - /** - * Enumerates the possible {@link CDOCommonSession.Options#getLockNotificationMode() lock notification modes} of a - * CDO session. - * - * @since 4.1 - */ - public enum LockNotificationMode - { - /** - * This mode delivers no lock notifications - */ - OFF, - - /** - * This mode delivers lock notifications if one or more views have enabled them. - */ - IF_REQUIRED_BY_VIEWS, - - /** - * This mode always delivers lock notifications, even if no views have them enabled, and even if no views are - * open. - */ - ALWAYS - } - - /** - * An {@link IOptionsEvent options event} fired when the {@link PassiveUpdateMode passive update mode} of a CDO - * session has changed. - * - * @author Eike Stepper - * @since 3.0 - */ - public interface PassiveUpdateEvent extends IOptionsEvent - { - public boolean getOldEnabled(); - - public boolean getNewEnabled(); - - public PassiveUpdateMode getOldMode(); - - public PassiveUpdateMode getNewMode(); - } - - /** - * An {@link IOptionsEvent options event} fired when the {@link LockNotificationMode lock notification mode} of a - * CDO session has changed. - * - * @author Caspar De Groot - * @since 4.1 - */ - public interface LockNotificationModeEvent extends IOptionsEvent - { - public LockNotificationMode getOldMode(); - - public LockNotificationMode getNewMode(); - } - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common;
+
+import org.eclipse.net4j.util.collection.Closeable;
+import org.eclipse.net4j.util.options.IOptions;
+import org.eclipse.net4j.util.options.IOptionsContainer;
+import org.eclipse.net4j.util.options.IOptionsEvent;
+import org.eclipse.net4j.util.security.IUserAware;
+
+/**
+ * Abstracts the information about CDO sessions that is common to both client and server side.
+ *
+ * @author Eike Stepper
+ * @since 2.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.landmark
+ * @apiviz.composedOf {@link CDOCommonView} - - views
+ * @apiviz.has {@link CDOCommonSession.Options}
+ * @apiviz.uses {@link CDOCommonRepository} - - connectsTo
+ */
+public interface CDOCommonSession extends IUserAware, IOptionsContainer, Closeable
+{
+ public int getSessionID();
+
+ public CDOCommonView[] getViews();
+
+ public CDOCommonView getView(int viewID);
+
+ /**
+ * Returns the {@link Options options} of this session.
+ */
+ public Options options();
+
+ /**
+ * Encapsulates the configuration options of CDO sessions that are common to both client and server side.
+ *
+ * @author Simon McDuff
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.has CDOCommonSession.Options.PassiveUpdateMode
+ * @apiviz.has CDOCommonSession.Options.LockNotificationMode
+ */
+ public interface Options extends IOptions
+ {
+ /**
+ * Returns the {@link CDOCommonSession session} of this options object.
+ *
+ * @since 4.0
+ */
+ public CDOCommonSession getContainer();
+
+ public boolean isPassiveUpdateEnabled();
+
+ /**
+ * Specifies whether objects will be invalidated due by other users changes.
+ * <p>
+ * Example:
+ * <p>
+ * <code>session.setPassiveUpdateEnabled(false);</code>
+ * <p>
+ * By default this property is enabled. If this property is disabled the latest versions of objects can still be
+ * obtained by calling refresh().
+ * <p>
+ * Passive update can be disabled in cases where more performance is needed and/or more control over when objects
+ * will be refreshed.
+ * <p>
+ * When enabled again, a refresh will be automatically performed to be in sync with the server.
+ *
+ * @since 3.0
+ */
+ public void setPassiveUpdateEnabled(boolean enabled);
+
+ /**
+ * @since 3.0
+ */
+ public PassiveUpdateMode getPassiveUpdateMode();
+
+ /**
+ * @since 3.0
+ */
+ public void setPassiveUpdateMode(PassiveUpdateMode mode);
+
+ /**
+ * @since 4.1
+ */
+ public LockNotificationMode getLockNotificationMode();
+
+ /**
+ * @since 4.1
+ */
+ public void setLockNotificationMode(LockNotificationMode mode);
+
+ /**
+ * Enumerates the possible {@link CDOCommonSession.Options#getPassiveUpdateMode() passive update modes} of a CDO
+ * session.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ */
+ public enum PassiveUpdateMode
+ {
+ /**
+ * This mode delivers change deltas only for change subscriptions, invalidation information for all other objects.
+ */
+ INVALIDATIONS,
+
+ /**
+ * This mode delivers change deltas for all changed objects, whether they have change subscriptions or not.
+ * Revisions for new objects are not delivered.
+ */
+ CHANGES,
+
+ /**
+ * This mode delivers change deltas for all changed objects, whether they have change subscriptions or not. In
+ * addition full revisions for new objects are delivered.
+ */
+ ADDITIONS
+ }
+
+ /**
+ * Enumerates the possible {@link CDOCommonSession.Options#getLockNotificationMode() lock notification modes} of a
+ * CDO session.
+ *
+ * @since 4.1
+ */
+ public enum LockNotificationMode
+ {
+ /**
+ * This mode delivers no lock notifications
+ */
+ OFF,
+
+ /**
+ * This mode delivers lock notifications if one or more views have enabled them.
+ */
+ IF_REQUIRED_BY_VIEWS,
+
+ /**
+ * This mode always delivers lock notifications, even if no views have them enabled, and even if no views are
+ * open.
+ */
+ ALWAYS
+ }
+
+ /**
+ * An {@link IOptionsEvent options event} fired when the {@link PassiveUpdateMode passive update mode} of a CDO
+ * session has changed.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ */
+ public interface PassiveUpdateEvent extends IOptionsEvent
+ {
+ public boolean getOldEnabled();
+
+ public boolean getNewEnabled();
+
+ public PassiveUpdateMode getOldMode();
+
+ public PassiveUpdateMode getNewMode();
+ }
+
+ /**
+ * An {@link IOptionsEvent options event} fired when the {@link LockNotificationMode lock notification mode} of a
+ * CDO session has changed.
+ *
+ * @author Caspar De Groot
+ * @since 4.1
+ */
+ public interface LockNotificationModeEvent extends IOptionsEvent
+ {
+ public LockNotificationMode getOldMode();
+
+ public LockNotificationMode getNewMode();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOCommonTransaction.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOCommonTransaction.java index 32d7fa0c2d..ab4a051ff6 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOCommonTransaction.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOCommonTransaction.java @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common; - -/** - * Abstracts the information about CDO transactions that is common to both client and server side. - * - * @author Eike Stepper - * @since 4.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.landmark - */ -public interface CDOCommonTransaction extends CDOCommonView -{ -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common;
+
+/**
+ * Abstracts the information about CDO transactions that is common to both client and server side.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.landmark
+ */
+public interface CDOCommonTransaction extends CDOCommonView
+{
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOCommonView.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOCommonView.java index 057a5fc213..d0c826f77c 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOCommonView.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/CDOCommonView.java @@ -1,98 +1,98 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common; - -import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; -import org.eclipse.emf.cdo.common.lock.CDOLockState; -import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; - -import org.eclipse.net4j.util.collection.Closeable; -import org.eclipse.net4j.util.event.IListener; -import org.eclipse.net4j.util.options.IOptions; -import org.eclipse.net4j.util.options.IOptionsContainer; -import org.eclipse.net4j.util.options.IOptionsEvent; - -/** - * Abstracts the information about CDO views that is common to both client and server side. - * - * @author Eike Stepper - * @since 2.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.landmark - * @apiviz.has {@link CDOCommonView.Options} - */ -public interface CDOCommonView extends CDOBranchPoint, CDORevisionProvider, IOptionsContainer, Closeable -{ - public int getViewID(); - - /** - * @since 3.0 - */ - public boolean isReadOnly(); - - public CDOCommonSession getSession(); - - /** - * @since 4.0 - */ - public String getDurableLockingID(); - - /** - * Returns the {@link Options options} of this view. - * - * @since 4.1 - */ - public Options options(); - - /** - * Encapsulates the configuration options of CDO views that are common to both client and server side. - * - * @author Eike Stepper - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @since 4.1 - * @apiviz.uses {@link CDOCommonView.Options.LockNotificationEvent} - - fires - */ - public interface Options extends IOptions - { - /** - * Returns <code>true</code> if this view will notify its {@link IListener listeners} about changes to the - * {@link CDOLockState lock states} of the objects in this view (due to lock operations in <i>other</i> views), - * <code>false</code> otherwise. - * - * @see CDOLockState - */ - public boolean isLockNotificationEnabled(); - - /** - * Specifies whether this view will notify its {@link IListener listeners} about changes to the {@link CDOLockState - * lock states} of the objects in this view (due to lock operations in <i>other</i> views), or not. - * - * @see CDOLockState - */ - public void setLockNotificationEnabled(boolean enabled); - - /** - * An {@link IOptionsEvent options event} fired from common view {@link CDOCommonView#options() options} when the - * {@link Options#setLockNotificationEnabled(boolean) lock notification enabled} option has changed. - * - * @author Caspar De Groot - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @since 4.1 - */ - public interface LockNotificationEvent extends IOptionsEvent - { - boolean getEnabled(); - } - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.lock.CDOLockState;
+import org.eclipse.emf.cdo.common.revision.CDORevisionProvider;
+
+import org.eclipse.net4j.util.collection.Closeable;
+import org.eclipse.net4j.util.event.IListener;
+import org.eclipse.net4j.util.options.IOptions;
+import org.eclipse.net4j.util.options.IOptionsContainer;
+import org.eclipse.net4j.util.options.IOptionsEvent;
+
+/**
+ * Abstracts the information about CDO views that is common to both client and server side.
+ *
+ * @author Eike Stepper
+ * @since 2.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.landmark
+ * @apiviz.has {@link CDOCommonView.Options}
+ */
+public interface CDOCommonView extends CDOBranchPoint, CDORevisionProvider, IOptionsContainer, Closeable
+{
+ public int getViewID();
+
+ /**
+ * @since 3.0
+ */
+ public boolean isReadOnly();
+
+ public CDOCommonSession getSession();
+
+ /**
+ * @since 4.0
+ */
+ public String getDurableLockingID();
+
+ /**
+ * Returns the {@link Options options} of this view.
+ *
+ * @since 4.1
+ */
+ public Options options();
+
+ /**
+ * Encapsulates the configuration options of CDO views that are common to both client and server side.
+ *
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 4.1
+ * @apiviz.uses {@link CDOCommonView.Options.LockNotificationEvent} - - fires
+ */
+ public interface Options extends IOptions
+ {
+ /**
+ * Returns <code>true</code> if this view will notify its {@link IListener listeners} about changes to the
+ * {@link CDOLockState lock states} of the objects in this view (due to lock operations in <i>other</i> views),
+ * <code>false</code> otherwise.
+ *
+ * @see CDOLockState
+ */
+ public boolean isLockNotificationEnabled();
+
+ /**
+ * Specifies whether this view will notify its {@link IListener listeners} about changes to the {@link CDOLockState
+ * lock states} of the objects in this view (due to lock operations in <i>other</i> views), or not.
+ *
+ * @see CDOLockState
+ */
+ public void setLockNotificationEnabled(boolean enabled);
+
+ /**
+ * An {@link IOptionsEvent options event} fired from common view {@link CDOCommonView#options() options} when the
+ * {@link Options#setLockNotificationEnabled(boolean) lock notification enabled} option has changed.
+ *
+ * @author Caspar De Groot
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 4.1
+ */
+ public interface LockNotificationEvent extends IOptionsEvent
+ {
+ boolean getEnabled();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranch.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranch.java index bccaaa62f6..afe328c786 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranch.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranch.java @@ -1,185 +1,185 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.branch; - -import org.eclipse.emf.cdo.common.CDOCommonRepository; -import org.eclipse.emf.cdo.common.CDOCommonRepository.State; -import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; -import org.eclipse.emf.cdo.common.util.CDOTimeProvider; - -import org.eclipse.net4j.util.container.IContainer; - -/** - * Represents a <i>stream of changes</i> that is isolated from other streams of changes. - * <p> - * A branch starts at a fixed {@link #getBase() base} point and ends at a floating {@link #getHead() head} point. - * Between these two points there can be a number of other {@link CDOBranchPoint branch points}: - * <ul> - * <li> {@link CDOCommitInfo Commit infos} are points in a branch that represent commit operations. - * <li> {@link CDOBranchTag Branch tags} are named points in a branch. - * <li> {@link #getBase() Base points } of sub branches of a branch. - * </ul> - * - * @author Eike Stepper - * @since 3.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.landmark - * @apiviz.has {@link CDOBranchPoint} oneway - - base - * @apiviz.composedOf {@link CDOBranch} - - subBranches - */ -public interface CDOBranch extends IContainer<CDOBranch>, Comparable<CDOBranch> -{ - /** - * The fixed ID of the {@link CDOBranchManager#getMainBranch() main branch}. - */ - public static final int MAIN_BRANCH_ID = 0; - - /** - * The fixed name of the {@link CDOBranchManager#getMainBranch() main branch}. - */ - public static final String MAIN_BRANCH_NAME = "MAIN"; //$NON-NLS-1$ - - /** - * The string used to separate the segments of branch paths. - * - * @see #getPathName() - * @see #getBranch(String) - * @see CDOBranchManager#getBranch(String) - */ - public static final String PATH_SEPARATOR = "/"; //$NON-NLS-1$ - - /** - * Returns <code>true</code> if this branch is the {@link CDOBranchManager#getMainBranch() main branch}, - * <code>false</code> otherwise. - */ - public boolean isMainBranch(); - - /** - * Returns <code>true</code> if this branch is a local branch, <code>false</code> otherwise. - * <p> - * Local branches are created on the fly when committing to a - * {@link org.eclipse.emf.cdo.common.CDOCommonRepository.Type#CLONE clone} repository while it is in - * {@link State#OFFLINE offline} state and they do not participate in repository replication. They can not be created - * manually and they have negative {@link #getID() IDs}. - */ - public boolean isLocal(); - - /** - * Returns the ID of this branch. - * <p> - * The {@link CDOBranchManager#getMainBranch() main branch} has the fixed ID 0 (zero), {@link #isLocal() Local - * branches} have negative IDs and normal branches have positive IDs. - */ - public int getID(); - - /** - * Returns the name of this branch as specified when it was created with {@link #createBranch(String, long) - * createBranch()} or {@link #MAIN_BRANCH_NAME} if this branch is the {@link CDOBranchManager#getMainBranch() main - * branch}. - */ - public String getName(); - - /** - * Returns the fully qualified path name of this branch, a concatenation of the names of all branches from the - * {@link CDOBranchManager#getMainBranch() main branch} to this branch, separated by {@link #PATH_SEPARATOR slashes} - * ("/" characters). Example: "MAIN/team1/smith". - */ - public String getPathName(); - - /** - * Returns an array of the {@link #getBase() base} branch points starting from the base of the - * {@link CDOBranchManager#getMainBranch() main branch} down to and including the base of this branch. - */ - public CDOBranchPoint[] getBasePath(); - - /** - * Returns the immutable base branch point of this branch, the point in the parent branch that marks the creation of - * this branch. - * <p> - * The base of the {@link CDOBranchManager#getMainBranch() main branch} marks the creation of the - * {@link CDOCommonRepository repository}. - * - * @see CDOBranch#getHead() - * @see #getPoint(long) - */ - public CDOBranchPoint getBase(); - - /** - * Returns the floating <i>end point</i> of this branch, a pair of this branch and the fixed special time stamp <i> - * {@link CDOBranchPoint#UNSPECIFIED_DATE unspecified}</i>. - * - * @see CDOBranch#getBase() - * @see #getPoint(long) - */ - public CDOBranchPoint getHead(); - - /** - * Returns the branch point in this branch with the given time stamp. - * <p> - * This factory method never returns <code>null</code>. - * - * @see CDOBranch#getBase() - * @see CDOBranch#getHead() - * @see #getVersion(int) - */ - public CDOBranchPoint getPoint(long timeStamp); - - /** - * Returns the branch version in this branch with the given version number. - * <p> - * This factory method never returns <code>null</code>. - * - * @see #getPoint(long) - */ - public CDOBranchVersion getVersion(int version); - - /** - * Returns the branch manager that manages this branch, never <code>null</code>. - */ - public CDOBranchManager getBranchManager(); - - /** - * Returns an array of the sub branches of this branch, never <code>null</code>. - */ - public CDOBranch[] getBranches(); - - /** - * Returns the sub branch of this branch with the given relative path, or <code>null</code> if no sub branch with this - * path exists in this branch. - * <p> - * The path name is the concatenation of the names of all branches from a direct sub branch of this branch, separated - * by {@link #PATH_SEPARATOR slashes} ("/" characters). Example: "team1/smith". - */ - public CDOBranch getBranch(String path); - - /** - * Creates a sub branch of this branch with the given name, {@link #getBase() based} at the {@link CDOBranchPoint - * branch point} in this branch with the given time stamp. - * <p> - * - * @param name - * The name of the sub branch to be created. It must not contain the {@link #PATH_SEPARATOR path separator} - * character (slash). - * @param timeStamp - * The time stamp in this branch that the sub branch to be created is supposed to be {@link #getBase() based - * at}. It must not be before the base time stamp of this branch and it must be different from the fixed - * special time stamp <i> {@link CDOBranchPoint#UNSPECIFIED_DATE unspecified}</i> - * @see #createBranch(String) - */ - public CDOBranch createBranch(String name, long timeStamp); - - /** - * Creates a sub branch of this branch with the given name, {@link #getBase() based} at the {@link CDOTimeProvider - * current time}. - */ - public CDOBranch createBranch(String name); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.branch;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository;
+import org.eclipse.emf.cdo.common.CDOCommonRepository.State;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.util.CDOTimeProvider;
+
+import org.eclipse.net4j.util.container.IContainer;
+
+/**
+ * Represents a <i>stream of changes</i> that is isolated from other streams of changes.
+ * <p>
+ * A branch starts at a fixed {@link #getBase() base} point and ends at a floating {@link #getHead() head} point.
+ * Between these two points there can be a number of other {@link CDOBranchPoint branch points}:
+ * <ul>
+ * <li> {@link CDOCommitInfo Commit infos} are points in a branch that represent commit operations.
+ * <li> {@link CDOBranchTag Branch tags} are named points in a branch.
+ * <li> {@link #getBase() Base points } of sub branches of a branch.
+ * </ul>
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.landmark
+ * @apiviz.has {@link CDOBranchPoint} oneway - - base
+ * @apiviz.composedOf {@link CDOBranch} - - subBranches
+ */
+public interface CDOBranch extends IContainer<CDOBranch>, Comparable<CDOBranch>
+{
+ /**
+ * The fixed ID of the {@link CDOBranchManager#getMainBranch() main branch}.
+ */
+ public static final int MAIN_BRANCH_ID = 0;
+
+ /**
+ * The fixed name of the {@link CDOBranchManager#getMainBranch() main branch}.
+ */
+ public static final String MAIN_BRANCH_NAME = "MAIN"; //$NON-NLS-1$
+
+ /**
+ * The string used to separate the segments of branch paths.
+ *
+ * @see #getPathName()
+ * @see #getBranch(String)
+ * @see CDOBranchManager#getBranch(String)
+ */
+ public static final String PATH_SEPARATOR = "/"; //$NON-NLS-1$
+
+ /**
+ * Returns <code>true</code> if this branch is the {@link CDOBranchManager#getMainBranch() main branch},
+ * <code>false</code> otherwise.
+ */
+ public boolean isMainBranch();
+
+ /**
+ * Returns <code>true</code> if this branch is a local branch, <code>false</code> otherwise.
+ * <p>
+ * Local branches are created on the fly when committing to a
+ * {@link org.eclipse.emf.cdo.common.CDOCommonRepository.Type#CLONE clone} repository while it is in
+ * {@link State#OFFLINE offline} state and they do not participate in repository replication. They can not be created
+ * manually and they have negative {@link #getID() IDs}.
+ */
+ public boolean isLocal();
+
+ /**
+ * Returns the ID of this branch.
+ * <p>
+ * The {@link CDOBranchManager#getMainBranch() main branch} has the fixed ID 0 (zero), {@link #isLocal() Local
+ * branches} have negative IDs and normal branches have positive IDs.
+ */
+ public int getID();
+
+ /**
+ * Returns the name of this branch as specified when it was created with {@link #createBranch(String, long)
+ * createBranch()} or {@link #MAIN_BRANCH_NAME} if this branch is the {@link CDOBranchManager#getMainBranch() main
+ * branch}.
+ */
+ public String getName();
+
+ /**
+ * Returns the fully qualified path name of this branch, a concatenation of the names of all branches from the
+ * {@link CDOBranchManager#getMainBranch() main branch} to this branch, separated by {@link #PATH_SEPARATOR slashes}
+ * ("/" characters). Example: "MAIN/team1/smith".
+ */
+ public String getPathName();
+
+ /**
+ * Returns an array of the {@link #getBase() base} branch points starting from the base of the
+ * {@link CDOBranchManager#getMainBranch() main branch} down to and including the base of this branch.
+ */
+ public CDOBranchPoint[] getBasePath();
+
+ /**
+ * Returns the immutable base branch point of this branch, the point in the parent branch that marks the creation of
+ * this branch.
+ * <p>
+ * The base of the {@link CDOBranchManager#getMainBranch() main branch} marks the creation of the
+ * {@link CDOCommonRepository repository}.
+ *
+ * @see CDOBranch#getHead()
+ * @see #getPoint(long)
+ */
+ public CDOBranchPoint getBase();
+
+ /**
+ * Returns the floating <i>end point</i> of this branch, a pair of this branch and the fixed special time stamp <i>
+ * {@link CDOBranchPoint#UNSPECIFIED_DATE unspecified}</i>.
+ *
+ * @see CDOBranch#getBase()
+ * @see #getPoint(long)
+ */
+ public CDOBranchPoint getHead();
+
+ /**
+ * Returns the branch point in this branch with the given time stamp.
+ * <p>
+ * This factory method never returns <code>null</code>.
+ *
+ * @see CDOBranch#getBase()
+ * @see CDOBranch#getHead()
+ * @see #getVersion(int)
+ */
+ public CDOBranchPoint getPoint(long timeStamp);
+
+ /**
+ * Returns the branch version in this branch with the given version number.
+ * <p>
+ * This factory method never returns <code>null</code>.
+ *
+ * @see #getPoint(long)
+ */
+ public CDOBranchVersion getVersion(int version);
+
+ /**
+ * Returns the branch manager that manages this branch, never <code>null</code>.
+ */
+ public CDOBranchManager getBranchManager();
+
+ /**
+ * Returns an array of the sub branches of this branch, never <code>null</code>.
+ */
+ public CDOBranch[] getBranches();
+
+ /**
+ * Returns the sub branch of this branch with the given relative path, or <code>null</code> if no sub branch with this
+ * path exists in this branch.
+ * <p>
+ * The path name is the concatenation of the names of all branches from a direct sub branch of this branch, separated
+ * by {@link #PATH_SEPARATOR slashes} ("/" characters). Example: "team1/smith".
+ */
+ public CDOBranch getBranch(String path);
+
+ /**
+ * Creates a sub branch of this branch with the given name, {@link #getBase() based} at the {@link CDOBranchPoint
+ * branch point} in this branch with the given time stamp.
+ * <p>
+ *
+ * @param name
+ * The name of the sub branch to be created. It must not contain the {@link #PATH_SEPARATOR path separator}
+ * character (slash).
+ * @param timeStamp
+ * The time stamp in this branch that the sub branch to be created is supposed to be {@link #getBase() based
+ * at}. It must not be before the base time stamp of this branch and it must be different from the fixed
+ * special time stamp <i> {@link CDOBranchPoint#UNSPECIFIED_DATE unspecified}</i>
+ * @see #createBranch(String)
+ */
+ public CDOBranch createBranch(String name, long timeStamp);
+
+ /**
+ * Creates a sub branch of this branch with the given name, {@link #getBase() based} at the {@link CDOTimeProvider
+ * current time}.
+ */
+ public CDOBranch createBranch(String name);
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchCreatedEvent.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchCreatedEvent.java index f3969fc540..f0f755ee9e 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchCreatedEvent.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchCreatedEvent.java @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.branch; - -import org.eclipse.net4j.util.event.IEvent; - -/** - * An {@link IEvent event} fired from a {@link CDOBranchManager branch manager} when a new {@link CDOBranch branch} has - * been created. - * - * @author Eike Stepper - * @since 3.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDOBranchCreatedEvent extends IEvent -{ - public CDOBranchManager getSource(); - - public CDOBranch getBranch(); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.branch;
+
+import org.eclipse.net4j.util.event.IEvent;
+
+/**
+ * An {@link IEvent event} fired from a {@link CDOBranchManager branch manager} when a new {@link CDOBranch branch} has
+ * been created.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDOBranchCreatedEvent extends IEvent
+{
+ public CDOBranchManager getSource();
+
+ public CDOBranch getBranch();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchHandler.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchHandler.java index 2310503156..4299176b90 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchHandler.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchHandler.java @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.branch; - -/** - * A call-back interface that indicates the ability to <i>handle</i> branches that are passed from other entities. - * - * @see CDOBranchManager#getBranches(int, int, CDOBranchHandler) - * @author Eike Stepper - * @since 3.0 - * @apiviz.uses {@link CDOBranch} - - handles - */ -public interface CDOBranchHandler -{ - /** - * A call-back method that other entities can pass branches to. - */ - public void handleBranch(CDOBranch branch); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.branch;
+
+/**
+ * A call-back interface that indicates the ability to <i>handle</i> branches that are passed from other entities.
+ *
+ * @see CDOBranchManager#getBranches(int, int, CDOBranchHandler)
+ * @author Eike Stepper
+ * @since 3.0
+ * @apiviz.uses {@link CDOBranch} - - handles
+ */
+public interface CDOBranchHandler
+{
+ /**
+ * A call-back method that other entities can pass branches to.
+ */
+ public void handleBranch(CDOBranch branch);
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchManager.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchManager.java index f6e4d8d88d..4274ca75e0 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchManager.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchManager.java @@ -1,79 +1,79 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.branch; - -import org.eclipse.net4j.util.event.INotifier; - -/** - * Manages a tree of {@link CDOBranch branches} and notifies about changes in this branch tree. - * <p> - * The branch tree is represented by a {@link #getMainBranch() main} branch, which, like all - * {@link CDOBranch#getBranches() sub} branches, offers the major part of the branching functionality. A branch manager - * provides additional methods to find branches by their unique integer ID or by their fully qualified path name, as - * well as asynchronous bulk queries. - * <p> - * A branch manager can fire the following events: - * <ul> - * <li> {@link CDOBranchCreatedEvent} after a new branch has been created. - * </ul> - * <p> - * Branch managers are usually associated with the following entities: - * <ul> - * <li> <code>org.eclipse.emf.cdo.session.CDOSession</code> - * <li> <code>org.eclipse.emf.cdo.server.IRepository</code> - * </ul> - * - * @author Eike Stepper - * @since 3.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.landmark - * @apiviz.has {@link CDOBranch} oneway - - mainBranch - * @apiviz.uses {@link CDOBranchCreatedEvent} - - fires - */ -public interface CDOBranchManager extends INotifier -{ - /** - * Returns the main branch of the branch tree managed by this branch manager. - * <p> - * The main branch has the fixed {@link CDOBranch#MAIN_BRANCH_NAME name} "MAIN" and the fixed - * {@link CDOBranch#MAIN_BRANCH_ID ID} 0 (zero). - */ - public CDOBranch getMainBranch(); - - /** - * Returns the branch with the given unique integer ID. - * <p> - * Note that this method never returns <code>null</code>. Due to the lazy loading nature of branch managers this - * method returns a transparent <i>branch proxy</i> if the branch is not already loaded in the internal <i>branch - * cache</i>. This can result in unchecked exceptions being thrown from calls to arbitrary branch methods if the ID - * that the proxy was created with does not exist in the branch tree. - */ - public CDOBranch getBranch(int branchID); - - /** - * Returns the branch with the given absolute path. - * - * @param path - * A concatenation of the names of all branches from the {@link #getMainBranch() main branch} to the - * requested branch, separated by {@link CDOBranch#PATH_SEPARATOR slashes} ("/" characters). Example: - * "MAIN/team1/smith". - */ - public CDOBranch getBranch(String path); - - /** - * Passes all branches with IDs in the given range to the given {@link CDOBranchHandler#handleBranch(CDOBranch) branch - * handler} and returns the number of handler invocations. - * <p> - * This is a blocking call. - */ - public int getBranches(int startID, int endID, CDOBranchHandler handler); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.branch;
+
+import org.eclipse.net4j.util.event.INotifier;
+
+/**
+ * Manages a tree of {@link CDOBranch branches} and notifies about changes in this branch tree.
+ * <p>
+ * The branch tree is represented by a {@link #getMainBranch() main} branch, which, like all
+ * {@link CDOBranch#getBranches() sub} branches, offers the major part of the branching functionality. A branch manager
+ * provides additional methods to find branches by their unique integer ID or by their fully qualified path name, as
+ * well as asynchronous bulk queries.
+ * <p>
+ * A branch manager can fire the following events:
+ * <ul>
+ * <li> {@link CDOBranchCreatedEvent} after a new branch has been created.
+ * </ul>
+ * <p>
+ * Branch managers are usually associated with the following entities:
+ * <ul>
+ * <li> <code>org.eclipse.emf.cdo.session.CDOSession</code>
+ * <li> <code>org.eclipse.emf.cdo.server.IRepository</code>
+ * </ul>
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.landmark
+ * @apiviz.has {@link CDOBranch} oneway - - mainBranch
+ * @apiviz.uses {@link CDOBranchCreatedEvent} - - fires
+ */
+public interface CDOBranchManager extends INotifier
+{
+ /**
+ * Returns the main branch of the branch tree managed by this branch manager.
+ * <p>
+ * The main branch has the fixed {@link CDOBranch#MAIN_BRANCH_NAME name} "MAIN" and the fixed
+ * {@link CDOBranch#MAIN_BRANCH_ID ID} 0 (zero).
+ */
+ public CDOBranch getMainBranch();
+
+ /**
+ * Returns the branch with the given unique integer ID.
+ * <p>
+ * Note that this method never returns <code>null</code>. Due to the lazy loading nature of branch managers this
+ * method returns a transparent <i>branch proxy</i> if the branch is not already loaded in the internal <i>branch
+ * cache</i>. This can result in unchecked exceptions being thrown from calls to arbitrary branch methods if the ID
+ * that the proxy was created with does not exist in the branch tree.
+ */
+ public CDOBranch getBranch(int branchID);
+
+ /**
+ * Returns the branch with the given absolute path.
+ *
+ * @param path
+ * A concatenation of the names of all branches from the {@link #getMainBranch() main branch} to the
+ * requested branch, separated by {@link CDOBranch#PATH_SEPARATOR slashes} ("/" characters). Example:
+ * "MAIN/team1/smith".
+ */
+ public CDOBranch getBranch(String path);
+
+ /**
+ * Passes all branches with IDs in the given range to the given {@link CDOBranchHandler#handleBranch(CDOBranch) branch
+ * handler} and returns the number of handler invocations.
+ * <p>
+ * This is a blocking call.
+ */
+ public int getBranches(int startID, int endID, CDOBranchHandler handler);
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchPoint.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchPoint.java index 80da9a4dec..ac4ba9b7dd 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchPoint.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchPoint.java @@ -1,59 +1,59 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.branch; - -import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; -import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil; - -/** - * A {@link #getTimeStamp() point in time} in a particular {@link #getBranch() branch}. - * - * @see CDOCommitInfo - * @see CDOBranchTag - * @see CDOBranch#getBase() - * @see CDOBranch#getHead() - * @see CDOBranch#getPoint(long) - * @see CDOBranchUtil#copyBranchPoint(CDOBranchPoint) - * @author Eike Stepper - * @since 3.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.has {@link CDOBranch} - */ -public interface CDOBranchPoint -{ - /** - * The fixed special time stamp <i>unspecified</i>. - * - * @see CDOBranch#getHead() - */ - public static final long UNSPECIFIED_DATE = 0; - - /** - * The fixed special time stamp <i>invalid</i>. - * - * @since 4.0 - */ - public static final long INVALID_DATE = -1; - - /** - * Returns the branch of this branch point, or <code>null</code> if this branch point is the - * {@link CDOBranch#getBase() base} of the {@link CDOBranchManager#getMainBranch() main branch}. - */ - public CDOBranch getBranch(); - - /** - * Returns the time stamp of this branch point, or the fixed special time stamp <i> - * {@link CDOBranchPoint#UNSPECIFIED_DATE unspecified}</i> if this branch point marks the {@link CDOBranch#getHead() - * head} of a branch. - */ - public long getTimeStamp(); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.branch;
+
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
+
+/**
+ * A {@link #getTimeStamp() point in time} in a particular {@link #getBranch() branch}.
+ *
+ * @see CDOCommitInfo
+ * @see CDOBranchTag
+ * @see CDOBranch#getBase()
+ * @see CDOBranch#getHead()
+ * @see CDOBranch#getPoint(long)
+ * @see CDOBranchUtil#copyBranchPoint(CDOBranchPoint)
+ * @author Eike Stepper
+ * @since 3.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.has {@link CDOBranch}
+ */
+public interface CDOBranchPoint
+{
+ /**
+ * The fixed special time stamp <i>unspecified</i>.
+ *
+ * @see CDOBranch#getHead()
+ */
+ public static final long UNSPECIFIED_DATE = 0;
+
+ /**
+ * The fixed special time stamp <i>invalid</i>.
+ *
+ * @since 4.0
+ */
+ public static final long INVALID_DATE = -1;
+
+ /**
+ * Returns the branch of this branch point, or <code>null</code> if this branch point is the
+ * {@link CDOBranch#getBase() base} of the {@link CDOBranchManager#getMainBranch() main branch}.
+ */
+ public CDOBranch getBranch();
+
+ /**
+ * Returns the time stamp of this branch point, or the fixed special time stamp <i>
+ * {@link CDOBranchPoint#UNSPECIFIED_DATE unspecified}</i> if this branch point marks the {@link CDOBranch#getHead()
+ * head} of a branch.
+ */
+ public long getTimeStamp();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchPointRange.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchPointRange.java index 28c2c9cfbb..dd80e94871 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchPointRange.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchPointRange.java @@ -1,44 +1,44 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.branch; - -import org.eclipse.emf.cdo.common.commit.CDOChangeSet; -import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil; - -/** - * A range between the {@link CDOBranch#getBase() base} of the {@link CDOBranchManager#getMainBranch() main branch} and - * the {@link CDOBranch#getHead() head} of any branch that is demarkated by a {@link #getStartPoint() start point} and - * an {@link #getEndPoint() end point}. - * <p> - * The start point and the end point of a branch point range may have different branches or not. - * <p> - * Branch point ranges are usually created with {@link CDOBranchUtil#createRange(CDOBranchPoint, CDOBranchPoint) - * CDOBranchUtil.createRange()} and often used in the context of {@link CDOChangeSet change sets}. - * - * @author Eike Stepper - * @since 3.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.has {@link CDOBranchPoint} oneway - - start - * @apiviz.has {@link CDOBranchPoint} oneway - - end - */ -public interface CDOBranchPointRange -{ - /** - * Returns the start point of this branch point range, never <code>null</code>. - */ - public CDOBranchPoint getStartPoint(); - - /** - * Returns the end point of this branch point range, never <code>null</code>. - */ - public CDOBranchPoint getEndPoint(); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.branch;
+
+import org.eclipse.emf.cdo.common.commit.CDOChangeSet;
+import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
+
+/**
+ * A range between the {@link CDOBranch#getBase() base} of the {@link CDOBranchManager#getMainBranch() main branch} and
+ * the {@link CDOBranch#getHead() head} of any branch that is demarkated by a {@link #getStartPoint() start point} and
+ * an {@link #getEndPoint() end point}.
+ * <p>
+ * The start point and the end point of a branch point range may have different branches or not.
+ * <p>
+ * Branch point ranges are usually created with {@link CDOBranchUtil#createRange(CDOBranchPoint, CDOBranchPoint)
+ * CDOBranchUtil.createRange()} and often used in the context of {@link CDOChangeSet change sets}.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.has {@link CDOBranchPoint} oneway - - start
+ * @apiviz.has {@link CDOBranchPoint} oneway - - end
+ */
+public interface CDOBranchPointRange
+{
+ /**
+ * Returns the start point of this branch point range, never <code>null</code>.
+ */
+ public CDOBranchPoint getStartPoint();
+
+ /**
+ * Returns the end point of this branch point range, never <code>null</code>.
+ */
+ public CDOBranchPoint getEndPoint();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchTag.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchTag.java index a7113d3c67..7ba2e64fd0 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchTag.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchTag.java @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.branch; - -/** - * A named {@link CDOBranchPoint branch point}. - * - * @author Eike Stepper - * @since 3.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDOBranchTag extends CDOBranchPoint -{ - /** - * Returns the name of this branch tag. - */ - public String getName(); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.branch;
+
+/**
+ * A named {@link CDOBranchPoint branch point}.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDOBranchTag extends CDOBranchPoint
+{
+ /**
+ * Returns the name of this branch tag.
+ */
+ public String getName();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchVersion.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchVersion.java index d98957e586..78f1153c41 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchVersion.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/CDOBranchVersion.java @@ -1,53 +1,53 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.branch; - -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.revision.CDORevision; -import org.eclipse.emf.cdo.common.revision.CDORevisionManager; - -/** - * A pair of a {@link #getBranch() branch} and an integer {@link #getVersion() version} number. - * <p> - * It is often used in the context of - * {@link CDORevisionManager#getRevisionByVersion(CDOID, CDOBranchVersion, int, boolean) - * CDORevisionManager.getRevisionByVersion()}. - * - * @see CDOBranch#getVersion(int) - * @author Eike Stepper - * @since 3.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.has {@link CDOBranch} - */ -public interface CDOBranchVersion -{ - /** - * The fixed special version number <i>unspecified</i>. - */ - public static final int UNSPECIFIED_VERSION = 0; - - /** - * The fixed version number that is assigned to the first {@link CDORevision revision} of an {@link CDOID object} that - * is committed to a particular branch . - */ - public static final int FIRST_VERSION = 1; - - /** - * Returns the branch of this branch version. - */ - public CDOBranch getBranch(); - - /** - * Returns the version number of this branch version. - */ - public int getVersion(); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.branch;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
+
+/**
+ * A pair of a {@link #getBranch() branch} and an integer {@link #getVersion() version} number.
+ * <p>
+ * It is often used in the context of
+ * {@link CDORevisionManager#getRevisionByVersion(CDOID, CDOBranchVersion, int, boolean)
+ * CDORevisionManager.getRevisionByVersion()}.
+ *
+ * @see CDOBranch#getVersion(int)
+ * @author Eike Stepper
+ * @since 3.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.has {@link CDOBranch}
+ */
+public interface CDOBranchVersion
+{
+ /**
+ * The fixed special version number <i>unspecified</i>.
+ */
+ public static final int UNSPECIFIED_VERSION = 0;
+
+ /**
+ * The fixed version number that is assigned to the first {@link CDORevision revision} of an {@link CDOID object} that
+ * is committed to a particular branch .
+ */
+ public static final int FIRST_VERSION = 1;
+
+ /**
+ * Returns the branch of this branch version.
+ */
+ public CDOBranch getBranch();
+
+ /**
+ * Returns the version number of this branch version.
+ */
+ public int getVersion();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/package-info.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/package-info.java index a3974bdde3..e30279294b 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/package-info.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/branch/package-info.java @@ -1,5 +1,5 @@ /*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 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
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeKind.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeKind.java index b8b8fa7e0b..4fdabd758b 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeKind.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeKind.java @@ -1,23 +1,23 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.commit; - -/** - * Enumerates possible change kinds. - * - * @author Eike Stepper - * @since 4.0 - * @noextend This interface is not intended to be extended by clients. - */ -public enum CDOChangeKind -{ - NEW, CHANGED, DETACHED -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.commit;
+
+/**
+ * Enumerates possible change kinds.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public enum CDOChangeKind
+{
+ NEW, CHANGED, DETACHED
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeKindProvider.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeKindProvider.java index 38fddf677f..2c76354da2 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeKindProvider.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeKindProvider.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.commit; - -import org.eclipse.emf.cdo.common.id.CDOID; - -/** - * Generic provider for the kinds of changes that have been applied to objects. - * - * @author Eike Stepper - * @since 4.0 - * @apiviz.uses {@link CDOChangeKind} - - provides - */ -public interface CDOChangeKindProvider -{ - public CDOChangeKind getChangeKind(CDOID id); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.commit;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+
+/**
+ * Generic provider for the kinds of changes that have been applied to objects.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ * @apiviz.uses {@link CDOChangeKind} - - provides
+ */
+public interface CDOChangeKindProvider
+{
+ public CDOChangeKind getChangeKind(CDOID id);
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeSet.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeSet.java index c54a90c61f..c36e8a6c48 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeSet.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeSet.java @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.commit; - -import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; -import org.eclipse.emf.cdo.common.branch.CDOBranchPointRange; - -/** - * The {@link CDOChangeSetData change set data} between two {@link CDOBranchPointRange branch points} with a common - * ancestor. - * - * @author Eike Stepper - * @since 3.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDOChangeSet extends CDOBranchPointRange, CDOChangeSetData -{ - public CDOBranchPoint getAncestorPoint(); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.commit;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPointRange;
+
+/**
+ * The {@link CDOChangeSetData change set data} between two {@link CDOBranchPointRange branch points} with a common
+ * ancestor.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDOChangeSet extends CDOBranchPointRange, CDOChangeSetData
+{
+ public CDOBranchPoint getAncestorPoint();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeSetData.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeSetData.java index 05b36d2ff0..b9cdb068e4 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeSetData.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeSetData.java @@ -1,78 +1,78 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.commit; - -import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion; -import org.eclipse.emf.cdo.common.revision.CDORevision; -import org.eclipse.emf.cdo.common.revision.CDORevisionKey; -import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; - -import java.util.List; -import java.util.Map; - -/** - * A {@link CDOChangeKindProvider change kind provider} with detailed information about {@link #getNewObjects() new}, - * {@link #getChangedObjects() changed} and {@link #getDetachedObjects() detached} objects. - * - * @author Eike Stepper - * @since 3.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDOChangeSetData extends CDOChangeKindProvider -{ - /** - * Returns <code>true</code>, if this change set data does not contain any changes, <code>false</code> otherwise. - */ - public boolean isEmpty(); - - /** - * Returns a deep copy of this change set data. - * - * @since 4.0 - */ - public CDOChangeSetData copy(); - - /** - * Changes the internal state of this change set data by adding the changes of the given change set data. - * - * @since 4.0 - */ - public void merge(CDOChangeSetData changeSetData); - - /** - * Returns a collection of keys denoting which revisions have been added in the context of a commit operation. - * Depending on various conditions like change subscriptions particular elements can also be full {@link CDORevision - * revisions}. - */ - public List<CDOIDAndVersion> getNewObjects(); - - /** - * Returns a collection of revision keys denoting which (original) revisions have been changed in the context of a - * commit operation. Depending on various conditions like change subscriptions particular elements can also be full - * {@link CDORevisionDelta revision deltas}. - */ - public List<CDORevisionKey> getChangedObjects(); - - /** - * Returns a collection of keys denoting which revisions have been revised (corresponds to detached objects) in the - * context of a commit operation. Depending on various conditions the version part of particular elements can be - * {@link CDOBranchVersion#UNSPECIFIED_VERSION unspecified}. - */ - public List<CDOIDAndVersion> getDetachedObjects(); - - /** - * @since 4.1 - */ - public Map<CDOID, CDOChangeKind> getChangeKinds(); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.commit;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A {@link CDOChangeKindProvider change kind provider} with detailed information about {@link #getNewObjects() new},
+ * {@link #getChangedObjects() changed} and {@link #getDetachedObjects() detached} objects.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDOChangeSetData extends CDOChangeKindProvider
+{
+ /**
+ * Returns <code>true</code>, if this change set data does not contain any changes, <code>false</code> otherwise.
+ */
+ public boolean isEmpty();
+
+ /**
+ * Returns a deep copy of this change set data.
+ *
+ * @since 4.0
+ */
+ public CDOChangeSetData copy();
+
+ /**
+ * Changes the internal state of this change set data by adding the changes of the given change set data.
+ *
+ * @since 4.0
+ */
+ public void merge(CDOChangeSetData changeSetData);
+
+ /**
+ * Returns a collection of keys denoting which revisions have been added in the context of a commit operation.
+ * Depending on various conditions like change subscriptions particular elements can also be full {@link CDORevision
+ * revisions}.
+ */
+ public List<CDOIDAndVersion> getNewObjects();
+
+ /**
+ * Returns a collection of revision keys denoting which (original) revisions have been changed in the context of a
+ * commit operation. Depending on various conditions like change subscriptions particular elements can also be full
+ * {@link CDORevisionDelta revision deltas}.
+ */
+ public List<CDORevisionKey> getChangedObjects();
+
+ /**
+ * Returns a collection of keys denoting which revisions have been revised (corresponds to detached objects) in the
+ * context of a commit operation. Depending on various conditions the version part of particular elements can be
+ * {@link CDOBranchVersion#UNSPECIFIED_VERSION unspecified}.
+ */
+ public List<CDOIDAndVersion> getDetachedObjects();
+
+ /**
+ * @since 4.1
+ */
+ public Map<CDOID, CDOChangeKind> getChangeKinds();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeSetDataProvider.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeSetDataProvider.java index aba9672d19..a9122c0ecf 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeSetDataProvider.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOChangeSetDataProvider.java @@ -1,23 +1,23 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.commit; - -/** - * Provides consumers with {@link CDOChangeSetData change set data} structures. - * - * @author Eike Stepper - * @since 4.0 - * @apiviz.uses {@link CDOChangeSetData} - - provides - */ -public interface CDOChangeSetDataProvider -{ - public CDOChangeSetData getChangeSetData(); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.commit;
+
+/**
+ * Provides consumers with {@link CDOChangeSetData change set data} structures.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ * @apiviz.uses {@link CDOChangeSetData} - - provides
+ */
+public interface CDOChangeSetDataProvider
+{
+ public CDOChangeSetData getChangeSetData();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOCommitData.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOCommitData.java index 664e2931ef..41ea320c6d 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOCommitData.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOCommitData.java @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.commit; - -import org.eclipse.emf.cdo.common.model.CDOPackageUnit; - -import java.util.List; - -/** - * {@link CDOChangeSetData Change set data} with detailed information about new {@link #getNewPackageUnits() package - * units}. - * - * @author Eike Stepper - * @since 3.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDOCommitData extends CDOChangeSetData -{ - public List<CDOPackageUnit> getNewPackageUnits(); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.commit;
+
+import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
+
+import java.util.List;
+
+/**
+ * {@link CDOChangeSetData Change set data} with detailed information about new {@link #getNewPackageUnits() package
+ * units}.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDOCommitData extends CDOChangeSetData
+{
+ public List<CDOPackageUnit> getNewPackageUnits();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOCommitInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOCommitInfo.java index 18e5ff56e5..1b93982d3a 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOCommitInfo.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOCommitInfo.java @@ -1,37 +1,37 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.commit; - -import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; - -/** - * {@link CDOCommitData Commit data} in the context of a {@link CDOCommitInfoManager commit info manager} with - * additional commit informations. - * - * @author Eike Stepper - * @since 3.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.landmark - */ -public interface CDOCommitInfo extends CDOBranchPoint, CDOCommitData -{ - public CDOCommitInfoManager getCommitInfoManager(); - - /** - * @since 4.0 - */ - public long getPreviousTimeStamp(); - - public String getUserID(); - - public String getComment(); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.commit;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+
+/**
+ * {@link CDOCommitData Commit data} in the context of a {@link CDOCommitInfoManager commit info manager} with
+ * additional commit informations.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.landmark
+ */
+public interface CDOCommitInfo extends CDOBranchPoint, CDOCommitData
+{
+ public CDOCommitInfoManager getCommitInfoManager();
+
+ /**
+ * @since 4.0
+ */
+ public long getPreviousTimeStamp();
+
+ public String getUserID();
+
+ public String getComment();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOCommitInfoHandler.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOCommitInfoHandler.java index 49166cb47f..800ccc5bb5 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOCommitInfoHandler.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOCommitInfoHandler.java @@ -1,24 +1,24 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.commit; - -/** - * A call-back interface that indicates the ability to <i>handle</i> {@link CDOCommitInfo commit infos} that are passed - * from other entities. - * - * @author Eike Stepper - * @since 3.0 - * @apiviz.uses {@link CDOCommitInfo} - - handles - */ -public interface CDOCommitInfoHandler -{ - public void handleCommitInfo(CDOCommitInfo commitInfo); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.commit;
+
+/**
+ * A call-back interface that indicates the ability to <i>handle</i> {@link CDOCommitInfo commit infos} that are passed
+ * from other entities.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ * @apiviz.uses {@link CDOCommitInfo} - - handles
+ */
+public interface CDOCommitInfoHandler
+{
+ public void handleCommitInfo(CDOCommitInfo commitInfo);
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOCommitInfoManager.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOCommitInfoManager.java index 9e9a3a18ce..58b7dee9de 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOCommitInfoManager.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/CDOCommitInfoManager.java @@ -1,39 +1,39 @@ -/* - * Copyright (c) 2004 - 2011 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: - * Andre Dietisheim - initial API and implementation - */ -package org.eclipse.emf.cdo.common.commit; - -import org.eclipse.emf.cdo.common.branch.CDOBranch; - -/** - * Loads, provides and possible manages {@link CDOCommitInfo commit info} objects. - * - * @author Andre Dietisheim - * @since 3.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.landmark - * @apiviz.uses {@link CDOCommitInfo} - - manages - */ -public interface CDOCommitInfoManager -{ - /** - * @since 4.0 - */ - public CDOCommitInfo getCommitInfo(long timeStamp); - - public void getCommitInfos(CDOBranch branch, long startTime, long endTime, CDOCommitInfoHandler handler); - - /** - * @since 4.0 - */ - public void getCommitInfos(CDOBranch branch, long startTime, String userID, String comment, int count, - CDOCommitInfoHandler handler); -} +/*
+ * Copyright (c) 2004 - 2012 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:
+ * Andre Dietisheim - initial API and implementation
+ */
+package org.eclipse.emf.cdo.common.commit;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+
+/**
+ * Loads, provides and possible manages {@link CDOCommitInfo commit info} objects.
+ *
+ * @author Andre Dietisheim
+ * @since 3.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.landmark
+ * @apiviz.uses {@link CDOCommitInfo} - - manages
+ */
+public interface CDOCommitInfoManager
+{
+ /**
+ * @since 4.0
+ */
+ public CDOCommitInfo getCommitInfo(long timeStamp);
+
+ public void getCommitInfos(CDOBranch branch, long startTime, long endTime, CDOCommitInfoHandler handler);
+
+ /**
+ * @since 4.0
+ */
+ public void getCommitInfos(CDOBranch branch, long startTime, String userID, String comment, int count,
+ CDOCommitInfoHandler handler);
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/handler/AsyncCommitInfoHandler.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/handler/AsyncCommitInfoHandler.java index e81565e4b4..441ce866fe 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/handler/AsyncCommitInfoHandler.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/handler/AsyncCommitInfoHandler.java @@ -1,58 +1,58 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.commit.handler; - -import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; -import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler; -import org.eclipse.emf.cdo.internal.common.bundle.OM; - -import org.eclipse.net4j.util.concurrent.QueueWorker; - -/** - * A {@link CDOCommitInfoHandler commit info handler} that asynchronously delegates {@link CDOCommitInfo commit infos} - * to another handler. - * - * @author Eike Stepper - * @since 4.0 - */ -public class AsyncCommitInfoHandler extends QueueWorker<CDOCommitInfo> implements CDOCommitInfoHandler -{ - private CDOCommitInfoHandler delegate; - - public AsyncCommitInfoHandler(CDOCommitInfoHandler delegate) - { - this.delegate = delegate; - } - - public void handleCommitInfo(CDOCommitInfo commitInfo) - { - addWork(commitInfo); - } - - @Override - protected void work(WorkContext context, CDOCommitInfo commitInfo) - { - try - { - delegate.handleCommitInfo(commitInfo); - } - catch (Exception ex) - { - OM.LOG.error(ex); - } - } - - @Override - protected boolean doRemainingWorkBeforeDeactivate() - { - return true; - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.commit.handler;
+
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
+import org.eclipse.emf.cdo.internal.common.bundle.OM;
+
+import org.eclipse.net4j.util.concurrent.QueueWorker;
+
+/**
+ * A {@link CDOCommitInfoHandler commit info handler} that asynchronously delegates {@link CDOCommitInfo commit infos}
+ * to another handler.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ */
+public class AsyncCommitInfoHandler extends QueueWorker<CDOCommitInfo> implements CDOCommitInfoHandler
+{
+ private CDOCommitInfoHandler delegate;
+
+ public AsyncCommitInfoHandler(CDOCommitInfoHandler delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ public void handleCommitInfo(CDOCommitInfo commitInfo)
+ {
+ addWork(commitInfo);
+ }
+
+ @Override
+ protected void work(WorkContext context, CDOCommitInfo commitInfo)
+ {
+ try
+ {
+ delegate.handleCommitInfo(commitInfo);
+ }
+ catch (Exception ex)
+ {
+ OM.LOG.error(ex);
+ }
+ }
+
+ @Override
+ protected boolean doRemainingWorkBeforeDeactivate()
+ {
+ return true;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/handler/BinaryCommitInfoLog.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/handler/BinaryCommitInfoLog.java index 4129ff5ee2..011db925db 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/handler/BinaryCommitInfoLog.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/handler/BinaryCommitInfoLog.java @@ -1,59 +1,59 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.commit.handler; - -import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; -import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler; -import org.eclipse.emf.cdo.common.id.CDOIDProvider; -import org.eclipse.emf.cdo.common.model.CDOPackageRegistry; -import org.eclipse.emf.cdo.common.protocol.CDODataOutput; -import org.eclipse.emf.cdo.common.util.CDOCommonUtil; -import org.eclipse.emf.cdo.internal.common.bundle.OM; - -import org.eclipse.net4j.util.io.ExtendedDataOutput; -import org.eclipse.net4j.util.io.ExtendedDataOutputStream; - -import java.io.OutputStream; - -/** - * A {@link CDOCommitInfoHandler commit info handler} that synchronously writes {@link CDOCommitInfo commit infos} to a - * binary log. - * - * @author Eike Stepper - * @since 4.0 - */ -public class BinaryCommitInfoLog implements CDOCommitInfoHandler -{ - private CDODataOutput out; - - public BinaryCommitInfoLog(OutputStream stream, CDOPackageRegistry packageRegistry) - { - ExtendedDataOutput eod = ExtendedDataOutputStream.wrap(stream); - out = CDOCommonUtil.createCDODataOutput(eod, packageRegistry, CDOIDProvider.NOOP); - } - - public void handleCommitInfo(CDOCommitInfo commitInfo) - { - try - { - out.writeCDOCommitInfo(commitInfo); - } - catch (Exception ex) - { - handleException(ex); - } - } - - protected void handleException(Exception ex) - { - OM.LOG.error(ex); - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.commit.handler;
+
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
+import org.eclipse.emf.cdo.common.id.CDOIDProvider;
+import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
+import org.eclipse.emf.cdo.internal.common.bundle.OM;
+
+import org.eclipse.net4j.util.io.ExtendedDataOutput;
+import org.eclipse.net4j.util.io.ExtendedDataOutputStream;
+
+import java.io.OutputStream;
+
+/**
+ * A {@link CDOCommitInfoHandler commit info handler} that synchronously writes {@link CDOCommitInfo commit infos} to a
+ * binary log.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ */
+public class BinaryCommitInfoLog implements CDOCommitInfoHandler
+{
+ private CDODataOutput out;
+
+ public BinaryCommitInfoLog(OutputStream stream, CDOPackageRegistry packageRegistry)
+ {
+ ExtendedDataOutput eod = ExtendedDataOutputStream.wrap(stream);
+ out = CDOCommonUtil.createCDODataOutput(eod, packageRegistry, CDOIDProvider.NOOP);
+ }
+
+ public void handleCommitInfo(CDOCommitInfo commitInfo)
+ {
+ try
+ {
+ out.writeCDOCommitInfo(commitInfo);
+ }
+ catch (Exception ex)
+ {
+ handleException(ex);
+ }
+ }
+
+ protected void handleException(Exception ex)
+ {
+ OM.LOG.error(ex);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/handler/TextCommitInfoLog.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/handler/TextCommitInfoLog.java index dddd283966..ca4e5c16d5 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/handler/TextCommitInfoLog.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/handler/TextCommitInfoLog.java @@ -1,65 +1,65 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.commit.handler; - -import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; -import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler; -import org.eclipse.emf.cdo.common.model.CDOPackageUnit; -import org.eclipse.emf.cdo.internal.common.bundle.OM; -import org.eclipse.emf.cdo.spi.common.commit.CDOCommitInfoUtil; - -import java.io.OutputStream; -import java.io.PrintStream; - -/** - * A {@link CDOCommitInfoHandler commit info handler} that synchronously writes {@link CDOCommitInfo commit infos} to a - * text log. - * - * @author Eike Stepper - * @since 4.0 - */ -public class TextCommitInfoLog implements CDOCommitInfoHandler -{ - private PrintStream printStream; - - public TextCommitInfoLog(OutputStream stream) - { - printStream = stream instanceof PrintStream ? (PrintStream)stream : new PrintStream(stream); - } - - public void handleCommitInfo(CDOCommitInfo commitInfo) - { - try - { - if (printStream != null) - { - printStream.println(commitInfo); - - for (CDOPackageUnit packageUnit : commitInfo.getNewPackageUnits()) - { - printStream.println(" P " + packageUnit.getID()); - } - - CDOCommitInfoUtil.dump(printStream, commitInfo); - printStream.flush(); - } - } - catch (Exception ex) - { - handleException(ex); - } - } - - protected void handleException(Exception ex) - { - OM.LOG.error(ex); - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.commit.handler;
+
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
+import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
+import org.eclipse.emf.cdo.internal.common.bundle.OM;
+import org.eclipse.emf.cdo.spi.common.commit.CDOCommitInfoUtil;
+
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+/**
+ * A {@link CDOCommitInfoHandler commit info handler} that synchronously writes {@link CDOCommitInfo commit infos} to a
+ * text log.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ */
+public class TextCommitInfoLog implements CDOCommitInfoHandler
+{
+ private PrintStream printStream;
+
+ public TextCommitInfoLog(OutputStream stream)
+ {
+ printStream = stream instanceof PrintStream ? (PrintStream)stream : new PrintStream(stream);
+ }
+
+ public void handleCommitInfo(CDOCommitInfo commitInfo)
+ {
+ try
+ {
+ if (printStream != null)
+ {
+ printStream.println(commitInfo);
+
+ for (CDOPackageUnit packageUnit : commitInfo.getNewPackageUnits())
+ {
+ printStream.println(" P " + packageUnit.getID());
+ }
+
+ CDOCommitInfoUtil.dump(printStream, commitInfo);
+ printStream.flush();
+ }
+ }
+ catch (Exception ex)
+ {
+ handleException(ex);
+ }
+ }
+
+ protected void handleException(Exception ex)
+ {
+ OM.LOG.error(ex);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/handler/package-info.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/handler/package-info.java index 9b3abafe7e..132c167e63 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/handler/package-info.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/handler/package-info.java @@ -1,5 +1,5 @@ /*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 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
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/package-info.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/package-info.java index 04104245ad..8c68efd5ef 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/package-info.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/package-info.java @@ -1,5 +1,5 @@ /*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 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
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOID.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOID.java index cc74e54b0b..054fef251e 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOID.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOID.java @@ -1,162 +1,162 @@ -/* - * Copyright (c) 2004 - 2011 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 226778 - * Simon McDuff - bug 213402 - */ -package org.eclipse.emf.cdo.common.id; - -import org.eclipse.emf.cdo.common.CDOCommonRepository; - -import org.eclipse.net4j.util.ImplementationError; - -import java.io.Serializable; -import java.lang.reflect.Array; - -/** - * Identifies CDO objects uniquely in a CDO {@link CDOCommonRepository repository}. - * - * @author Eike Stepper - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.landmark - * @apiviz.has {@link CDOID.Type} - */ -public interface CDOID extends Serializable, Comparable<CDOID> -{ - public static final CDOID NULL = org.eclipse.emf.cdo.internal.common.id.CDOIDNullImpl.INSTANCE; - - public Type getType(); - - public boolean isNull(); - - public boolean isObject(); - - public boolean isTemporary(); - - /** - * @since 3.0 - */ - public boolean isDangling(); - - /** - * @since 2.0 - */ - public boolean isExternal(); - - /** - * @since 2.0 - */ - public String toURIFragment(); - - /** - * Enumerates the possible types of CDO {@link CDOID IDs}. - * - * @author Eike Stepper - */ - public enum Type - { - NULL('N'), // - OBJECT(' '), // Superceded by ObjectType.getID() - - /** - * @since 2.0 - */ - EXTERNAL_OBJECT('E'), - - /** - * @since 3.0 - */ - DANGLING_OBJECT('D'), - - /** - * @since 2.0 - */ - EXTERNAL_TEMP_OBJECT('e'), // - TEMP_OBJECT('t'); - - private static Enum<?>[] chars; - - private char id; - - private Type(char id) - { - registerChar(id, this); - this.id = id; - } - - private static void registerChar(char id, Enum<?> literal) - { - if (chars == null) - { - chars = (Enum<?>[])Array.newInstance(Enum.class, id + 1); - } - else if (chars.length < id) - { - Enum<?>[] newChars = (Enum<?>[])Array.newInstance(Enum.class, id + 1); - System.arraycopy(chars, 0, newChars, 0, chars.length); - chars = newChars; - } - - if (chars[id] != null) - { - throw new ImplementationError("Duplicate id: " + id); - } - - chars[id] = literal; - } - - /** - * @since 4.0 - */ - public static Enum<?> getLiteral(char id) - { - return chars[id]; - } - - /** - * @since 4.0 - */ - public char getID() - { - return id; - } - } - - /** - * Enumerates the possible <b>sub</b> types of CDO {@link CDOID IDs} with the main type {@link Type#OBJECT OBJECT}. - * - * @author Eike Stepper - * @since 3.0 - */ - public enum ObjectType - { - LONG('L'), // - STRING('S'), // - LONG_WITH_CLASSIFIER('l'), // - STRING_WITH_CLASSIFIER('s'), // - UUID('U'); - - private char id; - - private ObjectType(char id) - { - Type.registerChar(id, this); - this.id = id; - } - - /** - * @since 4.0 - */ - public char getID() - { - return id; - } - } -} +/*
+ * Copyright (c) 2004 - 2012 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 226778
+ * Simon McDuff - bug 213402
+ */
+package org.eclipse.emf.cdo.common.id;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository;
+
+import org.eclipse.net4j.util.ImplementationError;
+
+import java.io.Serializable;
+import java.lang.reflect.Array;
+
+/**
+ * Identifies CDO objects uniquely in a CDO {@link CDOCommonRepository repository}.
+ *
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.landmark
+ * @apiviz.has {@link CDOID.Type}
+ */
+public interface CDOID extends Serializable, Comparable<CDOID>
+{
+ public static final CDOID NULL = org.eclipse.emf.cdo.internal.common.id.CDOIDNullImpl.INSTANCE;
+
+ public Type getType();
+
+ public boolean isNull();
+
+ public boolean isObject();
+
+ public boolean isTemporary();
+
+ /**
+ * @since 3.0
+ */
+ public boolean isDangling();
+
+ /**
+ * @since 2.0
+ */
+ public boolean isExternal();
+
+ /**
+ * @since 2.0
+ */
+ public String toURIFragment();
+
+ /**
+ * Enumerates the possible types of CDO {@link CDOID IDs}.
+ *
+ * @author Eike Stepper
+ */
+ public enum Type
+ {
+ NULL('N'), //
+ OBJECT(' '), // Superceded by ObjectType.getID()
+
+ /**
+ * @since 2.0
+ */
+ EXTERNAL_OBJECT('E'),
+
+ /**
+ * @since 3.0
+ */
+ DANGLING_OBJECT('D'),
+
+ /**
+ * @since 2.0
+ */
+ EXTERNAL_TEMP_OBJECT('e'), //
+ TEMP_OBJECT('t');
+
+ private static Enum<?>[] chars;
+
+ private char id;
+
+ private Type(char id)
+ {
+ registerChar(id, this);
+ this.id = id;
+ }
+
+ private static void registerChar(char id, Enum<?> literal)
+ {
+ if (chars == null)
+ {
+ chars = (Enum<?>[])Array.newInstance(Enum.class, id + 1);
+ }
+ else if (chars.length < id)
+ {
+ Enum<?>[] newChars = (Enum<?>[])Array.newInstance(Enum.class, id + 1);
+ System.arraycopy(chars, 0, newChars, 0, chars.length);
+ chars = newChars;
+ }
+
+ if (chars[id] != null)
+ {
+ throw new ImplementationError("Duplicate id: " + id);
+ }
+
+ chars[id] = literal;
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static Enum<?> getLiteral(char id)
+ {
+ return chars[id];
+ }
+
+ /**
+ * @since 4.0
+ */
+ public char getID()
+ {
+ return id;
+ }
+ }
+
+ /**
+ * Enumerates the possible <b>sub</b> types of CDO {@link CDOID IDs} with the main type {@link Type#OBJECT OBJECT}.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ */
+ public enum ObjectType
+ {
+ LONG('L'), //
+ STRING('S'), //
+ LONG_WITH_CLASSIFIER('l'), //
+ STRING_WITH_CLASSIFIER('s'), //
+ UUID('U');
+
+ private char id;
+
+ private ObjectType(char id)
+ {
+ Type.registerChar(id, this);
+ this.id = id;
+ }
+
+ /**
+ * @since 4.0
+ */
+ public char getID()
+ {
+ return id;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDExternal.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDExternal.java index bba12e86bf..7b52e8340d 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDExternal.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDExternal.java @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2004 - 2011 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: - * Simon McDuff - initial API and implementation - * Eike Stepper - maintenance - */ -package org.eclipse.emf.cdo.common.id; - -import org.eclipse.emf.cdo.common.CDOCommonRepository; - -/** - * The {@link CDOID ID} of a CDO object that is external to a CDO {@link CDOCommonRepository repository}. - * - * @author Simon McDuff - * @since 2.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDOIDExternal extends CDOID -{ - public String getURI(); -} +/*
+ * Copyright (c) 2004 - 2012 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:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.common.id;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository;
+
+/**
+ * The {@link CDOID ID} of a CDO object that is external to a CDO {@link CDOCommonRepository repository}.
+ *
+ * @author Simon McDuff
+ * @since 2.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDOIDExternal extends CDOID
+{
+ public String getURI();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDGenerator.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDGenerator.java index 293825eba8..b929df6373 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDGenerator.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDGenerator.java @@ -1,72 +1,72 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.id; - -import org.eclipse.net4j.util.UUIDGenerator; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.util.EcoreUtil; - -/** - * Generates {@link CDOID IDs}. - * - * @author Eike Stepper - * @since 4.1 - */ -public interface CDOIDGenerator -{ - /** - * Generates {@link CDOID#NULL NULL} values. - */ - public static final CDOIDGenerator NULL = new CDOIDGenerator() - { - public CDOID generateCDOID(EObject object) - { - return CDOID.NULL; - } - - public void reset() - { - // Do nothing - } - }; - - /** - * Generates {@link EcoreUtil#generateUUID(byte[]) UUID} values. - */ - public static final CDOIDGenerator UUID = new CDOIDGenerator() - { - public CDOID generateCDOID(EObject object) - { - byte[] bytes = new byte[16]; - UUIDGenerator.DEFAULT.generate(bytes); - return CDOIDUtil.createUUID(bytes); - } - - public void reset() - { - // Do nothing - } - }; - - /** - * Generates a {@link CDOID}. - * - * @param object - * the object to generate a new CDOID for if available, <code>null</code> otherwise. - */ - public CDOID generateCDOID(EObject object); - - /** - * Called at the end of a commit operation to give this ID generator a chance to reset its sequence of IDs. - */ - public void reset(); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.id;
+
+import org.eclipse.net4j.util.UUIDGenerator;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+/**
+ * Generates {@link CDOID IDs}.
+ *
+ * @author Eike Stepper
+ * @since 4.1
+ */
+public interface CDOIDGenerator
+{
+ /**
+ * Generates {@link CDOID#NULL NULL} values.
+ */
+ public static final CDOIDGenerator NULL = new CDOIDGenerator()
+ {
+ public CDOID generateCDOID(EObject object)
+ {
+ return CDOID.NULL;
+ }
+
+ public void reset()
+ {
+ // Do nothing
+ }
+ };
+
+ /**
+ * Generates {@link EcoreUtil#generateUUID(byte[]) UUID} values.
+ */
+ public static final CDOIDGenerator UUID = new CDOIDGenerator()
+ {
+ public CDOID generateCDOID(EObject object)
+ {
+ byte[] bytes = new byte[16];
+ UUIDGenerator.DEFAULT.generate(bytes);
+ return CDOIDUtil.createUUID(bytes);
+ }
+
+ public void reset()
+ {
+ // Do nothing
+ }
+ };
+
+ /**
+ * Generates a {@link CDOID}.
+ *
+ * @param object
+ * the object to generate a new CDOID for if available, <code>null</code> otherwise.
+ */
+ public CDOID generateCDOID(EObject object);
+
+ /**
+ * Called at the end of a commit operation to give this ID generator a chance to reset its sequence of IDs.
+ */
+ public void reset();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDObject.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDObject.java index 4a61ce239a..19d9ec4c96 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDObject.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDObject.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.id; - -import org.eclipse.emf.cdo.common.CDOCommonRepository; - -/** - * The {@link CDOID ID} of a CDO object that is persistent in a CDO {@link CDOCommonRepository repository}. - * - * @author Eike Stepper - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.has {@link CDOID.ObjectType} - */ -public interface CDOIDObject extends CDOID -{ -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.id;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository;
+
+/**
+ * The {@link CDOID ID} of a CDO object that is persistent in a CDO {@link CDOCommonRepository repository}.
+ *
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.has {@link CDOID.ObjectType}
+ */
+public interface CDOIDObject extends CDOID
+{
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDProvider.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDProvider.java index d6a1fd0cb1..8914221b5b 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDProvider.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDProvider.java @@ -1,33 +1,33 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.id; - -/** - * Provides the {@link CDOID IDs} of passed objects. - * - * @author Eike Stepper - * @apiviz.uses {@link CDOID} - - provides - */ -public interface CDOIDProvider -{ - /** - * @since 3.0 - */ - public static final CDOIDProvider NOOP = new CDOIDProvider() - { - public CDOID provideCDOID(Object id) - { - return (CDOID)id; - } - }; - - public CDOID provideCDOID(Object idOrObject); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.id;
+
+/**
+ * Provides the {@link CDOID IDs} of passed objects.
+ *
+ * @author Eike Stepper
+ * @apiviz.uses {@link CDOID} - - provides
+ */
+public interface CDOIDProvider
+{
+ /**
+ * @since 3.0
+ */
+ public static final CDOIDProvider NOOP = new CDOIDProvider()
+ {
+ public CDOID provideCDOID(Object id)
+ {
+ return (CDOID)id;
+ }
+ };
+
+ public CDOID provideCDOID(Object idOrObject);
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDReference.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDReference.java index 356cfc8958..775ab10c69 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDReference.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDReference.java @@ -1,108 +1,108 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.id; - -import org.eclipse.emf.cdo.common.protocol.CDODataInput; -import org.eclipse.emf.cdo.common.protocol.CDODataOutput; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EStructuralFeature; - -import java.io.IOException; - -/** - * Represents a {@link CDOID} typed reference from one object to another object. - * - * @author Eike Stepper - * @since 4.0 - * @noextend This interface is not intended to be extended by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - * @apiviz.has {@link CDOID} oneway - - source - * @apiviz.has {@link CDOID} oneway - - target - */ -public class CDOIDReference implements CDOReference<CDOID> -{ - private CDOID targetID; - - private CDOID sourceID; - - private EStructuralFeature sourceFeature; - - private int sourceIndex; - - public CDOIDReference(CDOID targetID, CDOID sourceID, EStructuralFeature sourceFeature, int sourceIndex) - { - this.targetID = targetID; - this.sourceID = sourceID; - this.sourceFeature = sourceFeature; - this.sourceIndex = sourceIndex; - } - - public CDOIDReference(CDODataInput in) throws IOException - { - targetID = in.readCDOID(); - sourceID = in.readCDOID(); - - EClass eClass = (EClass)in.readCDOClassifierRefAndResolve(); - String featureName = in.readString(); - sourceFeature = eClass.getEStructuralFeature(featureName); - - sourceIndex = in.readInt(); - } - - public void write(CDODataOutput out) throws IOException - { - out.writeCDOID(targetID); - out.writeCDOID(sourceID); - out.writeCDOClassifierRef(sourceFeature.getEContainingClass()); - out.writeString(sourceFeature.getName()); - out.writeInt(sourceIndex); - } - - public CDOID getTargetObject() - { - return targetID; - } - - public CDOID getSourceObject() - { - return sourceID; - } - - public EStructuralFeature getSourceFeature() - { - return sourceFeature; - } - - public int getSourceIndex() - { - return sourceIndex; - } - - @Override - public String toString() - { - StringBuilder builder = new StringBuilder(); - builder.append(sourceID); - builder.append("."); - builder.append(sourceFeature.getName()); - if (sourceIndex != NO_INDEX) - { - builder.append("["); - builder.append(sourceIndex); - builder.append("]"); - } - - builder.append(" --> "); - builder.append(targetID); - return builder.toString(); - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.id;
+
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import java.io.IOException;
+
+/**
+ * Represents a {@link CDOID} typed reference from one object to another object.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ * @apiviz.has {@link CDOID} oneway - - source
+ * @apiviz.has {@link CDOID} oneway - - target
+ */
+public class CDOIDReference implements CDOReference<CDOID>
+{
+ private CDOID targetID;
+
+ private CDOID sourceID;
+
+ private EStructuralFeature sourceFeature;
+
+ private int sourceIndex;
+
+ public CDOIDReference(CDOID targetID, CDOID sourceID, EStructuralFeature sourceFeature, int sourceIndex)
+ {
+ this.targetID = targetID;
+ this.sourceID = sourceID;
+ this.sourceFeature = sourceFeature;
+ this.sourceIndex = sourceIndex;
+ }
+
+ public CDOIDReference(CDODataInput in) throws IOException
+ {
+ targetID = in.readCDOID();
+ sourceID = in.readCDOID();
+
+ EClass eClass = (EClass)in.readCDOClassifierRefAndResolve();
+ String featureName = in.readString();
+ sourceFeature = eClass.getEStructuralFeature(featureName);
+
+ sourceIndex = in.readInt();
+ }
+
+ public void write(CDODataOutput out) throws IOException
+ {
+ out.writeCDOID(targetID);
+ out.writeCDOID(sourceID);
+ out.writeCDOClassifierRef(sourceFeature.getEContainingClass());
+ out.writeString(sourceFeature.getName());
+ out.writeInt(sourceIndex);
+ }
+
+ public CDOID getTargetObject()
+ {
+ return targetID;
+ }
+
+ public CDOID getSourceObject()
+ {
+ return sourceID;
+ }
+
+ public EStructuralFeature getSourceFeature()
+ {
+ return sourceFeature;
+ }
+
+ public int getSourceIndex()
+ {
+ return sourceIndex;
+ }
+
+ @Override
+ public String toString()
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append(sourceID);
+ builder.append(".");
+ builder.append(sourceFeature.getName());
+ if (sourceIndex != NO_INDEX)
+ {
+ builder.append("[");
+ builder.append(sourceIndex);
+ builder.append("]");
+ }
+
+ builder.append(" --> ");
+ builder.append(targetID);
+ return builder.toString();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDTemp.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDTemp.java index b8ba1ae781..bec16fbfa9 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDTemp.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDTemp.java @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2004 - 2011 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 213402 - */ -package org.eclipse.emf.cdo.common.id; - -import org.eclipse.emf.cdo.common.CDOCommonTransaction; - -/** - * The {@link CDOID ID} of a CDO object that is new in a dirty (uncommitted) CDO {@link CDOCommonTransaction - * transaction}. - * - * @author Eike Stepper - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDOIDTemp extends CDOID -{ -} +/*
+ * Copyright (c) 2004 - 2012 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 213402
+ */
+package org.eclipse.emf.cdo.common.id;
+
+import org.eclipse.emf.cdo.common.CDOCommonTransaction;
+
+/**
+ * The {@link CDOID ID} of a CDO object that is new in a dirty (uncommitted) CDO {@link CDOCommonTransaction
+ * transaction}.
+ *
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDOIDTemp extends CDOID
+{
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java index a5869fd03b..9b1687e02a 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOIDUtil.java @@ -1,452 +1,452 @@ -/* - * Copyright (c) 2004 - 2011 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 226778 - * Simon McDuff - bug 213402 - * Martin Taal - Added subtype handling and EClass conversion, bug 283106 - */ -package org.eclipse.emf.cdo.common.id; - -import org.eclipse.emf.cdo.common.branch.CDOBranch; -import org.eclipse.emf.cdo.common.id.CDOID.ObjectType; -import org.eclipse.emf.cdo.common.id.CDOID.Type; -import org.eclipse.emf.cdo.common.model.CDOClassifierRef; -import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch; -import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion; -import org.eclipse.emf.cdo.internal.common.id.CDOIDExternalImpl; -import org.eclipse.emf.cdo.internal.common.id.CDOIDObjectLongImpl; -import org.eclipse.emf.cdo.internal.common.id.CDOIDObjectLongWithClassifierImpl; -import org.eclipse.emf.cdo.internal.common.id.CDOIDObjectStringImpl; -import org.eclipse.emf.cdo.internal.common.id.CDOIDObjectStringWithClassifierImpl; -import org.eclipse.emf.cdo.internal.common.id.CDOIDObjectUUIDImpl; -import org.eclipse.emf.cdo.internal.common.id.CDOIDTempObjectExternalImpl; -import org.eclipse.emf.cdo.internal.common.id.CDOIDTempObjectImpl; -import org.eclipse.emf.cdo.internal.common.messages.Messages; -import org.eclipse.emf.cdo.internal.common.revision.CDOIDAndBranchImpl; -import org.eclipse.emf.cdo.internal.common.revision.CDOIDAndVersionImpl; -import org.eclipse.emf.cdo.spi.common.id.AbstractCDOID; -import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDByteArray; -import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong; -import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDString; -import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject; - -import org.eclipse.net4j.util.ObjectUtil; -import org.eclipse.net4j.util.UUIDGenerator; - -import java.text.MessageFormat; - -/** - * Various static methods that may help with CDO {@link CDOID IDs}. - * - * @author Eike Stepper - * @since 2.0 - */ -public final class CDOIDUtil -{ - private CDOIDUtil() - { - } - - /** - * @since 2.0 - */ - public static boolean isNull(CDOID id) - { - return id == null || id.isNull(); - } - - public static long getLong(CDOID id) - { - if (id == null) - { - return AbstractCDOIDLong.NULL_VALUE; - } - - switch (id.getType()) - { - case NULL: - return AbstractCDOIDLong.NULL_VALUE; - - case OBJECT: - if (id instanceof AbstractCDOIDLong) - { - return ((AbstractCDOIDLong)id).getLongValue(); - } - - throw new IllegalArgumentException(MessageFormat.format( - Messages.getString("CDOIDUtil.0"), id.getClass().getName())); //$NON-NLS-1$ - - case TEMP_OBJECT: - throw new IllegalArgumentException(Messages.getString("CDOIDUtil.1")); //$NON-NLS-1$ - - case EXTERNAL_OBJECT: - case EXTERNAL_TEMP_OBJECT: - throw new IllegalArgumentException(Messages.getString("CDOIDUtil.2")); //$NON-NLS-1$ - - default: - throw new IllegalArgumentException(MessageFormat.format( - Messages.getString("CDOIDUtil.3"), id.getClass().getName())); //$NON-NLS-1$ - } - } - - /** - * @since 4.0 - */ - public static String getString(CDOID id) - { - if (id == null) - { - return AbstractCDOIDString.NULL_VALUE; - } - - switch (id.getType()) - { - case NULL: - return AbstractCDOIDString.NULL_VALUE; - - case OBJECT: - if (id instanceof AbstractCDOIDString) - { - return ((AbstractCDOIDString)id).getStringValue(); - } - - throw new IllegalArgumentException(MessageFormat.format( - Messages.getString("CDOIDUtil.0"), id.getClass().getName())); //$NON-NLS-1$ - - case TEMP_OBJECT: - throw new IllegalArgumentException(Messages.getString("CDOIDUtil.1")); //$NON-NLS-1$ - - case EXTERNAL_OBJECT: - case EXTERNAL_TEMP_OBJECT: - if (id instanceof CDOIDExternalImpl) - { - return ((CDOIDExternalImpl)id).getURI(); - } - - throw new IllegalArgumentException(MessageFormat.format( - Messages.getString("CDOIDUtil.0"), id.getClass().getName())); //$NON-NLS-1$ - - default: - throw new IllegalArgumentException(MessageFormat.format( - Messages.getString("CDOIDUtil.3"), id.getClass().getName())); //$NON-NLS-1$ - } - } - - /** - * @since 4.1 - */ - public static byte[] getByteArray(CDOID id) - { - if (id == null) - { - return null; - } - - switch (id.getType()) - { - case NULL: - return null; - - case OBJECT: - if (id instanceof AbstractCDOIDByteArray) - { - return ((AbstractCDOIDByteArray)id).getByteArrayValue(); - } - - throw new IllegalArgumentException(MessageFormat.format( - Messages.getString("CDOIDUtil.0"), id.getClass().getName())); //$NON-NLS-1$ - - default: - throw new IllegalArgumentException(MessageFormat.format( - Messages.getString("CDOIDUtil.3"), id.getClass().getName())); //$NON-NLS-1$ - } - } - - /** - * @since 3.0 - */ - public static CDOClassifierRef getClassifierRef(CDOID id) - { - if (id instanceof CDOClassifierRef.Provider) - { - return ((CDOClassifierRef.Provider)id).getClassifierRef(); - } - - return null; - } - - public static CDOIDTemp createTempObject(int value) - { - return new CDOIDTempObjectImpl(value); - } - - /** - * @since 3.0 - */ - public static CDOIDExternal createTempObjectExternal(String uri) - { - return new CDOIDTempObjectExternalImpl(uri); - } - - public static CDOID createLong(long value) - { - if (value == AbstractCDOIDLong.NULL_VALUE) - { - return CDOID.NULL; - } - - return new CDOIDObjectLongImpl(value); - } - - /** - * @since 3.0 - */ - public static CDOID createLongWithClassifier(CDOClassifierRef classifierRef, long value) - { - return new CDOIDObjectLongWithClassifierImpl(classifierRef, value); - } - - /** - * @since 4.0 - */ - public static CDOID createString(String value) - { - return new CDOIDObjectStringImpl(value); - } - - /** - * @since 3.0 - */ - public static CDOID createStringWithClassifier(CDOClassifierRef classifierRef, String value) - { - return new CDOIDObjectStringWithClassifierImpl(classifierRef, value); - } - - /** - * @since 4.1 - */ - public static CDOID createUUID(byte[] value) - { - return new CDOIDObjectUUIDImpl(value); - } - - /** - * @since 4.1 - */ - public static CDOID createUUID() - { - byte[] value = new byte[16]; - UUIDGenerator.DEFAULT.generate(value); - return createUUID(value); - } - - /** - * @since 4.1 - */ - public static String encodeUUID(byte[] bytes) - { - return UUIDGenerator.DEFAULT.encode(bytes); - } - - /** - * @since 4.1 - */ - public static byte[] decodeUUID(String string) - { - return UUIDGenerator.DEFAULT.decode(string); - } - - /** - * @since 2.0 - */ - public static CDOIDExternal createExternal(String uri) - { - return new CDOIDExternalImpl(uri); - } - - /** - * @since 4.0 - */ - public static CDOIDAndVersion createIDAndVersion(CDOID id, int version) - { - return new CDOIDAndVersionImpl(id, version); - } - - /** - * @since 4.0 - */ - public static CDOIDAndVersion createIDAndVersion(CDOIDAndVersion source) - { - return createIDAndVersion(source.getID(), source.getVersion()); - } - - /** - * @since 4.0 - */ - public static CDOIDAndBranch createIDAndBranch(CDOID id, CDOBranch branch) - { - return new CDOIDAndBranchImpl(id, branch); - } - - /** - * Creates the correct implementation class for the passed {@link CDOID.ObjectType}. - * - * @param subType - * the subType for which to create an empty CDOID instance - * @return the instance of CDOIDObject which represents the subtype. - * @since 3.0 - */ - public static AbstractCDOID createCDOIDObject(CDOID.ObjectType subType) - { - if (subType == null) - { - throw new IllegalArgumentException("SubType may not be null"); - } - - InternalCDOIDObject id; - switch (subType) - { - case LONG: - id = new CDOIDObjectLongImpl(); - break; - - case STRING: - id = new CDOIDObjectStringImpl(); - break; - - case LONG_WITH_CLASSIFIER: - id = new CDOIDObjectLongWithClassifierImpl(); - break; - - case STRING_WITH_CLASSIFIER: - id = new CDOIDObjectStringWithClassifierImpl(); - break; - - case UUID: - id = new CDOIDObjectUUIDImpl(); - break; - - default: - throw new IllegalArgumentException("Subtype " + subType.name() + " not supported"); - } - - if (id.getSubType() != subType) - { - throw new IllegalStateException("Subtype of created id " + id + " is unequal (" + id.getSubType().name() - + ") to requested subtype " + subType.name()); - } - - return (AbstractCDOID)id; - } - - /** - * Format of the uri fragment. - * <p> - * Non-legacy: <code><ID TYPE>/<CUSTOM STRING FROM OBJECT FACTORY></code> - * <p> - * Legacy: <code><ID TYPE>/<PACKAGE URI>/<CLASSIFIER ID>/<CUSTOM STRING FROM OBJECT FACTORY></code> - * - * @since 2.0 - */ - public static void write(StringBuilder builder, CDOID id) - { - if (id == null) - { - id = CDOID.NULL; - } - - if (id instanceof InternalCDOIDObject) - { - ObjectType subType = ((InternalCDOIDObject)id).getSubType(); - builder.append(subType.getID()); - } - else - { - Type type = id.getType(); - builder.append(type.getID()); - } - - builder.append(id.toURIFragment()); - } - - /** - * Format of the URI fragment. - * <p> - * Non-legacy: <code><ID TYPE>/<CUSTOM STRING FROM OBJECT FACTORY></code> - * <p> - * Legacy: <code><ID TYPE>/<PACKAGE URI>/<CLASSIFIER ID>/<CUSTOM STRING FROM OBJECT FACTORY></code> - * - * @since 3.0 - */ - public static CDOID read(String uriFragment) - { - char typeID = uriFragment.charAt(0); - Enum<?> literal = CDOID.Type.getLiteral(typeID); - if (literal == null) - { - throw new IllegalArgumentException("Unknown type ID: " + typeID); - } - - String fragment = uriFragment.substring(1); - if (literal instanceof ObjectType) - { - return readCDOIDObject((ObjectType)literal, fragment); - } - - Type type = (Type)literal; - switch (type) - { - case NULL: - return CDOID.NULL; - - case TEMP_OBJECT: - return new CDOIDTempObjectImpl(Integer.valueOf(fragment)); - - case EXTERNAL_OBJECT: - return new CDOIDExternalImpl(fragment); - - case EXTERNAL_TEMP_OBJECT: - return new CDOIDTempObjectExternalImpl(fragment); - - case OBJECT: - { - // Normally this case should not occur (is an OBJECT subtype). - throw new IllegalArgumentException(); - } - - default: - throw new IllegalArgumentException(MessageFormat.format(Messages.getString("CDOIDUtil.5"), uriFragment)); //$NON-NLS-1$ - } - } - - private static CDOID readCDOIDObject(CDOID.ObjectType subType, String fragment) - { - AbstractCDOID id = createCDOIDObject(subType); - id.read(fragment); - return id; - } - - /** - * @since 2.0 - */ - public static boolean equals(CDOID id1, CDOID id2) - { - if (id1 == null) - { - id1 = CDOID.NULL; - } - - if (id2 == null) - { - id2 = CDOID.NULL; - } - - return ObjectUtil.equals(id1, id2); - } -} +/*
+ * Copyright (c) 2004 - 2012 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 226778
+ * Simon McDuff - bug 213402
+ * Martin Taal - Added subtype handling and EClass conversion, bug 283106
+ */
+package org.eclipse.emf.cdo.common.id;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.id.CDOID.ObjectType;
+import org.eclipse.emf.cdo.common.id.CDOID.Type;
+import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
+import org.eclipse.emf.cdo.internal.common.id.CDOIDExternalImpl;
+import org.eclipse.emf.cdo.internal.common.id.CDOIDObjectLongImpl;
+import org.eclipse.emf.cdo.internal.common.id.CDOIDObjectLongWithClassifierImpl;
+import org.eclipse.emf.cdo.internal.common.id.CDOIDObjectStringImpl;
+import org.eclipse.emf.cdo.internal.common.id.CDOIDObjectStringWithClassifierImpl;
+import org.eclipse.emf.cdo.internal.common.id.CDOIDObjectUUIDImpl;
+import org.eclipse.emf.cdo.internal.common.id.CDOIDTempObjectExternalImpl;
+import org.eclipse.emf.cdo.internal.common.id.CDOIDTempObjectImpl;
+import org.eclipse.emf.cdo.internal.common.messages.Messages;
+import org.eclipse.emf.cdo.internal.common.revision.CDOIDAndBranchImpl;
+import org.eclipse.emf.cdo.internal.common.revision.CDOIDAndVersionImpl;
+import org.eclipse.emf.cdo.spi.common.id.AbstractCDOID;
+import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDByteArray;
+import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong;
+import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDString;
+import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject;
+
+import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.UUIDGenerator;
+
+import java.text.MessageFormat;
+
+/**
+ * Various static methods that may help with CDO {@link CDOID IDs}.
+ *
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public final class CDOIDUtil
+{
+ private CDOIDUtil()
+ {
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static boolean isNull(CDOID id)
+ {
+ return id == null || id.isNull();
+ }
+
+ public static long getLong(CDOID id)
+ {
+ if (id == null)
+ {
+ return AbstractCDOIDLong.NULL_VALUE;
+ }
+
+ switch (id.getType())
+ {
+ case NULL:
+ return AbstractCDOIDLong.NULL_VALUE;
+
+ case OBJECT:
+ if (id instanceof AbstractCDOIDLong)
+ {
+ return ((AbstractCDOIDLong)id).getLongValue();
+ }
+
+ throw new IllegalArgumentException(MessageFormat.format(
+ Messages.getString("CDOIDUtil.0"), id.getClass().getName())); //$NON-NLS-1$
+
+ case TEMP_OBJECT:
+ throw new IllegalArgumentException(Messages.getString("CDOIDUtil.1")); //$NON-NLS-1$
+
+ case EXTERNAL_OBJECT:
+ case EXTERNAL_TEMP_OBJECT:
+ throw new IllegalArgumentException(Messages.getString("CDOIDUtil.2")); //$NON-NLS-1$
+
+ default:
+ throw new IllegalArgumentException(MessageFormat.format(
+ Messages.getString("CDOIDUtil.3"), id.getClass().getName())); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static String getString(CDOID id)
+ {
+ if (id == null)
+ {
+ return AbstractCDOIDString.NULL_VALUE;
+ }
+
+ switch (id.getType())
+ {
+ case NULL:
+ return AbstractCDOIDString.NULL_VALUE;
+
+ case OBJECT:
+ if (id instanceof AbstractCDOIDString)
+ {
+ return ((AbstractCDOIDString)id).getStringValue();
+ }
+
+ throw new IllegalArgumentException(MessageFormat.format(
+ Messages.getString("CDOIDUtil.0"), id.getClass().getName())); //$NON-NLS-1$
+
+ case TEMP_OBJECT:
+ throw new IllegalArgumentException(Messages.getString("CDOIDUtil.1")); //$NON-NLS-1$
+
+ case EXTERNAL_OBJECT:
+ case EXTERNAL_TEMP_OBJECT:
+ if (id instanceof CDOIDExternalImpl)
+ {
+ return ((CDOIDExternalImpl)id).getURI();
+ }
+
+ throw new IllegalArgumentException(MessageFormat.format(
+ Messages.getString("CDOIDUtil.0"), id.getClass().getName())); //$NON-NLS-1$
+
+ default:
+ throw new IllegalArgumentException(MessageFormat.format(
+ Messages.getString("CDOIDUtil.3"), id.getClass().getName())); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @since 4.1
+ */
+ public static byte[] getByteArray(CDOID id)
+ {
+ if (id == null)
+ {
+ return null;
+ }
+
+ switch (id.getType())
+ {
+ case NULL:
+ return null;
+
+ case OBJECT:
+ if (id instanceof AbstractCDOIDByteArray)
+ {
+ return ((AbstractCDOIDByteArray)id).getByteArrayValue();
+ }
+
+ throw new IllegalArgumentException(MessageFormat.format(
+ Messages.getString("CDOIDUtil.0"), id.getClass().getName())); //$NON-NLS-1$
+
+ default:
+ throw new IllegalArgumentException(MessageFormat.format(
+ Messages.getString("CDOIDUtil.3"), id.getClass().getName())); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * @since 3.0
+ */
+ public static CDOClassifierRef getClassifierRef(CDOID id)
+ {
+ if (id instanceof CDOClassifierRef.Provider)
+ {
+ return ((CDOClassifierRef.Provider)id).getClassifierRef();
+ }
+
+ return null;
+ }
+
+ public static CDOIDTemp createTempObject(int value)
+ {
+ return new CDOIDTempObjectImpl(value);
+ }
+
+ /**
+ * @since 3.0
+ */
+ public static CDOIDExternal createTempObjectExternal(String uri)
+ {
+ return new CDOIDTempObjectExternalImpl(uri);
+ }
+
+ public static CDOID createLong(long value)
+ {
+ if (value == AbstractCDOIDLong.NULL_VALUE)
+ {
+ return CDOID.NULL;
+ }
+
+ return new CDOIDObjectLongImpl(value);
+ }
+
+ /**
+ * @since 3.0
+ */
+ public static CDOID createLongWithClassifier(CDOClassifierRef classifierRef, long value)
+ {
+ return new CDOIDObjectLongWithClassifierImpl(classifierRef, value);
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static CDOID createString(String value)
+ {
+ return new CDOIDObjectStringImpl(value);
+ }
+
+ /**
+ * @since 3.0
+ */
+ public static CDOID createStringWithClassifier(CDOClassifierRef classifierRef, String value)
+ {
+ return new CDOIDObjectStringWithClassifierImpl(classifierRef, value);
+ }
+
+ /**
+ * @since 4.1
+ */
+ public static CDOID createUUID(byte[] value)
+ {
+ return new CDOIDObjectUUIDImpl(value);
+ }
+
+ /**
+ * @since 4.1
+ */
+ public static CDOID createUUID()
+ {
+ byte[] value = new byte[16];
+ UUIDGenerator.DEFAULT.generate(value);
+ return createUUID(value);
+ }
+
+ /**
+ * @since 4.1
+ */
+ public static String encodeUUID(byte[] bytes)
+ {
+ return UUIDGenerator.DEFAULT.encode(bytes);
+ }
+
+ /**
+ * @since 4.1
+ */
+ public static byte[] decodeUUID(String string)
+ {
+ return UUIDGenerator.DEFAULT.decode(string);
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static CDOIDExternal createExternal(String uri)
+ {
+ return new CDOIDExternalImpl(uri);
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static CDOIDAndVersion createIDAndVersion(CDOID id, int version)
+ {
+ return new CDOIDAndVersionImpl(id, version);
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static CDOIDAndVersion createIDAndVersion(CDOIDAndVersion source)
+ {
+ return createIDAndVersion(source.getID(), source.getVersion());
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static CDOIDAndBranch createIDAndBranch(CDOID id, CDOBranch branch)
+ {
+ return new CDOIDAndBranchImpl(id, branch);
+ }
+
+ /**
+ * Creates the correct implementation class for the passed {@link CDOID.ObjectType}.
+ *
+ * @param subType
+ * the subType for which to create an empty CDOID instance
+ * @return the instance of CDOIDObject which represents the subtype.
+ * @since 3.0
+ */
+ public static AbstractCDOID createCDOIDObject(CDOID.ObjectType subType)
+ {
+ if (subType == null)
+ {
+ throw new IllegalArgumentException("SubType may not be null");
+ }
+
+ InternalCDOIDObject id;
+ switch (subType)
+ {
+ case LONG:
+ id = new CDOIDObjectLongImpl();
+ break;
+
+ case STRING:
+ id = new CDOIDObjectStringImpl();
+ break;
+
+ case LONG_WITH_CLASSIFIER:
+ id = new CDOIDObjectLongWithClassifierImpl();
+ break;
+
+ case STRING_WITH_CLASSIFIER:
+ id = new CDOIDObjectStringWithClassifierImpl();
+ break;
+
+ case UUID:
+ id = new CDOIDObjectUUIDImpl();
+ break;
+
+ default:
+ throw new IllegalArgumentException("Subtype " + subType.name() + " not supported");
+ }
+
+ if (id.getSubType() != subType)
+ {
+ throw new IllegalStateException("Subtype of created id " + id + " is unequal (" + id.getSubType().name()
+ + ") to requested subtype " + subType.name());
+ }
+
+ return (AbstractCDOID)id;
+ }
+
+ /**
+ * Format of the uri fragment.
+ * <p>
+ * Non-legacy: <code><ID TYPE>/<CUSTOM STRING FROM OBJECT FACTORY></code>
+ * <p>
+ * Legacy: <code><ID TYPE>/<PACKAGE URI>/<CLASSIFIER ID>/<CUSTOM STRING FROM OBJECT FACTORY></code>
+ *
+ * @since 2.0
+ */
+ public static void write(StringBuilder builder, CDOID id)
+ {
+ if (id == null)
+ {
+ id = CDOID.NULL;
+ }
+
+ if (id instanceof InternalCDOIDObject)
+ {
+ ObjectType subType = ((InternalCDOIDObject)id).getSubType();
+ builder.append(subType.getID());
+ }
+ else
+ {
+ Type type = id.getType();
+ builder.append(type.getID());
+ }
+
+ builder.append(id.toURIFragment());
+ }
+
+ /**
+ * Format of the URI fragment.
+ * <p>
+ * Non-legacy: <code><ID TYPE>/<CUSTOM STRING FROM OBJECT FACTORY></code>
+ * <p>
+ * Legacy: <code><ID TYPE>/<PACKAGE URI>/<CLASSIFIER ID>/<CUSTOM STRING FROM OBJECT FACTORY></code>
+ *
+ * @since 3.0
+ */
+ public static CDOID read(String uriFragment)
+ {
+ char typeID = uriFragment.charAt(0);
+ Enum<?> literal = CDOID.Type.getLiteral(typeID);
+ if (literal == null)
+ {
+ throw new IllegalArgumentException("Unknown type ID: " + typeID);
+ }
+
+ String fragment = uriFragment.substring(1);
+ if (literal instanceof ObjectType)
+ {
+ return readCDOIDObject((ObjectType)literal, fragment);
+ }
+
+ Type type = (Type)literal;
+ switch (type)
+ {
+ case NULL:
+ return CDOID.NULL;
+
+ case TEMP_OBJECT:
+ return new CDOIDTempObjectImpl(Integer.valueOf(fragment));
+
+ case EXTERNAL_OBJECT:
+ return new CDOIDExternalImpl(fragment);
+
+ case EXTERNAL_TEMP_OBJECT:
+ return new CDOIDTempObjectExternalImpl(fragment);
+
+ case OBJECT:
+ {
+ // Normally this case should not occur (is an OBJECT subtype).
+ throw new IllegalArgumentException();
+ }
+
+ default:
+ throw new IllegalArgumentException(MessageFormat.format(Messages.getString("CDOIDUtil.5"), uriFragment)); //$NON-NLS-1$
+ }
+ }
+
+ private static CDOID readCDOIDObject(CDOID.ObjectType subType, String fragment)
+ {
+ AbstractCDOID id = createCDOIDObject(subType);
+ id.read(fragment);
+ return id;
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static boolean equals(CDOID id1, CDOID id2)
+ {
+ if (id1 == null)
+ {
+ id1 = CDOID.NULL;
+ }
+
+ if (id2 == null)
+ {
+ id2 = CDOID.NULL;
+ }
+
+ return ObjectUtil.equals(id1, id2);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOReference.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOReference.java index af7e8da1a8..a6af2693bc 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOReference.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOReference.java @@ -1,43 +1,43 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.id; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.util.FeatureMap; - -/** - * Represents a reference from one object to another object, possibly {@link CDOID} or CDOObject typed. - * - * @author Eike Stepper - * @since 4.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.has {@link org.eclipse.emf.ecore.EStructuralFeature} - */ -public interface CDOReference<OBJECT> -{ - public static final int NO_INDEX = Notification.NO_INDEX; - - public OBJECT getTargetObject(); - - public OBJECT getSourceObject(); - - /** - * Returns the source {@link EReference} or the source {@link EAttribute} if the source feature is a - * {@link FeatureMap}. - */ - public EStructuralFeature getSourceFeature(); - - public int getSourceIndex(); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.id;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.FeatureMap;
+
+/**
+ * Represents a reference from one object to another object, possibly {@link CDOID} or CDOObject typed.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.has {@link org.eclipse.emf.ecore.EStructuralFeature}
+ */
+public interface CDOReference<OBJECT>
+{
+ public static final int NO_INDEX = Notification.NO_INDEX;
+
+ public OBJECT getTargetObject();
+
+ public OBJECT getSourceObject();
+
+ /**
+ * Returns the source {@link EReference} or the source {@link EAttribute} if the source feature is a
+ * {@link FeatureMap}.
+ */
+ public EStructuralFeature getSourceFeature();
+
+ public int getSourceIndex();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOWithID.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOWithID.java index 3815258e29..1868346cdf 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOWithID.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOWithID.java @@ -1,5 +1,5 @@ /*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 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
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/package-info.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/package-info.java index a642658e9c..67bb822de0 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/package-info.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/package-info.java @@ -1,5 +1,5 @@ /*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 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
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOBlob.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOBlob.java index 260144976f..c3c2bb78f1 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOBlob.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOBlob.java @@ -1,60 +1,60 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.lob; - -import org.eclipse.emf.cdo.spi.common.CDOLobStoreImpl; - -import org.eclipse.net4j.util.io.ExtendedDataInput; - -import java.io.IOException; -import java.io.InputStream; - -/** - * A identifiable binary large object with streaming support. - * - * @author Eike Stepper - * @since 4.0 - * @apiviz.landmark - */ -public final class CDOBlob extends CDOLob<InputStream> -{ - public CDOBlob(InputStream contents) throws IOException - { - super(contents, CDOLobStoreImpl.INSTANCE); - } - - public CDOBlob(InputStream contents, CDOLobStore store) throws IOException - { - super(contents, store); - } - - CDOBlob(byte[] id, long size) - { - super(id, size); - } - - CDOBlob(ExtendedDataInput in) throws IOException - { - super(in); - } - - @Override - public InputStream getContents() throws IOException - { - return getStore().getBinary(this); - } - - @Override - protected CDOLobInfo put(InputStream contents) throws IOException - { - return getStore().putBinary(contents); - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.lob;
+
+import org.eclipse.emf.cdo.spi.common.CDOLobStoreImpl;
+
+import org.eclipse.net4j.util.io.ExtendedDataInput;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * A identifiable binary large object with streaming support.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ * @apiviz.landmark
+ */
+public final class CDOBlob extends CDOLob<InputStream>
+{
+ public CDOBlob(InputStream contents) throws IOException
+ {
+ super(contents, CDOLobStoreImpl.INSTANCE);
+ }
+
+ public CDOBlob(InputStream contents, CDOLobStore store) throws IOException
+ {
+ super(contents, store);
+ }
+
+ CDOBlob(byte[] id, long size)
+ {
+ super(id, size);
+ }
+
+ CDOBlob(ExtendedDataInput in) throws IOException
+ {
+ super(in);
+ }
+
+ @Override
+ public InputStream getContents() throws IOException
+ {
+ return getStore().getBinary(this);
+ }
+
+ @Override
+ protected CDOLobInfo put(InputStream contents) throws IOException
+ {
+ return getStore().putBinary(contents);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOClob.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOClob.java index 630fa70930..8d195a4605 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOClob.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOClob.java @@ -1,60 +1,60 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.lob; - -import org.eclipse.emf.cdo.spi.common.CDOLobStoreImpl; - -import org.eclipse.net4j.util.io.ExtendedDataInput; - -import java.io.IOException; -import java.io.Reader; - -/** - * A identifiable character large object with streaming support. - * - * @author Eike Stepper - * @since 4.0 - * @apiviz.landmark - */ -public final class CDOClob extends CDOLob<Reader> -{ - public CDOClob(Reader contents) throws IOException - { - super(contents, CDOLobStoreImpl.INSTANCE); - } - - public CDOClob(Reader contents, CDOLobStore store) throws IOException - { - super(contents, store); - } - - CDOClob(byte[] id, long size) - { - super(id, size); - } - - CDOClob(ExtendedDataInput in) throws IOException - { - super(in); - } - - @Override - public Reader getContents() throws IOException - { - return getStore().getCharacter(this); - } - - @Override - protected CDOLobInfo put(Reader contents) throws IOException - { - return getStore().putCharacter(contents); - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.lob;
+
+import org.eclipse.emf.cdo.spi.common.CDOLobStoreImpl;
+
+import org.eclipse.net4j.util.io.ExtendedDataInput;
+
+import java.io.IOException;
+import java.io.Reader;
+
+/**
+ * A identifiable character large object with streaming support.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ * @apiviz.landmark
+ */
+public final class CDOClob extends CDOLob<Reader>
+{
+ public CDOClob(Reader contents) throws IOException
+ {
+ super(contents, CDOLobStoreImpl.INSTANCE);
+ }
+
+ public CDOClob(Reader contents, CDOLobStore store) throws IOException
+ {
+ super(contents, store);
+ }
+
+ CDOClob(byte[] id, long size)
+ {
+ super(id, size);
+ }
+
+ CDOClob(ExtendedDataInput in) throws IOException
+ {
+ super(in);
+ }
+
+ @Override
+ public Reader getContents() throws IOException
+ {
+ return getStore().getCharacter(this);
+ }
+
+ @Override
+ protected CDOLobInfo put(Reader contents) throws IOException
+ {
+ return getStore().putCharacter(contents);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOLob.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOLob.java index 74bdc1d9f5..e1621d76ef 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOLob.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOLob.java @@ -1,69 +1,69 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.lob; - -import org.eclipse.net4j.util.io.ExtendedDataInput; -import org.eclipse.net4j.util.io.ExtendedDataOutput; - -import java.io.IOException; - -/** - * A identifiable large object with streaming support. - * - * @author Eike Stepper - * @since 4.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public abstract class CDOLob<IO> extends CDOLobInfo -{ - private CDOLobStore store; - - CDOLob(byte[] id, long size) - { - this.id = id; - this.size = size; - } - - CDOLob(IO contents, CDOLobStore store) throws IOException - { - this.store = store; - CDOLobInfo info = put(contents); - id = info.getID(); - size = info.getSize(); - } - - CDOLob(ExtendedDataInput in) throws IOException - { - id = in.readByteArray(); - size = in.readLong(); - } - - final void write(ExtendedDataOutput out) throws IOException - { - out.writeByteArray(id); - out.writeLong(size); - } - - final void setStore(CDOLobStore store) - { - this.store = store; - } - - public final CDOLobStore getStore() - { - return store; - } - - public abstract IO getContents() throws IOException; - - protected abstract CDOLobInfo put(IO contents) throws IOException; -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.lob;
+
+import org.eclipse.net4j.util.io.ExtendedDataInput;
+import org.eclipse.net4j.util.io.ExtendedDataOutput;
+
+import java.io.IOException;
+
+/**
+ * A identifiable large object with streaming support.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public abstract class CDOLob<IO> extends CDOLobInfo
+{
+ private CDOLobStore store;
+
+ CDOLob(byte[] id, long size)
+ {
+ this.id = id;
+ this.size = size;
+ }
+
+ CDOLob(IO contents, CDOLobStore store) throws IOException
+ {
+ this.store = store;
+ CDOLobInfo info = put(contents);
+ id = info.getID();
+ size = info.getSize();
+ }
+
+ CDOLob(ExtendedDataInput in) throws IOException
+ {
+ id = in.readByteArray();
+ size = in.readLong();
+ }
+
+ final void write(ExtendedDataOutput out) throws IOException
+ {
+ out.writeByteArray(id);
+ out.writeLong(size);
+ }
+
+ final void setStore(CDOLobStore store)
+ {
+ this.store = store;
+ }
+
+ public final CDOLobStore getStore()
+ {
+ return store;
+ }
+
+ public abstract IO getContents() throws IOException;
+
+ protected abstract CDOLobInfo put(IO contents) throws IOException;
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOLobHandler.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOLobHandler.java index c04f0264f0..0262df1275 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOLobHandler.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOLobHandler.java @@ -1,41 +1,41 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.lob; - -import java.io.IOException; -import java.io.OutputStream; -import java.io.Writer; - -/** - * A callback interface for handling large objects. - * - * @author Eike Stepper - * @since 4.0 - * @apiviz.uses {@link CDOLob} - - handles - */ -public interface CDOLobHandler -{ - /** - * A callback method for handling a {@link CDOBlob binary large object}. The {@link CDOLob#getID() ID} and - * {@link CDOLob#getSize() size} of the blob are passed by the caller. The implementor may return a - * {@link OutputStream stream} that the blob content will be written to by the caller of this method, or - * <code>null</code> to indicate that the content is not needed. - */ - public OutputStream handleBlob(byte[] id, long size) throws IOException; - - /** - * A callback method for handling a {@link CDOClob character large object}. The {@link CDOLob#getID() ID} and - * {@link CDOLob#getSize() size} of the blob are passed by the caller. The implementor may return a {@link Writer - * writer} that the blob content will be written to by the caller of this method, or <code>null</code> to indicate - * that the content is not needed. - */ - public Writer handleClob(byte[] id, long size) throws IOException; -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.lob;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.Writer;
+
+/**
+ * A callback interface for handling large objects.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ * @apiviz.uses {@link CDOLob} - - handles
+ */
+public interface CDOLobHandler
+{
+ /**
+ * A callback method for handling a {@link CDOBlob binary large object}. The {@link CDOLob#getID() ID} and
+ * {@link CDOLob#getSize() size} of the blob are passed by the caller. The implementor may return a
+ * {@link OutputStream stream} that the blob content will be written to by the caller of this method, or
+ * <code>null</code> to indicate that the content is not needed.
+ */
+ public OutputStream handleBlob(byte[] id, long size) throws IOException;
+
+ /**
+ * A callback method for handling a {@link CDOClob character large object}. The {@link CDOLob#getID() ID} and
+ * {@link CDOLob#getSize() size} of the blob are passed by the caller. The implementor may return a {@link Writer
+ * writer} that the blob content will be written to by the caller of this method, or <code>null</code> to indicate
+ * that the content is not needed.
+ */
+ public Writer handleClob(byte[] id, long size) throws IOException;
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOLobInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOLobInfo.java index 33204e7a24..05a4319be0 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOLobInfo.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOLobInfo.java @@ -1,59 +1,59 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.lob; - -import org.eclipse.net4j.util.HexUtil; - -import java.text.MessageFormat; - -/** - * Encapsulates {@link #getID() ID} and {@link #getSize() size} of a {@link CDOLob large object}. - * - * @author Eike Stepper - * @since 4.0 - * @noextend This interface is not intended to be extended by clients. - * @noinstantiate This class is not intended to be instantiated by clients. - */ -public class CDOLobInfo -{ - byte[] id; - - long size; - - CDOLobInfo() - { - } - - public CDOLobInfo(byte[] id, long size) - { - this.id = id; - this.size = size; - } - - /** - * The identifier of this large object. A SHA-1 digest of the content of this large object. - */ - public final byte[] getID() - { - return id; - } - - public final long getSize() - { - return size; - } - - @Override - public String toString() - { - return MessageFormat.format("{0}[id={1}, size={2}]", getClass().getSimpleName(), HexUtil.bytesToHex(id), size); - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.lob;
+
+import org.eclipse.net4j.util.HexUtil;
+
+import java.text.MessageFormat;
+
+/**
+ * Encapsulates {@link #getID() ID} and {@link #getSize() size} of a {@link CDOLob large object}.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noinstantiate This class is not intended to be instantiated by clients.
+ */
+public class CDOLobInfo
+{
+ byte[] id;
+
+ long size;
+
+ CDOLobInfo()
+ {
+ }
+
+ public CDOLobInfo(byte[] id, long size)
+ {
+ this.id = id;
+ this.size = size;
+ }
+
+ /**
+ * The identifier of this large object. A SHA-1 digest of the content of this large object.
+ */
+ public final byte[] getID()
+ {
+ return id;
+ }
+
+ public final long getSize()
+ {
+ return size;
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("{0}[id={1}, size={2}]", getClass().getSimpleName(), HexUtil.bytesToHex(id), size);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOLobStore.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOLobStore.java index 10fbde1844..66d3a421a8 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOLobStore.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOLobStore.java @@ -1,78 +1,78 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.lob; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; - -/** - * Stores and loads {@link CDOLob large objects}. - * - * @author Eike Stepper - * @since 4.0 - * @apiviz.composedOf {@link CDOLob} - */ -public interface CDOLobStore -{ - public File getBinaryFile(byte[] id); - - public InputStream getBinary(CDOLobInfo info) throws IOException; - - public CDOLobInfo putBinary(InputStream contents) throws IOException; - - public File getCharacterFile(byte[] id); - - public Reader getCharacter(CDOLobInfo info) throws IOException; - - public CDOLobInfo putCharacter(Reader contents) throws IOException; - - /** - * An abstract {@link CDOLobStore large object store} that delegates all method calls to a delegate. - * - * @author Eike Stepper - */ - public static abstract class Delegating implements CDOLobStore - { - public File getBinaryFile(byte[] id) - { - return getDelegate().getBinaryFile(id); - } - - public InputStream getBinary(CDOLobInfo info) throws IOException - { - return getDelegate().getBinary(info); - } - - public CDOLobInfo putBinary(InputStream contents) throws IOException - { - return getDelegate().putBinary(contents); - } - - public File getCharacterFile(byte[] id) - { - return getDelegate().getCharacterFile(id); - } - - public Reader getCharacter(CDOLobInfo info) throws IOException - { - return getDelegate().getCharacter(info); - } - - public CDOLobInfo putCharacter(Reader contents) throws IOException - { - return getDelegate().putCharacter(contents); - } - - protected abstract CDOLobStore getDelegate(); - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.lob;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+
+/**
+ * Stores and loads {@link CDOLob large objects}.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ * @apiviz.composedOf {@link CDOLob}
+ */
+public interface CDOLobStore
+{
+ public File getBinaryFile(byte[] id);
+
+ public InputStream getBinary(CDOLobInfo info) throws IOException;
+
+ public CDOLobInfo putBinary(InputStream contents) throws IOException;
+
+ public File getCharacterFile(byte[] id);
+
+ public Reader getCharacter(CDOLobInfo info) throws IOException;
+
+ public CDOLobInfo putCharacter(Reader contents) throws IOException;
+
+ /**
+ * An abstract {@link CDOLobStore large object store} that delegates all method calls to a delegate.
+ *
+ * @author Eike Stepper
+ */
+ public static abstract class Delegating implements CDOLobStore
+ {
+ public File getBinaryFile(byte[] id)
+ {
+ return getDelegate().getBinaryFile(id);
+ }
+
+ public InputStream getBinary(CDOLobInfo info) throws IOException
+ {
+ return getDelegate().getBinary(info);
+ }
+
+ public CDOLobInfo putBinary(InputStream contents) throws IOException
+ {
+ return getDelegate().putBinary(contents);
+ }
+
+ public File getCharacterFile(byte[] id)
+ {
+ return getDelegate().getCharacterFile(id);
+ }
+
+ public Reader getCharacter(CDOLobInfo info) throws IOException
+ {
+ return getDelegate().getCharacter(info);
+ }
+
+ public CDOLobInfo putCharacter(Reader contents) throws IOException
+ {
+ return getDelegate().putCharacter(contents);
+ }
+
+ protected abstract CDOLobStore getDelegate();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOLobUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOLobUtil.java index b164424bd6..132c763fc8 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOLobUtil.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/CDOLobUtil.java @@ -1,59 +1,59 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.lob; - -import org.eclipse.net4j.util.io.ExtendedDataInput; -import org.eclipse.net4j.util.io.ExtendedDataOutput; - -import java.io.IOException; - -/** - * Some useful helpers for dealing with {@link CDOLob large objects}. - * - * @author Eike Stepper - * @since 4.0 - */ -public final class CDOLobUtil -{ - private CDOLobUtil() - { - } - - public static CDOBlob readBlob(ExtendedDataInput in) throws IOException - { - return new CDOBlob(in); - } - - public static CDOClob readClob(ExtendedDataInput in) throws IOException - { - return new CDOClob(in); - } - - public static void write(ExtendedDataOutput out, CDOLob<?> lob) throws IOException - { - lob.write(out); - } - - public static CDOBlob createBlob(byte[] id, long size) - { - return new CDOBlob(id, size); - } - - public static CDOClob createClob(byte[] id, long size) - { - return new CDOClob(id, size); - } - - public static void setStore(CDOLobStore store, CDOLob<?> lob) throws IOException - { - lob.setStore(store); - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.lob;
+
+import org.eclipse.net4j.util.io.ExtendedDataInput;
+import org.eclipse.net4j.util.io.ExtendedDataOutput;
+
+import java.io.IOException;
+
+/**
+ * Some useful helpers for dealing with {@link CDOLob large objects}.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ */
+public final class CDOLobUtil
+{
+ private CDOLobUtil()
+ {
+ }
+
+ public static CDOBlob readBlob(ExtendedDataInput in) throws IOException
+ {
+ return new CDOBlob(in);
+ }
+
+ public static CDOClob readClob(ExtendedDataInput in) throws IOException
+ {
+ return new CDOClob(in);
+ }
+
+ public static void write(ExtendedDataOutput out, CDOLob<?> lob) throws IOException
+ {
+ lob.write(out);
+ }
+
+ public static CDOBlob createBlob(byte[] id, long size)
+ {
+ return new CDOBlob(id, size);
+ }
+
+ public static CDOClob createClob(byte[] id, long size)
+ {
+ return new CDOClob(id, size);
+ }
+
+ public static void setStore(CDOLobStore store, CDOLob<?> lob) throws IOException
+ {
+ lob.setStore(store);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/package-info.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/package-info.java index c5ba461dad..6d80513cc1 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/package-info.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lob/package-info.java @@ -1,5 +1,5 @@ /*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 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
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockChangeInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockChangeInfo.java index 7e73384b67..117f8bb176 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockChangeInfo.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockChangeInfo.java @@ -1,79 +1,79 @@ -/* - * Copyright (c) 2004 - 2011 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: - * Caspar De Groot - initial API and implementation - */ -package org.eclipse.emf.cdo.common.lock; - -import org.eclipse.emf.cdo.common.branch.CDOBranch; -import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; - -import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType; - -/** - * Represents a change in the lock state of a set of objects. Instances are meant to be sent from the server to the - * client for the purpose of notifying the latter. - * - * @author Caspar De Groot - * @since 4.1 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.has {@link CDOLockOwner} - * @apiviz.has {@link CDOLockChangeInfo.Operation} - * @apiviz.has {@link org.eclipse.net4j.util.concurrent.IRWLockManager.LockType} - * @apiviz.composedOf {@link CDOLockState} - */ -public interface CDOLockChangeInfo extends CDOBranchPoint -{ - /** - * @return <code>true</code> if this instance signals that all {@link CDOLockState lockstates} must be invalidated, - * <code>false</code> otherwise - */ - public boolean isInvalidateAll(); - - /** - * @return The branch at which the lock changes took place, same as <code>getView().getBranch()</code>. - */ - public CDOBranch getBranch(); - - /** - * @return The repository time at which the lock changes took place. This is only an informal indication; no formal - * relation (e.g. an ordering) with commit timestamps is guaranteed. - */ - public long getTimeStamp(); - - /** - * @return The view, represented as a {@link CDOLockOwner}, that authored the lock changes. - */ - public CDOLockOwner getLockOwner(); - - /** - * @return The new lock states of the objects that were affected by the change - */ - public CDOLockState[] getLockStates(); - - /** - * @return the type of lock operation that caused the lock changes - */ - public Operation getOperation(); - - /** - * @return the type of locks that were affected by the lock operation - */ - public LockType getLockType(); - - /** - * Enumerates the possible locking operations. - * - * @author Caspar De Groot - */ - public enum Operation - { - LOCK, UNLOCK - } -} +/*
+ * Copyright (c) 2004 - 2012 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:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.common.lock;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+
+import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
+
+/**
+ * Represents a change in the lock state of a set of objects. Instances are meant to be sent from the server to the
+ * client for the purpose of notifying the latter.
+ *
+ * @author Caspar De Groot
+ * @since 4.1
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.has {@link CDOLockOwner}
+ * @apiviz.has {@link CDOLockChangeInfo.Operation}
+ * @apiviz.has {@link org.eclipse.net4j.util.concurrent.IRWLockManager.LockType}
+ * @apiviz.composedOf {@link CDOLockState}
+ */
+public interface CDOLockChangeInfo extends CDOBranchPoint
+{
+ /**
+ * @return <code>true</code> if this instance signals that all {@link CDOLockState lockstates} must be invalidated,
+ * <code>false</code> otherwise
+ */
+ public boolean isInvalidateAll();
+
+ /**
+ * @return The branch at which the lock changes took place, same as <code>getView().getBranch()</code>.
+ */
+ public CDOBranch getBranch();
+
+ /**
+ * @return The repository time at which the lock changes took place. This is only an informal indication; no formal
+ * relation (e.g. an ordering) with commit timestamps is guaranteed.
+ */
+ public long getTimeStamp();
+
+ /**
+ * @return The view, represented as a {@link CDOLockOwner}, that authored the lock changes.
+ */
+ public CDOLockOwner getLockOwner();
+
+ /**
+ * @return The new lock states of the objects that were affected by the change
+ */
+ public CDOLockState[] getLockStates();
+
+ /**
+ * @return the type of lock operation that caused the lock changes
+ */
+ public Operation getOperation();
+
+ /**
+ * @return the type of locks that were affected by the lock operation
+ */
+ public LockType getLockType();
+
+ /**
+ * Enumerates the possible locking operations.
+ *
+ * @author Caspar De Groot
+ */
+ public enum Operation
+ {
+ LOCK, UNLOCK
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockChangeInfoHandler.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockChangeInfoHandler.java index e84ba6b29c..e2a0047760 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockChangeInfoHandler.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockChangeInfoHandler.java @@ -1,23 +1,23 @@ -/* - * Copyright (c) 2004 - 2011 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: - * Caspar De Groot - initial API and implementation - */ -package org.eclipse.emf.cdo.common.lock; - -/** - * A call-back interface that indicates the ability to <i>handle</i> {@link CDOLockChangeInfo lock-change infos} that - * are passed from other entities. - * - * @author Caspar De Groot - * @since 4.1 - */ -public interface CDOLockChangeInfoHandler -{ - public void handleLockChangeInfo(CDOLockChangeInfo lockChangeInfo); -} +/*
+ * Copyright (c) 2004 - 2012 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:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.common.lock;
+
+/**
+ * A call-back interface that indicates the ability to <i>handle</i> {@link CDOLockChangeInfo lock-change infos} that
+ * are passed from other entities.
+ *
+ * @author Caspar De Groot
+ * @since 4.1
+ */
+public interface CDOLockChangeInfoHandler
+{
+ public void handleLockChangeInfo(CDOLockChangeInfo lockChangeInfo);
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockOwner.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockOwner.java index e629a6dc95..fda27b77a8 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockOwner.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockOwner.java @@ -1,37 +1,37 @@ -/* - * Copyright (c) 2004 - 2011 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: - * Caspar De Groot - initial API and implementation - */ -package org.eclipse.emf.cdo.common.lock; - -/** - * A client-side representation of a view owning locks. - * <p> - * - * @author Caspar De Groot - * @since 4.1 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDOLockOwner -{ - /** - * @return the ID identifying the session that owns the view - */ - public int getSessionID(); - - /** - * @return the ID identifying the view within the session - */ - public int getViewID(); - - public String getDurableLockingID(); - - public boolean isDurableView(); -} +/*
+ * Copyright (c) 2004 - 2012 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:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.common.lock;
+
+/**
+ * A client-side representation of a view owning locks.
+ * <p>
+ *
+ * @author Caspar De Groot
+ * @since 4.1
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDOLockOwner
+{
+ /**
+ * @return the ID identifying the session that owns the view
+ */
+ public int getSessionID();
+
+ /**
+ * @return the ID identifying the view within the session
+ */
+ public int getViewID();
+
+ public String getDurableLockingID();
+
+ public boolean isDurableView();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockState.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockState.java index 242c1d208e..78f423c7c4 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockState.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockState.java @@ -1,61 +1,61 @@ -/* - * Copyright (c) 2004 - 2011 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: - * Caspar De Groot - initial API and implementation - */ -package org.eclipse.emf.cdo.common.lock; - -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch; - -import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType; - -import java.util.Set; - -/** - * A client-side representation of <i>all</i> the locks on a single CDOObject. - * <p> - * As an individual lock is always owned by view, which in turn is owned by a session, the methods on this interface - * return instances of {@link CDOLockOwner} which carry that information. - * <p> - * - * @author Caspar De Groot - * @since 4.1 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.landmark - * @apiviz.has {@link java.lang.Object} oneway - - lockedObject - * @apiviz.owns {@link CDOLockOwner} - - readLockOwners - * @apiviz.has {@link CDOLockOwner} oneway - - writeLockOwner - * @apiviz.has {@link CDOLockOwner} oneway - - writeOptionOwner - */ -public interface CDOLockState -{ - /** - * Gets a unique identifier for the object that is locked; typically a {@link CDOID} or a {@link CDOIDAndBranch}, - * depending on whether branching support is enabled or not - * - * @return the identifier - */ - public Object getLockedObject(); - - /** - * If the 'others' argument is <code>false</code>, this method returns <code>true</code> if this lock is currently - * held by the <i>requesting</i> CDOView, <code>false</code> otherwise. - * <p> - * If the 'others' argument is <code>true</code>, this method returns <code>true</code> if this lock is currently held - * by <i>another</i> view (i.e. any view different from the requesting one), <code>false</code> otherwise. - */ - public boolean isLocked(LockType lockType, CDOLockOwner lockOwner, boolean others); - - public Set<CDOLockOwner> getReadLockOwners(); - - public CDOLockOwner getWriteLockOwner(); - - public CDOLockOwner getWriteOptionOwner(); -} +/*
+ * Copyright (c) 2004 - 2012 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:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.common.lock;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
+
+import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
+
+import java.util.Set;
+
+/**
+ * A client-side representation of <i>all</i> the locks on a single CDOObject.
+ * <p>
+ * As an individual lock is always owned by view, which in turn is owned by a session, the methods on this interface
+ * return instances of {@link CDOLockOwner} which carry that information.
+ * <p>
+ *
+ * @author Caspar De Groot
+ * @since 4.1
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.landmark
+ * @apiviz.has {@link java.lang.Object} oneway - - lockedObject
+ * @apiviz.owns {@link CDOLockOwner} - - readLockOwners
+ * @apiviz.has {@link CDOLockOwner} oneway - - writeLockOwner
+ * @apiviz.has {@link CDOLockOwner} oneway - - writeOptionOwner
+ */
+public interface CDOLockState
+{
+ /**
+ * Gets a unique identifier for the object that is locked; typically a {@link CDOID} or a {@link CDOIDAndBranch},
+ * depending on whether branching support is enabled or not
+ *
+ * @return the identifier
+ */
+ public Object getLockedObject();
+
+ /**
+ * If the 'others' argument is <code>false</code>, this method returns <code>true</code> if this lock is currently
+ * held by the <i>requesting</i> CDOView, <code>false</code> otherwise.
+ * <p>
+ * If the 'others' argument is <code>true</code>, this method returns <code>true</code> if this lock is currently held
+ * by <i>another</i> view (i.e. any view different from the requesting one), <code>false</code> otherwise.
+ */
+ public boolean isLocked(LockType lockType, CDOLockOwner lockOwner, boolean others);
+
+ public Set<CDOLockOwner> getReadLockOwners();
+
+ public CDOLockOwner getWriteLockOwner();
+
+ public CDOLockOwner getWriteOptionOwner();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockUtil.java index 2dbfde6b1f..03ef04127e 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockUtil.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/CDOLockUtil.java @@ -1,163 +1,163 @@ -/* - * Copyright (c) 2004 - 2011 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: - * Caspar De Groot - initial API and implementation - */ -package org.eclipse.emf.cdo.common.lock; - -import org.eclipse.emf.cdo.common.CDOCommonSession; -import org.eclipse.emf.cdo.common.CDOCommonView; -import org.eclipse.emf.cdo.common.branch.CDOBranch; -import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo.Operation; -import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea; -import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockGrade; -import org.eclipse.emf.cdo.internal.common.lock.CDOLockAreaImpl; -import org.eclipse.emf.cdo.internal.common.lock.CDOLockChangeInfoImpl; -import org.eclipse.emf.cdo.internal.common.lock.CDOLockOwnerImpl; -import org.eclipse.emf.cdo.internal.common.lock.CDOLockStateImpl; -import org.eclipse.emf.cdo.spi.common.lock.InternalCDOLockState; - -import org.eclipse.net4j.util.CheckUtil; -import org.eclipse.net4j.util.HexUtil; -import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType; -import org.eclipse.net4j.util.concurrent.RWOLockManager.LockState; - -import java.util.Map; -import java.util.Random; - -/** - * Various static methods that may help with classes related to CDO locks. - * - * @author Caspar De Groot - * @since 4.1 - */ -public final class CDOLockUtil -{ - private static final int DURABLE_SESSION_ID = 0; - - private static final int DURABLE_VIEW_ID = 0; - - private CDOLockUtil() - { - } - - public static CDOLockState copyLockState(CDOLockState lockState) - { - CheckUtil.checkArg(lockState instanceof CDOLockStateImpl, "lockState instanceof CDOLockStateImpl"); - return ((CDOLockStateImpl)lockState).copy(); - } - - public static CDOLockState createLockState(Object target) - { - return new CDOLockStateImpl(target); - } - - public static CDOLockState createLockState(LockState<Object, ? extends CDOCommonView> lockState) - { - CheckUtil.checkArg(lockState, "lockState"); - InternalCDOLockState cdoLockState = new CDOLockStateImpl(lockState.getLockedObject()); - - for (CDOCommonView view : lockState.getReadLockOwners()) - { - String durableLockingID = view.getDurableLockingID(); - int sessionID, viewID; - CDOCommonSession session = view.getSession(); - boolean isDurableView = session == null; - if (isDurableView) - { - sessionID = DURABLE_SESSION_ID; - viewID = DURABLE_VIEW_ID; - } - else - { - sessionID = session.getSessionID(); - viewID = view.getViewID(); - } - - CDOLockOwner owner = new CDOLockOwnerImpl(sessionID, viewID, durableLockingID, isDurableView); - cdoLockState.addReadLockOwner(owner); - } - - CDOCommonView writeLockOwner = lockState.getWriteLockOwner(); - if (writeLockOwner != null) - { - CDOLockOwner owner = createLockOwner(writeLockOwner); - cdoLockState.setWriteLockOwner(owner); - } - - CDOCommonView writeOptionOwner = lockState.getWriteOptionOwner(); - if (writeOptionOwner != null) - { - CDOLockOwner owner = createLockOwner(writeOptionOwner); - cdoLockState.setWriteOptionOwner(owner); - } - - return cdoLockState; - } - - public static CDOLockOwner createLockOwner(CDOCommonView view) - { - CDOCommonSession session = view.getSession(); - String durableLockingID = view.getDurableLockingID(); - if (session != null) - { - int sessionID = session.getSessionID(); - int viewID = view.getViewID(); - return new CDOLockOwnerImpl(sessionID, viewID, durableLockingID, false); - } - - CheckUtil.checkNull(durableLockingID, "durableLockingID"); - return new CDOLockOwnerImpl(DURABLE_SESSION_ID, DURABLE_VIEW_ID, durableLockingID, true); - } - - public static CDOLockChangeInfo createLockChangeInfo(long timestamp, CDOLockOwner lockOwner, CDOBranch branch, - Operation op, LockType lockType, CDOLockState[] cdoLockStates) - { - return new CDOLockChangeInfoImpl(branch.getPoint(timestamp), lockOwner, cdoLockStates, op, lockType); - } - - public static CDOLockChangeInfo createLockChangeInfo() - { - return new CDOLockChangeInfoImpl(); - } - - public static CDOLockChangeInfo createLockChangeInfo(long timestamp, CDOCommonView view, CDOBranch viewedBranch, - Operation op, LockType lockType, CDOLockState[] cdoLockStates) - { - CDOLockOwner lockOwner = createLockOwner(view); - return createLockChangeInfo(timestamp, lockOwner, viewedBranch, op, lockType, cdoLockStates); - } - - public static LockArea createLockArea(String durableLockingID, String userID, CDOBranchPoint branchPoint, - boolean readOnly, Map<CDOID, LockGrade> locks) - { - return new CDOLockAreaImpl(durableLockingID, userID, branchPoint, readOnly, locks); - } - - public static LockArea createLockArea(String durableLockingID) - { - return new CDOLockAreaImpl(durableLockingID); - } - - public static String createDurableLockingID() - { - return createDurableLockingID(LockArea.DEFAULT_DURABLE_LOCKING_ID_BYTES); - } - - public static String createDurableLockingID(int bytes) - { - byte[] buffer = new byte[bytes]; - - Random random = new Random(System.currentTimeMillis()); - random.nextBytes(buffer); - - return HexUtil.bytesToHex(buffer); - } -} +/*
+ * Copyright (c) 2004 - 2012 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:
+ * Caspar De Groot - initial API and implementation
+ */
+package org.eclipse.emf.cdo.common.lock;
+
+import org.eclipse.emf.cdo.common.CDOCommonSession;
+import org.eclipse.emf.cdo.common.CDOCommonView;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo.Operation;
+import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea;
+import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockGrade;
+import org.eclipse.emf.cdo.internal.common.lock.CDOLockAreaImpl;
+import org.eclipse.emf.cdo.internal.common.lock.CDOLockChangeInfoImpl;
+import org.eclipse.emf.cdo.internal.common.lock.CDOLockOwnerImpl;
+import org.eclipse.emf.cdo.internal.common.lock.CDOLockStateImpl;
+import org.eclipse.emf.cdo.spi.common.lock.InternalCDOLockState;
+
+import org.eclipse.net4j.util.CheckUtil;
+import org.eclipse.net4j.util.HexUtil;
+import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
+import org.eclipse.net4j.util.concurrent.RWOLockManager.LockState;
+
+import java.util.Map;
+import java.util.Random;
+
+/**
+ * Various static methods that may help with classes related to CDO locks.
+ *
+ * @author Caspar De Groot
+ * @since 4.1
+ */
+public final class CDOLockUtil
+{
+ private static final int DURABLE_SESSION_ID = 0;
+
+ private static final int DURABLE_VIEW_ID = 0;
+
+ private CDOLockUtil()
+ {
+ }
+
+ public static CDOLockState copyLockState(CDOLockState lockState)
+ {
+ CheckUtil.checkArg(lockState instanceof CDOLockStateImpl, "lockState instanceof CDOLockStateImpl");
+ return ((CDOLockStateImpl)lockState).copy();
+ }
+
+ public static CDOLockState createLockState(Object target)
+ {
+ return new CDOLockStateImpl(target);
+ }
+
+ public static CDOLockState createLockState(LockState<Object, ? extends CDOCommonView> lockState)
+ {
+ CheckUtil.checkArg(lockState, "lockState");
+ InternalCDOLockState cdoLockState = new CDOLockStateImpl(lockState.getLockedObject());
+
+ for (CDOCommonView view : lockState.getReadLockOwners())
+ {
+ String durableLockingID = view.getDurableLockingID();
+ int sessionID, viewID;
+ CDOCommonSession session = view.getSession();
+ boolean isDurableView = session == null;
+ if (isDurableView)
+ {
+ sessionID = DURABLE_SESSION_ID;
+ viewID = DURABLE_VIEW_ID;
+ }
+ else
+ {
+ sessionID = session.getSessionID();
+ viewID = view.getViewID();
+ }
+
+ CDOLockOwner owner = new CDOLockOwnerImpl(sessionID, viewID, durableLockingID, isDurableView);
+ cdoLockState.addReadLockOwner(owner);
+ }
+
+ CDOCommonView writeLockOwner = lockState.getWriteLockOwner();
+ if (writeLockOwner != null)
+ {
+ CDOLockOwner owner = createLockOwner(writeLockOwner);
+ cdoLockState.setWriteLockOwner(owner);
+ }
+
+ CDOCommonView writeOptionOwner = lockState.getWriteOptionOwner();
+ if (writeOptionOwner != null)
+ {
+ CDOLockOwner owner = createLockOwner(writeOptionOwner);
+ cdoLockState.setWriteOptionOwner(owner);
+ }
+
+ return cdoLockState;
+ }
+
+ public static CDOLockOwner createLockOwner(CDOCommonView view)
+ {
+ CDOCommonSession session = view.getSession();
+ String durableLockingID = view.getDurableLockingID();
+ if (session != null)
+ {
+ int sessionID = session.getSessionID();
+ int viewID = view.getViewID();
+ return new CDOLockOwnerImpl(sessionID, viewID, durableLockingID, false);
+ }
+
+ CheckUtil.checkNull(durableLockingID, "durableLockingID");
+ return new CDOLockOwnerImpl(DURABLE_SESSION_ID, DURABLE_VIEW_ID, durableLockingID, true);
+ }
+
+ public static CDOLockChangeInfo createLockChangeInfo(long timestamp, CDOLockOwner lockOwner, CDOBranch branch,
+ Operation op, LockType lockType, CDOLockState[] cdoLockStates)
+ {
+ return new CDOLockChangeInfoImpl(branch.getPoint(timestamp), lockOwner, cdoLockStates, op, lockType);
+ }
+
+ public static CDOLockChangeInfo createLockChangeInfo()
+ {
+ return new CDOLockChangeInfoImpl();
+ }
+
+ public static CDOLockChangeInfo createLockChangeInfo(long timestamp, CDOCommonView view, CDOBranch viewedBranch,
+ Operation op, LockType lockType, CDOLockState[] cdoLockStates)
+ {
+ CDOLockOwner lockOwner = createLockOwner(view);
+ return createLockChangeInfo(timestamp, lockOwner, viewedBranch, op, lockType, cdoLockStates);
+ }
+
+ public static LockArea createLockArea(String durableLockingID, String userID, CDOBranchPoint branchPoint,
+ boolean readOnly, Map<CDOID, LockGrade> locks)
+ {
+ return new CDOLockAreaImpl(durableLockingID, userID, branchPoint, readOnly, locks);
+ }
+
+ public static LockArea createLockArea(String durableLockingID)
+ {
+ return new CDOLockAreaImpl(durableLockingID);
+ }
+
+ public static String createDurableLockingID()
+ {
+ return createDurableLockingID(LockArea.DEFAULT_DURABLE_LOCKING_ID_BYTES);
+ }
+
+ public static String createDurableLockingID(int bytes)
+ {
+ byte[] buffer = new byte[bytes];
+
+ Random random = new Random(System.currentTimeMillis());
+ random.nextBytes(buffer);
+
+ return HexUtil.bytesToHex(buffer);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/IDurableLockingManager.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/IDurableLockingManager.java index d10fd22d94..7f3620a187 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/IDurableLockingManager.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/IDurableLockingManager.java @@ -1,5 +1,5 @@ /*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 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
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/package-info.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/package-info.java index b59e380108..daf76d03b3 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/package-info.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/lock/package-info.java @@ -1,5 +1,5 @@ /*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 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
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClassInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClassInfo.java index b43dd30a4d..7ec16a3dbe 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClassInfo.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClassInfo.java @@ -1,42 +1,42 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.model; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EStructuralFeature; - -/** - * An EMF {@link Adapter adapter} that encapsulates CDO specific information about an {@link EClass}. - * - * @author Eike Stepper - * @since 2.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.landmark - * @apiviz.has {@link org.eclipse.emf.ecore.EClass} - */ -public interface CDOClassInfo extends Adapter -{ - public EClass getEClass(); - - public boolean isResourceNode(); - - public boolean isResourceFolder(); - - public boolean isResource(); - - public EStructuralFeature[] getAllPersistentFeatures(); - - public int getFeatureIndex(EStructuralFeature feature); - - public int getFeatureIndex(int featureID); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.model;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * An EMF {@link Adapter adapter} that encapsulates CDO specific information about an {@link EClass}.
+ *
+ * @author Eike Stepper
+ * @since 2.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.landmark
+ * @apiviz.has {@link org.eclipse.emf.ecore.EClass}
+ */
+public interface CDOClassInfo extends Adapter
+{
+ public EClass getEClass();
+
+ public boolean isResourceNode();
+
+ public boolean isResourceFolder();
+
+ public boolean isResource();
+
+ public EStructuralFeature[] getAllPersistentFeatures();
+
+ public int getFeatureIndex(EStructuralFeature feature);
+
+ public int getFeatureIndex(int featureID);
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClassifierRef.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClassifierRef.java index 2650fa1d0f..1a050de87f 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClassifierRef.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOClassifierRef.java @@ -1,159 +1,159 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.model; - -import org.eclipse.emf.cdo.common.protocol.CDODataInput; -import org.eclipse.emf.cdo.common.protocol.CDODataOutput; -import org.eclipse.emf.cdo.internal.common.messages.Messages; - -import org.eclipse.net4j.util.ObjectUtil; - -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EPackage; - -import java.io.IOException; -import java.text.MessageFormat; - -/** - * References an {@link EClassifier}. - * - * @author Eike Stepper - * @since 2.0 - */ -public final class CDOClassifierRef -{ - public static final String URI_SEPARATOR = "#"; //$NON-NLS-1$ - - private String packageURI; - - private String classifierName; - - public CDOClassifierRef() - { - } - - public CDOClassifierRef(EClassifier classifier) - { - this(classifier.getEPackage().getNsURI(), classifier.getName()); - } - - public CDOClassifierRef(String packageURI, String classifierName) - { - this.packageURI = packageURI.intern(); - this.classifierName = classifierName.intern(); - } - - /** - * @since 4.0 - */ - public CDOClassifierRef(String uri) - { - if (uri == null) - { - throw new IllegalArgumentException(Messages.getString("CDOClassifierRef.1") + uri); //$NON-NLS-1$ - } - - int hash = uri.lastIndexOf(URI_SEPARATOR); - if (hash == -1) - { - throw new IllegalArgumentException(Messages.getString("CDOClassifierRef.1") + uri); //$NON-NLS-1$ - } - - packageURI = uri.substring(0, hash); - classifierName = uri.substring(hash + 1); - } - - /** - * @since 3.0 - */ - public CDOClassifierRef(CDODataInput in) throws IOException - { - this(in.readCDOPackageURI()); - } - - /** - * @since 3.0 - */ - public void write(CDODataOutput out) throws IOException - { - out.writeCDOPackageURI(getURI()); - } - - /** - * @since 4.0 - */ - public String getURI() - { - return packageURI + URI_SEPARATOR + classifierName; - } - - public String getPackageURI() - { - return packageURI; - } - - public String getClassifierName() - { - return classifierName; - } - - public EClassifier resolve(EPackage.Registry packageRegistry) - { - EPackage ePackage = packageRegistry.getEPackage(packageURI); - if (ePackage == null) - { - throw new IllegalStateException(MessageFormat.format(Messages.getString("CDOClassifierRef.0"), packageURI)); //$NON-NLS-1$ - } - - return ePackage.getEClassifier(classifierName); - } - - @Override - public boolean equals(Object obj) - { - if (obj == this) - { - return true; - } - - if (obj != null && obj.getClass() == CDOClassifierRef.class) - { - CDOClassifierRef that = (CDOClassifierRef)obj; - return ObjectUtil.equals(packageURI, that.packageURI) && ObjectUtil.equals(classifierName, that.classifierName); - } - - return false; - } - - @Override - public int hashCode() - { - return packageURI.hashCode() ^ classifierName.hashCode(); - } - - @Override - public String toString() - { - return MessageFormat.format("CDOClassifierRef({0}, {1})", packageURI, classifierName); //$NON-NLS-1$ - } - - /** - * Provides {@link CDOClassifierRef classifier references}. - * - * @author Eike Stepper - * @since 3.0 - * @apiviz.uses {@link CDOClassifierRef} - - provides - */ - public interface Provider - { - public CDOClassifierRef getClassifierRef(); - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.model;
+
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.internal.common.messages.Messages;
+
+import org.eclipse.net4j.util.ObjectUtil;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EPackage;
+
+import java.io.IOException;
+import java.text.MessageFormat;
+
+/**
+ * References an {@link EClassifier}.
+ *
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public final class CDOClassifierRef
+{
+ public static final String URI_SEPARATOR = "#"; //$NON-NLS-1$
+
+ private String packageURI;
+
+ private String classifierName;
+
+ public CDOClassifierRef()
+ {
+ }
+
+ public CDOClassifierRef(EClassifier classifier)
+ {
+ this(classifier.getEPackage().getNsURI(), classifier.getName());
+ }
+
+ public CDOClassifierRef(String packageURI, String classifierName)
+ {
+ this.packageURI = packageURI.intern();
+ this.classifierName = classifierName.intern();
+ }
+
+ /**
+ * @since 4.0
+ */
+ public CDOClassifierRef(String uri)
+ {
+ if (uri == null)
+ {
+ throw new IllegalArgumentException(Messages.getString("CDOClassifierRef.1") + uri); //$NON-NLS-1$
+ }
+
+ int hash = uri.lastIndexOf(URI_SEPARATOR);
+ if (hash == -1)
+ {
+ throw new IllegalArgumentException(Messages.getString("CDOClassifierRef.1") + uri); //$NON-NLS-1$
+ }
+
+ packageURI = uri.substring(0, hash);
+ classifierName = uri.substring(hash + 1);
+ }
+
+ /**
+ * @since 3.0
+ */
+ public CDOClassifierRef(CDODataInput in) throws IOException
+ {
+ this(in.readCDOPackageURI());
+ }
+
+ /**
+ * @since 3.0
+ */
+ public void write(CDODataOutput out) throws IOException
+ {
+ out.writeCDOPackageURI(getURI());
+ }
+
+ /**
+ * @since 4.0
+ */
+ public String getURI()
+ {
+ return packageURI + URI_SEPARATOR + classifierName;
+ }
+
+ public String getPackageURI()
+ {
+ return packageURI;
+ }
+
+ public String getClassifierName()
+ {
+ return classifierName;
+ }
+
+ public EClassifier resolve(EPackage.Registry packageRegistry)
+ {
+ EPackage ePackage = packageRegistry.getEPackage(packageURI);
+ if (ePackage == null)
+ {
+ throw new IllegalStateException(MessageFormat.format(Messages.getString("CDOClassifierRef.0"), packageURI)); //$NON-NLS-1$
+ }
+
+ return ePackage.getEClassifier(classifierName);
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == this)
+ {
+ return true;
+ }
+
+ if (obj != null && obj.getClass() == CDOClassifierRef.class)
+ {
+ CDOClassifierRef that = (CDOClassifierRef)obj;
+ return ObjectUtil.equals(packageURI, that.packageURI) && ObjectUtil.equals(classifierName, that.classifierName);
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return packageURI.hashCode() ^ classifierName.hashCode();
+ }
+
+ @Override
+ public String toString()
+ {
+ return MessageFormat.format("CDOClassifierRef({0}, {1})", packageURI, classifierName); //$NON-NLS-1$
+ }
+
+ /**
+ * Provides {@link CDOClassifierRef classifier references}.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ * @apiviz.uses {@link CDOClassifierRef} - - provides
+ */
+ public interface Provider
+ {
+ public CDOClassifierRef getClassifierRef();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOModelConstants.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOModelConstants.java index 09573fc0b0..c786f72657 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOModelConstants.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOModelConstants.java @@ -1,69 +1,69 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.model; - -/** - * Symbolic model constants commonly used in CDO. - * - * @author Eike Stepper - * @since 4.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDOModelConstants -{ - public static final String RESOURCE_NODE_NAME_ATTRIBUTE = "name"; //$NON-NLS-1$ - - /** - * @since 4.0 - */ - public static final String CORE_PACKAGE_URI = "http://www.eclipse.org/emf/2002/Ecore"; //$NON-NLS-1$ - - /** - * @since 4.0 - */ - public static final String ROOT_CLASS_NAME = "EObject"; //$NON-NLS-1$ - - /** - * @since 4.0 - */ - public static final String RESOURCE_PACKAGE_URI = "http://www.eclipse.org/emf/CDO/Eresource/4.0.0"; //$NON-NLS-1$ - - /** - * @since 4.0 - */ - public static final String RESOURCE_NODE_CLASS_NAME = "CDOResourceNode"; //$NON-NLS-1$ - - /** - * @since 4.0 - */ - public static final String RESOURCE_FOLDER_CLASS_NAME = "CDOResourceFolder"; //$NON-NLS-1$ - - /** - * @since 4.0 - */ - public static final String RESOURCE_CLASS_NAME = "CDOResource"; //$NON-NLS-1$ - - /** - * @since 4.0 - */ - public static final String TYPES_PACKAGE_URI = "http://www.eclipse.org/emf/CDO/Etypes/4.0.0"; //$NON-NLS-1$ - - /** - * @since 4.0 - */ - public static final String BLOB_CLASS_NAME = "Blob"; //$NON-NLS-1$ - - /** - * @since 4.0 - */ - public static final String CLOB_CLASS_NAME = "Clob"; //$NON-NLS-1$ -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.model;
+
+/**
+ * Symbolic model constants commonly used in CDO.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDOModelConstants
+{
+ public static final String RESOURCE_NODE_NAME_ATTRIBUTE = "name"; //$NON-NLS-1$
+
+ /**
+ * @since 4.0
+ */
+ public static final String CORE_PACKAGE_URI = "http://www.eclipse.org/emf/2002/Ecore"; //$NON-NLS-1$
+
+ /**
+ * @since 4.0
+ */
+ public static final String ROOT_CLASS_NAME = "EObject"; //$NON-NLS-1$
+
+ /**
+ * @since 4.0
+ */
+ public static final String RESOURCE_PACKAGE_URI = "http://www.eclipse.org/emf/CDO/Eresource/4.0.0"; //$NON-NLS-1$
+
+ /**
+ * @since 4.0
+ */
+ public static final String RESOURCE_NODE_CLASS_NAME = "CDOResourceNode"; //$NON-NLS-1$
+
+ /**
+ * @since 4.0
+ */
+ public static final String RESOURCE_FOLDER_CLASS_NAME = "CDOResourceFolder"; //$NON-NLS-1$
+
+ /**
+ * @since 4.0
+ */
+ public static final String RESOURCE_CLASS_NAME = "CDOResource"; //$NON-NLS-1$
+
+ /**
+ * @since 4.0
+ */
+ public static final String TYPES_PACKAGE_URI = "http://www.eclipse.org/emf/CDO/Etypes/4.0.0"; //$NON-NLS-1$
+
+ /**
+ * @since 4.0
+ */
+ public static final String BLOB_CLASS_NAME = "Blob"; //$NON-NLS-1$
+
+ /**
+ * @since 4.0
+ */
+ public static final String CLOB_CLASS_NAME = "Clob"; //$NON-NLS-1$
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOModelUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOModelUtil.java index fc6098ca79..7afd0bc65b 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOModelUtil.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOModelUtil.java @@ -1,639 +1,639 @@ -/* - * Copyright (c) 2004 - 2011 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 - * Stefan Winkler - Bug 332912 - Caching subtype-relationships in the CDOPackageRegistry - * Erdal Karaca - added support for HASHMAP CDO Type - */ -package org.eclipse.emf.cdo.common.model; - -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.revision.CDORevision; -import org.eclipse.emf.cdo.internal.common.bundle.OM; -import org.eclipse.emf.cdo.internal.common.messages.Messages; -import org.eclipse.emf.cdo.internal.common.model.CDOClassInfoImpl; -import org.eclipse.emf.cdo.internal.common.model.CDOPackageInfoImpl; -import org.eclipse.emf.cdo.internal.common.model.CDOPackageUnitImpl; -import org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl; - -import org.eclipse.net4j.util.io.ExtendedDataInput; -import org.eclipse.net4j.util.io.ExtendedDataOutput; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.Enumerator; -import org.eclipse.emf.common.util.TreeIterator; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EDataType; -import org.eclipse.emf.ecore.EEnum; -import org.eclipse.emf.ecore.EEnumLiteral; -import org.eclipse.emf.ecore.EGenericType; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.EcorePackage; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.ecore.util.FeatureMap; -import org.eclipse.emf.ecore.util.FeatureMapUtil; - -import java.io.IOException; -import java.math.BigDecimal; -import java.math.BigInteger; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Various static helper methods for dealing with CDO meta models. - * - * @author Eike Stepper - * @since 2.0 - * @apiviz.uses {@link CDOType} - - provides - */ -public final class CDOModelUtil implements CDOModelConstants -{ - private static CDOType[] coreTypes; - - static - { - List<CDOType> types = new ArrayList<CDOType>(); - registerCoreType(types, EcorePackage.eINSTANCE.getEBigDecimal(), CDOType.BIG_DECIMAL); - registerCoreType(types, EcorePackage.eINSTANCE.getEBigInteger(), CDOType.BIG_INTEGER); - registerCoreType(types, EcorePackage.eINSTANCE.getEBooleanObject(), CDOType.BOOLEAN_OBJECT); - registerCoreType(types, EcorePackage.eINSTANCE.getEBoolean(), CDOType.BOOLEAN); - registerCoreType(types, EcorePackage.eINSTANCE.getEByteArray(), CDOType.BYTE_ARRAY); - registerCoreType(types, EcorePackage.eINSTANCE.getEByteObject(), CDOType.BYTE_OBJECT); - registerCoreType(types, EcorePackage.eINSTANCE.getEByte(), CDOType.BYTE); - registerCoreType(types, EcorePackage.eINSTANCE.getECharacterObject(), CDOType.CHARACTER_OBJECT); - registerCoreType(types, EcorePackage.eINSTANCE.getEChar(), CDOType.CHAR); - registerCoreType(types, EcorePackage.eINSTANCE.getEDate(), CDOType.DATE); - registerCoreType(types, EcorePackage.eINSTANCE.getEDoubleObject(), CDOType.DOUBLE_OBJECT); - registerCoreType(types, EcorePackage.eINSTANCE.getEDouble(), CDOType.DOUBLE); - registerCoreType(types, EcorePackage.eINSTANCE.getEFloatObject(), CDOType.FLOAT_OBJECT); - registerCoreType(types, EcorePackage.eINSTANCE.getEFloat(), CDOType.FLOAT); - registerCoreType(types, EcorePackage.eINSTANCE.getEIntegerObject(), CDOType.INTEGER_OBJECT); - registerCoreType(types, EcorePackage.eINSTANCE.getEInt(), CDOType.INT); - registerCoreType(types, EcorePackage.eINSTANCE.getEJavaClass(), null); - registerCoreType(types, EcorePackage.eINSTANCE.getEJavaObject(), null); - registerCoreType(types, EcorePackage.eINSTANCE.getELongObject(), CDOType.LONG_OBJECT); - registerCoreType(types, EcorePackage.eINSTANCE.getELong(), CDOType.LONG); - registerCoreType(types, EcorePackage.eINSTANCE.getEShortObject(), CDOType.SHORT_OBJECT); - registerCoreType(types, EcorePackage.eINSTANCE.getEShort(), CDOType.SHORT); - registerCoreType(types, EcorePackage.eINSTANCE.getEString(), CDOType.STRING); - coreTypes = types.toArray(new CDOType[types.size()]); - } - - private static void registerCoreType(List<CDOType> types, EClassifier classifier, CDOType type) - { - int index = classifier.getClassifierID(); - while (index >= types.size()) - { - types.add(null); - } - - types.set(index, type); - } - - private CDOModelUtil() - { - } - - /** - * @since 2.0 - */ - public static boolean isCorePackage(EPackage ePackage) - { - return CDOModelConstants.CORE_PACKAGE_URI.equals(ePackage.getNsURI()); - } - - /** - * @since 2.0 - */ - public static boolean isRoot(EClass eClass) - { - return isCorePackage(eClass.getEPackage()) && CDOModelConstants.ROOT_CLASS_NAME.equals(eClass.getName()); - } - - /** - * @since 2.0 - */ - public static boolean isResourcePackage(EPackage ePackage) - { - return CDOModelConstants.RESOURCE_PACKAGE_URI.equals(ePackage.getNsURI()); - } - - /** - * @since 2.0 - */ - public static boolean isResource(EClass eClass) - { - return isResourcePackage(eClass.getEPackage()) && CDOModelConstants.RESOURCE_CLASS_NAME.equals(eClass.getName()); - } - - /** - * @since 2.0 - */ - public static boolean isResourceFolder(EClass eClass) - { - return isResourcePackage(eClass.getEPackage()) - && CDOModelConstants.RESOURCE_FOLDER_CLASS_NAME.equals(eClass.getName()); - } - - /** - * @since 2.0 - */ - public static boolean isResourceNode(EClass eClass) - { - return isResourcePackage(eClass.getEPackage()) - && (CDOModelConstants.RESOURCE_NODE_CLASS_NAME.equals(eClass.getName()) - || CDOModelConstants.RESOURCE_CLASS_NAME.equals(eClass.getName()) || CDOModelConstants.RESOURCE_FOLDER_CLASS_NAME - .equals(eClass.getName())); - } - - /** - * @since 4.0 - */ - public static boolean isTypesPackage(EPackage ePackage) - { - return CDOModelConstants.TYPES_PACKAGE_URI.equals(ePackage.getNsURI()); - } - - /** - * @since 2.0 - */ - public static boolean isSystemPackage(EPackage ePackage) - { - return isCorePackage(ePackage) || isResourcePackage(ePackage) || isTypesPackage(ePackage); - } - - /** - * @since 4.0 - */ - public static boolean isLob(EClassifier eClassifier) - { - return isTypesPackage(eClassifier.getEPackage()) - && (CDOModelConstants.BLOB_CLASS_NAME.equals(eClassifier.getName()) || CDOModelConstants.CLOB_CLASS_NAME - .equals(eClassifier.getName())); - } - - /** - * @since 2.0 - */ - public static CDOType getType(EStructuralFeature feature) - { - if (FeatureMapUtil.isFeatureMap(feature)) - { - return CDOType.FEATURE_MAP_ENTRY; - } - - return CDOModelUtil.getType(feature.getEType()); - } - - /** - * @since 4.0 - */ - public static CDOType getType(byte typeID) - { - return CDOTypeImpl.getType(typeID); - } - - /** - * @since 2.0 - */ - public static CDOType getType(EClassifier classifier) - { - if (classifier instanceof EClass) - { - return CDOType.OBJECT; - } - - if (classifier instanceof EEnum) - { - return CDOType.ENUM_ORDINAL; - } - - EDataType eDataType = (EDataType)classifier; - EPackage ePackage = eDataType.getEPackage(); - - if (isCorePackage(ePackage)) - { - CDOType type = getCoreType(eDataType); - if (type != null) - { - return type; - } - } - else if (isTypesPackage(ePackage)) - { - String name = eDataType.getName(); - if (CDOModelConstants.BLOB_CLASS_NAME.equals(name)) - { - return CDOType.BLOB; - } - - if (CDOModelConstants.CLOB_CLASS_NAME.equals(name)) - { - return CDOType.CLOB; - } - - throw new IllegalArgumentException("Illegal data type: " + eDataType); - } - - return CDOType.CUSTOM; - } - - /** - * Core types includes also complex data like EAnnotation, and EEnum - * - * @since 2.0 - */ - public static CDOType getCoreType(EClassifier eDataType) - { - int index = eDataType.getClassifierID(); - if (0 <= index && index < coreTypes.length) - { - return coreTypes[index]; - } - - return null; - } - - /** - * @since 2.0 - */ - public static CDOType getPrimitiveType(Class<? extends Object> primitiveType) - { - if (primitiveType == String.class) - { - return CDOType.STRING; - } - - if (primitiveType == Boolean.class) - { - return CDOType.BOOLEAN; - } - - if (primitiveType == Integer.class) - { - return CDOType.INT; - } - - if (primitiveType == Double.class) - { - return CDOType.DOUBLE; - } - - if (primitiveType == Float.class) - { - return CDOType.FLOAT; - } - - if (primitiveType == Long.class) - { - return CDOType.LONG; - } - - if (primitiveType == Date.class) - { - return CDOType.DATE; - } - - if (primitiveType == Byte.class) - { - return CDOType.BYTE; - } - - if (primitiveType == Character.class) - { - return CDOType.CHAR; - } - - if (primitiveType == Object[].class) - { - return CDOType.OBJECT_ARRAY; - } - - if (EEnumLiteral.class.isAssignableFrom(primitiveType) || Enumerator.class.isAssignableFrom(primitiveType)) - { - return CDOType.ENUM_LITERAL; - } - - if (Map.class.isAssignableFrom(primitiveType)) - { - return CDOType.MAP; - } - - throw new IllegalArgumentException(MessageFormat.format(Messages.getString("CDOModelUtil.7"), primitiveType)); //$NON-NLS-1$ - } - - /** - * @since 4.0 - */ - public static CDOType getTypeOfObject(Object object) - { - if (object instanceof BigDecimal) - { - return CDOType.BIG_DECIMAL; - } - - if (object instanceof BigInteger) - { - return CDOType.BIG_INTEGER; - } - - if (object instanceof Boolean) - { - return CDOType.BOOLEAN_OBJECT; - } - - if (object instanceof Byte) - { - return CDOType.BYTE_OBJECT; - } - - if (object instanceof byte[]) - { - return CDOType.BYTE_ARRAY; - } - - if (object instanceof Character) - { - return CDOType.CHARACTER_OBJECT; - } - - if (object instanceof Date) - { - return CDOType.DATE; - } - - if (object instanceof Double) - { - return CDOType.DOUBLE_OBJECT; - } - - if (object instanceof EEnumLiteral) - { - return CDOType.ENUM_LITERAL; - } - - if (object instanceof FeatureMap.Entry) - { - return CDOType.FEATURE_MAP_ENTRY; - } - - if (object instanceof Float) - { - return CDOType.FLOAT_OBJECT; - } - - if (object instanceof Integer) - { - return CDOType.INTEGER_OBJECT; - } - - if (object instanceof Long) - { - return CDOType.LONG_OBJECT; - } - - if (object instanceof Short) - { - return CDOType.SHORT_OBJECT; - } - - if (object instanceof String) - { - return CDOType.STRING; - } - - if (object instanceof CDOID || object instanceof CDORevision) - { - return CDOType.OBJECT; - } - - if (object == null) - { - return CDOType.OBJECT; - } - - throw new IllegalArgumentException("Object type " + object.getClass().getName() + " is not supported."); - } - - /** - * @since 2.0 - */ - public static CDOPackageInfo getPackageInfo(Object value, CDOPackageRegistry packageRegistry) - { - if (value instanceof EPackage) - { - return packageRegistry.getPackageInfo((EPackage)value); - } - - if (value instanceof CDOPackageInfo) - { - CDOPackageInfo packageInfo = (CDOPackageInfo)value; - if (packageInfo.getPackageUnit().getPackageRegistry() == packageRegistry) - { - return packageInfo; - } - } - - return null; - } - - /** - * @since 2.0 - */ - public static CDOClassInfo getClassInfo(EClass eClass) - { - synchronized (eClass) - { - EList<Adapter> adapters = eClass.eAdapters(); - CDOClassInfo classInfo = (CDOClassInfo)EcoreUtil.getAdapter(adapters, CDOClassInfo.class); - if (classInfo == null) - { - classInfo = new CDOClassInfoImpl(); - adapters.add(classInfo); - } - - return classInfo; - } - } - - /** - * @since 2.0 - */ - public static EStructuralFeature[] getAllPersistentFeatures(EClass eClass) - { - CDOClassInfo classInfo = getClassInfo(eClass); - return classInfo.getAllPersistentFeatures(); - } - - /** - * @since 2.0 - */ - public static CDOPackageUnit createPackageUnit() - { - return new CDOPackageUnitImpl(); - } - - /** - * @since 2.0 - */ - public static CDOPackageInfo createPackageInfo() - { - return new CDOPackageInfoImpl(); - } - - /** - * @since 3.0 - */ - public static EPackage readPackage(ExtendedDataInput in, ResourceSet resourceSet, boolean lookForResource) - throws IOException - { - String uri = in.readString(); - boolean zipped = in.readBoolean(); - byte[] bytes = in.readByteArray(); - return EMFUtil.createEPackage(uri, bytes, zipped, resourceSet, lookForResource); - } - - /** - * @since 2.0 - */ - public static void writePackage(ExtendedDataOutput out, EPackage ePackage, boolean zipped, - EPackage.Registry packageRegistry) throws IOException - { - checkCrossResourceURIs(ePackage); - - byte[] bytes = EMFUtil.getEPackageBytes(ePackage, zipped, packageRegistry); - out.writeString(ePackage.getNsURI()); - out.writeBoolean(zipped); - out.writeByteArray(bytes); - } - - /** - * @since 3.0 - */ - public static void checkCrossResourceURIs(EPackage ePackage) - { - TreeIterator<EObject> it = ePackage.eAllContents(); - while (it.hasNext()) - { - EObject e = it.next(); - for (EObject r : e.eCrossReferences()) - { - EObject refTarget = null; - - if (r.eIsProxy()) - { - String msg = "Package '%s' contains unresolved proxy '%s'"; - msg = String.format(msg, ePackage.getNsURI(), ((InternalEObject)r).eProxyURI()); - throw new IllegalStateException(msg); - } - - if (r.eResource() != null && r.eResource() != e.eResource()) - { - // It's a ref into another resource - EPackage pkg = null; - if (r instanceof EClassifier) - { - refTarget = r; - pkg = ((EClassifier)r).getEPackage(); - } - else if (r instanceof EStructuralFeature) - { - refTarget = r; - EStructuralFeature feature = (EStructuralFeature)r; - EClass ownerClass = (EClass)feature.eContainer(); - pkg = ownerClass.getEPackage(); - } - else if (r instanceof EGenericType) - { - EGenericType genType = (EGenericType)r; - EClassifier c = genType.getEClassifier(); - if (c != null) - { - refTarget = c; - pkg = c.getEPackage(); - } - } - - if (pkg == null) - { - continue; - } - - while (pkg.getESuperPackage() != null) - { - pkg = pkg.getESuperPackage(); - } - - String resourceURI = refTarget.eResource().getURI().toString(); - if (!resourceURI.toString().equals(pkg.getNsURI())) - { - String msg = "URI of the resource (%s) does not match the nsURI (%s) of the top-level package;\n" - + "this can be fixed by calling Resource.setURI(URI) after loading the packages,\n" - + "or by configuring a URI mapping from nsURI's to location URI's before loading the packages,\n" - + "and then loading them with their nsURI's"; - msg = String.format(msg, resourceURI, pkg.getNsURI()); - throw new IllegalStateException(msg); - } - } - } - } - } - - /** - * @since 4.0 - */ - public static Map<EClass, List<EClass>> getSubTypes(EPackage.Registry packageRegistry) - { - Map<EClass, List<EClass>> result = new HashMap<EClass, List<EClass>>(); - for (String nsURI : packageRegistry.keySet()) - { - EPackage ePackage = packageRegistry.getEPackage(nsURI); - getSubTypes(ePackage, result); - } - - return result; - } - - private static void getSubTypes(EPackage ePackage, Map<EClass, List<EClass>> result) - { - for (EClassifier classifier : ePackage.getEClassifiers()) - { - if (classifier instanceof EClass) - { - EClass eClass = (EClass)classifier; - for (EClass eSuperType : eClass.getEAllSuperTypes()) - { - if (eSuperType.eIsProxy()) - { - OM.LOG.warn("getSubTypes encountered a proxy EClass which will be ignored: " + eSuperType); - continue; - } - - List<EClass> list = result.get(eSuperType); - if (list == null) - { - list = new ArrayList<EClass>(); - result.put(eSuperType, list); - } - - list.add(eClass); - } - } - } - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ * Stefan Winkler - Bug 332912 - Caching subtype-relationships in the CDOPackageRegistry
+ * Erdal Karaca - added support for HASHMAP CDO Type
+ */
+package org.eclipse.emf.cdo.common.model;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.internal.common.bundle.OM;
+import org.eclipse.emf.cdo.internal.common.messages.Messages;
+import org.eclipse.emf.cdo.internal.common.model.CDOClassInfoImpl;
+import org.eclipse.emf.cdo.internal.common.model.CDOPackageInfoImpl;
+import org.eclipse.emf.cdo.internal.common.model.CDOPackageUnitImpl;
+import org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl;
+
+import org.eclipse.net4j.util.io.ExtendedDataInput;
+import org.eclipse.net4j.util.io.ExtendedDataOutput;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.Enumerator;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EEnum;
+import org.eclipse.emf.ecore.EEnumLiteral;
+import org.eclipse.emf.ecore.EGenericType;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.util.FeatureMap;
+import org.eclipse.emf.ecore.util.FeatureMapUtil;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Various static helper methods for dealing with CDO meta models.
+ *
+ * @author Eike Stepper
+ * @since 2.0
+ * @apiviz.uses {@link CDOType} - - provides
+ */
+public final class CDOModelUtil implements CDOModelConstants
+{
+ private static CDOType[] coreTypes;
+
+ static
+ {
+ List<CDOType> types = new ArrayList<CDOType>();
+ registerCoreType(types, EcorePackage.eINSTANCE.getEBigDecimal(), CDOType.BIG_DECIMAL);
+ registerCoreType(types, EcorePackage.eINSTANCE.getEBigInteger(), CDOType.BIG_INTEGER);
+ registerCoreType(types, EcorePackage.eINSTANCE.getEBooleanObject(), CDOType.BOOLEAN_OBJECT);
+ registerCoreType(types, EcorePackage.eINSTANCE.getEBoolean(), CDOType.BOOLEAN);
+ registerCoreType(types, EcorePackage.eINSTANCE.getEByteArray(), CDOType.BYTE_ARRAY);
+ registerCoreType(types, EcorePackage.eINSTANCE.getEByteObject(), CDOType.BYTE_OBJECT);
+ registerCoreType(types, EcorePackage.eINSTANCE.getEByte(), CDOType.BYTE);
+ registerCoreType(types, EcorePackage.eINSTANCE.getECharacterObject(), CDOType.CHARACTER_OBJECT);
+ registerCoreType(types, EcorePackage.eINSTANCE.getEChar(), CDOType.CHAR);
+ registerCoreType(types, EcorePackage.eINSTANCE.getEDate(), CDOType.DATE);
+ registerCoreType(types, EcorePackage.eINSTANCE.getEDoubleObject(), CDOType.DOUBLE_OBJECT);
+ registerCoreType(types, EcorePackage.eINSTANCE.getEDouble(), CDOType.DOUBLE);
+ registerCoreType(types, EcorePackage.eINSTANCE.getEFloatObject(), CDOType.FLOAT_OBJECT);
+ registerCoreType(types, EcorePackage.eINSTANCE.getEFloat(), CDOType.FLOAT);
+ registerCoreType(types, EcorePackage.eINSTANCE.getEIntegerObject(), CDOType.INTEGER_OBJECT);
+ registerCoreType(types, EcorePackage.eINSTANCE.getEInt(), CDOType.INT);
+ registerCoreType(types, EcorePackage.eINSTANCE.getEJavaClass(), null);
+ registerCoreType(types, EcorePackage.eINSTANCE.getEJavaObject(), null);
+ registerCoreType(types, EcorePackage.eINSTANCE.getELongObject(), CDOType.LONG_OBJECT);
+ registerCoreType(types, EcorePackage.eINSTANCE.getELong(), CDOType.LONG);
+ registerCoreType(types, EcorePackage.eINSTANCE.getEShortObject(), CDOType.SHORT_OBJECT);
+ registerCoreType(types, EcorePackage.eINSTANCE.getEShort(), CDOType.SHORT);
+ registerCoreType(types, EcorePackage.eINSTANCE.getEString(), CDOType.STRING);
+ coreTypes = types.toArray(new CDOType[types.size()]);
+ }
+
+ private static void registerCoreType(List<CDOType> types, EClassifier classifier, CDOType type)
+ {
+ int index = classifier.getClassifierID();
+ while (index >= types.size())
+ {
+ types.add(null);
+ }
+
+ types.set(index, type);
+ }
+
+ private CDOModelUtil()
+ {
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static boolean isCorePackage(EPackage ePackage)
+ {
+ return CDOModelConstants.CORE_PACKAGE_URI.equals(ePackage.getNsURI());
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static boolean isRoot(EClass eClass)
+ {
+ return isCorePackage(eClass.getEPackage()) && CDOModelConstants.ROOT_CLASS_NAME.equals(eClass.getName());
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static boolean isResourcePackage(EPackage ePackage)
+ {
+ return CDOModelConstants.RESOURCE_PACKAGE_URI.equals(ePackage.getNsURI());
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static boolean isResource(EClass eClass)
+ {
+ return isResourcePackage(eClass.getEPackage()) && CDOModelConstants.RESOURCE_CLASS_NAME.equals(eClass.getName());
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static boolean isResourceFolder(EClass eClass)
+ {
+ return isResourcePackage(eClass.getEPackage())
+ && CDOModelConstants.RESOURCE_FOLDER_CLASS_NAME.equals(eClass.getName());
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static boolean isResourceNode(EClass eClass)
+ {
+ return isResourcePackage(eClass.getEPackage())
+ && (CDOModelConstants.RESOURCE_NODE_CLASS_NAME.equals(eClass.getName())
+ || CDOModelConstants.RESOURCE_CLASS_NAME.equals(eClass.getName()) || CDOModelConstants.RESOURCE_FOLDER_CLASS_NAME
+ .equals(eClass.getName()));
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static boolean isTypesPackage(EPackage ePackage)
+ {
+ return CDOModelConstants.TYPES_PACKAGE_URI.equals(ePackage.getNsURI());
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static boolean isSystemPackage(EPackage ePackage)
+ {
+ return isCorePackage(ePackage) || isResourcePackage(ePackage) || isTypesPackage(ePackage);
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static boolean isLob(EClassifier eClassifier)
+ {
+ return isTypesPackage(eClassifier.getEPackage())
+ && (CDOModelConstants.BLOB_CLASS_NAME.equals(eClassifier.getName()) || CDOModelConstants.CLOB_CLASS_NAME
+ .equals(eClassifier.getName()));
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static CDOType getType(EStructuralFeature feature)
+ {
+ if (FeatureMapUtil.isFeatureMap(feature))
+ {
+ return CDOType.FEATURE_MAP_ENTRY;
+ }
+
+ return CDOModelUtil.getType(feature.getEType());
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static CDOType getType(byte typeID)
+ {
+ return CDOTypeImpl.getType(typeID);
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static CDOType getType(EClassifier classifier)
+ {
+ if (classifier instanceof EClass)
+ {
+ return CDOType.OBJECT;
+ }
+
+ if (classifier instanceof EEnum)
+ {
+ return CDOType.ENUM_ORDINAL;
+ }
+
+ EDataType eDataType = (EDataType)classifier;
+ EPackage ePackage = eDataType.getEPackage();
+
+ if (isCorePackage(ePackage))
+ {
+ CDOType type = getCoreType(eDataType);
+ if (type != null)
+ {
+ return type;
+ }
+ }
+ else if (isTypesPackage(ePackage))
+ {
+ String name = eDataType.getName();
+ if (CDOModelConstants.BLOB_CLASS_NAME.equals(name))
+ {
+ return CDOType.BLOB;
+ }
+
+ if (CDOModelConstants.CLOB_CLASS_NAME.equals(name))
+ {
+ return CDOType.CLOB;
+ }
+
+ throw new IllegalArgumentException("Illegal data type: " + eDataType);
+ }
+
+ return CDOType.CUSTOM;
+ }
+
+ /**
+ * Core types includes also complex data like EAnnotation, and EEnum
+ *
+ * @since 2.0
+ */
+ public static CDOType getCoreType(EClassifier eDataType)
+ {
+ int index = eDataType.getClassifierID();
+ if (0 <= index && index < coreTypes.length)
+ {
+ return coreTypes[index];
+ }
+
+ return null;
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static CDOType getPrimitiveType(Class<? extends Object> primitiveType)
+ {
+ if (primitiveType == String.class)
+ {
+ return CDOType.STRING;
+ }
+
+ if (primitiveType == Boolean.class)
+ {
+ return CDOType.BOOLEAN;
+ }
+
+ if (primitiveType == Integer.class)
+ {
+ return CDOType.INT;
+ }
+
+ if (primitiveType == Double.class)
+ {
+ return CDOType.DOUBLE;
+ }
+
+ if (primitiveType == Float.class)
+ {
+ return CDOType.FLOAT;
+ }
+
+ if (primitiveType == Long.class)
+ {
+ return CDOType.LONG;
+ }
+
+ if (primitiveType == Date.class)
+ {
+ return CDOType.DATE;
+ }
+
+ if (primitiveType == Byte.class)
+ {
+ return CDOType.BYTE;
+ }
+
+ if (primitiveType == Character.class)
+ {
+ return CDOType.CHAR;
+ }
+
+ if (primitiveType == Object[].class)
+ {
+ return CDOType.OBJECT_ARRAY;
+ }
+
+ if (EEnumLiteral.class.isAssignableFrom(primitiveType) || Enumerator.class.isAssignableFrom(primitiveType))
+ {
+ return CDOType.ENUM_LITERAL;
+ }
+
+ if (Map.class.isAssignableFrom(primitiveType))
+ {
+ return CDOType.MAP;
+ }
+
+ throw new IllegalArgumentException(MessageFormat.format(Messages.getString("CDOModelUtil.7"), primitiveType)); //$NON-NLS-1$
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static CDOType getTypeOfObject(Object object)
+ {
+ if (object instanceof BigDecimal)
+ {
+ return CDOType.BIG_DECIMAL;
+ }
+
+ if (object instanceof BigInteger)
+ {
+ return CDOType.BIG_INTEGER;
+ }
+
+ if (object instanceof Boolean)
+ {
+ return CDOType.BOOLEAN_OBJECT;
+ }
+
+ if (object instanceof Byte)
+ {
+ return CDOType.BYTE_OBJECT;
+ }
+
+ if (object instanceof byte[])
+ {
+ return CDOType.BYTE_ARRAY;
+ }
+
+ if (object instanceof Character)
+ {
+ return CDOType.CHARACTER_OBJECT;
+ }
+
+ if (object instanceof Date)
+ {
+ return CDOType.DATE;
+ }
+
+ if (object instanceof Double)
+ {
+ return CDOType.DOUBLE_OBJECT;
+ }
+
+ if (object instanceof EEnumLiteral)
+ {
+ return CDOType.ENUM_LITERAL;
+ }
+
+ if (object instanceof FeatureMap.Entry)
+ {
+ return CDOType.FEATURE_MAP_ENTRY;
+ }
+
+ if (object instanceof Float)
+ {
+ return CDOType.FLOAT_OBJECT;
+ }
+
+ if (object instanceof Integer)
+ {
+ return CDOType.INTEGER_OBJECT;
+ }
+
+ if (object instanceof Long)
+ {
+ return CDOType.LONG_OBJECT;
+ }
+
+ if (object instanceof Short)
+ {
+ return CDOType.SHORT_OBJECT;
+ }
+
+ if (object instanceof String)
+ {
+ return CDOType.STRING;
+ }
+
+ if (object instanceof CDOID || object instanceof CDORevision)
+ {
+ return CDOType.OBJECT;
+ }
+
+ if (object == null)
+ {
+ return CDOType.OBJECT;
+ }
+
+ throw new IllegalArgumentException("Object type " + object.getClass().getName() + " is not supported.");
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static CDOPackageInfo getPackageInfo(Object value, CDOPackageRegistry packageRegistry)
+ {
+ if (value instanceof EPackage)
+ {
+ return packageRegistry.getPackageInfo((EPackage)value);
+ }
+
+ if (value instanceof CDOPackageInfo)
+ {
+ CDOPackageInfo packageInfo = (CDOPackageInfo)value;
+ if (packageInfo.getPackageUnit().getPackageRegistry() == packageRegistry)
+ {
+ return packageInfo;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static CDOClassInfo getClassInfo(EClass eClass)
+ {
+ synchronized (eClass)
+ {
+ EList<Adapter> adapters = eClass.eAdapters();
+ CDOClassInfo classInfo = (CDOClassInfo)EcoreUtil.getAdapter(adapters, CDOClassInfo.class);
+ if (classInfo == null)
+ {
+ classInfo = new CDOClassInfoImpl();
+ adapters.add(classInfo);
+ }
+
+ return classInfo;
+ }
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static EStructuralFeature[] getAllPersistentFeatures(EClass eClass)
+ {
+ CDOClassInfo classInfo = getClassInfo(eClass);
+ return classInfo.getAllPersistentFeatures();
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static CDOPackageUnit createPackageUnit()
+ {
+ return new CDOPackageUnitImpl();
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static CDOPackageInfo createPackageInfo()
+ {
+ return new CDOPackageInfoImpl();
+ }
+
+ /**
+ * @since 3.0
+ */
+ public static EPackage readPackage(ExtendedDataInput in, ResourceSet resourceSet, boolean lookForResource)
+ throws IOException
+ {
+ String uri = in.readString();
+ boolean zipped = in.readBoolean();
+ byte[] bytes = in.readByteArray();
+ return EMFUtil.createEPackage(uri, bytes, zipped, resourceSet, lookForResource);
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static void writePackage(ExtendedDataOutput out, EPackage ePackage, boolean zipped,
+ EPackage.Registry packageRegistry) throws IOException
+ {
+ checkCrossResourceURIs(ePackage);
+
+ byte[] bytes = EMFUtil.getEPackageBytes(ePackage, zipped, packageRegistry);
+ out.writeString(ePackage.getNsURI());
+ out.writeBoolean(zipped);
+ out.writeByteArray(bytes);
+ }
+
+ /**
+ * @since 3.0
+ */
+ public static void checkCrossResourceURIs(EPackage ePackage)
+ {
+ TreeIterator<EObject> it = ePackage.eAllContents();
+ while (it.hasNext())
+ {
+ EObject e = it.next();
+ for (EObject r : e.eCrossReferences())
+ {
+ EObject refTarget = null;
+
+ if (r.eIsProxy())
+ {
+ String msg = "Package '%s' contains unresolved proxy '%s'";
+ msg = String.format(msg, ePackage.getNsURI(), ((InternalEObject)r).eProxyURI());
+ throw new IllegalStateException(msg);
+ }
+
+ if (r.eResource() != null && r.eResource() != e.eResource())
+ {
+ // It's a ref into another resource
+ EPackage pkg = null;
+ if (r instanceof EClassifier)
+ {
+ refTarget = r;
+ pkg = ((EClassifier)r).getEPackage();
+ }
+ else if (r instanceof EStructuralFeature)
+ {
+ refTarget = r;
+ EStructuralFeature feature = (EStructuralFeature)r;
+ EClass ownerClass = (EClass)feature.eContainer();
+ pkg = ownerClass.getEPackage();
+ }
+ else if (r instanceof EGenericType)
+ {
+ EGenericType genType = (EGenericType)r;
+ EClassifier c = genType.getEClassifier();
+ if (c != null)
+ {
+ refTarget = c;
+ pkg = c.getEPackage();
+ }
+ }
+
+ if (pkg == null)
+ {
+ continue;
+ }
+
+ while (pkg.getESuperPackage() != null)
+ {
+ pkg = pkg.getESuperPackage();
+ }
+
+ String resourceURI = refTarget.eResource().getURI().toString();
+ if (!resourceURI.toString().equals(pkg.getNsURI()))
+ {
+ String msg = "URI of the resource (%s) does not match the nsURI (%s) of the top-level package;\n"
+ + "this can be fixed by calling Resource.setURI(URI) after loading the packages,\n"
+ + "or by configuring a URI mapping from nsURI's to location URI's before loading the packages,\n"
+ + "and then loading them with their nsURI's";
+ msg = String.format(msg, resourceURI, pkg.getNsURI());
+ throw new IllegalStateException(msg);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static Map<EClass, List<EClass>> getSubTypes(EPackage.Registry packageRegistry)
+ {
+ Map<EClass, List<EClass>> result = new HashMap<EClass, List<EClass>>();
+ for (String nsURI : packageRegistry.keySet())
+ {
+ EPackage ePackage = packageRegistry.getEPackage(nsURI);
+ getSubTypes(ePackage, result);
+ }
+
+ return result;
+ }
+
+ private static void getSubTypes(EPackage ePackage, Map<EClass, List<EClass>> result)
+ {
+ for (EClassifier classifier : ePackage.getEClassifiers())
+ {
+ if (classifier instanceof EClass)
+ {
+ EClass eClass = (EClass)classifier;
+ for (EClass eSuperType : eClass.getEAllSuperTypes())
+ {
+ if (eSuperType.eIsProxy())
+ {
+ OM.LOG.warn("getSubTypes encountered a proxy EClass which will be ignored: " + eSuperType);
+ continue;
+ }
+
+ List<EClass> list = result.get(eSuperType);
+ if (list == null)
+ {
+ list = new ArrayList<EClass>();
+ result.put(eSuperType, list);
+ }
+
+ list.add(eClass);
+ }
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageInfo.java index b83fbff8b9..269d38f507 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageInfo.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageInfo.java @@ -1,92 +1,92 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.model; - -import org.eclipse.emf.cdo.common.model.CDOPackageUnit.State; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EPackage.Descriptor; - -/** - * Describes a single {@link EPackage package } instance of the nested package tree strucure represented by the - * containing {@link CDOPackageUnit package unit}. - * <p> - * While the containing package unit is in the {@link CDOPackageUnit.State#PROXY PROXY} state this package info acts as - * a {@link Descriptor package descriptor} in the associated {@link CDOPackageRegistry package registry}. When that - * package unit is loaded all contained package infos/descriptors are resolved and replaced by their actual packages. At - * the same time the describing package info objects are attached as adapters to the resolved packages. This way the - * descriptive information is available before and after loading the packages. - * - * @author Eike Stepper - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.landmark - * @apiviz.has {@link org.eclipse.emf.ecore.EPackage} - * @apiviz.composedOf {@link CDOClassInfo} - */ -public interface CDOPackageInfo extends Adapter, EPackage.Descriptor, Comparable<CDOPackageInfo> -{ - /** - * Returns the package unit containing this package info. - */ - public CDOPackageUnit getPackageUnit(); - - /** - * Returns the namespace URI of the package described by this package info. - */ - public String getPackageURI(); - - /** - * Returns the namespace URI of the {@link EPackage#getESuperPackage() super package} of the package described by this - * package info. - */ - public String getParentURI(); - - /** - * Returns the {@link EPackage package} described by this package info. - * - * @param loadOnDemand - * If <code>true</code> and the containing {@link CDOPackageUnit package unit} is not {@link State#LOADED - * LOADED} the package unit is implicitely loaded. If <code>false</code> and this package unit is not - * {@link State#LOADED LOADED} <code>null</code> is returned. - */ - public EPackage getEPackage(boolean loadOnDemand); - - /** - * Returnes <code>true</code> if the package described by this package info is the <i>Ecore</i> model, - * <code>false</code> oterwise. - */ - public boolean isCorePackage(); - - /** - * Returnes <code>true</code> if the package described by this package info is the <i>Eresource</i> model, - * <code>false</code> oterwise. - */ - public boolean isResourcePackage(); - - /** - * Returnes <code>true</code> if the package described by this package info is the <i>Etypes</i> model, - * <code>false</code> oterwise. - * - * @since 4.0 - */ - public boolean isTypePackage(); - - /** - * Returns <code>true</code> is this package info describes one of the models <i>Ecore</i>, <i>Eresource</i> or - * <i>Etypes</i>, <code>false</code> otherwise. - * <p> - * Note that the models <i>Ecore</i>, <i>Eresource</i> and <i>Etypes</i> are expected to present as generated - * {@link CDOPackageUnit.Type#NATIVE NATIVE} models in all deployments. - */ - public boolean isSystemPackage(); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.model;
+
+import org.eclipse.emf.cdo.common.model.CDOPackageUnit.State;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EPackage.Descriptor;
+
+/**
+ * Describes a single {@link EPackage package } instance of the nested package tree strucure represented by the
+ * containing {@link CDOPackageUnit package unit}.
+ * <p>
+ * While the containing package unit is in the {@link CDOPackageUnit.State#PROXY PROXY} state this package info acts as
+ * a {@link Descriptor package descriptor} in the associated {@link CDOPackageRegistry package registry}. When that
+ * package unit is loaded all contained package infos/descriptors are resolved and replaced by their actual packages. At
+ * the same time the describing package info objects are attached as adapters to the resolved packages. This way the
+ * descriptive information is available before and after loading the packages.
+ *
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.landmark
+ * @apiviz.has {@link org.eclipse.emf.ecore.EPackage}
+ * @apiviz.composedOf {@link CDOClassInfo}
+ */
+public interface CDOPackageInfo extends Adapter, EPackage.Descriptor, Comparable<CDOPackageInfo>
+{
+ /**
+ * Returns the package unit containing this package info.
+ */
+ public CDOPackageUnit getPackageUnit();
+
+ /**
+ * Returns the namespace URI of the package described by this package info.
+ */
+ public String getPackageURI();
+
+ /**
+ * Returns the namespace URI of the {@link EPackage#getESuperPackage() super package} of the package described by this
+ * package info.
+ */
+ public String getParentURI();
+
+ /**
+ * Returns the {@link EPackage package} described by this package info.
+ *
+ * @param loadOnDemand
+ * If <code>true</code> and the containing {@link CDOPackageUnit package unit} is not {@link State#LOADED
+ * LOADED} the package unit is implicitely loaded. If <code>false</code> and this package unit is not
+ * {@link State#LOADED LOADED} <code>null</code> is returned.
+ */
+ public EPackage getEPackage(boolean loadOnDemand);
+
+ /**
+ * Returnes <code>true</code> if the package described by this package info is the <i>Ecore</i> model,
+ * <code>false</code> oterwise.
+ */
+ public boolean isCorePackage();
+
+ /**
+ * Returnes <code>true</code> if the package described by this package info is the <i>Eresource</i> model,
+ * <code>false</code> oterwise.
+ */
+ public boolean isResourcePackage();
+
+ /**
+ * Returnes <code>true</code> if the package described by this package info is the <i>Etypes</i> model,
+ * <code>false</code> oterwise.
+ *
+ * @since 4.0
+ */
+ public boolean isTypePackage();
+
+ /**
+ * Returns <code>true</code> is this package info describes one of the models <i>Ecore</i>, <i>Eresource</i> or
+ * <i>Etypes</i>, <code>false</code> otherwise.
+ * <p>
+ * Note that the models <i>Ecore</i>, <i>Eresource</i> and <i>Etypes</i> are expected to present as generated
+ * {@link CDOPackageUnit.Type#NATIVE NATIVE} models in all deployments.
+ */
+ public boolean isSystemPackage();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageRegistry.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageRegistry.java index f400bacfef..96f6bdac67 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageRegistry.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageRegistry.java @@ -1,81 +1,81 @@ -/* - * Copyright (c) 2004 - 2011 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 - * Stefan Winkler - Bug 332912 - Caching subtype-relationships in the CDOPackageRegistry - */ -package org.eclipse.emf.cdo.common.model; - -import org.eclipse.emf.cdo.common.CDOCommonRepository; -import org.eclipse.emf.cdo.common.CDOCommonSession; - -import org.eclipse.emf.common.util.Enumerator; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EEnumLiteral; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EPackage.Registry; - -import java.util.List; -import java.util.Map; - -/** - * An EMF {@link Registry package registry} that is used by CDO {@link CDOCommonRepository repositories} and - * {@link CDOCommonSession sessions}. - * - * @author Eike Stepper - * @since 2.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.landmark - * @apiviz.composedOf {@link CDOPackageUnit} - */ -public interface CDOPackageRegistry extends EPackage.Registry -{ - public boolean isReplacingDescriptors(); - - /** - * Registers an {@link EPackage} with this package registry. - */ - public Object putEPackage(EPackage ePackage); - - /** - * @since 3.0 - */ - public CDOPackageUnit getPackageUnit(String id); - - public CDOPackageUnit getPackageUnit(EPackage ePackage); - - /** - * Returns all package units that are registered in this package registry. - * - * @since 3.0 - */ - public CDOPackageUnit[] getPackageUnits(); - - /** - * @since 3.0 - */ - public CDOPackageUnit[] getPackageUnits(long startTime, long endTime); - - public CDOPackageInfo getPackageInfo(EPackage ePackage); - - /** - * Returns all package infos that are registered in this package registry. - */ - public CDOPackageInfo[] getPackageInfos(); - - /** - * @since 4.0 - */ - public Map<EClass, List<EClass>> getSubTypes(); - - /** - * @since 4.0 - */ - public EEnumLiteral getEnumLiteralFor(Enumerator value); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ * Stefan Winkler - Bug 332912 - Caching subtype-relationships in the CDOPackageRegistry
+ */
+package org.eclipse.emf.cdo.common.model;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository;
+import org.eclipse.emf.cdo.common.CDOCommonSession;
+
+import org.eclipse.emf.common.util.Enumerator;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EEnumLiteral;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EPackage.Registry;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * An EMF {@link Registry package registry} that is used by CDO {@link CDOCommonRepository repositories} and
+ * {@link CDOCommonSession sessions}.
+ *
+ * @author Eike Stepper
+ * @since 2.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.landmark
+ * @apiviz.composedOf {@link CDOPackageUnit}
+ */
+public interface CDOPackageRegistry extends EPackage.Registry
+{
+ public boolean isReplacingDescriptors();
+
+ /**
+ * Registers an {@link EPackage} with this package registry.
+ */
+ public Object putEPackage(EPackage ePackage);
+
+ /**
+ * @since 3.0
+ */
+ public CDOPackageUnit getPackageUnit(String id);
+
+ public CDOPackageUnit getPackageUnit(EPackage ePackage);
+
+ /**
+ * Returns all package units that are registered in this package registry.
+ *
+ * @since 3.0
+ */
+ public CDOPackageUnit[] getPackageUnits();
+
+ /**
+ * @since 3.0
+ */
+ public CDOPackageUnit[] getPackageUnits(long startTime, long endTime);
+
+ public CDOPackageInfo getPackageInfo(EPackage ePackage);
+
+ /**
+ * Returns all package infos that are registered in this package registry.
+ */
+ public CDOPackageInfo[] getPackageInfos();
+
+ /**
+ * @since 4.0
+ */
+ public Map<EClass, List<EClass>> getSubTypes();
+
+ /**
+ * @since 4.0
+ */
+ public EEnumLiteral getEnumLiteralFor(Enumerator value);
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageRegistryPopulator.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageRegistryPopulator.java index 138e887f1d..26e11b8b96 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageRegistryPopulator.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageRegistryPopulator.java @@ -1,159 +1,159 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.model; - -import org.eclipse.net4j.util.concurrent.Worker; - -import org.eclipse.emf.ecore.EFactory; -import org.eclipse.emf.ecore.EPackage; - -import java.util.Map.Entry; - -/** - * Populates a {@link #getTarget() target} package registry by asynchronously polling a {@link #getSource() source} - * package registry for new {@link EPackage} registrations. - * - * @author Eike Stepper - * @since 2.0 - * @apiviz.uses {@link CDOPackageRegistryPopulator.Descriptor} - - creates - * @apiviz.uses {@link CDOPackageRegistry} - - populates - * @apiviz.uses {@link org.eclipse.emf.ecore.EPackage.Registry} - - polls - */ -public class CDOPackageRegistryPopulator extends Worker -{ - public static final int DEFAULT_SOURCE_POLL_INTERVAL = 5000; - - private long sourcePollInterval = DEFAULT_SOURCE_POLL_INTERVAL; - - private EPackage.Registry source; - - private CDOPackageRegistry target; - - public CDOPackageRegistryPopulator(CDOPackageRegistry target) - { - this(EPackage.Registry.INSTANCE, target); - } - - public CDOPackageRegistryPopulator(EPackage.Registry source, CDOPackageRegistry target) - { - this.source = source; - this.target = target; - } - - public EPackage.Registry getSource() - { - return source; - } - - public CDOPackageRegistry getTarget() - { - return target; - } - - public long getSourcePollInterval() - { - return sourcePollInterval; - } - - public void setSourcePollInterval(long sourcePollInterval) - { - this.sourcePollInterval = sourcePollInterval; - } - - @Override - protected void work(WorkContext context) throws Exception - { - doWork(); - context.nextWork(getSourcePollInterval()); - } - - protected void doWork() - { - populate(getSource(), getTarget()); - } - - @Override - protected void doActivate() throws Exception - { - doWork(); - super.doActivate(); - } - - public static boolean populate(CDOPackageRegistry target) - { - return populate(EPackage.Registry.INSTANCE, target); - } - - public static boolean populate(EPackage.Registry source, CDOPackageRegistry target) - { - boolean populated = false; - while (populateFirstMatch(source, target)) - { - populated = true; - } - - return populated; - } - - private static boolean populateFirstMatch(EPackage.Registry source, CDOPackageRegistry target) - { - for (Entry<String, Object> entry : source.entrySet()) - { - String nsURI = entry.getKey(); - if (!target.containsKey(nsURI)) - { - target.put(nsURI, new Descriptor(source, nsURI)); - return true; - } - } - - return false; - } - - /** - * A package {@link org.eclipse.emf.ecore.EPackage.Descriptor descriptor} that resolves {@link EPackage packages} from - * a {@link #getSource() source } package registry. - * - * @author Eike Stepper - */ - public static class Descriptor implements EPackage.Descriptor - { - private EPackage.Registry source; - - private String nsURI; - - public Descriptor(EPackage.Registry source, String nsURI) - { - this.source = source; - this.nsURI = nsURI; - } - - public EPackage.Registry getSource() - { - return source; - } - - public String getNsURI() - { - return nsURI; - } - - public EFactory getEFactory() - { - return source.getEFactory(nsURI); - } - - public EPackage getEPackage() - { - return source.getEPackage(nsURI); - } - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.model;
+
+import org.eclipse.net4j.util.concurrent.Worker;
+
+import org.eclipse.emf.ecore.EFactory;
+import org.eclipse.emf.ecore.EPackage;
+
+import java.util.Map.Entry;
+
+/**
+ * Populates a {@link #getTarget() target} package registry by asynchronously polling a {@link #getSource() source}
+ * package registry for new {@link EPackage} registrations.
+ *
+ * @author Eike Stepper
+ * @since 2.0
+ * @apiviz.uses {@link CDOPackageRegistryPopulator.Descriptor} - - creates
+ * @apiviz.uses {@link CDOPackageRegistry} - - populates
+ * @apiviz.uses {@link org.eclipse.emf.ecore.EPackage.Registry} - - polls
+ */
+public class CDOPackageRegistryPopulator extends Worker
+{
+ public static final int DEFAULT_SOURCE_POLL_INTERVAL = 5000;
+
+ private long sourcePollInterval = DEFAULT_SOURCE_POLL_INTERVAL;
+
+ private EPackage.Registry source;
+
+ private CDOPackageRegistry target;
+
+ public CDOPackageRegistryPopulator(CDOPackageRegistry target)
+ {
+ this(EPackage.Registry.INSTANCE, target);
+ }
+
+ public CDOPackageRegistryPopulator(EPackage.Registry source, CDOPackageRegistry target)
+ {
+ this.source = source;
+ this.target = target;
+ }
+
+ public EPackage.Registry getSource()
+ {
+ return source;
+ }
+
+ public CDOPackageRegistry getTarget()
+ {
+ return target;
+ }
+
+ public long getSourcePollInterval()
+ {
+ return sourcePollInterval;
+ }
+
+ public void setSourcePollInterval(long sourcePollInterval)
+ {
+ this.sourcePollInterval = sourcePollInterval;
+ }
+
+ @Override
+ protected void work(WorkContext context) throws Exception
+ {
+ doWork();
+ context.nextWork(getSourcePollInterval());
+ }
+
+ protected void doWork()
+ {
+ populate(getSource(), getTarget());
+ }
+
+ @Override
+ protected void doActivate() throws Exception
+ {
+ doWork();
+ super.doActivate();
+ }
+
+ public static boolean populate(CDOPackageRegistry target)
+ {
+ return populate(EPackage.Registry.INSTANCE, target);
+ }
+
+ public static boolean populate(EPackage.Registry source, CDOPackageRegistry target)
+ {
+ boolean populated = false;
+ while (populateFirstMatch(source, target))
+ {
+ populated = true;
+ }
+
+ return populated;
+ }
+
+ private static boolean populateFirstMatch(EPackage.Registry source, CDOPackageRegistry target)
+ {
+ for (Entry<String, Object> entry : source.entrySet())
+ {
+ String nsURI = entry.getKey();
+ if (!target.containsKey(nsURI))
+ {
+ target.put(nsURI, new Descriptor(source, nsURI));
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * A package {@link org.eclipse.emf.ecore.EPackage.Descriptor descriptor} that resolves {@link EPackage packages} from
+ * a {@link #getSource() source } package registry.
+ *
+ * @author Eike Stepper
+ */
+ public static class Descriptor implements EPackage.Descriptor
+ {
+ private EPackage.Registry source;
+
+ private String nsURI;
+
+ public Descriptor(EPackage.Registry source, String nsURI)
+ {
+ this.source = source;
+ this.nsURI = nsURI;
+ }
+
+ public EPackage.Registry getSource()
+ {
+ return source;
+ }
+
+ public String getNsURI()
+ {
+ return nsURI;
+ }
+
+ public EFactory getEFactory()
+ {
+ return source.getEFactory(nsURI);
+ }
+
+ public EPackage getEPackage()
+ {
+ return source.getEPackage(nsURI);
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageTypeRegistry.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageTypeRegistry.java index 1e727b2960..cb3e0e5df8 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageTypeRegistry.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageTypeRegistry.java @@ -1,227 +1,227 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.model; - -import org.eclipse.emf.cdo.common.model.CDOPackageUnit.Type; - -import org.eclipse.net4j.util.ObjectUtil; -import org.eclipse.net4j.util.om.OMPlatform; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.impl.EPackageImpl; -import org.eclipse.emf.ecore.plugin.EcorePlugin; -import org.eclipse.emf.ecore.util.EcoreUtil; - -import java.util.HashMap; -import java.util.Map; - -/** - * A {@link #INSTANCE singleton} registry for the {@link Type package unit types} of EMF {@link EPackage packages}. - * - * @author Eike Stepper - * @since 2.0 - * @apiviz.exclude - */ -public final class CDOPackageTypeRegistry -{ - public static final CDOPackageTypeRegistry INSTANCE = new CDOPackageTypeRegistry(); - - private static final String ECORE_ID = "org.eclipse.emf.ecore"; //$NON-NLS-1$ - - private static final String PPID = EcorePlugin.GENERATED_PACKAGE_PPID; - - private static final String MARKER_FILE = "META-INF/CDO.MF"; //$NON-NLS-1$ - - private Map<String, CDOPackageUnit.Type> types = new HashMap<String, CDOPackageUnit.Type>(); - - private Map<String, CDOPackageUnit.Type> bundles = new HashMap<String, CDOPackageUnit.Type>(); - - private CDOPackageTypeRegistry() - { - } - - public synchronized CDOPackageUnit.Type register(EPackage ePackage) - { - CDOPackageUnit.Type type = getPackageType(ePackage); - types.put(ePackage.getNsURI(), type); - return type; - } - - public synchronized void registerNative(String packageURI) - { - types.put(packageURI, CDOPackageUnit.Type.NATIVE); - } - - public synchronized void registerLegacy(String packageURI) - { - types.put(packageURI, CDOPackageUnit.Type.LEGACY); - } - - public synchronized void registerDynamic(String packageURI) - { - types.put(packageURI, CDOPackageUnit.Type.DYNAMIC); - } - - public synchronized CDOPackageUnit.Type deregister(String packageURI) - { - return types.remove(packageURI); - } - - public synchronized CDOPackageUnit.Type lookup(String packageURI) - { - CDOPackageUnit.Type type = types.get(packageURI); - if (type == null) - { - Object value = EPackage.Registry.INSTANCE.get(packageURI); - if (value instanceof EPackage) - { - EPackage ePackage = (EPackage)value; - type = register(ePackage); - } - - if (type == null && OMPlatform.INSTANCE.isExtensionRegistryAvailable()) - { - type = getTypeFromBundle(packageURI); - types.put(packageURI, type); - } - } - - return type; - } - - public synchronized CDOPackageUnit.Type lookup(EPackage ePackage) - { - String packageURI = ePackage.getNsURI(); - CDOPackageUnit.Type type = types.get(packageURI); - if (type == null) - { - type = register(ePackage); - } - - return type; - } - - public synchronized void reset() - { - types.clear(); - bundles.clear(); - } - - private CDOPackageUnit.Type getTypeFromBundle(String packageURI) - { - String bundleID = getBundleID(packageURI); - if (bundleID == null) - { - return CDOPackageUnit.Type.UNKNOWN; - } - - CDOPackageUnit.Type type = bundles.get(bundleID); - if (type == null) - { - org.osgi.framework.Bundle bundle = org.eclipse.core.runtime.Platform.getBundle(bundleID); - if (bundle == null) - { - type = CDOPackageUnit.Type.UNKNOWN; - } - else if (bundle.getEntry(MARKER_FILE) != null) - { - type = CDOPackageUnit.Type.NATIVE; - } - else - { - type = CDOPackageUnit.Type.LEGACY; - } - - bundles.put(bundleID, type); - } - - return type; - } - - private static String getBundleID(String packageURI) - { - org.eclipse.core.runtime.IExtensionRegistry registry = org.eclipse.core.runtime.Platform.getExtensionRegistry(); - for (org.eclipse.core.runtime.IConfigurationElement element : registry.getConfigurationElementsFor(ECORE_ID, PPID)) - { - String uri = element.getAttribute("uri"); //$NON-NLS-1$ - if (ObjectUtil.equals(uri, packageURI)) - { - return element.getContributor().getName(); - } - } - - return null; - } - - private static CDOPackageUnit.Type getPackageType(EPackage ePackage) - { - if (ePackage.getClass() == EPackageImpl.class) - { - return CDOPackageUnit.Type.DYNAMIC; - } - - EPackage topLevelPackage = EMFUtil.getTopLevelPackage(ePackage); - EClass eClass = getAnyConcreteEClass(topLevelPackage); - if (eClass != null) - { - EObject testObject = EcoreUtil.create(eClass); - if (testObject instanceof CDOObjectMarker) - { - return CDOPackageUnit.Type.NATIVE; - } - - return CDOPackageUnit.Type.LEGACY; - } - - return null; - } - - private static EClass getAnyConcreteEClass(EPackage ePackage) - { - for (EClassifier classifier : ePackage.getEClassifiers()) - { - if (classifier instanceof EClass) - { - EClass eClass = (EClass)classifier; - if (!(eClass.isAbstract() || eClass.isInterface())) - { - return eClass; - } - } - } - - for (EPackage subpackage : ePackage.getESubpackages()) - { - EClass eClass = getAnyConcreteEClass(subpackage); - if (eClass != null) - { - return eClass; - } - } - - return null; - } - - /** - * A common marker interface for CDO (native) objects. - * - * @author Eike Stepper - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.exclude - */ - public static interface CDOObjectMarker - { - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.model;
+
+import org.eclipse.emf.cdo.common.model.CDOPackageUnit.Type;
+
+import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.om.OMPlatform;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.impl.EPackageImpl;
+import org.eclipse.emf.ecore.plugin.EcorePlugin;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * A {@link #INSTANCE singleton} registry for the {@link Type package unit types} of EMF {@link EPackage packages}.
+ *
+ * @author Eike Stepper
+ * @since 2.0
+ * @apiviz.exclude
+ */
+public final class CDOPackageTypeRegistry
+{
+ public static final CDOPackageTypeRegistry INSTANCE = new CDOPackageTypeRegistry();
+
+ private static final String ECORE_ID = "org.eclipse.emf.ecore"; //$NON-NLS-1$
+
+ private static final String PPID = EcorePlugin.GENERATED_PACKAGE_PPID;
+
+ private static final String MARKER_FILE = "META-INF/CDO.MF"; //$NON-NLS-1$
+
+ private Map<String, CDOPackageUnit.Type> types = new HashMap<String, CDOPackageUnit.Type>();
+
+ private Map<String, CDOPackageUnit.Type> bundles = new HashMap<String, CDOPackageUnit.Type>();
+
+ private CDOPackageTypeRegistry()
+ {
+ }
+
+ public synchronized CDOPackageUnit.Type register(EPackage ePackage)
+ {
+ CDOPackageUnit.Type type = getPackageType(ePackage);
+ types.put(ePackage.getNsURI(), type);
+ return type;
+ }
+
+ public synchronized void registerNative(String packageURI)
+ {
+ types.put(packageURI, CDOPackageUnit.Type.NATIVE);
+ }
+
+ public synchronized void registerLegacy(String packageURI)
+ {
+ types.put(packageURI, CDOPackageUnit.Type.LEGACY);
+ }
+
+ public synchronized void registerDynamic(String packageURI)
+ {
+ types.put(packageURI, CDOPackageUnit.Type.DYNAMIC);
+ }
+
+ public synchronized CDOPackageUnit.Type deregister(String packageURI)
+ {
+ return types.remove(packageURI);
+ }
+
+ public synchronized CDOPackageUnit.Type lookup(String packageURI)
+ {
+ CDOPackageUnit.Type type = types.get(packageURI);
+ if (type == null)
+ {
+ Object value = EPackage.Registry.INSTANCE.get(packageURI);
+ if (value instanceof EPackage)
+ {
+ EPackage ePackage = (EPackage)value;
+ type = register(ePackage);
+ }
+
+ if (type == null && OMPlatform.INSTANCE.isExtensionRegistryAvailable())
+ {
+ type = getTypeFromBundle(packageURI);
+ types.put(packageURI, type);
+ }
+ }
+
+ return type;
+ }
+
+ public synchronized CDOPackageUnit.Type lookup(EPackage ePackage)
+ {
+ String packageURI = ePackage.getNsURI();
+ CDOPackageUnit.Type type = types.get(packageURI);
+ if (type == null)
+ {
+ type = register(ePackage);
+ }
+
+ return type;
+ }
+
+ public synchronized void reset()
+ {
+ types.clear();
+ bundles.clear();
+ }
+
+ private CDOPackageUnit.Type getTypeFromBundle(String packageURI)
+ {
+ String bundleID = getBundleID(packageURI);
+ if (bundleID == null)
+ {
+ return CDOPackageUnit.Type.UNKNOWN;
+ }
+
+ CDOPackageUnit.Type type = bundles.get(bundleID);
+ if (type == null)
+ {
+ org.osgi.framework.Bundle bundle = org.eclipse.core.runtime.Platform.getBundle(bundleID);
+ if (bundle == null)
+ {
+ type = CDOPackageUnit.Type.UNKNOWN;
+ }
+ else if (bundle.getEntry(MARKER_FILE) != null)
+ {
+ type = CDOPackageUnit.Type.NATIVE;
+ }
+ else
+ {
+ type = CDOPackageUnit.Type.LEGACY;
+ }
+
+ bundles.put(bundleID, type);
+ }
+
+ return type;
+ }
+
+ private static String getBundleID(String packageURI)
+ {
+ org.eclipse.core.runtime.IExtensionRegistry registry = org.eclipse.core.runtime.Platform.getExtensionRegistry();
+ for (org.eclipse.core.runtime.IConfigurationElement element : registry.getConfigurationElementsFor(ECORE_ID, PPID))
+ {
+ String uri = element.getAttribute("uri"); //$NON-NLS-1$
+ if (ObjectUtil.equals(uri, packageURI))
+ {
+ return element.getContributor().getName();
+ }
+ }
+
+ return null;
+ }
+
+ private static CDOPackageUnit.Type getPackageType(EPackage ePackage)
+ {
+ if (ePackage.getClass() == EPackageImpl.class)
+ {
+ return CDOPackageUnit.Type.DYNAMIC;
+ }
+
+ EPackage topLevelPackage = EMFUtil.getTopLevelPackage(ePackage);
+ EClass eClass = getAnyConcreteEClass(topLevelPackage);
+ if (eClass != null)
+ {
+ EObject testObject = EcoreUtil.create(eClass);
+ if (testObject instanceof CDOObjectMarker)
+ {
+ return CDOPackageUnit.Type.NATIVE;
+ }
+
+ return CDOPackageUnit.Type.LEGACY;
+ }
+
+ return null;
+ }
+
+ private static EClass getAnyConcreteEClass(EPackage ePackage)
+ {
+ for (EClassifier classifier : ePackage.getEClassifiers())
+ {
+ if (classifier instanceof EClass)
+ {
+ EClass eClass = (EClass)classifier;
+ if (!(eClass.isAbstract() || eClass.isInterface()))
+ {
+ return eClass;
+ }
+ }
+ }
+
+ for (EPackage subpackage : ePackage.getESubpackages())
+ {
+ EClass eClass = getAnyConcreteEClass(subpackage);
+ if (eClass != null)
+ {
+ return eClass;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * A common marker interface for CDO (native) objects.
+ *
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.exclude
+ */
+ public static interface CDOObjectMarker
+ {
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageUnit.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageUnit.java index 314de36d22..00e7ca7a8f 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageUnit.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageUnit.java @@ -1,208 +1,208 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.model; - -import org.eclipse.emf.cdo.internal.common.messages.Messages; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EPackage.Registry; - -/** - * Represents a tree structure of nested {@link EPackage packages} that are registered with a {@link CDOPackageRegistry - * package registry} and that can only be serialized as a whole. - * <p> - * A package unit is the granule of committing or lazy loading packages. It contains some overall information like - * {@link Type type}, {@link State state}, {@link #getTimeStamp() commit time} and nested {@link CDOPackageInfo package - * info} objects that describe all the nested packages. - * - * @author Eike Stepper - * @since 2.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.landmark - * @apiviz.has {@link CDOPackageUnit.Type} - * @apiviz.has {@link CDOPackageUnit.State} - * @apiviz.composedOf {@link CDOPackageInfo} - */ -public interface CDOPackageUnit extends Comparable<CDOPackageUnit> -{ - /** - * Returns the package registry this package unit is managed by. - */ - public CDOPackageRegistry getPackageRegistry(); - - /** - * Returns the ID of this package unit. - * <p> - * Same as {@link #getTopLevelPackageInfo()}. {@link CDOPackageInfo#getPackageURI()}. - */ - public String getID(); - - /** - * Returns the current state of this package unit. - */ - public State getState(); - - /** - * Returns the current type of this package unit. - */ - public Type getType(); - - /** - * Returns the type of this package unit as it was at the time it was originally committed by a client. - */ - public Type getOriginalType(); - - /** - * Returns the time this package unit was originally committed. - */ - public long getTimeStamp(); - - /** - * Returns the {@link CDOPackageInfo package info} object that describes the top level {@link EPackage package} of the - * nested package tree structure described by this package unit. - */ - public CDOPackageInfo getTopLevelPackageInfo(); - - /** - * Returns the {@link CDOPackageInfo package info} object that describes the {@link EPackage package} with the given - * namespace URI, or <code>null</code> if this package unit does not contain a package with this URI. - */ - public CDOPackageInfo getPackageInfo(String packageURI); - - /** - * Returns all {@link CDOPackageInfo package info} objects of the nested package tree structure described by this - * package unit in depth-first traversal order. - */ - public CDOPackageInfo[] getPackageInfos(); - - /** - * Returns all {@link EPackage packages} of the nested package tree structure described by this package unit in - * depth-first traversal order. - * - * @param loadOnDemand - * If <code>true</code> and this package unit is not {@link State#LOADED LOADED} the package unit is - * implicitely loaded. If <code>false</code> and this package unit is not {@link State#LOADED LOADED} an - * empty array is returned. - */ - public EPackage[] getEPackages(boolean loadOnDemand); - - /** - * Returns <code>true</code> is this package unit describes one of the models <i>Ecore</i>, <i>Eresource</i> or - * <i>Etypes</i>, <code>false</code> otherwise. - * <p> - * Note that the models <i>Ecore</i>, <i>Eresource</i> and <i>Etypes</i> are expected to be present as generated - * {@link Type#NATIVE NATIVE} models in all deployments. - */ - public boolean isSystem(); - - /** - * Returns <code>true</code> is this package unit describes the model <i>Eresource</i> , <code>false</code> otherwise. - * <p> - * Note that the model <i>Eresource</i> is expected to bepresent as generated {@link Type#NATIVE NATIVE} models in all - * deployments. - * - * @since 4.0 - */ - public boolean isResource(); - - /** - * Describes the possible states a {@link CDOPackageUnit package unit} may be in during its lifecycle. - * - * @author Eike Stepper - */ - public enum State - { - /** - * The state of a {@link CDOPackageUnit package unit} after one of its described {@link EPackage packages} is newly - * attached to a transactional {@link CDOPackageRegistry package registry}, but before the associated transaction is - * committed. A {@link #NEW} package unit can only transition to {@link #LOADED} or {@link #DISPOSED}. - */ - NEW, - - /** - * The state of a {@link CDOPackageUnit package unit} after the described {@link EPackage packages} are loaded or - * wired from the {@link Registry#INSTANCE global package registry}. A {@link #LOADED} package unit can only - * transition to {@link #DISPOSED}. - */ - LOADED, - - /** - * The state of a {@link CDOPackageUnit package unit} after the context of the associated {@link CDOPackageRegistry - * package registry} has been initialized, that is the repository been started or the session been opened. A - * {@link #PROXY} package unit can only transition to {@link #LOADED} or {@link #DISPOSED}. - */ - PROXY, - - /** - * The state of a {@link CDOPackageUnit package unit} after the associated {@link CDOPackageRegistry package - * registry} has been deactivated, that is the repository been stopped or the session been closed. A - * {@link #DISPOSED} package unit can not transition to any other state. - */ - DISPOSED - } - - /** - * Describes the instances of {@link EClass classes} of a {@link CDOPackageUnit package unit}. - * - * @author Eike Stepper - */ - public enum Type - { - /** - * The type of models that are generated specifically for the usage with CDO. Instances of {@link EClass classes} of - * these models can be directly cast to InternalCDOObject. - */ - NATIVE, - - /** - * The type of models that are <b>not</b> generated specifically for the usage with CDO. Instances of {@link EClass - * classes} of these models can <b>not</b> be directly cast to InternalCDOObject. - */ - LEGACY, - - /** - * The type of models that are not generated <b>at all</b> but rather dynamically contructed at runtime. Instances - * of {@link EClass classes} of these models <b>can</b> be directly cast to InternalCDOObject, i.e. they're - * implicitely <i>native</i>. - */ - DYNAMIC, - - /** - * Used to indicate that the type of a model could not be determined. Refer to the - * {@link CDOPackageTypeRegistry#INSTANCE package type registry} on how to deal with this scenario. - */ - UNKNOWN; - - /** - * Returns <code>true</code> if this type is either {@link #NATIVE} or {@link #LEGACY}, <code>false</code> - * otherwise. - */ - public boolean isGenerated() - { - checkNotUnknown(); - return this == NATIVE || this == LEGACY; - } - - /** - * @throws IllegalStateException - * if this type is {@link #UNKNOWN}. - */ - public void checkNotUnknown() throws IllegalStateException - { - if (this == UNKNOWN) - { - throw new IllegalStateException(Messages.getString("CDOPackageUnit.0")); //$NON-NLS-1$ - } - } - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.model;
+
+import org.eclipse.emf.cdo.internal.common.messages.Messages;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EPackage.Registry;
+
+/**
+ * Represents a tree structure of nested {@link EPackage packages} that are registered with a {@link CDOPackageRegistry
+ * package registry} and that can only be serialized as a whole.
+ * <p>
+ * A package unit is the granule of committing or lazy loading packages. It contains some overall information like
+ * {@link Type type}, {@link State state}, {@link #getTimeStamp() commit time} and nested {@link CDOPackageInfo package
+ * info} objects that describe all the nested packages.
+ *
+ * @author Eike Stepper
+ * @since 2.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.landmark
+ * @apiviz.has {@link CDOPackageUnit.Type}
+ * @apiviz.has {@link CDOPackageUnit.State}
+ * @apiviz.composedOf {@link CDOPackageInfo}
+ */
+public interface CDOPackageUnit extends Comparable<CDOPackageUnit>
+{
+ /**
+ * Returns the package registry this package unit is managed by.
+ */
+ public CDOPackageRegistry getPackageRegistry();
+
+ /**
+ * Returns the ID of this package unit.
+ * <p>
+ * Same as {@link #getTopLevelPackageInfo()}. {@link CDOPackageInfo#getPackageURI()}.
+ */
+ public String getID();
+
+ /**
+ * Returns the current state of this package unit.
+ */
+ public State getState();
+
+ /**
+ * Returns the current type of this package unit.
+ */
+ public Type getType();
+
+ /**
+ * Returns the type of this package unit as it was at the time it was originally committed by a client.
+ */
+ public Type getOriginalType();
+
+ /**
+ * Returns the time this package unit was originally committed.
+ */
+ public long getTimeStamp();
+
+ /**
+ * Returns the {@link CDOPackageInfo package info} object that describes the top level {@link EPackage package} of the
+ * nested package tree structure described by this package unit.
+ */
+ public CDOPackageInfo getTopLevelPackageInfo();
+
+ /**
+ * Returns the {@link CDOPackageInfo package info} object that describes the {@link EPackage package} with the given
+ * namespace URI, or <code>null</code> if this package unit does not contain a package with this URI.
+ */
+ public CDOPackageInfo getPackageInfo(String packageURI);
+
+ /**
+ * Returns all {@link CDOPackageInfo package info} objects of the nested package tree structure described by this
+ * package unit in depth-first traversal order.
+ */
+ public CDOPackageInfo[] getPackageInfos();
+
+ /**
+ * Returns all {@link EPackage packages} of the nested package tree structure described by this package unit in
+ * depth-first traversal order.
+ *
+ * @param loadOnDemand
+ * If <code>true</code> and this package unit is not {@link State#LOADED LOADED} the package unit is
+ * implicitely loaded. If <code>false</code> and this package unit is not {@link State#LOADED LOADED} an
+ * empty array is returned.
+ */
+ public EPackage[] getEPackages(boolean loadOnDemand);
+
+ /**
+ * Returns <code>true</code> is this package unit describes one of the models <i>Ecore</i>, <i>Eresource</i> or
+ * <i>Etypes</i>, <code>false</code> otherwise.
+ * <p>
+ * Note that the models <i>Ecore</i>, <i>Eresource</i> and <i>Etypes</i> are expected to be present as generated
+ * {@link Type#NATIVE NATIVE} models in all deployments.
+ */
+ public boolean isSystem();
+
+ /**
+ * Returns <code>true</code> is this package unit describes the model <i>Eresource</i> , <code>false</code> otherwise.
+ * <p>
+ * Note that the model <i>Eresource</i> is expected to bepresent as generated {@link Type#NATIVE NATIVE} models in all
+ * deployments.
+ *
+ * @since 4.0
+ */
+ public boolean isResource();
+
+ /**
+ * Describes the possible states a {@link CDOPackageUnit package unit} may be in during its lifecycle.
+ *
+ * @author Eike Stepper
+ */
+ public enum State
+ {
+ /**
+ * The state of a {@link CDOPackageUnit package unit} after one of its described {@link EPackage packages} is newly
+ * attached to a transactional {@link CDOPackageRegistry package registry}, but before the associated transaction is
+ * committed. A {@link #NEW} package unit can only transition to {@link #LOADED} or {@link #DISPOSED}.
+ */
+ NEW,
+
+ /**
+ * The state of a {@link CDOPackageUnit package unit} after the described {@link EPackage packages} are loaded or
+ * wired from the {@link Registry#INSTANCE global package registry}. A {@link #LOADED} package unit can only
+ * transition to {@link #DISPOSED}.
+ */
+ LOADED,
+
+ /**
+ * The state of a {@link CDOPackageUnit package unit} after the context of the associated {@link CDOPackageRegistry
+ * package registry} has been initialized, that is the repository been started or the session been opened. A
+ * {@link #PROXY} package unit can only transition to {@link #LOADED} or {@link #DISPOSED}.
+ */
+ PROXY,
+
+ /**
+ * The state of a {@link CDOPackageUnit package unit} after the associated {@link CDOPackageRegistry package
+ * registry} has been deactivated, that is the repository been stopped or the session been closed. A
+ * {@link #DISPOSED} package unit can not transition to any other state.
+ */
+ DISPOSED
+ }
+
+ /**
+ * Describes the instances of {@link EClass classes} of a {@link CDOPackageUnit package unit}.
+ *
+ * @author Eike Stepper
+ */
+ public enum Type
+ {
+ /**
+ * The type of models that are generated specifically for the usage with CDO. Instances of {@link EClass classes} of
+ * these models can be directly cast to InternalCDOObject.
+ */
+ NATIVE,
+
+ /**
+ * The type of models that are <b>not</b> generated specifically for the usage with CDO. Instances of {@link EClass
+ * classes} of these models can <b>not</b> be directly cast to InternalCDOObject.
+ */
+ LEGACY,
+
+ /**
+ * The type of models that are not generated <b>at all</b> but rather dynamically contructed at runtime. Instances
+ * of {@link EClass classes} of these models <b>can</b> be directly cast to InternalCDOObject, i.e. they're
+ * implicitely <i>native</i>.
+ */
+ DYNAMIC,
+
+ /**
+ * Used to indicate that the type of a model could not be determined. Refer to the
+ * {@link CDOPackageTypeRegistry#INSTANCE package type registry} on how to deal with this scenario.
+ */
+ UNKNOWN;
+
+ /**
+ * Returns <code>true</code> if this type is either {@link #NATIVE} or {@link #LEGACY}, <code>false</code>
+ * otherwise.
+ */
+ public boolean isGenerated()
+ {
+ checkNotUnknown();
+ return this == NATIVE || this == LEGACY;
+ }
+
+ /**
+ * @throws IllegalStateException
+ * if this type is {@link #UNKNOWN}.
+ */
+ public void checkNotUnknown() throws IllegalStateException
+ {
+ if (this == UNKNOWN)
+ {
+ throw new IllegalStateException(Messages.getString("CDOPackageUnit.0")); //$NON-NLS-1$
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOType.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOType.java index 45fb183616..b49b80ae61 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOType.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOType.java @@ -1,157 +1,157 @@ -/* - * Copyright (c) 2004 - 2011 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 - * Erdal Karaca - added support for MAP Type - */ -package org.eclipse.emf.cdo.common.model; - -import org.eclipse.emf.cdo.common.protocol.CDODataInput; -import org.eclipse.emf.cdo.common.protocol.CDODataOutput; -import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster; - -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EStructuralFeature; - -import java.io.IOException; - -/** - * Provides access to all CDO-supported data types. - * - * @author Eike Stepper - * @noimplement This interface is not intended to be implemented by clients. - * @since 2.0 - * @apiviz.landmark - */ -public interface CDOType -{ - public static final CDOType OBJECT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.OBJECT; - - public static final CDOType BOOLEAN = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.BOOLEAN; - - public static final CDOType BOOLEAN_OBJECT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.BOOLEAN_OBJECT; - - public static final CDOType BYTE = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.BYTE; - - public static final CDOType BYTE_OBJECT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.BYTE_OBJECT; - - public static final CDOType CHAR = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.CHAR; - - public static final CDOType CHARACTER_OBJECT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.CHARACTER_OBJECT; - - public static final CDOType DATE = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.DATE; - - public static final CDOType DOUBLE = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.DOUBLE; - - public static final CDOType DOUBLE_OBJECT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.DOUBLE_OBJECT; - - public static final CDOType FLOAT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.FLOAT; - - public static final CDOType FLOAT_OBJECT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.FLOAT_OBJECT; - - public static final CDOType INT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.INT; - - public static final CDOType INTEGER_OBJECT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.INTEGER_OBJECT; - - public static final CDOType LONG = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.LONG; - - public static final CDOType LONG_OBJECT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.LONG_OBJECT; - - public static final CDOType SHORT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.SHORT; - - public static final CDOType SHORT_OBJECT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.SHORT_OBJECT; - - public static final CDOType STRING = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.STRING; - - public static final CDOType BYTE_ARRAY = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.BYTE_ARRAY; - - /** - * @since 3.0 - */ - public static final CDOType OBJECT_ARRAY = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.OBJECT_ARRAY; - - /** - * @since 4.0 - */ - public static final CDOType MAP = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.MAP; - - /** - * @since 2.0 - */ - public static final CDOType BIG_DECIMAL = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.BIG_DECIMAL; - - /** - * @since 2.0 - */ - public static final CDOType BIG_INTEGER = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.BIG_INTEGER; - - /** - * @since 3.0 - */ - public static final CDOType ENUM_ORDINAL = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.ENUM_ORDINAL; - - /** - * @since 3.0 - */ - public static final CDOType ENUM_LITERAL = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.ENUM_LITERAL; - - /** - * @since 4.0 - */ - public static final CDOType BLOB = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.BLOB; - - /** - * @since 4.0 - */ - public static final CDOType CLOB = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.CLOB; - - public static final CDOType CUSTOM = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.CUSTOM; - - /** - * @since 2.0 - */ - public static final CDOType FEATURE_MAP_ENTRY = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.FEATURE_MAP_ENTRY; - - public String getName(); - - /** - * @since 4.0 - */ - public byte getTypeID(); - - public boolean canBeNull(); - - public Object getDefaultValue(); - - public Object copyValue(Object value); - - /** - * @since 4.0 - */ - public Object adjustReferences(CDOReferenceAdjuster adjuster, Object value, EStructuralFeature feature, int index); - - /** - * @since 3.0 - */ - public Object readValue(CDODataInput in) throws IOException; - - /** - * @since 3.0 - */ - public void writeValue(CDODataOutput out, Object value) throws IOException; - - /** - * @since 2.0 - */ - public Object convertToEMF(EClassifier feature, Object value); - - /** - * @since 2.0 - */ - public Object convertToCDO(EClassifier feature, Object value); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ * Erdal Karaca - added support for MAP Type
+ */
+package org.eclipse.emf.cdo.common.model;
+
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
+
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import java.io.IOException;
+
+/**
+ * Provides access to all CDO-supported data types.
+ *
+ * @author Eike Stepper
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @since 2.0
+ * @apiviz.landmark
+ */
+public interface CDOType
+{
+ public static final CDOType OBJECT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.OBJECT;
+
+ public static final CDOType BOOLEAN = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.BOOLEAN;
+
+ public static final CDOType BOOLEAN_OBJECT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.BOOLEAN_OBJECT;
+
+ public static final CDOType BYTE = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.BYTE;
+
+ public static final CDOType BYTE_OBJECT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.BYTE_OBJECT;
+
+ public static final CDOType CHAR = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.CHAR;
+
+ public static final CDOType CHARACTER_OBJECT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.CHARACTER_OBJECT;
+
+ public static final CDOType DATE = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.DATE;
+
+ public static final CDOType DOUBLE = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.DOUBLE;
+
+ public static final CDOType DOUBLE_OBJECT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.DOUBLE_OBJECT;
+
+ public static final CDOType FLOAT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.FLOAT;
+
+ public static final CDOType FLOAT_OBJECT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.FLOAT_OBJECT;
+
+ public static final CDOType INT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.INT;
+
+ public static final CDOType INTEGER_OBJECT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.INTEGER_OBJECT;
+
+ public static final CDOType LONG = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.LONG;
+
+ public static final CDOType LONG_OBJECT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.LONG_OBJECT;
+
+ public static final CDOType SHORT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.SHORT;
+
+ public static final CDOType SHORT_OBJECT = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.SHORT_OBJECT;
+
+ public static final CDOType STRING = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.STRING;
+
+ public static final CDOType BYTE_ARRAY = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.BYTE_ARRAY;
+
+ /**
+ * @since 3.0
+ */
+ public static final CDOType OBJECT_ARRAY = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.OBJECT_ARRAY;
+
+ /**
+ * @since 4.0
+ */
+ public static final CDOType MAP = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.MAP;
+
+ /**
+ * @since 2.0
+ */
+ public static final CDOType BIG_DECIMAL = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.BIG_DECIMAL;
+
+ /**
+ * @since 2.0
+ */
+ public static final CDOType BIG_INTEGER = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.BIG_INTEGER;
+
+ /**
+ * @since 3.0
+ */
+ public static final CDOType ENUM_ORDINAL = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.ENUM_ORDINAL;
+
+ /**
+ * @since 3.0
+ */
+ public static final CDOType ENUM_LITERAL = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.ENUM_LITERAL;
+
+ /**
+ * @since 4.0
+ */
+ public static final CDOType BLOB = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.BLOB;
+
+ /**
+ * @since 4.0
+ */
+ public static final CDOType CLOB = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.CLOB;
+
+ public static final CDOType CUSTOM = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.CUSTOM;
+
+ /**
+ * @since 2.0
+ */
+ public static final CDOType FEATURE_MAP_ENTRY = org.eclipse.emf.cdo.internal.common.model.CDOTypeImpl.FEATURE_MAP_ENTRY;
+
+ public String getName();
+
+ /**
+ * @since 4.0
+ */
+ public byte getTypeID();
+
+ public boolean canBeNull();
+
+ public Object getDefaultValue();
+
+ public Object copyValue(Object value);
+
+ /**
+ * @since 4.0
+ */
+ public Object adjustReferences(CDOReferenceAdjuster adjuster, Object value, EStructuralFeature feature, int index);
+
+ /**
+ * @since 3.0
+ */
+ public Object readValue(CDODataInput in) throws IOException;
+
+ /**
+ * @since 3.0
+ */
+ public void writeValue(CDODataOutput out, Object value) throws IOException;
+
+ /**
+ * @since 2.0
+ */
+ public Object convertToEMF(EClassifier feature, Object value);
+
+ /**
+ * @since 2.0
+ */
+ public Object convertToCDO(EClassifier feature, Object value);
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/EMFUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/EMFUtil.java index 2b343dde74..cfd8b13691 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/EMFUtil.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/EMFUtil.java @@ -1,513 +1,513 @@ -/* - * Copyright (c) 2004 - 2011 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 - * Victor Roldan Betancort - maintenance - * Simon McDuff - maintenance - */ -package org.eclipse.emf.cdo.common.model; - -import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry; - -import org.eclipse.net4j.util.WrappedException; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.emf.common.notify.Notifier; -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.TreeIterator; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EPackage; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.EcoreFactory; -import org.eclipse.emf.ecore.EcorePackage; -import org.eclipse.emf.ecore.InternalEObject; -import org.eclipse.emf.ecore.impl.EPackageImpl; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -/** - * Various static helper methods for dealing with EMF meta models. - * - * @author Eike Stepper - * @since 2.0 - * @apiviz.exclude - */ -public final class EMFUtil -{ - /** - * @since 3.0 - */ - public static final String CDO_ANNOTATION_SOURCE = "http://www.eclipse.org/emf/CDO"; - - /** - * @since 3.0 - */ - public static final String CDO_ANNOTATION_KEY_PERSISTENT = "persistent"; - - private static final EReference EOPERATION_EEXCEPTIONS = EcorePackage.eINSTANCE.getEOperation_EExceptions(); - - private static final EReference ETYPED_ELEMENT_ETYPE = EcorePackage.eINSTANCE.getETypedElement_EType(); - - private static final EReference ECLASS_ESUPER_TYPES = EcorePackage.eINSTANCE.getEClass_ESuperTypes(); - - private EMFUtil() - { - } - - public static EPackage getGeneratedEPackage(EPackage ePackage) - { - String packageURI = ePackage.getNsURI(); - if (packageURI.equals(EcorePackage.eINSTANCE.getNsURI())) - { - return EcorePackage.eINSTANCE; - } - - EPackage.Registry registry = EPackage.Registry.INSTANCE; - return registry.getEPackage(packageURI); - } - - public static Map.Entry<String, Object>[] getSortedRegistryEntries(EPackage.Registry packageRegistry) - { - Set<Map.Entry<String, Object>> entries = packageRegistry.entrySet(); - @SuppressWarnings("unchecked") - Map.Entry<String, Object>[] array = entries.toArray(new Entry[entries.size()]); - Arrays.sort(array, new Comparator<Map.Entry<String, Object>>() - { - public int compare(Map.Entry<String, Object> o1, Map.Entry<String, Object> o2) - { - return o1.getKey().compareTo(o2.getKey()); - } - }); - - return array; - } - - public static EPackage getTopLevelPackage(EPackage ePackage) - { - EPackage superPackage = ePackage.getESuperPackage(); - return superPackage == null ? ePackage : getTopLevelPackage(superPackage); - } - - /** - * @since 2.0 - */ - public static EPackage createEPackage(String name, String nsPrefix, String nsURI) - { - EPackage ePackage = EcoreFactory.eINSTANCE.createEPackage(); - ePackage.setName(name); - ePackage.setNsPrefix(nsPrefix); - ePackage.setNsURI(nsURI); - return ePackage; - } - - /** - * @since 2.0 - */ - public static EClass createEClass(EPackage ePackage, String name, boolean isAbstract, boolean isInterface) - { - EClass eClass = EcoreFactory.eINSTANCE.createEClass(); - eClass.setName(name); - eClass.setAbstract(isAbstract); - eClass.setInterface(isInterface); - ePackage.getEClassifiers().add(eClass); - return eClass; - } - - /** - * @since 2.0 - */ - public static EAttribute createEAttribute(EClass eClass, String name, EClassifier type) - { - EAttribute eAttribute = EcoreFactory.eINSTANCE.createEAttribute(); - eAttribute.setName(name); - eAttribute.setEType(type); - eClass.getEStructuralFeatures().add(eAttribute); - return eAttribute; - } - - /** - * @since 2.0 - */ - public static EReference createEReference(EClass eClass, String name, EClassifier type, boolean isRequired, - boolean isMany) - { - EReference eReference = EcoreFactory.eINSTANCE.createEReference(); - eReference.setName(name); - eReference.setEType(type); - eReference.setLowerBound(isRequired ? 1 : 0); - eReference.setUpperBound(isMany ? -1 : 0); - eClass.getEStructuralFeatures().add(eReference); - return eReference; - } - - public static EClass[] getPersistentClasses(EPackage ePackage) - { - List<EClass> result = new ArrayList<EClass>(); - for (EClassifier classifier : ePackage.getEClassifiers()) - { - if (classifier instanceof EClass) - { - result.add((EClass)classifier); - } - } - - return result.toArray(new EClass[result.size()]); - } - - /** - * @since 3.0 - */ - public static List<EStructuralFeature> getPersistentFeatures(EList<EStructuralFeature> eFeatures) - { - List<EStructuralFeature> result = new ArrayList<EStructuralFeature>(); - for (EStructuralFeature feature : eFeatures) - { - if (isPersistent(feature)) - { - result.add(feature); - } - } - - return result; - } - - /** - * @since 3.0 - */ - public static boolean isPersistent(EStructuralFeature feature) - { - if (feature == ECLASS_ESUPER_TYPES || feature == ETYPED_ELEMENT_ETYPE || feature == EOPERATION_EEXCEPTIONS) - { - // http://www.eclipse.org/newsportal/article.php?id=26780&group=eclipse.tools.emf#26780 - return false; - } - - String persistent = EcoreUtil.getAnnotation(feature, CDO_ANNOTATION_SOURCE, CDO_ANNOTATION_KEY_PERSISTENT); - if (persistent != null) - { - return "true".equalsIgnoreCase(persistent); - } - - if (feature.isTransient()) - { - // Bug 333950: Transient eRefs with a persistent eOpposite, must be considered persistent - if (feature instanceof EReference) - { - EReference eOpposite = ((EReference)feature).getEOpposite(); - if (eOpposite != null && !eOpposite.isTransient()) - { - return true; - } - } - - return false; - } - - return true; - } - - public static boolean isDynamicEPackage(Object value) - { - return value.getClass() == EPackageImpl.class; - } - - public static String getParentURI(EPackage ePackage) - { - EPackage superPackage = ePackage.getESuperPackage(); - String parentURI = superPackage == null ? null : superPackage.getNsURI(); - return parentURI; - } - - public static void registerPackage(EPackage ePackage, EPackage.Registry... packageRegistries) - { - ePackage.getClass(); // Initialize package in standalone mode - if (packageRegistries == null || packageRegistries.length == 0) - { - EPackage.Registry[] globalRegistry = { EPackage.Registry.INSTANCE }; - packageRegistries = globalRegistry; - } - - for (EPackage.Registry packageRegistry : packageRegistries) - { - packageRegistry.put(ePackage.getNsURI(), ePackage); - } - } - - public static byte[] getEPackageBytes(EPackage ePackage, boolean zipped, EPackage.Registry packageRegistry) - { - try - { - Resource resource = ePackage.eResource(); - if (resource == null) - { - // Happens e.g. for dynamic packages that were not loaded from a resource - ResourceSet resourceSet = newEcoreResourceSet(packageRegistry); - resource = resourceSet.createResource(URI.createURI(ePackage.getNsURI())); - resource.getContents().add(ePackage); - } - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - resource.save(baos, createResourceOptions(zipped)); - return baos.toByteArray(); - } - catch (Exception ex) - { - throw WrappedException.wrap(ex); - } - } - - /** - * @since 3.0 - */ - public static EPackage createEPackage(String uri, byte[] bytes, boolean zipped, ResourceSet resourceSet, - boolean lookForResource) - { - try - { - Resource resource = null; - if (lookForResource) - { - resource = resourceSet.getResource(URI.createURI(uri), true); - } - - if (resource == null) - { - resource = resourceSet.createResource(URI.createURI(uri)); - } - - ByteArrayInputStream bais = new ByteArrayInputStream(bytes); - resource.load(bais, createResourceOptions(zipped)); - - EList<EObject> contents = resource.getContents(); - return (EPackage)contents.get(0); - } - catch (Exception ex) - { - throw WrappedException.wrap(ex); - } - } - - private static Map<String, Object> createResourceOptions(boolean zipped) - { - Map<String, Object> options = new HashMap<String, Object>(); - if (zipped) - { - options.put(Resource.OPTION_ZIP, true); - } - - return options; - } - - public static void addAdapter(Notifier notifier, Adapter adapter) - { - synchronized (notifier) - { - EList<Adapter> adapters = notifier.eAdapters(); - adapters.add(adapter); - } - } - - public static EPackage[] getAllPackages(EPackage ePackage) - { - List<EPackage> result = new ArrayList<EPackage>(); - getAllPackages(ePackage, result); - return result.toArray(new EPackage[result.size()]); - } - - private static void getAllPackages(EPackage ePackage, List<EPackage> result) - { - result.add(ePackage); - for (EPackage subPackage : ePackage.getESubpackages()) - { - getAllPackages(subPackage, result); - } - } - - public static String getQualifiedName(EPackage ePackage, String separator) - { - StringBuilder builder = new StringBuilder(); - EPackage eSuperPackage = ePackage.getESuperPackage(); - if (eSuperPackage != null) - { - builder.append(getQualifiedName(eSuperPackage, separator)); - builder.append(separator); - } - - builder.append(ePackage.getName()); - return builder.toString(); - } - - public static String getQualifiedName(EClassifier classifier, String separator) - { - StringBuilder builder = new StringBuilder(); - EPackage ePackage = classifier.getEPackage(); - if (ePackage != null) - { - builder.append(getQualifiedName(ePackage, separator)); - builder.append(separator); - } - - builder.append(classifier.getName()); - return builder.toString(); - } - - public static ResourceSet newResourceSet(Resource.Factory resourceFactory) - { - ResourceSet resourceSet = new ResourceSetImpl(); - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", resourceFactory); //$NON-NLS-1$ - return resourceSet; - } - - public static ResourceSet newEcoreResourceSet(EPackage.Registry packageRegistry) - { - ResourceSet resourceSet = newResourceSet(new EcoreResourceFactoryImpl()); - resourceSet.setPackageRegistry(packageRegistry); - return resourceSet; - } - - public static ResourceSet newEcoreResourceSet() - { - return newEcoreResourceSet(EPackage.Registry.INSTANCE); - } - - /** - * @since 3.0 - */ - public static EObject safeResolve(EObject proxy, ResourceSet resourceSet) - { - if (!proxy.eIsProxy()) - { - return proxy; - } - - EObject resolved = EcoreUtil.resolve(proxy, resourceSet); - if (resolved == proxy) - { - throw new IllegalStateException("Unresolvable proxy: " + ((InternalEObject)proxy).eProxyURI()); - } - - return resolved; - } - - /** - * @since 3.0 - */ - public static void safeResolveAll(ResourceSet resourceSet) - { - TreeIterator<Notifier> it = resourceSet.getAllContents(); - while (it.hasNext()) - { - Notifier notifier = it.next(); - if (notifier instanceof EObject) - { - safeResolve((EObject)notifier, resourceSet); - Iterator<EObject> it2 = ((EObject)notifier).eCrossReferences().iterator(); - while (it2.hasNext()) - { - safeResolve(it2.next(), resourceSet); - } - } - } - } - - /** - * @see ExtResourceSet - * @since 4.0 - */ - public static ExtResourceSet createExtResourceSet(InternalCDOPackageRegistry packageRegistry, boolean delegating, - boolean demandLoading) - { - Resource.Factory resourceFactory = new EcoreResourceFactoryImpl(); - - ExtResourceSet resourceSet = new ExtResourceSet(delegating, demandLoading); - resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", resourceFactory); //$NON-NLS-1$ - resourceSet.setPackageRegistry(packageRegistry); - return resourceSet; - } - - /** - * An extension of {@link ResourceSetImpl} that allows demandLoading of resources and delegation of resource lookups, - * to be switched on/off as desired. - * - * @since 4.0 - * @apiviz.exclude - */ - public static class ExtResourceSet extends ResourceSetImpl - { - private boolean delegating; - - private boolean demandLoading; - - ExtResourceSet(boolean delegating, boolean demandLoading) - { - this.delegating = delegating; - this.demandLoading = demandLoading; - } - - public boolean isDelegating() - { - return delegating; - } - - public void setDelegating(boolean delegating) - { - this.delegating = delegating; - } - - public boolean isDemandLoading() - { - return demandLoading; - } - - public void setDemandLoading(boolean demandLoading) - { - this.demandLoading = demandLoading; - } - - @Override - protected void demandLoad(Resource resource) throws IOException - { - if (demandLoading) - { - super.demandLoad(resource); - } - } - - @Override - protected Resource delegatedGetResource(URI uri, boolean loadOnDemand) - { - if (delegating) - { - return super.delegatedGetResource(uri, loadOnDemand); - } - - return null; - } - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ * Victor Roldan Betancort - maintenance
+ * Simon McDuff - maintenance
+ */
+package org.eclipse.emf.cdo.common.model;
+
+import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
+
+import org.eclipse.net4j.util.WrappedException;
+
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EReference;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.EcorePackage;
+import org.eclipse.emf.ecore.InternalEObject;
+import org.eclipse.emf.ecore.impl.EPackageImpl;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.xmi.impl.EcoreResourceFactoryImpl;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+/**
+ * Various static helper methods for dealing with EMF meta models.
+ *
+ * @author Eike Stepper
+ * @since 2.0
+ * @apiviz.exclude
+ */
+public final class EMFUtil
+{
+ /**
+ * @since 3.0
+ */
+ public static final String CDO_ANNOTATION_SOURCE = "http://www.eclipse.org/emf/CDO";
+
+ /**
+ * @since 3.0
+ */
+ public static final String CDO_ANNOTATION_KEY_PERSISTENT = "persistent";
+
+ private static final EReference EOPERATION_EEXCEPTIONS = EcorePackage.eINSTANCE.getEOperation_EExceptions();
+
+ private static final EReference ETYPED_ELEMENT_ETYPE = EcorePackage.eINSTANCE.getETypedElement_EType();
+
+ private static final EReference ECLASS_ESUPER_TYPES = EcorePackage.eINSTANCE.getEClass_ESuperTypes();
+
+ private EMFUtil()
+ {
+ }
+
+ public static EPackage getGeneratedEPackage(EPackage ePackage)
+ {
+ String packageURI = ePackage.getNsURI();
+ if (packageURI.equals(EcorePackage.eINSTANCE.getNsURI()))
+ {
+ return EcorePackage.eINSTANCE;
+ }
+
+ EPackage.Registry registry = EPackage.Registry.INSTANCE;
+ return registry.getEPackage(packageURI);
+ }
+
+ public static Map.Entry<String, Object>[] getSortedRegistryEntries(EPackage.Registry packageRegistry)
+ {
+ Set<Map.Entry<String, Object>> entries = packageRegistry.entrySet();
+ @SuppressWarnings("unchecked")
+ Map.Entry<String, Object>[] array = entries.toArray(new Entry[entries.size()]);
+ Arrays.sort(array, new Comparator<Map.Entry<String, Object>>()
+ {
+ public int compare(Map.Entry<String, Object> o1, Map.Entry<String, Object> o2)
+ {
+ return o1.getKey().compareTo(o2.getKey());
+ }
+ });
+
+ return array;
+ }
+
+ public static EPackage getTopLevelPackage(EPackage ePackage)
+ {
+ EPackage superPackage = ePackage.getESuperPackage();
+ return superPackage == null ? ePackage : getTopLevelPackage(superPackage);
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static EPackage createEPackage(String name, String nsPrefix, String nsURI)
+ {
+ EPackage ePackage = EcoreFactory.eINSTANCE.createEPackage();
+ ePackage.setName(name);
+ ePackage.setNsPrefix(nsPrefix);
+ ePackage.setNsURI(nsURI);
+ return ePackage;
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static EClass createEClass(EPackage ePackage, String name, boolean isAbstract, boolean isInterface)
+ {
+ EClass eClass = EcoreFactory.eINSTANCE.createEClass();
+ eClass.setName(name);
+ eClass.setAbstract(isAbstract);
+ eClass.setInterface(isInterface);
+ ePackage.getEClassifiers().add(eClass);
+ return eClass;
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static EAttribute createEAttribute(EClass eClass, String name, EClassifier type)
+ {
+ EAttribute eAttribute = EcoreFactory.eINSTANCE.createEAttribute();
+ eAttribute.setName(name);
+ eAttribute.setEType(type);
+ eClass.getEStructuralFeatures().add(eAttribute);
+ return eAttribute;
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static EReference createEReference(EClass eClass, String name, EClassifier type, boolean isRequired,
+ boolean isMany)
+ {
+ EReference eReference = EcoreFactory.eINSTANCE.createEReference();
+ eReference.setName(name);
+ eReference.setEType(type);
+ eReference.setLowerBound(isRequired ? 1 : 0);
+ eReference.setUpperBound(isMany ? -1 : 0);
+ eClass.getEStructuralFeatures().add(eReference);
+ return eReference;
+ }
+
+ public static EClass[] getPersistentClasses(EPackage ePackage)
+ {
+ List<EClass> result = new ArrayList<EClass>();
+ for (EClassifier classifier : ePackage.getEClassifiers())
+ {
+ if (classifier instanceof EClass)
+ {
+ result.add((EClass)classifier);
+ }
+ }
+
+ return result.toArray(new EClass[result.size()]);
+ }
+
+ /**
+ * @since 3.0
+ */
+ public static List<EStructuralFeature> getPersistentFeatures(EList<EStructuralFeature> eFeatures)
+ {
+ List<EStructuralFeature> result = new ArrayList<EStructuralFeature>();
+ for (EStructuralFeature feature : eFeatures)
+ {
+ if (isPersistent(feature))
+ {
+ result.add(feature);
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * @since 3.0
+ */
+ public static boolean isPersistent(EStructuralFeature feature)
+ {
+ if (feature == ECLASS_ESUPER_TYPES || feature == ETYPED_ELEMENT_ETYPE || feature == EOPERATION_EEXCEPTIONS)
+ {
+ // http://www.eclipse.org/newsportal/article.php?id=26780&group=eclipse.tools.emf#26780
+ return false;
+ }
+
+ String persistent = EcoreUtil.getAnnotation(feature, CDO_ANNOTATION_SOURCE, CDO_ANNOTATION_KEY_PERSISTENT);
+ if (persistent != null)
+ {
+ return "true".equalsIgnoreCase(persistent);
+ }
+
+ if (feature.isTransient())
+ {
+ // Bug 333950: Transient eRefs with a persistent eOpposite, must be considered persistent
+ if (feature instanceof EReference)
+ {
+ EReference eOpposite = ((EReference)feature).getEOpposite();
+ if (eOpposite != null && !eOpposite.isTransient())
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ return true;
+ }
+
+ public static boolean isDynamicEPackage(Object value)
+ {
+ return value.getClass() == EPackageImpl.class;
+ }
+
+ public static String getParentURI(EPackage ePackage)
+ {
+ EPackage superPackage = ePackage.getESuperPackage();
+ String parentURI = superPackage == null ? null : superPackage.getNsURI();
+ return parentURI;
+ }
+
+ public static void registerPackage(EPackage ePackage, EPackage.Registry... packageRegistries)
+ {
+ ePackage.getClass(); // Initialize package in standalone mode
+ if (packageRegistries == null || packageRegistries.length == 0)
+ {
+ EPackage.Registry[] globalRegistry = { EPackage.Registry.INSTANCE };
+ packageRegistries = globalRegistry;
+ }
+
+ for (EPackage.Registry packageRegistry : packageRegistries)
+ {
+ packageRegistry.put(ePackage.getNsURI(), ePackage);
+ }
+ }
+
+ public static byte[] getEPackageBytes(EPackage ePackage, boolean zipped, EPackage.Registry packageRegistry)
+ {
+ try
+ {
+ Resource resource = ePackage.eResource();
+ if (resource == null)
+ {
+ // Happens e.g. for dynamic packages that were not loaded from a resource
+ ResourceSet resourceSet = newEcoreResourceSet(packageRegistry);
+ resource = resourceSet.createResource(URI.createURI(ePackage.getNsURI()));
+ resource.getContents().add(ePackage);
+ }
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ resource.save(baos, createResourceOptions(zipped));
+ return baos.toByteArray();
+ }
+ catch (Exception ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
+
+ /**
+ * @since 3.0
+ */
+ public static EPackage createEPackage(String uri, byte[] bytes, boolean zipped, ResourceSet resourceSet,
+ boolean lookForResource)
+ {
+ try
+ {
+ Resource resource = null;
+ if (lookForResource)
+ {
+ resource = resourceSet.getResource(URI.createURI(uri), true);
+ }
+
+ if (resource == null)
+ {
+ resource = resourceSet.createResource(URI.createURI(uri));
+ }
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ resource.load(bais, createResourceOptions(zipped));
+
+ EList<EObject> contents = resource.getContents();
+ return (EPackage)contents.get(0);
+ }
+ catch (Exception ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
+
+ private static Map<String, Object> createResourceOptions(boolean zipped)
+ {
+ Map<String, Object> options = new HashMap<String, Object>();
+ if (zipped)
+ {
+ options.put(Resource.OPTION_ZIP, true);
+ }
+
+ return options;
+ }
+
+ public static void addAdapter(Notifier notifier, Adapter adapter)
+ {
+ synchronized (notifier)
+ {
+ EList<Adapter> adapters = notifier.eAdapters();
+ adapters.add(adapter);
+ }
+ }
+
+ public static EPackage[] getAllPackages(EPackage ePackage)
+ {
+ List<EPackage> result = new ArrayList<EPackage>();
+ getAllPackages(ePackage, result);
+ return result.toArray(new EPackage[result.size()]);
+ }
+
+ private static void getAllPackages(EPackage ePackage, List<EPackage> result)
+ {
+ result.add(ePackage);
+ for (EPackage subPackage : ePackage.getESubpackages())
+ {
+ getAllPackages(subPackage, result);
+ }
+ }
+
+ public static String getQualifiedName(EPackage ePackage, String separator)
+ {
+ StringBuilder builder = new StringBuilder();
+ EPackage eSuperPackage = ePackage.getESuperPackage();
+ if (eSuperPackage != null)
+ {
+ builder.append(getQualifiedName(eSuperPackage, separator));
+ builder.append(separator);
+ }
+
+ builder.append(ePackage.getName());
+ return builder.toString();
+ }
+
+ public static String getQualifiedName(EClassifier classifier, String separator)
+ {
+ StringBuilder builder = new StringBuilder();
+ EPackage ePackage = classifier.getEPackage();
+ if (ePackage != null)
+ {
+ builder.append(getQualifiedName(ePackage, separator));
+ builder.append(separator);
+ }
+
+ builder.append(classifier.getName());
+ return builder.toString();
+ }
+
+ public static ResourceSet newResourceSet(Resource.Factory resourceFactory)
+ {
+ ResourceSet resourceSet = new ResourceSetImpl();
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", resourceFactory); //$NON-NLS-1$
+ return resourceSet;
+ }
+
+ public static ResourceSet newEcoreResourceSet(EPackage.Registry packageRegistry)
+ {
+ ResourceSet resourceSet = newResourceSet(new EcoreResourceFactoryImpl());
+ resourceSet.setPackageRegistry(packageRegistry);
+ return resourceSet;
+ }
+
+ public static ResourceSet newEcoreResourceSet()
+ {
+ return newEcoreResourceSet(EPackage.Registry.INSTANCE);
+ }
+
+ /**
+ * @since 3.0
+ */
+ public static EObject safeResolve(EObject proxy, ResourceSet resourceSet)
+ {
+ if (!proxy.eIsProxy())
+ {
+ return proxy;
+ }
+
+ EObject resolved = EcoreUtil.resolve(proxy, resourceSet);
+ if (resolved == proxy)
+ {
+ throw new IllegalStateException("Unresolvable proxy: " + ((InternalEObject)proxy).eProxyURI());
+ }
+
+ return resolved;
+ }
+
+ /**
+ * @since 3.0
+ */
+ public static void safeResolveAll(ResourceSet resourceSet)
+ {
+ TreeIterator<Notifier> it = resourceSet.getAllContents();
+ while (it.hasNext())
+ {
+ Notifier notifier = it.next();
+ if (notifier instanceof EObject)
+ {
+ safeResolve((EObject)notifier, resourceSet);
+ Iterator<EObject> it2 = ((EObject)notifier).eCrossReferences().iterator();
+ while (it2.hasNext())
+ {
+ safeResolve(it2.next(), resourceSet);
+ }
+ }
+ }
+ }
+
+ /**
+ * @see ExtResourceSet
+ * @since 4.0
+ */
+ public static ExtResourceSet createExtResourceSet(InternalCDOPackageRegistry packageRegistry, boolean delegating,
+ boolean demandLoading)
+ {
+ Resource.Factory resourceFactory = new EcoreResourceFactoryImpl();
+
+ ExtResourceSet resourceSet = new ExtResourceSet(delegating, demandLoading);
+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", resourceFactory); //$NON-NLS-1$
+ resourceSet.setPackageRegistry(packageRegistry);
+ return resourceSet;
+ }
+
+ /**
+ * An extension of {@link ResourceSetImpl} that allows demandLoading of resources and delegation of resource lookups,
+ * to be switched on/off as desired.
+ *
+ * @since 4.0
+ * @apiviz.exclude
+ */
+ public static class ExtResourceSet extends ResourceSetImpl
+ {
+ private boolean delegating;
+
+ private boolean demandLoading;
+
+ ExtResourceSet(boolean delegating, boolean demandLoading)
+ {
+ this.delegating = delegating;
+ this.demandLoading = demandLoading;
+ }
+
+ public boolean isDelegating()
+ {
+ return delegating;
+ }
+
+ public void setDelegating(boolean delegating)
+ {
+ this.delegating = delegating;
+ }
+
+ public boolean isDemandLoading()
+ {
+ return demandLoading;
+ }
+
+ public void setDemandLoading(boolean demandLoading)
+ {
+ this.demandLoading = demandLoading;
+ }
+
+ @Override
+ protected void demandLoad(Resource resource) throws IOException
+ {
+ if (demandLoading)
+ {
+ super.demandLoad(resource);
+ }
+ }
+
+ @Override
+ protected Resource delegatedGetResource(URI uri, boolean loadOnDemand)
+ {
+ if (delegating)
+ {
+ return super.delegatedGetResource(uri, loadOnDemand);
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/package-info.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/package-info.java index 60f669011a..63bfb5eb9c 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/package-info.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/package-info.java @@ -1,5 +1,5 @@ /*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 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
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/package-info.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/package-info.java index 96f974eb3c..750d1ee1fa 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/package-info.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/package-info.java @@ -1,5 +1,5 @@ /*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 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
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDOAuthenticator.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDOAuthenticator.java index 6017406519..2eb66f6cc7 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDOAuthenticator.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDOAuthenticator.java @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.protocol; - -import org.eclipse.emf.cdo.spi.common.CDOAuthenticationResult; - -import org.eclipse.net4j.util.security.IPasswordCredentialsProvider; - -/** - * The front-end of the CDO challenge/response authentication. - * - * @author Eike Stepper - * @since 2.0 - */ -public interface CDOAuthenticator -{ - public String getEncryptionAlgorithmName(); - - public void setEncryptionAlgorithmName(String encryptionAlgorithmName); - - public byte[] getEncryptionSaltBytes(); - - public void setEncryptionSaltBytes(byte[] encryptionSaltBytes); - - public int getEncryptionIterationCount(); - - public void setEncryptionIterationCount(int encryptionIterationCount); - - public IPasswordCredentialsProvider getCredentialsProvider(); - - public void setCredentialsProvider(IPasswordCredentialsProvider credentialsProvider); - - /** - * @since 4.0 - */ - public CDOAuthenticationResult authenticate(byte[] randomToken); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.protocol;
+
+import org.eclipse.emf.cdo.spi.common.CDOAuthenticationResult;
+
+import org.eclipse.net4j.util.security.IPasswordCredentialsProvider;
+
+/**
+ * The front-end of the CDO challenge/response authentication.
+ *
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public interface CDOAuthenticator
+{
+ public String getEncryptionAlgorithmName();
+
+ public void setEncryptionAlgorithmName(String encryptionAlgorithmName);
+
+ public byte[] getEncryptionSaltBytes();
+
+ public void setEncryptionSaltBytes(byte[] encryptionSaltBytes);
+
+ public int getEncryptionIterationCount();
+
+ public void setEncryptionIterationCount(int encryptionIterationCount);
+
+ public IPasswordCredentialsProvider getCredentialsProvider();
+
+ public void setCredentialsProvider(IPasswordCredentialsProvider credentialsProvider);
+
+ /**
+ * @since 4.0
+ */
+ public CDOAuthenticationResult authenticate(byte[] randomToken);
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDODataInput.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDODataInput.java index 2231e70115..0cb9d5915d 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDODataInput.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDODataInput.java @@ -1,167 +1,167 @@ -/* - * Copyright (c) 2004 - 2011 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 - maintenance - */ -package org.eclipse.emf.cdo.common.protocol; - -import org.eclipse.emf.cdo.common.branch.CDOBranch; -import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; -import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; -import org.eclipse.emf.cdo.common.commit.CDOChangeSetData; -import org.eclipse.emf.cdo.common.commit.CDOCommitData; -import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.id.CDOIDReference; -import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo; -import org.eclipse.emf.cdo.common.lock.CDOLockOwner; -import org.eclipse.emf.cdo.common.lock.CDOLockState; -import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea; -import org.eclipse.emf.cdo.common.model.CDOClassifierRef; -import org.eclipse.emf.cdo.common.model.CDOPackageInfo; -import org.eclipse.emf.cdo.common.model.CDOPackageUnit; -import org.eclipse.emf.cdo.common.model.CDOType; -import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch; -import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion; -import org.eclipse.emf.cdo.common.revision.CDOList; -import org.eclipse.emf.cdo.common.revision.CDORevisable; -import org.eclipse.emf.cdo.common.revision.CDORevision; -import org.eclipse.emf.cdo.common.revision.CDORevisionKey; -import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta; -import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; - -import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType; -import org.eclipse.net4j.util.io.ExtendedDataInput; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.resource.ResourceSet; - -import java.io.IOException; - -/** - * Provides I/O methods for reading various CDO data types and concepts from streams. - * - * @author Eike Stepper - * @since 3.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDODataInput extends ExtendedDataInput -{ - // ///////////////////////////////////////////////////////////////////////////////////////////////// - - public CDOPackageUnit readCDOPackageUnit(ResourceSet resourceSet) throws IOException; - - public CDOPackageUnit[] readCDOPackageUnits(ResourceSet resourceSet) throws IOException; - - public CDOPackageUnit.Type readCDOPackageUnitType() throws IOException; - - public CDOPackageInfo readCDOPackageInfo() throws IOException; - - public CDOClassifierRef readCDOClassifierRef() throws IOException; - - public EClassifier readCDOClassifierRefAndResolve() throws IOException; - - public String readCDOPackageURI() throws IOException; - - public CDOType readCDOType() throws IOException; - - // ///////////////////////////////////////////////////////////////////////////////////////////////// - - public CDOBranch readCDOBranch() throws IOException; - - public CDOBranchPoint readCDOBranchPoint() throws IOException; - - public CDOBranchVersion readCDOBranchVersion() throws IOException; - - public CDOChangeSetData readCDOChangeSetData() throws IOException; - - public CDOCommitData readCDOCommitData() throws IOException; - - public CDOCommitInfo readCDOCommitInfo() throws IOException; - - // ///////////////////////////////////////////////////////////////////////////////////////////////// - - public CDOID readCDOID() throws IOException; - - /** - * @since 4.0 - */ - public CDOIDReference readCDOIDReference() throws IOException; - - /** - * @since 4.0 - */ - public CDOIDAndVersion readCDOIDAndVersion() throws IOException; - - /** - * @since 4.0 - */ - public CDOIDAndBranch readCDOIDAndBranch() throws IOException; - - // ///////////////////////////////////////////////////////////////////////////////////////////////// - - public CDORevisionKey readCDORevisionKey() throws IOException; - - public CDORevision readCDORevision() throws IOException; - - /** - * @since 4.1 - */ - public CDORevision readCDORevision(boolean freeze) throws IOException; - - /** - * @since 4.0 - */ - public CDORevisable readCDORevisable() throws IOException; - - public CDOList readCDOList(EClass owner, EStructuralFeature feature) throws IOException; - - public Object readCDOFeatureValue(EStructuralFeature feature) throws IOException; - - public CDORevisionDelta readCDORevisionDelta() throws IOException; - - public CDOFeatureDelta readCDOFeatureDelta(EClass owner) throws IOException; - - /** - * Read either a CDORevision or a primitive value. - */ - public Object readCDORevisionOrPrimitive() throws IOException; - - /** - * Read either a CDORevision, a primitive value or a EClass. - */ - public Object readCDORevisionOrPrimitiveOrClassifier() throws IOException; - - // ///////////////////////////////////////////////////////////////////////////////////////////////// - - public LockType readCDOLockType() throws IOException; - - /** - * @since 4.1 - */ - public CDOLockChangeInfo readCDOLockChangeInfo() throws IOException; - - /** - * @since 4.1 - */ - public CDOLockOwner readCDOLockOwner() throws IOException; - - /** - * @since 4.1 - */ - public CDOLockState readCDOLockState() throws IOException; - - /** - * @since 4.1 - */ - public LockArea readCDOLockArea() throws IOException; -} +/*
+ * Copyright (c) 2004 - 2012 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 - maintenance
+ */
+package org.eclipse.emf.cdo.common.protocol;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
+import org.eclipse.emf.cdo.common.commit.CDOCommitData;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDReference;
+import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
+import org.eclipse.emf.cdo.common.lock.CDOLockOwner;
+import org.eclipse.emf.cdo.common.lock.CDOLockState;
+import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea;
+import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
+import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
+import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
+import org.eclipse.emf.cdo.common.model.CDOType;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
+import org.eclipse.emf.cdo.common.revision.CDOList;
+import org.eclipse.emf.cdo.common.revision.CDORevisable;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+
+import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
+import org.eclipse.net4j.util.io.ExtendedDataInput;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.ResourceSet;
+
+import java.io.IOException;
+
+/**
+ * Provides I/O methods for reading various CDO data types and concepts from streams.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDODataInput extends ExtendedDataInput
+{
+ // /////////////////////////////////////////////////////////////////////////////////////////////////
+
+ public CDOPackageUnit readCDOPackageUnit(ResourceSet resourceSet) throws IOException;
+
+ public CDOPackageUnit[] readCDOPackageUnits(ResourceSet resourceSet) throws IOException;
+
+ public CDOPackageUnit.Type readCDOPackageUnitType() throws IOException;
+
+ public CDOPackageInfo readCDOPackageInfo() throws IOException;
+
+ public CDOClassifierRef readCDOClassifierRef() throws IOException;
+
+ public EClassifier readCDOClassifierRefAndResolve() throws IOException;
+
+ public String readCDOPackageURI() throws IOException;
+
+ public CDOType readCDOType() throws IOException;
+
+ // /////////////////////////////////////////////////////////////////////////////////////////////////
+
+ public CDOBranch readCDOBranch() throws IOException;
+
+ public CDOBranchPoint readCDOBranchPoint() throws IOException;
+
+ public CDOBranchVersion readCDOBranchVersion() throws IOException;
+
+ public CDOChangeSetData readCDOChangeSetData() throws IOException;
+
+ public CDOCommitData readCDOCommitData() throws IOException;
+
+ public CDOCommitInfo readCDOCommitInfo() throws IOException;
+
+ // /////////////////////////////////////////////////////////////////////////////////////////////////
+
+ public CDOID readCDOID() throws IOException;
+
+ /**
+ * @since 4.0
+ */
+ public CDOIDReference readCDOIDReference() throws IOException;
+
+ /**
+ * @since 4.0
+ */
+ public CDOIDAndVersion readCDOIDAndVersion() throws IOException;
+
+ /**
+ * @since 4.0
+ */
+ public CDOIDAndBranch readCDOIDAndBranch() throws IOException;
+
+ // /////////////////////////////////////////////////////////////////////////////////////////////////
+
+ public CDORevisionKey readCDORevisionKey() throws IOException;
+
+ public CDORevision readCDORevision() throws IOException;
+
+ /**
+ * @since 4.1
+ */
+ public CDORevision readCDORevision(boolean freeze) throws IOException;
+
+ /**
+ * @since 4.0
+ */
+ public CDORevisable readCDORevisable() throws IOException;
+
+ public CDOList readCDOList(EClass owner, EStructuralFeature feature) throws IOException;
+
+ public Object readCDOFeatureValue(EStructuralFeature feature) throws IOException;
+
+ public CDORevisionDelta readCDORevisionDelta() throws IOException;
+
+ public CDOFeatureDelta readCDOFeatureDelta(EClass owner) throws IOException;
+
+ /**
+ * Read either a CDORevision or a primitive value.
+ */
+ public Object readCDORevisionOrPrimitive() throws IOException;
+
+ /**
+ * Read either a CDORevision, a primitive value or a EClass.
+ */
+ public Object readCDORevisionOrPrimitiveOrClassifier() throws IOException;
+
+ // /////////////////////////////////////////////////////////////////////////////////////////////////
+
+ public LockType readCDOLockType() throws IOException;
+
+ /**
+ * @since 4.1
+ */
+ public CDOLockChangeInfo readCDOLockChangeInfo() throws IOException;
+
+ /**
+ * @since 4.1
+ */
+ public CDOLockOwner readCDOLockOwner() throws IOException;
+
+ /**
+ * @since 4.1
+ */
+ public CDOLockState readCDOLockState() throws IOException;
+
+ /**
+ * @since 4.1
+ */
+ public LockArea readCDOLockArea() throws IOException;
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDODataOutput.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDODataOutput.java index 3608ed436a..07f9aa4390 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDODataOutput.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDODataOutput.java @@ -1,168 +1,168 @@ -/* - * Copyright (c) 2004 - 2011 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 - maintenance - */ -package org.eclipse.emf.cdo.common.protocol; - -import org.eclipse.emf.cdo.common.branch.CDOBranch; -import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; -import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; -import org.eclipse.emf.cdo.common.commit.CDOChangeSetData; -import org.eclipse.emf.cdo.common.commit.CDOCommitData; -import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.id.CDOIDProvider; -import org.eclipse.emf.cdo.common.id.CDOIDReference; -import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo; -import org.eclipse.emf.cdo.common.lock.CDOLockOwner; -import org.eclipse.emf.cdo.common.lock.CDOLockState; -import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea; -import org.eclipse.emf.cdo.common.model.CDOClassifierRef; -import org.eclipse.emf.cdo.common.model.CDOPackageInfo; -import org.eclipse.emf.cdo.common.model.CDOPackageRegistry; -import org.eclipse.emf.cdo.common.model.CDOPackageUnit; -import org.eclipse.emf.cdo.common.model.CDOType; -import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch; -import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion; -import org.eclipse.emf.cdo.common.revision.CDOList; -import org.eclipse.emf.cdo.common.revision.CDORevisable; -import org.eclipse.emf.cdo.common.revision.CDORevision; -import org.eclipse.emf.cdo.common.revision.CDORevisionKey; -import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta; -import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; - -import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType; -import org.eclipse.net4j.util.io.ExtendedDataOutput; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EClassifier; -import org.eclipse.emf.ecore.EStructuralFeature; - -import java.io.IOException; - -/** - * Provides I/O methods for writing various CDO data types and concepts to streams. - * - * @author Eike Stepper - * @since 3.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDODataOutput extends ExtendedDataOutput -{ - public CDOPackageRegistry getPackageRegistry(); - - public CDOIDProvider getIDProvider(); - - // ///////////////////////////////////////////////////////////////////////////////////////////////// - - public void writeCDOPackageUnit(CDOPackageUnit packageUnit, boolean withPackages) throws IOException; - - public void writeCDOPackageUnits(CDOPackageUnit... packageUnit) throws IOException; - - public void writeCDOPackageUnitType(CDOPackageUnit.Type type) throws IOException; - - public void writeCDOPackageInfo(CDOPackageInfo packageInfo) throws IOException; - - public void writeCDOClassifierRef(CDOClassifierRef eClassifierRef) throws IOException; - - public void writeCDOClassifierRef(EClassifier eClassifier) throws IOException; - - public void writeCDOPackageURI(String uri) throws IOException; - - public void writeCDOType(CDOType cdoType) throws IOException; - - // ///////////////////////////////////////////////////////////////////////////////////////////////// - - public void writeCDOBranch(CDOBranch branch) throws IOException; - - public void writeCDOBranchPoint(CDOBranchPoint branchPoint) throws IOException; - - public void writeCDOBranchVersion(CDOBranchVersion branchVersion) throws IOException; - - public void writeCDOChangeSetData(CDOChangeSetData changeSetData) throws IOException; - - public void writeCDOCommitData(CDOCommitData commitData) throws IOException; - - public void writeCDOCommitInfo(CDOCommitInfo commitInfo) throws IOException; - - // ///////////////////////////////////////////////////////////////////////////////////////////////// - - public void writeCDOID(CDOID id) throws IOException; - - /** - * @since 4.0 - */ - public void writeCDOIDReference(CDOIDReference idReference) throws IOException; - - /** - * @since 4.0 - */ - public void writeCDOIDAndVersion(CDOIDAndVersion idAndVersion) throws IOException; - - /** - * @since 4.0 - */ - public void writeCDOIDAndBranch(CDOIDAndBranch idAndBranch) throws IOException; - - // ///////////////////////////////////////////////////////////////////////////////////////////////// - - public void writeCDORevisionKey(CDORevisionKey revisionKey) throws IOException; - - public void writeCDORevision(CDORevision revision, int referenceChunk) throws IOException; - - /** - * @since 4.0 - */ - public void writeCDORevisable(CDORevisable revisable) throws IOException; - - public void writeCDOList(EClass owner, EStructuralFeature feature, CDOList list, int referenceChunk) - throws IOException; - - public void writeCDOFeatureValue(EStructuralFeature feature, Object value) throws IOException; - - public void writeCDORevisionDelta(CDORevisionDelta revisionDelta) throws IOException; - - public void writeCDOFeatureDelta(EClass owner, CDOFeatureDelta featureDelta) throws IOException; - - /** - * Write either a CDORevision or a primitive value. - */ - public void writeCDORevisionOrPrimitive(Object value) throws IOException; - - /** - * Write either a CDORevision, a primitive value or a EClass. - */ - public void writeCDORevisionOrPrimitiveOrClassifier(Object value) throws IOException; - - // ///////////////////////////////////////////////////////////////////////////////////////////////// - - public void writeCDOLockType(LockType lockType) throws IOException; - - /** - * @since 4.1 - */ - public void writeCDOLockChangeInfo(CDOLockChangeInfo lockChangeInfo) throws IOException; - - /** - * @since 4.1 - */ - public void writeCDOLockState(CDOLockState lockState) throws IOException; - - /** - * @since 4.1 - */ - public void writeCDOLockOwner(CDOLockOwner lockOwner) throws IOException; - - /** - * @since 4.1 - */ - public void writeCDOLockArea(LockArea lockArea) throws IOException; -} +/*
+ * Copyright (c) 2004 - 2012 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 - maintenance
+ */
+package org.eclipse.emf.cdo.common.protocol;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
+import org.eclipse.emf.cdo.common.commit.CDOCommitData;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDProvider;
+import org.eclipse.emf.cdo.common.id.CDOIDReference;
+import org.eclipse.emf.cdo.common.lock.CDOLockChangeInfo;
+import org.eclipse.emf.cdo.common.lock.CDOLockOwner;
+import org.eclipse.emf.cdo.common.lock.CDOLockState;
+import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockArea;
+import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
+import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
+import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
+import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
+import org.eclipse.emf.cdo.common.model.CDOType;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
+import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
+import org.eclipse.emf.cdo.common.revision.CDOList;
+import org.eclipse.emf.cdo.common.revision.CDORevisable;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
+import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+
+import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
+import org.eclipse.net4j.util.io.ExtendedDataOutput;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import java.io.IOException;
+
+/**
+ * Provides I/O methods for writing various CDO data types and concepts to streams.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDODataOutput extends ExtendedDataOutput
+{
+ public CDOPackageRegistry getPackageRegistry();
+
+ public CDOIDProvider getIDProvider();
+
+ // /////////////////////////////////////////////////////////////////////////////////////////////////
+
+ public void writeCDOPackageUnit(CDOPackageUnit packageUnit, boolean withPackages) throws IOException;
+
+ public void writeCDOPackageUnits(CDOPackageUnit... packageUnit) throws IOException;
+
+ public void writeCDOPackageUnitType(CDOPackageUnit.Type type) throws IOException;
+
+ public void writeCDOPackageInfo(CDOPackageInfo packageInfo) throws IOException;
+
+ public void writeCDOClassifierRef(CDOClassifierRef eClassifierRef) throws IOException;
+
+ public void writeCDOClassifierRef(EClassifier eClassifier) throws IOException;
+
+ public void writeCDOPackageURI(String uri) throws IOException;
+
+ public void writeCDOType(CDOType cdoType) throws IOException;
+
+ // /////////////////////////////////////////////////////////////////////////////////////////////////
+
+ public void writeCDOBranch(CDOBranch branch) throws IOException;
+
+ public void writeCDOBranchPoint(CDOBranchPoint branchPoint) throws IOException;
+
+ public void writeCDOBranchVersion(CDOBranchVersion branchVersion) throws IOException;
+
+ public void writeCDOChangeSetData(CDOChangeSetData changeSetData) throws IOException;
+
+ public void writeCDOCommitData(CDOCommitData commitData) throws IOException;
+
+ public void writeCDOCommitInfo(CDOCommitInfo commitInfo) throws IOException;
+
+ // /////////////////////////////////////////////////////////////////////////////////////////////////
+
+ public void writeCDOID(CDOID id) throws IOException;
+
+ /**
+ * @since 4.0
+ */
+ public void writeCDOIDReference(CDOIDReference idReference) throws IOException;
+
+ /**
+ * @since 4.0
+ */
+ public void writeCDOIDAndVersion(CDOIDAndVersion idAndVersion) throws IOException;
+
+ /**
+ * @since 4.0
+ */
+ public void writeCDOIDAndBranch(CDOIDAndBranch idAndBranch) throws IOException;
+
+ // /////////////////////////////////////////////////////////////////////////////////////////////////
+
+ public void writeCDORevisionKey(CDORevisionKey revisionKey) throws IOException;
+
+ public void writeCDORevision(CDORevision revision, int referenceChunk) throws IOException;
+
+ /**
+ * @since 4.0
+ */
+ public void writeCDORevisable(CDORevisable revisable) throws IOException;
+
+ public void writeCDOList(EClass owner, EStructuralFeature feature, CDOList list, int referenceChunk)
+ throws IOException;
+
+ public void writeCDOFeatureValue(EStructuralFeature feature, Object value) throws IOException;
+
+ public void writeCDORevisionDelta(CDORevisionDelta revisionDelta) throws IOException;
+
+ public void writeCDOFeatureDelta(EClass owner, CDOFeatureDelta featureDelta) throws IOException;
+
+ /**
+ * Write either a CDORevision or a primitive value.
+ */
+ public void writeCDORevisionOrPrimitive(Object value) throws IOException;
+
+ /**
+ * Write either a CDORevision, a primitive value or a EClass.
+ */
+ public void writeCDORevisionOrPrimitiveOrClassifier(Object value) throws IOException;
+
+ // /////////////////////////////////////////////////////////////////////////////////////////////////
+
+ public void writeCDOLockType(LockType lockType) throws IOException;
+
+ /**
+ * @since 4.1
+ */
+ public void writeCDOLockChangeInfo(CDOLockChangeInfo lockChangeInfo) throws IOException;
+
+ /**
+ * @since 4.1
+ */
+ public void writeCDOLockState(CDOLockState lockState) throws IOException;
+
+ /**
+ * @since 4.1
+ */
+ public void writeCDOLockOwner(CDOLockOwner lockOwner) throws IOException;
+
+ /**
+ * @since 4.1
+ */
+ public void writeCDOLockArea(LockArea lockArea) throws IOException;
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDOProtocol.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDOProtocol.java index c23231e8d4..b67dca234f 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDOProtocol.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDOProtocol.java @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.protocol; - -import org.eclipse.emf.cdo.common.CDOCommonSession; - -/** - * The communications protocol associated with a CDO {@link CDOCommonSession session}. - * - * @author Eike Stepper - * @since 2.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.uses {@link CDODataInput} - * @apiviz.uses {@link CDODataOutput} - */ -public interface CDOProtocol -{ - public CDOCommonSession getSession(); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.protocol;
+
+import org.eclipse.emf.cdo.common.CDOCommonSession;
+
+/**
+ * The communications protocol associated with a CDO {@link CDOCommonSession session}.
+ *
+ * @author Eike Stepper
+ * @since 2.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.uses {@link CDODataInput}
+ * @apiviz.uses {@link CDODataOutput}
+ */
+public interface CDOProtocol
+{
+ public CDOCommonSession getSession();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDOProtocolConstants.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDOProtocolConstants.java index 260b3f764c..d23efa66c5 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDOProtocolConstants.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDOProtocolConstants.java @@ -1,337 +1,337 @@ -/* - * Copyright (c) 2004 - 2011 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 230832 - * Simon McDuff - bug 233490 - * Simon McDuff - bug 213402 - */ -package org.eclipse.emf.cdo.common.protocol; - -/** - * Symbolic protocol constants commonly used in CDO. - * - * @author Eike Stepper - * @since 2.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDOProtocolConstants -{ - public static final String PROTOCOL_NAME = "cdo"; //$NON-NLS-1$ - - // ////////////////////////////////////////////////////////////////////// - // Signal IDs - - public static final short SIGNAL_OPEN_SESSION = 1; - - public static final short SIGNAL_AUTHENTICATION = 2; - - /** - * @since 3.0 - */ - public static final short SIGNAL_OPEN_VIEW = 3; - - /** - * @since 4.0 - */ - public static final short SIGNAL_SWITCH_TARGET = 4; - - /** - * @since 3.0 - */ - public static final short SIGNAL_CLOSE_VIEW = 5; - - public static final short SIGNAL_LOAD_PACKAGES = 6; - - /** - * @since 3.0 - */ - public static final short SIGNAL_LOAD_REVISIONS = 7; - - public static final short SIGNAL_LOAD_REVISION_BY_VERSION = 8; - - public static final short SIGNAL_LOAD_CHUNK = 9; - - public static final short SIGNAL_COMMIT_NOTIFICATION = 10; - - public static final short SIGNAL_COMMIT_TRANSACTION = 11; - - /** - * @since 3.0 - */ - public static final short SIGNAL_COMMIT_DELEGATION = 12; - - /** - * @since 3.0 - */ - public static final short SIGNAL_XA_COMMIT_TRANSACTION_PHASE1 = 13; - - /** - * @since 3.0 - */ - public static final short SIGNAL_XA_COMMIT_TRANSACTION_PHASE2 = 14; - - /** - * @since 3.0 - */ - public static final short SIGNAL_XA_COMMIT_TRANSACTION_PHASE3 = 15; - - /** - * @since 3.0 - */ - public static final short SIGNAL_XA_COMMIT_TRANSACTION_CANCEL = 16; - - public static final short SIGNAL_QUERY = 17; - - public static final short SIGNAL_QUERY_CANCEL = 18; - - /** - * @since 3.0 - */ - public static final short SIGNAL_REFRESH_SESSION = 19; - - /** - * @since 3.0 - */ - public static final short SIGNAL_DISABLE_PASSIVE_UPDATE = 20; - - /** - * @since 3.0 - */ - public static final short SIGNAL_SET_PASSIVE_UPDATE_MODE = 21; - - public static final short SIGNAL_CHANGE_SUBSCRIPTION = 22; - - public static final short SIGNAL_REPOSITORY_TIME = 23; - - public static final short SIGNAL_LOCK_OBJECTS = 24; - - public static final short SIGNAL_UNLOCK_OBJECTS = 25; - - public static final short SIGNAL_OBJECT_LOCKED = 26; - - /** - * @since 4.0 - */ - public static final short SIGNAL_LOCK_AREA = 27; - - public static final short SIGNAL_GET_REMOTE_SESSIONS = 28; - - /** - * @since 3.0 - */ - public static final short SIGNAL_REMOTE_MESSAGE = 29; - - /** - * @since 3.0 - */ - public static final short SIGNAL_REMOTE_MESSAGE_NOTIFICATION = 30; - - public static final short SIGNAL_UNSUBSCRIBE_REMOTE_SESSIONS = 31; - - public static final short SIGNAL_REMOTE_SESSION_NOTIFICATION = 32; - - /** - * @since 3.0 - */ - public static final short SIGNAL_CREATE_BRANCH = 33; - - /** - * @since 3.0 - */ - public static final short SIGNAL_LOAD_BRANCH = 34; - - /** - * @since 3.0 - */ - public static final short SIGNAL_LOAD_SUB_BRANCHES = 35; - - /** - * @since 3.0 - */ - public static final short SIGNAL_LOAD_BRANCHES = 36; - - /** - * @since 3.0 - */ - public static final short SIGNAL_REPOSITORY_TYPE_NOTIFICATION = 37; - - /** - * @since 3.0 - */ - public static final short SIGNAL_REPOSITORY_STATE_NOTIFICATION = 38; - - /** - * @since 3.0 - */ - public static final short SIGNAL_BRANCH_NOTIFICATION = 39; - - /** - * @since 3.0 - */ - public static final short SIGNAL_LOAD_COMMIT_INFOS = 40; - - /** - * @since 3.0 - */ - public static final short SIGNAL_LOAD_COMMIT_DATA = 41; - - /** - * @since 3.0 - */ - public static final short SIGNAL_REPLICATE_REPOSITORY = 42; - - /** - * @since 3.0 - */ - public static final short SIGNAL_REPLICATE_REPOSITORY_RAW = 43; - - /** - * @since 3.0 - */ - public static final short SIGNAL_LOAD_CHANGE_SETS = 44; - - /** - * @since 3.0 - */ - public static final short SIGNAL_LOAD_MERGE_DATA = 45; - - /** - * @since 4.0 - */ - public static final short SIGNAL_QUERY_LOBS = 46; - - /** - * @since 4.0 - */ - public static final short SIGNAL_LOAD_LOB = 47; - - /** - * @since 4.0 - */ - public static final short SIGNAL_HANDLE_REVISIONS = 48; - - /** - * @since 4.1 - */ - public static final short SIGNAL_LOCK_DELEGATION = 49; - - /** - * @since 4.1 - */ - public static final short SIGNAL_UNLOCK_DELEGATION = 50; - - /** - * @since 4.1 - */ - public static final short SIGNAL_LOCK_NOTIFICATION = 51; - - /** - * @since 4.1 - */ - public static final short SIGNAL_LOCK_STATE = 52; - - /** - * @since 4.1 - */ - public static final short SIGNAL_ENABLE_LOCK_NOTIFICATION = 53; - - /** - * @since 4.1 - */ - public static final short SIGNAL_SET_LOCK_NOTIFICATION_MODE = 54; - - // ////////////////////////////////////////////////////////////////////// - // Session Refresh - - /** - * @since 3.0 - */ - public static final byte REFRESH_FINISHED = 0; - - /** - * @since 3.0 - */ - public static final byte REFRESH_PACKAGE_UNIT = 1; - - /** - * @since 3.0 - */ - public static final byte REFRESH_CHANGED_OBJECT = 2; - - /** - * @since 3.0 - */ - public static final byte REFRESH_DETACHED_OBJECT = 3; - - // ////////////////////////////////////////////////////////////////////// - // Query Support - - public static final String QUERY_LANGUAGE_RESOURCES = "resources"; //$NON-NLS-1$ - - public static final String QUERY_LANGUAGE_RESOURCES_FOLDER_ID = "folder"; //$NON-NLS-1$ - - public static final String QUERY_LANGUAGE_RESOURCES_EXACT_MATCH = "exactMatch"; //$NON-NLS-1$ - - /** - * @since 3.0 - */ - public static final String QUERY_LANGUAGE_XREFS = "xrefs"; //$NON-NLS-1$ - - /** - * @since 3.0 - */ - public static final String QUERY_LANGUAGE_XREFS_SOURCE_REFERENCES = "sourceReferences"; //$NON-NLS-1$ - - // ////////////////////////////////////////////////////////////////////// - // Locking Objects - - public static final int RELEASE_ALL_LOCKS = -1; - - // ////////////////////////////////////////////////////////////////////// - // Remote Sessions - - public static final int NO_MORE_REMOTE_SESSIONS = -1; - - public static final byte REMOTE_SESSION_OPENED = 1; - - public static final byte REMOTE_SESSION_CLOSED = 2; - - public static final byte REMOTE_SESSION_SUBSCRIBED = 3; - - public static final byte REMOTE_SESSION_UNSUBSCRIBED = 4; - - /** - * @since 3.0 - */ - public static final byte REMOTE_SESSION_CUSTOM_DATA = 5; - - // ////////////////////////////////////////////////////////////////////// - // Syncing - - /** - * @since 3.0 - */ - public static final byte REPLICATE_FINISHED = 0; - - /** - * @since 3.0 - */ - public static final byte REPLICATE_BRANCH = 1; - - /** - * @since 3.0 - */ - public static final byte REPLICATE_COMMIT = 2; - - /** - * @since 4.1 - */ - public static final byte REPLICATE_LOCKAREA = 3; -} +/*
+ * Copyright (c) 2004 - 2012 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 230832
+ * Simon McDuff - bug 233490
+ * Simon McDuff - bug 213402
+ */
+package org.eclipse.emf.cdo.common.protocol;
+
+/**
+ * Symbolic protocol constants commonly used in CDO.
+ *
+ * @author Eike Stepper
+ * @since 2.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDOProtocolConstants
+{
+ public static final String PROTOCOL_NAME = "cdo"; //$NON-NLS-1$
+
+ // //////////////////////////////////////////////////////////////////////
+ // Signal IDs
+
+ public static final short SIGNAL_OPEN_SESSION = 1;
+
+ public static final short SIGNAL_AUTHENTICATION = 2;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_OPEN_VIEW = 3;
+
+ /**
+ * @since 4.0
+ */
+ public static final short SIGNAL_SWITCH_TARGET = 4;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_CLOSE_VIEW = 5;
+
+ public static final short SIGNAL_LOAD_PACKAGES = 6;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_LOAD_REVISIONS = 7;
+
+ public static final short SIGNAL_LOAD_REVISION_BY_VERSION = 8;
+
+ public static final short SIGNAL_LOAD_CHUNK = 9;
+
+ public static final short SIGNAL_COMMIT_NOTIFICATION = 10;
+
+ public static final short SIGNAL_COMMIT_TRANSACTION = 11;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_COMMIT_DELEGATION = 12;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_XA_COMMIT_TRANSACTION_PHASE1 = 13;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_XA_COMMIT_TRANSACTION_PHASE2 = 14;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_XA_COMMIT_TRANSACTION_PHASE3 = 15;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_XA_COMMIT_TRANSACTION_CANCEL = 16;
+
+ public static final short SIGNAL_QUERY = 17;
+
+ public static final short SIGNAL_QUERY_CANCEL = 18;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_REFRESH_SESSION = 19;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_DISABLE_PASSIVE_UPDATE = 20;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_SET_PASSIVE_UPDATE_MODE = 21;
+
+ public static final short SIGNAL_CHANGE_SUBSCRIPTION = 22;
+
+ public static final short SIGNAL_REPOSITORY_TIME = 23;
+
+ public static final short SIGNAL_LOCK_OBJECTS = 24;
+
+ public static final short SIGNAL_UNLOCK_OBJECTS = 25;
+
+ public static final short SIGNAL_OBJECT_LOCKED = 26;
+
+ /**
+ * @since 4.0
+ */
+ public static final short SIGNAL_LOCK_AREA = 27;
+
+ public static final short SIGNAL_GET_REMOTE_SESSIONS = 28;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_REMOTE_MESSAGE = 29;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_REMOTE_MESSAGE_NOTIFICATION = 30;
+
+ public static final short SIGNAL_UNSUBSCRIBE_REMOTE_SESSIONS = 31;
+
+ public static final short SIGNAL_REMOTE_SESSION_NOTIFICATION = 32;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_CREATE_BRANCH = 33;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_LOAD_BRANCH = 34;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_LOAD_SUB_BRANCHES = 35;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_LOAD_BRANCHES = 36;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_REPOSITORY_TYPE_NOTIFICATION = 37;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_REPOSITORY_STATE_NOTIFICATION = 38;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_BRANCH_NOTIFICATION = 39;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_LOAD_COMMIT_INFOS = 40;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_LOAD_COMMIT_DATA = 41;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_REPLICATE_REPOSITORY = 42;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_REPLICATE_REPOSITORY_RAW = 43;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_LOAD_CHANGE_SETS = 44;
+
+ /**
+ * @since 3.0
+ */
+ public static final short SIGNAL_LOAD_MERGE_DATA = 45;
+
+ /**
+ * @since 4.0
+ */
+ public static final short SIGNAL_QUERY_LOBS = 46;
+
+ /**
+ * @since 4.0
+ */
+ public static final short SIGNAL_LOAD_LOB = 47;
+
+ /**
+ * @since 4.0
+ */
+ public static final short SIGNAL_HANDLE_REVISIONS = 48;
+
+ /**
+ * @since 4.1
+ */
+ public static final short SIGNAL_LOCK_DELEGATION = 49;
+
+ /**
+ * @since 4.1
+ */
+ public static final short SIGNAL_UNLOCK_DELEGATION = 50;
+
+ /**
+ * @since 4.1
+ */
+ public static final short SIGNAL_LOCK_NOTIFICATION = 51;
+
+ /**
+ * @since 4.1
+ */
+ public static final short SIGNAL_LOCK_STATE = 52;
+
+ /**
+ * @since 4.1
+ */
+ public static final short SIGNAL_ENABLE_LOCK_NOTIFICATION = 53;
+
+ /**
+ * @since 4.1
+ */
+ public static final short SIGNAL_SET_LOCK_NOTIFICATION_MODE = 54;
+
+ // //////////////////////////////////////////////////////////////////////
+ // Session Refresh
+
+ /**
+ * @since 3.0
+ */
+ public static final byte REFRESH_FINISHED = 0;
+
+ /**
+ * @since 3.0
+ */
+ public static final byte REFRESH_PACKAGE_UNIT = 1;
+
+ /**
+ * @since 3.0
+ */
+ public static final byte REFRESH_CHANGED_OBJECT = 2;
+
+ /**
+ * @since 3.0
+ */
+ public static final byte REFRESH_DETACHED_OBJECT = 3;
+
+ // //////////////////////////////////////////////////////////////////////
+ // Query Support
+
+ public static final String QUERY_LANGUAGE_RESOURCES = "resources"; //$NON-NLS-1$
+
+ public static final String QUERY_LANGUAGE_RESOURCES_FOLDER_ID = "folder"; //$NON-NLS-1$
+
+ public static final String QUERY_LANGUAGE_RESOURCES_EXACT_MATCH = "exactMatch"; //$NON-NLS-1$
+
+ /**
+ * @since 3.0
+ */
+ public static final String QUERY_LANGUAGE_XREFS = "xrefs"; //$NON-NLS-1$
+
+ /**
+ * @since 3.0
+ */
+ public static final String QUERY_LANGUAGE_XREFS_SOURCE_REFERENCES = "sourceReferences"; //$NON-NLS-1$
+
+ // //////////////////////////////////////////////////////////////////////
+ // Locking Objects
+
+ public static final int RELEASE_ALL_LOCKS = -1;
+
+ // //////////////////////////////////////////////////////////////////////
+ // Remote Sessions
+
+ public static final int NO_MORE_REMOTE_SESSIONS = -1;
+
+ public static final byte REMOTE_SESSION_OPENED = 1;
+
+ public static final byte REMOTE_SESSION_CLOSED = 2;
+
+ public static final byte REMOTE_SESSION_SUBSCRIBED = 3;
+
+ public static final byte REMOTE_SESSION_UNSUBSCRIBED = 4;
+
+ /**
+ * @since 3.0
+ */
+ public static final byte REMOTE_SESSION_CUSTOM_DATA = 5;
+
+ // //////////////////////////////////////////////////////////////////////
+ // Syncing
+
+ /**
+ * @since 3.0
+ */
+ public static final byte REPLICATE_FINISHED = 0;
+
+ /**
+ * @since 3.0
+ */
+ public static final byte REPLICATE_BRANCH = 1;
+
+ /**
+ * @since 3.0
+ */
+ public static final byte REPLICATE_COMMIT = 2;
+
+ /**
+ * @since 4.1
+ */
+ public static final byte REPLICATE_LOCKAREA = 3;
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/package-info.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/package-info.java index aa7b150166..cdc5429d8a 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/package-info.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/package-info.java @@ -1,5 +1,5 @@ /*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 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
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOAllRevisionsProvider.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOAllRevisionsProvider.java index a94148929f..82768439d4 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOAllRevisionsProvider.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOAllRevisionsProvider.java @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.revision; - -import org.eclipse.emf.cdo.common.branch.CDOBranch; - -import java.util.List; -import java.util.Map; - -/** - * Provides consumers with all {@link CDORevision revisions} available in an instance of this interface. - * - * @author Eike Stepper - * @since 3.0 - * @apiviz.exclude - */ -public interface CDOAllRevisionsProvider -{ - public Map<CDOBranch, List<CDORevision>> getAllRevisions(); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.revision;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Provides consumers with all {@link CDORevision revisions} available in an instance of this interface.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ * @apiviz.exclude
+ */
+public interface CDOAllRevisionsProvider
+{
+ public Map<CDOBranch, List<CDORevision>> getAllRevisions();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOElementProxy.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOElementProxy.java index 3865b4b7db..4fe98a5d37 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOElementProxy.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOElementProxy.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2004 - 2011 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 - maintenance - */ -package org.eclipse.emf.cdo.common.revision; - -/** - * A moveable placeholder for the element of a {@link CDOList list} at a specified {@link #getIndex() index}. - * - * @author Eike Stepper - * @since 4.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDOElementProxy -{ - public int getIndex(); -} +/*
+ * Copyright (c) 2004 - 2012 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 - maintenance
+ */
+package org.eclipse.emf.cdo.common.revision;
+
+/**
+ * A moveable placeholder for the element of a {@link CDOList list} at a specified {@link #getIndex() index}.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDOElementProxy
+{
+ public int getIndex();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOIDAndBranch.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOIDAndBranch.java index f1e295e308..a187a22891 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOIDAndBranch.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOIDAndBranch.java @@ -1,30 +1,30 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.revision; - -import org.eclipse.emf.cdo.common.branch.CDOBranch; -import org.eclipse.emf.cdo.common.id.CDOID; - -/** - * An {@link CDOID ID} / {@link CDOBranch branch} pair. - * - * @author Eike Stepper - * @since 4.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.exclude - */ -public interface CDOIDAndBranch -{ - public CDOID getID(); - - public CDOBranch getBranch(); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.revision;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.id.CDOID;
+
+/**
+ * An {@link CDOID ID} / {@link CDOBranch branch} pair.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.exclude
+ */
+public interface CDOIDAndBranch
+{
+ public CDOID getID();
+
+ public CDOBranch getBranch();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOIDAndVersion.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOIDAndVersion.java index 1bce44a0f7..14d6b87d4b 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOIDAndVersion.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOIDAndVersion.java @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.revision; - -import org.eclipse.emf.cdo.common.id.CDOID; - -/** - * An {@link CDOID ID} / version pair. - * - * @author Eike Stepper - * @since 4.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDOIDAndVersion -{ - public CDOID getID(); - - public int getVersion(); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.revision;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+
+/**
+ * An {@link CDOID ID} / version pair.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDOIDAndVersion
+{
+ public CDOID getID();
+
+ public int getVersion();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOList.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOList.java index 12c0870bcf..0b9b27df27 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOList.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOList.java @@ -1,41 +1,41 @@ -/* - * Copyright (c) 2004 - 2011 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: - * Simon McDuff - initial API and implementation - * Eike Stepper - maintenance - */ -package org.eclipse.emf.cdo.common.revision; - -import org.eclipse.net4j.util.collection.MoveableList; - -import org.eclipse.emf.common.util.EList; - -/** - * A {@link MoveableList moveable} {@link EList}. - * - * @author Simon McDuff - * @since 2.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.uses {@link CDOElementProxy} - - contains - */ -public interface CDOList extends MoveableList<Object>, EList<Object> -{ - /** - * Returns the element at position index of this list and optionally resolves proxies (see CDOElementProxy). - * <p> - * - * @param index - * The position of the element to return from this list. - * @param resolve - * A value of <code>false</code> indicates that {@link CDORevisionUtil#UNINITIALIZED} may be returned for - * unresolved elements. A value of <code>true</code> indicates that it should behave identical to - * {@link CDOList#get(int)}. - */ - public Object get(int index, boolean resolve); -} +/*
+ * Copyright (c) 2004 - 2012 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:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.common.revision;
+
+import org.eclipse.net4j.util.collection.MoveableList;
+
+import org.eclipse.emf.common.util.EList;
+
+/**
+ * A {@link MoveableList moveable} {@link EList}.
+ *
+ * @author Simon McDuff
+ * @since 2.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.uses {@link CDOElementProxy} - - contains
+ */
+public interface CDOList extends MoveableList<Object>, EList<Object>
+{
+ /**
+ * Returns the element at position index of this list and optionally resolves proxies (see CDOElementProxy).
+ * <p>
+ *
+ * @param index
+ * The position of the element to return from this list.
+ * @param resolve
+ * A value of <code>false</code> indicates that {@link CDORevisionUtil#UNINITIALIZED} may be returned for
+ * unresolved elements. A value of <code>true</code> indicates that it should behave identical to
+ * {@link CDOList#get(int)}.
+ */
+ public Object get(int index, boolean resolve);
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOListFactory.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOListFactory.java index 96542128c8..f67b58a5e0 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOListFactory.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOListFactory.java @@ -1,28 +1,28 @@ -/* - * Copyright (c) 2004 - 2011 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: - * Simon McDuff - initial API and implementation - * Eike Stepper - maintenance - */ -package org.eclipse.emf.cdo.common.revision; - -import org.eclipse.emf.cdo.internal.common.revision.CDOListImpl; - -/** - * Creates {@link CDOList list} instances. - * - * @author Simon McDuff - * @since 2.0 - * @apiviz.uses {@link CDOList} - - creates - */ -public interface CDOListFactory -{ - public static final CDOListFactory DEFAULT = CDOListImpl.FACTORY; - - public CDOList createList(int intitialCapacity, int size, int initialChunk); -} +/*
+ * Copyright (c) 2004 - 2012 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:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.common.revision;
+
+import org.eclipse.emf.cdo.internal.common.revision.CDOListImpl;
+
+/**
+ * Creates {@link CDOList list} instances.
+ *
+ * @author Simon McDuff
+ * @since 2.0
+ * @apiviz.uses {@link CDOList} - - creates
+ */
+public interface CDOListFactory
+{
+ public static final CDOListFactory DEFAULT = CDOListImpl.FACTORY;
+
+ public CDOList createList(int intitialCapacity, int size, int initialChunk);
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOListResolver.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOListResolver.java index cec257d209..98b15be4b2 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOListResolver.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOListResolver.java @@ -1,37 +1,37 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.revision; - -import org.eclipse.emf.cdo.common.id.CDOID; - -import org.eclipse.emf.ecore.EStructuralFeature; - -/** - * A strategy that specifies which list elememts must be present (loaded) in a {@link CDOID} list of a - * {@link CDORevision revision} when a certain list index is accessed. Implementations of this interface can control the - * exact characteristics of a certain <em>partial collection loading</em> strategy. - * - * @author Eike Stepper - * @since 4.0 - * @apiviz.uses {@link CDOList} - - resolves - */ -public interface CDOListResolver -{ - /** - * Defines a strategy to be used when the collection needs to resolve one element. - */ - public Object resolveProxy(CDORevision revision, EStructuralFeature feature, int accessIndex, int serverIndex); - - /** - * Defines a strategy to be used when the collection needs to resolve all elements. - */ - public void resolveAllProxies(CDORevision revision, EStructuralFeature feature); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.revision;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * A strategy that specifies which list elememts must be present (loaded) in a {@link CDOID} list of a
+ * {@link CDORevision revision} when a certain list index is accessed. Implementations of this interface can control the
+ * exact characteristics of a certain <em>partial collection loading</em> strategy.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ * @apiviz.uses {@link CDOList} - - resolves
+ */
+public interface CDOListResolver
+{
+ /**
+ * Defines a strategy to be used when the collection needs to resolve one element.
+ */
+ public Object resolveProxy(CDORevision revision, EStructuralFeature feature, int accessIndex, int serverIndex);
+
+ /**
+ * Defines a strategy to be used when the collection needs to resolve all elements.
+ */
+ public void resolveAllProxies(CDORevision revision, EStructuralFeature feature);
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisable.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisable.java index b67eda9774..0864240027 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisable.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisable.java @@ -1,5 +1,5 @@ /*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 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
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevision.java index ee535b97f7..cfb54d3a1d 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevision.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevision.java @@ -1,103 +1,103 @@ -/* - * Copyright (c) 2004 - 2011 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 - delta support - */ -package org.eclipse.emf.cdo.common.revision; - -import org.eclipse.emf.cdo.common.branch.CDOBranch; -import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; -import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; -import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; -import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; - -/** - * Encapsulates the immutable system information of a <b>single</b> CDO {@link EObject object} between two - * {@link CDOCommitInfo commits} in a {@link CDOBranch branch} and provides access to its modeled - * {@link CDORevisionData data}. - * - * @author Eike Stepper - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.landmark - * @apiviz.has {@link CDORevisionData} - */ -public interface CDORevision extends CDORevisionKey, CDORevisable -{ - /** - * @since 3.0 - */ - public static final int MAIN_BRANCH_ID = CDOBranch.MAIN_BRANCH_ID; - - /** - * @since 3.0 - */ - public static final int FIRST_VERSION = CDOBranchVersion.FIRST_VERSION; - - public static final int UNCHUNKED = -1; - - /** - * @since 3.0 - */ - public static final int DEPTH_NONE = 0; - - /** - * @since 3.0 - */ - public static final int DEPTH_INFINITE = -1; - - /** - * @since 2.0 - */ - public EClass getEClass(); - - /** - * Returns <code>true</code> exactly if {@link #getTimeStamp()} does not return {@link #UNSPECIFIED_DATE}, - * <code>false</code> otherwise. - * - * @since 3.0 - */ - public boolean isHistorical(); - - public boolean isValid(long timeStamp); - - /** - * @since 4.0 - */ - public boolean isValid(CDOBranchPoint branchPoint); - - /** - * @since 2.0 - */ - public boolean isResourceNode(); - - /** - * @since 2.0 - */ - public boolean isResourceFolder(); - - public boolean isResource(); - - /** - * @since 2.0 - */ - public CDORevisionData data(); - - public CDORevisionDelta compare(CDORevision origin); - - public void merge(CDORevisionDelta delta); - - /** - * @since 2.0 - */ - public CDORevision copy(); -} +/*
+ * Copyright (c) 2004 - 2012 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 - delta support
+ */
+package org.eclipse.emf.cdo.common.revision;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+
+/**
+ * Encapsulates the immutable system information of a <b>single</b> CDO {@link EObject object} between two
+ * {@link CDOCommitInfo commits} in a {@link CDOBranch branch} and provides access to its modeled
+ * {@link CDORevisionData data}.
+ *
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.landmark
+ * @apiviz.has {@link CDORevisionData}
+ */
+public interface CDORevision extends CDORevisionKey, CDORevisable
+{
+ /**
+ * @since 3.0
+ */
+ public static final int MAIN_BRANCH_ID = CDOBranch.MAIN_BRANCH_ID;
+
+ /**
+ * @since 3.0
+ */
+ public static final int FIRST_VERSION = CDOBranchVersion.FIRST_VERSION;
+
+ public static final int UNCHUNKED = -1;
+
+ /**
+ * @since 3.0
+ */
+ public static final int DEPTH_NONE = 0;
+
+ /**
+ * @since 3.0
+ */
+ public static final int DEPTH_INFINITE = -1;
+
+ /**
+ * @since 2.0
+ */
+ public EClass getEClass();
+
+ /**
+ * Returns <code>true</code> exactly if {@link #getTimeStamp()} does not return {@link #UNSPECIFIED_DATE},
+ * <code>false</code> otherwise.
+ *
+ * @since 3.0
+ */
+ public boolean isHistorical();
+
+ public boolean isValid(long timeStamp);
+
+ /**
+ * @since 4.0
+ */
+ public boolean isValid(CDOBranchPoint branchPoint);
+
+ /**
+ * @since 2.0
+ */
+ public boolean isResourceNode();
+
+ /**
+ * @since 2.0
+ */
+ public boolean isResourceFolder();
+
+ public boolean isResource();
+
+ /**
+ * @since 2.0
+ */
+ public CDORevisionData data();
+
+ public CDORevisionDelta compare(CDORevision origin);
+
+ public void merge(CDORevisionDelta delta);
+
+ /**
+ * @since 2.0
+ */
+ public CDORevision copy();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionCache.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionCache.java index 2211737463..7bd85e287a 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionCache.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionCache.java @@ -1,83 +1,83 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.revision; - -import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; -import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.internal.common.revision.NOOPRevisionCache; - -import org.eclipse.net4j.util.event.IEvent; -import org.eclipse.net4j.util.event.INotifier; - -import org.eclipse.emf.ecore.EClass; - -import java.util.List; - -/** - * Caches {@link CDORevision revisions} and possibly {@link EvictionEvent evicts} those that are no longer strongly - * referenced when free memory runs low. - * - * @author Eike Stepper - * @since 4.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.composedOf {@link CDORevision} - */ -public interface CDORevisionCache extends CDORevisionCacheAdder, INotifier -{ - /** - * @since 3.0 - */ - public static final CDORevisionCache NOOP = NOOPRevisionCache.INSTANCE; - - public EClass getObjectType(CDOID id); - - /** - * @since 3.0 - */ - public CDORevision getRevision(CDOID id, CDOBranchPoint branchPoint); - - /** - * @since 3.0 - */ - public CDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion); - - /** - * Returns a list of {@link CDORevision revisions} that are current. - * - * @since 3.0 - */ - public List<CDORevision> getCurrentRevisions(); - - /** - * An {@link IEvent event} fired from a {@link CDORevisionCache revision cache} for {@link CDORevision revisions} that - * are evicted because they are no longer strongly referenced when free memory runs low. - * - * @author Eike Stepper - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ - public interface EvictionEvent extends IEvent, CDORevisionKey - { - /** - * @since 3.0 - */ - public CDORevisionCache getSource(); - - /** - * May be <code>null</code> for certain cache implementations. - * - * @since 3.0 - */ - public CDORevision getRevision(); - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.revision;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.internal.common.revision.NOOPRevisionCache;
+
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.INotifier;
+
+import org.eclipse.emf.ecore.EClass;
+
+import java.util.List;
+
+/**
+ * Caches {@link CDORevision revisions} and possibly {@link EvictionEvent evicts} those that are no longer strongly
+ * referenced when free memory runs low.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.composedOf {@link CDORevision}
+ */
+public interface CDORevisionCache extends CDORevisionCacheAdder, INotifier
+{
+ /**
+ * @since 3.0
+ */
+ public static final CDORevisionCache NOOP = NOOPRevisionCache.INSTANCE;
+
+ public EClass getObjectType(CDOID id);
+
+ /**
+ * @since 3.0
+ */
+ public CDORevision getRevision(CDOID id, CDOBranchPoint branchPoint);
+
+ /**
+ * @since 3.0
+ */
+ public CDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion);
+
+ /**
+ * Returns a list of {@link CDORevision revisions} that are current.
+ *
+ * @since 3.0
+ */
+ public List<CDORevision> getCurrentRevisions();
+
+ /**
+ * An {@link IEvent event} fired from a {@link CDORevisionCache revision cache} for {@link CDORevision revisions} that
+ * are evicted because they are no longer strongly referenced when free memory runs low.
+ *
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+ public interface EvictionEvent extends IEvent, CDORevisionKey
+ {
+ /**
+ * @since 3.0
+ */
+ public CDORevisionCache getSource();
+
+ /**
+ * May be <code>null</code> for certain cache implementations.
+ *
+ * @since 3.0
+ */
+ public CDORevision getRevision();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionCacheAdder.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionCacheAdder.java index e517a00da6..cb002b5e3b 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionCacheAdder.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionCacheAdder.java @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.revision; - -/** - * An entity that {@link CDORevision revisions} can be added to. - * - * @author Eike Stepper - * @since 4.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDORevisionCacheAdder -{ - /** - * Adds the given revision to this cache. - */ - public void addRevision(CDORevision revision); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.revision;
+
+/**
+ * An entity that {@link CDORevision revisions} can be added to.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDORevisionCacheAdder
+{
+ /**
+ * Adds the given revision to this cache.
+ */
+ public void addRevision(CDORevision revision);
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionData.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionData.java index 6dbf2b0f53..d38a2740b5 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionData.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionData.java @@ -1,112 +1,112 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.revision; - -import org.eclipse.emf.cdo.common.id.CDOID; - -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.impl.BasicEObjectImpl; -import org.eclipse.emf.ecore.impl.EStoreEObjectImpl; - -/** - * Encapsulates the modeled information and the EMF system values of a {@link CDORevision revision}. - * - * @author Eike Stepper - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDORevisionData -{ - /** - * The equivalent of <code>EStructuralFeatureImpl.NIL</code> (i.e. explicit <code>null</code>). - * - * @since 3.0 - */ - public static final Object NIL = EStoreEObjectImpl.NIL; - - /** - * @since 2.0 - */ - public CDORevision revision(); - - public CDOID getResourceID(); - - /** - * @since 2.0 - */ - public Object getContainerID(); - - /** - * Provides the input to the calculation of the feature in the container revision that actually holds this revision. - * <p> - * <b>Usage Example:</b> - * <p> - * <code><pre> - * CDORevision revision = ...; - * CDORevision container = <i>Util.getRevision</i>(revision.data().getContainerID()); - * - * int containingFeatureID = revision.data().getContainingFeatureID(); - * - * EStructuralFeature feature = containingFeatureID <= InternalEObject.EOPPOSITE_FEATURE_BASE ? - * container.getEClass().getEStructuralFeature(InternalEObject.EOPPOSITE_FEATURE_BASE - containingFeatureID) : - * ((EReference)revision.getEClass().getEStructuralFeature(containingFeatureID)).getEOpposite();</pre></code> - * - * @see BasicEObjectImpl#eContainingFeature() - * @see #getContainerID() - */ - public int getContainingFeatureID(); - - /** - * @since 2.0 - */ - public Object get(EStructuralFeature feature, int index); - - /** - * @since 2.0 - */ - public int size(EStructuralFeature feature); - - /** - * @since 2.0 - */ - public boolean isEmpty(EStructuralFeature feature); - - /** - * @since 2.0 - */ - public boolean contains(EStructuralFeature feature, Object value); - - /** - * @since 2.0 - */ - public int indexOf(EStructuralFeature feature, Object value); - - /** - * @since 2.0 - */ - public int lastIndexOf(EStructuralFeature feature, Object value); - - /** - * @since 2.0 - */ - public <T> T[] toArray(EStructuralFeature feature, T[] array); - - /** - * @since 2.0 - */ - public Object[] toArray(EStructuralFeature feature); - - /** - * @since 2.0 - */ - public int hashCode(EStructuralFeature feature); - -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.revision;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.impl.BasicEObjectImpl;
+import org.eclipse.emf.ecore.impl.EStoreEObjectImpl;
+
+/**
+ * Encapsulates the modeled information and the EMF system values of a {@link CDORevision revision}.
+ *
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDORevisionData
+{
+ /**
+ * The equivalent of <code>EStructuralFeatureImpl.NIL</code> (i.e. explicit <code>null</code>).
+ *
+ * @since 3.0
+ */
+ public static final Object NIL = EStoreEObjectImpl.NIL;
+
+ /**
+ * @since 2.0
+ */
+ public CDORevision revision();
+
+ public CDOID getResourceID();
+
+ /**
+ * @since 2.0
+ */
+ public Object getContainerID();
+
+ /**
+ * Provides the input to the calculation of the feature in the container revision that actually holds this revision.
+ * <p>
+ * <b>Usage Example:</b>
+ * <p>
+ * <code><pre>
+ * CDORevision revision = ...;
+ * CDORevision container = <i>Util.getRevision</i>(revision.data().getContainerID());
+ *
+ * int containingFeatureID = revision.data().getContainingFeatureID();
+ *
+ * EStructuralFeature feature = containingFeatureID <= InternalEObject.EOPPOSITE_FEATURE_BASE ?
+ * container.getEClass().getEStructuralFeature(InternalEObject.EOPPOSITE_FEATURE_BASE - containingFeatureID) :
+ * ((EReference)revision.getEClass().getEStructuralFeature(containingFeatureID)).getEOpposite();</pre></code>
+ *
+ * @see BasicEObjectImpl#eContainingFeature()
+ * @see #getContainerID()
+ */
+ public int getContainingFeatureID();
+
+ /**
+ * @since 2.0
+ */
+ public Object get(EStructuralFeature feature, int index);
+
+ /**
+ * @since 2.0
+ */
+ public int size(EStructuralFeature feature);
+
+ /**
+ * @since 2.0
+ */
+ public boolean isEmpty(EStructuralFeature feature);
+
+ /**
+ * @since 2.0
+ */
+ public boolean contains(EStructuralFeature feature, Object value);
+
+ /**
+ * @since 2.0
+ */
+ public int indexOf(EStructuralFeature feature, Object value);
+
+ /**
+ * @since 2.0
+ */
+ public int lastIndexOf(EStructuralFeature feature, Object value);
+
+ /**
+ * @since 2.0
+ */
+ public <T> T[] toArray(EStructuralFeature feature, T[] array);
+
+ /**
+ * @since 2.0
+ */
+ public Object[] toArray(EStructuralFeature feature);
+
+ /**
+ * @since 2.0
+ */
+ public int hashCode(EStructuralFeature feature);
+
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionFactory.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionFactory.java index 80985dce93..a45f526117 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionFactory.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionFactory.java @@ -1,38 +1,38 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.revision; - -import org.eclipse.emf.ecore.EClass; - -/** - * Creates {@link CDORevision revision} instances. - * - * @author Eike Stepper - * @since 2.0 - */ -public interface CDORevisionFactory -{ - /** - * @since 3.0 - */ - public static final CDORevisionFactory DEFAULT = new CDORevisionFactory() - { - public CDORevision createRevision(EClass eClass) - { - return new org.eclipse.emf.cdo.internal.common.revision.CDORevisionImpl(eClass); - } - }; - - /** - * @since 3.0 - */ - public CDORevision createRevision(EClass eClass); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.revision;
+
+import org.eclipse.emf.ecore.EClass;
+
+/**
+ * Creates {@link CDORevision revision} instances.
+ *
+ * @author Eike Stepper
+ * @since 2.0
+ */
+public interface CDORevisionFactory
+{
+ /**
+ * @since 3.0
+ */
+ public static final CDORevisionFactory DEFAULT = new CDORevisionFactory()
+ {
+ public CDORevision createRevision(EClass eClass)
+ {
+ return new org.eclipse.emf.cdo.internal.common.revision.CDORevisionImpl(eClass);
+ }
+ };
+
+ /**
+ * @since 3.0
+ */
+ public CDORevision createRevision(EClass eClass);
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionHandler.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionHandler.java index dfbf63ba41..c51560a472 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionHandler.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionHandler.java @@ -1,82 +1,82 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.revision; - -import org.eclipse.emf.cdo.spi.common.revision.DetachedCDORevision; - -/** - * A call-back interface that indicates the ability to <i>handle</i> {@link CDORevision revisions} that are passed from - * other entities. - * - * @author Eike Stepper - * @since 3.0 - */ -public interface CDORevisionHandler -{ - /** - * Handles a revision. - * - * @return <code>true</code> to indicate that the caller may pass more revisions, <code>false</code> otherwise. - * @since 4.0 - */ - public boolean handleRevision(CDORevision revision); - - /** - * A delegating {@link CDORevisionHandler revision handler} with a {@link #filter(CDORevision) filter()} method used - * to suppress specific revisions. - * - * @author Eike Stepper - * @since 4.1 - */ - public static class Filtered implements CDORevisionHandler - { - private final CDORevisionHandler delegate; - - public Filtered(CDORevisionHandler delegate) - { - this.delegate = delegate; - } - - public final boolean handleRevision(CDORevision revision) - { - if (filter(revision)) - { - return true; - } - - return delegate.handleRevision(revision); - } - - protected boolean filter(CDORevision revision) - { - return false; - } - - /** - * A delegating {@link Filtered revision handler} that filters detached revisions. - * - * @author Eike Stepper - */ - public static final class Undetached extends Filtered - { - public Undetached(CDORevisionHandler delegate) - { - super(delegate); - } - - @Override - protected boolean filter(CDORevision revision) - { - return revision instanceof DetachedCDORevision; - } - } - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.revision;
+
+import org.eclipse.emf.cdo.spi.common.revision.DetachedCDORevision;
+
+/**
+ * A call-back interface that indicates the ability to <i>handle</i> {@link CDORevision revisions} that are passed from
+ * other entities.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ */
+public interface CDORevisionHandler
+{
+ /**
+ * Handles a revision.
+ *
+ * @return <code>true</code> to indicate that the caller may pass more revisions, <code>false</code> otherwise.
+ * @since 4.0
+ */
+ public boolean handleRevision(CDORevision revision);
+
+ /**
+ * A delegating {@link CDORevisionHandler revision handler} with a {@link #filter(CDORevision) filter()} method used
+ * to suppress specific revisions.
+ *
+ * @author Eike Stepper
+ * @since 4.1
+ */
+ public static class Filtered implements CDORevisionHandler
+ {
+ private final CDORevisionHandler delegate;
+
+ public Filtered(CDORevisionHandler delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ public final boolean handleRevision(CDORevision revision)
+ {
+ if (filter(revision))
+ {
+ return true;
+ }
+
+ return delegate.handleRevision(revision);
+ }
+
+ protected boolean filter(CDORevision revision)
+ {
+ return false;
+ }
+
+ /**
+ * A delegating {@link Filtered revision handler} that filters detached revisions.
+ *
+ * @author Eike Stepper
+ */
+ public static final class Undetached extends Filtered
+ {
+ public Undetached(CDORevisionHandler delegate)
+ {
+ super(delegate);
+ }
+
+ @Override
+ protected boolean filter(CDORevision revision)
+ {
+ return revision instanceof DetachedCDORevision;
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionKey.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionKey.java index 64b89c765b..89a37d2987 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionKey.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionKey.java @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.revision; - -import org.eclipse.emf.cdo.common.branch.CDOBranch; -import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; - -/** - * Uniquely identifies a {@link CDORevision revision} by version in a {@link CDOBranch branch}. - * - * @author Eike Stepper - * @since 3.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDORevisionKey extends CDOBranchVersion, CDOIDAndVersion -{ -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.revision;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+
+/**
+ * Uniquely identifies a {@link CDORevision revision} by version in a {@link CDOBranch branch}.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDORevisionKey extends CDOBranchVersion, CDOIDAndVersion
+{
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionManager.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionManager.java index 5cfc2f926e..9409d0b7db 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionManager.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionManager.java @@ -1,171 +1,171 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.revision; - -import org.eclipse.emf.cdo.common.CDOCommonRepository; -import org.eclipse.emf.cdo.common.CDOCommonSession; -import org.eclipse.emf.cdo.common.branch.CDOBranch; -import org.eclipse.emf.cdo.common.branch.CDOBranchManager; -import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; -import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; -import org.eclipse.emf.cdo.common.id.CDOID; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EObject; - -import java.util.List; - -/** - * Provides access to {@link CDORevision revisions} in a CDO {@link CDOCommonRepository repository} by demand loading - * and caching them. - * <p> - * Revisions are generally queried by: - * <p> - * <ul> - * <li>their object {@link CDOID ID} <b>and</b> - * <li>their {@link CDOBranch branch} plus <b>either</b>: - * <ul> - * <li>a timestamp <b>or</b> - * <li>a version - * </ul> - * </ul> - * <p> - * If querying by timestamp it's also possible to ask for multiple revisions (identified by a list of object IDs) in one - * round trip (to the server if this revision manager is contained by a {@link CDOCommonSession session} or to the - * backend store if it is contained by a {@link CDOCommonRepository repository}. - * - * @author Eike Stepper - * @since 3.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.landmark - * @apiviz.has {@link CDORevisionFactory} - * @apiviz.has {@link CDORevisionCache} - * @apiviz.uses {@link CDORevision} - - loads - */ -public interface CDORevisionManager -{ - /** - * Returns the {@link CDORevision#getEClass() type} of an object if a revision for that object is in the revision - * cache, <code>null</code> otherwise. - * <p> - * Same as calling {@link #getObjectType(CDOID, CDOBranchManager) getObjectType(id, null)}. - * - * @see EObject#eClass() - * @see #getObjectType(CDOID, CDOBranchManager) - */ - public EClass getObjectType(CDOID id); - - /** - * Returns the {@link CDORevision#getEClass() type} of an object. - * <p> - * If no revision for that object is found in the revision cache the following is tried: - * <ol> - * <li>If <code>branchManagerForLoadOnDemand</code> is not <code>null</code> the first revision of the object in the - * main branch is loaded from the server and its type is returned. - * <li>Otherwise (i.e., if <code>branchManagerForLoadOnDemand</code> is <code>null</code> or the object does not - * exist) <code>null</code> is returned. - * </ol> - * <p> - * A {@link CDOBranchManager branch manager} is required instead of just a boolean value to specify whether to - * demand-load or not because this revision manager must be able to access the - * {@link CDOBranchManager#getMainBranch() main branch} while demand-loading. - * - * @see EObject#eClass() - * @see #getObjectType(CDOID) - * @since 4.1 - */ - public EClass getObjectType(CDOID id, CDOBranchManager branchManagerForLoadOnDemand); - - /** - * Returns <code>true</code> if the {@link CDORevisionCache revision cache} contains a {@link CDORevision revision} - * with the given {@link CDOID ID} at the given {@link CDOBranchPoint branch point} (branch + timestamp), - * <code>false</code> otherwise. - * - * @see CDORevisionManager#getRevision(CDOID, CDOBranchPoint, int, int, boolean) - * @see CDORevisionManager#getRevisions(List, CDOBranchPoint, int, int, boolean) - */ - public boolean containsRevision(CDOID id, CDOBranchPoint branchPoint); - - /** - * Returns the {@link CDORevision revision} with the given {@link CDOID ID} at the given {@link CDOBranchPoint branch - * point} (branch + timestamp), optionally demand loading it if it is not already in the {@link CDORevisionCache - * cache}. - * - * @param referenceChunk - * The number of target {@link CDOID IDs} to load for each many-valued reference in the returned revision, or - * {@link CDORevision#UNCHUNKED} for all such list elements (IDs). - * @param prefetchDepth - * The number of nested containment levels to load revisions for in one round trip. Use the symbolic - * constants {@link CDORevision#DEPTH_INFINITE} to prefetch all contained revisions or - * {@link CDORevision#DEPTH_NONE} to not prefetch anything. Only the explicitely requested revision is - * returned by this method. If additional revisions are prefetched they are placed in the revision cache to - * speed up subsequent calls to this method. - * @param loadOnDemand - * If the requested revision is not contained in the revision cache it depends on this parameter's value - * whether the revision is loaded from the server or <code>null</code> is returned. - * @see #getRevisions(List, CDOBranchPoint, int, int, boolean) - * @see #getRevisionByVersion(CDOID, CDOBranchVersion, int, boolean) - */ - public CDORevision getRevision(CDOID id, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth, - boolean loadOnDemand); - - /** - * Returns the {@link CDORevision revisions} with the given {@link CDOID IDs} at the given {@link CDOBranchPoint - * branch point} (branch + timestamp), optionally demand loading them if they are not already in the - * {@link CDORevisionCache cache}. - * - * @param referenceChunk - * The number of target {@link CDOID IDs} to load for each many-valued reference in the returned revisions, - * or {@link CDORevision#UNCHUNKED} for all such list elements (IDs). - * @param prefetchDepth - * The number of nested containment levels to load revisions for in one round trip. Use the symbolic - * constants {@link CDORevision#DEPTH_INFINITE} to prefetch all contained revisions or - * {@link CDORevision#DEPTH_NONE} to not prefetch anything. Only the explicitely requested revisions are - * returned by this method. If additional revisions are prefetched they are placed in the revision cache to - * speed up subsequent calls to this method. - * @param loadOnDemand - * If one or more of the requested revisions is/are not contained in the revision cache it depends on this - * parameter's value whether the revision(s) is/are loaded from the server or <code>null</code> is placed in - * the list that is returned. - * @see #getRevision(CDOID, CDOBranchPoint, int, int, boolean) - */ - public List<CDORevision> getRevisions(List<CDOID> ids, CDOBranchPoint branchPoint, int referenceChunk, - int prefetchDepth, boolean loadOnDemand); - - /** - * Returns <code>true</code> if the {@link CDORevisionCache revision cache} contains a {@link CDORevision revision} - * with the given {@link CDOID ID} at the given {@link CDOBranchVersion branch version} (branch + version), - * <code>false</code> otherwise. - * - * @see #getRevisionByVersion(CDOID, CDOBranchVersion, int, boolean) - */ - public boolean containsRevisionByVersion(CDOID id, CDOBranchVersion branchVersion); - - /** - * Returns the {@link CDORevision revision} with the given {@link CDOID ID} at the given {@link CDOBranchVersion - * branch version} (branch + version), optionally demand loading it if it is not already in the - * {@link CDORevisionCache cache}. - * <p> - * Prefetching of nested containment levels is not support by this method because the version of a particular revision - * can not serve as a reasonable baseline criterium for a consistent graph of multiple revisions. - * - * @param referenceChunk - * The number of target {@link CDOID IDs} to load for each many-valued reference in the returned revision, or - * {@link CDORevision#UNCHUNKED} for all such list elements (IDs). - * @param loadOnDemand - * If the requested revision is not contained in the revision cache it depends on this parameter's value - * whether the revision is loaded from the server or <code>null</code> is returned. - * @see #getRevision(CDOID, CDOBranchPoint, int, int, boolean) - */ - public CDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int referenceChunk, - boolean loadOnDemand); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.revision;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository;
+import org.eclipse.emf.cdo.common.CDOCommonSession;
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+import org.eclipse.emf.cdo.common.id.CDOID;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+
+import java.util.List;
+
+/**
+ * Provides access to {@link CDORevision revisions} in a CDO {@link CDOCommonRepository repository} by demand loading
+ * and caching them.
+ * <p>
+ * Revisions are generally queried by:
+ * <p>
+ * <ul>
+ * <li>their object {@link CDOID ID} <b>and</b>
+ * <li>their {@link CDOBranch branch} plus <b>either</b>:
+ * <ul>
+ * <li>a timestamp <b>or</b>
+ * <li>a version
+ * </ul>
+ * </ul>
+ * <p>
+ * If querying by timestamp it's also possible to ask for multiple revisions (identified by a list of object IDs) in one
+ * round trip (to the server if this revision manager is contained by a {@link CDOCommonSession session} or to the
+ * backend store if it is contained by a {@link CDOCommonRepository repository}.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.landmark
+ * @apiviz.has {@link CDORevisionFactory}
+ * @apiviz.has {@link CDORevisionCache}
+ * @apiviz.uses {@link CDORevision} - - loads
+ */
+public interface CDORevisionManager
+{
+ /**
+ * Returns the {@link CDORevision#getEClass() type} of an object if a revision for that object is in the revision
+ * cache, <code>null</code> otherwise.
+ * <p>
+ * Same as calling {@link #getObjectType(CDOID, CDOBranchManager) getObjectType(id, null)}.
+ *
+ * @see EObject#eClass()
+ * @see #getObjectType(CDOID, CDOBranchManager)
+ */
+ public EClass getObjectType(CDOID id);
+
+ /**
+ * Returns the {@link CDORevision#getEClass() type} of an object.
+ * <p>
+ * If no revision for that object is found in the revision cache the following is tried:
+ * <ol>
+ * <li>If <code>branchManagerForLoadOnDemand</code> is not <code>null</code> the first revision of the object in the
+ * main branch is loaded from the server and its type is returned.
+ * <li>Otherwise (i.e., if <code>branchManagerForLoadOnDemand</code> is <code>null</code> or the object does not
+ * exist) <code>null</code> is returned.
+ * </ol>
+ * <p>
+ * A {@link CDOBranchManager branch manager} is required instead of just a boolean value to specify whether to
+ * demand-load or not because this revision manager must be able to access the
+ * {@link CDOBranchManager#getMainBranch() main branch} while demand-loading.
+ *
+ * @see EObject#eClass()
+ * @see #getObjectType(CDOID)
+ * @since 4.1
+ */
+ public EClass getObjectType(CDOID id, CDOBranchManager branchManagerForLoadOnDemand);
+
+ /**
+ * Returns <code>true</code> if the {@link CDORevisionCache revision cache} contains a {@link CDORevision revision}
+ * with the given {@link CDOID ID} at the given {@link CDOBranchPoint branch point} (branch + timestamp),
+ * <code>false</code> otherwise.
+ *
+ * @see CDORevisionManager#getRevision(CDOID, CDOBranchPoint, int, int, boolean)
+ * @see CDORevisionManager#getRevisions(List, CDOBranchPoint, int, int, boolean)
+ */
+ public boolean containsRevision(CDOID id, CDOBranchPoint branchPoint);
+
+ /**
+ * Returns the {@link CDORevision revision} with the given {@link CDOID ID} at the given {@link CDOBranchPoint branch
+ * point} (branch + timestamp), optionally demand loading it if it is not already in the {@link CDORevisionCache
+ * cache}.
+ *
+ * @param referenceChunk
+ * The number of target {@link CDOID IDs} to load for each many-valued reference in the returned revision, or
+ * {@link CDORevision#UNCHUNKED} for all such list elements (IDs).
+ * @param prefetchDepth
+ * The number of nested containment levels to load revisions for in one round trip. Use the symbolic
+ * constants {@link CDORevision#DEPTH_INFINITE} to prefetch all contained revisions or
+ * {@link CDORevision#DEPTH_NONE} to not prefetch anything. Only the explicitely requested revision is
+ * returned by this method. If additional revisions are prefetched they are placed in the revision cache to
+ * speed up subsequent calls to this method.
+ * @param loadOnDemand
+ * If the requested revision is not contained in the revision cache it depends on this parameter's value
+ * whether the revision is loaded from the server or <code>null</code> is returned.
+ * @see #getRevisions(List, CDOBranchPoint, int, int, boolean)
+ * @see #getRevisionByVersion(CDOID, CDOBranchVersion, int, boolean)
+ */
+ public CDORevision getRevision(CDOID id, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth,
+ boolean loadOnDemand);
+
+ /**
+ * Returns the {@link CDORevision revisions} with the given {@link CDOID IDs} at the given {@link CDOBranchPoint
+ * branch point} (branch + timestamp), optionally demand loading them if they are not already in the
+ * {@link CDORevisionCache cache}.
+ *
+ * @param referenceChunk
+ * The number of target {@link CDOID IDs} to load for each many-valued reference in the returned revisions,
+ * or {@link CDORevision#UNCHUNKED} for all such list elements (IDs).
+ * @param prefetchDepth
+ * The number of nested containment levels to load revisions for in one round trip. Use the symbolic
+ * constants {@link CDORevision#DEPTH_INFINITE} to prefetch all contained revisions or
+ * {@link CDORevision#DEPTH_NONE} to not prefetch anything. Only the explicitely requested revisions are
+ * returned by this method. If additional revisions are prefetched they are placed in the revision cache to
+ * speed up subsequent calls to this method.
+ * @param loadOnDemand
+ * If one or more of the requested revisions is/are not contained in the revision cache it depends on this
+ * parameter's value whether the revision(s) is/are loaded from the server or <code>null</code> is placed in
+ * the list that is returned.
+ * @see #getRevision(CDOID, CDOBranchPoint, int, int, boolean)
+ */
+ public List<CDORevision> getRevisions(List<CDOID> ids, CDOBranchPoint branchPoint, int referenceChunk,
+ int prefetchDepth, boolean loadOnDemand);
+
+ /**
+ * Returns <code>true</code> if the {@link CDORevisionCache revision cache} contains a {@link CDORevision revision}
+ * with the given {@link CDOID ID} at the given {@link CDOBranchVersion branch version} (branch + version),
+ * <code>false</code> otherwise.
+ *
+ * @see #getRevisionByVersion(CDOID, CDOBranchVersion, int, boolean)
+ */
+ public boolean containsRevisionByVersion(CDOID id, CDOBranchVersion branchVersion);
+
+ /**
+ * Returns the {@link CDORevision revision} with the given {@link CDOID ID} at the given {@link CDOBranchVersion
+ * branch version} (branch + version), optionally demand loading it if it is not already in the
+ * {@link CDORevisionCache cache}.
+ * <p>
+ * Prefetching of nested containment levels is not support by this method because the version of a particular revision
+ * can not serve as a reasonable baseline criterium for a consistent graph of multiple revisions.
+ *
+ * @param referenceChunk
+ * The number of target {@link CDOID IDs} to load for each many-valued reference in the returned revision, or
+ * {@link CDORevision#UNCHUNKED} for all such list elements (IDs).
+ * @param loadOnDemand
+ * If the requested revision is not contained in the revision cache it depends on this parameter's value
+ * whether the revision is loaded from the server or <code>null</code> is returned.
+ * @see #getRevision(CDOID, CDOBranchPoint, int, int, boolean)
+ */
+ public CDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int referenceChunk,
+ boolean loadOnDemand);
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionProvider.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionProvider.java index cf7e5fb4e3..c18c2b9c96 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionProvider.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionProvider.java @@ -1,27 +1,27 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.revision; - -import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; -import org.eclipse.emf.cdo.common.id.CDOID; - -/** - * Provides consumers with the {@link CDORevision revisions} of {@link CDOID identifiable} CDO objects by selecting a - * particular one from several possible {@link CDOBranchPoint branch points}. - * - * @author Eike Stepper - * @since 3.0 - * @apiviz.uses {@link CDORevision} - - provides - */ -public interface CDORevisionProvider -{ - public CDORevision getRevision(CDOID id); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.revision;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.id.CDOID;
+
+/**
+ * Provides consumers with the {@link CDORevision revisions} of {@link CDOID identifiable} CDO objects by selecting a
+ * particular one from several possible {@link CDOBranchPoint branch points}.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ * @apiviz.uses {@link CDORevision} - - provides
+ */
+public interface CDORevisionProvider
+{
+ public CDORevision getRevision(CDOID id);
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java index 8cb55a0a14..67914d9066 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDORevisionUtil.java @@ -1,597 +1,597 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.revision; - -import org.eclipse.emf.cdo.common.branch.CDOBranch; -import org.eclipse.emf.cdo.common.branch.CDOBranchManager; -import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; -import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; -import org.eclipse.emf.cdo.common.commit.CDOChangeSet; -import org.eclipse.emf.cdo.common.commit.CDOChangeSetData; -import org.eclipse.emf.cdo.common.id.CDOID; -import org.eclipse.emf.cdo.common.id.CDOIDUtil; -import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; -import org.eclipse.emf.cdo.common.util.CDOCommonUtil; -import org.eclipse.emf.cdo.internal.common.commit.CDOChangeSetDataImpl; -import org.eclipse.emf.cdo.internal.common.commit.CDOChangeSetImpl; -import org.eclipse.emf.cdo.internal.common.messages.Messages; -import org.eclipse.emf.cdo.internal.common.revision.CDOFeatureMapEntryImpl; -import org.eclipse.emf.cdo.internal.common.revision.CDORevisableImpl; -import org.eclipse.emf.cdo.internal.common.revision.CDORevisionCacheAuditing; -import org.eclipse.emf.cdo.internal.common.revision.CDORevisionCacheBranching; -import org.eclipse.emf.cdo.internal.common.revision.CDORevisionCacheNonAuditing; -import org.eclipse.emf.cdo.internal.common.revision.CDORevisionImpl; -import org.eclipse.emf.cdo.internal.common.revision.CDORevisionKeyImpl; -import org.eclipse.emf.cdo.internal.common.revision.CDORevisionManagerImpl; -import org.eclipse.emf.cdo.internal.common.revision.delta.CDORevisionDeltaImpl; -import org.eclipse.emf.cdo.spi.common.revision.CDOFeatureMapEntry; -import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; -import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager; -import org.eclipse.emf.cdo.spi.common.revision.ManagedRevisionProvider; - -import org.eclipse.emf.ecore.EAttribute; -import org.eclipse.emf.ecore.EStructuralFeature; -import org.eclipse.emf.ecore.util.FeatureMap; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.StringTokenizer; - -/** - * Various static helper methods for dealing with {@link CDORevision revisions}. - * - * @author Eike Stepper - * @apiviz.exclude - */ -public final class CDORevisionUtil -{ - public static final Object UNINITIALIZED = new Uninitialized(); - - private CDORevisionUtil() - { - } - - /** - * Creates and returns a new memory sensitive revision cache. - * - * @since 4.0 - */ - public static CDORevisionCache createRevisionCache(boolean supportingAudits, boolean supportingBranches) - { - if (supportingBranches) - { - return new CDORevisionCacheBranching(); - } - - if (supportingAudits) - { - return new CDORevisionCacheAuditing(); - } - - return new CDORevisionCacheNonAuditing(); - } - - /** - * @since 4.0 - */ - public static CDORevisionManager createRevisionManager() - { - return new CDORevisionManagerImpl(); - } - - /** - * @since 4.0 - */ - public static CDORevisionManager createRevisionManager(CDORevisionCache cache) - { - InternalCDORevisionManager revisionManager = (InternalCDORevisionManager)createRevisionManager(); - revisionManager.setCache(cache); - return revisionManager; - } - - /** - * @since 4.0 - */ - public static CDORevisable copyRevisable(CDORevisable source) - { - return new CDORevisableImpl(source); - } - - /** - * @since 4.0 - */ - public static CDORevisable createRevisable(CDOBranch branch, int version, long timeStamp, long revised) - { - return new CDORevisableImpl(branch, version, timeStamp, revised); - } - - /** - * @since 4.0 - */ - public static CDORevisionKey copyRevisionKey(CDORevisionKey source) - { - return new CDORevisionKeyImpl(source.getID(), source.getBranch(), source.getVersion()); - } - - /** - * @since 3.0 - */ - public static CDORevisionKey createRevisionKey(CDOID id, CDOBranch branch, int version) - { - return new CDORevisionKeyImpl(id, branch, version); - } - - /** - * @since 4.0 - */ - public static String formatRevisionKey(CDORevisionKey key) - { - StringBuilder builder = new StringBuilder(); - CDOIDUtil.write(builder, key.getID()); - builder.append(":"); - builder.append(key.getBranch().getID()); - builder.append(":"); - builder.append(key.getVersion()); - return builder.toString(); - } - - /** - * @since 4.0 - */ - public static CDORevisionKey parseRevisionKey(String source, CDOBranchManager branchManager) - { - StringTokenizer tokenizer = new StringTokenizer(source, ":"); - if (!tokenizer.hasMoreTokens()) - { - throw new IllegalArgumentException("No ID segment"); - } - - String idSegment = tokenizer.nextToken(); - CDOID id = CDOIDUtil.read(idSegment); - - if (!tokenizer.hasMoreTokens()) - { - throw new IllegalArgumentException("No branch segment"); - } - - String branchSegment = tokenizer.nextToken(); - CDOBranch branch = branchManager.getBranch(Integer.parseInt(branchSegment)); - - if (!tokenizer.hasMoreTokens()) - { - throw new IllegalArgumentException("No version segment"); - } - - String versionSegment = tokenizer.nextToken(); - int version = Integer.parseInt(versionSegment); - - return new CDORevisionKeyImpl(id, branch, version); - } - - /** - * @since 2.0 - */ - public static FeatureMap.Entry createFeatureMapEntry(EStructuralFeature feature, Object value) - { - return new CDOFeatureMapEntryImpl(feature, value); - } - - /** - * @since 3.0 - */ - public static CDOFeatureMapEntry createCDOFeatureMapEntry() - { - return new CDOFeatureMapEntryImpl(); - } - - /** - * @since 4.0 - */ - public static CDORevisionDelta createDelta(CDORevision revision) - { - return new CDORevisionDeltaImpl(revision); - } - - /** - * @since 4.0 - */ - public static CDOChangeSetData createChangeSetData(Set<CDOID> ids, final CDOBranchPoint startPoint, - final CDOBranchPoint endPoint, final CDORevisionManager revisionManager) - { - CDORevisionProvider startProvider = new ManagedRevisionProvider(revisionManager, startPoint); - CDORevisionProvider endProvider = new ManagedRevisionProvider(revisionManager, endPoint); - return createChangeSetData(ids, startProvider, endProvider); - } - - /** - * @since 4.0 - */ - public static CDOChangeSetData createChangeSetData(Set<CDOID> ids, CDORevisionProvider startProvider, - CDORevisionProvider endProvider) - { - return createChangeSetData(ids, startProvider, endProvider, false); - } - - /** - * @since 4.1 - */ - public static CDOChangeSetData createChangeSetData(Set<CDOID> ids, CDORevisionProvider startProvider, - CDORevisionProvider endProvider, boolean useStartVersions) - { - List<CDOIDAndVersion> newObjects = new ArrayList<CDOIDAndVersion>(); - List<CDORevisionKey> changedObjects = new ArrayList<CDORevisionKey>(); - List<CDOIDAndVersion> detachedObjects = new ArrayList<CDOIDAndVersion>(); - for (CDOID id : ids) - { - CDORevision startRevision = startProvider.getRevision(id); - CDORevision endRevision = endProvider.getRevision(id); - - if (startRevision == null && endRevision != null) - { - if (useStartVersions) - { - ((InternalCDORevision)endRevision).setVersion(0); - } - - newObjects.add(endRevision); - } - else if (startRevision != null && endRevision == null) - { - detachedObjects.add(CDOIDUtil.createIDAndVersion(id, CDOBranchVersion.UNSPECIFIED_VERSION)); - } - else if (startRevision != null && endRevision != null) - { - if (!startRevision.equals(endRevision)) - { - if (useStartVersions) - { - ((InternalCDORevision)endRevision).setVersion(startRevision.getVersion()); - } - - CDORevisionDelta delta = endRevision.compare(startRevision); - if (!delta.isEmpty()) - { - changedObjects.add(delta); - } - } - } - } - - return createChangeSetData(newObjects, changedObjects, detachedObjects); - } - - /** - * @since 4.0 - */ - public static CDOChangeSetData createChangeSetData(List<CDOIDAndVersion> newObjects, - List<CDORevisionKey> changedObjects, List<CDOIDAndVersion> detachedObjects) - { - return new CDOChangeSetDataImpl(newObjects, changedObjects, detachedObjects); - } - - /** - * @since 4.0 - */ - public static CDOChangeSet createChangeSet(CDOBranchPoint startPoint, CDOBranchPoint endPoint, CDOChangeSetData data) - { - return new CDOChangeSetImpl(startPoint, endPoint, data); - } - - /** - * @since 3.0 - */ - public static Object remapID(Object value, Map<CDOID, CDOID> idMappings, boolean allowUnmappedTempIDs) - { - return CDORevisionImpl.remapID(value, idMappings, allowUnmappedTempIDs); - } - - /** - * @since 4.0 - */ - public static String getResourceNodePath(CDORevision revision, CDORevisionProvider provider) - { - EAttribute nameFeature = (EAttribute)revision.getEClass().getEStructuralFeature("name"); - - StringBuilder builder = new StringBuilder(); - getResourceNodePath((InternalCDORevision)revision, provider, nameFeature, builder); - - builder.insert(0, "/"); - return builder.toString(); - } - - private static void getResourceNodePath(InternalCDORevision revision, CDORevisionProvider provider, - EAttribute nameFeature, StringBuilder result) - { - String name = (String)revision.get(nameFeature, 0); - if (name != null) - { - if (result.length() != 0) - { - result.insert(0, "/"); - } - - result.insert(0, name); - } - - CDOID folder = (CDOID)revision.getContainerID(); - if (!CDOIDUtil.isNull(folder)) - { - InternalCDORevision container = (InternalCDORevision)provider.getRevision(folder); - getResourceNodePath(container, provider, nameFeature, result); - } - } - - /** - * @since 3.0 - */ - public static String dumpAllRevisions(Map<CDOBranch, List<CDORevision>> map) - { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - PrintStream out = new PrintStream(baos); - dumpAllRevisions(map, out); - return baos.toString(); - } - - /** - * @since 3.0 - */ - public static void dumpAllRevisions(Map<CDOBranch, List<CDORevision>> map, PrintStream out) - { - new AllRevisionsDumper.Stream.Plain(map, out).dump(); - } - - /** - * Dumps {@link CDORevision revisions}, sorted and grouped by {@link CDOBranch branch}, to various output formats and - * targets. Concrete output formats and targets are implemented by subclasses. - * - * @since 4.0 - * @apiviz.exclude - */ - public static abstract class AllRevisionsDumper - { - private Map<CDOBranch, List<CDORevision>> map; - - public AllRevisionsDumper(Map<CDOBranch, List<CDORevision>> map) - { - this.map = map; - } - - public Map<CDOBranch, List<CDORevision>> getMap() - { - return map; - } - - public void dump() - { - ArrayList<CDOBranch> branches = new ArrayList<CDOBranch>(map.keySet()); - Collections.sort(branches); - - dumpStart(branches); - for (CDOBranch branch : branches) - { - dumpBranch(branch); - - List<CDORevision> revisions = map.get(branch); - Collections.sort(revisions, new CDORevisionComparator()); - - for (CDORevision revision : revisions) - { - dumpRevision(revision); - } - } - - dumpEnd(branches); - } - - protected void dumpStart(List<CDOBranch> branches) - { - } - - protected void dumpEnd(List<CDOBranch> branches) - { - } - - protected abstract void dumpBranch(CDOBranch branch); - - protected abstract void dumpRevision(CDORevision revision); - - /** - * A {@link AllRevisionsDumper revision dumper} that directs all output to a stream. The concrete output format is - * implemented by subclasses. - * - * @author Eike Stepper - * @apiviz.exclude - */ - public static abstract class Stream extends AllRevisionsDumper - { - private PrintStream out; - - public Stream(Map<CDOBranch, List<CDORevision>> map, PrintStream out) - { - super(map); - this.out = out; - } - - public PrintStream out() - { - return out; - } - - /** - * A {@link Stream revision dumper} that directs all output as plain text to a stream. - * - * @author Eike Stepper - * @apiviz.exclude - */ - public static class Plain extends Stream - { - public static final int pad = 48; - - public Plain(Map<CDOBranch, List<CDORevision>> map, PrintStream out) - { - super(map, out); - } - - @Override - protected void dumpEnd(List<CDOBranch> branches) - { - out().println(); - } - - @Override - protected void dumpBranch(CDOBranch branch) - { - out().println( - padTimeRange(branch.getName() + "[" + branch.getID() + "]", pad, branch.getBase().getTimeStamp(), //$NON-NLS-1$ //$NON-NLS-2$ - CDORevision.UNSPECIFIED_DATE)); - } - - @Override - protected void dumpRevision(CDORevision revision) - { - out().println(padTimeRange(" " + revision, pad, revision.getTimeStamp(), revision.getRevised())); //$NON-NLS-1$ - } - - private static String padTimeRange(String s, int pos, long t1, long t2) - { - StringBuffer buffer = new StringBuffer(s); - while (buffer.length() < pos) - { - buffer.append(' '); - } - - buffer.append(CDOCommonUtil.formatTimeStamp(t1)); - buffer.append("/"); - buffer.append(CDOCommonUtil.formatTimeStamp(t2)); - return buffer.toString(); - } - } - - /** - * A {@link Stream revision dumper} that directs all output as HTML text to a stream. - * - * @author Eike Stepper - * @apiviz.exclude - */ - public static class Html extends Stream - { - public Html(Map<CDOBranch, List<CDORevision>> map, PrintStream out) - { - super(map, out); - } - - @Override - protected void dumpStart(List<CDOBranch> branches) - { - out().println("<table border=\"0\">"); - } - - @Override - protected void dumpEnd(List<CDOBranch> branches) - { - out().println("</table>"); - } - - @Override - protected void dumpBranch(CDOBranch branch) - { - PrintStream out = out(); - if (!branch.isMainBranch()) - { - out.println("<tr><td> </td><td> </td></tr>"); - } - - out.println("<tr>"); - out.println("<td>"); - out.println("<h4>" + branch.getName() + "[" + branch.getID() + "]</h4>"); - out.println("</td>"); - out.println("<td>"); - out.println("<h4>" + CDOCommonUtil.formatTimeStamp(branch.getBase().getTimeStamp()) + " / " - + CDOCommonUtil.formatTimeStamp(CDORevision.UNSPECIFIED_DATE) + "</h4>"); - out.println("</td>"); - out.println("</tr>"); - } - - @Override - protected void dumpRevision(CDORevision revision) - { - PrintStream out = out(); - - out.println("<tr>"); - out.println("<td> "); - dumpRevision(revision, out); - out.println(" </td>"); - - out.println("<td>"); - out.println(CDOCommonUtil.formatTimeStamp(revision.getTimeStamp()) + " / " - + CDOCommonUtil.formatTimeStamp(revision.getRevised())); - out.println("</td>"); - out.println("</tr>"); - } - - protected void dumpRevision(CDORevision revision, PrintStream out) - { - out.println(revision); - } - } - } - } - - /** - * Compares {@link CDORevisionKey revision keys} by {@link CDORevision#getID() ID} and - * {@link CDORevision#getVersion() version}. - * - * @author Eike Stepper - * @since 4.0 - * @apiviz.exclude - */ - public static class CDORevisionComparator implements Comparator<CDORevisionKey> - { - public CDORevisionComparator() - { - } - - public int compare(CDORevisionKey rev1, CDORevisionKey rev2) - { - int result = rev1.getID().compareTo(rev2.getID()); - if (result == 0) - { - int version1 = rev1.getVersion(); - int version2 = rev2.getVersion(); - result = version1 < version2 ? -1 : version1 == version2 ? 0 : 1; - } - - return result; - } - } - - /** - * @author Eike Stepper - */ - private static final class Uninitialized - { - public Uninitialized() - { - } - - @Override - public String toString() - { - return Messages.getString("CDORevisionUtil.0"); //$NON-NLS-1$ - } - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.revision;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+import org.eclipse.emf.cdo.common.commit.CDOChangeSet;
+import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.id.CDOIDUtil;
+import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
+import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
+import org.eclipse.emf.cdo.internal.common.commit.CDOChangeSetDataImpl;
+import org.eclipse.emf.cdo.internal.common.commit.CDOChangeSetImpl;
+import org.eclipse.emf.cdo.internal.common.messages.Messages;
+import org.eclipse.emf.cdo.internal.common.revision.CDOFeatureMapEntryImpl;
+import org.eclipse.emf.cdo.internal.common.revision.CDORevisableImpl;
+import org.eclipse.emf.cdo.internal.common.revision.CDORevisionCacheAuditing;
+import org.eclipse.emf.cdo.internal.common.revision.CDORevisionCacheBranching;
+import org.eclipse.emf.cdo.internal.common.revision.CDORevisionCacheNonAuditing;
+import org.eclipse.emf.cdo.internal.common.revision.CDORevisionImpl;
+import org.eclipse.emf.cdo.internal.common.revision.CDORevisionKeyImpl;
+import org.eclipse.emf.cdo.internal.common.revision.CDORevisionManagerImpl;
+import org.eclipse.emf.cdo.internal.common.revision.delta.CDORevisionDeltaImpl;
+import org.eclipse.emf.cdo.spi.common.revision.CDOFeatureMapEntry;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
+import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
+import org.eclipse.emf.cdo.spi.common.revision.ManagedRevisionProvider;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.util.FeatureMap;
+
+import java.io.ByteArrayOutputStream;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+/**
+ * Various static helper methods for dealing with {@link CDORevision revisions}.
+ *
+ * @author Eike Stepper
+ * @apiviz.exclude
+ */
+public final class CDORevisionUtil
+{
+ public static final Object UNINITIALIZED = new Uninitialized();
+
+ private CDORevisionUtil()
+ {
+ }
+
+ /**
+ * Creates and returns a new memory sensitive revision cache.
+ *
+ * @since 4.0
+ */
+ public static CDORevisionCache createRevisionCache(boolean supportingAudits, boolean supportingBranches)
+ {
+ if (supportingBranches)
+ {
+ return new CDORevisionCacheBranching();
+ }
+
+ if (supportingAudits)
+ {
+ return new CDORevisionCacheAuditing();
+ }
+
+ return new CDORevisionCacheNonAuditing();
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static CDORevisionManager createRevisionManager()
+ {
+ return new CDORevisionManagerImpl();
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static CDORevisionManager createRevisionManager(CDORevisionCache cache)
+ {
+ InternalCDORevisionManager revisionManager = (InternalCDORevisionManager)createRevisionManager();
+ revisionManager.setCache(cache);
+ return revisionManager;
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static CDORevisable copyRevisable(CDORevisable source)
+ {
+ return new CDORevisableImpl(source);
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static CDORevisable createRevisable(CDOBranch branch, int version, long timeStamp, long revised)
+ {
+ return new CDORevisableImpl(branch, version, timeStamp, revised);
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static CDORevisionKey copyRevisionKey(CDORevisionKey source)
+ {
+ return new CDORevisionKeyImpl(source.getID(), source.getBranch(), source.getVersion());
+ }
+
+ /**
+ * @since 3.0
+ */
+ public static CDORevisionKey createRevisionKey(CDOID id, CDOBranch branch, int version)
+ {
+ return new CDORevisionKeyImpl(id, branch, version);
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static String formatRevisionKey(CDORevisionKey key)
+ {
+ StringBuilder builder = new StringBuilder();
+ CDOIDUtil.write(builder, key.getID());
+ builder.append(":");
+ builder.append(key.getBranch().getID());
+ builder.append(":");
+ builder.append(key.getVersion());
+ return builder.toString();
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static CDORevisionKey parseRevisionKey(String source, CDOBranchManager branchManager)
+ {
+ StringTokenizer tokenizer = new StringTokenizer(source, ":");
+ if (!tokenizer.hasMoreTokens())
+ {
+ throw new IllegalArgumentException("No ID segment");
+ }
+
+ String idSegment = tokenizer.nextToken();
+ CDOID id = CDOIDUtil.read(idSegment);
+
+ if (!tokenizer.hasMoreTokens())
+ {
+ throw new IllegalArgumentException("No branch segment");
+ }
+
+ String branchSegment = tokenizer.nextToken();
+ CDOBranch branch = branchManager.getBranch(Integer.parseInt(branchSegment));
+
+ if (!tokenizer.hasMoreTokens())
+ {
+ throw new IllegalArgumentException("No version segment");
+ }
+
+ String versionSegment = tokenizer.nextToken();
+ int version = Integer.parseInt(versionSegment);
+
+ return new CDORevisionKeyImpl(id, branch, version);
+ }
+
+ /**
+ * @since 2.0
+ */
+ public static FeatureMap.Entry createFeatureMapEntry(EStructuralFeature feature, Object value)
+ {
+ return new CDOFeatureMapEntryImpl(feature, value);
+ }
+
+ /**
+ * @since 3.0
+ */
+ public static CDOFeatureMapEntry createCDOFeatureMapEntry()
+ {
+ return new CDOFeatureMapEntryImpl();
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static CDORevisionDelta createDelta(CDORevision revision)
+ {
+ return new CDORevisionDeltaImpl(revision);
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static CDOChangeSetData createChangeSetData(Set<CDOID> ids, final CDOBranchPoint startPoint,
+ final CDOBranchPoint endPoint, final CDORevisionManager revisionManager)
+ {
+ CDORevisionProvider startProvider = new ManagedRevisionProvider(revisionManager, startPoint);
+ CDORevisionProvider endProvider = new ManagedRevisionProvider(revisionManager, endPoint);
+ return createChangeSetData(ids, startProvider, endProvider);
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static CDOChangeSetData createChangeSetData(Set<CDOID> ids, CDORevisionProvider startProvider,
+ CDORevisionProvider endProvider)
+ {
+ return createChangeSetData(ids, startProvider, endProvider, false);
+ }
+
+ /**
+ * @since 4.1
+ */
+ public static CDOChangeSetData createChangeSetData(Set<CDOID> ids, CDORevisionProvider startProvider,
+ CDORevisionProvider endProvider, boolean useStartVersions)
+ {
+ List<CDOIDAndVersion> newObjects = new ArrayList<CDOIDAndVersion>();
+ List<CDORevisionKey> changedObjects = new ArrayList<CDORevisionKey>();
+ List<CDOIDAndVersion> detachedObjects = new ArrayList<CDOIDAndVersion>();
+ for (CDOID id : ids)
+ {
+ CDORevision startRevision = startProvider.getRevision(id);
+ CDORevision endRevision = endProvider.getRevision(id);
+
+ if (startRevision == null && endRevision != null)
+ {
+ if (useStartVersions)
+ {
+ ((InternalCDORevision)endRevision).setVersion(0);
+ }
+
+ newObjects.add(endRevision);
+ }
+ else if (startRevision != null && endRevision == null)
+ {
+ detachedObjects.add(CDOIDUtil.createIDAndVersion(id, CDOBranchVersion.UNSPECIFIED_VERSION));
+ }
+ else if (startRevision != null && endRevision != null)
+ {
+ if (!startRevision.equals(endRevision))
+ {
+ if (useStartVersions)
+ {
+ ((InternalCDORevision)endRevision).setVersion(startRevision.getVersion());
+ }
+
+ CDORevisionDelta delta = endRevision.compare(startRevision);
+ if (!delta.isEmpty())
+ {
+ changedObjects.add(delta);
+ }
+ }
+ }
+ }
+
+ return createChangeSetData(newObjects, changedObjects, detachedObjects);
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static CDOChangeSetData createChangeSetData(List<CDOIDAndVersion> newObjects,
+ List<CDORevisionKey> changedObjects, List<CDOIDAndVersion> detachedObjects)
+ {
+ return new CDOChangeSetDataImpl(newObjects, changedObjects, detachedObjects);
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static CDOChangeSet createChangeSet(CDOBranchPoint startPoint, CDOBranchPoint endPoint, CDOChangeSetData data)
+ {
+ return new CDOChangeSetImpl(startPoint, endPoint, data);
+ }
+
+ /**
+ * @since 3.0
+ */
+ public static Object remapID(Object value, Map<CDOID, CDOID> idMappings, boolean allowUnmappedTempIDs)
+ {
+ return CDORevisionImpl.remapID(value, idMappings, allowUnmappedTempIDs);
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static String getResourceNodePath(CDORevision revision, CDORevisionProvider provider)
+ {
+ EAttribute nameFeature = (EAttribute)revision.getEClass().getEStructuralFeature("name");
+
+ StringBuilder builder = new StringBuilder();
+ getResourceNodePath((InternalCDORevision)revision, provider, nameFeature, builder);
+
+ builder.insert(0, "/");
+ return builder.toString();
+ }
+
+ private static void getResourceNodePath(InternalCDORevision revision, CDORevisionProvider provider,
+ EAttribute nameFeature, StringBuilder result)
+ {
+ String name = (String)revision.get(nameFeature, 0);
+ if (name != null)
+ {
+ if (result.length() != 0)
+ {
+ result.insert(0, "/");
+ }
+
+ result.insert(0, name);
+ }
+
+ CDOID folder = (CDOID)revision.getContainerID();
+ if (!CDOIDUtil.isNull(folder))
+ {
+ InternalCDORevision container = (InternalCDORevision)provider.getRevision(folder);
+ getResourceNodePath(container, provider, nameFeature, result);
+ }
+ }
+
+ /**
+ * @since 3.0
+ */
+ public static String dumpAllRevisions(Map<CDOBranch, List<CDORevision>> map)
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ PrintStream out = new PrintStream(baos);
+ dumpAllRevisions(map, out);
+ return baos.toString();
+ }
+
+ /**
+ * @since 3.0
+ */
+ public static void dumpAllRevisions(Map<CDOBranch, List<CDORevision>> map, PrintStream out)
+ {
+ new AllRevisionsDumper.Stream.Plain(map, out).dump();
+ }
+
+ /**
+ * Dumps {@link CDORevision revisions}, sorted and grouped by {@link CDOBranch branch}, to various output formats and
+ * targets. Concrete output formats and targets are implemented by subclasses.
+ *
+ * @since 4.0
+ * @apiviz.exclude
+ */
+ public static abstract class AllRevisionsDumper
+ {
+ private Map<CDOBranch, List<CDORevision>> map;
+
+ public AllRevisionsDumper(Map<CDOBranch, List<CDORevision>> map)
+ {
+ this.map = map;
+ }
+
+ public Map<CDOBranch, List<CDORevision>> getMap()
+ {
+ return map;
+ }
+
+ public void dump()
+ {
+ ArrayList<CDOBranch> branches = new ArrayList<CDOBranch>(map.keySet());
+ Collections.sort(branches);
+
+ dumpStart(branches);
+ for (CDOBranch branch : branches)
+ {
+ dumpBranch(branch);
+
+ List<CDORevision> revisions = map.get(branch);
+ Collections.sort(revisions, new CDORevisionComparator());
+
+ for (CDORevision revision : revisions)
+ {
+ dumpRevision(revision);
+ }
+ }
+
+ dumpEnd(branches);
+ }
+
+ protected void dumpStart(List<CDOBranch> branches)
+ {
+ }
+
+ protected void dumpEnd(List<CDOBranch> branches)
+ {
+ }
+
+ protected abstract void dumpBranch(CDOBranch branch);
+
+ protected abstract void dumpRevision(CDORevision revision);
+
+ /**
+ * A {@link AllRevisionsDumper revision dumper} that directs all output to a stream. The concrete output format is
+ * implemented by subclasses.
+ *
+ * @author Eike Stepper
+ * @apiviz.exclude
+ */
+ public static abstract class Stream extends AllRevisionsDumper
+ {
+ private PrintStream out;
+
+ public Stream(Map<CDOBranch, List<CDORevision>> map, PrintStream out)
+ {
+ super(map);
+ this.out = out;
+ }
+
+ public PrintStream out()
+ {
+ return out;
+ }
+
+ /**
+ * A {@link Stream revision dumper} that directs all output as plain text to a stream.
+ *
+ * @author Eike Stepper
+ * @apiviz.exclude
+ */
+ public static class Plain extends Stream
+ {
+ public static final int pad = 48;
+
+ public Plain(Map<CDOBranch, List<CDORevision>> map, PrintStream out)
+ {
+ super(map, out);
+ }
+
+ @Override
+ protected void dumpEnd(List<CDOBranch> branches)
+ {
+ out().println();
+ }
+
+ @Override
+ protected void dumpBranch(CDOBranch branch)
+ {
+ out().println(
+ padTimeRange(branch.getName() + "[" + branch.getID() + "]", pad, branch.getBase().getTimeStamp(), //$NON-NLS-1$ //$NON-NLS-2$
+ CDORevision.UNSPECIFIED_DATE));
+ }
+
+ @Override
+ protected void dumpRevision(CDORevision revision)
+ {
+ out().println(padTimeRange(" " + revision, pad, revision.getTimeStamp(), revision.getRevised())); //$NON-NLS-1$
+ }
+
+ private static String padTimeRange(String s, int pos, long t1, long t2)
+ {
+ StringBuffer buffer = new StringBuffer(s);
+ while (buffer.length() < pos)
+ {
+ buffer.append(' ');
+ }
+
+ buffer.append(CDOCommonUtil.formatTimeStamp(t1));
+ buffer.append("/");
+ buffer.append(CDOCommonUtil.formatTimeStamp(t2));
+ return buffer.toString();
+ }
+ }
+
+ /**
+ * A {@link Stream revision dumper} that directs all output as HTML text to a stream.
+ *
+ * @author Eike Stepper
+ * @apiviz.exclude
+ */
+ public static class Html extends Stream
+ {
+ public Html(Map<CDOBranch, List<CDORevision>> map, PrintStream out)
+ {
+ super(map, out);
+ }
+
+ @Override
+ protected void dumpStart(List<CDOBranch> branches)
+ {
+ out().println("<table border=\"0\">");
+ }
+
+ @Override
+ protected void dumpEnd(List<CDOBranch> branches)
+ {
+ out().println("</table>");
+ }
+
+ @Override
+ protected void dumpBranch(CDOBranch branch)
+ {
+ PrintStream out = out();
+ if (!branch.isMainBranch())
+ {
+ out.println("<tr><td> </td><td> </td></tr>");
+ }
+
+ out.println("<tr>");
+ out.println("<td>");
+ out.println("<h4>" + branch.getName() + "[" + branch.getID() + "]</h4>");
+ out.println("</td>");
+ out.println("<td>");
+ out.println("<h4>" + CDOCommonUtil.formatTimeStamp(branch.getBase().getTimeStamp()) + " / "
+ + CDOCommonUtil.formatTimeStamp(CDORevision.UNSPECIFIED_DATE) + "</h4>");
+ out.println("</td>");
+ out.println("</tr>");
+ }
+
+ @Override
+ protected void dumpRevision(CDORevision revision)
+ {
+ PrintStream out = out();
+
+ out.println("<tr>");
+ out.println("<td> ");
+ dumpRevision(revision, out);
+ out.println(" </td>");
+
+ out.println("<td>");
+ out.println(CDOCommonUtil.formatTimeStamp(revision.getTimeStamp()) + " / "
+ + CDOCommonUtil.formatTimeStamp(revision.getRevised()));
+ out.println("</td>");
+ out.println("</tr>");
+ }
+
+ protected void dumpRevision(CDORevision revision, PrintStream out)
+ {
+ out.println(revision);
+ }
+ }
+ }
+ }
+
+ /**
+ * Compares {@link CDORevisionKey revision keys} by {@link CDORevision#getID() ID} and
+ * {@link CDORevision#getVersion() version}.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ * @apiviz.exclude
+ */
+ public static class CDORevisionComparator implements Comparator<CDORevisionKey>
+ {
+ public CDORevisionComparator()
+ {
+ }
+
+ public int compare(CDORevisionKey rev1, CDORevisionKey rev2)
+ {
+ int result = rev1.getID().compareTo(rev2.getID());
+ if (result == 0)
+ {
+ int version1 = rev1.getVersion();
+ int version2 = rev2.getVersion();
+ result = version1 < version2 ? -1 : version1 == version2 ? 0 : 1;
+ }
+
+ return result;
+ }
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ private static final class Uninitialized
+ {
+ public Uninitialized()
+ {
+ }
+
+ @Override
+ public String toString()
+ {
+ return Messages.getString("CDORevisionUtil.0"); //$NON-NLS-1$
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOAddFeatureDelta.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOAddFeatureDelta.java index f1862fbcde..ace02a912f 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOAddFeatureDelta.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOAddFeatureDelta.java @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2004 - 2011 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: - * Simon McDuff - initial API and implementation - * Eike Stepper - maintenance - */ -package org.eclipse.emf.cdo.common.revision.delta; - -import org.eclipse.emf.ecore.EStructuralFeature; - -/** - * A {@link CDOFeatureDelta feature delta} that represents an addition to a many-valued {@link EStructuralFeature - * feature}. - * - * @author Simon McDuff - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDOAddFeatureDelta extends CDOFeatureDelta -{ - public int getIndex(); - - public Object getValue(); -} +/*
+ * Copyright (c) 2004 - 2012 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:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.common.revision.delta;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * A {@link CDOFeatureDelta feature delta} that represents an addition to a many-valued {@link EStructuralFeature
+ * feature}.
+ *
+ * @author Simon McDuff
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDOAddFeatureDelta extends CDOFeatureDelta
+{
+ public int getIndex();
+
+ public Object getValue();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOClearFeatureDelta.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOClearFeatureDelta.java index 14e5c17b25..3e3e88ccac 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOClearFeatureDelta.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOClearFeatureDelta.java @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2004 - 2011 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: - * Simon McDuff - initial API and implementation - * Eike Stepper - maintenance - */ -package org.eclipse.emf.cdo.common.revision.delta; - -import org.eclipse.emf.ecore.EStructuralFeature; - -/** - * A {@link CDOFeatureDelta feature delta} that represents the removal of all elements from a many-valued - * {@link EStructuralFeature feature}. - * - * @author Simon McDuff - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDOClearFeatureDelta extends CDOFeatureDelta -{ -} +/*
+ * Copyright (c) 2004 - 2012 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:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.common.revision.delta;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * A {@link CDOFeatureDelta feature delta} that represents the removal of all elements from a many-valued
+ * {@link EStructuralFeature feature}.
+ *
+ * @author Simon McDuff
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDOClearFeatureDelta extends CDOFeatureDelta
+{
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOContainerFeatureDelta.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOContainerFeatureDelta.java index 628c213603..0a55ae00a6 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOContainerFeatureDelta.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOContainerFeatureDelta.java @@ -1,46 +1,46 @@ -/* - * Copyright (c) 2004 - 2011 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: - * Simon McDuff - initial API and implementation - * Eike Stepper - maintenance - * Simon McDuff - bug 213402 - */ -package org.eclipse.emf.cdo.common.revision.delta; - -import org.eclipse.emf.cdo.common.id.CDOID; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.EReference; - -/** - * A {@link CDOFeatureDelta feature delta} that represents a modification of the {@link EObject#eContainer() eContainer} - * feature. - * - * @author Simon McDuff - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDOContainerFeatureDelta extends CDOFeatureDelta -{ - /** - * @since 2.0 - */ - public static final EReference CONTAINER_FEATURE = new org.eclipse.emf.cdo.internal.common.revision.delta.CDOContainerFeatureDeltaImpl.ContainerFeature(); - - /** - * @since 2.0 - */ - public CDOID getResourceID(); - - /** - * @since 2.0 - */ - public Object getContainerID(); - - public int getContainerFeatureID(); -} +/*
+ * Copyright (c) 2004 - 2012 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:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ * Simon McDuff - bug 213402
+ */
+package org.eclipse.emf.cdo.common.revision.delta;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EReference;
+
+/**
+ * A {@link CDOFeatureDelta feature delta} that represents a modification of the {@link EObject#eContainer() eContainer}
+ * feature.
+ *
+ * @author Simon McDuff
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDOContainerFeatureDelta extends CDOFeatureDelta
+{
+ /**
+ * @since 2.0
+ */
+ public static final EReference CONTAINER_FEATURE = new org.eclipse.emf.cdo.internal.common.revision.delta.CDOContainerFeatureDeltaImpl.ContainerFeature();
+
+ /**
+ * @since 2.0
+ */
+ public CDOID getResourceID();
+
+ /**
+ * @since 2.0
+ */
+ public Object getContainerID();
+
+ public int getContainerFeatureID();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOFeatureDelta.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOFeatureDelta.java index c7ae6f3852..c911e1d782 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOFeatureDelta.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOFeatureDelta.java @@ -1,78 +1,78 @@ -/* - * Copyright (c) 2004 - 2011 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: - * Simon McDuff - initial API and implementation - * Eike Stepper - maintenance - */ -package org.eclipse.emf.cdo.common.revision.delta; - -import org.eclipse.emf.cdo.common.revision.CDORevision; - -import org.eclipse.emf.common.notify.Notification; -import org.eclipse.emf.ecore.EStructuralFeature; - -/** - * Represents a change delta between two values of a single {@link EStructuralFeature feature}. - * - * @author Simon McDuff - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.landmark - * @apiviz.has {@link org.eclipse.emf.ecore.EStructuralFeature} - * @apiviz.has {@link CDOFeatureDelta.Type} - */ -public interface CDOFeatureDelta -{ - /** - * @since 4.0 - */ - public static final int NO_INDEX = Notification.NO_INDEX; - - /** - * @since 3.0 - */ - public static final Object UNKNOWN_VALUE = new Object() - { - @Override - public String toString() - { - return "UNKNOWN"; //$NON-NLS-1$ - } - }; - - public Type getType(); - - /** - * @since 2.0 - */ - public EStructuralFeature getFeature(); - - public void apply(CDORevision revision); - - public void accept(CDOFeatureDeltaVisitor visitor); - - /** - * @since 3.0 - */ - public CDOFeatureDelta copy(); - - /** - * @since 4.0 - */ - public boolean isStructurallyEqual(Object obj); - - /** - * Enumerates the possible types of {@link CDOFeatureDelta feature deltas}. - * - * @author Simon McDuff - */ - public enum Type - { - ADD, REMOVE, CLEAR, MOVE, SET, UNSET, LIST, CONTAINER - } -} +/*
+ * Copyright (c) 2004 - 2012 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:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.common.revision.delta;
+
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * Represents a change delta between two values of a single {@link EStructuralFeature feature}.
+ *
+ * @author Simon McDuff
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.landmark
+ * @apiviz.has {@link org.eclipse.emf.ecore.EStructuralFeature}
+ * @apiviz.has {@link CDOFeatureDelta.Type}
+ */
+public interface CDOFeatureDelta
+{
+ /**
+ * @since 4.0
+ */
+ public static final int NO_INDEX = Notification.NO_INDEX;
+
+ /**
+ * @since 3.0
+ */
+ public static final Object UNKNOWN_VALUE = new Object()
+ {
+ @Override
+ public String toString()
+ {
+ return "UNKNOWN"; //$NON-NLS-1$
+ }
+ };
+
+ public Type getType();
+
+ /**
+ * @since 2.0
+ */
+ public EStructuralFeature getFeature();
+
+ public void apply(CDORevision revision);
+
+ public void accept(CDOFeatureDeltaVisitor visitor);
+
+ /**
+ * @since 3.0
+ */
+ public CDOFeatureDelta copy();
+
+ /**
+ * @since 4.0
+ */
+ public boolean isStructurallyEqual(Object obj);
+
+ /**
+ * Enumerates the possible types of {@link CDOFeatureDelta feature deltas}.
+ *
+ * @author Simon McDuff
+ */
+ public enum Type
+ {
+ ADD, REMOVE, CLEAR, MOVE, SET, UNSET, LIST, CONTAINER
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOFeatureDeltaVisitor.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOFeatureDeltaVisitor.java index 17fb77151f..f86ff72900 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOFeatureDeltaVisitor.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOFeatureDeltaVisitor.java @@ -1,38 +1,38 @@ -/* - * Copyright (c) 2004 - 2011 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: - * Simon McDuff - initial API and implementation - * Eike Stepper - maintenance - */ -package org.eclipse.emf.cdo.common.revision.delta; - -/** - * Visits all {@link CDOFeatureDelta feature deltas} of a {@link CDORevisionDelta revision delta}. - * - * @see CDORevisionDelta#accept(CDOFeatureDeltaVisitor) - * @author Simon McDuff - * @apiviz.uses {@link CDOFeatureDelta} - - visits - */ -public interface CDOFeatureDeltaVisitor -{ - public void visit(CDOMoveFeatureDelta delta); - - public void visit(CDOAddFeatureDelta delta); - - public void visit(CDORemoveFeatureDelta delta); - - public void visit(CDOSetFeatureDelta delta); - - public void visit(CDOUnsetFeatureDelta delta); - - public void visit(CDOListFeatureDelta delta); - - public void visit(CDOClearFeatureDelta delta); - - public void visit(CDOContainerFeatureDelta delta); -} +/*
+ * Copyright (c) 2004 - 2012 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:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.common.revision.delta;
+
+/**
+ * Visits all {@link CDOFeatureDelta feature deltas} of a {@link CDORevisionDelta revision delta}.
+ *
+ * @see CDORevisionDelta#accept(CDOFeatureDeltaVisitor)
+ * @author Simon McDuff
+ * @apiviz.uses {@link CDOFeatureDelta} - - visits
+ */
+public interface CDOFeatureDeltaVisitor
+{
+ public void visit(CDOMoveFeatureDelta delta);
+
+ public void visit(CDOAddFeatureDelta delta);
+
+ public void visit(CDORemoveFeatureDelta delta);
+
+ public void visit(CDOSetFeatureDelta delta);
+
+ public void visit(CDOUnsetFeatureDelta delta);
+
+ public void visit(CDOListFeatureDelta delta);
+
+ public void visit(CDOClearFeatureDelta delta);
+
+ public void visit(CDOContainerFeatureDelta delta);
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOListFeatureDelta.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOListFeatureDelta.java index c0b15aee40..1495f5e188 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOListFeatureDelta.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOListFeatureDelta.java @@ -1,31 +1,31 @@ -/* - * Copyright (c) 2004 - 2011 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: - * Simon McDuff - initial API and implementation - * Eike Stepper - maintenance - */ -package org.eclipse.emf.cdo.common.revision.delta; - -import org.eclipse.emf.ecore.EStructuralFeature; - -import java.util.List; - -/** - * A {@link CDOFeatureDelta feature delta} that represents any modification of the list of a many-valued - * {@link EStructuralFeature feature}. The detailed changes to this list are returned by the {@link #getListChanges()} - * method. - * - * @author Simon McDuff - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.composedOf {@link CDOFeatureDelta} - - listChanges - */ -public interface CDOListFeatureDelta extends CDOFeatureDelta -{ - public List<CDOFeatureDelta> getListChanges(); -} +/*
+ * Copyright (c) 2004 - 2012 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:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.common.revision.delta;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import java.util.List;
+
+/**
+ * A {@link CDOFeatureDelta feature delta} that represents any modification of the list of a many-valued
+ * {@link EStructuralFeature feature}. The detailed changes to this list are returned by the {@link #getListChanges()}
+ * method.
+ *
+ * @author Simon McDuff
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.composedOf {@link CDOFeatureDelta} - - listChanges
+ */
+public interface CDOListFeatureDelta extends CDOFeatureDelta
+{
+ public List<CDOFeatureDelta> getListChanges();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOMoveFeatureDelta.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOMoveFeatureDelta.java index 669309bfe6..a2f5ad9ca2 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOMoveFeatureDelta.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOMoveFeatureDelta.java @@ -1,34 +1,34 @@ -/* - * Copyright (c) 2004 - 2011 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: - * Simon McDuff - initial API and implementation - * Eike Stepper - maintenance - */ -package org.eclipse.emf.cdo.common.revision.delta; - -import org.eclipse.emf.ecore.EStructuralFeature; - -/** - * A {@link CDOFeatureDelta feature delta} that represents a move of one element of a many-valued - * {@link EStructuralFeature feature} to a different list position. - * - * @author Simon McDuff - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDOMoveFeatureDelta extends CDOFeatureDelta -{ - public int getOldPosition(); - - public int getNewPosition(); - - /** - * @since 4.0 - */ - public Object getValue(); -} +/*
+ * Copyright (c) 2004 - 2012 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:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.common.revision.delta;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * A {@link CDOFeatureDelta feature delta} that represents a move of one element of a many-valued
+ * {@link EStructuralFeature feature} to a different list position.
+ *
+ * @author Simon McDuff
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDOMoveFeatureDelta extends CDOFeatureDelta
+{
+ public int getOldPosition();
+
+ public int getNewPosition();
+
+ /**
+ * @since 4.0
+ */
+ public Object getValue();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDORemoveFeatureDelta.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDORemoveFeatureDelta.java index 530ccd0129..578c6de287 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDORemoveFeatureDelta.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDORemoveFeatureDelta.java @@ -1,32 +1,32 @@ -/* - * Copyright (c) 2004 - 2011 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: - * Simon McDuff - initial API and implementation - * Eike Stepper - maintenance - */ -package org.eclipse.emf.cdo.common.revision.delta; - -import org.eclipse.emf.ecore.EStructuralFeature; - -/** - * A {@link CDOFeatureDelta feature delta} that represents a removal from a many-valued {@link EStructuralFeature - * feature}. - * - * @author Simon McDuff - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDORemoveFeatureDelta extends CDOFeatureDelta -{ - public int getIndex(); - - /** - * @since 3.0 - */ - public Object getValue(); -} +/*
+ * Copyright (c) 2004 - 2012 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:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.common.revision.delta;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * A {@link CDOFeatureDelta feature delta} that represents a removal from a many-valued {@link EStructuralFeature
+ * feature}.
+ *
+ * @author Simon McDuff
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDORemoveFeatureDelta extends CDOFeatureDelta
+{
+ public int getIndex();
+
+ /**
+ * @since 3.0
+ */
+ public Object getValue();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDORevisionDelta.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDORevisionDelta.java index 47c8433db5..a9d6a4e639 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDORevisionDelta.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDORevisionDelta.java @@ -1,88 +1,88 @@ -/* - * Copyright (c) 2004 - 2011 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 201266 - */ -package org.eclipse.emf.cdo.common.revision.delta; - -import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; -import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; -import org.eclipse.emf.cdo.common.revision.CDORevisable; -import org.eclipse.emf.cdo.common.revision.CDORevision; -import org.eclipse.emf.cdo.common.revision.CDORevisionData; -import org.eclipse.emf.cdo.common.revision.CDORevisionKey; -import org.eclipse.emf.cdo.internal.common.revision.delta.CDODetachedRevisionDeltaImpl; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EStructuralFeature; - -import java.util.List; - -/** - * Represents the change delta between two {@link CDORevision revisions} of a CDO object. The detailed - * {@link CDOFeatureDelta feature deltas} are returned by the {@link #getFeatureDeltas()} method. - * - * @author Eike Stepper - * @since 2.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - * @apiviz.landmark - * @apiviz.has {@link org.eclipse.emf.ecore.EClass} - * @apiviz.has {@link org.eclipse.emf.cdo.common.revision.CDORevisable} oneway - - target - * @apiviz.composedOf {@link CDOFeatureDelta} - */ -public interface CDORevisionDelta extends CDORevisionKey -{ - /** - * This constant is only passed into conflict resolvers to indicate that a conflict was caused by remote detachment of - * an object. Calling any method on this marker instance will result in an {@link UnsupportedOperationException} being - * thrown. - * - * @since 4.0 - */ - public static final CDORevisionDelta DETACHED = new CDODetachedRevisionDeltaImpl(); - - /** - * @since 3.0 - */ - public EClass getEClass(); - - /** - * @since 4.0 - */ - public CDORevisable getTarget(); - - /** - * @since 3.0 - */ - public boolean isEmpty(); - - /** - * @since 4.0 - */ - public CDORevisionDelta copy(); - - /** - * @since 4.0 - */ - public CDOFeatureDelta getFeatureDelta(EStructuralFeature feature); - - public List<CDOFeatureDelta> getFeatureDeltas(); - - /** - * Applies the {@link #getFeatureDeltas() feature deltas} in this revision delta to the {@link CDORevisionData data} - * of the given revision. - * <p> - * The system data of the given revision, e.g. {@link CDOBranchPoint branch point} or {@link CDOBranchVersion branch - * version} of the given revision are <b>not</b> modified. - */ - public void apply(CDORevision revision); - - public void accept(CDOFeatureDeltaVisitor visitor); -} +/*
+ * Copyright (c) 2004 - 2012 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 201266
+ */
+package org.eclipse.emf.cdo.common.revision.delta;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
+import org.eclipse.emf.cdo.common.revision.CDORevisable;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionData;
+import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
+import org.eclipse.emf.cdo.internal.common.revision.delta.CDODetachedRevisionDeltaImpl;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import java.util.List;
+
+/**
+ * Represents the change delta between two {@link CDORevision revisions} of a CDO object. The detailed
+ * {@link CDOFeatureDelta feature deltas} are returned by the {@link #getFeatureDeltas()} method.
+ *
+ * @author Eike Stepper
+ * @since 2.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * @apiviz.landmark
+ * @apiviz.has {@link org.eclipse.emf.ecore.EClass}
+ * @apiviz.has {@link org.eclipse.emf.cdo.common.revision.CDORevisable} oneway - - target
+ * @apiviz.composedOf {@link CDOFeatureDelta}
+ */
+public interface CDORevisionDelta extends CDORevisionKey
+{
+ /**
+ * This constant is only passed into conflict resolvers to indicate that a conflict was caused by remote detachment of
+ * an object. Calling any method on this marker instance will result in an {@link UnsupportedOperationException} being
+ * thrown.
+ *
+ * @since 4.0
+ */
+ public static final CDORevisionDelta DETACHED = new CDODetachedRevisionDeltaImpl();
+
+ /**
+ * @since 3.0
+ */
+ public EClass getEClass();
+
+ /**
+ * @since 4.0
+ */
+ public CDORevisable getTarget();
+
+ /**
+ * @since 3.0
+ */
+ public boolean isEmpty();
+
+ /**
+ * @since 4.0
+ */
+ public CDORevisionDelta copy();
+
+ /**
+ * @since 4.0
+ */
+ public CDOFeatureDelta getFeatureDelta(EStructuralFeature feature);
+
+ public List<CDOFeatureDelta> getFeatureDeltas();
+
+ /**
+ * Applies the {@link #getFeatureDeltas() feature deltas} in this revision delta to the {@link CDORevisionData data}
+ * of the given revision.
+ * <p>
+ * The system data of the given revision, e.g. {@link CDOBranchPoint branch point} or {@link CDOBranchVersion branch
+ * version} of the given revision are <b>not</b> modified.
+ */
+ public void apply(CDORevision revision);
+
+ public void accept(CDOFeatureDeltaVisitor visitor);
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDORevisionDeltaProvider.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDORevisionDeltaProvider.java index 213f842b4c..f5f99b1582 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDORevisionDeltaProvider.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDORevisionDeltaProvider.java @@ -1,25 +1,25 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.revision.delta; - -import org.eclipse.emf.cdo.common.id.CDOID; - -/** - * Provides consumers with the {@link CDORevisionDelta revision deltas} of {@link CDOID identifiable} CDO objects. - * - * @author Eike Stepper - * @since 4.0 - * @apiviz.uses {@link CDORevisionDelta} - - provides - */ -public interface CDORevisionDeltaProvider -{ - public CDORevisionDelta getRevisionDelta(CDOID id); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.revision.delta;
+
+import org.eclipse.emf.cdo.common.id.CDOID;
+
+/**
+ * Provides consumers with the {@link CDORevisionDelta revision deltas} of {@link CDOID identifiable} CDO objects.
+ *
+ * @author Eike Stepper
+ * @since 4.0
+ * @apiviz.uses {@link CDORevisionDelta} - - provides
+ */
+public interface CDORevisionDeltaProvider
+{
+ public CDORevisionDelta getRevisionDelta(CDOID id);
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOSetFeatureDelta.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOSetFeatureDelta.java index bbcc2ad3ef..36f43c2755 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOSetFeatureDelta.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOSetFeatureDelta.java @@ -1,39 +1,39 @@ -/* - * Copyright (c) 2004 - 2011 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: - * Simon McDuff - initial API and implementation - * Eike Stepper - maintenance - */ -package org.eclipse.emf.cdo.common.revision.delta; - -import org.eclipse.emf.ecore.EStructuralFeature; - -/** - * A {@link CDOFeatureDelta feature delta} that represents a value change of a single-valued {@link EStructuralFeature - * feature}. - * - * @author Simon McDuff - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDOSetFeatureDelta extends CDOFeatureDelta -{ - /** - * @since 4.0 - */ - public static final Object UNSPECIFIED = new Object(); - - public int getIndex(); - - public Object getValue(); - - /** - * @since 4.0 - */ - public Object getOldValue(); -} +/*
+ * Copyright (c) 2004 - 2012 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:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.common.revision.delta;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * A {@link CDOFeatureDelta feature delta} that represents a value change of a single-valued {@link EStructuralFeature
+ * feature}.
+ *
+ * @author Simon McDuff
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDOSetFeatureDelta extends CDOFeatureDelta
+{
+ /**
+ * @since 4.0
+ */
+ public static final Object UNSPECIFIED = new Object();
+
+ public int getIndex();
+
+ public Object getValue();
+
+ /**
+ * @since 4.0
+ */
+ public Object getOldValue();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOUnsetFeatureDelta.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOUnsetFeatureDelta.java index fccb6b57f1..a3e495f42a 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOUnsetFeatureDelta.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOUnsetFeatureDelta.java @@ -1,26 +1,26 @@ -/* - * Copyright (c) 2004 - 2011 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: - * Simon McDuff - initial API and implementation - * Eike Stepper - maintenance - */ -package org.eclipse.emf.cdo.common.revision.delta; - -import org.eclipse.emf.ecore.EStructuralFeature; - -/** - * A {@link CDOFeatureDelta feature delta} that represents the <em>unsetting</em> of the value of a - * {@link EStructuralFeature feature}. - * - * @author Simon McDuff - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDOUnsetFeatureDelta extends CDOFeatureDelta -{ -} +/*
+ * Copyright (c) 2004 - 2012 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:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.common.revision.delta;
+
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+/**
+ * A {@link CDOFeatureDelta feature delta} that represents the <em>unsetting</em> of the value of a
+ * {@link EStructuralFeature feature}.
+ *
+ * @author Simon McDuff
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDOUnsetFeatureDelta extends CDOFeatureDelta
+{
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/package-info.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/package-info.java index c0b93c464b..244301ea74 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/package-info.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/package-info.java @@ -1,5 +1,5 @@ /*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 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
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/package-info.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/package-info.java index d33bb844ec..7797a7f021 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/package-info.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/package-info.java @@ -1,5 +1,5 @@ /*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 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
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/BlockingCloseableIterator.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/BlockingCloseableIterator.java index 8686d490e0..7b2e36e181 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/BlockingCloseableIterator.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/BlockingCloseableIterator.java @@ -1,29 +1,29 @@ -/* - * Copyright (c) 2004 - 2011 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: - * Simon McDuff - initial API and implementation - * Eike Stepper - maintenance - *************************************************************************/ -package org.eclipse.emf.cdo.common.util; - -import org.eclipse.net4j.util.collection.CloseableIterator; - -/** - * A closeable iterator that blocks on {@link #hasNext()} until the next element is available or the end of the - * iteration is reached. - * - * @author Simon McDuff - * @since 2.0 - */ -public interface BlockingCloseableIterator<T> extends CloseableIterator<T> -{ - /** - * Non-blocking call. - */ - public T peek(); -} +/*
+ * Copyright (c) 2004 - 2012 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:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ *************************************************************************/
+package org.eclipse.emf.cdo.common.util;
+
+import org.eclipse.net4j.util.collection.CloseableIterator;
+
+/**
+ * A closeable iterator that blocks on {@link #hasNext()} until the next element is available or the end of the
+ * iteration is reached.
+ *
+ * @author Simon McDuff
+ * @since 2.0
+ */
+public interface BlockingCloseableIterator<T> extends CloseableIterator<T>
+{
+ /**
+ * Non-blocking call.
+ */
+ public T peek();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOCommonEventAdapter.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOCommonEventAdapter.java index 111ab1ae86..ca59d4e14b 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOCommonEventAdapter.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOCommonEventAdapter.java @@ -1,85 +1,85 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.util; - -import org.eclipse.emf.cdo.common.CDOCommonSession; -import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode; -import org.eclipse.emf.cdo.common.CDOCommonView; - -import org.eclipse.net4j.util.container.ContainerEventAdapter; -import org.eclipse.net4j.util.container.IContainer; -import org.eclipse.net4j.util.event.IEvent; - -/** - * A convenience adapter for common CDO {@link IEvent events}. - * - * @author Eike Stepper - * @since 3.0 - */ -public class CDOCommonEventAdapter extends ContainerEventAdapter<Object> -{ - public CDOCommonEventAdapter() - { - } - - @Override - protected void notifyOtherEvent(IEvent event) - { - if (event instanceof CDOCommonSession.Options.PassiveUpdateEvent) - { - CDOCommonSession.Options.PassiveUpdateEvent e = (CDOCommonSession.Options.PassiveUpdateEvent)event; - boolean oldEnabled = e.getOldEnabled(); - boolean newEnabled = e.getNewEnabled(); - if (oldEnabled != newEnabled) - { - onPassiveUpdatesEnabled(oldEnabled, newEnabled); - } - else - { - onPassiveUpdatesMode(e.getOldMode(), e.getNewMode()); - } - } - } - - @Override - protected void onAdded(IContainer<Object> container, Object element) - { - if (element instanceof CDOCommonView) - { - onViewOpened((CDOCommonView)element); - } - } - - @Override - protected void onRemoved(IContainer<Object> container, Object element) - { - if (element instanceof CDOCommonView) - { - onViewClosed((CDOCommonView)element); - } - } - - protected void onViewOpened(CDOCommonView view) - { - } - - protected void onViewClosed(CDOCommonView element) - { - } - - protected void onPassiveUpdatesEnabled(boolean oldEnabled, boolean newEnabled) - { - } - - protected void onPassiveUpdatesMode(PassiveUpdateMode oldMode, PassiveUpdateMode newMode) - { - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.util;
+
+import org.eclipse.emf.cdo.common.CDOCommonSession;
+import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
+import org.eclipse.emf.cdo.common.CDOCommonView;
+
+import org.eclipse.net4j.util.container.ContainerEventAdapter;
+import org.eclipse.net4j.util.container.IContainer;
+import org.eclipse.net4j.util.event.IEvent;
+
+/**
+ * A convenience adapter for common CDO {@link IEvent events}.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ */
+public class CDOCommonEventAdapter extends ContainerEventAdapter<Object>
+{
+ public CDOCommonEventAdapter()
+ {
+ }
+
+ @Override
+ protected void notifyOtherEvent(IEvent event)
+ {
+ if (event instanceof CDOCommonSession.Options.PassiveUpdateEvent)
+ {
+ CDOCommonSession.Options.PassiveUpdateEvent e = (CDOCommonSession.Options.PassiveUpdateEvent)event;
+ boolean oldEnabled = e.getOldEnabled();
+ boolean newEnabled = e.getNewEnabled();
+ if (oldEnabled != newEnabled)
+ {
+ onPassiveUpdatesEnabled(oldEnabled, newEnabled);
+ }
+ else
+ {
+ onPassiveUpdatesMode(e.getOldMode(), e.getNewMode());
+ }
+ }
+ }
+
+ @Override
+ protected void onAdded(IContainer<Object> container, Object element)
+ {
+ if (element instanceof CDOCommonView)
+ {
+ onViewOpened((CDOCommonView)element);
+ }
+ }
+
+ @Override
+ protected void onRemoved(IContainer<Object> container, Object element)
+ {
+ if (element instanceof CDOCommonView)
+ {
+ onViewClosed((CDOCommonView)element);
+ }
+ }
+
+ protected void onViewOpened(CDOCommonView view)
+ {
+ }
+
+ protected void onViewClosed(CDOCommonView element)
+ {
+ }
+
+ protected void onPassiveUpdatesEnabled(boolean oldEnabled, boolean newEnabled)
+ {
+ }
+
+ protected void onPassiveUpdatesMode(PassiveUpdateMode oldMode, PassiveUpdateMode newMode)
+ {
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOCommonUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOCommonUtil.java index 4dab399657..16785e73c4 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOCommonUtil.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOCommonUtil.java @@ -1,174 +1,174 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.util; - -import org.eclipse.emf.cdo.common.branch.CDOBranchManager; -import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; -import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager; -import org.eclipse.emf.cdo.common.id.CDOIDProvider; -import org.eclipse.emf.cdo.common.lob.CDOLobStore; -import org.eclipse.emf.cdo.common.model.CDOPackageRegistry; -import org.eclipse.emf.cdo.common.protocol.CDODataInput; -import org.eclipse.emf.cdo.common.protocol.CDODataOutput; -import org.eclipse.emf.cdo.common.revision.CDOListFactory; -import org.eclipse.emf.cdo.common.revision.CDORevision; -import org.eclipse.emf.cdo.common.revision.CDORevisionFactory; -import org.eclipse.emf.cdo.internal.common.protocol.CDODataInputImpl; -import org.eclipse.emf.cdo.internal.common.protocol.CDODataOutputImpl; - -import org.eclipse.net4j.util.io.ExtendedDataInputStream; -import org.eclipse.net4j.util.io.ExtendedDataOutput; - -import java.io.IOException; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - -/** - * Various static methods that may help with I/O and time stamps. - * - * @author Eike Stepper - * @since 3.0 - */ -public final class CDOCommonUtil -{ - /** - * @since 4.0 - */ - public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss'.'SSS"); - - private CDOCommonUtil() - { - } - - /** - * @since 4.0 - */ - public static CDODataInput createCDODataInput(ExtendedDataInputStream inputStream, - final CDOPackageRegistry packageRegistry, final CDOBranchManager branchManager, - final CDOCommitInfoManager commitManager, final CDORevisionFactory revisionFactory, - final CDOListFactory listFactory, final CDOLobStore lobStore) throws IOException - { - return new CDODataInputImpl(inputStream) - { - @Override - protected CDOPackageRegistry getPackageRegistry() - { - return packageRegistry; - } - - @Override - protected CDOBranchManager getBranchManager() - { - return branchManager; - } - - @Override - protected CDOCommitInfoManager getCommitInfoManager() - { - return commitManager; - } - - @Override - protected CDORevisionFactory getRevisionFactory() - { - return revisionFactory; - } - - @Override - protected CDOListFactory getListFactory() - { - return listFactory; - } - - @Override - protected CDOLobStore getLobStore() - { - return lobStore; - } - }; - } - - /** - * @since 4.0 - */ - public static CDODataOutput createCDODataOutput(ExtendedDataOutput extendedDataOutputStream, - final CDOPackageRegistry packageRegistry, final CDOIDProvider idProvider) - { - return new CDODataOutputImpl(extendedDataOutputStream) - { - @Override - public CDOPackageRegistry getPackageRegistry() - { - return packageRegistry; - } - - @Override - public CDOIDProvider getIDProvider() - { - return idProvider; - } - }; - } - - public static boolean isValidTimeStamp(long timeStamp, long startTime, long endTime) - { - if (timeStamp == CDOBranchPoint.UNSPECIFIED_DATE) - { - return endTime == CDOBranchPoint.UNSPECIFIED_DATE; - } - - return (endTime == CDOBranchPoint.UNSPECIFIED_DATE || endTime >= timeStamp) && timeStamp >= startTime; - } - - public static int compareTimeStamps(long t1, long t2) - { - if (t1 == CDORevision.UNSPECIFIED_DATE) - { - t1 = Long.MAX_VALUE; - } - - if (t2 == CDORevision.UNSPECIFIED_DATE) - { - t2 = Long.MAX_VALUE; - } - - return t1 < t2 ? -1 : t1 == t2 ? 0 : 1; - } - - public static String formatTimeStamp() - { - return formatTimeStamp(System.currentTimeMillis()); - } - - public static String formatTimeStamp(long timeStamp) - { - if (timeStamp == CDORevision.UNSPECIFIED_DATE) - { - return "*"; - } - - return DATE_FORMAT.format(new Date(timeStamp)); - } - - /** - * @since 4.0 - */ - public static long parseTimeStamp(String timeStamp) throws ParseException - { - if ("*".equals(timeStamp)) - { - return CDORevision.UNSPECIFIED_DATE; - } - - return DATE_FORMAT.parse(timeStamp).getTime(); - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.util;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
+import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
+import org.eclipse.emf.cdo.common.id.CDOIDProvider;
+import org.eclipse.emf.cdo.common.lob.CDOLobStore;
+import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+import org.eclipse.emf.cdo.common.revision.CDOListFactory;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
+import org.eclipse.emf.cdo.internal.common.protocol.CDODataInputImpl;
+import org.eclipse.emf.cdo.internal.common.protocol.CDODataOutputImpl;
+
+import org.eclipse.net4j.util.io.ExtendedDataInputStream;
+import org.eclipse.net4j.util.io.ExtendedDataOutput;
+
+import java.io.IOException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * Various static methods that may help with I/O and time stamps.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ */
+public final class CDOCommonUtil
+{
+ /**
+ * @since 4.0
+ */
+ public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss'.'SSS");
+
+ private CDOCommonUtil()
+ {
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static CDODataInput createCDODataInput(ExtendedDataInputStream inputStream,
+ final CDOPackageRegistry packageRegistry, final CDOBranchManager branchManager,
+ final CDOCommitInfoManager commitManager, final CDORevisionFactory revisionFactory,
+ final CDOListFactory listFactory, final CDOLobStore lobStore) throws IOException
+ {
+ return new CDODataInputImpl(inputStream)
+ {
+ @Override
+ protected CDOPackageRegistry getPackageRegistry()
+ {
+ return packageRegistry;
+ }
+
+ @Override
+ protected CDOBranchManager getBranchManager()
+ {
+ return branchManager;
+ }
+
+ @Override
+ protected CDOCommitInfoManager getCommitInfoManager()
+ {
+ return commitManager;
+ }
+
+ @Override
+ protected CDORevisionFactory getRevisionFactory()
+ {
+ return revisionFactory;
+ }
+
+ @Override
+ protected CDOListFactory getListFactory()
+ {
+ return listFactory;
+ }
+
+ @Override
+ protected CDOLobStore getLobStore()
+ {
+ return lobStore;
+ }
+ };
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static CDODataOutput createCDODataOutput(ExtendedDataOutput extendedDataOutputStream,
+ final CDOPackageRegistry packageRegistry, final CDOIDProvider idProvider)
+ {
+ return new CDODataOutputImpl(extendedDataOutputStream)
+ {
+ @Override
+ public CDOPackageRegistry getPackageRegistry()
+ {
+ return packageRegistry;
+ }
+
+ @Override
+ public CDOIDProvider getIDProvider()
+ {
+ return idProvider;
+ }
+ };
+ }
+
+ public static boolean isValidTimeStamp(long timeStamp, long startTime, long endTime)
+ {
+ if (timeStamp == CDOBranchPoint.UNSPECIFIED_DATE)
+ {
+ return endTime == CDOBranchPoint.UNSPECIFIED_DATE;
+ }
+
+ return (endTime == CDOBranchPoint.UNSPECIFIED_DATE || endTime >= timeStamp) && timeStamp >= startTime;
+ }
+
+ public static int compareTimeStamps(long t1, long t2)
+ {
+ if (t1 == CDORevision.UNSPECIFIED_DATE)
+ {
+ t1 = Long.MAX_VALUE;
+ }
+
+ if (t2 == CDORevision.UNSPECIFIED_DATE)
+ {
+ t2 = Long.MAX_VALUE;
+ }
+
+ return t1 < t2 ? -1 : t1 == t2 ? 0 : 1;
+ }
+
+ public static String formatTimeStamp()
+ {
+ return formatTimeStamp(System.currentTimeMillis());
+ }
+
+ public static String formatTimeStamp(long timeStamp)
+ {
+ if (timeStamp == CDORevision.UNSPECIFIED_DATE)
+ {
+ return "*";
+ }
+
+ return DATE_FORMAT.format(new Date(timeStamp));
+ }
+
+ /**
+ * @since 4.0
+ */
+ public static long parseTimeStamp(String timeStamp) throws ParseException
+ {
+ if ("*".equals(timeStamp))
+ {
+ return CDORevision.UNSPECIFIED_DATE;
+ }
+
+ return DATE_FORMAT.parse(timeStamp).getTime();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOException.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOException.java index 9be82f2df7..ad35efb2af 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOException.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOException.java @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.util; - -/** - * An unchecked exception for general CDO purposes. - * - * @author Eike Stepper - */ -public class CDOException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - public CDOException() - { - } - - public CDOException(String message) - { - super(message); - } - - public CDOException(Throwable cause) - { - super(cause); - } - - public CDOException(String message, Throwable cause) - { - super(message, cause); - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.util;
+
+/**
+ * An unchecked exception for general CDO purposes.
+ *
+ * @author Eike Stepper
+ */
+public class CDOException extends RuntimeException
+{
+ private static final long serialVersionUID = 1L;
+
+ public CDOException()
+ {
+ }
+
+ public CDOException(String message)
+ {
+ super(message);
+ }
+
+ public CDOException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ public CDOException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOFetchRule.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOFetchRule.java index 432c8ab0eb..f8fe8d88fb 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOFetchRule.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOFetchRule.java @@ -1,88 +1,88 @@ -/* - * Copyright (c) 2004 - 2011 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: - * Simon McDuff - initial API and implementation - * Eike Stepper - maintenance - */ -package org.eclipse.emf.cdo.common.util; - -import org.eclipse.emf.cdo.common.model.CDOPackageRegistry; -import org.eclipse.emf.cdo.common.protocol.CDODataInput; -import org.eclipse.emf.cdo.common.protocol.CDODataOutput; - -import org.eclipse.emf.ecore.EClass; -import org.eclipse.emf.ecore.EStructuralFeature; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -/** - * Represents a subset of the {@link EStructuralFeature features} of a {@link EClass class}. - * - * @author Simon McDuff - * @since 3.0 - */ -public final class CDOFetchRule -{ - private EClass eClass; - - private List<EStructuralFeature> features = new ArrayList<EStructuralFeature>(0); - - public CDOFetchRule(EClass eClass) - { - this.eClass = eClass; - } - - public CDOFetchRule(CDODataInput in, CDOPackageRegistry packageManager) throws IOException - { - eClass = (EClass)in.readCDOClassifierRefAndResolve(); - int size = in.readInt(); - for (int i = 0; i < size; i++) - { - int featureID = in.readInt(); - EStructuralFeature feature = eClass.getEStructuralFeature(featureID); - features.add(feature); - } - } - - public void write(CDODataOutput out) throws IOException - { - out.writeCDOClassifierRef(eClass); - out.writeInt(features.size()); - for (EStructuralFeature feature : features) - { - out.writeInt(feature.getFeatureID()); - } - } - - public EClass getEClass() - { - return eClass; - } - - public List<EStructuralFeature> getFeatures() - { - return features; - } - - public void addFeature(EStructuralFeature feature) - { - features.add(feature); - } - - public void removeFeature(EStructuralFeature feature) - { - features.remove(feature); - } - - public boolean isEmpty() - { - return features.isEmpty(); - } -} +/*
+ * Copyright (c) 2004 - 2012 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:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.common.util;
+
+import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
+import org.eclipse.emf.cdo.common.protocol.CDODataInput;
+import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
+
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Represents a subset of the {@link EStructuralFeature features} of a {@link EClass class}.
+ *
+ * @author Simon McDuff
+ * @since 3.0
+ */
+public final class CDOFetchRule
+{
+ private EClass eClass;
+
+ private List<EStructuralFeature> features = new ArrayList<EStructuralFeature>(0);
+
+ public CDOFetchRule(EClass eClass)
+ {
+ this.eClass = eClass;
+ }
+
+ public CDOFetchRule(CDODataInput in, CDOPackageRegistry packageManager) throws IOException
+ {
+ eClass = (EClass)in.readCDOClassifierRefAndResolve();
+ int size = in.readInt();
+ for (int i = 0; i < size; i++)
+ {
+ int featureID = in.readInt();
+ EStructuralFeature feature = eClass.getEStructuralFeature(featureID);
+ features.add(feature);
+ }
+ }
+
+ public void write(CDODataOutput out) throws IOException
+ {
+ out.writeCDOClassifierRef(eClass);
+ out.writeInt(features.size());
+ for (EStructuralFeature feature : features)
+ {
+ out.writeInt(feature.getFeatureID());
+ }
+ }
+
+ public EClass getEClass()
+ {
+ return eClass;
+ }
+
+ public List<EStructuralFeature> getFeatures()
+ {
+ return features;
+ }
+
+ public void addFeature(EStructuralFeature feature)
+ {
+ features.add(feature);
+ }
+
+ public void removeFeature(EStructuralFeature feature)
+ {
+ features.remove(feature);
+ }
+
+ public boolean isEmpty()
+ {
+ return features.isEmpty();
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOQueryInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOQueryInfo.java index 8f5880724b..8a8d19aa1e 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOQueryInfo.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOQueryInfo.java @@ -1,75 +1,75 @@ -/* - * Copyright (c) 2004 - 2011 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: - * Simon McDuff - initial API and implementation - * Eike Stepper - maintenance - */ -package org.eclipse.emf.cdo.common.util; - -import org.eclipse.emf.cdo.common.CDOCommonRepository; -import org.eclipse.emf.cdo.common.CDOCommonView; -import org.eclipse.emf.cdo.common.commit.CDOChangeSetData; - -import java.util.Map; - -/** - * Encapsulates all the transferrable information that fully specifies a query from a {@link CDOCommonView view} to a - * {@link CDOCommonRepository repository}. - * - * @author Simon McDuff - * @since 3.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public interface CDOQueryInfo -{ - public static final int UNLIMITED_RESULTS = -1; - - /** - * Returns the language identifier of this query, never <code>null</code>. - */ - public String getQueryLanguage(); - - /** - * Returns the query string of this query or <code>null</code> if no query string has been set. - */ - public String getQueryString(); - - /** - * Returns the parameters of this query as a map. - */ - public Map<String, Object> getParameters(); - - /** - * Returns the context object, or <code>null</code> if no context is bound. - * - * @since 4.0 - */ - public Object getContext(); - - /** - * Returns the maximum number of results to retrieve or {@link #UNLIMITED_RESULTS} for no limitation. - */ - public int getMaxResults(); - - /** - * Returns <code>true</code> if the view of this query had legacy mode enabled at the time this query was created, - * <code>false</code> otherwise. - * - * @since 4.0 - */ - public boolean isLegacyModeEnabled(); - - /** - * Returns the {@link CDOChangeSetData change set} to be considered if this query has been created by a dirty - * transaction, <code>null</code> otherwise. - * - * @since 4.0 - */ - public CDOChangeSetData getChangeSetData(); -} +/*
+ * Copyright (c) 2004 - 2012 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:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.common.util;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository;
+import org.eclipse.emf.cdo.common.CDOCommonView;
+import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
+
+import java.util.Map;
+
+/**
+ * Encapsulates all the transferrable information that fully specifies a query from a {@link CDOCommonView view} to a
+ * {@link CDOCommonRepository repository}.
+ *
+ * @author Simon McDuff
+ * @since 3.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface CDOQueryInfo
+{
+ public static final int UNLIMITED_RESULTS = -1;
+
+ /**
+ * Returns the language identifier of this query, never <code>null</code>.
+ */
+ public String getQueryLanguage();
+
+ /**
+ * Returns the query string of this query or <code>null</code> if no query string has been set.
+ */
+ public String getQueryString();
+
+ /**
+ * Returns the parameters of this query as a map.
+ */
+ public Map<String, Object> getParameters();
+
+ /**
+ * Returns the context object, or <code>null</code> if no context is bound.
+ *
+ * @since 4.0
+ */
+ public Object getContext();
+
+ /**
+ * Returns the maximum number of results to retrieve or {@link #UNLIMITED_RESULTS} for no limitation.
+ */
+ public int getMaxResults();
+
+ /**
+ * Returns <code>true</code> if the view of this query had legacy mode enabled at the time this query was created,
+ * <code>false</code> otherwise.
+ *
+ * @since 4.0
+ */
+ public boolean isLegacyModeEnabled();
+
+ /**
+ * Returns the {@link CDOChangeSetData change set} to be considered if this query has been created by a dirty
+ * transaction, <code>null</code> otherwise.
+ *
+ * @since 4.0
+ */
+ public CDOChangeSetData getChangeSetData();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOQueryQueue.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOQueryQueue.java index deee8997ed..576522c67f 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOQueryQueue.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOQueryQueue.java @@ -1,415 +1,415 @@ -/* - * Copyright (c) 2004 - 2011 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: - * Simon McDuff - initial API and implementation - * Eike Stepper - maintenance - */ -package org.eclipse.emf.cdo.common.util; - -import org.eclipse.net4j.util.WrappedException; -import org.eclipse.net4j.util.collection.Closeable; - -import java.util.Collection; -import java.util.Comparator; -import java.util.NoSuchElementException; -import java.util.Queue; -import java.util.concurrent.PriorityBlockingQueue; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.atomic.AtomicLong; - -/** - * The {@link Queue queue} that represents the result of a CDOQuery. - * - * @author Simon McDuff - * @since 2.0 - * @noextend This interface is not intended to be extended by clients. - * @noimplement This interface is not intended to be implemented by clients. - */ -public class CDOQueryQueue<E> implements Queue<E>, Closeable -{ - // Static not allowed due to <E> - private final QueueEntry<E> QUEUE_CLOSED = new QueueEntry<E>(); - - private PriorityBlockingQueue<QueueEntry<E>> queue = new PriorityBlockingQueue<QueueEntry<E>>(10); - - private boolean closed; - - private Object closeLock = new Object(); - - public CDOQueryQueue() - { - } - - public void setException(Throwable exception) - { - queue.add(new QueueEntry<E>(exception)); - } - - public void close() - { - synchronized (closeLock) - { - if (!closed) - { - closed = true; - queue.add(QUEUE_CLOSED); - } - } - } - - public boolean isClosed() - { - synchronized (closeLock) - { - return closed; - } - } - - public boolean add(E e) - { - return queue.add(new QueueEntry<E>(e)); - } - - public void clear() - { - queue.clear(); - } - - public boolean contains(Object o) - { - return queue.contains(o); - } - - public E element() - { - return checkObject(queue.element()); - } - - @Override - public boolean equals(Object obj) - { - return queue.equals(obj); - } - - @Override - public int hashCode() - { - return queue.hashCode(); - } - - public boolean isEmpty() - { - return queue.isEmpty(); - } - - public BlockingCloseableIterator<E> iterator() - { - return new BlockingCloseableIteratorImpl(); - } - - public boolean offer(E e, long timeout, TimeUnit unit) - { - return queue.offer(new QueueEntry<E>(e), timeout, unit); - } - - public boolean offer(E e) - { - return queue.offer(new QueueEntry<E>(e)); - } - - public E peek() - { - return checkObject(queue.peek()); - } - - public E poll(long timeout, TimeUnit unit) throws InterruptedException - { - return checkObject(queue.poll(timeout, unit)); - } - - public void put(E e) - { - queue.put(new QueueEntry<E>(e)); - } - - public int remainingCapacity() - { - return queue.remainingCapacity(); - } - - public E remove() - { - return checkObject(queue.remove()); - } - - public boolean remove(Object o) - { - return queue.remove(o); - } - - public int size() - { - return queue.size(); - } - - public E take() throws InterruptedException - { - QueueEntry<E> entry = null; - - entry = queue.take(); - - return checkObject(entry); - } - - public Object[] toArray() - { - return queue.toArray(); - } - - @SuppressWarnings("unchecked") - public Object[] toArray(Object[] a) - { - return queue.toArray(a); - } - - @Override - public String toString() - { - return queue.toString(); - } - - public E poll() - { - QueueEntry<E> entry = queue.poll(); - return checkObject(entry); - } - - public Comparator<?> comparator() - { - throw new UnsupportedOperationException(); - } - - public boolean containsAll(Collection<?> c) - { - throw new UnsupportedOperationException(); - } - - public boolean addAll(Collection<? extends E> c) - { - throw new UnsupportedOperationException(); - } - - public boolean removeAll(Collection<?> c) - { - throw new UnsupportedOperationException(); - } - - public boolean retainAll(Collection<?> c) - { - throw new UnsupportedOperationException(); - } - - private E checkObject(QueueEntry<E> entry) - { - if (entry == null || entry == QUEUE_CLOSED) - { - return null; - } - - return entry.getObjectWithException(); - } - - /** - * @author Simon McDuff - * @since 2.0 - */ - private static class QueueEntry<E> implements Comparable<QueueEntry<E>> - { - private static final AtomicLong nextSeq = new AtomicLong(0); - - private long seqNumber; - - private Object internalObject; - - public QueueEntry() - { - seqNumber = Long.MAX_VALUE; - } - - public QueueEntry(E object) - { - internalObject = object; - seqNumber = nextSeq.getAndIncrement(); - } - - public QueueEntry(Throwable object) - { - internalObject = object; - seqNumber = nextSeq.getAndIncrement(); - } - - @SuppressWarnings("unchecked") - public E getObjectWithException() - { - Throwable exception = getException(); - if (exception instanceof Exception) - { - throw WrappedException.wrap((Exception)exception); - } - else if (exception instanceof Error) - { - throw (Error)exception; - } - - return (E)internalObject; - } - - public Throwable getException() - { - if (internalObject instanceof Throwable) - { - return (Throwable)internalObject; - } - - return null; - } - - public int compareTo(QueueEntry<E> o) - { - if (getException() != null) - { - return -1; - } - - if (o.getException() != null) - { - return 1; - } - - if (this == o) - { - return 0; - } - - if (seqNumber == o.seqNumber) - { - // Should not be possible - return 0; - } - - return seqNumber < o.seqNumber ? -1 : 1; - } - - // @Override - // public boolean equals(Object obj) - // { - // if (this == obj) - // { - // return true; - // } - // - // if (obj instanceof QueueEntry<?>) - // { - // @SuppressWarnings("unchecked") - // QueueEntry<E> that = (QueueEntry<E>)obj; - // return compareTo(that) == 0; - // } - // - // return false; - // } - } - - /** - * A blocking iterator that takes elements from a {@link CDOQueryQueue}. - * - * @author Simon McDuff - * @since 2.0 - */ - public class BlockingCloseableIteratorImpl implements BlockingCloseableIterator<E> - { - private boolean closed; - - private E nextElement; - - public BlockingCloseableIteratorImpl() - { - } - - public E peek() - { - if (nextElement == null) - { - return CDOQueryQueue.this.peek(); - } - - return nextElement; - } - - public boolean hasNext() - { - privateNext(false); - return nextElement != null; - } - - private void privateNext(boolean failOnNull) - { - if (nextElement == null) - { - try - { - synchronized (closeLock) - { - if (CDOQueryQueue.this.isEmpty() && CDOQueryQueue.this.isClosed()) - { - if (failOnNull) - { - throw new NoSuchElementException(); - } - - return; - } - } - - nextElement = take(); - } - catch (InterruptedException ex) - { - throw WrappedException.wrap(ex); - } - } - } - - public E next() - { - try - { - privateNext(true); - return nextElement; - } - finally - { - nextElement = null; - } - } - - public void remove() - { - throw new UnsupportedOperationException(); - } - - public void close() - { - this.closed = true; - } - - public boolean isClosed() - { - return this.closed; - } - } -} +/*
+ * Copyright (c) 2004 - 2012 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:
+ * Simon McDuff - initial API and implementation
+ * Eike Stepper - maintenance
+ */
+package org.eclipse.emf.cdo.common.util;
+
+import org.eclipse.net4j.util.WrappedException;
+import org.eclipse.net4j.util.collection.Closeable;
+
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.NoSuchElementException;
+import java.util.Queue;
+import java.util.concurrent.PriorityBlockingQueue;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+
+/**
+ * The {@link Queue queue} that represents the result of a CDOQuery.
+ *
+ * @author Simon McDuff
+ * @since 2.0
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public class CDOQueryQueue<E> implements Queue<E>, Closeable
+{
+ // Static not allowed due to <E>
+ private final QueueEntry<E> QUEUE_CLOSED = new QueueEntry<E>();
+
+ private PriorityBlockingQueue<QueueEntry<E>> queue = new PriorityBlockingQueue<QueueEntry<E>>(10);
+
+ private boolean closed;
+
+ private Object closeLock = new Object();
+
+ public CDOQueryQueue()
+ {
+ }
+
+ public void setException(Throwable exception)
+ {
+ queue.add(new QueueEntry<E>(exception));
+ }
+
+ public void close()
+ {
+ synchronized (closeLock)
+ {
+ if (!closed)
+ {
+ closed = true;
+ queue.add(QUEUE_CLOSED);
+ }
+ }
+ }
+
+ public boolean isClosed()
+ {
+ synchronized (closeLock)
+ {
+ return closed;
+ }
+ }
+
+ public boolean add(E e)
+ {
+ return queue.add(new QueueEntry<E>(e));
+ }
+
+ public void clear()
+ {
+ queue.clear();
+ }
+
+ public boolean contains(Object o)
+ {
+ return queue.contains(o);
+ }
+
+ public E element()
+ {
+ return checkObject(queue.element());
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ return queue.equals(obj);
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return queue.hashCode();
+ }
+
+ public boolean isEmpty()
+ {
+ return queue.isEmpty();
+ }
+
+ public BlockingCloseableIterator<E> iterator()
+ {
+ return new BlockingCloseableIteratorImpl();
+ }
+
+ public boolean offer(E e, long timeout, TimeUnit unit)
+ {
+ return queue.offer(new QueueEntry<E>(e), timeout, unit);
+ }
+
+ public boolean offer(E e)
+ {
+ return queue.offer(new QueueEntry<E>(e));
+ }
+
+ public E peek()
+ {
+ return checkObject(queue.peek());
+ }
+
+ public E poll(long timeout, TimeUnit unit) throws InterruptedException
+ {
+ return checkObject(queue.poll(timeout, unit));
+ }
+
+ public void put(E e)
+ {
+ queue.put(new QueueEntry<E>(e));
+ }
+
+ public int remainingCapacity()
+ {
+ return queue.remainingCapacity();
+ }
+
+ public E remove()
+ {
+ return checkObject(queue.remove());
+ }
+
+ public boolean remove(Object o)
+ {
+ return queue.remove(o);
+ }
+
+ public int size()
+ {
+ return queue.size();
+ }
+
+ public E take() throws InterruptedException
+ {
+ QueueEntry<E> entry = null;
+
+ entry = queue.take();
+
+ return checkObject(entry);
+ }
+
+ public Object[] toArray()
+ {
+ return queue.toArray();
+ }
+
+ @SuppressWarnings("unchecked")
+ public Object[] toArray(Object[] a)
+ {
+ return queue.toArray(a);
+ }
+
+ @Override
+ public String toString()
+ {
+ return queue.toString();
+ }
+
+ public E poll()
+ {
+ QueueEntry<E> entry = queue.poll();
+ return checkObject(entry);
+ }
+
+ public Comparator<?> comparator()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean containsAll(Collection<?> c)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean addAll(Collection<? extends E> c)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean removeAll(Collection<?> c)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean retainAll(Collection<?> c)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ private E checkObject(QueueEntry<E> entry)
+ {
+ if (entry == null || entry == QUEUE_CLOSED)
+ {
+ return null;
+ }
+
+ return entry.getObjectWithException();
+ }
+
+ /**
+ * @author Simon McDuff
+ * @since 2.0
+ */
+ private static class QueueEntry<E> implements Comparable<QueueEntry<E>>
+ {
+ private static final AtomicLong nextSeq = new AtomicLong(0);
+
+ private long seqNumber;
+
+ private Object internalObject;
+
+ public QueueEntry()
+ {
+ seqNumber = Long.MAX_VALUE;
+ }
+
+ public QueueEntry(E object)
+ {
+ internalObject = object;
+ seqNumber = nextSeq.getAndIncrement();
+ }
+
+ public QueueEntry(Throwable object)
+ {
+ internalObject = object;
+ seqNumber = nextSeq.getAndIncrement();
+ }
+
+ @SuppressWarnings("unchecked")
+ public E getObjectWithException()
+ {
+ Throwable exception = getException();
+ if (exception instanceof Exception)
+ {
+ throw WrappedException.wrap((Exception)exception);
+ }
+ else if (exception instanceof Error)
+ {
+ throw (Error)exception;
+ }
+
+ return (E)internalObject;
+ }
+
+ public Throwable getException()
+ {
+ if (internalObject instanceof Throwable)
+ {
+ return (Throwable)internalObject;
+ }
+
+ return null;
+ }
+
+ public int compareTo(QueueEntry<E> o)
+ {
+ if (getException() != null)
+ {
+ return -1;
+ }
+
+ if (o.getException() != null)
+ {
+ return 1;
+ }
+
+ if (this == o)
+ {
+ return 0;
+ }
+
+ if (seqNumber == o.seqNumber)
+ {
+ // Should not be possible
+ return 0;
+ }
+
+ return seqNumber < o.seqNumber ? -1 : 1;
+ }
+
+ // @Override
+ // public boolean equals(Object obj)
+ // {
+ // if (this == obj)
+ // {
+ // return true;
+ // }
+ //
+ // if (obj instanceof QueueEntry<?>)
+ // {
+ // @SuppressWarnings("unchecked")
+ // QueueEntry<E> that = (QueueEntry<E>)obj;
+ // return compareTo(that) == 0;
+ // }
+ //
+ // return false;
+ // }
+ }
+
+ /**
+ * A blocking iterator that takes elements from a {@link CDOQueryQueue}.
+ *
+ * @author Simon McDuff
+ * @since 2.0
+ */
+ public class BlockingCloseableIteratorImpl implements BlockingCloseableIterator<E>
+ {
+ private boolean closed;
+
+ private E nextElement;
+
+ public BlockingCloseableIteratorImpl()
+ {
+ }
+
+ public E peek()
+ {
+ if (nextElement == null)
+ {
+ return CDOQueryQueue.this.peek();
+ }
+
+ return nextElement;
+ }
+
+ public boolean hasNext()
+ {
+ privateNext(false);
+ return nextElement != null;
+ }
+
+ private void privateNext(boolean failOnNull)
+ {
+ if (nextElement == null)
+ {
+ try
+ {
+ synchronized (closeLock)
+ {
+ if (CDOQueryQueue.this.isEmpty() && CDOQueryQueue.this.isClosed())
+ {
+ if (failOnNull)
+ {
+ throw new NoSuchElementException();
+ }
+
+ return;
+ }
+ }
+
+ nextElement = take();
+ }
+ catch (InterruptedException ex)
+ {
+ throw WrappedException.wrap(ex);
+ }
+ }
+ }
+
+ public E next()
+ {
+ try
+ {
+ privateNext(true);
+ return nextElement;
+ }
+ finally
+ {
+ nextElement = null;
+ }
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void close()
+ {
+ this.closed = true;
+ }
+
+ public boolean isClosed()
+ {
+ return this.closed;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOTimeProvider.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOTimeProvider.java index 33de8a435f..d951c3044c 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOTimeProvider.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/CDOTimeProvider.java @@ -1,22 +1,22 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.util; - -/** - * Provides the consumer with a long-valued time stamp. - * - * @author Eike Stepper - * @since 3.0 - */ -public interface CDOTimeProvider -{ - public long getTimeStamp(); -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.util;
+
+/**
+ * Provides the consumer with a long-valued time stamp.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ */
+public interface CDOTimeProvider
+{
+ public long getTimeStamp();
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/PartialCollectionLoadingNotSupportedException.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/PartialCollectionLoadingNotSupportedException.java index f4f3db5926..392eceb0a6 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/PartialCollectionLoadingNotSupportedException.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/PartialCollectionLoadingNotSupportedException.java @@ -1,45 +1,45 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.util; - -import org.eclipse.emf.cdo.common.revision.CDOElementProxy; - -/** - * An unchecked exception that indicates that {@link CDOElementProxy list element proxies} have been encountered but - * cannot be handled. - * - * @author Eike Stepper - * @noextend This interface is not intended to be extended by clients. - * @since 4.1 - */ -public class PartialCollectionLoadingNotSupportedException extends IllegalStateException -{ - private static final long serialVersionUID = 1L; - - public PartialCollectionLoadingNotSupportedException() - { - } - - public PartialCollectionLoadingNotSupportedException(String message) - { - super(message); - } - - public PartialCollectionLoadingNotSupportedException(String message, Throwable cause) - { - super(message, cause); - } - - public PartialCollectionLoadingNotSupportedException(Throwable cause) - { - super(cause); - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.util;
+
+import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
+
+/**
+ * An unchecked exception that indicates that {@link CDOElementProxy list element proxies} have been encountered but
+ * cannot be handled.
+ *
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ * @since 4.1
+ */
+public class PartialCollectionLoadingNotSupportedException extends IllegalStateException
+{
+ private static final long serialVersionUID = 1L;
+
+ public PartialCollectionLoadingNotSupportedException()
+ {
+ }
+
+ public PartialCollectionLoadingNotSupportedException(String message)
+ {
+ super(message);
+ }
+
+ public PartialCollectionLoadingNotSupportedException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public PartialCollectionLoadingNotSupportedException(Throwable cause)
+ {
+ super(cause);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/RepositoryStateChangedEvent.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/RepositoryStateChangedEvent.java index 507b318536..6c74a8cf1c 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/RepositoryStateChangedEvent.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/RepositoryStateChangedEvent.java @@ -1,52 +1,52 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.util; - -import org.eclipse.emf.cdo.common.CDOCommonRepository; - -import org.eclipse.net4j.util.event.Event; -import org.eclipse.net4j.util.event.IEvent; -import org.eclipse.net4j.util.event.INotifier; - -/** - * An {@link IEvent event} fired when the {@link org.eclipse.emf.cdo.common.CDOCommonRepository.State state} of a - * repository has changed. - * - * @author Eike Stepper - * @since 3.0 - * @noextend This interface is not intended to be extended by clients. - */ -public class RepositoryStateChangedEvent extends Event implements CDOCommonRepository.StateChangedEvent -{ - private static final long serialVersionUID = 1L; - - private CDOCommonRepository.State oldState; - - private CDOCommonRepository.State newState; - - public RepositoryStateChangedEvent(INotifier source, CDOCommonRepository.State oldState, - CDOCommonRepository.State newState) - { - super(source); - this.oldState = oldState; - this.newState = newState; - } - - public CDOCommonRepository.State getOldState() - { - return oldState; - } - - public CDOCommonRepository.State getNewState() - { - return newState; - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.util;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository;
+
+import org.eclipse.net4j.util.event.Event;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.INotifier;
+
+/**
+ * An {@link IEvent event} fired when the {@link org.eclipse.emf.cdo.common.CDOCommonRepository.State state} of a
+ * repository has changed.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public class RepositoryStateChangedEvent extends Event implements CDOCommonRepository.StateChangedEvent
+{
+ private static final long serialVersionUID = 1L;
+
+ private CDOCommonRepository.State oldState;
+
+ private CDOCommonRepository.State newState;
+
+ public RepositoryStateChangedEvent(INotifier source, CDOCommonRepository.State oldState,
+ CDOCommonRepository.State newState)
+ {
+ super(source);
+ this.oldState = oldState;
+ this.newState = newState;
+ }
+
+ public CDOCommonRepository.State getOldState()
+ {
+ return oldState;
+ }
+
+ public CDOCommonRepository.State getNewState()
+ {
+ return newState;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/RepositoryTypeChangedEvent.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/RepositoryTypeChangedEvent.java index 1fec51f7e8..aa3ba5e222 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/RepositoryTypeChangedEvent.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/RepositoryTypeChangedEvent.java @@ -1,51 +1,51 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.util; - -import org.eclipse.emf.cdo.common.CDOCommonRepository; - -import org.eclipse.net4j.util.event.Event; -import org.eclipse.net4j.util.event.IEvent; -import org.eclipse.net4j.util.event.INotifier; - -/** - * An {@link IEvent event} fired when the {@link org.eclipse.emf.cdo.common.CDOCommonRepository.Type type} of a - * repository has changed. - * - * @author Eike Stepper - * @since 3.0 - * @noextend This interface is not intended to be extended by clients. - */ -public class RepositoryTypeChangedEvent extends Event implements CDOCommonRepository.TypeChangedEvent -{ - private static final long serialVersionUID = 1L; - - private CDOCommonRepository.Type oldType; - - private CDOCommonRepository.Type newType; - - public RepositoryTypeChangedEvent(INotifier source, CDOCommonRepository.Type oldType, CDOCommonRepository.Type newType) - { - super(source); - this.oldType = oldType; - this.newType = newType; - } - - public CDOCommonRepository.Type getOldType() - { - return oldType; - } - - public CDOCommonRepository.Type getNewType() - { - return newType; - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.util;
+
+import org.eclipse.emf.cdo.common.CDOCommonRepository;
+
+import org.eclipse.net4j.util.event.Event;
+import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.event.INotifier;
+
+/**
+ * An {@link IEvent event} fired when the {@link org.eclipse.emf.cdo.common.CDOCommonRepository.Type type} of a
+ * repository has changed.
+ *
+ * @author Eike Stepper
+ * @since 3.0
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public class RepositoryTypeChangedEvent extends Event implements CDOCommonRepository.TypeChangedEvent
+{
+ private static final long serialVersionUID = 1L;
+
+ private CDOCommonRepository.Type oldType;
+
+ private CDOCommonRepository.Type newType;
+
+ public RepositoryTypeChangedEvent(INotifier source, CDOCommonRepository.Type oldType, CDOCommonRepository.Type newType)
+ {
+ super(source);
+ this.oldType = oldType;
+ this.newType = newType;
+ }
+
+ public CDOCommonRepository.Type getOldType()
+ {
+ return oldType;
+ }
+
+ public CDOCommonRepository.Type getNewType()
+ {
+ return newType;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/TransportException.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/TransportException.java index caba1020c7..e9b4c1b91a 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/TransportException.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/TransportException.java @@ -1,41 +1,41 @@ -/* - * Copyright (c) 2004 - 2011 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 - */ -package org.eclipse.emf.cdo.common.util; - -/** - * An unchecked exception that indicates transport-level problems. - * - * @author Eike Stepper - * @noextend This interface is not intended to be extended by clients. - */ -public class TransportException extends CDOException -{ - private static final long serialVersionUID = 1L; - - public TransportException() - { - } - - public TransportException(String message) - { - super(message); - } - - public TransportException(String message, Throwable cause) - { - super(message, cause); - } - - public TransportException(Throwable cause) - { - super(cause); - } -} +/*
+ * Copyright (c) 2004 - 2012 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
+ */
+package org.eclipse.emf.cdo.common.util;
+
+/**
+ * An unchecked exception that indicates transport-level problems.
+ *
+ * @author Eike Stepper
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public class TransportException extends CDOException
+{
+ private static final long serialVersionUID = 1L;
+
+ public TransportException()
+ {
+ }
+
+ public TransportException(String message)
+ {
+ super(message);
+ }
+
+ public TransportException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public TransportException(Throwable cause)
+ {
+ super(cause);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/package-info.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/package-info.java index 5466baa84d..c7b15046b4 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/package-info.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/util/package-info.java @@ -1,5 +1,5 @@ /*
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * Copyright (c) 2004 - 2012 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
|