diff options
author | Eike Stepper | 2012-07-19 08:22:04 +0000 |
---|---|---|
committer | Eike Stepper | 2012-07-19 08:22:04 +0000 |
commit | 1460904fd3c193ffaf809913b2983a400fce9d94 (patch) | |
tree | 72f3a17b75fedba3ae1060df1d32c9c7889be954 /plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo | |
parent | 5f360965ae87478e0681899bf310a210cafc2c44 (diff) | |
download | cdo-1460904fd3c193ffaf809913b2983a400fce9d94.tar.gz cdo-1460904fd3c193ffaf809913b2983a400fce9d94.tar.xz cdo-1460904fd3c193ffaf809913b2983a400fce9d94.zip |
Fix line endings in master (dos2unix)
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo')
214 files changed, 19871 insertions, 19871 deletions
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 c5a68c63c8..5a76dadf5e 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 - 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();
- }
- }
-}
+/* + * 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 ab4a051ff6..5444f45bfe 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 - 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
-{
-}
+/* + * 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 1b499450f0..df15ee87a6 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,99 +1,99 @@ -/*
- * 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.CDOLockOwner;
-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 CDOLockOwner, 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.CDOLockOwner; +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 CDOLockOwner, 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 afe328c786..5637fd6382 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 - 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);
-}
+/* + * 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 f0f755ee9e..dcf680aee7 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 - 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();
-}
+/* + * 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 4299176b90..149f6e4b5c 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 - 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);
-}
+/* + * 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 4274ca75e0..fadf832806 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 - 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);
-}
+/* + * 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 ac4ba9b7dd..639597a9d6 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 - 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();
-}
+/* + * 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 dd80e94871..538863090e 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 - 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();
-}
+/* + * 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 7ba2e64fd0..41b7d4f3e1 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 - 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();
-}
+/* + * 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 78f1153c41..dc9ecd1a80 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 - 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();
-}
+/* + * 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 e30279294b..2a44e199a5 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,20 +1,20 @@ -/*
- * 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
- */
-
-/**
- * Common concepts for dealing with branches.
- *
- * @apiviz.exclude .*\.IContainer
- * @apiviz.exclude .*\.INotifier
- * @apiviz.exclude .*Event
- */
-package org.eclipse.emf.cdo.common.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 + */ + +/** + * Common concepts for dealing with branches. + * + * @apiviz.exclude .*\.IContainer + * @apiviz.exclude .*\.INotifier + * @apiviz.exclude .*Event + */ +package org.eclipse.emf.cdo.common.branch; + 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 4fdabd758b..c565f8f419 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 - 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
-}
+/* + * 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 2c76354da2..f12db6193d 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 - 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);
-}
+/* + * 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 c36e8a6c48..262430c71e 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 - 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();
-}
+/* + * 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 b9cdb068e4..e5333de082 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 - 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();
-}
+/* + * 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 a9122c0ecf..6a5b43a2c6 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 - 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();
-}
+/* + * 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 41ea320c6d..5f57741d0d 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 - 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();
-}
+/* + * 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 1b93982d3a..101c6f1768 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 - 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();
-}
+/* + * 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 800ccc5bb5..5866ab1791 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 - 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);
-}
+/* + * 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 58b7dee9de..c895f81d7d 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 - 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);
-}
+/* + * 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/BinaryCommitInfoLog.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/commit/handler/BinaryCommitInfoLog.java index 011db925db..8ea201196b 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 - 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);
- }
-}
+/* + * 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 ca4e5c16d5..16871550d4 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 - 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);
- }
-}
+/* + * 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 132c167e63..606d26a8c8 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,15 +1,15 @@ -/*
- * 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
- */
-
-/**
- * Some useful commit info handler implementations.
- */
-package org.eclipse.emf.cdo.common.commit.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 + */ + +/** + * Some useful commit info handler implementations. + */ +package org.eclipse.emf.cdo.common.commit.handler; 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 8c68efd5ef..700bb031e1 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,15 +1,15 @@ -/*
- * 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
- */
-
-/**
- * Common concepts for dealing with commits and change sets.
- */
-package org.eclipse.emf.cdo.common.commit;
+/* + * 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 + */ + +/** + * Common concepts for dealing with commits and change sets. + */ +package org.eclipse.emf.cdo.common.commit; 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 054fef251e..be107471c3 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 - 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;
- }
- }
-}
+/* + * 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 7b52e8340d..a4ff3c7593 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 - 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();
-}
+/* + * 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 b929df6373..1f16ff9b32 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 - 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();
-}
+/* + * 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 19d9ec4c96..e87e24c083 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 - 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
-{
-}
+/* + * 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 8914221b5b..5c46f096ba 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 - 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);
-}
+/* + * 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 775ab10c69..c6fbed79fa 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 - 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();
- }
-}
+/* + * 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 bec16fbfa9..681d9d22ad 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 - 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
-{
-}
+/* + * 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/CDOReference.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/id/CDOReference.java index a6af2693bc..4701c3181d 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 - 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();
-}
+/* + * 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 1868346cdf..de9ac93aa6 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,23 +1,23 @@ -/*
- * 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;
-
-/**
- * An identifiable object.
- *
- * @author Eike Stepper
- * @since 4.0
- * @apiviz.has {@link CDOID}
- */
-public interface CDOWithID
-{
- public CDOID 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; + +/** + * An identifiable object. + * + * @author Eike Stepper + * @since 4.0 + * @apiviz.has {@link CDOID} + */ +public interface CDOWithID +{ + public CDOID cdoID(); +} 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 67bb822de0..a7b2bd498d 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,15 +1,15 @@ -/*
- * 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
- */
-
-/**
- * Common concepts for dealing with object and revision IDs.
- */
-package org.eclipse.emf.cdo.common.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 + */ + +/** + * Common concepts for dealing with object and revision IDs. + */ +package org.eclipse.emf.cdo.common.id; 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 c3c2bb78f1..538e30ba74 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 - 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);
- }
-}
+/* + * 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 8d195a4605..7f33031113 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 - 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);
- }
-}
+/* + * 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 e1621d76ef..9089ee4a54 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 - 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;
-}
+/* + * 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 0262df1275..be95179dc3 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 - 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;
-}
+/* + * 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 05a4319be0..e106edfa17 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 - 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);
- }
-}
+/* + * 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 66d3a421a8..16680ceb09 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 - 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();
- }
-}
+/* + * 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 132c763fc8..ff352f4861 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 - 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);
- }
-}
+/* + * 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 6d80513cc1..6e5296c977 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,15 +1,15 @@ -/*
- * 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
- */
-
-/**
- * Common concepts for dealing with large binary objects and large character objects.
- */
-package org.eclipse.emf.cdo.common.lob;
+/* + * 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 + */ + +/** + * Common concepts for dealing with large binary objects and large character objects. + */ +package org.eclipse.emf.cdo.common.lob; 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 117f8bb176..54042c3f86 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 - 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
- }
-}
+/* + * 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 e2a0047760..d7e283823d 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 - 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);
-}
+/* + * 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 fda27b77a8..1a5b5ed2c5 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 - 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();
-}
+/* + * 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 78f423c7c4..b959340c39 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 - 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();
-}
+/* + * 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 03ef04127e..59a50452ac 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 - 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);
- }
-}
+/* + * 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 7f3620a187..c08df3294c 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,302 +1,302 @@ -/*
- * 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.lock;
-
-import org.eclipse.emf.cdo.common.CDOCommonRepository;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.id.CDOID;
-
-import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
-
-import java.util.Map;
-
-/**
- * Manages all persistent aspects of durable CDO views such as {@link CDOBranchPoint branch point} and acquired locks.
- *
- * @author Eike Stepper
- * @since 4.0
- * @apiviz.uses {@link IDurableLockingManager.LockArea} - - manages
- */
-public interface IDurableLockingManager
-{
- public LockArea createLockArea(String userID, CDOBranchPoint branchPoint, boolean readOnly,
- Map<CDOID, LockGrade> locks) throws LockAreaAlreadyExistsException;
-
- /**
- * Returns the {@link LockArea lock area} specified by the given durableLockingID, never <code>null</code>.
- *
- * @throws LockAreaNotFoundException
- * if the given durableLockingID is unknown.
- */
- public LockArea getLockArea(String durableLockingID) throws LockAreaNotFoundException;
-
- public void getLockAreas(String userIDPrefix, LockArea.Handler handler);
-
- public void deleteLockArea(String durableLockingID);
-
- /**
- * Encapsulates the persistable information about a single durable CDO view like {@link CDOBranchPoint branch point}
- * and acquired locks.
- *
- * @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.composedOf {@link IDurableLockingManager.LockGrade} - - locks
- */
- public interface LockArea extends CDOBranchPoint
- {
- /**
- * @since 4.1
- */
- public static final int DEFAULT_DURABLE_LOCKING_ID_BYTES = 32;
-
- public String getDurableLockingID();
-
- public String getUserID();
-
- public boolean isReadOnly();
-
- public Map<CDOID, LockGrade> getLocks();
-
- /**
- * Returns <code>true</code> if this instance represents a lock area that is known to be missing (not present) on a
- * master server. (Relevant only in a replicating configuration.)
- *
- * @since 4.1
- */
- public boolean isMissing();
-
- /**
- * A call-back interface for <em>handling</em> {@link LockArea lock area} objects.
- *
- * @author Eike Stepper
- * @apiviz.uses {@link IDurableLockingManager.LockArea} - - handles
- */
- public interface Handler
- {
- public boolean handleLockArea(LockArea area);
- }
- }
-
- /**
- * Thrown if a {@link LockArea lock area} is spcified that does not exist in a CDO {@link CDOCommonRepository
- * repository}.
- *
- * @author Eike Stepper
- */
- public static class LockAreaNotFoundException extends IllegalStateException
- {
- private static final long serialVersionUID = 1L;
-
- private String durableLockingID;
-
- public LockAreaNotFoundException(String durableLockingID)
- {
- super("No lock area for ID=" + durableLockingID);
- this.durableLockingID = durableLockingID;
- }
-
- public LockAreaNotFoundException(String message, Throwable cause, String durableLockingID)
- {
- super(message, cause);
- this.durableLockingID = durableLockingID;
- }
-
- public String getDurableLockingID()
- {
- return durableLockingID;
- }
- }
-
- /**
- * Exception occurs when attempting to create a durable {@link LockArea} that already exists.
- *
- * @author Caspar De Groot
- * @since 4.1
- */
- public static class LockAreaAlreadyExistsException extends IllegalStateException
- {
- private static final long serialVersionUID = 1L;
-
- private String durableLockingID;
-
- public LockAreaAlreadyExistsException(String durableLockingID)
- {
- super("A lock area with ID=" + durableLockingID + " already exists");
- this.durableLockingID = durableLockingID;
- }
-
- public String getDurableLockingID()
- {
- return durableLockingID;
- }
- }
-
- /**
- * Enumerates the possible combinations of read and write locks on a single CDO object.
- *
- * @author Eike Stepper
- * @noextend This interface is not intended to be extended by clients.
- */
- public enum LockGrade
- {
- NONE(0), READ(1), WRITE(2), READ_WRITE(READ.getValue() | WRITE.getValue()),
-
- /**
- * @since 4.1
- */
- OPTION(4),
-
- /**
- * @since 4.1
- */
- READ_OPTION(READ.getValue() | OPTION.getValue()),
-
- /**
- * @since 4.1
- */
- WRITE_OPTION(WRITE.getValue() | OPTION.getValue()),
-
- /**
- * @since 4.1
- */
- READ_WRITE_OPTION(READ.getValue() | WRITE.getValue() | OPTION.getValue());
-
- private final int value;
-
- private LockGrade(int value)
- {
- this.value = value;
- }
-
- public int getValue()
- {
- return value;
- }
-
- public boolean isRead()
- {
- return (value & 1) != 0;
- }
-
- public boolean isWrite()
- {
- return (value & 2) != 0;
- }
-
- /**
- * @since 4.1
- */
- public boolean isOption()
- {
- return (value & 4) != 0;
- }
-
- public LockGrade getUpdated(LockType type, boolean on)
- {
- int mask = getMask(type);
-
- if (on)
- {
- return get(value | mask);
- }
-
- return get(value & ~mask);
- }
-
- private int getMask(LockType type)
- {
- switch (type)
- {
- case READ:
- return 1;
-
- case WRITE:
- return 2;
-
- case OPTION:
- return 4;
- }
-
- return 0;
- }
-
- public static LockGrade get(LockType type)
- {
- if (type == LockType.READ)
- {
- return READ;
- }
-
- if (type == LockType.WRITE)
- {
- return WRITE;
- }
-
- if (type == LockType.OPTION)
- {
- return OPTION;
- }
-
- return NONE;
- }
-
- /**
- * @deprecated Use {@link #get(boolean, boolean, boolean)}
- */
- @Deprecated
- public static LockGrade get(boolean read, boolean write)
- {
- return get((read ? 1 : 0) | (write ? 2 : 0));
- }
-
- /**
- * @since 4.1
- */
- public static LockGrade get(boolean read, boolean write, boolean option)
- {
- return get((read ? 1 : 0) | (write ? 2 : 0) | (option ? 4 : 0));
- }
-
- public static LockGrade get(int value)
- {
- switch (value)
- {
- case 0:
- return NONE;
-
- case 1:
- return READ;
-
- case 2:
- return WRITE;
-
- case 3:
- return READ_WRITE;
-
- case 4:
- return OPTION;
-
- case 1 | 4:
- return READ_OPTION;
-
- case 2 | 4:
- return WRITE_OPTION;
-
- case 1 | 2 | 4:
- return READ_WRITE_OPTION;
-
- default:
- throw new IllegalArgumentException("Invalid lock grade: " + 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 + */ +package org.eclipse.emf.cdo.common.lock; + +import org.eclipse.emf.cdo.common.CDOCommonRepository; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.id.CDOID; + +import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType; + +import java.util.Map; + +/** + * Manages all persistent aspects of durable CDO views such as {@link CDOBranchPoint branch point} and acquired locks. + * + * @author Eike Stepper + * @since 4.0 + * @apiviz.uses {@link IDurableLockingManager.LockArea} - - manages + */ +public interface IDurableLockingManager +{ + public LockArea createLockArea(String userID, CDOBranchPoint branchPoint, boolean readOnly, + Map<CDOID, LockGrade> locks) throws LockAreaAlreadyExistsException; + + /** + * Returns the {@link LockArea lock area} specified by the given durableLockingID, never <code>null</code>. + * + * @throws LockAreaNotFoundException + * if the given durableLockingID is unknown. + */ + public LockArea getLockArea(String durableLockingID) throws LockAreaNotFoundException; + + public void getLockAreas(String userIDPrefix, LockArea.Handler handler); + + public void deleteLockArea(String durableLockingID); + + /** + * Encapsulates the persistable information about a single durable CDO view like {@link CDOBranchPoint branch point} + * and acquired locks. + * + * @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.composedOf {@link IDurableLockingManager.LockGrade} - - locks + */ + public interface LockArea extends CDOBranchPoint + { + /** + * @since 4.1 + */ + public static final int DEFAULT_DURABLE_LOCKING_ID_BYTES = 32; + + public String getDurableLockingID(); + + public String getUserID(); + + public boolean isReadOnly(); + + public Map<CDOID, LockGrade> getLocks(); + + /** + * Returns <code>true</code> if this instance represents a lock area that is known to be missing (not present) on a + * master server. (Relevant only in a replicating configuration.) + * + * @since 4.1 + */ + public boolean isMissing(); + + /** + * A call-back interface for <em>handling</em> {@link LockArea lock area} objects. + * + * @author Eike Stepper + * @apiviz.uses {@link IDurableLockingManager.LockArea} - - handles + */ + public interface Handler + { + public boolean handleLockArea(LockArea area); + } + } + + /** + * Thrown if a {@link LockArea lock area} is spcified that does not exist in a CDO {@link CDOCommonRepository + * repository}. + * + * @author Eike Stepper + */ + public static class LockAreaNotFoundException extends IllegalStateException + { + private static final long serialVersionUID = 1L; + + private String durableLockingID; + + public LockAreaNotFoundException(String durableLockingID) + { + super("No lock area for ID=" + durableLockingID); + this.durableLockingID = durableLockingID; + } + + public LockAreaNotFoundException(String message, Throwable cause, String durableLockingID) + { + super(message, cause); + this.durableLockingID = durableLockingID; + } + + public String getDurableLockingID() + { + return durableLockingID; + } + } + + /** + * Exception occurs when attempting to create a durable {@link LockArea} that already exists. + * + * @author Caspar De Groot + * @since 4.1 + */ + public static class LockAreaAlreadyExistsException extends IllegalStateException + { + private static final long serialVersionUID = 1L; + + private String durableLockingID; + + public LockAreaAlreadyExistsException(String durableLockingID) + { + super("A lock area with ID=" + durableLockingID + " already exists"); + this.durableLockingID = durableLockingID; + } + + public String getDurableLockingID() + { + return durableLockingID; + } + } + + /** + * Enumerates the possible combinations of read and write locks on a single CDO object. + * + * @author Eike Stepper + * @noextend This interface is not intended to be extended by clients. + */ + public enum LockGrade + { + NONE(0), READ(1), WRITE(2), READ_WRITE(READ.getValue() | WRITE.getValue()), + + /** + * @since 4.1 + */ + OPTION(4), + + /** + * @since 4.1 + */ + READ_OPTION(READ.getValue() | OPTION.getValue()), + + /** + * @since 4.1 + */ + WRITE_OPTION(WRITE.getValue() | OPTION.getValue()), + + /** + * @since 4.1 + */ + READ_WRITE_OPTION(READ.getValue() | WRITE.getValue() | OPTION.getValue()); + + private final int value; + + private LockGrade(int value) + { + this.value = value; + } + + public int getValue() + { + return value; + } + + public boolean isRead() + { + return (value & 1) != 0; + } + + public boolean isWrite() + { + return (value & 2) != 0; + } + + /** + * @since 4.1 + */ + public boolean isOption() + { + return (value & 4) != 0; + } + + public LockGrade getUpdated(LockType type, boolean on) + { + int mask = getMask(type); + + if (on) + { + return get(value | mask); + } + + return get(value & ~mask); + } + + private int getMask(LockType type) + { + switch (type) + { + case READ: + return 1; + + case WRITE: + return 2; + + case OPTION: + return 4; + } + + return 0; + } + + public static LockGrade get(LockType type) + { + if (type == LockType.READ) + { + return READ; + } + + if (type == LockType.WRITE) + { + return WRITE; + } + + if (type == LockType.OPTION) + { + return OPTION; + } + + return NONE; + } + + /** + * @deprecated Use {@link #get(boolean, boolean, boolean)} + */ + @Deprecated + public static LockGrade get(boolean read, boolean write) + { + return get((read ? 1 : 0) | (write ? 2 : 0)); + } + + /** + * @since 4.1 + */ + public static LockGrade get(boolean read, boolean write, boolean option) + { + return get((read ? 1 : 0) | (write ? 2 : 0) | (option ? 4 : 0)); + } + + public static LockGrade get(int value) + { + switch (value) + { + case 0: + return NONE; + + case 1: + return READ; + + case 2: + return WRITE; + + case 3: + return READ_WRITE; + + case 4: + return OPTION; + + case 1 | 4: + return READ_OPTION; + + case 2 | 4: + return WRITE_OPTION; + + case 1 | 2 | 4: + return READ_WRITE_OPTION; + + default: + throw new IllegalArgumentException("Invalid lock grade: " + value); + } + } + } +} 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 daf76d03b3..f2d6965c6a 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,18 +1,18 @@ -/*
- * 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
- */
-
-/**
- * Common concepts for dealing with durable locks and views.
- *
- * @apiviz.exclude .*Exception
- */
-package org.eclipse.emf.cdo.common.lock;
-
+/* + * 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 + */ + +/** + * Common concepts for dealing with durable locks and views. + * + * @apiviz.exclude .*Exception + */ +package org.eclipse.emf.cdo.common.lock; + 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 7ec16a3dbe..75a3f31ded 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 - 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);
-}
+/* + * 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 1a050de87f..7d7f8cfa71 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 - 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();
- }
-}
+/* + * 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 c786f72657..373c7eecc1 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 - 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$
-}
+/* + * 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/CDOPackageInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageInfo.java index 269d38f507..c0b649eb18 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 - 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();
-}
+/* + * 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 96f6bdac67..5018fcdbc5 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 - 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);
-}
+/* + * 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/CDOPackageTypeRegistry.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/CDOPackageTypeRegistry.java index cb3e0e5df8..4fc22a37b2 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 - 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
- {
- }
-}
+/* + * 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 00e7ca7a8f..d076e6a378 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 - 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$
- }
- }
- }
-}
+/* + * 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/EMFUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/model/EMFUtil.java index cfd8b13691..e6200c5714 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 - 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;
- }
- }
-}
+/* + * 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 63bfb5eb9c..0bd3d6bb48 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,18 +1,18 @@ -/*
- * 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
- */
-
-/**
- * Common concepts for dealing with models and types.
- *
- * @apiviz.exclude .*\.Comparable
- */
-package org.eclipse.emf.cdo.common.model;
-
+/* + * 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 + */ + +/** + * Common concepts for dealing with models and types. + * + * @apiviz.exclude .*\.Comparable + */ +package org.eclipse.emf.cdo.common.model; + 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 750d1ee1fa..a60e5035d6 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,21 +1,21 @@ -/*
- * 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
- */
-
-/**
- * Common concepts that are differently extended in clients and servers.
- *
- * @apiviz.exclude .*\.IOptions
- * @apiviz.exclude .*\.IOptionsContainer
- * @apiviz.exclude .*\.Closeable
- * @apiviz.exclude .*Event
- */
-package org.eclipse.emf.cdo.common;
-
+/* + * 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 + */ + +/** + * Common concepts that are differently extended in clients and servers. + * + * @apiviz.exclude .*\.IOptions + * @apiviz.exclude .*\.IOptionsContainer + * @apiviz.exclude .*\.Closeable + * @apiviz.exclude .*Event + */ +package org.eclipse.emf.cdo.common; + 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 2eb66f6cc7..30490a2c7e 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 - 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);
-}
+/* + * 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/CDOProtocol.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDOProtocol.java index b67dca234f..211b423604 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 - 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();
-}
+/* + * 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 d23efa66c5..5d2b64b780 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 - 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;
-}
+/* + * 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 cdc5429d8a..d19bb6a733 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,15 +1,15 @@ -/*
- * 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
- */
-
-/**
- * Common concepts for dealing with protocols and CDO-specific I/O.
- */
-package org.eclipse.emf.cdo.common.protocol;
+/* + * 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 + */ + +/** + * Common concepts for dealing with protocols and CDO-specific I/O. + */ +package org.eclipse.emf.cdo.common.protocol; 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 82768439d4..773251b5c1 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 - 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();
-}
+/* + * 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 4fe98a5d37..7694c5598d 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 - 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();
-}
+/* + * 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 a187a22891..5f2c90981f 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 - 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();
-}
+/* + * 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/CDOList.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/CDOList.java index 0b9b27df27..be4b500238 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 - 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);
-}
+/* + * 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 f67b58a5e0..5f2d929407 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 - 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);
-}
+/* + * 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 98b15be4b2..5b242a325b 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 - 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);
-}
+/* + * 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 0864240027..47f893f5f5 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,28 +1,28 @@ -/*
- * 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.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-
-/**
- * An entity that has a defined lifetime (creation plus revision) and a version in a {@link CDOBranch branch}.
- *
- * @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 CDORevisable extends CDOBranchPoint, CDOBranchVersion
-{
- public long getRevised();
-}
+/* + * 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.CDOBranchPoint; +import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; + +/** + * An entity that has a defined lifetime (creation plus revision) and a version in a {@link CDOBranch branch}. + * + * @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 CDORevisable extends CDOBranchPoint, CDOBranchVersion +{ + public long getRevised(); +} 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 7bd85e287a..fdb245b0cc 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 - 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();
- }
-}
+/* + * 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 cb002b5e3b..f4783fc4ad 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 - 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);
-}
+/* + * 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 d38a2740b5..13c348bf32 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 - 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);
-
-}
+/* + * 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 a45f526117..e628a2b7f5 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 - 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);
-}
+/* + * 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 c51560a472..fcac1959e7 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 - 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;
- }
- }
- }
-}
+/* + * 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 89a37d2987..5440e09ed2 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 - 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
-{
-}
+/* + * 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 9409d0b7db..5460e84a45 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 - 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);
-}
+/* + * 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 c18c2b9c96..7b28301cfc 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 - 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);
-}
+/* + * 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 67914d9066..d16d1ba5f1 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 - 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$
- }
- }
-}
+/* + * 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 ace02a912f..c6eaf22cfd 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 - 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();
-}
+/* + * 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 3e3e88ccac..8888219aaf 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 - 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
-{
-}
+/* + * 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 0a55ae00a6..f2f0448c7d 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 - 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();
-}
+/* + * 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/CDOFeatureDeltaVisitor.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/revision/delta/CDOFeatureDeltaVisitor.java index f86ff72900..69a36d2899 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 - 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);
-}
+/* + * 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 1495f5e188..47c22c4b3c 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 - 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();
-}
+/* + * 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 a2f5ad9ca2..18607550b8 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 - 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();
-}
+/* + * 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 578c6de287..ad719effc2 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 - 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();
-}
+/* + * 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 a9d6a4e639..0213ec5553 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 - 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);
-}
+/* + * 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 f5f99b1582..40a73619c0 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 - 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);
-}
+/* + * 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 36f43c2755..571adf258a 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 - 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();
-}
+/* + * 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 a3e495f42a..94e44b5d77 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 - 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
-{
-}
+/* + * 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 244301ea74..30d16768a9 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,15 +1,15 @@ -/*
- * 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
- */
-
-/**
- * Common concepts for dealing with revision deltas and feature deltas.
- */
-package org.eclipse.emf.cdo.common.revision.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: + * Eike Stepper - initial API and implementation + */ + +/** + * Common concepts for dealing with revision deltas and feature deltas. + */ +package org.eclipse.emf.cdo.common.revision.delta; 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 7797a7f021..7ed5c5f3bc 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,19 +1,19 @@ -/*
- * 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
- */
-
-/**
- * Common concepts for dealing with revisions and revision lists.
- *
- * @apiviz.exclude .*\.INotifier
- * @apiviz.exclude .*Event
- */
-package org.eclipse.emf.cdo.common.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 + */ + +/** + * Common concepts for dealing with revisions and revision lists. + * + * @apiviz.exclude .*\.INotifier + * @apiviz.exclude .*Event + */ +package org.eclipse.emf.cdo.common.revision; + 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 7b2e36e181..7a6d9a8629 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 - 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();
-}
+/* + * 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 ca59d4e14b..d10ad413c9 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 - 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)
- {
- }
-}
+/* + * 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 16785e73c4..ce012e9d44 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 - 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();
- }
-}
+/* + * 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 ad35efb2af..39eb523d25 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 - 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);
- }
-}
+/* + * 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 f8fe8d88fb..1ebf9106b9 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 - 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();
- }
-}
+/* + * 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 8a8d19aa1e..c87ad81216 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 - 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();
-}
+/* + * 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 576522c67f..32c4d11dde 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 - 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;
- }
- }
-}
+/* + * 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 d951c3044c..c7d5d4ac93 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 - 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();
-}
+/* + * 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 392eceb0a6..73d17f2f77 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 - 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);
- }
-}
+/* + * 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 6c74a8cf1c..9b1c3d4eb1 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 - 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;
- }
-}
+/* + * 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 aa3ba5e222..f4242ce17f 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 - 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;
- }
-}
+/* + * 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 e9b4c1b91a..c9e0304d8d 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 - 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);
- }
-}
+/* + * 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 c7b15046b4..f8a92c9685 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,18 +1,18 @@ -/*
- * 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
- */
-
-/**
- * Common utility classes, some common interfaces and exceptions.
- *
- * @apiviz.exclude .*
- */
-package org.eclipse.emf.cdo.common.util;
-
+/* + * 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 + */ + +/** + * Common utility classes, some common interfaces and exceptions. + * + * @apiviz.exclude .* + */ +package org.eclipse.emf.cdo.common.util; + diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/CDOQueryInfoImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/CDOQueryInfoImpl.java index 1053c06e5f..243e515bb0 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/CDOQueryInfoImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/CDOQueryInfoImpl.java @@ -1,160 +1,160 @@ -/*
- * 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.internal.common;
-
-import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.util.CDOQueryInfo;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-/**
- * @author Simon McDuff
- */
-public class CDOQueryInfoImpl implements CDOQueryInfo
-{
- protected String queryLanguage;
-
- protected String queryString;
-
- protected Object context;
-
- protected Map<String, Object> parameters = new HashMap<String, Object>();
-
- protected int maxResults = UNLIMITED_RESULTS;
-
- protected boolean legacyModeEnabled;
-
- protected CDOChangeSetData changeSetData;
-
- public CDOQueryInfoImpl(String queryLanguage, String queryString, Object context)
- {
- this.queryLanguage = queryLanguage;
- this.queryString = queryString;
- this.context = context;
- }
-
- public CDOQueryInfoImpl(CDODataInput in) throws IOException
- {
- queryLanguage = in.readString();
- queryString = in.readString();
- context = in.readCDORevisionOrPrimitiveOrClassifier();
- maxResults = in.readInt();
- legacyModeEnabled = in.readBoolean();
-
- if (in.readBoolean())
- {
- changeSetData = in.readCDOChangeSetData();
- }
-
- int size = in.readInt();
- for (int i = 0; i < size; i++)
- {
- String key = in.readString();
- Object object = in.readCDORevisionOrPrimitiveOrClassifier();
- parameters.put(key, object);
- }
- }
-
- public void write(CDODataOutput out) throws IOException
- {
- out.writeString(queryLanguage);
- out.writeString(queryString);
- out.writeCDORevisionOrPrimitiveOrClassifier(context);
- out.writeInt(maxResults);
- out.writeBoolean(legacyModeEnabled);
-
- if (changeSetData != null)
- {
- out.writeBoolean(true);
- out.writeCDOChangeSetData(changeSetData);
- }
- else
- {
- out.writeBoolean(false);
- }
-
- out.writeInt(parameters.size());
- for (Entry<String, Object> entry : parameters.entrySet())
- {
- out.writeString(entry.getKey());
- out.writeCDORevisionOrPrimitiveOrClassifier(entry.getValue());
- }
- }
-
- public String getQueryString()
- {
- return queryString;
- }
-
- public String getQueryLanguage()
- {
- return queryLanguage;
- }
-
- public Map<String, Object> getParameters()
- {
- return Collections.unmodifiableMap(parameters);
- }
-
- public Object getContext()
- {
- return context;
- }
-
- public CDOQueryInfoImpl setContext(Object context)
- {
- this.context = context;
- return this;
- }
-
- public void addParameter(String key, Object value)
- {
- parameters.put(key, value);
- }
-
- public int getMaxResults()
- {
- return maxResults;
- }
-
- public CDOQueryInfoImpl setMaxResults(int maxResults)
- {
- this.maxResults = maxResults;
- return this;
- }
-
- public boolean isLegacyModeEnabled()
- {
- return legacyModeEnabled;
- }
-
- public void setLegacyModeEnabled(boolean legacyModeEnabled)
- {
- this.legacyModeEnabled = legacyModeEnabled;
- }
-
- public CDOChangeSetData getChangeSetData()
- {
- return changeSetData;
- }
-
- public void setChangeSetData(CDOChangeSetData changeSetData)
- {
- this.changeSetData = changeSetData;
- }
-}
+/* + * 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.internal.common; + +import org.eclipse.emf.cdo.common.commit.CDOChangeSetData; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.util.CDOQueryInfo; + +import java.io.IOException; +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; + +/** + * @author Simon McDuff + */ +public class CDOQueryInfoImpl implements CDOQueryInfo +{ + protected String queryLanguage; + + protected String queryString; + + protected Object context; + + protected Map<String, Object> parameters = new HashMap<String, Object>(); + + protected int maxResults = UNLIMITED_RESULTS; + + protected boolean legacyModeEnabled; + + protected CDOChangeSetData changeSetData; + + public CDOQueryInfoImpl(String queryLanguage, String queryString, Object context) + { + this.queryLanguage = queryLanguage; + this.queryString = queryString; + this.context = context; + } + + public CDOQueryInfoImpl(CDODataInput in) throws IOException + { + queryLanguage = in.readString(); + queryString = in.readString(); + context = in.readCDORevisionOrPrimitiveOrClassifier(); + maxResults = in.readInt(); + legacyModeEnabled = in.readBoolean(); + + if (in.readBoolean()) + { + changeSetData = in.readCDOChangeSetData(); + } + + int size = in.readInt(); + for (int i = 0; i < size; i++) + { + String key = in.readString(); + Object object = in.readCDORevisionOrPrimitiveOrClassifier(); + parameters.put(key, object); + } + } + + public void write(CDODataOutput out) throws IOException + { + out.writeString(queryLanguage); + out.writeString(queryString); + out.writeCDORevisionOrPrimitiveOrClassifier(context); + out.writeInt(maxResults); + out.writeBoolean(legacyModeEnabled); + + if (changeSetData != null) + { + out.writeBoolean(true); + out.writeCDOChangeSetData(changeSetData); + } + else + { + out.writeBoolean(false); + } + + out.writeInt(parameters.size()); + for (Entry<String, Object> entry : parameters.entrySet()) + { + out.writeString(entry.getKey()); + out.writeCDORevisionOrPrimitiveOrClassifier(entry.getValue()); + } + } + + public String getQueryString() + { + return queryString; + } + + public String getQueryLanguage() + { + return queryLanguage; + } + + public Map<String, Object> getParameters() + { + return Collections.unmodifiableMap(parameters); + } + + public Object getContext() + { + return context; + } + + public CDOQueryInfoImpl setContext(Object context) + { + this.context = context; + return this; + } + + public void addParameter(String key, Object value) + { + parameters.put(key, value); + } + + public int getMaxResults() + { + return maxResults; + } + + public CDOQueryInfoImpl setMaxResults(int maxResults) + { + this.maxResults = maxResults; + return this; + } + + public boolean isLegacyModeEnabled() + { + return legacyModeEnabled; + } + + public void setLegacyModeEnabled(boolean legacyModeEnabled) + { + this.legacyModeEnabled = legacyModeEnabled; + } + + public CDOChangeSetData getChangeSetData() + { + return changeSetData; + } + + public void setChangeSetData(CDOChangeSetData changeSetData) + { + this.changeSetData = changeSetData; + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchImpl.java index 6d3986dff0..3283cb40ab 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchImpl.java @@ -1,342 +1,342 @@ -/*
- * 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.internal.common.branch;
-
-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.spi.common.branch.InternalCDOBranch;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.SubBranchInfo;
-
-import org.eclipse.net4j.util.container.Container;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class CDOBranchImpl extends Container<CDOBranch> implements InternalCDOBranch
-{
- public static final int ILLEGAL_BRANCH_ID = Integer.MIN_VALUE;
-
- private InternalCDOBranchManager branchManager;
-
- private int id;
-
- private String name;
-
- private CDOBranchPoint base;
-
- private CDOBranchPoint head = getPoint(CDOBranchPoint.UNSPECIFIED_DATE);
-
- private InternalCDOBranch[] branches;
-
- public CDOBranchImpl(InternalCDOBranchManager branchManager, int id, String name, CDOBranchPoint base)
- {
- this.branchManager = branchManager;
- this.id = id;
- this.name = name;
- this.base = base;
- activate();
- }
-
- public boolean isMainBranch()
- {
- return false;
- }
-
- public boolean isLocal()
- {
- return id < 0;
- }
-
- public InternalCDOBranchManager getBranchManager()
- {
- return branchManager;
- }
-
- public int getID()
- {
- return id;
- }
-
- public synchronized String getName()
- {
- if (name == null)
- {
- load();
- }
-
- return name;
- }
-
- public boolean isProxy()
- {
- return name == null || base == null;
- }
-
- public String getPathName()
- {
- StringBuilder builder = new StringBuilder();
- computePathName(this, builder);
- return builder.toString();
- }
-
- private void computePathName(CDOBranch branch, StringBuilder builder)
- {
- CDOBranchPoint base = branch.getBase();
- CDOBranch parent = base.getBranch();
- if (parent != null)
- {
- computePathName(parent, builder);
- builder.append(PATH_SEPARATOR);
- }
-
- builder.append(branch.getName());
- }
-
- public CDOBranchPoint[] getBasePath()
- {
- List<CDOBranchPoint> path = new ArrayList<CDOBranchPoint>();
- computeBasePath(this, path);
- return path.toArray(new CDOBranchPoint[path.size()]);
- }
-
- private void computeBasePath(CDOBranch branch, List<CDOBranchPoint> path)
- {
- CDOBranchPoint base = branch.getBase();
- CDOBranch parent = base.getBranch();
- if (parent != null)
- {
- computeBasePath(parent, path);
- }
-
- path.add(base);
- }
-
- public synchronized CDOBranchPoint getBase()
- {
- if (base == null)
- {
- load();
- }
-
- return base;
- }
-
- public CDOBranchPoint getHead()
- {
- return head;
- }
-
- public CDOBranchPoint getPoint(long timeStamp)
- {
- return new CDOBranchPointImpl(this, timeStamp);
- }
-
- public CDOBranchVersion getVersion(int version)
- {
- return new CDOBranchVersionImpl(this, version);
- }
-
- public InternalCDOBranch createBranch(String name, long timeStamp)
- {
- return getBranchManager().createBranch(BranchLoader.NEW_BRANCH, name, this, timeStamp);
- }
-
- public InternalCDOBranch createBranch(String name)
- {
- return createBranch(name, CDOBranchPoint.UNSPECIFIED_DATE);
- }
-
- public InternalCDOBranch[] getElements()
- {
- return getBranches();
- }
-
- public InternalCDOBranch[] getBranches(boolean loadOnDemand)
- {
- if (branches == null && loadOnDemand)
- {
- InternalCDOBranchManager branchManager = getBranchManager();
- SubBranchInfo[] infos = branchManager.getBranchLoader().loadSubBranches(id);
- branches = new InternalCDOBranch[infos.length];
- for (int i = 0; i < infos.length; i++)
- {
- SubBranchInfo info = infos[i];
- branches[i] = branchManager.getBranch(info.getID(), info.getName(), this, info.getBaseTimeStamp());
- }
- }
-
- return branches;
- }
-
- public synchronized InternalCDOBranch[] getBranches()
- {
- return getBranches(true);
- }
-
- public InternalCDOBranch getBranch(String path)
- {
- while (path.startsWith(PATH_SEPARATOR))
- {
- path = path.substring(1);
- }
-
- while (path.endsWith(PATH_SEPARATOR))
- {
- path = path.substring(0, path.length() - PATH_SEPARATOR.length());
- }
-
- int sep = path.indexOf(PATH_SEPARATOR);
- if (sep == -1)
- {
- return getChild(path);
- }
-
- String name = path.substring(0, sep);
- InternalCDOBranch child = getChild(name);
- if (child == null)
- {
- return null;
- }
-
- // Recurse
- String rest = path.substring(sep + 1);
- return child.getBranch(rest);
- }
-
- private InternalCDOBranch getChild(String name)
- {
- InternalCDOBranch[] branches = getBranches();
- for (InternalCDOBranch branch : branches)
- {
- if (name.equals(branch.getName()))
- {
- return branch;
- }
- }
-
- return null;
- }
-
- public BranchInfo getBranchInfo()
- {
- CDOBranchPoint base = getBase();
- return new BranchInfo(getName(), base.getBranch().getID(), base.getTimeStamp());
- }
-
- public void setBranchInfo(String name, InternalCDOBranch baseBranch, long baseTimeStamp)
- {
- this.name = name;
- base = baseBranch.getPoint(baseTimeStamp);
- }
-
- public void addChild(InternalCDOBranch branch)
- {
- synchronized (this)
- {
- if (branches == null)
- {
- branches = new InternalCDOBranch[] { branch };
- }
- else
- {
- InternalCDOBranch[] newBranches = new InternalCDOBranch[branches.length + 1];
- System.arraycopy(branches, 0, newBranches, 0, branches.length);
- newBranches[branches.length] = branch;
- branches = newBranches;
- }
- }
-
- fireElementAddedEvent(branch);
- }
-
- public int compareTo(CDOBranch o)
- {
- int otherID = o.getID();
- return id < otherID ? -1 : id == otherID ? 0 : 1;
- }
-
- @Override
- public int hashCode()
- {
- return id;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj instanceof CDOBranch)
- {
- CDOBranch that = (CDOBranch)obj;
- return id == that.getID();
- }
-
- return false;
- }
-
- @Override
- public String toString()
- {
- if (isProxy())
- {
- return MessageFormat.format("Branch[id={0}, PROXY]", id); //$NON-NLS-1$
- }
-
- return MessageFormat.format("Branch[id={0}, name={1}]", id, name); //$NON-NLS-1$
- }
-
- private synchronized void load()
- {
- BranchInfo branchInfo = branchManager.getBranchLoader().loadBranch(id);
- CDOBranch baseBranch = branchManager.getBranch(branchInfo.getBaseBranchID());
-
- name = branchInfo.getName();
- base = baseBranch.getPoint(branchInfo.getBaseTimeStamp());
- }
-
- /**
- * @author Eike Stepper
- */
- public static class Main extends CDOBranchImpl
- {
- private boolean local;
-
- public Main(InternalCDOBranchManager branchManager, boolean local, long timeStamp)
- {
- super(branchManager, MAIN_BRANCH_ID, MAIN_BRANCH_NAME, new CDOBranchPointImpl(null, timeStamp));
- this.local = local;
- }
-
- @Override
- public boolean isMainBranch()
- {
- return true;
- }
-
- @Override
- public boolean isLocal()
- {
- return local;
- }
- }
-}
+/* + * 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.internal.common.branch; + +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.spi.common.branch.InternalCDOBranch; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.SubBranchInfo; + +import org.eclipse.net4j.util.container.Container; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class CDOBranchImpl extends Container<CDOBranch> implements InternalCDOBranch +{ + public static final int ILLEGAL_BRANCH_ID = Integer.MIN_VALUE; + + private InternalCDOBranchManager branchManager; + + private int id; + + private String name; + + private CDOBranchPoint base; + + private CDOBranchPoint head = getPoint(CDOBranchPoint.UNSPECIFIED_DATE); + + private InternalCDOBranch[] branches; + + public CDOBranchImpl(InternalCDOBranchManager branchManager, int id, String name, CDOBranchPoint base) + { + this.branchManager = branchManager; + this.id = id; + this.name = name; + this.base = base; + activate(); + } + + public boolean isMainBranch() + { + return false; + } + + public boolean isLocal() + { + return id < 0; + } + + public InternalCDOBranchManager getBranchManager() + { + return branchManager; + } + + public int getID() + { + return id; + } + + public synchronized String getName() + { + if (name == null) + { + load(); + } + + return name; + } + + public boolean isProxy() + { + return name == null || base == null; + } + + public String getPathName() + { + StringBuilder builder = new StringBuilder(); + computePathName(this, builder); + return builder.toString(); + } + + private void computePathName(CDOBranch branch, StringBuilder builder) + { + CDOBranchPoint base = branch.getBase(); + CDOBranch parent = base.getBranch(); + if (parent != null) + { + computePathName(parent, builder); + builder.append(PATH_SEPARATOR); + } + + builder.append(branch.getName()); + } + + public CDOBranchPoint[] getBasePath() + { + List<CDOBranchPoint> path = new ArrayList<CDOBranchPoint>(); + computeBasePath(this, path); + return path.toArray(new CDOBranchPoint[path.size()]); + } + + private void computeBasePath(CDOBranch branch, List<CDOBranchPoint> path) + { + CDOBranchPoint base = branch.getBase(); + CDOBranch parent = base.getBranch(); + if (parent != null) + { + computeBasePath(parent, path); + } + + path.add(base); + } + + public synchronized CDOBranchPoint getBase() + { + if (base == null) + { + load(); + } + + return base; + } + + public CDOBranchPoint getHead() + { + return head; + } + + public CDOBranchPoint getPoint(long timeStamp) + { + return new CDOBranchPointImpl(this, timeStamp); + } + + public CDOBranchVersion getVersion(int version) + { + return new CDOBranchVersionImpl(this, version); + } + + public InternalCDOBranch createBranch(String name, long timeStamp) + { + return getBranchManager().createBranch(BranchLoader.NEW_BRANCH, name, this, timeStamp); + } + + public InternalCDOBranch createBranch(String name) + { + return createBranch(name, CDOBranchPoint.UNSPECIFIED_DATE); + } + + public InternalCDOBranch[] getElements() + { + return getBranches(); + } + + public InternalCDOBranch[] getBranches(boolean loadOnDemand) + { + if (branches == null && loadOnDemand) + { + InternalCDOBranchManager branchManager = getBranchManager(); + SubBranchInfo[] infos = branchManager.getBranchLoader().loadSubBranches(id); + branches = new InternalCDOBranch[infos.length]; + for (int i = 0; i < infos.length; i++) + { + SubBranchInfo info = infos[i]; + branches[i] = branchManager.getBranch(info.getID(), info.getName(), this, info.getBaseTimeStamp()); + } + } + + return branches; + } + + public synchronized InternalCDOBranch[] getBranches() + { + return getBranches(true); + } + + public InternalCDOBranch getBranch(String path) + { + while (path.startsWith(PATH_SEPARATOR)) + { + path = path.substring(1); + } + + while (path.endsWith(PATH_SEPARATOR)) + { + path = path.substring(0, path.length() - PATH_SEPARATOR.length()); + } + + int sep = path.indexOf(PATH_SEPARATOR); + if (sep == -1) + { + return getChild(path); + } + + String name = path.substring(0, sep); + InternalCDOBranch child = getChild(name); + if (child == null) + { + return null; + } + + // Recurse + String rest = path.substring(sep + 1); + return child.getBranch(rest); + } + + private InternalCDOBranch getChild(String name) + { + InternalCDOBranch[] branches = getBranches(); + for (InternalCDOBranch branch : branches) + { + if (name.equals(branch.getName())) + { + return branch; + } + } + + return null; + } + + public BranchInfo getBranchInfo() + { + CDOBranchPoint base = getBase(); + return new BranchInfo(getName(), base.getBranch().getID(), base.getTimeStamp()); + } + + public void setBranchInfo(String name, InternalCDOBranch baseBranch, long baseTimeStamp) + { + this.name = name; + base = baseBranch.getPoint(baseTimeStamp); + } + + public void addChild(InternalCDOBranch branch) + { + synchronized (this) + { + if (branches == null) + { + branches = new InternalCDOBranch[] { branch }; + } + else + { + InternalCDOBranch[] newBranches = new InternalCDOBranch[branches.length + 1]; + System.arraycopy(branches, 0, newBranches, 0, branches.length); + newBranches[branches.length] = branch; + branches = newBranches; + } + } + + fireElementAddedEvent(branch); + } + + public int compareTo(CDOBranch o) + { + int otherID = o.getID(); + return id < otherID ? -1 : id == otherID ? 0 : 1; + } + + @Override + public int hashCode() + { + return id; + } + + @Override + public boolean equals(Object obj) + { + if (obj == this) + { + return true; + } + + if (obj instanceof CDOBranch) + { + CDOBranch that = (CDOBranch)obj; + return id == that.getID(); + } + + return false; + } + + @Override + public String toString() + { + if (isProxy()) + { + return MessageFormat.format("Branch[id={0}, PROXY]", id); //$NON-NLS-1$ + } + + return MessageFormat.format("Branch[id={0}, name={1}]", id, name); //$NON-NLS-1$ + } + + private synchronized void load() + { + BranchInfo branchInfo = branchManager.getBranchLoader().loadBranch(id); + CDOBranch baseBranch = branchManager.getBranch(branchInfo.getBaseBranchID()); + + name = branchInfo.getName(); + base = baseBranch.getPoint(branchInfo.getBaseTimeStamp()); + } + + /** + * @author Eike Stepper + */ + public static class Main extends CDOBranchImpl + { + private boolean local; + + public Main(InternalCDOBranchManager branchManager, boolean local, long timeStamp) + { + super(branchManager, MAIN_BRANCH_ID, MAIN_BRANCH_NAME, new CDOBranchPointImpl(null, timeStamp)); + this.local = local; + } + + @Override + public boolean isMainBranch() + { + return true; + } + + @Override + public boolean isLocal() + { + return local; + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchManagerImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchManagerImpl.java index 94e69d80aa..f472cd653f 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchManagerImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchManagerImpl.java @@ -1,251 +1,251 @@ -/*
- * 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.internal.common.branch;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchCreatedEvent;
-import org.eclipse.emf.cdo.common.branch.CDOBranchHandler;
-import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.util.CDOTimeProvider;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo;
-
-import org.eclipse.net4j.util.collection.Pair;
-import org.eclipse.net4j.util.container.Container;
-import org.eclipse.net4j.util.event.Event;
-import org.eclipse.net4j.util.ref.ReferenceValueMap;
-import org.eclipse.net4j.util.ref.ReferenceValueMap.Soft;
-
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class CDOBranchManagerImpl extends Container<CDOBranch> implements InternalCDOBranchManager
-{
- private BranchLoader branchLoader;
-
- private CDOTimeProvider timeProvider;
-
- private InternalCDOBranch mainBranch;
-
- private Map<Integer, InternalCDOBranch> branches = createMap();
-
- public CDOBranchManagerImpl()
- {
- }
-
- public BranchLoader getBranchLoader()
- {
- return branchLoader;
- }
-
- public void setBranchLoader(BranchLoader branchLoader)
- {
- checkInactive();
- this.branchLoader = branchLoader;
- }
-
- public CDOTimeProvider getTimeProvider()
- {
- return timeProvider;
- }
-
- public void setTimeProvider(CDOTimeProvider timeProvider)
- {
- this.timeProvider = timeProvider;
- }
-
- public void initMainBranch(boolean local, long timeStamp)
- {
- mainBranch = new CDOBranchImpl.Main(this, local, timeStamp);
- }
-
- public void handleBranchCreated(InternalCDOBranch branch)
- {
- CDOBranchPoint base = branch.getBase();
- InternalCDOBranch baseBranch = (InternalCDOBranch)base.getBranch();
- baseBranch.addChild(branch);
-
- fireEvent(new BranchCreatedEvent(branch));
- }
-
- public CDOBranch[] getElements()
- {
- return new CDOBranch[] { getMainBranch() };
- }
-
- public InternalCDOBranch getMainBranch()
- {
- checkActive();
- return mainBranch;
- }
-
- public InternalCDOBranch getBranch(int branchID)
- {
- checkActive();
- if (branchID == CDOBranch.MAIN_BRANCH_ID)
- {
- return mainBranch;
- }
-
- InternalCDOBranch branch;
- synchronized (branches)
- {
- branch = branches.get(branchID);
- if (branch == null)
- {
- branch = new CDOBranchImpl(this, branchID, null, null);
- putBranch(branch);
- }
- }
-
- return branch;
- }
-
- public InternalCDOBranch getBranch(int id, String name, InternalCDOBranch baseBranch, long baseTimeStamp)
- {
- synchronized (branches)
- {
- InternalCDOBranch branch = branches.get(id);
- if (branch == null)
- {
- branch = new CDOBranchImpl(this, id, name, baseBranch.getPoint(baseTimeStamp));
- putBranch(branch);
- }
- else if (branch.isProxy())
- {
- branch.setBranchInfo(name, baseBranch, baseTimeStamp);
- }
-
- return branch;
- }
- }
-
- public InternalCDOBranch getBranch(int id, BranchInfo branchInfo)
- {
- String name = branchInfo.getName();
- InternalCDOBranch baseBranch = getBranch(branchInfo.getBaseBranchID());
- long baseTimeStamp = branchInfo.getBaseTimeStamp();
- return getBranch(id, name, baseBranch, baseTimeStamp);
- }
-
- public InternalCDOBranch getBranch(String path)
- {
- if (path.startsWith(CDOBranch.PATH_SEPARATOR))
- {
- path = path.substring(1);
- }
-
- int sep = path.indexOf(CDOBranch.PATH_SEPARATOR);
- if (sep == -1)
- {
- if (CDOBranch.MAIN_BRANCH_NAME.equals(path))
- {
- return mainBranch;
- }
-
- return null;
- }
-
- String name = path.substring(0, sep);
- if (CDOBranch.MAIN_BRANCH_NAME.equals(name))
- {
- String rest = path.substring(sep + 1);
- return mainBranch.getBranch(rest);
- }
-
- return null;
- }
-
- public int getBranches(int startID, int endID, CDOBranchHandler handler)
- {
- checkActive();
- return branchLoader.loadBranches(startID, endID, handler);
- }
-
- public InternalCDOBranch createBranch(int branchID, String name, InternalCDOBranch baseBranch, long baseTimeStamp)
- {
- checkActive();
-
- Pair<Integer, Long> result = branchLoader.createBranch(branchID, new BranchInfo(name, baseBranch.getID(),
- baseTimeStamp));
- branchID = result.getElement1();
- baseTimeStamp = result.getElement2();
-
- CDOBranchPoint base = baseBranch.getPoint(baseTimeStamp);
- InternalCDOBranch branch = new CDOBranchImpl(this, branchID, name, base);
- synchronized (branches)
- {
- putBranch(branch);
- }
-
- handleBranchCreated(branch);
- return branch;
- }
-
- /**
- * {@link #branches} must be synchronized by caller!
- */
- private boolean putBranch(InternalCDOBranch branch)
- {
- int id = branch.getID();
- if (branches.containsKey(id))
- {
- return false;
- }
-
- branches.put(id, branch);
- return true;
- }
-
- protected Soft<Integer, InternalCDOBranch> createMap()
- {
- return new ReferenceValueMap.Soft<Integer, InternalCDOBranch>();
- }
-
- @Override
- protected void doBeforeActivate() throws Exception
- {
- super.doBeforeActivate();
- checkState(branchLoader, "branchLoader"); //$NON-NLS-1$
- checkState(timeProvider, "timeProvider"); //$NON-NLS-1$
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class BranchCreatedEvent extends Event implements CDOBranchCreatedEvent
- {
- private static final long serialVersionUID = 1L;
-
- private CDOBranch branch;
-
- public BranchCreatedEvent(CDOBranch branch)
- {
- super(branch.getBranchManager());
- this.branch = branch;
- }
-
- @Override
- public CDOBranchManager getSource()
- {
- return (CDOBranchManager)super.getSource();
- }
-
- public CDOBranch getBranch()
- {
- return 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.internal.common.branch; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.branch.CDOBranchCreatedEvent; +import org.eclipse.emf.cdo.common.branch.CDOBranchHandler; +import org.eclipse.emf.cdo.common.branch.CDOBranchManager; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.util.CDOTimeProvider; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranch; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo; + +import org.eclipse.net4j.util.collection.Pair; +import org.eclipse.net4j.util.container.Container; +import org.eclipse.net4j.util.event.Event; +import org.eclipse.net4j.util.ref.ReferenceValueMap; +import org.eclipse.net4j.util.ref.ReferenceValueMap.Soft; + +import java.util.Map; + +/** + * @author Eike Stepper + */ +public class CDOBranchManagerImpl extends Container<CDOBranch> implements InternalCDOBranchManager +{ + private BranchLoader branchLoader; + + private CDOTimeProvider timeProvider; + + private InternalCDOBranch mainBranch; + + private Map<Integer, InternalCDOBranch> branches = createMap(); + + public CDOBranchManagerImpl() + { + } + + public BranchLoader getBranchLoader() + { + return branchLoader; + } + + public void setBranchLoader(BranchLoader branchLoader) + { + checkInactive(); + this.branchLoader = branchLoader; + } + + public CDOTimeProvider getTimeProvider() + { + return timeProvider; + } + + public void setTimeProvider(CDOTimeProvider timeProvider) + { + this.timeProvider = timeProvider; + } + + public void initMainBranch(boolean local, long timeStamp) + { + mainBranch = new CDOBranchImpl.Main(this, local, timeStamp); + } + + public void handleBranchCreated(InternalCDOBranch branch) + { + CDOBranchPoint base = branch.getBase(); + InternalCDOBranch baseBranch = (InternalCDOBranch)base.getBranch(); + baseBranch.addChild(branch); + + fireEvent(new BranchCreatedEvent(branch)); + } + + public CDOBranch[] getElements() + { + return new CDOBranch[] { getMainBranch() }; + } + + public InternalCDOBranch getMainBranch() + { + checkActive(); + return mainBranch; + } + + public InternalCDOBranch getBranch(int branchID) + { + checkActive(); + if (branchID == CDOBranch.MAIN_BRANCH_ID) + { + return mainBranch; + } + + InternalCDOBranch branch; + synchronized (branches) + { + branch = branches.get(branchID); + if (branch == null) + { + branch = new CDOBranchImpl(this, branchID, null, null); + putBranch(branch); + } + } + + return branch; + } + + public InternalCDOBranch getBranch(int id, String name, InternalCDOBranch baseBranch, long baseTimeStamp) + { + synchronized (branches) + { + InternalCDOBranch branch = branches.get(id); + if (branch == null) + { + branch = new CDOBranchImpl(this, id, name, baseBranch.getPoint(baseTimeStamp)); + putBranch(branch); + } + else if (branch.isProxy()) + { + branch.setBranchInfo(name, baseBranch, baseTimeStamp); + } + + return branch; + } + } + + public InternalCDOBranch getBranch(int id, BranchInfo branchInfo) + { + String name = branchInfo.getName(); + InternalCDOBranch baseBranch = getBranch(branchInfo.getBaseBranchID()); + long baseTimeStamp = branchInfo.getBaseTimeStamp(); + return getBranch(id, name, baseBranch, baseTimeStamp); + } + + public InternalCDOBranch getBranch(String path) + { + if (path.startsWith(CDOBranch.PATH_SEPARATOR)) + { + path = path.substring(1); + } + + int sep = path.indexOf(CDOBranch.PATH_SEPARATOR); + if (sep == -1) + { + if (CDOBranch.MAIN_BRANCH_NAME.equals(path)) + { + return mainBranch; + } + + return null; + } + + String name = path.substring(0, sep); + if (CDOBranch.MAIN_BRANCH_NAME.equals(name)) + { + String rest = path.substring(sep + 1); + return mainBranch.getBranch(rest); + } + + return null; + } + + public int getBranches(int startID, int endID, CDOBranchHandler handler) + { + checkActive(); + return branchLoader.loadBranches(startID, endID, handler); + } + + public InternalCDOBranch createBranch(int branchID, String name, InternalCDOBranch baseBranch, long baseTimeStamp) + { + checkActive(); + + Pair<Integer, Long> result = branchLoader.createBranch(branchID, new BranchInfo(name, baseBranch.getID(), + baseTimeStamp)); + branchID = result.getElement1(); + baseTimeStamp = result.getElement2(); + + CDOBranchPoint base = baseBranch.getPoint(baseTimeStamp); + InternalCDOBranch branch = new CDOBranchImpl(this, branchID, name, base); + synchronized (branches) + { + putBranch(branch); + } + + handleBranchCreated(branch); + return branch; + } + + /** + * {@link #branches} must be synchronized by caller! + */ + private boolean putBranch(InternalCDOBranch branch) + { + int id = branch.getID(); + if (branches.containsKey(id)) + { + return false; + } + + branches.put(id, branch); + return true; + } + + protected Soft<Integer, InternalCDOBranch> createMap() + { + return new ReferenceValueMap.Soft<Integer, InternalCDOBranch>(); + } + + @Override + protected void doBeforeActivate() throws Exception + { + super.doBeforeActivate(); + checkState(branchLoader, "branchLoader"); //$NON-NLS-1$ + checkState(timeProvider, "timeProvider"); //$NON-NLS-1$ + } + + /** + * @author Eike Stepper + */ + private static final class BranchCreatedEvent extends Event implements CDOBranchCreatedEvent + { + private static final long serialVersionUID = 1L; + + private CDOBranch branch; + + public BranchCreatedEvent(CDOBranch branch) + { + super(branch.getBranchManager()); + this.branch = branch; + } + + @Override + public CDOBranchManager getSource() + { + return (CDOBranchManager)super.getSource(); + } + + public CDOBranch getBranch() + { + return branch; + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchPointImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchPointImpl.java index 48341226a1..b7bb7ffea6 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchPointImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchPointImpl.java @@ -1,85 +1,85 @@ -/*
- * 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.internal.common.branch;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
-
-import org.eclipse.net4j.util.ObjectUtil;
-
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public class CDOBranchPointImpl implements CDOBranchPoint, Comparable<CDOBranchPoint>
-{
- private CDOBranch branch;
-
- private long timeStamp;
-
- public CDOBranchPointImpl(CDOBranch branch, long timeStamp)
- {
- this.branch = branch;
- this.timeStamp = timeStamp;
- }
-
- public CDOBranch getBranch()
- {
- return branch;
- }
-
- public long getTimeStamp()
- {
- return timeStamp;
- }
-
- public int compareTo(CDOBranchPoint o)
- {
- int result = branch.compareTo(o.getBranch());
- if (result == 0)
- {
- result = CDOCommonUtil.compareTimeStamps(timeStamp, o.getTimeStamp());
- }
-
- return result;
- }
-
- @Override
- public int hashCode()
- {
- return branch.hashCode() ^ new Long(timeStamp).hashCode();
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj instanceof CDOBranchPoint)
- {
- CDOBranchPoint that = (CDOBranchPoint)obj;
- return ObjectUtil.equals(branch, that.getBranch()) && timeStamp == that.getTimeStamp();
- }
-
- return false;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("BranchPoint[{0}, {1}]", branch, CDOCommonUtil.formatTimeStamp(timeStamp)); //$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.internal.common.branch; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.util.CDOCommonUtil; + +import org.eclipse.net4j.util.ObjectUtil; + +import java.text.MessageFormat; + +/** + * @author Eike Stepper + */ +public class CDOBranchPointImpl implements CDOBranchPoint, Comparable<CDOBranchPoint> +{ + private CDOBranch branch; + + private long timeStamp; + + public CDOBranchPointImpl(CDOBranch branch, long timeStamp) + { + this.branch = branch; + this.timeStamp = timeStamp; + } + + public CDOBranch getBranch() + { + return branch; + } + + public long getTimeStamp() + { + return timeStamp; + } + + public int compareTo(CDOBranchPoint o) + { + int result = branch.compareTo(o.getBranch()); + if (result == 0) + { + result = CDOCommonUtil.compareTimeStamps(timeStamp, o.getTimeStamp()); + } + + return result; + } + + @Override + public int hashCode() + { + return branch.hashCode() ^ new Long(timeStamp).hashCode(); + } + + @Override + public boolean equals(Object obj) + { + if (obj == this) + { + return true; + } + + if (obj instanceof CDOBranchPoint) + { + CDOBranchPoint that = (CDOBranchPoint)obj; + return ObjectUtil.equals(branch, that.getBranch()) && timeStamp == that.getTimeStamp(); + } + + return false; + } + + @Override + public String toString() + { + return MessageFormat.format("BranchPoint[{0}, {1}]", branch, CDOCommonUtil.formatTimeStamp(timeStamp)); //$NON-NLS-1$ + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchPointRangeImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchPointRangeImpl.java index c980e44c84..900396851a 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchPointRangeImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchPointRangeImpl.java @@ -1,48 +1,48 @@ -/*
- * 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.internal.common.branch;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPointRange;
-
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public class CDOBranchPointRangeImpl implements CDOBranchPointRange
-{
- private CDOBranchPoint startPoint;
-
- private CDOBranchPoint endPoint;
-
- public CDOBranchPointRangeImpl(CDOBranchPoint startPoint, CDOBranchPoint endPoint)
- {
- this.startPoint = startPoint;
- this.endPoint = endPoint;
- }
-
- public CDOBranchPoint getStartPoint()
- {
- return startPoint;
- }
-
- public CDOBranchPoint getEndPoint()
- {
- return endPoint;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("Range[{0}, {1}]", startPoint, endPoint); //$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.internal.common.branch; + +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.branch.CDOBranchPointRange; + +import java.text.MessageFormat; + +/** + * @author Eike Stepper + */ +public class CDOBranchPointRangeImpl implements CDOBranchPointRange +{ + private CDOBranchPoint startPoint; + + private CDOBranchPoint endPoint; + + public CDOBranchPointRangeImpl(CDOBranchPoint startPoint, CDOBranchPoint endPoint) + { + this.startPoint = startPoint; + this.endPoint = endPoint; + } + + public CDOBranchPoint getStartPoint() + { + return startPoint; + } + + public CDOBranchPoint getEndPoint() + { + return endPoint; + } + + @Override + public String toString() + { + return MessageFormat.format("Range[{0}, {1}]", startPoint, endPoint); //$NON-NLS-1$ + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchVersionImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchVersionImpl.java index dc04d2ad0e..1d5050875f 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchVersionImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/branch/CDOBranchVersionImpl.java @@ -1,73 +1,73 @@ -/*
- * 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.internal.common.branch;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-
-import org.eclipse.net4j.util.ObjectUtil;
-
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public class CDOBranchVersionImpl implements CDOBranchVersion
-{
- private CDOBranch branch;
-
- private int version;
-
- public CDOBranchVersionImpl(CDOBranch branch, int version)
- {
- this.branch = branch;
- this.version = version;
- }
-
- public CDOBranch getBranch()
- {
- return branch;
- }
-
- public int getVersion()
- {
- return version;
- }
-
- @Override
- public int hashCode()
- {
- return branch.hashCode() ^ version;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj instanceof CDOBranchVersion)
- {
- CDOBranchVersion that = (CDOBranchVersion)obj;
- return ObjectUtil.equals(branch, that.getBranch()) && version == that.getVersion();
- }
-
- return false;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("BranchVersion[{0}, v{1}]", branch, version); //$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.internal.common.branch; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; + +import org.eclipse.net4j.util.ObjectUtil; + +import java.text.MessageFormat; + +/** + * @author Eike Stepper + */ +public class CDOBranchVersionImpl implements CDOBranchVersion +{ + private CDOBranch branch; + + private int version; + + public CDOBranchVersionImpl(CDOBranch branch, int version) + { + this.branch = branch; + this.version = version; + } + + public CDOBranch getBranch() + { + return branch; + } + + public int getVersion() + { + return version; + } + + @Override + public int hashCode() + { + return branch.hashCode() ^ version; + } + + @Override + public boolean equals(Object obj) + { + if (obj == this) + { + return true; + } + + if (obj instanceof CDOBranchVersion) + { + CDOBranchVersion that = (CDOBranchVersion)obj; + return ObjectUtil.equals(branch, that.getBranch()) && version == that.getVersion(); + } + + return false; + } + + @Override + public String toString() + { + return MessageFormat.format("BranchVersion[{0}, v{1}]", branch, version); //$NON-NLS-1$ + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/bundle/OM.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/bundle/OM.java index 90481c4df5..11b0b6390f 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/bundle/OM.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/bundle/OM.java @@ -1,58 +1,58 @@ -/*
- * 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.internal.common.bundle;
-
-import org.eclipse.net4j.util.om.OMBundle;
-import org.eclipse.net4j.util.om.OMPlatform;
-import org.eclipse.net4j.util.om.OSGiActivator;
-import org.eclipse.net4j.util.om.log.OMLogger;
-import org.eclipse.net4j.util.om.trace.OMTracer;
-
-/**
- * The <em>Operations & Maintenance</em> class of this bundle.
- *
- * @author Eike Stepper
- */
-public abstract class OM
-{
- public static final String BUNDLE_ID = "org.eclipse.emf.cdo.common"; //$NON-NLS-1$
-
- public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class);
-
- public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$
-
- public static final OMTracer DEBUG_PROTOCOL = DEBUG.tracer("protocol"); //$NON-NLS-1$
-
- public static final OMTracer DEBUG_ID = DEBUG.tracer("id"); //$NON-NLS-1$
-
- public static final OMTracer DEBUG_REVISION = DEBUG.tracer("revision"); //$NON-NLS-1$
-
- public static final OMTracer PERF = BUNDLE.tracer("perf"); //$NON-NLS-1$
-
- public static final OMTracer PERF_REVISION = PERF.tracer("revision"); //$NON-NLS-1$
-
- public static final OMTracer PERF_REVISION_READING = PERF_REVISION.tracer("reading"); //$NON-NLS-1$
-
- public static final OMTracer PERF_REVISION_WRITING = PERF_REVISION.tracer("writing"); //$NON-NLS-1$
-
- public static final OMLogger LOG = BUNDLE.logger();
-
- /**
- * @author Eike Stepper
- */
- public static final class Activator extends OSGiActivator
- {
- public Activator()
- {
- super(BUNDLE);
- }
- }
-}
+/* + * 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.internal.common.bundle; + +import org.eclipse.net4j.util.om.OMBundle; +import org.eclipse.net4j.util.om.OMPlatform; +import org.eclipse.net4j.util.om.OSGiActivator; +import org.eclipse.net4j.util.om.log.OMLogger; +import org.eclipse.net4j.util.om.trace.OMTracer; + +/** + * The <em>Operations & Maintenance</em> class of this bundle. + * + * @author Eike Stepper + */ +public abstract class OM +{ + public static final String BUNDLE_ID = "org.eclipse.emf.cdo.common"; //$NON-NLS-1$ + + public static final OMBundle BUNDLE = OMPlatform.INSTANCE.bundle(BUNDLE_ID, OM.class); + + public static final OMTracer DEBUG = BUNDLE.tracer("debug"); //$NON-NLS-1$ + + public static final OMTracer DEBUG_PROTOCOL = DEBUG.tracer("protocol"); //$NON-NLS-1$ + + public static final OMTracer DEBUG_ID = DEBUG.tracer("id"); //$NON-NLS-1$ + + public static final OMTracer DEBUG_REVISION = DEBUG.tracer("revision"); //$NON-NLS-1$ + + public static final OMTracer PERF = BUNDLE.tracer("perf"); //$NON-NLS-1$ + + public static final OMTracer PERF_REVISION = PERF.tracer("revision"); //$NON-NLS-1$ + + public static final OMTracer PERF_REVISION_READING = PERF_REVISION.tracer("reading"); //$NON-NLS-1$ + + public static final OMTracer PERF_REVISION_WRITING = PERF_REVISION.tracer("writing"); //$NON-NLS-1$ + + public static final OMLogger LOG = BUNDLE.logger(); + + /** + * @author Eike Stepper + */ + public static final class Activator extends OSGiActivator + { + public Activator() + { + super(BUNDLE); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetDataImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetDataImpl.java index b327991a41..dd0694cead 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetDataImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetDataImpl.java @@ -1,225 +1,225 @@ -/*
- * 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.internal.common.commit;
-
-import org.eclipse.emf.cdo.common.commit.CDOChangeKind;
-import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-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.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.spi.common.commit.CDOChangeKindCache;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class CDOChangeSetDataImpl implements CDOChangeSetData
-{
- private List<CDOIDAndVersion> newObjects;
-
- private List<CDORevisionKey> changedObjects;
-
- private List<CDOIDAndVersion> detachedObjects;
-
- private CDOChangeKindCache changeKindCache;
-
- public CDOChangeSetDataImpl(List<CDOIDAndVersion> newObjects, List<CDORevisionKey> changedObjects,
- List<CDOIDAndVersion> detachedObjects)
- {
- this.newObjects = newObjects;
- this.changedObjects = changedObjects;
- this.detachedObjects = detachedObjects;
- }
-
- public CDOChangeSetDataImpl()
- {
- this(new ArrayList<CDOIDAndVersion>(), new ArrayList<CDORevisionKey>(), new ArrayList<CDOIDAndVersion>());
- }
-
- public boolean isEmpty()
- {
- if (newObjects != null && !newObjects.isEmpty())
- {
- return false;
- }
-
- if (changedObjects != null && !changedObjects.isEmpty())
- {
- return false;
- }
-
- if (detachedObjects != null && !detachedObjects.isEmpty())
- {
- return false;
- }
-
- return true;
- }
-
- public CDOChangeSetData copy()
- {
- List<CDOIDAndVersion> newObjectsCopy = new ArrayList<CDOIDAndVersion>(newObjects.size());
- for (CDOIDAndVersion key : newObjects)
- {
- if (key instanceof CDORevision)
- {
- CDORevision revision = (CDORevision)key;
- newObjectsCopy.add(revision.copy());
- }
- else
- {
- newObjectsCopy.add(key);
- }
- }
-
- List<CDORevisionKey> changedObjectsCopy = new ArrayList<CDORevisionKey>(changedObjects.size());
- for (CDORevisionKey key : changedObjects)
- {
- if (key instanceof CDORevisionDelta)
- {
- CDORevisionDelta delta = (CDORevisionDelta)key;
- changedObjectsCopy.add(delta.copy());
- }
- else
- {
- changedObjectsCopy.add(key);
- }
- }
-
- List<CDOIDAndVersion> detachedObjectsCopy = new ArrayList<CDOIDAndVersion>(detachedObjects.size());
- for (CDOIDAndVersion key : detachedObjects)
- {
- detachedObjectsCopy.add(key);
- }
-
- return new CDOChangeSetDataImpl(newObjectsCopy, changedObjectsCopy, detachedObjectsCopy);
- }
-
- public void merge(CDOChangeSetData changeSetData)
- {
- Map<CDOID, CDOIDAndVersion> newMap = new HashMap<CDOID, CDOIDAndVersion>();
- fillMap(newMap, newObjects);
- fillMap(newMap, changeSetData.getNewObjects());
-
- Map<CDOID, CDORevisionKey> changedMap = new HashMap<CDOID, CDORevisionKey>();
- fillMap(changedMap, changedObjects);
- for (CDORevisionKey key : changeSetData.getChangedObjects())
- {
- mergeChangedObject(key, newMap, changedMap);
- }
-
- Map<CDOID, CDOIDAndVersion> detachedMap = new HashMap<CDOID, CDOIDAndVersion>();
- fillMap(detachedMap, detachedObjects);
- for (CDOIDAndVersion key : changeSetData.getDetachedObjects())
- {
- CDOID id = key.getID();
- if (newMap.remove(id) == null)
- {
- detachedMap.put(id, key);
- }
- }
-
- newObjects = new ArrayList<CDOIDAndVersion>(newMap.values());
- changedObjects = new ArrayList<CDORevisionKey>(changedMap.values());
- detachedObjects = new ArrayList<CDOIDAndVersion>(detachedMap.values());
- }
-
- private void mergeChangedObject(CDORevisionKey key, Map<CDOID, CDOIDAndVersion> newMap,
- Map<CDOID, CDORevisionKey> changedMap)
- {
- CDOID id = key.getID();
- if (key instanceof CDORevisionDelta)
- {
- CDORevisionDelta delta = (CDORevisionDelta)key;
-
- // Try to add the delta to existing new revision
- CDOIDAndVersion oldRevision = newMap.get(id);
- if (oldRevision instanceof CDORevision)
- {
- CDORevision newRevision = (CDORevision)oldRevision;
- delta.apply(newRevision);
- return;
- }
-
- // Try to add the delta to existing delta
- CDORevisionKey oldDelta = changedMap.get(id);
- if (oldDelta instanceof CDORevisionDelta)
- {
- InternalCDORevisionDelta newDelta = (InternalCDORevisionDelta)oldDelta;
- for (CDOFeatureDelta featureDelta : delta.getFeatureDeltas())
- {
- newDelta.addFeatureDelta(featureDelta);
- }
-
- return;
- }
- }
-
- // Fall back
- changedMap.put(id, key);
- }
-
- public List<CDOIDAndVersion> getNewObjects()
- {
- return newObjects;
- }
-
- public List<CDORevisionKey> getChangedObjects()
- {
- return changedObjects;
- }
-
- public List<CDOIDAndVersion> getDetachedObjects()
- {
- return detachedObjects;
- }
-
- public synchronized Map<CDOID, CDOChangeKind> getChangeKinds()
- {
- if (changeKindCache == null)
- {
- changeKindCache = new CDOChangeKindCache(this);
- }
-
- return changeKindCache;
- }
-
- public CDOChangeKind getChangeKind(CDOID id)
- {
- return getChangeKinds().get(id);
- }
-
- @Override
- public String toString()
- {
- return MessageFormat
- .format(
- "ChangeSetData[newObjects={0}, changedObjects={1}, detachedObjects={2}]", newObjects.size(), changedObjects.size(), detachedObjects.size()); //$NON-NLS-1$
- }
-
- private static <T extends CDOIDAndVersion> void fillMap(Map<CDOID, T> map, Collection<T> c)
- {
- for (T key : c)
- {
- map.put(key.getID(), key);
- }
- }
-}
+/* + * 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.internal.common.commit; + +import org.eclipse.emf.cdo.common.commit.CDOChangeKind; +import org.eclipse.emf.cdo.common.commit.CDOChangeSetData; +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.CDOFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; +import org.eclipse.emf.cdo.spi.common.commit.CDOChangeKindCache; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author Eike Stepper + */ +public class CDOChangeSetDataImpl implements CDOChangeSetData +{ + private List<CDOIDAndVersion> newObjects; + + private List<CDORevisionKey> changedObjects; + + private List<CDOIDAndVersion> detachedObjects; + + private CDOChangeKindCache changeKindCache; + + public CDOChangeSetDataImpl(List<CDOIDAndVersion> newObjects, List<CDORevisionKey> changedObjects, + List<CDOIDAndVersion> detachedObjects) + { + this.newObjects = newObjects; + this.changedObjects = changedObjects; + this.detachedObjects = detachedObjects; + } + + public CDOChangeSetDataImpl() + { + this(new ArrayList<CDOIDAndVersion>(), new ArrayList<CDORevisionKey>(), new ArrayList<CDOIDAndVersion>()); + } + + public boolean isEmpty() + { + if (newObjects != null && !newObjects.isEmpty()) + { + return false; + } + + if (changedObjects != null && !changedObjects.isEmpty()) + { + return false; + } + + if (detachedObjects != null && !detachedObjects.isEmpty()) + { + return false; + } + + return true; + } + + public CDOChangeSetData copy() + { + List<CDOIDAndVersion> newObjectsCopy = new ArrayList<CDOIDAndVersion>(newObjects.size()); + for (CDOIDAndVersion key : newObjects) + { + if (key instanceof CDORevision) + { + CDORevision revision = (CDORevision)key; + newObjectsCopy.add(revision.copy()); + } + else + { + newObjectsCopy.add(key); + } + } + + List<CDORevisionKey> changedObjectsCopy = new ArrayList<CDORevisionKey>(changedObjects.size()); + for (CDORevisionKey key : changedObjects) + { + if (key instanceof CDORevisionDelta) + { + CDORevisionDelta delta = (CDORevisionDelta)key; + changedObjectsCopy.add(delta.copy()); + } + else + { + changedObjectsCopy.add(key); + } + } + + List<CDOIDAndVersion> detachedObjectsCopy = new ArrayList<CDOIDAndVersion>(detachedObjects.size()); + for (CDOIDAndVersion key : detachedObjects) + { + detachedObjectsCopy.add(key); + } + + return new CDOChangeSetDataImpl(newObjectsCopy, changedObjectsCopy, detachedObjectsCopy); + } + + public void merge(CDOChangeSetData changeSetData) + { + Map<CDOID, CDOIDAndVersion> newMap = new HashMap<CDOID, CDOIDAndVersion>(); + fillMap(newMap, newObjects); + fillMap(newMap, changeSetData.getNewObjects()); + + Map<CDOID, CDORevisionKey> changedMap = new HashMap<CDOID, CDORevisionKey>(); + fillMap(changedMap, changedObjects); + for (CDORevisionKey key : changeSetData.getChangedObjects()) + { + mergeChangedObject(key, newMap, changedMap); + } + + Map<CDOID, CDOIDAndVersion> detachedMap = new HashMap<CDOID, CDOIDAndVersion>(); + fillMap(detachedMap, detachedObjects); + for (CDOIDAndVersion key : changeSetData.getDetachedObjects()) + { + CDOID id = key.getID(); + if (newMap.remove(id) == null) + { + detachedMap.put(id, key); + } + } + + newObjects = new ArrayList<CDOIDAndVersion>(newMap.values()); + changedObjects = new ArrayList<CDORevisionKey>(changedMap.values()); + detachedObjects = new ArrayList<CDOIDAndVersion>(detachedMap.values()); + } + + private void mergeChangedObject(CDORevisionKey key, Map<CDOID, CDOIDAndVersion> newMap, + Map<CDOID, CDORevisionKey> changedMap) + { + CDOID id = key.getID(); + if (key instanceof CDORevisionDelta) + { + CDORevisionDelta delta = (CDORevisionDelta)key; + + // Try to add the delta to existing new revision + CDOIDAndVersion oldRevision = newMap.get(id); + if (oldRevision instanceof CDORevision) + { + CDORevision newRevision = (CDORevision)oldRevision; + delta.apply(newRevision); + return; + } + + // Try to add the delta to existing delta + CDORevisionKey oldDelta = changedMap.get(id); + if (oldDelta instanceof CDORevisionDelta) + { + InternalCDORevisionDelta newDelta = (InternalCDORevisionDelta)oldDelta; + for (CDOFeatureDelta featureDelta : delta.getFeatureDeltas()) + { + newDelta.addFeatureDelta(featureDelta); + } + + return; + } + } + + // Fall back + changedMap.put(id, key); + } + + public List<CDOIDAndVersion> getNewObjects() + { + return newObjects; + } + + public List<CDORevisionKey> getChangedObjects() + { + return changedObjects; + } + + public List<CDOIDAndVersion> getDetachedObjects() + { + return detachedObjects; + } + + public synchronized Map<CDOID, CDOChangeKind> getChangeKinds() + { + if (changeKindCache == null) + { + changeKindCache = new CDOChangeKindCache(this); + } + + return changeKindCache; + } + + public CDOChangeKind getChangeKind(CDOID id) + { + return getChangeKinds().get(id); + } + + @Override + public String toString() + { + return MessageFormat + .format( + "ChangeSetData[newObjects={0}, changedObjects={1}, detachedObjects={2}]", newObjects.size(), changedObjects.size(), detachedObjects.size()); //$NON-NLS-1$ + } + + private static <T extends CDOIDAndVersion> void fillMap(Map<CDOID, T> map, Collection<T> c) + { + for (T key : c) + { + map.put(key.getID(), key); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetImpl.java index f637f6ee24..ea3c04bd83 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOChangeSetImpl.java @@ -1,48 +1,48 @@ -/*
- * 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.internal.common.commit;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.commit.CDOChangeSet;
-import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
-
-/**
- * @author Eike Stepper
- */
-public class CDOChangeSetImpl extends CDOChangeSetDataImpl implements CDOChangeSet
-{
- private CDOBranchPoint startPoint;
-
- private CDOBranchPoint endPoint;
-
- public CDOChangeSetImpl(CDOBranchPoint startPoint, CDOBranchPoint endPoint, CDOChangeSetData data)
- {
- super(data.getNewObjects(), data.getChangedObjects(), data.getDetachedObjects());
- this.startPoint = startPoint;
- this.endPoint = endPoint;
- }
-
- public CDOBranchPoint getStartPoint()
- {
- return startPoint;
- }
-
- public CDOBranchPoint getEndPoint()
- {
- return endPoint;
- }
-
- public CDOBranchPoint getAncestorPoint()
- {
- return CDOBranchUtil.getAncestor(startPoint, endPoint);
- }
-}
+/* + * 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.internal.common.commit; + +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.commit.CDOChangeSet; +import org.eclipse.emf.cdo.common.commit.CDOChangeSetData; +import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil; + +/** + * @author Eike Stepper + */ +public class CDOChangeSetImpl extends CDOChangeSetDataImpl implements CDOChangeSet +{ + private CDOBranchPoint startPoint; + + private CDOBranchPoint endPoint; + + public CDOChangeSetImpl(CDOBranchPoint startPoint, CDOBranchPoint endPoint, CDOChangeSetData data) + { + super(data.getNewObjects(), data.getChangedObjects(), data.getDetachedObjects()); + this.startPoint = startPoint; + this.endPoint = endPoint; + } + + public CDOBranchPoint getStartPoint() + { + return startPoint; + } + + public CDOBranchPoint getEndPoint() + { + return endPoint; + } + + public CDOBranchPoint getAncestorPoint() + { + return CDOBranchUtil.getAncestor(startPoint, endPoint); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitDataImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitDataImpl.java index 3ae3d24957..8c56707f56 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitDataImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitDataImpl.java @@ -1,47 +1,47 @@ -/*
- * 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.internal.common.commit;
-
-import org.eclipse.emf.cdo.common.commit.CDOCommitData;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-
-import java.text.MessageFormat;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class CDOCommitDataImpl extends CDOChangeSetDataImpl implements CDOCommitData
-{
- private List<CDOPackageUnit> newPackageUnits;
-
- public CDOCommitDataImpl(List<CDOPackageUnit> newPackageUnits, List<CDOIDAndVersion> newObjects,
- List<CDORevisionKey> changedObjects, List<CDOIDAndVersion> detachedObjects)
- {
- super(newObjects, changedObjects, detachedObjects);
- this.newPackageUnits = newPackageUnits;
- }
-
- public List<CDOPackageUnit> getNewPackageUnits()
- {
- return newPackageUnits;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format(
- "CommitData[newPackageUnits={0}, newObjects={1}, changedObjects={2}, detachedObjects={3}]", //$NON-NLS-1$
- newPackageUnits.size(), getNewObjects().size(), getChangedObjects().size(), getDetachedObjects().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.internal.common.commit; + +import org.eclipse.emf.cdo.common.commit.CDOCommitData; +import org.eclipse.emf.cdo.common.model.CDOPackageUnit; +import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion; +import org.eclipse.emf.cdo.common.revision.CDORevisionKey; + +import java.text.MessageFormat; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class CDOCommitDataImpl extends CDOChangeSetDataImpl implements CDOCommitData +{ + private List<CDOPackageUnit> newPackageUnits; + + public CDOCommitDataImpl(List<CDOPackageUnit> newPackageUnits, List<CDOIDAndVersion> newObjects, + List<CDORevisionKey> changedObjects, List<CDOIDAndVersion> detachedObjects) + { + super(newObjects, changedObjects, detachedObjects); + this.newPackageUnits = newPackageUnits; + } + + public List<CDOPackageUnit> getNewPackageUnits() + { + return newPackageUnits; + } + + @Override + public String toString() + { + return MessageFormat.format( + "CommitData[newPackageUnits={0}, newObjects={1}, changedObjects={2}, detachedObjects={3}]", //$NON-NLS-1$ + newPackageUnits.size(), getNewObjects().size(), getChangedObjects().size(), getDetachedObjects().size()); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoImpl.java index b556e5072a..cb3056062e 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoImpl.java @@ -1,153 +1,153 @@ -/*
- * 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.internal.common.commit;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.commit.CDOChangeKind;
-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.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
-import org.eclipse.emf.cdo.internal.common.branch.CDOBranchPointImpl;
-import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
-
-import org.eclipse.net4j.util.CheckUtil;
-
-import java.text.MessageFormat;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class CDOCommitInfoImpl extends CDOBranchPointImpl implements CDOCommitInfo
-{
- private InternalCDOCommitInfoManager commitInfoManager;
-
- private long previousTimeStamp;
-
- private String userID;
-
- private String comment;
-
- private CDOCommitData commitData;
-
- public CDOCommitInfoImpl(InternalCDOCommitInfoManager commitInfoManager, CDOBranch branch, long timeStamp,
- long previousTimeStamp, String userID, String comment, CDOCommitData commitData)
- {
- super(branch, timeStamp);
- CheckUtil.checkArg(commitInfoManager, "commitInfoManager"); //$NON-NLS-1$
- this.commitInfoManager = commitInfoManager;
- this.previousTimeStamp = previousTimeStamp;
- this.userID = userID;
- this.comment = comment;
- this.commitData = commitData;
- }
-
- public InternalCDOCommitInfoManager getCommitInfoManager()
- {
- return commitInfoManager;
- }
-
- public long getPreviousTimeStamp()
- {
- return previousTimeStamp;
- }
-
- public String getUserID()
- {
- return userID;
- }
-
- public String getComment()
- {
- return comment;
- }
-
- public boolean isEmpty()
- {
- return false;
- }
-
- public CDOChangeSetData copy()
- {
- return commitData == null ? null : commitData.copy();
- }
-
- public void merge(CDOChangeSetData changeSetData)
- {
- loadCommitDataIfNeeded();
- commitData.merge(changeSetData);
- }
-
- public synchronized List<CDOPackageUnit> getNewPackageUnits()
- {
- loadCommitDataIfNeeded();
- return commitData.getNewPackageUnits();
- }
-
- public synchronized List<CDOIDAndVersion> getNewObjects()
- {
- loadCommitDataIfNeeded();
- return commitData.getNewObjects();
- }
-
- public synchronized List<CDORevisionKey> getChangedObjects()
- {
- loadCommitDataIfNeeded();
- return commitData.getChangedObjects();
- }
-
- public synchronized List<CDOIDAndVersion> getDetachedObjects()
- {
- loadCommitDataIfNeeded();
- return commitData.getDetachedObjects();
- }
-
- public Map<CDOID, CDOChangeKind> getChangeKinds()
- {
- loadCommitDataIfNeeded();
- return commitData.getChangeKinds();
- }
-
- public CDOChangeKind getChangeKind(CDOID id)
- {
- loadCommitDataIfNeeded();
- return commitData.getChangeKind(id);
- }
-
- @Override
- public String toString()
- {
- String data = null;
- if (commitData != null)
- {
- data = commitData.toString();
- }
-
- String timeStamp = CDOCommonUtil.formatTimeStamp(getTimeStamp());
- return MessageFormat
- .format(
- "CommitInfo[{0}, {1}, {2}, {3}, {4}, {5}]", getPreviousTimeStamp(), getBranch(), timeStamp, getUserID(), getComment(), data); //$NON-NLS-1$
- }
-
- private void loadCommitDataIfNeeded()
- {
- if (commitData == null)
- {
- commitData = commitInfoManager.getCommitInfoLoader().loadCommitData(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.internal.common.commit; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.commit.CDOChangeKind; +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.model.CDOPackageUnit; +import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion; +import org.eclipse.emf.cdo.common.revision.CDORevisionKey; +import org.eclipse.emf.cdo.common.util.CDOCommonUtil; +import org.eclipse.emf.cdo.internal.common.branch.CDOBranchPointImpl; +import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager; + +import org.eclipse.net4j.util.CheckUtil; + +import java.text.MessageFormat; +import java.util.List; +import java.util.Map; + +/** + * @author Eike Stepper + */ +public class CDOCommitInfoImpl extends CDOBranchPointImpl implements CDOCommitInfo +{ + private InternalCDOCommitInfoManager commitInfoManager; + + private long previousTimeStamp; + + private String userID; + + private String comment; + + private CDOCommitData commitData; + + public CDOCommitInfoImpl(InternalCDOCommitInfoManager commitInfoManager, CDOBranch branch, long timeStamp, + long previousTimeStamp, String userID, String comment, CDOCommitData commitData) + { + super(branch, timeStamp); + CheckUtil.checkArg(commitInfoManager, "commitInfoManager"); //$NON-NLS-1$ + this.commitInfoManager = commitInfoManager; + this.previousTimeStamp = previousTimeStamp; + this.userID = userID; + this.comment = comment; + this.commitData = commitData; + } + + public InternalCDOCommitInfoManager getCommitInfoManager() + { + return commitInfoManager; + } + + public long getPreviousTimeStamp() + { + return previousTimeStamp; + } + + public String getUserID() + { + return userID; + } + + public String getComment() + { + return comment; + } + + public boolean isEmpty() + { + return false; + } + + public CDOChangeSetData copy() + { + return commitData == null ? null : commitData.copy(); + } + + public void merge(CDOChangeSetData changeSetData) + { + loadCommitDataIfNeeded(); + commitData.merge(changeSetData); + } + + public synchronized List<CDOPackageUnit> getNewPackageUnits() + { + loadCommitDataIfNeeded(); + return commitData.getNewPackageUnits(); + } + + public synchronized List<CDOIDAndVersion> getNewObjects() + { + loadCommitDataIfNeeded(); + return commitData.getNewObjects(); + } + + public synchronized List<CDORevisionKey> getChangedObjects() + { + loadCommitDataIfNeeded(); + return commitData.getChangedObjects(); + } + + public synchronized List<CDOIDAndVersion> getDetachedObjects() + { + loadCommitDataIfNeeded(); + return commitData.getDetachedObjects(); + } + + public Map<CDOID, CDOChangeKind> getChangeKinds() + { + loadCommitDataIfNeeded(); + return commitData.getChangeKinds(); + } + + public CDOChangeKind getChangeKind(CDOID id) + { + loadCommitDataIfNeeded(); + return commitData.getChangeKind(id); + } + + @Override + public String toString() + { + String data = null; + if (commitData != null) + { + data = commitData.toString(); + } + + String timeStamp = CDOCommonUtil.formatTimeStamp(getTimeStamp()); + return MessageFormat + .format( + "CommitInfo[{0}, {1}, {2}, {3}, {4}, {5}]", getPreviousTimeStamp(), getBranch(), timeStamp, getUserID(), getComment(), data); //$NON-NLS-1$ + } + + private void loadCommitDataIfNeeded() + { + if (commitData == null) + { + commitData = commitInfoManager.getCommitInfoLoader().loadCommitData(getTimeStamp()); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoManagerImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoManagerImpl.java index 271f294d24..e5e3c10610 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoManagerImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/CDOCommitInfoManagerImpl.java @@ -1,87 +1,87 @@ -/*
- * 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
- * Andre Dietisheim - bug 256649
- */
-package org.eclipse.emf.cdo.internal.common.commit;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.commit.CDOCommitData;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
-import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
-
-import org.eclipse.net4j.util.lifecycle.Lifecycle;
-
-/**
- * @author Andre Dietisheim
- */
-public class CDOCommitInfoManagerImpl extends Lifecycle implements InternalCDOCommitInfoManager
-{
- private CommitInfoLoader commitInfoLoader;
-
- public CDOCommitInfoManagerImpl()
- {
- }
-
- public CommitInfoLoader getCommitInfoLoader()
- {
- return commitInfoLoader;
- }
-
- public void setCommitInfoLoader(CommitInfoLoader commitInfoLoader)
- {
- checkInactive();
- this.commitInfoLoader = commitInfoLoader;
- }
-
- public CDOCommitInfo createCommitInfo(CDOBranch branch, long timeStamp, long previousTimeStamp, String userID,
- String comment, CDOCommitData commitData)
- {
- checkActive();
- return new CDOCommitInfoImpl(this, branch, timeStamp, previousTimeStamp, userID, comment, commitData);
- }
-
- public CDOCommitInfo getCommitInfo(long timeStamp)
- {
- checkActive();
- final CDOCommitInfo[] result = { null };
- getCommitInfos(null, timeStamp, timeStamp, new CDOCommitInfoHandler()
- {
- public void handleCommitInfo(CDOCommitInfo commitInfo)
- {
- result[0] = commitInfo;
- }
- });
-
- return result[0];
- }
-
- public void getCommitInfos(CDOBranch branch, long startTime, long endTime, CDOCommitInfoHandler handler)
- {
- checkActive();
- commitInfoLoader.loadCommitInfos(branch, startTime, endTime, handler);
- }
-
- public void getCommitInfos(CDOBranch branch, long startTime, String userID, String comment, int count,
- CDOCommitInfoHandler handler)
- {
- checkActive();
-
- // TODO: implement CDOCommitInfoManagerImpl.getCommitInfos(branch, startTime, userID, comment, count, handler)
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected void doBeforeActivate() throws Exception
- {
- super.doBeforeActivate();
- checkState(commitInfoLoader, "commitInfoLoader"); //$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 + * Andre Dietisheim - bug 256649 + */ +package org.eclipse.emf.cdo.internal.common.commit; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.commit.CDOCommitData; +import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; +import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler; +import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager; + +import org.eclipse.net4j.util.lifecycle.Lifecycle; + +/** + * @author Andre Dietisheim + */ +public class CDOCommitInfoManagerImpl extends Lifecycle implements InternalCDOCommitInfoManager +{ + private CommitInfoLoader commitInfoLoader; + + public CDOCommitInfoManagerImpl() + { + } + + public CommitInfoLoader getCommitInfoLoader() + { + return commitInfoLoader; + } + + public void setCommitInfoLoader(CommitInfoLoader commitInfoLoader) + { + checkInactive(); + this.commitInfoLoader = commitInfoLoader; + } + + public CDOCommitInfo createCommitInfo(CDOBranch branch, long timeStamp, long previousTimeStamp, String userID, + String comment, CDOCommitData commitData) + { + checkActive(); + return new CDOCommitInfoImpl(this, branch, timeStamp, previousTimeStamp, userID, comment, commitData); + } + + public CDOCommitInfo getCommitInfo(long timeStamp) + { + checkActive(); + final CDOCommitInfo[] result = { null }; + getCommitInfos(null, timeStamp, timeStamp, new CDOCommitInfoHandler() + { + public void handleCommitInfo(CDOCommitInfo commitInfo) + { + result[0] = commitInfo; + } + }); + + return result[0]; + } + + public void getCommitInfos(CDOBranch branch, long startTime, long endTime, CDOCommitInfoHandler handler) + { + checkActive(); + commitInfoLoader.loadCommitInfos(branch, startTime, endTime, handler); + } + + public void getCommitInfos(CDOBranch branch, long startTime, String userID, String comment, int count, + CDOCommitInfoHandler handler) + { + checkActive(); + + // TODO: implement CDOCommitInfoManagerImpl.getCommitInfos(branch, startTime, userID, comment, count, handler) + throw new UnsupportedOperationException(); + } + + @Override + protected void doBeforeActivate() throws Exception + { + super.doBeforeActivate(); + checkState(commitInfoLoader, "commitInfoLoader"); //$NON-NLS-1$ + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/DelegatingCommitInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/DelegatingCommitInfo.java index 6f464afefe..d0e0e604b9 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/DelegatingCommitInfo.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/DelegatingCommitInfo.java @@ -1,111 +1,111 @@ -/*
- * 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.internal.common.commit;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.commit.CDOChangeKind;
-import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public abstract class DelegatingCommitInfo implements CDOCommitInfo
-{
- public DelegatingCommitInfo()
- {
- }
-
- protected abstract CDOCommitInfo getDelegate();
-
- public CDOBranch getBranch()
- {
- return getDelegate().getBranch();
- }
-
- public CDOCommitInfoManager getCommitInfoManager()
- {
- return getDelegate().getCommitInfoManager();
- }
-
- public long getPreviousTimeStamp()
- {
- return getDelegate().getPreviousTimeStamp();
- }
-
- public long getTimeStamp()
- {
- return getDelegate().getTimeStamp();
- }
-
- public String getUserID()
- {
- return getDelegate().getUserID();
- }
-
- public String getComment()
- {
- return getDelegate().getComment();
- }
-
- public boolean isEmpty()
- {
- return getDelegate().isEmpty();
- }
-
- public List<CDOPackageUnit> getNewPackageUnits()
- {
- return getDelegate().getNewPackageUnits();
- }
-
- public List<CDOIDAndVersion> getNewObjects()
- {
- return getDelegate().getNewObjects();
- }
-
- public List<CDORevisionKey> getChangedObjects()
- {
- return getDelegate().getChangedObjects();
- }
-
- public List<CDOIDAndVersion> getDetachedObjects()
- {
- return getDelegate().getDetachedObjects();
- }
-
- public Map<CDOID, CDOChangeKind> getChangeKinds()
- {
- return getDelegate().getChangeKinds();
- }
-
- public CDOChangeKind getChangeKind(CDOID id)
- {
- return getDelegate().getChangeKind(id);
- }
-
- public CDOChangeSetData copy()
- {
- return getDelegate().copy();
- }
-
- public void merge(CDOChangeSetData changeSetData)
- {
- getDelegate().merge(changeSetData);
- }
-}
+/* + * 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.internal.common.commit; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.commit.CDOChangeKind; +import org.eclipse.emf.cdo.common.commit.CDOChangeSetData; +import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; +import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.model.CDOPackageUnit; +import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion; +import org.eclipse.emf.cdo.common.revision.CDORevisionKey; + +import java.util.List; +import java.util.Map; + +/** + * @author Eike Stepper + */ +public abstract class DelegatingCommitInfo implements CDOCommitInfo +{ + public DelegatingCommitInfo() + { + } + + protected abstract CDOCommitInfo getDelegate(); + + public CDOBranch getBranch() + { + return getDelegate().getBranch(); + } + + public CDOCommitInfoManager getCommitInfoManager() + { + return getDelegate().getCommitInfoManager(); + } + + public long getPreviousTimeStamp() + { + return getDelegate().getPreviousTimeStamp(); + } + + public long getTimeStamp() + { + return getDelegate().getTimeStamp(); + } + + public String getUserID() + { + return getDelegate().getUserID(); + } + + public String getComment() + { + return getDelegate().getComment(); + } + + public boolean isEmpty() + { + return getDelegate().isEmpty(); + } + + public List<CDOPackageUnit> getNewPackageUnits() + { + return getDelegate().getNewPackageUnits(); + } + + public List<CDOIDAndVersion> getNewObjects() + { + return getDelegate().getNewObjects(); + } + + public List<CDORevisionKey> getChangedObjects() + { + return getDelegate().getChangedObjects(); + } + + public List<CDOIDAndVersion> getDetachedObjects() + { + return getDelegate().getDetachedObjects(); + } + + public Map<CDOID, CDOChangeKind> getChangeKinds() + { + return getDelegate().getChangeKinds(); + } + + public CDOChangeKind getChangeKind(CDOID id) + { + return getDelegate().getChangeKind(id); + } + + public CDOChangeSetData copy() + { + return getDelegate().copy(); + } + + public void merge(CDOChangeSetData changeSetData) + { + getDelegate().merge(changeSetData); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/FailureCommitInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/FailureCommitInfo.java index 11bc8b007a..1517828476 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/FailureCommitInfo.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/commit/FailureCommitInfo.java @@ -1,116 +1,116 @@ -/*
- * 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.internal.common.commit;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.commit.CDOChangeKind;
-import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class FailureCommitInfo implements CDOCommitInfo
-{
- private long timeStamp;
-
- private long previousTimeStamp;
-
- public FailureCommitInfo(long timeStamp, long previousTimeStamp)
- {
- this.timeStamp = timeStamp;
- this.previousTimeStamp = previousTimeStamp;
- }
-
- public long getTimeStamp()
- {
- return timeStamp;
- }
-
- public long getPreviousTimeStamp()
- {
- return previousTimeStamp;
- }
-
- public CDOBranch getBranch()
- {
- return null;
- }
-
- public String getUserID()
- {
- return null;
- }
-
- public String getComment()
- {
- return null;
- }
-
- public CDOCommitInfoManager getCommitInfoManager()
- {
- return null;
- }
-
- public boolean isEmpty()
- {
- return true;
- }
-
- public List<CDOPackageUnit> getNewPackageUnits()
- {
- return Collections.emptyList();
- }
-
- public List<CDOIDAndVersion> getNewObjects()
- {
- return Collections.emptyList();
- }
-
- public List<CDORevisionKey> getChangedObjects()
- {
- return Collections.emptyList();
- }
-
- public List<CDOIDAndVersion> getDetachedObjects()
- {
- return Collections.emptyList();
- }
-
- public Map<CDOID, CDOChangeKind> getChangeKinds()
- {
- return Collections.emptyMap();
- }
-
- public CDOChangeKind getChangeKind(CDOID id)
- {
- return null;
- }
-
- public CDOChangeSetData copy()
- {
- return this;
- }
-
- public void merge(CDOChangeSetData changeSetData)
- {
- throw new UnsupportedOperationException();
- }
-}
+/* + * 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.internal.common.commit; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.commit.CDOChangeKind; +import org.eclipse.emf.cdo.common.commit.CDOChangeSetData; +import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; +import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.model.CDOPackageUnit; +import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion; +import org.eclipse.emf.cdo.common.revision.CDORevisionKey; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + * @author Eike Stepper + */ +public class FailureCommitInfo implements CDOCommitInfo +{ + private long timeStamp; + + private long previousTimeStamp; + + public FailureCommitInfo(long timeStamp, long previousTimeStamp) + { + this.timeStamp = timeStamp; + this.previousTimeStamp = previousTimeStamp; + } + + public long getTimeStamp() + { + return timeStamp; + } + + public long getPreviousTimeStamp() + { + return previousTimeStamp; + } + + public CDOBranch getBranch() + { + return null; + } + + public String getUserID() + { + return null; + } + + public String getComment() + { + return null; + } + + public CDOCommitInfoManager getCommitInfoManager() + { + return null; + } + + public boolean isEmpty() + { + return true; + } + + public List<CDOPackageUnit> getNewPackageUnits() + { + return Collections.emptyList(); + } + + public List<CDOIDAndVersion> getNewObjects() + { + return Collections.emptyList(); + } + + public List<CDORevisionKey> getChangedObjects() + { + return Collections.emptyList(); + } + + public List<CDOIDAndVersion> getDetachedObjects() + { + return Collections.emptyList(); + } + + public Map<CDOID, CDOChangeKind> getChangeKinds() + { + return Collections.emptyMap(); + } + + public CDOChangeKind getChangeKind(CDOID id) + { + return null; + } + + public CDOChangeSetData copy() + { + return this; + } + + public void merge(CDOChangeSetData changeSetData) + { + throw new UnsupportedOperationException(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDExternalImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDExternalImpl.java index 887ac19adf..f3491c1e5c 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDExternalImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDExternalImpl.java @@ -1,131 +1,131 @@ -/*
- * 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.internal.common.id;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDExternal;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOID;
-
-import org.eclipse.net4j.util.ObjectUtil;
-import org.eclipse.net4j.util.io.ExtendedDataInput;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
-
-import java.io.IOException;
-
-/**
- * @author Simon McDuff
- */
-public class CDOIDExternalImpl extends AbstractCDOID implements CDOIDExternal
-{
- private static final long serialVersionUID = 1L;
-
- private String uri;
-
- public CDOIDExternalImpl(String uri)
- {
- this.uri = uri;
- }
-
- public Type getType()
- {
- return Type.EXTERNAL_OBJECT;
- }
-
- public boolean isDangling()
- {
- return false;
- }
-
- public boolean isExternal()
- {
- return true;
- }
-
- public boolean isNull()
- {
- return false;
- }
-
- public boolean isObject()
- {
- return true;
- }
-
- public boolean isTemporary()
- {
- return false;
- }
-
- public String getURI()
- {
- return uri;
- }
-
- @Override
- public String toString()
- {
- return "oid:" + toURIFragment(); //$NON-NLS-1$
- }
-
- @Override
- public void read(String fragmentPart)
- {
- uri = fragmentPart;
- }
-
- @Override
- public void read(ExtendedDataInput in) throws IOException
- {
- uri = in.readString();
- }
-
- @Override
- public void write(ExtendedDataOutput out) throws IOException
- {
- out.writeString(uri);
- }
-
- public String toURIFragment()
- {
- return uri;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- // Could CDOIDTempObjectExternalImpl and CDOIDExternalImpl have the same uri. We don't want to mixed them.
- if (obj != null && obj.getClass() == getClass())
- {
- CDOIDExternal that = (CDOIDExternal)obj;
- return ObjectUtil.equals(getURI(), that.getURI());
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- return getClass().hashCode() ^ uri.hashCode();
- }
-
- @Override
- protected int doCompareTo(CDOID o) throws ClassCastException
- {
- return getURI().compareTo(((CDOIDExternalImpl)o).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.internal.common.id; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.id.CDOIDExternal; +import org.eclipse.emf.cdo.spi.common.id.AbstractCDOID; + +import org.eclipse.net4j.util.ObjectUtil; +import org.eclipse.net4j.util.io.ExtendedDataInput; +import org.eclipse.net4j.util.io.ExtendedDataOutput; + +import java.io.IOException; + +/** + * @author Simon McDuff + */ +public class CDOIDExternalImpl extends AbstractCDOID implements CDOIDExternal +{ + private static final long serialVersionUID = 1L; + + private String uri; + + public CDOIDExternalImpl(String uri) + { + this.uri = uri; + } + + public Type getType() + { + return Type.EXTERNAL_OBJECT; + } + + public boolean isDangling() + { + return false; + } + + public boolean isExternal() + { + return true; + } + + public boolean isNull() + { + return false; + } + + public boolean isObject() + { + return true; + } + + public boolean isTemporary() + { + return false; + } + + public String getURI() + { + return uri; + } + + @Override + public String toString() + { + return "oid:" + toURIFragment(); //$NON-NLS-1$ + } + + @Override + public void read(String fragmentPart) + { + uri = fragmentPart; + } + + @Override + public void read(ExtendedDataInput in) throws IOException + { + uri = in.readString(); + } + + @Override + public void write(ExtendedDataOutput out) throws IOException + { + out.writeString(uri); + } + + public String toURIFragment() + { + return uri; + } + + @Override + public boolean equals(Object obj) + { + if (obj == this) + { + return true; + } + + // Could CDOIDTempObjectExternalImpl and CDOIDExternalImpl have the same uri. We don't want to mixed them. + if (obj != null && obj.getClass() == getClass()) + { + CDOIDExternal that = (CDOIDExternal)obj; + return ObjectUtil.equals(getURI(), that.getURI()); + } + + return false; + } + + @Override + public int hashCode() + { + return getClass().hashCode() ^ uri.hashCode(); + } + + @Override + protected int doCompareTo(CDOID o) throws ClassCastException + { + return getURI().compareTo(((CDOIDExternalImpl)o).getURI()); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDNullImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDNullImpl.java index 4162b4d7b9..836db08673 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDNullImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDNullImpl.java @@ -1,125 +1,125 @@ -/*
- * 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
- *
- */
-package org.eclipse.emf.cdo.internal.common.id;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDObject;
-import org.eclipse.emf.cdo.common.id.CDOIDTemp;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOID;
-
-import org.eclipse.net4j.util.io.ExtendedDataInput;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- */
-public final class CDOIDNullImpl extends AbstractCDOID implements CDOIDTemp, CDOIDObject
-{
- public static final CDOIDNullImpl INSTANCE = new CDOIDNullImpl();
-
- private static final long serialVersionUID = 1L;
-
- private CDOIDNullImpl()
- {
- }
-
- public Type getType()
- {
- return Type.NULL;
- }
-
- public boolean isDangling()
- {
- return false;
- }
-
- public boolean isExternal()
- {
- return false;
- }
-
- public boolean isNull()
- {
- return true;
- }
-
- public boolean isObject()
- {
- return false;
- }
-
- public boolean isTemporary()
- {
- return false;
- }
-
- public int getIntValue()
- {
- return 0;
- }
-
- public long getLongValue()
- {
- return 0L;
- }
-
- public String toURIFragment()
- {
- return "NULL"; //$NON-NLS-1$
- }
-
- @Override
- public void read(String fragmentPart)
- {
- // Do nothing
- }
-
- @Override
- public void read(ExtendedDataInput in) throws IOException
- {
- // Do nothing
- }
-
- @Override
- public void write(ExtendedDataOutput out) throws IOException
- {
- // Do nothing
- }
-
- @Override
- public boolean equals(Object obj)
- {
- return obj == INSTANCE;
- }
-
- @Override
- public int hashCode()
- {
- return 0;
- }
-
- @Override
- public String toString()
- {
- return "NULL"; //$NON-NLS-1$
- }
-
- @Override
- protected int doCompareTo(CDOID o) throws ClassCastException
- {
- ((CDOIDNullImpl)o).getIntValue(); // Possibly throw ClassCastException
- return 0; // NULL == 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 + * Simon McDuff - bug 226778 + * + */ +package org.eclipse.emf.cdo.internal.common.id; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.id.CDOIDObject; +import org.eclipse.emf.cdo.common.id.CDOIDTemp; +import org.eclipse.emf.cdo.spi.common.id.AbstractCDOID; + +import org.eclipse.net4j.util.io.ExtendedDataInput; +import org.eclipse.net4j.util.io.ExtendedDataOutput; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public final class CDOIDNullImpl extends AbstractCDOID implements CDOIDTemp, CDOIDObject +{ + public static final CDOIDNullImpl INSTANCE = new CDOIDNullImpl(); + + private static final long serialVersionUID = 1L; + + private CDOIDNullImpl() + { + } + + public Type getType() + { + return Type.NULL; + } + + public boolean isDangling() + { + return false; + } + + public boolean isExternal() + { + return false; + } + + public boolean isNull() + { + return true; + } + + public boolean isObject() + { + return false; + } + + public boolean isTemporary() + { + return false; + } + + public int getIntValue() + { + return 0; + } + + public long getLongValue() + { + return 0L; + } + + public String toURIFragment() + { + return "NULL"; //$NON-NLS-1$ + } + + @Override + public void read(String fragmentPart) + { + // Do nothing + } + + @Override + public void read(ExtendedDataInput in) throws IOException + { + // Do nothing + } + + @Override + public void write(ExtendedDataOutput out) throws IOException + { + // Do nothing + } + + @Override + public boolean equals(Object obj) + { + return obj == INSTANCE; + } + + @Override + public int hashCode() + { + return 0; + } + + @Override + public String toString() + { + return "NULL"; //$NON-NLS-1$ + } + + @Override + protected int doCompareTo(CDOID o) throws ClassCastException + { + ((CDOIDNullImpl)o).getIntValue(); // Possibly throw ClassCastException + return 0; // NULL == NULL + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectLongImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectLongImpl.java index 9e95fc337c..a4d17b3855 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectLongImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectLongImpl.java @@ -1,83 +1,83 @@ -/*
- * 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.internal.common.id;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong;
-import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject;
-
-/**
- * @author Eike Stepper
- * @since 2.0
- */
-public class CDOIDObjectLongImpl extends AbstractCDOIDLong implements InternalCDOIDObject
-{
- private static final long serialVersionUID = 1L;
-
- public CDOIDObjectLongImpl()
- {
- }
-
- public CDOIDObjectLongImpl(long value)
- {
- super(value);
- }
-
- public Type getType()
- {
- return Type.OBJECT;
- }
-
- public boolean isDangling()
- {
- return false;
- }
-
- public boolean isExternal()
- {
- return false;
- }
-
- public boolean isNull()
- {
- return false;
- }
-
- public boolean isObject()
- {
- return true;
- }
-
- public boolean isTemporary()
- {
- return false;
- }
-
- /**
- * @since 3.0
- */
- public CDOID.ObjectType getSubType()
- {
- return CDOID.ObjectType.LONG;
- }
-
- @Override
- public String toString()
- {
- return "OID" + getLongValue(); //$NON-NLS-1$
- }
-
- @Override
- protected int doCompareTo(CDOID o) throws ClassCastException
- {
- return new Long(getLongValue()).compareTo(((CDOIDObjectLongImpl)o).getLongValue());
- }
-}
+/* + * 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.internal.common.id; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDLong; +import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject; + +/** + * @author Eike Stepper + * @since 2.0 + */ +public class CDOIDObjectLongImpl extends AbstractCDOIDLong implements InternalCDOIDObject +{ + private static final long serialVersionUID = 1L; + + public CDOIDObjectLongImpl() + { + } + + public CDOIDObjectLongImpl(long value) + { + super(value); + } + + public Type getType() + { + return Type.OBJECT; + } + + public boolean isDangling() + { + return false; + } + + public boolean isExternal() + { + return false; + } + + public boolean isNull() + { + return false; + } + + public boolean isObject() + { + return true; + } + + public boolean isTemporary() + { + return false; + } + + /** + * @since 3.0 + */ + public CDOID.ObjectType getSubType() + { + return CDOID.ObjectType.LONG; + } + + @Override + public String toString() + { + return "OID" + getLongValue(); //$NON-NLS-1$ + } + + @Override + protected int doCompareTo(CDOID o) throws ClassCastException + { + return new Long(getLongValue()).compareTo(((CDOIDObjectLongImpl)o).getLongValue()); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectLongWithClassifierImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectLongWithClassifierImpl.java index 6e3a5c7ae1..eb781efea5 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectLongWithClassifierImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectLongWithClassifierImpl.java @@ -1,145 +1,145 @@ -/*
- * 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:
- * Martin Taal - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.id;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-
-import org.eclipse.net4j.util.ObjectUtil;
-import org.eclipse.net4j.util.io.ExtendedDataInput;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
-
-import java.io.IOException;
-
-/**
- * @author Martin Taal
- * @since 3.0
- */
-public class CDOIDObjectLongWithClassifierImpl extends CDOIDObjectLongImpl implements CDOClassifierRef.Provider
-{
- private static final long serialVersionUID = 1L;
-
- private CDOClassifierRef classifierRef;
-
- public CDOIDObjectLongWithClassifierImpl()
- {
- }
-
- public CDOIDObjectLongWithClassifierImpl(CDOClassifierRef classifierRef, long value)
- {
- super(value);
- this.classifierRef = classifierRef;
- }
-
- public CDOClassifierRef getClassifierRef()
- {
- return classifierRef;
- }
-
- @Override
- public Type getType()
- {
- return Type.OBJECT;
- }
-
- @Override
- public CDOID.ObjectType getSubType()
- {
- return CDOID.ObjectType.LONG_WITH_CLASSIFIER;
- }
-
- @Override
- public String toURIFragment()
- {
- return getClassifierRef().getPackageURI() + CDOClassifierRef.URI_SEPARATOR + getClassifierRef().getClassifierName()
- + CDOClassifierRef.URI_SEPARATOR + super.toURIFragment();
- }
-
- @Override
- public void read(String fragmentPart)
- {
- // get the CDOClassifierRef part
- int index1 = fragmentPart.indexOf(CDOClassifierRef.URI_SEPARATOR);
- int index2 = fragmentPart.indexOf(CDOClassifierRef.URI_SEPARATOR, index1 + 1);
- if (index1 == -1 || index2 == -1)
- {
- throw new IllegalArgumentException("The fragment " + fragmentPart + " is not a valid fragment");
- }
-
- classifierRef = new CDOClassifierRef(fragmentPart.substring(0, index1), fragmentPart.substring(index1 + 1, index2));
-
- // let the super take care of the rest
- super.read(fragmentPart.substring(index2 + 1));
- }
-
- @Override
- public void read(ExtendedDataInput in) throws IOException
- {
- // TODO: change the parameter to prevent casting to CDODataInput
- CDODataInput cdoDataInput = (CDODataInput)in;
- classifierRef = cdoDataInput.readCDOClassifierRef();
-
- // and let the super take care of the rest
- super.read(in);
- }
-
- @Override
- public void write(ExtendedDataOutput out) throws IOException
- {
- // TODO: change the parameter to prevent casting to CDODataInput
- CDODataOutput cdoDataOutput = (CDODataOutput)out;
- cdoDataOutput.writeCDOClassifierRef(classifierRef);
-
- // and let the super write the rest
- super.write(out);
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj != null && obj.getClass() == getClass())
- {
- CDOIDObjectLongWithClassifierImpl that = (CDOIDObjectLongWithClassifierImpl)obj;
- return ObjectUtil.equals(classifierRef, that.classifierRef) && getLongValue() == that.getLongValue();
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- int hashCode = classifierRef.hashCode() ^ ObjectUtil.hashCode(getLongValue());
- return getClass().hashCode() ^ hashCode;
- }
-
- @Override
- public String toString()
- {
- return "OID:" + toURIFragment(); //$NON-NLS-1$
- }
-
- @Override
- protected int doCompareTo(CDOID o) throws ClassCastException
- {
- // conversion to uri fragment is pretty heavy but afaics the compareTo
- // is not used in a critical place.
- return toURIFragment().compareTo(o.toURIFragment());
- }
-}
+/* + * 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: + * Martin Taal - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.internal.common.id; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.model.CDOClassifierRef; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; + +import org.eclipse.net4j.util.ObjectUtil; +import org.eclipse.net4j.util.io.ExtendedDataInput; +import org.eclipse.net4j.util.io.ExtendedDataOutput; + +import java.io.IOException; + +/** + * @author Martin Taal + * @since 3.0 + */ +public class CDOIDObjectLongWithClassifierImpl extends CDOIDObjectLongImpl implements CDOClassifierRef.Provider +{ + private static final long serialVersionUID = 1L; + + private CDOClassifierRef classifierRef; + + public CDOIDObjectLongWithClassifierImpl() + { + } + + public CDOIDObjectLongWithClassifierImpl(CDOClassifierRef classifierRef, long value) + { + super(value); + this.classifierRef = classifierRef; + } + + public CDOClassifierRef getClassifierRef() + { + return classifierRef; + } + + @Override + public Type getType() + { + return Type.OBJECT; + } + + @Override + public CDOID.ObjectType getSubType() + { + return CDOID.ObjectType.LONG_WITH_CLASSIFIER; + } + + @Override + public String toURIFragment() + { + return getClassifierRef().getPackageURI() + CDOClassifierRef.URI_SEPARATOR + getClassifierRef().getClassifierName() + + CDOClassifierRef.URI_SEPARATOR + super.toURIFragment(); + } + + @Override + public void read(String fragmentPart) + { + // get the CDOClassifierRef part + int index1 = fragmentPart.indexOf(CDOClassifierRef.URI_SEPARATOR); + int index2 = fragmentPart.indexOf(CDOClassifierRef.URI_SEPARATOR, index1 + 1); + if (index1 == -1 || index2 == -1) + { + throw new IllegalArgumentException("The fragment " + fragmentPart + " is not a valid fragment"); + } + + classifierRef = new CDOClassifierRef(fragmentPart.substring(0, index1), fragmentPart.substring(index1 + 1, index2)); + + // let the super take care of the rest + super.read(fragmentPart.substring(index2 + 1)); + } + + @Override + public void read(ExtendedDataInput in) throws IOException + { + // TODO: change the parameter to prevent casting to CDODataInput + CDODataInput cdoDataInput = (CDODataInput)in; + classifierRef = cdoDataInput.readCDOClassifierRef(); + + // and let the super take care of the rest + super.read(in); + } + + @Override + public void write(ExtendedDataOutput out) throws IOException + { + // TODO: change the parameter to prevent casting to CDODataInput + CDODataOutput cdoDataOutput = (CDODataOutput)out; + cdoDataOutput.writeCDOClassifierRef(classifierRef); + + // and let the super write the rest + super.write(out); + } + + @Override + public boolean equals(Object obj) + { + if (obj == this) + { + return true; + } + + if (obj != null && obj.getClass() == getClass()) + { + CDOIDObjectLongWithClassifierImpl that = (CDOIDObjectLongWithClassifierImpl)obj; + return ObjectUtil.equals(classifierRef, that.classifierRef) && getLongValue() == that.getLongValue(); + } + + return false; + } + + @Override + public int hashCode() + { + int hashCode = classifierRef.hashCode() ^ ObjectUtil.hashCode(getLongValue()); + return getClass().hashCode() ^ hashCode; + } + + @Override + public String toString() + { + return "OID:" + toURIFragment(); //$NON-NLS-1$ + } + + @Override + protected int doCompareTo(CDOID o) throws ClassCastException + { + // conversion to uri fragment is pretty heavy but afaics the compareTo + // is not used in a critical place. + return toURIFragment().compareTo(o.toURIFragment()); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectStringImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectStringImpl.java index 42ceebddd6..376a113b81 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectStringImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectStringImpl.java @@ -1,81 +1,81 @@ -/*
- * 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:
- * Martin Taal - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.id;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDString;
-import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject;
-
-/**
- * @author Martin Taal
- * @since 3.0
- */
-public class CDOIDObjectStringImpl extends AbstractCDOIDString implements InternalCDOIDObject
-{
- private static final long serialVersionUID = 1L;
-
- public CDOIDObjectStringImpl()
- {
- }
-
- public CDOIDObjectStringImpl(String value)
- {
- super(value);
- }
-
- public Type getType()
- {
- return Type.OBJECT;
- }
-
- public boolean isDangling()
- {
- return false;
- }
-
- public boolean isExternal()
- {
- return false;
- }
-
- public boolean isNull()
- {
- return false;
- }
-
- public boolean isObject()
- {
- return true;
- }
-
- public boolean isTemporary()
- {
- return false;
- }
-
- public CDOID.ObjectType getSubType()
- {
- return CDOID.ObjectType.STRING;
- }
-
- @Override
- public String toString()
- {
- return "OID" + getStringValue(); //$NON-NLS-1$
- }
-
- @Override
- protected int doCompareTo(CDOID o) throws ClassCastException
- {
- return getStringValue().compareTo(((CDOIDObjectStringImpl)o).getStringValue());
- }
-}
+/* + * 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: + * Martin Taal - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.internal.common.id; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDString; +import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject; + +/** + * @author Martin Taal + * @since 3.0 + */ +public class CDOIDObjectStringImpl extends AbstractCDOIDString implements InternalCDOIDObject +{ + private static final long serialVersionUID = 1L; + + public CDOIDObjectStringImpl() + { + } + + public CDOIDObjectStringImpl(String value) + { + super(value); + } + + public Type getType() + { + return Type.OBJECT; + } + + public boolean isDangling() + { + return false; + } + + public boolean isExternal() + { + return false; + } + + public boolean isNull() + { + return false; + } + + public boolean isObject() + { + return true; + } + + public boolean isTemporary() + { + return false; + } + + public CDOID.ObjectType getSubType() + { + return CDOID.ObjectType.STRING; + } + + @Override + public String toString() + { + return "OID" + getStringValue(); //$NON-NLS-1$ + } + + @Override + protected int doCompareTo(CDOID o) throws ClassCastException + { + return getStringValue().compareTo(((CDOIDObjectStringImpl)o).getStringValue()); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectStringWithClassifierImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectStringWithClassifierImpl.java index 4d24ee6380..6b6ed62ff2 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectStringWithClassifierImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectStringWithClassifierImpl.java @@ -1,138 +1,138 @@ -/*
- * 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:
- * Martin Taal - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.id;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-
-import org.eclipse.net4j.util.ObjectUtil;
-import org.eclipse.net4j.util.io.ExtendedDataInput;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
-
-import java.io.IOException;
-
-/**
- * @author Martin Taal
- * @since 3.0
- */
-public class CDOIDObjectStringWithClassifierImpl extends CDOIDObjectStringImpl implements CDOClassifierRef.Provider
-{
- private static final long serialVersionUID = 1L;
-
- private CDOClassifierRef classifierRef;
-
- public CDOIDObjectStringWithClassifierImpl()
- {
- }
-
- public CDOIDObjectStringWithClassifierImpl(CDOClassifierRef classifierRef, String value)
- {
- super(value);
- this.classifierRef = classifierRef;
- }
-
- public CDOClassifierRef getClassifierRef()
- {
- return classifierRef;
- }
-
- @Override
- public CDOID.ObjectType getSubType()
- {
- return CDOID.ObjectType.STRING_WITH_CLASSIFIER;
- }
-
- @Override
- public String toURIFragment()
- {
- return getClassifierRef().getPackageURI() + CDOClassifierRef.URI_SEPARATOR + getClassifierRef().getClassifierName()
- + CDOClassifierRef.URI_SEPARATOR + super.toURIFragment();
- }
-
- @Override
- public void read(String fragmentPart)
- {
- // get the EClass part
- int index1 = fragmentPart.indexOf(CDOClassifierRef.URI_SEPARATOR);
- int index2 = fragmentPart.indexOf(CDOClassifierRef.URI_SEPARATOR, index1 + 1);
- if (index1 == -1 || index2 == -1)
- {
- throw new IllegalArgumentException("The fragment " + fragmentPart + " is invalid");
- }
-
- classifierRef = new CDOClassifierRef(fragmentPart.substring(0, index1), fragmentPart.substring(index1 + 1, index2));
-
- // let the super take care of the rest
- super.read(fragmentPart.substring(index2 + 1));
- }
-
- @Override
- public void read(ExtendedDataInput in) throws IOException
- {
- CDODataInput cdoDataInput = (CDODataInput)in;
- classifierRef = cdoDataInput.readCDOClassifierRef();
-
- // and let the super take care of the rest
- super.read(in);
- }
-
- @Override
- public void write(ExtendedDataOutput out) throws IOException
- {
- // TODO: change the parameter to prevent casting to CDODataInput
- CDODataOutput cdoDataOutput = (CDODataOutput)out;
- cdoDataOutput.writeCDOClassifierRef(classifierRef);
-
- // and let the super write the rest
- super.write(out);
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj != null && obj.getClass() == getClass())
- {
- CDOIDObjectStringWithClassifierImpl that = (CDOIDObjectStringWithClassifierImpl)obj;
- return ObjectUtil.equals(classifierRef, that.classifierRef) && getStringValue().equals(that.getStringValue());
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- int hashCode = classifierRef.hashCode() ^ ObjectUtil.hashCode(getStringValue());
- return getClass().hashCode() ^ hashCode;
- }
-
- @Override
- public String toString()
- {
- return "OID:" + toURIFragment(); //$NON-NLS-1$
- }
-
- @Override
- protected int doCompareTo(CDOID o) throws ClassCastException
- {
- // conversion to uri fragment is pretty heavy but afaics the compareTo
- // is not used in a critical place.
- return toURIFragment().compareTo(o.toURIFragment());
- }
-}
+/* + * 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: + * Martin Taal - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.internal.common.id; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.model.CDOClassifierRef; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; + +import org.eclipse.net4j.util.ObjectUtil; +import org.eclipse.net4j.util.io.ExtendedDataInput; +import org.eclipse.net4j.util.io.ExtendedDataOutput; + +import java.io.IOException; + +/** + * @author Martin Taal + * @since 3.0 + */ +public class CDOIDObjectStringWithClassifierImpl extends CDOIDObjectStringImpl implements CDOClassifierRef.Provider +{ + private static final long serialVersionUID = 1L; + + private CDOClassifierRef classifierRef; + + public CDOIDObjectStringWithClassifierImpl() + { + } + + public CDOIDObjectStringWithClassifierImpl(CDOClassifierRef classifierRef, String value) + { + super(value); + this.classifierRef = classifierRef; + } + + public CDOClassifierRef getClassifierRef() + { + return classifierRef; + } + + @Override + public CDOID.ObjectType getSubType() + { + return CDOID.ObjectType.STRING_WITH_CLASSIFIER; + } + + @Override + public String toURIFragment() + { + return getClassifierRef().getPackageURI() + CDOClassifierRef.URI_SEPARATOR + getClassifierRef().getClassifierName() + + CDOClassifierRef.URI_SEPARATOR + super.toURIFragment(); + } + + @Override + public void read(String fragmentPart) + { + // get the EClass part + int index1 = fragmentPart.indexOf(CDOClassifierRef.URI_SEPARATOR); + int index2 = fragmentPart.indexOf(CDOClassifierRef.URI_SEPARATOR, index1 + 1); + if (index1 == -1 || index2 == -1) + { + throw new IllegalArgumentException("The fragment " + fragmentPart + " is invalid"); + } + + classifierRef = new CDOClassifierRef(fragmentPart.substring(0, index1), fragmentPart.substring(index1 + 1, index2)); + + // let the super take care of the rest + super.read(fragmentPart.substring(index2 + 1)); + } + + @Override + public void read(ExtendedDataInput in) throws IOException + { + CDODataInput cdoDataInput = (CDODataInput)in; + classifierRef = cdoDataInput.readCDOClassifierRef(); + + // and let the super take care of the rest + super.read(in); + } + + @Override + public void write(ExtendedDataOutput out) throws IOException + { + // TODO: change the parameter to prevent casting to CDODataInput + CDODataOutput cdoDataOutput = (CDODataOutput)out; + cdoDataOutput.writeCDOClassifierRef(classifierRef); + + // and let the super write the rest + super.write(out); + } + + @Override + public boolean equals(Object obj) + { + if (obj == this) + { + return true; + } + + if (obj != null && obj.getClass() == getClass()) + { + CDOIDObjectStringWithClassifierImpl that = (CDOIDObjectStringWithClassifierImpl)obj; + return ObjectUtil.equals(classifierRef, that.classifierRef) && getStringValue().equals(that.getStringValue()); + } + + return false; + } + + @Override + public int hashCode() + { + int hashCode = classifierRef.hashCode() ^ ObjectUtil.hashCode(getStringValue()); + return getClass().hashCode() ^ hashCode; + } + + @Override + public String toString() + { + return "OID:" + toURIFragment(); //$NON-NLS-1$ + } + + @Override + protected int doCompareTo(CDOID o) throws ClassCastException + { + // conversion to uri fragment is pretty heavy but afaics the compareTo + // is not used in a critical place. + return toURIFragment().compareTo(o.toURIFragment()); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectUUIDImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectUUIDImpl.java index 5b5e04f3fc..fd76f4f4b4 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectUUIDImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDObjectUUIDImpl.java @@ -1,104 +1,104 @@ -/*
- * 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:
- * Martin Taal - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.id;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDByteArray;
-import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject;
-
-/**
- * @author Martin Taal
- * @since 3.0
- */
-public class CDOIDObjectUUIDImpl extends AbstractCDOIDByteArray implements InternalCDOIDObject
-{
- private static final long serialVersionUID = 1L;
-
- public CDOIDObjectUUIDImpl()
- {
- }
-
- public CDOIDObjectUUIDImpl(byte[] value)
- {
- super(value);
- }
-
- public Type getType()
- {
- return Type.OBJECT;
- }
-
- public boolean isDangling()
- {
- return false;
- }
-
- public boolean isExternal()
- {
- return false;
- }
-
- public boolean isNull()
- {
- return false;
- }
-
- public boolean isObject()
- {
- return true;
- }
-
- public boolean isTemporary()
- {
- return false;
- }
-
- public CDOID.ObjectType getSubType()
- {
- return CDOID.ObjectType.UUID;
- }
-
- @Override
- protected int doCompareTo(CDOID o) throws ClassCastException
- {
- byte[] thisValue = getByteArrayValue();
- byte[] thatValue = ((CDOIDObjectUUIDImpl)o).getByteArrayValue();
- int minLength = Math.min(thisValue.length, thatValue.length);
-
- for (int i = 0; i < minLength; i++)
- {
- byte thisByte = thisValue[i];
- byte thatByte = thatValue[i];
- if (thisByte < thatByte)
- {
- return -1;
- }
-
- if (thisByte > thatByte)
- {
- return 1;
- }
- }
-
- if (thisValue.length < thatValue.length)
- {
- return -1;
- }
-
- if (thisValue.length > thatValue.length)
- {
- return 1;
- }
-
- return 0;
- }
-}
+/* + * 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: + * Martin Taal - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.internal.common.id; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDByteArray; +import org.eclipse.emf.cdo.spi.common.id.InternalCDOIDObject; + +/** + * @author Martin Taal + * @since 3.0 + */ +public class CDOIDObjectUUIDImpl extends AbstractCDOIDByteArray implements InternalCDOIDObject +{ + private static final long serialVersionUID = 1L; + + public CDOIDObjectUUIDImpl() + { + } + + public CDOIDObjectUUIDImpl(byte[] value) + { + super(value); + } + + public Type getType() + { + return Type.OBJECT; + } + + public boolean isDangling() + { + return false; + } + + public boolean isExternal() + { + return false; + } + + public boolean isNull() + { + return false; + } + + public boolean isObject() + { + return true; + } + + public boolean isTemporary() + { + return false; + } + + public CDOID.ObjectType getSubType() + { + return CDOID.ObjectType.UUID; + } + + @Override + protected int doCompareTo(CDOID o) throws ClassCastException + { + byte[] thisValue = getByteArrayValue(); + byte[] thatValue = ((CDOIDObjectUUIDImpl)o).getByteArrayValue(); + int minLength = Math.min(thisValue.length, thatValue.length); + + for (int i = 0; i < minLength; i++) + { + byte thisByte = thisValue[i]; + byte thatByte = thatValue[i]; + if (thisByte < thatByte) + { + return -1; + } + + if (thisByte > thatByte) + { + return 1; + } + } + + if (thisValue.length < thatValue.length) + { + return -1; + } + + if (thisValue.length > thatValue.length) + { + return 1; + } + + return 0; + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectExternalImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectExternalImpl.java index 1a637113b6..b72babdd7e 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectExternalImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectExternalImpl.java @@ -1,33 +1,33 @@ -/*
- * 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.internal.common.id;
-
-import org.eclipse.emf.cdo.common.id.CDOIDTemp;
-
-/**
- * @author Simon McDuff
- */
-public class CDOIDTempObjectExternalImpl extends CDOIDExternalImpl implements CDOIDTemp
-{
- private static final long serialVersionUID = 1L;
-
- public CDOIDTempObjectExternalImpl(String uri)
- {
- super(uri);
- }
-
- @Override
- public Type getType()
- {
- return Type.EXTERNAL_TEMP_OBJECT;
- }
-}
+/* + * 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.internal.common.id; + +import org.eclipse.emf.cdo.common.id.CDOIDTemp; + +/** + * @author Simon McDuff + */ +public class CDOIDTempObjectExternalImpl extends CDOIDExternalImpl implements CDOIDTemp +{ + private static final long serialVersionUID = 1L; + + public CDOIDTempObjectExternalImpl(String uri) + { + super(uri); + } + + @Override + public Type getType() + { + return Type.EXTERNAL_TEMP_OBJECT; + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectImpl.java index 625d9660b4..2cc4034065 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/id/CDOIDTempObjectImpl.java @@ -1,70 +1,70 @@ -/*
- * 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.internal.common.id;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDTemp;
-import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDInteger;
-
-/**
- * @author Eike Stepper
- */
-public class CDOIDTempObjectImpl extends AbstractCDOIDInteger implements CDOIDTemp
-{
- private static final long serialVersionUID = 1L;
-
- public CDOIDTempObjectImpl(int value)
- {
- super(value);
- }
-
- public Type getType()
- {
- return Type.TEMP_OBJECT;
- }
-
- public boolean isDangling()
- {
- return false;
- }
-
- public boolean isExternal()
- {
- return false;
- }
-
- public boolean isNull()
- {
- return false;
- }
-
- public boolean isObject()
- {
- return true;
- }
-
- public boolean isTemporary()
- {
- return true;
- }
-
- @Override
- public String toString()
- {
- return "oid" + getIntValue(); //$NON-NLS-1$
- }
-
- @Override
- protected int doCompareTo(CDOID o) throws ClassCastException
- {
- return new Integer(getIntValue()).compareTo(((CDOIDTempObjectImpl)o).getIntValue());
- }
-}
+/* + * 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.internal.common.id; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.id.CDOIDTemp; +import org.eclipse.emf.cdo.spi.common.id.AbstractCDOIDInteger; + +/** + * @author Eike Stepper + */ +public class CDOIDTempObjectImpl extends AbstractCDOIDInteger implements CDOIDTemp +{ + private static final long serialVersionUID = 1L; + + public CDOIDTempObjectImpl(int value) + { + super(value); + } + + public Type getType() + { + return Type.TEMP_OBJECT; + } + + public boolean isDangling() + { + return false; + } + + public boolean isExternal() + { + return false; + } + + public boolean isNull() + { + return false; + } + + public boolean isObject() + { + return true; + } + + public boolean isTemporary() + { + return true; + } + + @Override + public String toString() + { + return "oid" + getIntValue(); //$NON-NLS-1$ + } + + @Override + protected int doCompareTo(CDOID o) throws ClassCastException + { + return new Integer(getIntValue()).compareTo(((CDOIDTempObjectImpl)o).getIntValue()); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockAreaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockAreaImpl.java index 923dd38f8f..a970a53ec1 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockAreaImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockAreaImpl.java @@ -1,106 +1,106 @@ -/*
- * 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
- * Caspar De Groot - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.lock;
-
-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.IDurableLockingManager.LockArea;
-import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockGrade;
-
-import java.text.MessageFormat;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- * @since 4.1
- * @noextend This interface is not intended to be extended by clients.
- */
-public class CDOLockAreaImpl implements LockArea
-{
- public static final int DEFAULT_DURABLE_LOCKING_ID_BYTES = 32;
-
- private final String durableLockingID;
-
- private final String userID;
-
- private final CDOBranchPoint branchPoint;
-
- private final boolean readOnly;
-
- private final Map<CDOID, LockGrade> locks;
-
- private final boolean missing;
-
- public CDOLockAreaImpl(String durableLockingID, String userID, CDOBranchPoint branchPoint, boolean readOnly,
- Map<CDOID, LockGrade> locks)
- {
- this.durableLockingID = durableLockingID;
- this.userID = userID;
- this.branchPoint = branchPoint;
- this.readOnly = readOnly;
- this.locks = locks;
- missing = false;
- }
-
- public CDOLockAreaImpl(String durableLockingID)
- {
- this.durableLockingID = durableLockingID;
- userID = null;
- branchPoint = null;
- readOnly = false;
- locks = null;
- missing = true;
- }
-
- public String getDurableLockingID()
- {
- return durableLockingID;
- }
-
- public String getUserID()
- {
- return userID;
- }
-
- public CDOBranch getBranch()
- {
- return branchPoint.getBranch();
- }
-
- public long getTimeStamp()
- {
- return branchPoint.getTimeStamp();
- }
-
- public boolean isReadOnly()
- {
- return readOnly;
- }
-
- public Map<CDOID, LockGrade> getLocks()
- {
- return locks;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("DurableLockArea\nid={0}\nuser={1}\nbranchPoint={2}\nreadOnly={3}\nlocks={4}",
- durableLockingID, userID, branchPoint, readOnly, locks);
- }
-
- public boolean isMissing()
- {
- return missing;
- }
-}
+/* + * 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 + * Caspar De Groot - maintenance + */ +package org.eclipse.emf.cdo.internal.common.lock; + +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.IDurableLockingManager.LockArea; +import org.eclipse.emf.cdo.common.lock.IDurableLockingManager.LockGrade; + +import java.text.MessageFormat; +import java.util.Map; + +/** + * @author Eike Stepper + * @since 4.1 + * @noextend This interface is not intended to be extended by clients. + */ +public class CDOLockAreaImpl implements LockArea +{ + public static final int DEFAULT_DURABLE_LOCKING_ID_BYTES = 32; + + private final String durableLockingID; + + private final String userID; + + private final CDOBranchPoint branchPoint; + + private final boolean readOnly; + + private final Map<CDOID, LockGrade> locks; + + private final boolean missing; + + public CDOLockAreaImpl(String durableLockingID, String userID, CDOBranchPoint branchPoint, boolean readOnly, + Map<CDOID, LockGrade> locks) + { + this.durableLockingID = durableLockingID; + this.userID = userID; + this.branchPoint = branchPoint; + this.readOnly = readOnly; + this.locks = locks; + missing = false; + } + + public CDOLockAreaImpl(String durableLockingID) + { + this.durableLockingID = durableLockingID; + userID = null; + branchPoint = null; + readOnly = false; + locks = null; + missing = true; + } + + public String getDurableLockingID() + { + return durableLockingID; + } + + public String getUserID() + { + return userID; + } + + public CDOBranch getBranch() + { + return branchPoint.getBranch(); + } + + public long getTimeStamp() + { + return branchPoint.getTimeStamp(); + } + + public boolean isReadOnly() + { + return readOnly; + } + + public Map<CDOID, LockGrade> getLocks() + { + return locks; + } + + @Override + public String toString() + { + return MessageFormat.format("DurableLockArea\nid={0}\nuser={1}\nbranchPoint={2}\nreadOnly={3}\nlocks={4}", + durableLockingID, userID, branchPoint, readOnly, locks); + } + + public boolean isMissing() + { + return missing; + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockChangeInfoImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockChangeInfoImpl.java index 49747d85f1..ad5719be6a 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockChangeInfoImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockChangeInfoImpl.java @@ -1,93 +1,93 @@ -/*
- * 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.internal.common.lock;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-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.net4j.util.concurrent.IRWLockManager.LockType;
-
-/**
- * @author Caspar De Groot
- */
-public class CDOLockChangeInfoImpl implements CDOLockChangeInfo
-{
- private final CDOBranchPoint branchPoint;
-
- private final CDOLockOwner lockOwner;
-
- private final CDOLockState[] lockStates;
-
- private final Operation operation;
-
- private final LockType lockType;
-
- private final boolean isInvalidateAll;
-
- public CDOLockChangeInfoImpl(CDOBranchPoint branchPoint, CDOLockOwner lockOwner, CDOLockState[] lockStates,
- Operation operation, LockType lockType)
- {
- this.branchPoint = branchPoint;
- this.lockOwner = lockOwner;
- this.lockStates = lockStates;
- this.operation = operation;
- this.lockType = lockType;
- isInvalidateAll = false;
- }
-
- public CDOLockChangeInfoImpl()
- {
- branchPoint = null;
- lockOwner = null;
- lockStates = null;
- operation = null;
- lockType = null;
- isInvalidateAll = true;
- }
-
- public CDOBranch getBranch()
- {
- return branchPoint == null ? null : branchPoint.getBranch();
- }
-
- public long getTimeStamp()
- {
- return branchPoint == null ? CDOBranchPoint.UNSPECIFIED_DATE : branchPoint.getTimeStamp();
- }
-
- public CDOLockOwner getLockOwner()
- {
- return lockOwner;
- }
-
- public CDOLockState[] getLockStates()
- {
- return lockStates;
- }
-
- public Operation getOperation()
- {
- return operation;
- }
-
- public LockType getLockType()
- {
- return lockType;
- }
-
- public boolean isInvalidateAll()
- {
- return isInvalidateAll;
- }
-}
+/* + * 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.internal.common.lock; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +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.net4j.util.concurrent.IRWLockManager.LockType; + +/** + * @author Caspar De Groot + */ +public class CDOLockChangeInfoImpl implements CDOLockChangeInfo +{ + private final CDOBranchPoint branchPoint; + + private final CDOLockOwner lockOwner; + + private final CDOLockState[] lockStates; + + private final Operation operation; + + private final LockType lockType; + + private final boolean isInvalidateAll; + + public CDOLockChangeInfoImpl(CDOBranchPoint branchPoint, CDOLockOwner lockOwner, CDOLockState[] lockStates, + Operation operation, LockType lockType) + { + this.branchPoint = branchPoint; + this.lockOwner = lockOwner; + this.lockStates = lockStates; + this.operation = operation; + this.lockType = lockType; + isInvalidateAll = false; + } + + public CDOLockChangeInfoImpl() + { + branchPoint = null; + lockOwner = null; + lockStates = null; + operation = null; + lockType = null; + isInvalidateAll = true; + } + + public CDOBranch getBranch() + { + return branchPoint == null ? null : branchPoint.getBranch(); + } + + public long getTimeStamp() + { + return branchPoint == null ? CDOBranchPoint.UNSPECIFIED_DATE : branchPoint.getTimeStamp(); + } + + public CDOLockOwner getLockOwner() + { + return lockOwner; + } + + public CDOLockState[] getLockStates() + { + return lockStates; + } + + public Operation getOperation() + { + return operation; + } + + public LockType getLockType() + { + return lockType; + } + + public boolean isInvalidateAll() + { + return isInvalidateAll; + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockOwnerImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockOwnerImpl.java index 7d4c1c7925..c3d14cf99f 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockOwnerImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockOwnerImpl.java @@ -1,91 +1,91 @@ -/*
- * 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.internal.common.lock;
-
-import org.eclipse.emf.cdo.common.lock.CDOLockOwner;
-
-import org.eclipse.net4j.util.ObjectUtil;
-
-/**
- * @author Caspar De Groot
- */
-public class CDOLockOwnerImpl implements CDOLockOwner
-{
- private final int sessionID;
-
- private final int viewID;
-
- private final String durableLockingID;
-
- private final boolean isDurableView;
-
- public CDOLockOwnerImpl(int sessionID, int viewID, String durableLockingID, boolean isDurableView)
- {
- this.sessionID = sessionID;
- this.viewID = viewID;
- this.durableLockingID = durableLockingID;
- this.isDurableView = isDurableView;
- }
-
- public int getSessionID()
- {
- return sessionID;
- }
-
- public int getViewID()
- {
- return viewID;
- }
-
- public String getDurableLockingID()
- {
- return durableLockingID;
- }
-
- public boolean isDurableView()
- {
- return isDurableView;
- }
-
- @Override
- public int hashCode()
- {
- return ObjectUtil.hashCode(sessionID, viewID);
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj instanceof CDOLockOwner)
- {
- CDOLockOwner that = (CDOLockOwner)obj;
- return sessionID == that.getSessionID() && viewID == that.getViewID();
- }
-
- return false;
- }
-
- @Override
- public String toString()
- {
- StringBuilder builder = new StringBuilder("CDOLockOwner[");
- builder.append(sessionID);
- builder.append(':');
- builder.append(viewID);
- builder.append(']');
- 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: + * Caspar De Groot - initial API and implementation + */ +package org.eclipse.emf.cdo.internal.common.lock; + +import org.eclipse.emf.cdo.common.lock.CDOLockOwner; + +import org.eclipse.net4j.util.ObjectUtil; + +/** + * @author Caspar De Groot + */ +public class CDOLockOwnerImpl implements CDOLockOwner +{ + private final int sessionID; + + private final int viewID; + + private final String durableLockingID; + + private final boolean isDurableView; + + public CDOLockOwnerImpl(int sessionID, int viewID, String durableLockingID, boolean isDurableView) + { + this.sessionID = sessionID; + this.viewID = viewID; + this.durableLockingID = durableLockingID; + this.isDurableView = isDurableView; + } + + public int getSessionID() + { + return sessionID; + } + + public int getViewID() + { + return viewID; + } + + public String getDurableLockingID() + { + return durableLockingID; + } + + public boolean isDurableView() + { + return isDurableView; + } + + @Override + public int hashCode() + { + return ObjectUtil.hashCode(sessionID, viewID); + } + + @Override + public boolean equals(Object obj) + { + if (obj == this) + { + return true; + } + + if (obj instanceof CDOLockOwner) + { + CDOLockOwner that = (CDOLockOwner)obj; + return sessionID == that.getSessionID() && viewID == that.getViewID(); + } + + return false; + } + + @Override + public String toString() + { + StringBuilder builder = new StringBuilder("CDOLockOwner["); + builder.append(sessionID); + builder.append(':'); + builder.append(viewID); + builder.append(']'); + return builder.toString(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockStateImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockStateImpl.java index f5f88aff7d..7f7d2eb83a 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockStateImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/lock/CDOLockStateImpl.java @@ -1,191 +1,191 @@ -/*
- * 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.internal.common.lock;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.lock.CDOLockOwner;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
-import org.eclipse.emf.cdo.spi.common.lock.InternalCDOLockState;
-
-import org.eclipse.net4j.util.CheckUtil;
-import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * @author Caspar De Groot
- */
-public class CDOLockStateImpl implements InternalCDOLockState
-{
- private final Object lockedObject;
-
- private final Set<CDOLockOwner> readLockOwners = new HashSet<CDOLockOwner>();
-
- private CDOLockOwner writeLockOwner;
-
- private CDOLockOwner writeOptionOwner;
-
- public CDOLockStateImpl(Object lockedObject)
- {
- CheckUtil.checkArg(lockedObject, "lockedObject");
- CheckUtil.checkState(lockedObject instanceof CDOID || lockedObject instanceof CDOIDAndBranch,
- "lockedObject is of wrong type");
- this.lockedObject = lockedObject;
- }
-
- public CDOLockStateImpl copy()
- {
- CDOLockStateImpl newLockState = new CDOLockStateImpl(lockedObject);
- for (CDOLockOwner owner : readLockOwners)
- {
- newLockState.readLockOwners.add(owner);
- }
-
- newLockState.writeLockOwner = writeLockOwner;
- newLockState.writeOptionOwner = writeOptionOwner;
- return newLockState;
- }
-
- public boolean isLocked(LockType lockType, CDOLockOwner lockOwner, boolean others)
- {
- switch (lockType)
- {
- case READ:
- return isReadLocked(lockOwner, others);
-
- case WRITE:
- return isWriteLocked(lockOwner, others);
-
- case OPTION:
- return isOptionLocked(lockOwner, others);
- }
-
- return false;
- }
-
- private boolean isReadLocked(CDOLockOwner by, boolean others)
- {
- int n = readLockOwners.size();
- if (n == 0)
- {
- return false;
- }
-
- if (!others)
- {
- return readLockOwners.contains(by);
- }
-
- return true;
- }
-
- private boolean isWriteLocked(CDOLockOwner by, boolean others)
- {
- if (writeLockOwner == null)
- {
- return false;
- }
-
- return writeLockOwner.equals(by) ^ others;
- }
-
- private boolean isOptionLocked(CDOLockOwner by, boolean others)
- {
- if (writeOptionOwner == null)
- {
- return false;
- }
-
- return writeOptionOwner.equals(by) ^ others;
- }
-
- public Set<CDOLockOwner> getReadLockOwners()
- {
- return Collections.unmodifiableSet(readLockOwners);
- }
-
- public void addReadLockOwner(CDOLockOwner lockOwner)
- {
- readLockOwners.add(lockOwner);
- }
-
- public boolean removeReadLockOwner(CDOLockOwner lockOwner)
- {
- return readLockOwners.remove(lockOwner);
- }
-
- public CDOLockOwner getWriteLockOwner()
- {
- return writeLockOwner;
- }
-
- public void setWriteLockOwner(CDOLockOwner lockOwner)
- {
- writeLockOwner = lockOwner;
- }
-
- public CDOLockOwner getWriteOptionOwner()
- {
- return writeOptionOwner;
- }
-
- public void setWriteOptionOwner(CDOLockOwner lockOwner)
- {
- writeOptionOwner = lockOwner;
- }
-
- public Object getLockedObject()
- {
- return lockedObject;
- }
-
- @Override
- public String toString()
- {
- StringBuilder builder = new StringBuilder("CDOLockState\nlockedObject=");
- builder.append(lockedObject);
-
- builder.append("\nreadLockOwners=");
- if (readLockOwners.size() > 0)
- {
- boolean first = true;
- for (CDOLockOwner lockOwner : readLockOwners)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- builder.append(", ");
- }
-
- builder.append(lockOwner);
- }
-
- builder.deleteCharAt(builder.length() - 1);
- }
- else
- {
- builder.append("NONE");
- }
-
- builder.append("\nwriteLockOwner=");
- builder.append(writeLockOwner != null ? writeLockOwner : "NONE");
-
- builder.append("\nwriteOptionOwner=");
- builder.append(writeOptionOwner != null ? writeOptionOwner : "NONE");
-
- 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: + * Caspar De Groot - initial API and implementation + */ +package org.eclipse.emf.cdo.internal.common.lock; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.lock.CDOLockOwner; +import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch; +import org.eclipse.emf.cdo.spi.common.lock.InternalCDOLockState; + +import org.eclipse.net4j.util.CheckUtil; +import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType; + +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +/** + * @author Caspar De Groot + */ +public class CDOLockStateImpl implements InternalCDOLockState +{ + private final Object lockedObject; + + private final Set<CDOLockOwner> readLockOwners = new HashSet<CDOLockOwner>(); + + private CDOLockOwner writeLockOwner; + + private CDOLockOwner writeOptionOwner; + + public CDOLockStateImpl(Object lockedObject) + { + CheckUtil.checkArg(lockedObject, "lockedObject"); + CheckUtil.checkState(lockedObject instanceof CDOID || lockedObject instanceof CDOIDAndBranch, + "lockedObject is of wrong type"); + this.lockedObject = lockedObject; + } + + public CDOLockStateImpl copy() + { + CDOLockStateImpl newLockState = new CDOLockStateImpl(lockedObject); + for (CDOLockOwner owner : readLockOwners) + { + newLockState.readLockOwners.add(owner); + } + + newLockState.writeLockOwner = writeLockOwner; + newLockState.writeOptionOwner = writeOptionOwner; + return newLockState; + } + + public boolean isLocked(LockType lockType, CDOLockOwner lockOwner, boolean others) + { + switch (lockType) + { + case READ: + return isReadLocked(lockOwner, others); + + case WRITE: + return isWriteLocked(lockOwner, others); + + case OPTION: + return isOptionLocked(lockOwner, others); + } + + return false; + } + + private boolean isReadLocked(CDOLockOwner by, boolean others) + { + int n = readLockOwners.size(); + if (n == 0) + { + return false; + } + + if (!others) + { + return readLockOwners.contains(by); + } + + return true; + } + + private boolean isWriteLocked(CDOLockOwner by, boolean others) + { + if (writeLockOwner == null) + { + return false; + } + + return writeLockOwner.equals(by) ^ others; + } + + private boolean isOptionLocked(CDOLockOwner by, boolean others) + { + if (writeOptionOwner == null) + { + return false; + } + + return writeOptionOwner.equals(by) ^ others; + } + + public Set<CDOLockOwner> getReadLockOwners() + { + return Collections.unmodifiableSet(readLockOwners); + } + + public void addReadLockOwner(CDOLockOwner lockOwner) + { + readLockOwners.add(lockOwner); + } + + public boolean removeReadLockOwner(CDOLockOwner lockOwner) + { + return readLockOwners.remove(lockOwner); + } + + public CDOLockOwner getWriteLockOwner() + { + return writeLockOwner; + } + + public void setWriteLockOwner(CDOLockOwner lockOwner) + { + writeLockOwner = lockOwner; + } + + public CDOLockOwner getWriteOptionOwner() + { + return writeOptionOwner; + } + + public void setWriteOptionOwner(CDOLockOwner lockOwner) + { + writeOptionOwner = lockOwner; + } + + public Object getLockedObject() + { + return lockedObject; + } + + @Override + public String toString() + { + StringBuilder builder = new StringBuilder("CDOLockState\nlockedObject="); + builder.append(lockedObject); + + builder.append("\nreadLockOwners="); + if (readLockOwners.size() > 0) + { + boolean first = true; + for (CDOLockOwner lockOwner : readLockOwners) + { + if (first) + { + first = false; + } + else + { + builder.append(", "); + } + + builder.append(lockOwner); + } + + builder.deleteCharAt(builder.length() - 1); + } + else + { + builder.append("NONE"); + } + + builder.append("\nwriteLockOwner="); + builder.append(writeLockOwner != null ? writeLockOwner : "NONE"); + + builder.append("\nwriteOptionOwner="); + builder.append(writeOptionOwner != null ? writeOptionOwner : "NONE"); + + return builder.toString(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/messages/Messages.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/messages/Messages.java index 6e854db79c..64af5b3e8f 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/messages/Messages.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/messages/Messages.java @@ -1,41 +1,41 @@ -/*
- * 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:
- * Victor Roldan Betancort - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.internal.common.messages;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * @author Victor Roldan Betancort
- */
-public class Messages
-{
- private static final String BUNDLE_NAME = "org.eclipse.emf.cdo.internal.common.messages.messages"; //$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
-
- private Messages()
- {
- }
-
- public static String getString(String key)
- {
- try
- {
- return RESOURCE_BUNDLE.getString(key);
- }
- catch (MissingResourceException e)
- {
- return '!' + key + '!';
- }
- }
-}
+/* + * 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: + * Victor Roldan Betancort - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.internal.common.messages; + +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * @author Victor Roldan Betancort + */ +public class Messages +{ + private static final String BUNDLE_NAME = "org.eclipse.emf.cdo.internal.common.messages.messages"; //$NON-NLS-1$ + + private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME); + + private Messages() + { + } + + public static String getString(String key) + { + try + { + return RESOURCE_BUNDLE.getString(key); + } + catch (MissingResourceException e) + { + return '!' + key + '!'; + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/messages/messages.properties b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/messages/messages.properties index cf74bb5f59..ea3ccc5e62 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/messages/messages.properties +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/messages/messages.properties @@ -1,39 +1,39 @@ -# 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:
-# Victor Roldan Betancort - initial API and implementation
-# Eike Stepper - maintenance
-
-AbstractCDORevision.0=EClass is abstract: {0}
-AbstractCDORevision.1=CDOID is null
-AbstractCDORevision.2=Missing ID mapping for {0}
-AbstractCDORevision.20=Could not find feature {0} in class {1}
-CDOClassifierRef.0=Package not found: {0}
-CDOClassifierRef.1=Invalid classifier URI:
-CDODataInputImpl.5=Invalid CDOFeatureDelta type
-CDODataOutputImpl.5=Temporary ID not supported: {0}
-CDODataOutputImpl.6=No type for object of class {0}
-CDOIDLibraryProviderImpl.0=Unknown library: {0}
-CDOIDLibraryProviderImpl.2=Not a JAR: {0}
-CDOIDUtil.0=Unknown CDOIDObject implementation: {0}
-CDOIDUtil.1=ID is temporary
-CDOIDUtil.2=Can not get id value from external ID types
-CDOIDUtil.3=Invalid CDOID type: {0}
-CDOIDUtil.5=Invalid ID type: {0}
-CDOModelUtil.6=No type for id {0}
-CDOModelUtil.7=Not a primitive type nor String nor Date: {0}
-CDOPackageRegistryImpl.0=No package unit available for: {0}
-CDOPackageUnit.0=Package unit type is unknown
-CDOPackageUnitImpl.0=UNINITIALIZED
-CDOPackageUnitImpl.1=Package unit not initialized
-CDORevisionUtil.0=UNINITIALIZED
-CDOTypeImpl.23=Cannot find the enum literal {0}
-DLRevisionList.0=Cannot assign to a different list while linked to a list
-DLRevisionList.3=Holder {0} is still linked in different list
-DLRevisionList.5=Holder {0} does not belong to this list
-LRURevisionHolder.0=Not a {0}: {1}
-MEMRevisionCache.1=Invalid referenceType: {0}
+# 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: +# Victor Roldan Betancort - initial API and implementation +# Eike Stepper - maintenance + +AbstractCDORevision.0=EClass is abstract: {0} +AbstractCDORevision.1=CDOID is null +AbstractCDORevision.2=Missing ID mapping for {0} +AbstractCDORevision.20=Could not find feature {0} in class {1} +CDOClassifierRef.0=Package not found: {0} +CDOClassifierRef.1=Invalid classifier URI: +CDODataInputImpl.5=Invalid CDOFeatureDelta type +CDODataOutputImpl.5=Temporary ID not supported: {0} +CDODataOutputImpl.6=No type for object of class {0} +CDOIDLibraryProviderImpl.0=Unknown library: {0} +CDOIDLibraryProviderImpl.2=Not a JAR: {0} +CDOIDUtil.0=Unknown CDOIDObject implementation: {0} +CDOIDUtil.1=ID is temporary +CDOIDUtil.2=Can not get id value from external ID types +CDOIDUtil.3=Invalid CDOID type: {0} +CDOIDUtil.5=Invalid ID type: {0} +CDOModelUtil.6=No type for id {0} +CDOModelUtil.7=Not a primitive type nor String nor Date: {0} +CDOPackageRegistryImpl.0=No package unit available for: {0} +CDOPackageUnit.0=Package unit type is unknown +CDOPackageUnitImpl.0=UNINITIALIZED +CDOPackageUnitImpl.1=Package unit not initialized +CDORevisionUtil.0=UNINITIALIZED +CDOTypeImpl.23=Cannot find the enum literal {0} +DLRevisionList.0=Cannot assign to a different list while linked to a list +DLRevisionList.3=Holder {0} is still linked in different list +DLRevisionList.5=Holder {0} does not belong to this list +LRURevisionHolder.0=Not a {0}: {1} +MEMRevisionCache.1=Invalid referenceType: {0} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java index 49ed16a907..69a40cd8fb 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOClassInfoImpl.java @@ -1,126 +1,126 @@ -/*
- * 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.internal.common.model;
-
-import org.eclipse.emf.cdo.common.model.CDOClassInfo;
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class CDOClassInfoImpl extends AdapterImpl implements CDOClassInfo
-{
- private static final int NOT_MAPPED = -1;
-
- private EStructuralFeature[] allPersistentFeatures;
-
- private int[] featureIDMappings;
-
- public CDOClassInfoImpl()
- {
- }
-
- @Override
- public boolean isAdapterForType(Object type)
- {
- return type == CDOClassInfo.class;
- }
-
- @Override
- public void setTarget(Notifier newTarget)
- {
- init((EClass)newTarget);
- super.setTarget(newTarget);
- }
-
- public EClass getEClass()
- {
- return (EClass)getTarget();
- }
-
- public boolean isResource()
- {
- return CDOModelUtil.isResource(getEClass());
- }
-
- public boolean isResourceFolder()
- {
- return CDOModelUtil.isResourceFolder(getEClass());
- }
-
- public boolean isResourceNode()
- {
- return CDOModelUtil.isResourceNode(getEClass());
- }
-
- public EStructuralFeature[] getAllPersistentFeatures()
- {
- return allPersistentFeatures;
- }
-
- public int getFeatureIndex(EStructuralFeature feature)
- {
- int featureID = getEClass().getFeatureID(feature);
- return getFeatureIndex(featureID);
- }
-
- public int getFeatureIndex(int featureID)
- {
- int index = featureIDMappings[featureID];
- if (index == NOT_MAPPED)
- {
- throw new IllegalArgumentException("Feature not mapped: " + getEClass().getEStructuralFeature(featureID)); //$NON-NLS-1$
- }
-
- return index;
- }
-
- private void init(EClass eClass)
- {
- List<EStructuralFeature> persistentFeatures = new ArrayList<EStructuralFeature>();
- EList<EStructuralFeature> allFeatures = eClass.getEAllStructuralFeatures();
- for (EStructuralFeature feature : allFeatures)
- {
- if (EMFUtil.isPersistent(feature))
- {
- persistentFeatures.add(feature);
- }
- }
-
- allPersistentFeatures = persistentFeatures.toArray(new EStructuralFeature[persistentFeatures.size()]);
- featureIDMappings = new int[allFeatures.size()];
- Arrays.fill(featureIDMappings, NOT_MAPPED);
-
- for (int i = 0; i < allPersistentFeatures.length; i++)
- {
- EStructuralFeature feature = allPersistentFeatures[i];
- int featureID = eClass.getFeatureID(feature);
- featureIDMappings[featureID] = i;
- }
- }
-
- @Override
- public String toString()
- {
- return getEClass().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.internal.common.model; + +import org.eclipse.emf.cdo.common.model.CDOClassInfo; +import org.eclipse.emf.cdo.common.model.CDOModelUtil; +import org.eclipse.emf.cdo.common.model.EMFUtil; + +import org.eclipse.emf.common.notify.Notifier; +import org.eclipse.emf.common.notify.impl.AdapterImpl; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class CDOClassInfoImpl extends AdapterImpl implements CDOClassInfo +{ + private static final int NOT_MAPPED = -1; + + private EStructuralFeature[] allPersistentFeatures; + + private int[] featureIDMappings; + + public CDOClassInfoImpl() + { + } + + @Override + public boolean isAdapterForType(Object type) + { + return type == CDOClassInfo.class; + } + + @Override + public void setTarget(Notifier newTarget) + { + init((EClass)newTarget); + super.setTarget(newTarget); + } + + public EClass getEClass() + { + return (EClass)getTarget(); + } + + public boolean isResource() + { + return CDOModelUtil.isResource(getEClass()); + } + + public boolean isResourceFolder() + { + return CDOModelUtil.isResourceFolder(getEClass()); + } + + public boolean isResourceNode() + { + return CDOModelUtil.isResourceNode(getEClass()); + } + + public EStructuralFeature[] getAllPersistentFeatures() + { + return allPersistentFeatures; + } + + public int getFeatureIndex(EStructuralFeature feature) + { + int featureID = getEClass().getFeatureID(feature); + return getFeatureIndex(featureID); + } + + public int getFeatureIndex(int featureID) + { + int index = featureIDMappings[featureID]; + if (index == NOT_MAPPED) + { + throw new IllegalArgumentException("Feature not mapped: " + getEClass().getEStructuralFeature(featureID)); //$NON-NLS-1$ + } + + return index; + } + + private void init(EClass eClass) + { + List<EStructuralFeature> persistentFeatures = new ArrayList<EStructuralFeature>(); + EList<EStructuralFeature> allFeatures = eClass.getEAllStructuralFeatures(); + for (EStructuralFeature feature : allFeatures) + { + if (EMFUtil.isPersistent(feature)) + { + persistentFeatures.add(feature); + } + } + + allPersistentFeatures = persistentFeatures.toArray(new EStructuralFeature[persistentFeatures.size()]); + featureIDMappings = new int[allFeatures.size()]; + Arrays.fill(featureIDMappings, NOT_MAPPED); + + for (int i = 0; i < allPersistentFeatures.length; i++) + { + EStructuralFeature feature = allPersistentFeatures[i]; + int featureID = eClass.getFeatureID(feature); + featureIDMappings[featureID] = i; + } + } + + @Override + public String toString() + { + return getEClass().toString(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageInfoImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageInfoImpl.java index 2b182cc038..106b05d438 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageInfoImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageInfoImpl.java @@ -1,160 +1,160 @@ -/*
- * 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.internal.common.model;
-
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.internal.common.bundle.OM;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
-
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.emf.ecore.EPackage;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public class CDOPackageInfoImpl extends AdapterImpl implements InternalCDOPackageInfo
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDOPackageInfoImpl.class);
-
- private InternalCDOPackageUnit packageUnit;
-
- private String packageURI;
-
- private String parentURI;
-
- public CDOPackageInfoImpl()
- {
- }
-
- public InternalCDOPackageUnit getPackageUnit()
- {
- return packageUnit;
- }
-
- public void setPackageUnit(InternalCDOPackageUnit packageUnit)
- {
- this.packageUnit = packageUnit;
- }
-
- public String getPackageURI()
- {
- return packageURI;
- }
-
- public void setPackageURI(String packageURI)
- {
- this.packageURI = packageURI;
- }
-
- public String getParentURI()
- {
- return parentURI;
- }
-
- public void setParentURI(String parentURI)
- {
- this.parentURI = parentURI;
- }
-
- public void write(CDODataOutput out) throws IOException
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing {0}", this); //$NON-NLS-1$
- }
-
- out.writeCDOPackageURI(packageURI);
- out.writeCDOPackageURI(parentURI);
- }
-
- public void read(CDODataInput in) throws IOException
- {
- packageURI = in.readCDOPackageURI();
- parentURI = in.readCDOPackageURI();
- if (TRACER.isEnabled())
- {
- TRACER.format("Read {0}", this); //$NON-NLS-1$
- }
- }
-
- public EFactory getEFactory()
- {
- return getEPackage().getEFactoryInstance();
- }
-
- public EPackage getEPackage()
- {
- return getEPackage(true);
- }
-
- public EPackage getEPackage(boolean loadOnDemand)
- {
- return doGetEPackage(loadOnDemand);
- }
-
- public EPackage doGetEPackage(boolean loadOnDemand)
- {
- EPackage ePackage = (EPackage)getTarget();
- if (ePackage != null)
- {
- return ePackage;
- }
-
- if (loadOnDemand)
- {
- packageUnit.load(true); // TODO (CD) Dubious: is resolution-on-load really a good idea?
- return (EPackage)getTarget();
- }
-
- return null;
- }
-
- public boolean isCorePackage()
- {
- return CDOModelUtil.isCorePackage(getEPackage());
- }
-
- public boolean isResourcePackage()
- {
- return CDOModelUtil.isResourcePackage(getEPackage());
- }
-
- public boolean isTypePackage()
- {
- return CDOModelUtil.isTypesPackage(getEPackage());
- }
-
- public boolean isSystemPackage()
- {
- return CDOModelUtil.isSystemPackage(getEPackage());
- }
-
- public int compareTo(CDOPackageInfo o)
- {
- return getPackageURI().compareTo(o.getPackageURI());
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("CDOPackageInfo[packageURI={0}, parentURI={1}]", packageURI, parentURI); //$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.internal.common.model; + +import org.eclipse.emf.cdo.common.model.CDOModelUtil; +import org.eclipse.emf.cdo.common.model.CDOPackageInfo; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.internal.common.bundle.OM; +import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo; +import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit; + +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.common.notify.impl.AdapterImpl; +import org.eclipse.emf.ecore.EFactory; +import org.eclipse.emf.ecore.EPackage; + +import java.io.IOException; +import java.text.MessageFormat; + +/** + * @author Eike Stepper + */ +public class CDOPackageInfoImpl extends AdapterImpl implements InternalCDOPackageInfo +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDOPackageInfoImpl.class); + + private InternalCDOPackageUnit packageUnit; + + private String packageURI; + + private String parentURI; + + public CDOPackageInfoImpl() + { + } + + public InternalCDOPackageUnit getPackageUnit() + { + return packageUnit; + } + + public void setPackageUnit(InternalCDOPackageUnit packageUnit) + { + this.packageUnit = packageUnit; + } + + public String getPackageURI() + { + return packageURI; + } + + public void setPackageURI(String packageURI) + { + this.packageURI = packageURI; + } + + public String getParentURI() + { + return parentURI; + } + + public void setParentURI(String parentURI) + { + this.parentURI = parentURI; + } + + public void write(CDODataOutput out) throws IOException + { + if (TRACER.isEnabled()) + { + TRACER.format("Writing {0}", this); //$NON-NLS-1$ + } + + out.writeCDOPackageURI(packageURI); + out.writeCDOPackageURI(parentURI); + } + + public void read(CDODataInput in) throws IOException + { + packageURI = in.readCDOPackageURI(); + parentURI = in.readCDOPackageURI(); + if (TRACER.isEnabled()) + { + TRACER.format("Read {0}", this); //$NON-NLS-1$ + } + } + + public EFactory getEFactory() + { + return getEPackage().getEFactoryInstance(); + } + + public EPackage getEPackage() + { + return getEPackage(true); + } + + public EPackage getEPackage(boolean loadOnDemand) + { + return doGetEPackage(loadOnDemand); + } + + public EPackage doGetEPackage(boolean loadOnDemand) + { + EPackage ePackage = (EPackage)getTarget(); + if (ePackage != null) + { + return ePackage; + } + + if (loadOnDemand) + { + packageUnit.load(true); // TODO (CD) Dubious: is resolution-on-load really a good idea? + return (EPackage)getTarget(); + } + + return null; + } + + public boolean isCorePackage() + { + return CDOModelUtil.isCorePackage(getEPackage()); + } + + public boolean isResourcePackage() + { + return CDOModelUtil.isResourcePackage(getEPackage()); + } + + public boolean isTypePackage() + { + return CDOModelUtil.isTypesPackage(getEPackage()); + } + + public boolean isSystemPackage() + { + return CDOModelUtil.isSystemPackage(getEPackage()); + } + + public int compareTo(CDOPackageInfo o) + { + return getPackageURI().compareTo(o.getPackageURI()); + } + + @Override + public String toString() + { + return MessageFormat.format("CDOPackageInfo[packageURI={0}, parentURI={1}]", packageURI, parentURI); //$NON-NLS-1$ + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageRegistryImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageRegistryImpl.java index 8c07d0c508..ec91ad0e39 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageRegistryImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageRegistryImpl.java @@ -1,663 +1,663 @@ -/*
- * 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.internal.common.model;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit.State;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.internal.common.bundle.OM;
-import org.eclipse.emf.cdo.internal.common.messages.Messages;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
-
-import org.eclipse.net4j.util.CheckUtil;
-import org.eclipse.net4j.util.ImplementationError;
-import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
-import org.eclipse.net4j.util.event.EventUtil;
-import org.eclipse.net4j.util.event.IListener;
-import org.eclipse.net4j.util.lifecycle.LifecycleException;
-import org.eclipse.net4j.util.lifecycle.LifecycleState;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-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.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EEnum;
-import org.eclipse.emf.ecore.EEnumLiteral;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.impl.EPackageRegistryImpl;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- */
-public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements InternalCDOPackageRegistry
-{
- private static final long serialVersionUID = 1L;
-
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDOPackageRegistryImpl.class);
-
- private static final boolean eagerInternalCaches = false;
-
- private boolean replacingDescriptors;
-
- private PackageProcessor packageProcessor;
-
- private PackageLoader packageLoader;
-
- private transient boolean active;
-
- @ExcludeFromDump
- private transient InternalCDOPackageInfo[] packageInfos;
-
- @ExcludeFromDump
- private transient InternalCDOPackageUnit[] packageUnits;
-
- @ExcludeFromDump
- private transient Map<EClass, List<EClass>> subTypes;
-
- private Map<Enumerator, EEnumLiteral> enumLiterals = new HashMap<Enumerator, EEnumLiteral>();
-
- private Set<CDOPackageInfo> visitedPackages = new HashSet<CDOPackageInfo>();
-
- public CDOPackageRegistryImpl()
- {
- }
-
- public boolean isReplacingDescriptors()
- {
- return replacingDescriptors;
- }
-
- public void setReplacingDescriptors(boolean replacingDescriptors)
- {
- this.replacingDescriptors = replacingDescriptors;
- }
-
- public PackageProcessor getPackageProcessor()
- {
- return packageProcessor;
- }
-
- public void setPackageProcessor(PackageProcessor packageProcessor)
- {
- this.packageProcessor = packageProcessor;
- }
-
- public PackageLoader getPackageLoader()
- {
- return packageLoader;
- }
-
- public void setPackageLoader(PackageLoader packageLoader)
- {
- LifecycleUtil.checkInactive(this);
- this.packageLoader = packageLoader;
- }
-
- static int lockCount;
-
- @Override
- public Object get(Object key)
- {
- LifecycleUtil.checkActive(this);
- return super.get(key);
- }
-
- public synchronized Set<String> getAllKeys()
- {
- LifecycleUtil.checkActive(this);
- Set<String> result = new HashSet<String>();
- result.addAll(keySet());
- if (delegateRegistry != null)
- {
- if (delegateRegistry instanceof InternalCDOPackageRegistry)
- {
- result.addAll(((InternalCDOPackageRegistry)delegateRegistry).getAllKeys());
- }
- else
- {
- result.addAll(delegateRegistry.keySet());
- }
- }
-
- return result;
- }
-
- public synchronized Object getWithDelegation(String nsURI, boolean resolve)
- {
- LifecycleUtil.checkActive(this);
- Object result = getFrom(this, nsURI, resolve);
- if (result == null && delegateRegistry != null)
- {
- result = getFrom(delegateRegistry, nsURI, resolve);
- }
-
- return result;
- }
-
- private static Object getFrom(EPackage.Registry registry, String nsURI, boolean resolve)
- {
- if (resolve)
- {
- return registry.getEPackage(nsURI);
- }
-
- return registry.get(nsURI);
- }
-
- public synchronized Object basicPut(String nsURI, Object value)
- {
- LifecycleUtil.checkActive(this);
- if (TRACER.isEnabled())
- {
- TRACER.format("Registering {0} --> {1}", nsURI, value); //$NON-NLS-1$
- }
-
- if (packageProcessor != null)
- {
- value = packageProcessor.processPackage(value);
- }
-
- Object oldValue = get(nsURI);
- if (oldValue instanceof InternalCDOPackageInfo && value instanceof EPackage)
- {
- InternalCDOPackageInfo oldPackageInfo = (InternalCDOPackageInfo)oldValue;
- EPackage newValue = (EPackage)value;
- if (oldPackageInfo.getEPackage(false) == null)
- {
- EMFUtil.addAdapter(newValue, oldPackageInfo);
- oldPackageInfo.getPackageUnit().setState(CDOPackageUnit.State.LOADED);
- }
- }
- else if (oldValue instanceof EPackage && value instanceof InternalCDOPackageInfo)
- {
- EPackage oldPackage = (EPackage)oldValue;
- InternalCDOPackageInfo oldPackageInfo = getPackageInfo(oldPackage);
- InternalCDOPackageInfo newPackageInfo = (InternalCDOPackageInfo)value;
-
- InternalCDOPackageUnit oldPackageUnit = oldPackageInfo.getPackageUnit();
- InternalCDOPackageUnit newPackageUnit = newPackageInfo.getPackageUnit();
- if (oldPackageUnit.getState() == CDOPackageUnit.State.NEW
- && newPackageUnit.getState() != CDOPackageUnit.State.NEW)
- {
- oldPackageUnit.setState(CDOPackageUnit.State.LOADED);
- }
-
- // Keep old value!
- return null;
- }
-
- return super.put(nsURI, value);
- }
-
- @Override
- public synchronized Object put(String nsURI, Object value)
- {
- LifecycleUtil.checkActive(this);
- if (replacingDescriptors && value instanceof EPackage.Descriptor)
- {
- EPackage.Descriptor descriptor = (EPackage.Descriptor)value;
- value = descriptor.getEPackage();
- }
-
- if (value instanceof EPackage)
- {
- EPackage ePackage = (EPackage)value;
- InternalCDOPackageInfo packageInfo = getPackageInfo(ePackage);
- if (packageInfo == null)
- {
- initPackageUnit(ePackage);
- return null;
- }
- }
-
- return basicPut(nsURI, value);
- }
-
- public synchronized Object putEPackage(EPackage ePackage)
- {
- LifecycleUtil.checkActive(this);
- return put(ePackage.getNsURI(), ePackage);
- }
-
- public synchronized void putPackageUnit(InternalCDOPackageUnit packageUnit)
- {
- LifecycleUtil.checkActive(this);
- packageUnit.setPackageRegistry(this);
- for (InternalCDOPackageInfo packageInfo : packageUnit.getPackageInfos())
- {
- EPackage ePackage = packageInfo.getEPackage(false);
- if (ePackage != null)
- {
- EMFUtil.addAdapter(ePackage, packageInfo);
- basicPut(ePackage.getNsURI(), ePackage);
- }
- else
- {
- basicPut(packageInfo.getPackageURI(), packageInfo);
- }
- }
-
- resetInternalCaches();
- }
-
- public synchronized void putPackageUnits(InternalCDOPackageUnit[] packageUnits, State state)
- {
- LifecycleUtil.checkActive(this);
- for (InternalCDOPackageUnit packageUnit : packageUnits)
- {
- if (state != null)
- {
- packageUnit.setState(state);
- }
-
- putPackageUnit(packageUnit);
- }
- }
-
- public synchronized InternalCDOPackageInfo getPackageInfo(EPackage ePackage)
- {
- LifecycleUtil.checkActive(this);
-
- // Looks in the registry
- Object object = get(ePackage.getNsURI());
- if (object instanceof InternalCDOPackageInfo)
- {
- InternalCDOPackageInfo packageInfo = (InternalCDOPackageInfo)object;
- if (packageInfo.getPackageUnit().getPackageRegistry() == this)
- {
- return packageInfo;
- }
- }
-
- // Looks in the adapters
- synchronized (ePackage)
- {
- EList<Adapter> adapters = ePackage.eAdapters();
- for (int i = 0, size = adapters.size(); i < size; ++i)
- {
- Adapter adapter = adapters.get(i);
- if (adapter instanceof InternalCDOPackageInfo)
- {
- InternalCDOPackageInfo packageInfo = (InternalCDOPackageInfo)adapter;
- if (packageInfo.getPackageUnit().getPackageRegistry() == this)
- {
- return packageInfo;
- }
- }
- }
- }
-
- return null;
- }
-
- public synchronized InternalCDOPackageInfo[] getPackageInfos()
- {
- LifecycleUtil.checkActive(this);
- if (packageInfos == null)
- {
- List<InternalCDOPackageInfo> result = new ArrayList<InternalCDOPackageInfo>();
- for (Object value : values())
- {
- if (value instanceof InternalCDOPackageInfo)
- {
- result.add((InternalCDOPackageInfo)value);
- }
- else if (value instanceof EPackage)
- {
- InternalCDOPackageInfo packageInfo = getPackageInfo((EPackage)value);
- if (packageInfo != null)
- {
- result.add(packageInfo);
- }
- }
- }
-
- packageInfos = result.toArray(new InternalCDOPackageInfo[result.size()]);
- Arrays.sort(packageInfos);
- }
-
- return packageInfos;
- }
-
- public synchronized InternalCDOPackageUnit getPackageUnit(EPackage ePackage)
- {
- LifecycleUtil.checkActive(this);
- CDOPackageInfo packageInfo = getPackageInfo(ePackage);
- if (packageInfo == null)
- {
- putEPackage(ePackage);
- packageInfo = getPackageInfo(ePackage);
- if (packageInfo == null)
- {
- throw new ImplementationError(MessageFormat.format(Messages.getString("CDOPackageRegistryImpl.0"), ePackage)); //$NON-NLS-1$
- }
- }
-
- return (InternalCDOPackageUnit)packageInfo.getPackageUnit();
- }
-
- public synchronized InternalCDOPackageUnit getPackageUnit(String id)
- {
- LifecycleUtil.checkActive(this);
- for (Object value : values())
- {
- InternalCDOPackageUnit packageUnit = null;
- if (value instanceof InternalCDOPackageInfo)
- {
- packageUnit = ((InternalCDOPackageInfo)value).getPackageUnit();
- }
- else if (value instanceof EPackage)
- {
- InternalCDOPackageInfo packageInfo = getPackageInfo((EPackage)value);
- if (packageInfo != null)
- {
- packageUnit = packageInfo.getPackageUnit();
- }
- }
-
- if (packageUnit != null && id.equals(packageUnit.getID()))
- {
- return packageUnit;
- }
- }
-
- return null;
- }
-
- public synchronized InternalCDOPackageUnit[] getPackageUnits(long startTime, long endTime)
- {
- LifecycleUtil.checkActive(this);
- if (endTime == CDOBranchPoint.UNSPECIFIED_DATE)
- {
- endTime = Long.MAX_VALUE;
- }
-
- Set<InternalCDOPackageUnit> result = new HashSet<InternalCDOPackageUnit>();
- for (Object value : values())
- {
- InternalCDOPackageUnit packageUnit = null;
- if (value instanceof InternalCDOPackageInfo)
- {
- packageUnit = ((InternalCDOPackageInfo)value).getPackageUnit();
- }
- else if (value instanceof EPackage)
- {
- InternalCDOPackageInfo packageInfo = getPackageInfo((EPackage)value);
- if (packageInfo != null)
- {
- packageUnit = packageInfo.getPackageUnit();
- }
- }
-
- if (packageUnit != null)
- {
- long timeStamp = packageUnit.getTimeStamp();
- if (startTime <= timeStamp && timeStamp <= endTime)
- {
- result.add(packageUnit);
- }
- }
- }
-
- return result.toArray(new InternalCDOPackageUnit[result.size()]);
- }
-
- public synchronized InternalCDOPackageUnit[] getPackageUnits(boolean withSystemPackages)
- {
- LifecycleUtil.checkActive(this);
- return collectPackageUnits(withSystemPackages);
- }
-
- public synchronized InternalCDOPackageUnit[] getPackageUnits()
- {
- LifecycleUtil.checkActive(this);
- if (packageUnits == null)
- {
- packageUnits = collectPackageUnits(true);
- Arrays.sort(packageUnits);
- }
-
- return packageUnits;
- }
-
- private InternalCDOPackageUnit[] collectPackageUnits(boolean withSystemPackages)
- {
- Set<InternalCDOPackageUnit> result = new HashSet<InternalCDOPackageUnit>();
- for (Object value : values())
- {
- InternalCDOPackageUnit packageUnit = collectPackageUnit(value);
- if (packageUnit != null && (withSystemPackages || !packageUnit.isSystem()))
- {
- result.add(packageUnit);
- }
- }
-
- return result.toArray(new InternalCDOPackageUnit[result.size()]);
- }
-
- private InternalCDOPackageUnit collectPackageUnit(Object value)
- {
- if (value instanceof InternalCDOPackageInfo)
- {
- return ((InternalCDOPackageInfo)value).getPackageUnit();
- }
-
- if (value instanceof EPackage)
- {
- InternalCDOPackageInfo packageInfo = getPackageInfo((EPackage)value);
- if (packageInfo != null)
- {
- InternalCDOPackageUnit packageUnit = packageInfo.getPackageUnit();
- return packageUnit;
- }
- }
-
- return null;
- }
-
- public synchronized EPackage[] getEPackages()
- {
- LifecycleUtil.checkActive(this);
- List<EPackage> result = new ArrayList<EPackage>();
- for (String packageURI : keySet())
- {
- EPackage ePackage = getEPackage(packageURI);
- if (ePackage != null)
- {
- result.add(ePackage);
- }
- }
-
- return result.toArray(new EPackage[result.size()]);
- }
-
- public synchronized EEnumLiteral getEnumLiteralFor(Enumerator value)
- {
- LifecycleUtil.checkActive(this);
- EEnumLiteral result = enumLiterals.get(value);
- if (result != null)
- {
- return result;
- }
-
- for (CDOPackageUnit packageUnit : getPackageUnits())
- {
- for (CDOPackageInfo packageInfo : packageUnit.getPackageInfos())
- {
- if (visitedPackages.add(packageInfo))
- {
- result = visitPackage(packageInfo, value);
- if (result != null)
- {
- return result;
- }
- }
- }
- }
-
- return null;
- }
-
- private EEnumLiteral visitPackage(CDOPackageInfo packageInfo, Enumerator value)
- {
- EEnumLiteral result = null;
- for (EClassifier classifier : packageInfo.getEPackage().getEClassifiers())
- {
- if (classifier instanceof EEnum)
- {
- EEnum eenum = (EEnum)classifier;
- for (EEnumLiteral eEnumLiteral : eenum.getELiterals())
- {
- Enumerator instance = eEnumLiteral.getInstance();
- enumLiterals.put(instance, eEnumLiteral);
- if (instance == value)
- {
- result = eEnumLiteral;
- }
- }
- }
- }
-
- return result;
- }
-
- public synchronized Map<EClass, List<EClass>> getSubTypes()
- {
- LifecycleUtil.checkActive(this);
- if (subTypes == null)
- {
- subTypes = CDOModelUtil.getSubTypes(this);
- }
-
- return subTypes;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("{0}[packageLoader={1}]", getClass().getSimpleName(), getPackageLoader()); //$NON-NLS-1$
- }
-
- public void addListener(IListener listener)
- {
- // Do nothing
- }
-
- public void removeListener(IListener listener)
- {
- // Do nothing
- }
-
- public IListener[] getListeners()
- {
- return EventUtil.NO_LISTENERS;
- }
-
- public boolean hasListeners()
- {
- return false;
- }
-
- public synchronized boolean isActive()
- {
- return active;
- }
-
- public synchronized LifecycleState getLifecycleState()
- {
- return active ? LifecycleState.ACTIVE : LifecycleState.INACTIVE;
- }
-
- public synchronized void activate() throws LifecycleException
- {
- if (!active)
- {
- CheckUtil.checkState(packageLoader, "packageLoader"); //$NON-NLS-1$
- active = true;
- }
- }
-
- public synchronized Exception deactivate()
- {
- if (active)
- {
- try
- {
- disposePackageUnits();
- clear();
- active = false;
- }
- catch (RuntimeException ex)
- {
- return ex;
- }
- }
-
- return null;
- }
-
- protected void disposePackageUnits()
- {
- for (InternalCDOPackageUnit packageUnit : getPackageUnits())
- {
- packageUnit.dispose();
- }
-
- packageInfos = null;
- packageUnits = null;
- subTypes = null;
- }
-
- protected void initPackageUnit(EPackage ePackage)
- {
- InternalCDOPackageUnit packageUnit = createPackageUnit();
- packageUnit.init(ePackage);
- resetInternalCaches();
- }
-
- protected void resetInternalCaches()
- {
- packageInfos = null;
- packageUnits = null;
- subTypes = null;
- if (eagerInternalCaches)
- {
- getPackageInfos();
- getPackageUnits();
- getSubTypes();
- }
- }
-
- public InternalCDOPackageUnit createPackageUnit()
- {
- InternalCDOPackageUnit packageUnit = (InternalCDOPackageUnit)CDOModelUtil.createPackageUnit();
- packageUnit.setPackageRegistry(this);
- return packageUnit;
- }
-}
+/* + * 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.internal.common.model; + +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.model.CDOModelUtil; +import org.eclipse.emf.cdo.common.model.CDOPackageInfo; +import org.eclipse.emf.cdo.common.model.CDOPackageUnit; +import org.eclipse.emf.cdo.common.model.CDOPackageUnit.State; +import org.eclipse.emf.cdo.common.model.EMFUtil; +import org.eclipse.emf.cdo.internal.common.bundle.OM; +import org.eclipse.emf.cdo.internal.common.messages.Messages; +import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo; +import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry; +import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit; + +import org.eclipse.net4j.util.CheckUtil; +import org.eclipse.net4j.util.ImplementationError; +import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump; +import org.eclipse.net4j.util.event.EventUtil; +import org.eclipse.net4j.util.event.IListener; +import org.eclipse.net4j.util.lifecycle.LifecycleException; +import org.eclipse.net4j.util.lifecycle.LifecycleState; +import org.eclipse.net4j.util.lifecycle.LifecycleUtil; +import org.eclipse.net4j.util.om.trace.ContextTracer; + +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.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EEnum; +import org.eclipse.emf.ecore.EEnumLiteral; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.impl.EPackageRegistryImpl; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * @author Eike Stepper + */ +public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements InternalCDOPackageRegistry +{ + private static final long serialVersionUID = 1L; + + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDOPackageRegistryImpl.class); + + private static final boolean eagerInternalCaches = false; + + private boolean replacingDescriptors; + + private PackageProcessor packageProcessor; + + private PackageLoader packageLoader; + + private transient boolean active; + + @ExcludeFromDump + private transient InternalCDOPackageInfo[] packageInfos; + + @ExcludeFromDump + private transient InternalCDOPackageUnit[] packageUnits; + + @ExcludeFromDump + private transient Map<EClass, List<EClass>> subTypes; + + private Map<Enumerator, EEnumLiteral> enumLiterals = new HashMap<Enumerator, EEnumLiteral>(); + + private Set<CDOPackageInfo> visitedPackages = new HashSet<CDOPackageInfo>(); + + public CDOPackageRegistryImpl() + { + } + + public boolean isReplacingDescriptors() + { + return replacingDescriptors; + } + + public void setReplacingDescriptors(boolean replacingDescriptors) + { + this.replacingDescriptors = replacingDescriptors; + } + + public PackageProcessor getPackageProcessor() + { + return packageProcessor; + } + + public void setPackageProcessor(PackageProcessor packageProcessor) + { + this.packageProcessor = packageProcessor; + } + + public PackageLoader getPackageLoader() + { + return packageLoader; + } + + public void setPackageLoader(PackageLoader packageLoader) + { + LifecycleUtil.checkInactive(this); + this.packageLoader = packageLoader; + } + + static int lockCount; + + @Override + public Object get(Object key) + { + LifecycleUtil.checkActive(this); + return super.get(key); + } + + public synchronized Set<String> getAllKeys() + { + LifecycleUtil.checkActive(this); + Set<String> result = new HashSet<String>(); + result.addAll(keySet()); + if (delegateRegistry != null) + { + if (delegateRegistry instanceof InternalCDOPackageRegistry) + { + result.addAll(((InternalCDOPackageRegistry)delegateRegistry).getAllKeys()); + } + else + { + result.addAll(delegateRegistry.keySet()); + } + } + + return result; + } + + public synchronized Object getWithDelegation(String nsURI, boolean resolve) + { + LifecycleUtil.checkActive(this); + Object result = getFrom(this, nsURI, resolve); + if (result == null && delegateRegistry != null) + { + result = getFrom(delegateRegistry, nsURI, resolve); + } + + return result; + } + + private static Object getFrom(EPackage.Registry registry, String nsURI, boolean resolve) + { + if (resolve) + { + return registry.getEPackage(nsURI); + } + + return registry.get(nsURI); + } + + public synchronized Object basicPut(String nsURI, Object value) + { + LifecycleUtil.checkActive(this); + if (TRACER.isEnabled()) + { + TRACER.format("Registering {0} --> {1}", nsURI, value); //$NON-NLS-1$ + } + + if (packageProcessor != null) + { + value = packageProcessor.processPackage(value); + } + + Object oldValue = get(nsURI); + if (oldValue instanceof InternalCDOPackageInfo && value instanceof EPackage) + { + InternalCDOPackageInfo oldPackageInfo = (InternalCDOPackageInfo)oldValue; + EPackage newValue = (EPackage)value; + if (oldPackageInfo.getEPackage(false) == null) + { + EMFUtil.addAdapter(newValue, oldPackageInfo); + oldPackageInfo.getPackageUnit().setState(CDOPackageUnit.State.LOADED); + } + } + else if (oldValue instanceof EPackage && value instanceof InternalCDOPackageInfo) + { + EPackage oldPackage = (EPackage)oldValue; + InternalCDOPackageInfo oldPackageInfo = getPackageInfo(oldPackage); + InternalCDOPackageInfo newPackageInfo = (InternalCDOPackageInfo)value; + + InternalCDOPackageUnit oldPackageUnit = oldPackageInfo.getPackageUnit(); + InternalCDOPackageUnit newPackageUnit = newPackageInfo.getPackageUnit(); + if (oldPackageUnit.getState() == CDOPackageUnit.State.NEW + && newPackageUnit.getState() != CDOPackageUnit.State.NEW) + { + oldPackageUnit.setState(CDOPackageUnit.State.LOADED); + } + + // Keep old value! + return null; + } + + return super.put(nsURI, value); + } + + @Override + public synchronized Object put(String nsURI, Object value) + { + LifecycleUtil.checkActive(this); + if (replacingDescriptors && value instanceof EPackage.Descriptor) + { + EPackage.Descriptor descriptor = (EPackage.Descriptor)value; + value = descriptor.getEPackage(); + } + + if (value instanceof EPackage) + { + EPackage ePackage = (EPackage)value; + InternalCDOPackageInfo packageInfo = getPackageInfo(ePackage); + if (packageInfo == null) + { + initPackageUnit(ePackage); + return null; + } + } + + return basicPut(nsURI, value); + } + + public synchronized Object putEPackage(EPackage ePackage) + { + LifecycleUtil.checkActive(this); + return put(ePackage.getNsURI(), ePackage); + } + + public synchronized void putPackageUnit(InternalCDOPackageUnit packageUnit) + { + LifecycleUtil.checkActive(this); + packageUnit.setPackageRegistry(this); + for (InternalCDOPackageInfo packageInfo : packageUnit.getPackageInfos()) + { + EPackage ePackage = packageInfo.getEPackage(false); + if (ePackage != null) + { + EMFUtil.addAdapter(ePackage, packageInfo); + basicPut(ePackage.getNsURI(), ePackage); + } + else + { + basicPut(packageInfo.getPackageURI(), packageInfo); + } + } + + resetInternalCaches(); + } + + public synchronized void putPackageUnits(InternalCDOPackageUnit[] packageUnits, State state) + { + LifecycleUtil.checkActive(this); + for (InternalCDOPackageUnit packageUnit : packageUnits) + { + if (state != null) + { + packageUnit.setState(state); + } + + putPackageUnit(packageUnit); + } + } + + public synchronized InternalCDOPackageInfo getPackageInfo(EPackage ePackage) + { + LifecycleUtil.checkActive(this); + + // Looks in the registry + Object object = get(ePackage.getNsURI()); + if (object instanceof InternalCDOPackageInfo) + { + InternalCDOPackageInfo packageInfo = (InternalCDOPackageInfo)object; + if (packageInfo.getPackageUnit().getPackageRegistry() == this) + { + return packageInfo; + } + } + + // Looks in the adapters + synchronized (ePackage) + { + EList<Adapter> adapters = ePackage.eAdapters(); + for (int i = 0, size = adapters.size(); i < size; ++i) + { + Adapter adapter = adapters.get(i); + if (adapter instanceof InternalCDOPackageInfo) + { + InternalCDOPackageInfo packageInfo = (InternalCDOPackageInfo)adapter; + if (packageInfo.getPackageUnit().getPackageRegistry() == this) + { + return packageInfo; + } + } + } + } + + return null; + } + + public synchronized InternalCDOPackageInfo[] getPackageInfos() + { + LifecycleUtil.checkActive(this); + if (packageInfos == null) + { + List<InternalCDOPackageInfo> result = new ArrayList<InternalCDOPackageInfo>(); + for (Object value : values()) + { + if (value instanceof InternalCDOPackageInfo) + { + result.add((InternalCDOPackageInfo)value); + } + else if (value instanceof EPackage) + { + InternalCDOPackageInfo packageInfo = getPackageInfo((EPackage)value); + if (packageInfo != null) + { + result.add(packageInfo); + } + } + } + + packageInfos = result.toArray(new InternalCDOPackageInfo[result.size()]); + Arrays.sort(packageInfos); + } + + return packageInfos; + } + + public synchronized InternalCDOPackageUnit getPackageUnit(EPackage ePackage) + { + LifecycleUtil.checkActive(this); + CDOPackageInfo packageInfo = getPackageInfo(ePackage); + if (packageInfo == null) + { + putEPackage(ePackage); + packageInfo = getPackageInfo(ePackage); + if (packageInfo == null) + { + throw new ImplementationError(MessageFormat.format(Messages.getString("CDOPackageRegistryImpl.0"), ePackage)); //$NON-NLS-1$ + } + } + + return (InternalCDOPackageUnit)packageInfo.getPackageUnit(); + } + + public synchronized InternalCDOPackageUnit getPackageUnit(String id) + { + LifecycleUtil.checkActive(this); + for (Object value : values()) + { + InternalCDOPackageUnit packageUnit = null; + if (value instanceof InternalCDOPackageInfo) + { + packageUnit = ((InternalCDOPackageInfo)value).getPackageUnit(); + } + else if (value instanceof EPackage) + { + InternalCDOPackageInfo packageInfo = getPackageInfo((EPackage)value); + if (packageInfo != null) + { + packageUnit = packageInfo.getPackageUnit(); + } + } + + if (packageUnit != null && id.equals(packageUnit.getID())) + { + return packageUnit; + } + } + + return null; + } + + public synchronized InternalCDOPackageUnit[] getPackageUnits(long startTime, long endTime) + { + LifecycleUtil.checkActive(this); + if (endTime == CDOBranchPoint.UNSPECIFIED_DATE) + { + endTime = Long.MAX_VALUE; + } + + Set<InternalCDOPackageUnit> result = new HashSet<InternalCDOPackageUnit>(); + for (Object value : values()) + { + InternalCDOPackageUnit packageUnit = null; + if (value instanceof InternalCDOPackageInfo) + { + packageUnit = ((InternalCDOPackageInfo)value).getPackageUnit(); + } + else if (value instanceof EPackage) + { + InternalCDOPackageInfo packageInfo = getPackageInfo((EPackage)value); + if (packageInfo != null) + { + packageUnit = packageInfo.getPackageUnit(); + } + } + + if (packageUnit != null) + { + long timeStamp = packageUnit.getTimeStamp(); + if (startTime <= timeStamp && timeStamp <= endTime) + { + result.add(packageUnit); + } + } + } + + return result.toArray(new InternalCDOPackageUnit[result.size()]); + } + + public synchronized InternalCDOPackageUnit[] getPackageUnits(boolean withSystemPackages) + { + LifecycleUtil.checkActive(this); + return collectPackageUnits(withSystemPackages); + } + + public synchronized InternalCDOPackageUnit[] getPackageUnits() + { + LifecycleUtil.checkActive(this); + if (packageUnits == null) + { + packageUnits = collectPackageUnits(true); + Arrays.sort(packageUnits); + } + + return packageUnits; + } + + private InternalCDOPackageUnit[] collectPackageUnits(boolean withSystemPackages) + { + Set<InternalCDOPackageUnit> result = new HashSet<InternalCDOPackageUnit>(); + for (Object value : values()) + { + InternalCDOPackageUnit packageUnit = collectPackageUnit(value); + if (packageUnit != null && (withSystemPackages || !packageUnit.isSystem())) + { + result.add(packageUnit); + } + } + + return result.toArray(new InternalCDOPackageUnit[result.size()]); + } + + private InternalCDOPackageUnit collectPackageUnit(Object value) + { + if (value instanceof InternalCDOPackageInfo) + { + return ((InternalCDOPackageInfo)value).getPackageUnit(); + } + + if (value instanceof EPackage) + { + InternalCDOPackageInfo packageInfo = getPackageInfo((EPackage)value); + if (packageInfo != null) + { + InternalCDOPackageUnit packageUnit = packageInfo.getPackageUnit(); + return packageUnit; + } + } + + return null; + } + + public synchronized EPackage[] getEPackages() + { + LifecycleUtil.checkActive(this); + List<EPackage> result = new ArrayList<EPackage>(); + for (String packageURI : keySet()) + { + EPackage ePackage = getEPackage(packageURI); + if (ePackage != null) + { + result.add(ePackage); + } + } + + return result.toArray(new EPackage[result.size()]); + } + + public synchronized EEnumLiteral getEnumLiteralFor(Enumerator value) + { + LifecycleUtil.checkActive(this); + EEnumLiteral result = enumLiterals.get(value); + if (result != null) + { + return result; + } + + for (CDOPackageUnit packageUnit : getPackageUnits()) + { + for (CDOPackageInfo packageInfo : packageUnit.getPackageInfos()) + { + if (visitedPackages.add(packageInfo)) + { + result = visitPackage(packageInfo, value); + if (result != null) + { + return result; + } + } + } + } + + return null; + } + + private EEnumLiteral visitPackage(CDOPackageInfo packageInfo, Enumerator value) + { + EEnumLiteral result = null; + for (EClassifier classifier : packageInfo.getEPackage().getEClassifiers()) + { + if (classifier instanceof EEnum) + { + EEnum eenum = (EEnum)classifier; + for (EEnumLiteral eEnumLiteral : eenum.getELiterals()) + { + Enumerator instance = eEnumLiteral.getInstance(); + enumLiterals.put(instance, eEnumLiteral); + if (instance == value) + { + result = eEnumLiteral; + } + } + } + } + + return result; + } + + public synchronized Map<EClass, List<EClass>> getSubTypes() + { + LifecycleUtil.checkActive(this); + if (subTypes == null) + { + subTypes = CDOModelUtil.getSubTypes(this); + } + + return subTypes; + } + + @Override + public String toString() + { + return MessageFormat.format("{0}[packageLoader={1}]", getClass().getSimpleName(), getPackageLoader()); //$NON-NLS-1$ + } + + public void addListener(IListener listener) + { + // Do nothing + } + + public void removeListener(IListener listener) + { + // Do nothing + } + + public IListener[] getListeners() + { + return EventUtil.NO_LISTENERS; + } + + public boolean hasListeners() + { + return false; + } + + public synchronized boolean isActive() + { + return active; + } + + public synchronized LifecycleState getLifecycleState() + { + return active ? LifecycleState.ACTIVE : LifecycleState.INACTIVE; + } + + public synchronized void activate() throws LifecycleException + { + if (!active) + { + CheckUtil.checkState(packageLoader, "packageLoader"); //$NON-NLS-1$ + active = true; + } + } + + public synchronized Exception deactivate() + { + if (active) + { + try + { + disposePackageUnits(); + clear(); + active = false; + } + catch (RuntimeException ex) + { + return ex; + } + } + + return null; + } + + protected void disposePackageUnits() + { + for (InternalCDOPackageUnit packageUnit : getPackageUnits()) + { + packageUnit.dispose(); + } + + packageInfos = null; + packageUnits = null; + subTypes = null; + } + + protected void initPackageUnit(EPackage ePackage) + { + InternalCDOPackageUnit packageUnit = createPackageUnit(); + packageUnit.init(ePackage); + resetInternalCaches(); + } + + protected void resetInternalCaches() + { + packageInfos = null; + packageUnits = null; + subTypes = null; + if (eagerInternalCaches) + { + getPackageInfos(); + getPackageUnits(); + getSubTypes(); + } + } + + public InternalCDOPackageUnit createPackageUnit() + { + InternalCDOPackageUnit packageUnit = (InternalCDOPackageUnit)CDOModelUtil.createPackageUnit(); + packageUnit.setPackageRegistry(this); + return packageUnit; + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageUnitImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageUnitImpl.java index bd0106bea3..db20245bf3 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageUnitImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/CDOPackageUnitImpl.java @@ -1,393 +1,393 @@ -/*
- * 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.internal.common.model;
-
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.CDOPackageTypeRegistry;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.model.EMFUtil;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-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.emf.cdo.internal.common.messages.Messages;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry.PackageLoader;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
-
-import org.eclipse.net4j.util.CheckUtil;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class CDOPackageUnitImpl implements InternalCDOPackageUnit
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDOPackageUnitImpl.class);
-
- private InternalCDOPackageRegistry packageRegistry;
-
- private State state = State.PROXY;
-
- private Type type;
-
- private Type originalType;
-
- private long timeStamp;
-
- private InternalCDOPackageInfo[] packageInfos;
-
- public CDOPackageUnitImpl()
- {
- }
-
- public InternalCDOPackageRegistry getPackageRegistry()
- {
- return packageRegistry;
- }
-
- public void setPackageRegistry(InternalCDOPackageRegistry packageRegistry)
- {
- this.packageRegistry = packageRegistry;
- }
-
- public String getID()
- {
- try
- {
- return getTopLevelPackageInfo().getPackageURI();
- }
- catch (RuntimeException ex)
- {
- return Messages.getString("CDOPackageUnitImpl.0"); //$NON-NLS-1$
- }
- }
-
- public State getState()
- {
- return state;
- }
-
- public void setState(State state)
- {
- this.state = state;
- if (state == State.LOADED)
- {
- type = null;
- }
- }
-
- public Type getType()
- {
- if (getOriginalType() == Type.DYNAMIC)
- {
- type = Type.DYNAMIC;
- }
- else if (type == null || type == Type.UNKNOWN)
- {
- if (state == State.PROXY)
- {
- type = CDOPackageTypeRegistry.INSTANCE.lookup(getID());
- }
- else
- {
- InternalCDOPackageInfo packageInfo = getTopLevelPackageInfo();
- EPackage ePackage = packageInfo.getEPackage();
- type = CDOPackageTypeRegistry.INSTANCE.lookup(ePackage);
- }
-
- if (type == null)
- {
- type = Type.UNKNOWN;
- }
- }
-
- return type;
- }
-
- public Type getOriginalType()
- {
- return originalType;
- }
-
- public void setOriginalType(Type originalType)
- {
- this.originalType = originalType;
- }
-
- public long getTimeStamp()
- {
- return timeStamp;
- }
-
- public void setTimeStamp(long timeStamp)
- {
- this.timeStamp = timeStamp;
- }
-
- public InternalCDOPackageInfo getTopLevelPackageInfo()
- {
- if (packageInfos == null || packageInfos.length == 0)
- {
- throw new IllegalStateException(Messages.getString("CDOPackageUnitImpl.1")); //$NON-NLS-1$
- }
-
- return packageInfos[0];
- }
-
- public InternalCDOPackageInfo getPackageInfo(String packageURI)
- {
- for (InternalCDOPackageInfo packageInfo : packageInfos)
- {
- if (packageInfo.getPackageURI().equals(packageURI))
- {
- return packageInfo;
- }
- }
-
- return null;
- }
-
- public InternalCDOPackageInfo[] getPackageInfos()
- {
- return packageInfos;
- }
-
- public void setPackageInfos(InternalCDOPackageInfo[] packageInfos)
- {
- this.packageInfos = packageInfos;
- for (InternalCDOPackageInfo packageInfo : packageInfos)
- {
- packageInfo.setPackageUnit(this);
- }
- }
-
- public EPackage[] getEPackages(boolean loadOnDemand)
- {
- List<EPackage> result = new ArrayList<EPackage>();
- for (InternalCDOPackageInfo packageInfo : packageInfos)
- {
- EPackage ePackage = packageInfo.getEPackage(loadOnDemand);
- if (ePackage != null)
- {
- result.add(ePackage);
- }
- }
-
- return result.toArray(new EPackage[result.size()]);
- }
-
- public boolean isSystem()
- {
- return getTopLevelPackageInfo().isSystemPackage();
- }
-
- public boolean isResource()
- {
- return getTopLevelPackageInfo().isResourcePackage();
- }
-
- public void init(EPackage ePackage)
- {
- EPackage topLevelPackage = EMFUtil.getTopLevelPackage(ePackage);
- List<InternalCDOPackageInfo> result = new ArrayList<InternalCDOPackageInfo>();
- initPackageInfos(topLevelPackage, result);
- packageInfos = result.toArray(new InternalCDOPackageInfo[result.size()]);
-
- setState(State.NEW);
- setOriginalType(getType());
- }
-
- public void dispose()
- {
- for (InternalCDOPackageInfo packageInfo : packageInfos)
- {
- EPackage ePackage = packageInfo.getEPackage(false);
- if (ePackage != null)
- {
- synchronized (ePackage)
- {
- ePackage.eAdapters().remove(packageInfo);
- }
- }
- }
-
- packageInfos = null;
- setState(State.DISPOSED);
- }
-
- public synchronized void load(boolean resolve)
- {
- load(packageRegistry.getPackageLoader(), resolve);
- }
-
- public synchronized void load(PackageLoader packageLoader, boolean resolve)
- {
- if (state == State.PROXY)
- {
- EPackage[] ePackages = null;
- ePackages = loadPackagesFromGlobalRegistry();
- if (ePackages == null)
- {
- ePackages = packageLoader.loadPackages(this);
- }
-
- for (EPackage ePackage : ePackages)
- {
- String packageURI = ePackage.getNsURI();
- InternalCDOPackageInfo packageInfo = getPackageInfo(packageURI);
- synchronized (ePackage)
- {
- EMFUtil.addAdapter(ePackage, packageInfo);
- if (resolve)
- {
- EcoreUtil.resolveAll(ePackage);
- }
- }
- }
-
- setState(State.LOADED);
- }
- }
-
- public void write(CDODataOutput out, boolean withPackages) throws IOException
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Writing {0}", this); //$NON-NLS-1$
- }
-
- out.writeBoolean(withPackages);
- if (withPackages)
- {
- CDOModelUtil.writePackage(out, packageInfos[0].getEPackage(), true, packageRegistry);
- }
-
- out.writeCDOPackageUnitType(originalType);
- out.writeLong(timeStamp);
- out.writeInt(packageInfos.length);
- for (InternalCDOPackageInfo packageInfo : packageInfos)
- {
- out.writeCDOPackageInfo(packageInfo);
- }
- }
-
- public void read(CDODataInput in, ResourceSet resourceSet) throws IOException
- {
- EPackage ePackage = null;
- boolean withPackages = in.readBoolean();
- if (withPackages)
- {
- CheckUtil.checkArg(resourceSet, "resourceSet"); //$NON-NLS-1$
- CheckUtil.checkNull(resourceSet.getPackageRegistry(), "ResourceSet's packageRegistry == null");
- ePackage = CDOModelUtil.readPackage(in, resourceSet, true);
- EPackage globalPackage = loadPackageFromGlobalRegistry(ePackage.getNsURI());
- if (globalPackage != null)
- {
- ePackage = globalPackage;
- }
-
- setState(State.LOADED);
- }
-
- originalType = in.readCDOPackageUnitType();
- timeStamp = in.readLong();
- packageInfos = new InternalCDOPackageInfo[in.readInt()];
- for (int i = 0; i < packageInfos.length; i++)
- {
- packageInfos[i] = (InternalCDOPackageInfo)in.readCDOPackageInfo();
- packageInfos[i].setPackageUnit(this);
- }
-
- if (ePackage != null)
- {
- attachPackageInfos(ePackage);
- }
-
- if (TRACER.isEnabled())
- {
- TRACER.format("Read {0}", this); //$NON-NLS-1$
- }
- }
-
- public int compareTo(CDOPackageUnit o)
- {
- return getID().compareTo(o.getID());
- }
-
- @Override
- public String toString()
- {
- String fmt = "CDOPackageUnit[id={0}, state={1}, type={2}, originalType={3}, timeStamp={4}]"; //$NON-NLS-1$
- return MessageFormat.format(fmt, getID(), getState(), getType(), getOriginalType(),
- CDOCommonUtil.formatTimeStamp(getTimeStamp()));
- }
-
- private void initPackageInfos(EPackage ePackage, List<InternalCDOPackageInfo> result)
- {
- InternalCDOPackageInfo packageInfo = (InternalCDOPackageInfo)CDOModelUtil.createPackageInfo();
- packageInfo.setPackageUnit(this);
- packageInfo.setPackageURI(ePackage.getNsURI());
- packageInfo.setParentURI(ePackage.getESuperPackage() == null ? null : ePackage.getESuperPackage().getNsURI());
- EMFUtil.addAdapter(ePackage, packageInfo);
-
- packageRegistry.basicPut(ePackage.getNsURI(), ePackage);
- result.add(packageInfo);
- for (EPackage subPackage : ePackage.getESubpackages())
- {
- initPackageInfos(subPackage, result);
- }
- }
-
- private void attachPackageInfos(EPackage ePackage)
- {
- InternalCDOPackageInfo packageInfo = getPackageInfo(ePackage.getNsURI());
- if (packageInfo != null)
- {
- EMFUtil.addAdapter(ePackage, packageInfo);
- }
-
- for (EPackage subPackage : ePackage.getESubpackages())
- {
- attachPackageInfos(subPackage);
- }
- }
-
- private EPackage[] loadPackagesFromGlobalRegistry()
- {
- EPackage[] ePackages = new EPackage[packageInfos.length];
- for (int i = 0; i < ePackages.length; i++)
- {
- ePackages[i] = loadPackageFromGlobalRegistry(packageInfos[i].getPackageURI());
- if (ePackages[i] == null)
- {
- return null;
- }
- }
-
- return ePackages;
- }
-
- private EPackage loadPackageFromGlobalRegistry(String packageURI)
- {
- return EPackage.Registry.INSTANCE.getEPackage(packageURI);
- }
-}
+/* + * 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.internal.common.model; + +import org.eclipse.emf.cdo.common.model.CDOModelUtil; +import org.eclipse.emf.cdo.common.model.CDOPackageTypeRegistry; +import org.eclipse.emf.cdo.common.model.CDOPackageUnit; +import org.eclipse.emf.cdo.common.model.EMFUtil; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +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.emf.cdo.internal.common.messages.Messages; +import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageInfo; +import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry; +import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry.PackageLoader; +import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit; + +import org.eclipse.net4j.util.CheckUtil; +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.util.EcoreUtil; + +import java.io.IOException; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class CDOPackageUnitImpl implements InternalCDOPackageUnit +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, CDOPackageUnitImpl.class); + + private InternalCDOPackageRegistry packageRegistry; + + private State state = State.PROXY; + + private Type type; + + private Type originalType; + + private long timeStamp; + + private InternalCDOPackageInfo[] packageInfos; + + public CDOPackageUnitImpl() + { + } + + public InternalCDOPackageRegistry getPackageRegistry() + { + return packageRegistry; + } + + public void setPackageRegistry(InternalCDOPackageRegistry packageRegistry) + { + this.packageRegistry = packageRegistry; + } + + public String getID() + { + try + { + return getTopLevelPackageInfo().getPackageURI(); + } + catch (RuntimeException ex) + { + return Messages.getString("CDOPackageUnitImpl.0"); //$NON-NLS-1$ + } + } + + public State getState() + { + return state; + } + + public void setState(State state) + { + this.state = state; + if (state == State.LOADED) + { + type = null; + } + } + + public Type getType() + { + if (getOriginalType() == Type.DYNAMIC) + { + type = Type.DYNAMIC; + } + else if (type == null || type == Type.UNKNOWN) + { + if (state == State.PROXY) + { + type = CDOPackageTypeRegistry.INSTANCE.lookup(getID()); + } + else + { + InternalCDOPackageInfo packageInfo = getTopLevelPackageInfo(); + EPackage ePackage = packageInfo.getEPackage(); + type = CDOPackageTypeRegistry.INSTANCE.lookup(ePackage); + } + + if (type == null) + { + type = Type.UNKNOWN; + } + } + + return type; + } + + public Type getOriginalType() + { + return originalType; + } + + public void setOriginalType(Type originalType) + { + this.originalType = originalType; + } + + public long getTimeStamp() + { + return timeStamp; + } + + public void setTimeStamp(long timeStamp) + { + this.timeStamp = timeStamp; + } + + public InternalCDOPackageInfo getTopLevelPackageInfo() + { + if (packageInfos == null || packageInfos.length == 0) + { + throw new IllegalStateException(Messages.getString("CDOPackageUnitImpl.1")); //$NON-NLS-1$ + } + + return packageInfos[0]; + } + + public InternalCDOPackageInfo getPackageInfo(String packageURI) + { + for (InternalCDOPackageInfo packageInfo : packageInfos) + { + if (packageInfo.getPackageURI().equals(packageURI)) + { + return packageInfo; + } + } + + return null; + } + + public InternalCDOPackageInfo[] getPackageInfos() + { + return packageInfos; + } + + public void setPackageInfos(InternalCDOPackageInfo[] packageInfos) + { + this.packageInfos = packageInfos; + for (InternalCDOPackageInfo packageInfo : packageInfos) + { + packageInfo.setPackageUnit(this); + } + } + + public EPackage[] getEPackages(boolean loadOnDemand) + { + List<EPackage> result = new ArrayList<EPackage>(); + for (InternalCDOPackageInfo packageInfo : packageInfos) + { + EPackage ePackage = packageInfo.getEPackage(loadOnDemand); + if (ePackage != null) + { + result.add(ePackage); + } + } + + return result.toArray(new EPackage[result.size()]); + } + + public boolean isSystem() + { + return getTopLevelPackageInfo().isSystemPackage(); + } + + public boolean isResource() + { + return getTopLevelPackageInfo().isResourcePackage(); + } + + public void init(EPackage ePackage) + { + EPackage topLevelPackage = EMFUtil.getTopLevelPackage(ePackage); + List<InternalCDOPackageInfo> result = new ArrayList<InternalCDOPackageInfo>(); + initPackageInfos(topLevelPackage, result); + packageInfos = result.toArray(new InternalCDOPackageInfo[result.size()]); + + setState(State.NEW); + setOriginalType(getType()); + } + + public void dispose() + { + for (InternalCDOPackageInfo packageInfo : packageInfos) + { + EPackage ePackage = packageInfo.getEPackage(false); + if (ePackage != null) + { + synchronized (ePackage) + { + ePackage.eAdapters().remove(packageInfo); + } + } + } + + packageInfos = null; + setState(State.DISPOSED); + } + + public synchronized void load(boolean resolve) + { + load(packageRegistry.getPackageLoader(), resolve); + } + + public synchronized void load(PackageLoader packageLoader, boolean resolve) + { + if (state == State.PROXY) + { + EPackage[] ePackages = null; + ePackages = loadPackagesFromGlobalRegistry(); + if (ePackages == null) + { + ePackages = packageLoader.loadPackages(this); + } + + for (EPackage ePackage : ePackages) + { + String packageURI = ePackage.getNsURI(); + InternalCDOPackageInfo packageInfo = getPackageInfo(packageURI); + synchronized (ePackage) + { + EMFUtil.addAdapter(ePackage, packageInfo); + if (resolve) + { + EcoreUtil.resolveAll(ePackage); + } + } + } + + setState(State.LOADED); + } + } + + public void write(CDODataOutput out, boolean withPackages) throws IOException + { + if (TRACER.isEnabled()) + { + TRACER.format("Writing {0}", this); //$NON-NLS-1$ + } + + out.writeBoolean(withPackages); + if (withPackages) + { + CDOModelUtil.writePackage(out, packageInfos[0].getEPackage(), true, packageRegistry); + } + + out.writeCDOPackageUnitType(originalType); + out.writeLong(timeStamp); + out.writeInt(packageInfos.length); + for (InternalCDOPackageInfo packageInfo : packageInfos) + { + out.writeCDOPackageInfo(packageInfo); + } + } + + public void read(CDODataInput in, ResourceSet resourceSet) throws IOException + { + EPackage ePackage = null; + boolean withPackages = in.readBoolean(); + if (withPackages) + { + CheckUtil.checkArg(resourceSet, "resourceSet"); //$NON-NLS-1$ + CheckUtil.checkNull(resourceSet.getPackageRegistry(), "ResourceSet's packageRegistry == null"); + ePackage = CDOModelUtil.readPackage(in, resourceSet, true); + EPackage globalPackage = loadPackageFromGlobalRegistry(ePackage.getNsURI()); + if (globalPackage != null) + { + ePackage = globalPackage; + } + + setState(State.LOADED); + } + + originalType = in.readCDOPackageUnitType(); + timeStamp = in.readLong(); + packageInfos = new InternalCDOPackageInfo[in.readInt()]; + for (int i = 0; i < packageInfos.length; i++) + { + packageInfos[i] = (InternalCDOPackageInfo)in.readCDOPackageInfo(); + packageInfos[i].setPackageUnit(this); + } + + if (ePackage != null) + { + attachPackageInfos(ePackage); + } + + if (TRACER.isEnabled()) + { + TRACER.format("Read {0}", this); //$NON-NLS-1$ + } + } + + public int compareTo(CDOPackageUnit o) + { + return getID().compareTo(o.getID()); + } + + @Override + public String toString() + { + String fmt = "CDOPackageUnit[id={0}, state={1}, type={2}, originalType={3}, timeStamp={4}]"; //$NON-NLS-1$ + return MessageFormat.format(fmt, getID(), getState(), getType(), getOriginalType(), + CDOCommonUtil.formatTimeStamp(getTimeStamp())); + } + + private void initPackageInfos(EPackage ePackage, List<InternalCDOPackageInfo> result) + { + InternalCDOPackageInfo packageInfo = (InternalCDOPackageInfo)CDOModelUtil.createPackageInfo(); + packageInfo.setPackageUnit(this); + packageInfo.setPackageURI(ePackage.getNsURI()); + packageInfo.setParentURI(ePackage.getESuperPackage() == null ? null : ePackage.getESuperPackage().getNsURI()); + EMFUtil.addAdapter(ePackage, packageInfo); + + packageRegistry.basicPut(ePackage.getNsURI(), ePackage); + result.add(packageInfo); + for (EPackage subPackage : ePackage.getESubpackages()) + { + initPackageInfos(subPackage, result); + } + } + + private void attachPackageInfos(EPackage ePackage) + { + InternalCDOPackageInfo packageInfo = getPackageInfo(ePackage.getNsURI()); + if (packageInfo != null) + { + EMFUtil.addAdapter(ePackage, packageInfo); + } + + for (EPackage subPackage : ePackage.getESubpackages()) + { + attachPackageInfos(subPackage); + } + } + + private EPackage[] loadPackagesFromGlobalRegistry() + { + EPackage[] ePackages = new EPackage[packageInfos.length]; + for (int i = 0; i < ePackages.length; i++) + { + ePackages[i] = loadPackageFromGlobalRegistry(packageInfos[i].getPackageURI()); + if (ePackages[i] == null) + { + return null; + } + } + + return ePackages; + } + + private EPackage loadPackageFromGlobalRegistry(String packageURI) + { + return EPackage.Registry.INSTANCE.getEPackage(packageURI); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/GenUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/GenUtil.java index 14794fe6b5..9e4cb8d1c7 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/GenUtil.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/model/GenUtil.java @@ -1,213 +1,213 @@ -/*
- * 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.internal.common.model;
-
-import org.eclipse.net4j.util.StringUtil;
-
-import org.eclipse.emf.ecore.EClassifier;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public final class GenUtil
-{
- private GenUtil()
- {
- }
-
- /**
- * See GenGenBaseImpl.isPrimitiveType
- */
- public static boolean isPrimitiveType(EClassifier eType)
- {
- try
- {
- // J9 2.2 has problems assigning null to a Class variable.
- Object result = eType.getInstanceClass();
- if (result == null)
- {
- return false;
- }
-
- Class<?> instanceClass = (Class<?>)result;
- return instanceClass.isPrimitive();
- }
- catch (Exception e)
- {
- return false;
- }
- }
-
- /**
- * See GenFeatureImpl.getUpperName
- */
- public static String getFeatureUpperName(String featureName)
- {
- return format(featureName, '_', null, false, true).toUpperCase();
- }
-
- /**
- * See GenFeatureImpl.getGetAccessor
- */
- public static String getFeatureGetterName(String featureName, boolean isBooleanType)
- {
- String capName = StringUtil.cap(featureName);
- // if (isMapEntryFeature())
- // return "getTyped" + capName;
- String result = isBooleanType ? "is" + capName : "get" + ("Class".equals(capName) ? "Class_" : capName); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- // if (isListType() && !isFeatureMapType() && !isMapType() &&
- // getGenModel().isArrayAccessors())
- // {
- // result += "List";
- // }
-
- // GenClass rootImplementsInterface =
- // getGenModel().getRootImplementsInterfaceGenClass();
- // GenClass context = getContext();
- // if (rootImplementsInterface != null &&
- // !rootImplementsInterface.isEObject())
- // {
- // for (GenOperation genOperation :
- // rootImplementsInterface.getAllGenOperations())
- // {
- // if (genOperation.getName().equals(result) &&
- // genOperation.getGenParameters().isEmpty() &&
- // !genOperation.getType(context).equals(getType(context)))
- // {
- // result = result + "_";
- // break;
- // }
- // }
- // }
-
- return result;
- }
-
- /**
- * Formats a name by parsing it into words separated by underscores and/or mixed-casing and then recombining them
- * using the specified separator. A prefix can also be given to be recognized as a separate word or to be trimmed.
- * Leading underscores can be ignored or can cause a leading separator to be prepended.
- */
- public static String format(String name, char separator, String prefix, boolean includePrefix,
- boolean includeLeadingSeparator)
- {
- String leadingSeparators = includeLeadingSeparator ? getLeadingSeparators(name, '_') : null;
- if (leadingSeparators != null)
- {
- name = name.substring(leadingSeparators.length());
- }
-
- List<String> parsedName = new ArrayList<String>();
- if (prefix != null && name.startsWith(prefix) && name.length() > prefix.length()
- && Character.isUpperCase(name.charAt(prefix.length())))
- {
- name = name.substring(prefix.length());
- if (includePrefix)
- {
- parsedName = parseName(prefix, '_');
- }
- }
-
- if (name.length() != 0)
- {
- parsedName.addAll(parseName(name, '_'));
- }
-
- StringBuilder result = new StringBuilder();
-
- for (Iterator<String> nameIter = parsedName.iterator(); nameIter.hasNext();)
- {
- String nameComponent = nameIter.next();
- result.append(nameComponent);
-
- if (nameIter.hasNext() && nameComponent.length() > 1)
- {
- result.append(separator);
- }
- }
-
- if (result.length() == 0 && prefix != null)
- {
- result.append(prefix);
- }
-
- return leadingSeparators != null ? "_" + result.toString() : result.toString(); //$NON-NLS-1$
- }
-
- /**
- * This method breaks sourceName into words delimited by separator and/or mixed-case naming.
- */
- public static List<String> parseName(String sourceName, char separator)
- {
- List<String> result = new ArrayList<String>();
- if (sourceName != null)
- {
- StringBuilder currentWord = new StringBuilder();
- boolean lastIsLower = false;
- for (int index = 0, length = sourceName.length(); index < length; ++index)
- {
- char curChar = sourceName.charAt(index);
- if (Character.isUpperCase(curChar) || !lastIsLower && Character.isDigit(curChar) || curChar == separator)
- {
- if (lastIsLower && currentWord.length() > 1 || curChar == separator && currentWord.length() > 0)
- {
- result.add(currentWord.toString());
- currentWord = new StringBuilder();
- }
-
- lastIsLower = false;
- }
- else
- {
- if (!lastIsLower)
- {
- int currentWordLength = currentWord.length();
- if (currentWordLength > 1)
- {
- char lastChar = currentWord.charAt(--currentWordLength);
- currentWord.setLength(currentWordLength);
- result.add(currentWord.toString());
- currentWord = new StringBuilder();
- currentWord.append(lastChar);
- }
- }
-
- lastIsLower = true;
- }
-
- if (curChar != separator)
- {
- currentWord.append(curChar);
- }
- }
-
- result.add(currentWord.toString());
- }
-
- return result;
- }
-
- private static String getLeadingSeparators(String name, char separator)
- {
- int i = 0;
- for (int len = name.length(); i < len && name.charAt(i) == separator; i++)
- {
- // the for loop's condition finds the separator
- }
-
- return i != 0 ? name.substring(0, i) : 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 + */ +package org.eclipse.emf.cdo.internal.common.model; + +import org.eclipse.net4j.util.StringUtil; + +import org.eclipse.emf.ecore.EClassifier; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * @author Eike Stepper + */ +public final class GenUtil +{ + private GenUtil() + { + } + + /** + * See GenGenBaseImpl.isPrimitiveType + */ + public static boolean isPrimitiveType(EClassifier eType) + { + try + { + // J9 2.2 has problems assigning null to a Class variable. + Object result = eType.getInstanceClass(); + if (result == null) + { + return false; + } + + Class<?> instanceClass = (Class<?>)result; + return instanceClass.isPrimitive(); + } + catch (Exception e) + { + return false; + } + } + + /** + * See GenFeatureImpl.getUpperName + */ + public static String getFeatureUpperName(String featureName) + { + return format(featureName, '_', null, false, true).toUpperCase(); + } + + /** + * See GenFeatureImpl.getGetAccessor + */ + public static String getFeatureGetterName(String featureName, boolean isBooleanType) + { + String capName = StringUtil.cap(featureName); + // if (isMapEntryFeature()) + // return "getTyped" + capName; + String result = isBooleanType ? "is" + capName : "get" + ("Class".equals(capName) ? "Class_" : capName); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ + + // if (isListType() && !isFeatureMapType() && !isMapType() && + // getGenModel().isArrayAccessors()) + // { + // result += "List"; + // } + + // GenClass rootImplementsInterface = + // getGenModel().getRootImplementsInterfaceGenClass(); + // GenClass context = getContext(); + // if (rootImplementsInterface != null && + // !rootImplementsInterface.isEObject()) + // { + // for (GenOperation genOperation : + // rootImplementsInterface.getAllGenOperations()) + // { + // if (genOperation.getName().equals(result) && + // genOperation.getGenParameters().isEmpty() && + // !genOperation.getType(context).equals(getType(context))) + // { + // result = result + "_"; + // break; + // } + // } + // } + + return result; + } + + /** + * Formats a name by parsing it into words separated by underscores and/or mixed-casing and then recombining them + * using the specified separator. A prefix can also be given to be recognized as a separate word or to be trimmed. + * Leading underscores can be ignored or can cause a leading separator to be prepended. + */ + public static String format(String name, char separator, String prefix, boolean includePrefix, + boolean includeLeadingSeparator) + { + String leadingSeparators = includeLeadingSeparator ? getLeadingSeparators(name, '_') : null; + if (leadingSeparators != null) + { + name = name.substring(leadingSeparators.length()); + } + + List<String> parsedName = new ArrayList<String>(); + if (prefix != null && name.startsWith(prefix) && name.length() > prefix.length() + && Character.isUpperCase(name.charAt(prefix.length()))) + { + name = name.substring(prefix.length()); + if (includePrefix) + { + parsedName = parseName(prefix, '_'); + } + } + + if (name.length() != 0) + { + parsedName.addAll(parseName(name, '_')); + } + + StringBuilder result = new StringBuilder(); + + for (Iterator<String> nameIter = parsedName.iterator(); nameIter.hasNext();) + { + String nameComponent = nameIter.next(); + result.append(nameComponent); + + if (nameIter.hasNext() && nameComponent.length() > 1) + { + result.append(separator); + } + } + + if (result.length() == 0 && prefix != null) + { + result.append(prefix); + } + + return leadingSeparators != null ? "_" + result.toString() : result.toString(); //$NON-NLS-1$ + } + + /** + * This method breaks sourceName into words delimited by separator and/or mixed-case naming. + */ + public static List<String> parseName(String sourceName, char separator) + { + List<String> result = new ArrayList<String>(); + if (sourceName != null) + { + StringBuilder currentWord = new StringBuilder(); + boolean lastIsLower = false; + for (int index = 0, length = sourceName.length(); index < length; ++index) + { + char curChar = sourceName.charAt(index); + if (Character.isUpperCase(curChar) || !lastIsLower && Character.isDigit(curChar) || curChar == separator) + { + if (lastIsLower && currentWord.length() > 1 || curChar == separator && currentWord.length() > 0) + { + result.add(currentWord.toString()); + currentWord = new StringBuilder(); + } + + lastIsLower = false; + } + else + { + if (!lastIsLower) + { + int currentWordLength = currentWord.length(); + if (currentWordLength > 1) + { + char lastChar = currentWord.charAt(--currentWordLength); + currentWord.setLength(currentWordLength); + result.add(currentWord.toString()); + currentWord = new StringBuilder(); + currentWord.append(lastChar); + } + } + + lastIsLower = true; + } + + if (curChar != separator) + { + currentWord.append(curChar); + } + } + + result.add(currentWord.toString()); + } + + return result; + } + + private static String getLeadingSeparators(String name, char separator) + { + int i = 0; + for (int len = name.length(); i < len && name.charAt(i) == separator; i++) + { + // the for loop's condition finds the separator + } + + return i != 0 ? name.substring(0, i) : null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOElementProxyImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOElementProxyImpl.java index cda9a09a9e..dcdc0ca272 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOElementProxyImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOElementProxyImpl.java @@ -1,45 +1,45 @@ -/*
- * 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.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
-
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public final class CDOElementProxyImpl implements CDOElementProxy
-{
- private int index;
-
- public CDOElementProxyImpl(int index)
- {
- this.index = index;
- }
-
- public int getIndex()
- {
- return index;
- }
-
- public void setIndex(int index)
- {
- this.index = index;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("CDOElementProxy[{0}]", index); //$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 + * Simon McDuff - maintenance + */ +package org.eclipse.emf.cdo.internal.common.revision; + +import org.eclipse.emf.cdo.common.revision.CDOElementProxy; + +import java.text.MessageFormat; + +/** + * @author Eike Stepper + */ +public final class CDOElementProxyImpl implements CDOElementProxy +{ + private int index; + + public CDOElementProxyImpl(int index) + { + this.index = index; + } + + public int getIndex() + { + return index; + } + + public void setIndex(int index) + { + this.index = index; + } + + @Override + public String toString() + { + return MessageFormat.format("CDOElementProxy[{0}]", index); //$NON-NLS-1$ + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOFeatureMapEntryImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOFeatureMapEntryImpl.java index f852ffafd8..8d656ef683 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOFeatureMapEntryImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOFeatureMapEntryImpl.java @@ -1,63 +1,63 @@ -/*
- * 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.internal.common.revision;
-
-import org.eclipse.emf.cdo.spi.common.revision.CDOFeatureMapEntry;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public class CDOFeatureMapEntryImpl implements CDOFeatureMapEntry
-{
- private EStructuralFeature feature;
-
- private Object value;
-
- public CDOFeatureMapEntryImpl()
- {
- }
-
- public CDOFeatureMapEntryImpl(EStructuralFeature feature, Object value)
- {
- this.feature = feature;
- this.value = value;
- }
-
- public EStructuralFeature getEStructuralFeature()
- {
- return feature;
- }
-
- public void setEStructuralFeature(EStructuralFeature feature)
- {
- this.feature = feature;
- }
-
- public Object getValue()
- {
- return value;
- }
-
- public void setValue(Object value)
- {
- this.value = value;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("CDOFeatureMapEntry({0}, {1})", feature.getName(), value); //$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.internal.common.revision; + +import org.eclipse.emf.cdo.spi.common.revision.CDOFeatureMapEntry; + +import org.eclipse.emf.ecore.EStructuralFeature; + +import java.text.MessageFormat; + +/** + * @author Eike Stepper + */ +public class CDOFeatureMapEntryImpl implements CDOFeatureMapEntry +{ + private EStructuralFeature feature; + + private Object value; + + public CDOFeatureMapEntryImpl() + { + } + + public CDOFeatureMapEntryImpl(EStructuralFeature feature, Object value) + { + this.feature = feature; + this.value = value; + } + + public EStructuralFeature getEStructuralFeature() + { + return feature; + } + + public void setEStructuralFeature(EStructuralFeature feature) + { + this.feature = feature; + } + + public Object getValue() + { + return value; + } + + public void setValue(Object value) + { + this.value = value; + } + + @Override + public String toString() + { + return MessageFormat.format("CDOFeatureMapEntry({0}, {1})", feature.getName(), value); //$NON-NLS-1$ + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndBranchImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndBranchImpl.java index 22abddb88f..d977da09a2 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndBranchImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndBranchImpl.java @@ -1,78 +1,78 @@ -/*
- * 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.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
-
-import org.eclipse.net4j.util.CheckUtil;
-import org.eclipse.net4j.util.ObjectUtil;
-
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public class CDOIDAndBranchImpl implements CDOIDAndBranch
-{
- private CDOID id;
-
- private CDOBranch branch;
-
- public CDOIDAndBranchImpl(CDOID id, CDOBranch branch)
- {
- CheckUtil.checkArg(id, "id");
- CheckUtil.checkArg(branch, "branch");
-
- this.id = id;
- this.branch = branch;
- }
-
- public CDOID getID()
- {
- return id;
- }
-
- public CDOBranch getBranch()
- {
- return branch;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj instanceof CDOIDAndBranch)
- {
- CDOIDAndBranch that = (CDOIDAndBranch)obj;
- return ObjectUtil.equals(branch, that.getBranch()) && ObjectUtil.equals(id, that.getID());
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- return id.hashCode() ^ branch.hashCode();
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("{0}:{1}", id, branch.getID()); //$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.internal.common.revision; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch; + +import org.eclipse.net4j.util.CheckUtil; +import org.eclipse.net4j.util.ObjectUtil; + +import java.text.MessageFormat; + +/** + * @author Eike Stepper + */ +public class CDOIDAndBranchImpl implements CDOIDAndBranch +{ + private CDOID id; + + private CDOBranch branch; + + public CDOIDAndBranchImpl(CDOID id, CDOBranch branch) + { + CheckUtil.checkArg(id, "id"); + CheckUtil.checkArg(branch, "branch"); + + this.id = id; + this.branch = branch; + } + + public CDOID getID() + { + return id; + } + + public CDOBranch getBranch() + { + return branch; + } + + @Override + public boolean equals(Object obj) + { + if (obj == this) + { + return true; + } + + if (obj instanceof CDOIDAndBranch) + { + CDOIDAndBranch that = (CDOIDAndBranch)obj; + return ObjectUtil.equals(branch, that.getBranch()) && ObjectUtil.equals(id, that.getID()); + } + + return false; + } + + @Override + public int hashCode() + { + return id.hashCode() ^ branch.hashCode(); + } + + @Override + public String toString() + { + return MessageFormat.format("{0}:{1}", id, branch.getID()); //$NON-NLS-1$ + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndVersionImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndVersionImpl.java index 27ead89940..5ac777a1cf 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndVersionImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOIDAndVersionImpl.java @@ -1,75 +1,75 @@ -/*
- * 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.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
-
-import org.eclipse.net4j.util.CheckUtil;
-
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public class CDOIDAndVersionImpl implements CDOIDAndVersion
-{
- private CDOID id;
-
- private int version;
-
- public CDOIDAndVersionImpl(CDOID id, int version)
- {
- CheckUtil.checkArg(id, "id");
-
- this.id = id;
- this.version = version;
- }
-
- public CDOID getID()
- {
- return id;
- }
-
- public int getVersion()
- {
- return version;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj instanceof CDOIDAndVersion)
- {
- CDOIDAndVersion that = (CDOIDAndVersion)obj;
- return id.equals(that.getID()) && version == that.getVersion();
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- return id.hashCode() ^ version;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("{0}v{1}", id, version); //$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.internal.common.revision; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion; + +import org.eclipse.net4j.util.CheckUtil; + +import java.text.MessageFormat; + +/** + * @author Eike Stepper + */ +public class CDOIDAndVersionImpl implements CDOIDAndVersion +{ + private CDOID id; + + private int version; + + public CDOIDAndVersionImpl(CDOID id, int version) + { + CheckUtil.checkArg(id, "id"); + + this.id = id; + this.version = version; + } + + public CDOID getID() + { + return id; + } + + public int getVersion() + { + return version; + } + + @Override + public boolean equals(Object obj) + { + if (obj == this) + { + return true; + } + + if (obj instanceof CDOIDAndVersion) + { + CDOIDAndVersion that = (CDOIDAndVersion)obj; + return id.equals(that.getID()) && version == that.getVersion(); + } + + return false; + } + + @Override + public int hashCode() + { + return id.hashCode() ^ version; + } + + @Override + public String toString() + { + return MessageFormat.format("{0}v{1}", id, version); //$NON-NLS-1$ + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListImpl.java index 62b5cbc176..f99201743f 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListImpl.java @@ -1,187 +1,187 @@ -/*
- * 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.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.CDOType;
-import org.eclipse.emf.cdo.common.revision.CDOList;
-import org.eclipse.emf.cdo.common.revision.CDOListFactory;
-import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList;
-
-import org.eclipse.net4j.util.collection.MoveableArrayList;
-
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.util.Collection;
-
-/**
- * @author Simon McDuff
- */
-public class CDOListImpl extends MoveableArrayList<Object> implements InternalCDOList
-{
- public static final CDOListFactory FACTORY = new CDOListFactory()
- {
- public CDOList createList(int initialCapacity, int size, int initialChunk)
- {
- return new CDOListImpl(initialCapacity, size);
- }
- };
-
- private static final long serialVersionUID = 1L;
-
- private transient boolean frozen;
-
- public CDOListImpl(int initialCapacity, int size)
- {
- super(initialCapacity);
- for (int j = 0; j < size; j++)
- {
- this.add(UNINITIALIZED);
- }
- }
-
- public InternalCDOList clone(EClassifier classifier)
- {
- CDOType type = CDOModelUtil.getType(classifier);
- int size = size();
- InternalCDOList list = new CDOListImpl(size, 0);
- for (int j = 0; j < size; j++)
- {
- Object value = this.get(j);
- list.add(j, type.copyValue(value));
- }
-
- return list;
- }
-
- public Object get(int index, boolean resolve)
- {
- return super.get(index);
- }
-
- /**
- * There's a duplicate of this method in WrappedHibernateList!!!
- */
- public boolean adjustReferences(CDOReferenceAdjuster revisionAdjuster, EStructuralFeature feature)
- {
- boolean changed = false;
- CDOType type = CDOModelUtil.getType(feature);
- int size = size();
- for (int i = 0; i < size; i++)
- {
- Object element = super.get(i);
- handleAdjustReference(i, element);
- Object newID = type.adjustReferences(revisionAdjuster, element, feature, i);
- if (newID != element) // Just an optimization for NOOP adjusters
- {
- super.set(i, newID);
- changed = true;
- }
- }
-
- return changed;
- }
-
- protected void handleAdjustReference(int index, Object element)
- {
- }
-
- public void freeze()
- {
- frozen = true;
- }
-
- private void checkFrozen()
- {
- if (frozen)
- {
- throw new IllegalStateException("Cannot modify a frozen list");
- }
- }
-
- @Override
- public boolean add(Object o)
- {
- checkFrozen();
- return super.add(o);
- }
-
- @Override
- public boolean remove(Object o)
- {
- checkFrozen();
- return super.remove(o);
- }
-
- @Override
- public boolean addAll(Collection<? extends Object> c)
- {
- checkFrozen();
- return super.addAll(c);
- }
-
- @Override
- public boolean addAll(int index, Collection<? extends Object> c)
- {
- checkFrozen();
- return super.addAll(index, c);
- }
-
- @Override
- public boolean removeAll(Collection<?> c)
- {
- checkFrozen();
- return super.removeAll(c);
- }
-
- @Override
- public boolean retainAll(Collection<?> c)
- {
- checkFrozen();
- return super.retainAll(c);
- }
-
- @Override
- public void clear()
- {
- checkFrozen();
- super.clear();
- }
-
- @Override
- public Object set(int index, Object element)
- {
- checkFrozen();
- return super.set(index, element);
- }
-
- @Override
- public void add(int index, Object element)
- {
- checkFrozen();
- super.add(index, element);
- }
-
- @Override
- public Object remove(int index)
- {
- checkFrozen();
- return super.remove(index);
- }
-
- public void setWithoutFrozenCheck(int index, Object element)
- {
- super.set(index, element);
- }
-}
+/* + * 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.internal.common.revision; + +import org.eclipse.emf.cdo.common.model.CDOModelUtil; +import org.eclipse.emf.cdo.common.model.CDOType; +import org.eclipse.emf.cdo.common.revision.CDOList; +import org.eclipse.emf.cdo.common.revision.CDOListFactory; +import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList; + +import org.eclipse.net4j.util.collection.MoveableArrayList; + +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EStructuralFeature; + +import java.util.Collection; + +/** + * @author Simon McDuff + */ +public class CDOListImpl extends MoveableArrayList<Object> implements InternalCDOList +{ + public static final CDOListFactory FACTORY = new CDOListFactory() + { + public CDOList createList(int initialCapacity, int size, int initialChunk) + { + return new CDOListImpl(initialCapacity, size); + } + }; + + private static final long serialVersionUID = 1L; + + private transient boolean frozen; + + public CDOListImpl(int initialCapacity, int size) + { + super(initialCapacity); + for (int j = 0; j < size; j++) + { + this.add(UNINITIALIZED); + } + } + + public InternalCDOList clone(EClassifier classifier) + { + CDOType type = CDOModelUtil.getType(classifier); + int size = size(); + InternalCDOList list = new CDOListImpl(size, 0); + for (int j = 0; j < size; j++) + { + Object value = this.get(j); + list.add(j, type.copyValue(value)); + } + + return list; + } + + public Object get(int index, boolean resolve) + { + return super.get(index); + } + + /** + * There's a duplicate of this method in WrappedHibernateList!!! + */ + public boolean adjustReferences(CDOReferenceAdjuster revisionAdjuster, EStructuralFeature feature) + { + boolean changed = false; + CDOType type = CDOModelUtil.getType(feature); + int size = size(); + for (int i = 0; i < size; i++) + { + Object element = super.get(i); + handleAdjustReference(i, element); + Object newID = type.adjustReferences(revisionAdjuster, element, feature, i); + if (newID != element) // Just an optimization for NOOP adjusters + { + super.set(i, newID); + changed = true; + } + } + + return changed; + } + + protected void handleAdjustReference(int index, Object element) + { + } + + public void freeze() + { + frozen = true; + } + + private void checkFrozen() + { + if (frozen) + { + throw new IllegalStateException("Cannot modify a frozen list"); + } + } + + @Override + public boolean add(Object o) + { + checkFrozen(); + return super.add(o); + } + + @Override + public boolean remove(Object o) + { + checkFrozen(); + return super.remove(o); + } + + @Override + public boolean addAll(Collection<? extends Object> c) + { + checkFrozen(); + return super.addAll(c); + } + + @Override + public boolean addAll(int index, Collection<? extends Object> c) + { + checkFrozen(); + return super.addAll(index, c); + } + + @Override + public boolean removeAll(Collection<?> c) + { + checkFrozen(); + return super.removeAll(c); + } + + @Override + public boolean retainAll(Collection<?> c) + { + checkFrozen(); + return super.retainAll(c); + } + + @Override + public void clear() + { + checkFrozen(); + super.clear(); + } + + @Override + public Object set(int index, Object element) + { + checkFrozen(); + return super.set(index, element); + } + + @Override + public void add(int index, Object element) + { + checkFrozen(); + super.add(index, element); + } + + @Override + public Object remove(int index) + { + checkFrozen(); + return super.remove(index); + } + + public void setWithoutFrozenCheck(int index, Object element) + { + super.set(index, element); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListWithElementProxiesImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListWithElementProxiesImpl.java index 2179d9b092..4151f2c33d 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListWithElementProxiesImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDOListWithElementProxiesImpl.java @@ -1,91 +1,91 @@ -/*
- * 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.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.model.CDOModelUtil;
-import org.eclipse.emf.cdo.common.model.CDOType;
-import org.eclipse.emf.cdo.common.revision.CDOElementProxy;
-import org.eclipse.emf.cdo.common.revision.CDOList;
-import org.eclipse.emf.cdo.common.revision.CDOListFactory;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList;
-
-import org.eclipse.emf.ecore.EClassifier;
-
-/**
- * @author Simon McDuff
- */
-public class CDOListWithElementProxiesImpl extends CDOListImpl
-{
- public static final CDOListFactory FACTORY = new CDOListFactory()
- {
- public CDOList createList(int initialCapacity, int size, int initialChunk)
- {
- return new CDOListWithElementProxiesImpl(initialCapacity, size, initialChunk);
- }
- };
-
- private static final long serialVersionUID = 1L;
-
- public CDOListWithElementProxiesImpl(int initialCapacity, int size, int initialChunk)
- {
- super(initialCapacity, initialChunk);
- for (int j = initialChunk; j < size; j++)
- {
- this.add(new CDOElementProxyImpl(j));
- }
- }
-
- @Override
- public Object get(int index, boolean resolve)
- {
- if (resolve == true)
- {
- return get(index);
- }
-
- Object element = super.get(index);
-
- return element instanceof CDOElementProxy ? UNINITIALIZED : element;
- }
-
- @Override
- protected void handleAdjustReference(int index, Object element)
- {
- if (element instanceof CDOElementProxy)
- {
- ((CDOElementProxyImpl)element).setIndex(index);
- }
- }
-
- @Override
- public InternalCDOList clone(EClassifier classifier)
- {
- CDOType type = CDOModelUtil.getType(classifier);
- int size = size();
- InternalCDOList list = new CDOListWithElementProxiesImpl(size, 0, 0);
- for (int j = 0; j < size; j++)
- {
- Object value = this.get(j);
-
- if (value instanceof CDOElementProxy)
- {
- list.add(j, new CDOElementProxyImpl(((CDOElementProxy)value).getIndex()));
- }
- else
- {
- list.add(j, type.copyValue(value));
- }
- }
-
- return list;
- }
-}
+/* + * 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.internal.common.revision; + +import org.eclipse.emf.cdo.common.model.CDOModelUtil; +import org.eclipse.emf.cdo.common.model.CDOType; +import org.eclipse.emf.cdo.common.revision.CDOElementProxy; +import org.eclipse.emf.cdo.common.revision.CDOList; +import org.eclipse.emf.cdo.common.revision.CDOListFactory; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDOList; + +import org.eclipse.emf.ecore.EClassifier; + +/** + * @author Simon McDuff + */ +public class CDOListWithElementProxiesImpl extends CDOListImpl +{ + public static final CDOListFactory FACTORY = new CDOListFactory() + { + public CDOList createList(int initialCapacity, int size, int initialChunk) + { + return new CDOListWithElementProxiesImpl(initialCapacity, size, initialChunk); + } + }; + + private static final long serialVersionUID = 1L; + + public CDOListWithElementProxiesImpl(int initialCapacity, int size, int initialChunk) + { + super(initialCapacity, initialChunk); + for (int j = initialChunk; j < size; j++) + { + this.add(new CDOElementProxyImpl(j)); + } + } + + @Override + public Object get(int index, boolean resolve) + { + if (resolve == true) + { + return get(index); + } + + Object element = super.get(index); + + return element instanceof CDOElementProxy ? UNINITIALIZED : element; + } + + @Override + protected void handleAdjustReference(int index, Object element) + { + if (element instanceof CDOElementProxy) + { + ((CDOElementProxyImpl)element).setIndex(index); + } + } + + @Override + public InternalCDOList clone(EClassifier classifier) + { + CDOType type = CDOModelUtil.getType(classifier); + int size = size(); + InternalCDOList list = new CDOListWithElementProxiesImpl(size, 0, 0); + for (int j = 0; j < size; j++) + { + Object value = this.get(j); + + if (value instanceof CDOElementProxy) + { + list.add(j, new CDOElementProxyImpl(((CDOElementProxy)value).getIndex())); + } + else + { + list.add(j, type.copyValue(value)); + } + } + + return list; + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisableImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisableImpl.java index b9ce22a600..c81cd79991 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisableImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisableImpl.java @@ -1,90 +1,90 @@ -/*
- * 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.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.revision.CDORevisable;
-import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
-import org.eclipse.emf.cdo.internal.common.branch.CDOBranchVersionImpl;
-
-import org.eclipse.net4j.util.ObjectUtil;
-
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public class CDORevisableImpl extends CDOBranchVersionImpl implements CDORevisable
-{
- private long timeStamp;
-
- private long revised;
-
- public CDORevisableImpl(CDOBranch branch, int version, long timeStamp, long revised)
- {
- super(branch, version);
- this.timeStamp = timeStamp;
- this.revised = revised;
- }
-
- public CDORevisableImpl(CDORevisable source)
- {
- super(source.getBranch(), source.getVersion());
- timeStamp = source.getTimeStamp();
- revised = source.getRevised();
- }
-
- public CDORevisableImpl(CDOBranch branch, int version)
- {
- super(branch, version);
- }
-
- public long getTimeStamp()
- {
- return timeStamp;
- }
-
- public long getRevised()
- {
- return revised;
- }
-
- @Override
- public int hashCode()
- {
- return ObjectUtil.hashCode(timeStamp) ^ ObjectUtil.hashCode(revised) ^ super.hashCode();
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj instanceof CDORevisable)
- {
- CDORevisable that = (CDORevisable)obj;
- return timeStamp == that.getTimeStamp() && revised == that.getRevised() && getBranch().equals(that.getBranch())
- && getVersion() == that.getVersion();
- }
-
- return false;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("{0}v{1}[{2}-{3}]", getBranch().getID(), getVersion(),
- CDOCommonUtil.formatTimeStamp(timeStamp), CDOCommonUtil.formatTimeStamp(revised));
- }
-}
+/* + * 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.internal.common.revision; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.revision.CDORevisable; +import org.eclipse.emf.cdo.common.util.CDOCommonUtil; +import org.eclipse.emf.cdo.internal.common.branch.CDOBranchVersionImpl; + +import org.eclipse.net4j.util.ObjectUtil; + +import java.text.MessageFormat; + +/** + * @author Eike Stepper + */ +public class CDORevisableImpl extends CDOBranchVersionImpl implements CDORevisable +{ + private long timeStamp; + + private long revised; + + public CDORevisableImpl(CDOBranch branch, int version, long timeStamp, long revised) + { + super(branch, version); + this.timeStamp = timeStamp; + this.revised = revised; + } + + public CDORevisableImpl(CDORevisable source) + { + super(source.getBranch(), source.getVersion()); + timeStamp = source.getTimeStamp(); + revised = source.getRevised(); + } + + public CDORevisableImpl(CDOBranch branch, int version) + { + super(branch, version); + } + + public long getTimeStamp() + { + return timeStamp; + } + + public long getRevised() + { + return revised; + } + + @Override + public int hashCode() + { + return ObjectUtil.hashCode(timeStamp) ^ ObjectUtil.hashCode(revised) ^ super.hashCode(); + } + + @Override + public boolean equals(Object obj) + { + if (obj == this) + { + return true; + } + + if (obj instanceof CDORevisable) + { + CDORevisable that = (CDORevisable)obj; + return timeStamp == that.getTimeStamp() && revised == that.getRevised() && getBranch().equals(that.getBranch()) + && getVersion() == that.getVersion(); + } + + return false; + } + + @Override + public String toString() + { + return MessageFormat.format("{0}v{1}[{2}-{3}]", getBranch().getID(), getVersion(), + CDOCommonUtil.formatTimeStamp(timeStamp), CDOCommonUtil.formatTimeStamp(revised)); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheAuditing.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheAuditing.java index 41125adba2..a12def5698 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheAuditing.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheAuditing.java @@ -1,443 +1,443 @@ -/*
- * 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
- * Simon McDuff - bug 230832
- */
-package org.eclipse.emf.cdo.internal.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.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-import org.eclipse.emf.cdo.internal.common.bundle.OM;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
-
-import org.eclipse.net4j.util.CheckUtil;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EClass;
-
-import java.lang.ref.Reference;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class CDORevisionCacheAuditing extends AbstractCDORevisionCache
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_REVISION, CDORevisionCacheAuditing.class);
-
- protected Map<Object, RevisionList> revisionLists = new HashMap<Object, RevisionList>();
-
- public CDORevisionCacheAuditing()
- {
- }
-
- public InternalCDORevisionCache instantiate(CDORevision revision)
- {
- return new CDORevisionCacheAuditing();
- }
-
- public EClass getObjectType(CDOID id)
- {
- synchronized (revisionLists)
- {
- RevisionList revisionList = revisionLists.get(id);
- if (revisionList != null && !revisionList.isEmpty())
- {
- Reference<InternalCDORevision> ref = revisionList.getFirst();
- InternalCDORevision revision = ref.get();
- if (revision != null)
- {
- return revision.getEClass();
- }
- }
-
- return null;
- }
- }
-
- public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint)
- {
- RevisionList revisionList = getRevisionList(id, branchPoint.getBranch());
- if (revisionList != null)
- {
- return revisionList.getRevision(branchPoint.getTimeStamp());
- }
-
- return null;
- }
-
- public InternalCDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion)
- {
- RevisionList revisionList = getRevisionList(id, branchVersion.getBranch());
- if (revisionList != null)
- {
- return revisionList.getRevisionByVersion(branchVersion.getVersion());
- }
-
- return null;
- }
-
- public List<CDORevision> getCurrentRevisions()
- {
- List<CDORevision> currentRevisions = new ArrayList<CDORevision>();
- synchronized (revisionLists)
- {
- for (RevisionList revisionList : revisionLists.values())
- {
- InternalCDORevision revision = revisionList.getRevision(CDORevision.UNSPECIFIED_DATE);
- if (revision != null)
- {
- currentRevisions.add(revision);
- }
- }
- }
-
- return currentRevisions;
- }
-
- public Map<CDOBranch, List<CDORevision>> getAllRevisions()
- {
- Map<CDOBranch, List<CDORevision>> result = new HashMap<CDOBranch, List<CDORevision>>();
- synchronized (revisionLists)
- {
- for (RevisionList list : revisionLists.values())
- {
- list.getAllRevisions(result);
- }
- }
-
- return result;
- }
-
- public List<CDORevision> getRevisions(CDOBranchPoint branchPoint)
- {
- List<CDORevision> result = new ArrayList<CDORevision>();
- CDOBranch branch = branchPoint.getBranch();
- synchronized (revisionLists)
- {
- for (Map.Entry<Object, RevisionList> entry : revisionLists.entrySet())
- {
- if (isKeyInBranch(entry.getKey(), branch))
- // if (ObjectUtil.equals(entry.getKey().getBranch(), branch))
- {
- RevisionList list = entry.getValue();
- InternalCDORevision revision = list.getRevision(branchPoint.getTimeStamp());
- if (revision != null)
- {
- result.add(revision);
- }
- }
- }
- }
-
- return result;
- }
-
- public void addRevision(CDORevision revision)
- {
- CheckUtil.checkArg(revision, "revision");
-
- CDOID id = revision.getID();
- Object key = createKey(id, revision.getBranch());
-
- synchronized (revisionLists)
- {
- RevisionList list = revisionLists.get(key);
- if (list == null)
- {
- list = new RevisionList();
- revisionLists.put(key, list);
- }
-
- list.addRevision((InternalCDORevision)revision, createReference(revision));
- typeRefIncrease(id, revision.getEClass());
- }
- }
-
- public InternalCDORevision removeRevision(CDOID id, CDOBranchVersion branchVersion)
- {
- Object key = createKey(id, branchVersion.getBranch());
- synchronized (revisionLists)
- {
- RevisionList list = revisionLists.get(key);
- if (list != null)
- {
- list.removeRevision(branchVersion.getVersion());
- if (list.isEmpty())
- {
- revisionLists.remove(key);
- typeRefDecrease(id);
-
- if (TRACER.isEnabled())
- {
- TRACER.format("Removed cache list of {0}", key); //$NON-NLS-1$
- }
- }
- }
- }
-
- return null;
- }
-
- public void clear()
- {
- synchronized (revisionLists)
- {
- revisionLists.clear();
- typeRefDispose();
- }
- }
-
- @Override
- public String toString()
- {
- synchronized (revisionLists)
- {
- return revisionLists.toString();
- }
- }
-
- protected void typeRefIncrease(CDOID id, EClass type)
- {
- // Do nothing
- }
-
- protected void typeRefDecrease(CDOID id)
- {
- // Do nothing
- }
-
- protected void typeRefDispose()
- {
- // Do nothing
- }
-
- protected Object createKey(CDOID id, CDOBranch branch)
- {
- return id;
- }
-
- protected boolean isKeyInBranch(Object key, CDOBranch branch)
- {
- return true;
- }
-
- protected RevisionList getRevisionList(CDOID id, CDOBranch branch)
- {
- Object key = createKey(id, branch);
- synchronized (revisionLists)
- {
- return revisionLists.get(key);
- }
- }
-
- /**
- * @author Eike Stepper
- */
- protected static final class RevisionList extends LinkedList<Reference<InternalCDORevision>>
- {
- private static final long serialVersionUID = 1L;
-
- public RevisionList()
- {
- }
-
- public synchronized InternalCDORevision getRevision(long timeStamp)
- {
- if (timeStamp == CDORevision.UNSPECIFIED_DATE)
- {
- Reference<InternalCDORevision> ref = isEmpty() ? null : getFirst();
- if (ref != null)
- {
- InternalCDORevision revision = ref.get();
- if (revision != null)
- {
- if (!revision.isHistorical())
- {
- return revision;
- }
- }
- else
- {
- removeFirst();
- }
- }
-
- return null;
- }
-
- for (Iterator<Reference<InternalCDORevision>> it = iterator(); it.hasNext();)
- {
- Reference<InternalCDORevision> ref = it.next();
- InternalCDORevision revision = ref.get();
- if (revision != null)
- {
- long created = revision.getTimeStamp();
- if (created <= timeStamp)
- {
- long revised = revision.getRevised();
- if (timeStamp <= revised || revised == CDORevision.UNSPECIFIED_DATE)
- {
- return revision;
- }
-
- break;
- }
- }
- else
- {
- it.remove();
- }
- }
-
- return null;
- }
-
- public synchronized InternalCDORevision getRevisionByVersion(int version)
- {
- for (Iterator<Reference<InternalCDORevision>> it = iterator(); it.hasNext();)
- {
- Reference<InternalCDORevision> ref = it.next();
- InternalCDORevision revision = ref.get();
- if (revision != null)
- {
- int v = revision.getVersion();
- if (v == version)
- {
- return revision;
- }
- else if (v < version)
- {
- break;
- }
- }
- else
- {
- it.remove();
- }
- }
-
- return null;
- }
-
- public synchronized boolean addRevision(InternalCDORevision revision, Reference<InternalCDORevision> reference)
- {
- int version = revision.getVersion();
- for (ListIterator<Reference<InternalCDORevision>> it = listIterator(); it.hasNext();)
- {
- Reference<InternalCDORevision> ref = it.next();
- InternalCDORevision foundRevision = ref.get();
- if (foundRevision != null)
- {
- CDORevisionKey key = (CDORevisionKey)ref;
- int v = key.getVersion();
- if (v == version)
- {
- return false;
- }
-
- if (v < version)
- {
- it.previous();
- it.add(reference);
- return true;
- }
- }
- else
- {
- it.remove();
- }
- }
-
- addLast(reference);
- return true;
- }
-
- public synchronized void removeRevision(int version)
- {
- for (Iterator<Reference<InternalCDORevision>> it = iterator(); it.hasNext();)
- {
- Reference<InternalCDORevision> ref = it.next();
- CDORevisionKey key = (CDORevisionKey)ref;
- int v = key.getVersion();
- if (v == version)
- {
- it.remove();
- if (TRACER.isEnabled())
- {
- TRACER.format("Removed version {0} from cache list of {1}", version, key.getID()); //$NON-NLS-1$
- }
-
- break;
- }
- else if (v < version)
- {
- break;
- }
- }
- }
-
- @Override
- public String toString()
- {
- StringBuffer buffer = new StringBuffer();
- for (Iterator<Reference<InternalCDORevision>> it = iterator(); it.hasNext();)
- {
- Reference<InternalCDORevision> ref = it.next();
- InternalCDORevision revision = ref.get();
- if (buffer.length() == 0)
- {
- buffer.append("{");
- }
- else
- {
- buffer.append(", ");
- }
-
- buffer.append(revision);
- }
-
- buffer.append("}");
- return buffer.toString();
- }
-
- public void getAllRevisions(Map<CDOBranch, List<CDORevision>> result)
- {
- for (Iterator<Reference<InternalCDORevision>> it = iterator(); it.hasNext();)
- {
- Reference<InternalCDORevision> ref = it.next();
- InternalCDORevision revision = ref.get();
- if (revision != null)
- {
- CDOBranch branch = revision.getBranch();
- List<CDORevision> resultList = result.get(branch);
- if (resultList == null)
- {
- resultList = new ArrayList<CDORevision>(1);
- result.put(branch, resultList);
- }
-
- resultList.add(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 + * Simon McDuff - bug 201266 + * Simon McDuff - bug 230832 + */ +package org.eclipse.emf.cdo.internal.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.id.CDOID; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.CDORevisionKey; +import org.eclipse.emf.cdo.internal.common.bundle.OM; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache; + +import org.eclipse.net4j.util.CheckUtil; +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.ecore.EClass; + +import java.lang.ref.Reference; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; + +/** + * @author Eike Stepper + */ +public class CDORevisionCacheAuditing extends AbstractCDORevisionCache +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_REVISION, CDORevisionCacheAuditing.class); + + protected Map<Object, RevisionList> revisionLists = new HashMap<Object, RevisionList>(); + + public CDORevisionCacheAuditing() + { + } + + public InternalCDORevisionCache instantiate(CDORevision revision) + { + return new CDORevisionCacheAuditing(); + } + + public EClass getObjectType(CDOID id) + { + synchronized (revisionLists) + { + RevisionList revisionList = revisionLists.get(id); + if (revisionList != null && !revisionList.isEmpty()) + { + Reference<InternalCDORevision> ref = revisionList.getFirst(); + InternalCDORevision revision = ref.get(); + if (revision != null) + { + return revision.getEClass(); + } + } + + return null; + } + } + + public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint) + { + RevisionList revisionList = getRevisionList(id, branchPoint.getBranch()); + if (revisionList != null) + { + return revisionList.getRevision(branchPoint.getTimeStamp()); + } + + return null; + } + + public InternalCDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion) + { + RevisionList revisionList = getRevisionList(id, branchVersion.getBranch()); + if (revisionList != null) + { + return revisionList.getRevisionByVersion(branchVersion.getVersion()); + } + + return null; + } + + public List<CDORevision> getCurrentRevisions() + { + List<CDORevision> currentRevisions = new ArrayList<CDORevision>(); + synchronized (revisionLists) + { + for (RevisionList revisionList : revisionLists.values()) + { + InternalCDORevision revision = revisionList.getRevision(CDORevision.UNSPECIFIED_DATE); + if (revision != null) + { + currentRevisions.add(revision); + } + } + } + + return currentRevisions; + } + + public Map<CDOBranch, List<CDORevision>> getAllRevisions() + { + Map<CDOBranch, List<CDORevision>> result = new HashMap<CDOBranch, List<CDORevision>>(); + synchronized (revisionLists) + { + for (RevisionList list : revisionLists.values()) + { + list.getAllRevisions(result); + } + } + + return result; + } + + public List<CDORevision> getRevisions(CDOBranchPoint branchPoint) + { + List<CDORevision> result = new ArrayList<CDORevision>(); + CDOBranch branch = branchPoint.getBranch(); + synchronized (revisionLists) + { + for (Map.Entry<Object, RevisionList> entry : revisionLists.entrySet()) + { + if (isKeyInBranch(entry.getKey(), branch)) + // if (ObjectUtil.equals(entry.getKey().getBranch(), branch)) + { + RevisionList list = entry.getValue(); + InternalCDORevision revision = list.getRevision(branchPoint.getTimeStamp()); + if (revision != null) + { + result.add(revision); + } + } + } + } + + return result; + } + + public void addRevision(CDORevision revision) + { + CheckUtil.checkArg(revision, "revision"); + + CDOID id = revision.getID(); + Object key = createKey(id, revision.getBranch()); + + synchronized (revisionLists) + { + RevisionList list = revisionLists.get(key); + if (list == null) + { + list = new RevisionList(); + revisionLists.put(key, list); + } + + list.addRevision((InternalCDORevision)revision, createReference(revision)); + typeRefIncrease(id, revision.getEClass()); + } + } + + public InternalCDORevision removeRevision(CDOID id, CDOBranchVersion branchVersion) + { + Object key = createKey(id, branchVersion.getBranch()); + synchronized (revisionLists) + { + RevisionList list = revisionLists.get(key); + if (list != null) + { + list.removeRevision(branchVersion.getVersion()); + if (list.isEmpty()) + { + revisionLists.remove(key); + typeRefDecrease(id); + + if (TRACER.isEnabled()) + { + TRACER.format("Removed cache list of {0}", key); //$NON-NLS-1$ + } + } + } + } + + return null; + } + + public void clear() + { + synchronized (revisionLists) + { + revisionLists.clear(); + typeRefDispose(); + } + } + + @Override + public String toString() + { + synchronized (revisionLists) + { + return revisionLists.toString(); + } + } + + protected void typeRefIncrease(CDOID id, EClass type) + { + // Do nothing + } + + protected void typeRefDecrease(CDOID id) + { + // Do nothing + } + + protected void typeRefDispose() + { + // Do nothing + } + + protected Object createKey(CDOID id, CDOBranch branch) + { + return id; + } + + protected boolean isKeyInBranch(Object key, CDOBranch branch) + { + return true; + } + + protected RevisionList getRevisionList(CDOID id, CDOBranch branch) + { + Object key = createKey(id, branch); + synchronized (revisionLists) + { + return revisionLists.get(key); + } + } + + /** + * @author Eike Stepper + */ + protected static final class RevisionList extends LinkedList<Reference<InternalCDORevision>> + { + private static final long serialVersionUID = 1L; + + public RevisionList() + { + } + + public synchronized InternalCDORevision getRevision(long timeStamp) + { + if (timeStamp == CDORevision.UNSPECIFIED_DATE) + { + Reference<InternalCDORevision> ref = isEmpty() ? null : getFirst(); + if (ref != null) + { + InternalCDORevision revision = ref.get(); + if (revision != null) + { + if (!revision.isHistorical()) + { + return revision; + } + } + else + { + removeFirst(); + } + } + + return null; + } + + for (Iterator<Reference<InternalCDORevision>> it = iterator(); it.hasNext();) + { + Reference<InternalCDORevision> ref = it.next(); + InternalCDORevision revision = ref.get(); + if (revision != null) + { + long created = revision.getTimeStamp(); + if (created <= timeStamp) + { + long revised = revision.getRevised(); + if (timeStamp <= revised || revised == CDORevision.UNSPECIFIED_DATE) + { + return revision; + } + + break; + } + } + else + { + it.remove(); + } + } + + return null; + } + + public synchronized InternalCDORevision getRevisionByVersion(int version) + { + for (Iterator<Reference<InternalCDORevision>> it = iterator(); it.hasNext();) + { + Reference<InternalCDORevision> ref = it.next(); + InternalCDORevision revision = ref.get(); + if (revision != null) + { + int v = revision.getVersion(); + if (v == version) + { + return revision; + } + else if (v < version) + { + break; + } + } + else + { + it.remove(); + } + } + + return null; + } + + public synchronized boolean addRevision(InternalCDORevision revision, Reference<InternalCDORevision> reference) + { + int version = revision.getVersion(); + for (ListIterator<Reference<InternalCDORevision>> it = listIterator(); it.hasNext();) + { + Reference<InternalCDORevision> ref = it.next(); + InternalCDORevision foundRevision = ref.get(); + if (foundRevision != null) + { + CDORevisionKey key = (CDORevisionKey)ref; + int v = key.getVersion(); + if (v == version) + { + return false; + } + + if (v < version) + { + it.previous(); + it.add(reference); + return true; + } + } + else + { + it.remove(); + } + } + + addLast(reference); + return true; + } + + public synchronized void removeRevision(int version) + { + for (Iterator<Reference<InternalCDORevision>> it = iterator(); it.hasNext();) + { + Reference<InternalCDORevision> ref = it.next(); + CDORevisionKey key = (CDORevisionKey)ref; + int v = key.getVersion(); + if (v == version) + { + it.remove(); + if (TRACER.isEnabled()) + { + TRACER.format("Removed version {0} from cache list of {1}", version, key.getID()); //$NON-NLS-1$ + } + + break; + } + else if (v < version) + { + break; + } + } + } + + @Override + public String toString() + { + StringBuffer buffer = new StringBuffer(); + for (Iterator<Reference<InternalCDORevision>> it = iterator(); it.hasNext();) + { + Reference<InternalCDORevision> ref = it.next(); + InternalCDORevision revision = ref.get(); + if (buffer.length() == 0) + { + buffer.append("{"); + } + else + { + buffer.append(", "); + } + + buffer.append(revision); + } + + buffer.append("}"); + return buffer.toString(); + } + + public void getAllRevisions(Map<CDOBranch, List<CDORevision>> result) + { + for (Iterator<Reference<InternalCDORevision>> it = iterator(); it.hasNext();) + { + Reference<InternalCDORevision> ref = it.next(); + InternalCDORevision revision = ref.get(); + if (revision != null) + { + CDOBranch branch = revision.getBranch(); + List<CDORevision> resultList = result.get(branch); + if (resultList == null) + { + resultList = new ArrayList<CDORevision>(1); + result.put(branch, resultList); + } + + resultList.add(revision); + } + } + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheBranching.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheBranching.java index c099944732..3904bb9d52 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheBranching.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheBranching.java @@ -1,131 +1,131 @@ -/*
- * 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
- * Simon McDuff - bug 230832
- */
-package org.eclipse.emf.cdo.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
-
-import org.eclipse.net4j.util.ObjectUtil;
-
-import org.eclipse.emf.ecore.EClass;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class CDORevisionCacheBranching extends CDORevisionCacheAuditing
-{
- private Map<CDOID, TypeAndRefCounter> typeMap = new HashMap<CDOID, TypeAndRefCounter>();
-
- public CDORevisionCacheBranching()
- {
- }
-
- @Override
- public InternalCDORevisionCache instantiate(CDORevision revision)
- {
- return new CDORevisionCacheBranching();
- }
-
- @Override
- public EClass getObjectType(CDOID id)
- {
- synchronized (revisionLists)
- {
- TypeAndRefCounter typeCounter = typeMap.get(id);
- if (typeCounter != null)
- {
- return typeCounter.getType();
- }
-
- return null;
- }
- }
-
- @Override
- protected void typeRefIncrease(CDOID id, EClass type)
- {
- TypeAndRefCounter typeCounter = typeMap.get(id);
- if (typeCounter == null)
- {
- typeCounter = new TypeAndRefCounter(type);
- typeMap.put(id, typeCounter);
- }
-
- typeCounter.increase();
- }
-
- @Override
- protected void typeRefDecrease(CDOID id)
- {
- TypeAndRefCounter typeCounter = typeMap.get(id);
- if (typeCounter != null && typeCounter.decreaseAndGet() == 0)
- {
- typeMap.remove(id);
- }
- }
-
- @Override
- protected void typeRefDispose()
- {
- typeMap.clear();
- }
-
- @Override
- protected boolean isKeyInBranch(Object key, CDOBranch branch)
- {
- return ObjectUtil.equals(((CDOIDAndBranch)key).getBranch(), branch);
- }
-
- @Override
- protected Object createKey(CDOID id, CDOBranch branch)
- {
- return CDOIDUtil.createIDAndBranch(id, branch);
- }
-
- /**
- * @author Eike Stepper
- */
- private static final class TypeAndRefCounter
- {
- private EClass type;
-
- private int refCounter;
-
- public TypeAndRefCounter(EClass type)
- {
- this.type = type;
- }
-
- public EClass getType()
- {
- return type;
- }
-
- public void increase()
- {
- ++refCounter;
- }
-
- public int decreaseAndGet()
- {
- return --refCounter;
- }
- }
-}
+/* + * 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 + * Simon McDuff - bug 230832 + */ +package org.eclipse.emf.cdo.internal.common.revision; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.id.CDOIDUtil; +import org.eclipse.emf.cdo.common.revision.CDOIDAndBranch; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache; + +import org.eclipse.net4j.util.ObjectUtil; + +import org.eclipse.emf.ecore.EClass; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Eike Stepper + */ +public class CDORevisionCacheBranching extends CDORevisionCacheAuditing +{ + private Map<CDOID, TypeAndRefCounter> typeMap = new HashMap<CDOID, TypeAndRefCounter>(); + + public CDORevisionCacheBranching() + { + } + + @Override + public InternalCDORevisionCache instantiate(CDORevision revision) + { + return new CDORevisionCacheBranching(); + } + + @Override + public EClass getObjectType(CDOID id) + { + synchronized (revisionLists) + { + TypeAndRefCounter typeCounter = typeMap.get(id); + if (typeCounter != null) + { + return typeCounter.getType(); + } + + return null; + } + } + + @Override + protected void typeRefIncrease(CDOID id, EClass type) + { + TypeAndRefCounter typeCounter = typeMap.get(id); + if (typeCounter == null) + { + typeCounter = new TypeAndRefCounter(type); + typeMap.put(id, typeCounter); + } + + typeCounter.increase(); + } + + @Override + protected void typeRefDecrease(CDOID id) + { + TypeAndRefCounter typeCounter = typeMap.get(id); + if (typeCounter != null && typeCounter.decreaseAndGet() == 0) + { + typeMap.remove(id); + } + } + + @Override + protected void typeRefDispose() + { + typeMap.clear(); + } + + @Override + protected boolean isKeyInBranch(Object key, CDOBranch branch) + { + return ObjectUtil.equals(((CDOIDAndBranch)key).getBranch(), branch); + } + + @Override + protected Object createKey(CDOID id, CDOBranch branch) + { + return CDOIDUtil.createIDAndBranch(id, branch); + } + + /** + * @author Eike Stepper + */ + private static final class TypeAndRefCounter + { + private EClass type; + + private int refCounter; + + public TypeAndRefCounter(EClass type) + { + this.type = type; + } + + public EClass getType() + { + return type; + } + + public void increase() + { + ++refCounter; + } + + public int decreaseAndGet() + { + return --refCounter; + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheNonAuditing.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheNonAuditing.java index 4faa69bc04..5e140270e4 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheNonAuditing.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionCacheNonAuditing.java @@ -1,217 +1,217 @@ -/*
- * 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
- * Simon McDuff - bug 230832
- */
-package org.eclipse.emf.cdo.internal.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.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
-
-import org.eclipse.net4j.util.CheckUtil;
-
-import org.eclipse.emf.ecore.EClass;
-
-import java.lang.ref.Reference;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class CDORevisionCacheNonAuditing extends AbstractCDORevisionCache
-{
- private Map<CDOID, Reference<InternalCDORevision>> revisions = new HashMap<CDOID, Reference<InternalCDORevision>>();
-
- public CDORevisionCacheNonAuditing()
- {
- }
-
- public InternalCDORevisionCache instantiate(CDORevision revision)
- {
- return new CDORevisionCacheNonAuditing();
- }
-
- public EClass getObjectType(CDOID id)
- {
- synchronized (revisions)
- {
- Reference<InternalCDORevision> ref = revisions.get(id);
- if (ref != null)
- {
- InternalCDORevision revision = ref.get();
- if (revision != null)
- {
- return revision.getEClass();
- }
- }
-
- return null;
- }
- }
-
- public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint)
- {
- synchronized (revisions)
- {
- Reference<InternalCDORevision> ref = revisions.get(id);
- if (ref != null)
- {
- InternalCDORevision revision = ref.get();
- if (revision != null && revision.isValid(branchPoint))
- {
- return revision;
- }
- }
-
- return null;
- }
- }
-
- public InternalCDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion)
- {
- synchronized (revisions)
- {
- Reference<InternalCDORevision> ref = revisions.get(id);
- if (ref != null)
- {
- InternalCDORevision revision = ref.get();
- if (revision != null && revision.getVersion() == branchVersion.getVersion())
- {
- return revision;
- }
- }
-
- return null;
- }
- }
-
- public List<CDORevision> getCurrentRevisions()
- {
- List<CDORevision> currentRevisions = new ArrayList<CDORevision>();
- synchronized (revisions)
- {
- for (Reference<InternalCDORevision> ref : revisions.values())
- {
- InternalCDORevision revision = ref.get();
- if (revision != null && !revision.isHistorical())
- {
- currentRevisions.add(revision);
- }
- }
- }
-
- return currentRevisions;
- }
-
- public Map<CDOBranch, List<CDORevision>> getAllRevisions()
- {
- Map<CDOBranch, List<CDORevision>> result = new HashMap<CDOBranch, List<CDORevision>>();
- synchronized (revisions)
- {
- List<CDORevision> list = new ArrayList<CDORevision>();
- for (Reference<InternalCDORevision> ref : revisions.values())
- {
- InternalCDORevision revision = ref.get();
- if (revision != null)
- {
- list.add(revision);
- }
- }
-
- if (!list.isEmpty())
- {
- result.put(list.get(0).getBranch(), list);
- }
- }
-
- return result;
- }
-
- public List<CDORevision> getRevisions(CDOBranchPoint branchPoint)
- {
- List<CDORevision> result = new ArrayList<CDORevision>();
- synchronized (revisions)
- {
- for (Reference<InternalCDORevision> ref : revisions.values())
- {
- InternalCDORevision revision = ref.get();
- if (revision != null && revision.isValid(branchPoint))
- {
- result.add(revision);
- }
- }
- }
-
- return result;
- }
-
- public void addRevision(CDORevision revision)
- {
- CheckUtil.checkArg(revision, "revision");
- if (!revision.isHistorical())
- {
- synchronized (revisions)
- {
- revisions.put(revision.getID(), createReference(revision));
- }
- }
- }
-
- public InternalCDORevision removeRevision(CDOID id, CDOBranchVersion branchVersion)
- {
- synchronized (revisions)
- {
- Reference<InternalCDORevision> ref = revisions.get(id);
- if (ref != null)
- {
- InternalCDORevision revision = ref.get();
- if (revision != null)
- {
- if (revision.getVersion() == branchVersion.getVersion()) // No branch check needed in non-auditing
- {
- revisions.remove(id);
- return revision;
- }
- }
- else
- {
- revisions.remove(id);
- }
- }
- }
-
- return null;
- }
-
- public void clear()
- {
- synchronized (revisions)
- {
- revisions.clear();
- }
- }
-
- @Override
- public String toString()
- {
- synchronized (revisions)
- {
- return revisions.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 + * Simon McDuff - bug 201266 + * Simon McDuff - bug 230832 + */ +package org.eclipse.emf.cdo.internal.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.id.CDOID; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache; + +import org.eclipse.net4j.util.CheckUtil; + +import org.eclipse.emf.ecore.EClass; + +import java.lang.ref.Reference; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author Eike Stepper + */ +public class CDORevisionCacheNonAuditing extends AbstractCDORevisionCache +{ + private Map<CDOID, Reference<InternalCDORevision>> revisions = new HashMap<CDOID, Reference<InternalCDORevision>>(); + + public CDORevisionCacheNonAuditing() + { + } + + public InternalCDORevisionCache instantiate(CDORevision revision) + { + return new CDORevisionCacheNonAuditing(); + } + + public EClass getObjectType(CDOID id) + { + synchronized (revisions) + { + Reference<InternalCDORevision> ref = revisions.get(id); + if (ref != null) + { + InternalCDORevision revision = ref.get(); + if (revision != null) + { + return revision.getEClass(); + } + } + + return null; + } + } + + public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint) + { + synchronized (revisions) + { + Reference<InternalCDORevision> ref = revisions.get(id); + if (ref != null) + { + InternalCDORevision revision = ref.get(); + if (revision != null && revision.isValid(branchPoint)) + { + return revision; + } + } + + return null; + } + } + + public InternalCDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion) + { + synchronized (revisions) + { + Reference<InternalCDORevision> ref = revisions.get(id); + if (ref != null) + { + InternalCDORevision revision = ref.get(); + if (revision != null && revision.getVersion() == branchVersion.getVersion()) + { + return revision; + } + } + + return null; + } + } + + public List<CDORevision> getCurrentRevisions() + { + List<CDORevision> currentRevisions = new ArrayList<CDORevision>(); + synchronized (revisions) + { + for (Reference<InternalCDORevision> ref : revisions.values()) + { + InternalCDORevision revision = ref.get(); + if (revision != null && !revision.isHistorical()) + { + currentRevisions.add(revision); + } + } + } + + return currentRevisions; + } + + public Map<CDOBranch, List<CDORevision>> getAllRevisions() + { + Map<CDOBranch, List<CDORevision>> result = new HashMap<CDOBranch, List<CDORevision>>(); + synchronized (revisions) + { + List<CDORevision> list = new ArrayList<CDORevision>(); + for (Reference<InternalCDORevision> ref : revisions.values()) + { + InternalCDORevision revision = ref.get(); + if (revision != null) + { + list.add(revision); + } + } + + if (!list.isEmpty()) + { + result.put(list.get(0).getBranch(), list); + } + } + + return result; + } + + public List<CDORevision> getRevisions(CDOBranchPoint branchPoint) + { + List<CDORevision> result = new ArrayList<CDORevision>(); + synchronized (revisions) + { + for (Reference<InternalCDORevision> ref : revisions.values()) + { + InternalCDORevision revision = ref.get(); + if (revision != null && revision.isValid(branchPoint)) + { + result.add(revision); + } + } + } + + return result; + } + + public void addRevision(CDORevision revision) + { + CheckUtil.checkArg(revision, "revision"); + if (!revision.isHistorical()) + { + synchronized (revisions) + { + revisions.put(revision.getID(), createReference(revision)); + } + } + } + + public InternalCDORevision removeRevision(CDOID id, CDOBranchVersion branchVersion) + { + synchronized (revisions) + { + Reference<InternalCDORevision> ref = revisions.get(id); + if (ref != null) + { + InternalCDORevision revision = ref.get(); + if (revision != null) + { + if (revision.getVersion() == branchVersion.getVersion()) // No branch check needed in non-auditing + { + revisions.remove(id); + return revision; + } + } + else + { + revisions.remove(id); + } + } + } + + return null; + } + + public void clear() + { + synchronized (revisions) + { + revisions.clear(); + } + } + + @Override + public String toString() + { + synchronized (revisions) + { + return revisions.toString(); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionKeyImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionKeyImpl.java index c220b309a6..23cbdf5e16 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionKeyImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionKeyImpl.java @@ -1,66 +1,66 @@ -/*
- * 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.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-import org.eclipse.emf.cdo.internal.common.branch.CDOBranchVersionImpl;
-
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public class CDORevisionKeyImpl extends CDOBranchVersionImpl implements CDORevisionKey
-{
- private CDOID id;
-
- public CDORevisionKeyImpl(CDOID id, CDOBranch branch, int version)
- {
- super(branch, version);
- this.id = id;
- }
-
- public CDOID getID()
- {
- return id;
- }
-
- @Override
- public int hashCode()
- {
- return id.hashCode() ^ super.hashCode();
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj instanceof CDORevisionKey)
- {
- CDORevisionKey that = (CDORevisionKey)obj;
- return id.equals(that.getID()) && getBranch().equals(that.getBranch()) && getVersion() == that.getVersion();
- }
-
- return false;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("{0}:{1}v{2}", id, getBranch().getID(), 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.internal.common.revision; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.revision.CDORevisionKey; +import org.eclipse.emf.cdo.internal.common.branch.CDOBranchVersionImpl; + +import java.text.MessageFormat; + +/** + * @author Eike Stepper + */ +public class CDORevisionKeyImpl extends CDOBranchVersionImpl implements CDORevisionKey +{ + private CDOID id; + + public CDORevisionKeyImpl(CDOID id, CDOBranch branch, int version) + { + super(branch, version); + this.id = id; + } + + public CDOID getID() + { + return id; + } + + @Override + public int hashCode() + { + return id.hashCode() ^ super.hashCode(); + } + + @Override + public boolean equals(Object obj) + { + if (obj == this) + { + return true; + } + + if (obj instanceof CDORevisionKey) + { + CDORevisionKey that = (CDORevisionKey)obj; + return id.equals(that.getID()) && getBranch().equals(that.getBranch()) && getVersion() == that.getVersion(); + } + + return false; + } + + @Override + public String toString() + { + return MessageFormat.format("{0}:{1}v{2}", id, getBranch().getID(), getVersion()); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionManagerImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionManagerImpl.java index 00331a53d3..b9631c4dbc 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionManagerImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/CDORevisionManagerImpl.java @@ -1,539 +1,539 @@ -/*
- * 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
- * Simon McDuff - bug 230832
- */
-package org.eclipse.emf.cdo.internal.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.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionCache;
-import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
-import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
-import org.eclipse.emf.cdo.internal.common.bundle.OM;
-import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil;
-import org.eclipse.emf.cdo.spi.common.revision.DetachedCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager;
-import org.eclipse.emf.cdo.spi.common.revision.PointerCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.RevisionInfo;
-import org.eclipse.emf.cdo.spi.common.revision.SyntheticCDORevision;
-
-import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump;
-import org.eclipse.net4j.util.lifecycle.Lifecycle;
-import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
-import org.eclipse.net4j.util.om.trace.ContextTracer;
-
-import org.eclipse.emf.ecore.EClass;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class CDORevisionManagerImpl extends Lifecycle implements InternalCDORevisionManager
-{
- private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_REVISION, CDORevisionManagerImpl.class);
-
- private boolean supportingAudits;
-
- private boolean supportingBranches;
-
- private RevisionLoader revisionLoader;
-
- private RevisionLocker revisionLocker;
-
- private CDORevisionFactory factory;
-
- private InternalCDORevisionCache cache;
-
- @ExcludeFromDump
- private transient Object loadAndAddLock = new Object()
- {
- @Override
- public String toString()
- {
- return "LoadAndAddLock"; //$NON-NLS-1$
- }
- };
-
- @ExcludeFromDump
- private transient Object reviseLock = new Object()
- {
- @Override
- public String toString()
- {
- return "ReviseLock"; //$NON-NLS-1$
- }
- };
-
- public CDORevisionManagerImpl()
- {
- }
-
- public boolean isSupportingAudits()
- {
- return supportingAudits;
- }
-
- public void setSupportingAudits(boolean on)
- {
- checkInactive();
- supportingAudits = on;
- }
-
- public boolean isSupportingBranches()
- {
- return supportingBranches;
- }
-
- public void setSupportingBranches(boolean on)
- {
- checkInactive();
- supportingBranches = on;
- }
-
- public RevisionLoader getRevisionLoader()
- {
- return revisionLoader;
- }
-
- public void setRevisionLoader(RevisionLoader revisionLoader)
- {
- checkInactive();
- this.revisionLoader = revisionLoader;
- }
-
- public RevisionLocker getRevisionLocker()
- {
- return revisionLocker;
- }
-
- public void setRevisionLocker(RevisionLocker revisionLocker)
- {
- checkInactive();
- this.revisionLocker = revisionLocker;
- }
-
- public CDORevisionFactory getFactory()
- {
- return factory;
- }
-
- public void setFactory(CDORevisionFactory factory)
- {
- checkInactive();
- this.factory = factory;
- }
-
- public InternalCDORevisionCache getCache()
- {
- return cache;
- }
-
- public void setCache(CDORevisionCache cache)
- {
- checkInactive();
- this.cache = (InternalCDORevisionCache)cache;
- }
-
- public EClass getObjectType(CDOID id, CDOBranchManager branchManagerForLoadOnDemand)
- {
- EClass type = cache.getObjectType(id);
- if (type == null && branchManagerForLoadOnDemand != null)
- {
- CDOBranch mainBranch = branchManagerForLoadOnDemand.getMainBranch();
- CDORevision revision = getRevisionByVersion(id, mainBranch.getVersion(CDOBranchVersion.FIRST_VERSION), 0, true);
- if (revision != null)
- {
- type = revision.getEClass();
- }
- }
-
- return type;
- }
-
- public EClass getObjectType(CDOID id)
- {
- return getObjectType(id, null);
- }
-
- public boolean containsRevision(CDOID id, CDOBranchPoint branchPoint)
- {
- if (supportingBranches)
- {
- return getRevision(id, branchPoint, CDORevision.UNCHUNKED, CDORevision.DEPTH_NONE, false, null) != null;
- }
-
- return getCachedRevision(id, branchPoint) != null;
- }
-
- public boolean containsRevisionByVersion(CDOID id, CDOBranchVersion branchVersion)
- {
- return cache.getRevisionByVersion(id, branchVersion) != null;
- }
-
- public void reviseLatest(CDOID id, CDOBranch branch)
- {
- acquireAtomicRequestLock(reviseLock);
-
- try
- {
- InternalCDORevision revision = (InternalCDORevision)cache.getRevision(id, branch.getHead());
- if (revision != null)
- {
- cache.removeRevision(id, branch.getVersion(revision.getVersion()));
- }
- }
- finally
- {
- releaseAtomicRequestLock(reviseLock);
- }
- }
-
- public void reviseVersion(CDOID id, CDOBranchVersion branchVersion, long timeStamp)
- {
- acquireAtomicRequestLock(reviseLock);
-
- try
- {
- InternalCDORevision revision = getCachedRevisionByVersion(id, branchVersion);
- if (revision != null)
- {
- if (timeStamp == CDORevision.UNSPECIFIED_DATE)
- {
- cache.removeRevision(id, branchVersion);
- }
- else
- {
- revision.setRevised(timeStamp - 1);
- }
- }
- }
- finally
- {
- releaseAtomicRequestLock(reviseLock);
- }
- }
-
- public InternalCDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int referenceChunk,
- boolean loadOnDemand)
- {
- checkArg(branchVersion.getVersion() >= CDOBranchVersion.FIRST_VERSION,
- "Invalid version: " + branchVersion.getVersion());
- acquireAtomicRequestLock(loadAndAddLock);
-
- try
- {
- InternalCDORevision revision = getCachedRevisionByVersion(id, branchVersion);
- if (revision == null)
- {
- if (loadOnDemand)
- {
- if (TRACER.isEnabled())
- {
- TRACER.format("Loading revision {0} from {1}", id, branchVersion); //$NON-NLS-1$
- }
-
- revision = revisionLoader.loadRevisionByVersion(id, branchVersion, referenceChunk);
- addRevision(revision);
- }
- }
-
- return revision;
- }
- finally
- {
- releaseAtomicRequestLock(loadAndAddLock);
- }
- }
-
- public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth,
- boolean loadOnDemand)
- {
- return getRevision(id, branchPoint, referenceChunk, prefetchDepth, loadOnDemand, null);
- }
-
- public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth,
- boolean loadOnDemand, SyntheticCDORevision[] synthetics)
- {
- List<CDOID> ids = Collections.singletonList(id);
- CDORevision result = getRevisions(ids, branchPoint, referenceChunk, prefetchDepth, loadOnDemand, synthetics).get(0);
- return (InternalCDORevision)result;
- }
-
- public List<CDORevision> getRevisions(List<CDOID> ids, CDOBranchPoint branchPoint, int referenceChunk,
- int prefetchDepth, boolean loadOnDemand)
- {
- return getRevisions(ids, branchPoint, referenceChunk, prefetchDepth, loadOnDemand, null);
- }
-
- public List<CDORevision> getRevisions(List<CDOID> ids, CDOBranchPoint branchPoint, int referenceChunk,
- int prefetchDepth, boolean loadOnDemand, SyntheticCDORevision[] synthetics)
- {
- RevisionInfo[] infos = new RevisionInfo[ids.size()];
- List<RevisionInfo> infosToLoad = createRevisionInfos(ids, branchPoint, prefetchDepth, loadOnDemand, infos);
- if (infosToLoad != null)
- {
- loadRevisions(infosToLoad, branchPoint, referenceChunk, prefetchDepth);
- }
-
- return getResultsAndSynthetics(infos, synthetics);
- }
-
- private List<RevisionInfo> createRevisionInfos(List<CDOID> ids, CDOBranchPoint branchPoint, int prefetchDepth,
- boolean loadOnDemand, RevisionInfo[] infos)
- {
- List<RevisionInfo> infosToLoad = null;
- Iterator<CDOID> idIterator = ids.iterator();
- for (int i = 0; i < infos.length; i++)
- {
- CDOID id = idIterator.next();
- RevisionInfo info = createRevisionInfo(id, branchPoint);
- infos[i] = info;
-
- if (loadOnDemand && (prefetchDepth != CDORevision.DEPTH_NONE || info.isLoadNeeded()))
- {
- if (infosToLoad == null)
- {
- infosToLoad = new ArrayList<RevisionInfo>(1);
- }
-
- infosToLoad.add(info);
- }
- }
-
- return infosToLoad;
- }
-
- private RevisionInfo createRevisionInfo(CDOID id, CDOBranchPoint branchPoint)
- {
- InternalCDORevision revision = getCachedRevision(id, branchPoint);
- if (revision != null)
- {
- return createRevisionInfoAvailable(revision, branchPoint);
- }
-
- if (supportingBranches)
- {
- revision = getCachedRevisionRecursively(id, branchPoint);
- if (revision != null)
- {
- return createRevisionInfoAvailable(revision, branchPoint);
- }
- }
-
- return createRevisionInfoMissing(id, branchPoint);
- }
-
- private RevisionInfo.Available createRevisionInfoAvailable(InternalCDORevision revision,
- CDOBranchPoint requestedBranchPoint)
- {
- if (revision instanceof PointerCDORevision)
- {
- PointerCDORevision pointer = (PointerCDORevision)revision;
- CDOBranchVersion target = pointer.getTarget();
- InternalCDORevision targetRevision = target == null ? null : getCachedRevisionByVersion(pointer.getID(), target);
- if (targetRevision != null)
- {
- target = targetRevision;
- }
-
- return new RevisionInfo.Available.Pointer(pointer.getID(), requestedBranchPoint, pointer, target);
- }
-
- if (revision instanceof DetachedCDORevision)
- {
- DetachedCDORevision detached = (DetachedCDORevision)revision;
- return new RevisionInfo.Available.Detached(detached.getID(), requestedBranchPoint, detached);
- }
-
- return new RevisionInfo.Available.Normal(revision.getID(), requestedBranchPoint, revision);
- }
-
- private RevisionInfo.Missing createRevisionInfoMissing(CDOID id, CDOBranchPoint requestedBranchPoint)
- {
- return new RevisionInfo.Missing(id, requestedBranchPoint);
- }
-
- protected List<InternalCDORevision> loadRevisions(List<RevisionInfo> infosToLoad, CDOBranchPoint branchPoint,
- int referenceChunk, int prefetchDepth)
- {
- acquireAtomicRequestLock(loadAndAddLock);
-
- try
- {
- List<InternalCDORevision> additionalRevisions = //
- revisionLoader.loadRevisions(infosToLoad, branchPoint, referenceChunk, prefetchDepth);
-
- if (additionalRevisions != null)
- {
- for (InternalCDORevision revision : additionalRevisions)
- {
- addRevision(revision);
- }
- }
-
- return additionalRevisions;
- }
- finally
- {
- releaseAtomicRequestLock(loadAndAddLock);
- }
- }
-
- private List<CDORevision> getResultsAndSynthetics(RevisionInfo[] infos, SyntheticCDORevision[] synthetics)
- {
- List<CDORevision> results = new ArrayList<CDORevision>(infos.length);
- for (int i = 0; i < infos.length; i++)
- {
- RevisionInfo info = infos[i];
- info.processResult(this, results, synthetics, i);
- }
-
- return results;
- }
-
- public void addRevision(CDORevision revision)
- {
- if (revision != null)
- {
- acquireAtomicRequestLock(loadAndAddLock);
-
- try
- {
- if (revision instanceof PointerCDORevision)
- {
- PointerCDORevision pointer = (PointerCDORevision)revision;
- CDOBranchVersion target = pointer.getTarget();
- if (target instanceof InternalCDORevision)
- {
- revision = new PointerCDORevision(pointer.getEClass(), pointer.getID(), pointer.getBranch(),
- pointer.getRevised(), CDOBranchUtil.copyBranchVersion(target));
- }
- }
-
- int oldVersion = revision.getVersion() - 1;
- if (oldVersion >= CDORevision.UNSPECIFIED_VERSION)
- {
- CDOBranchVersion old = revision.getBranch().getVersion(oldVersion);
- InternalCDORevision oldRevision = getCachedRevisionByVersion(revision.getID(), old);
- if (!revision.isHistorical())
- {
- if (oldRevision != null)
- {
- oldRevision.setRevised(revision.getTimeStamp() - 1);
- }
- else
- {
- // Remove last revision from cache, which is not revised
- InternalCDORevision cachedLatestRevision = getCachedRevision(revision.getID(), revision);
- if (cachedLatestRevision != null && !cachedLatestRevision.isHistorical())
- {
- // Found revision is stale.
- // We cannot revise it now because of lack information, thus remove it from the cache
- cache.removeRevision(cachedLatestRevision.getID(), cachedLatestRevision);
- }
- }
- }
- }
-
- cache.addRevision(revision);
- }
- finally
- {
- releaseAtomicRequestLock(loadAndAddLock);
- }
- }
- }
-
- @Override
- protected void doBeforeActivate() throws Exception
- {
- super.doBeforeActivate();
- if (factory == null)
- {
- factory = CDORevisionFactory.DEFAULT;
- }
-
- if (cache == null)
- {
- cache = (InternalCDORevisionCache)CDORevisionUtil.createRevisionCache(supportingAudits, supportingBranches);
- }
- }
-
- @Override
- protected void doActivate() throws Exception
- {
- super.doActivate();
- LifecycleUtil.activate(cache);
- }
-
- @Override
- protected void doDeactivate() throws Exception
- {
- LifecycleUtil.deactivate(cache);
- super.doDeactivate();
- }
-
- private void acquireAtomicRequestLock(Object key)
- {
- if (revisionLocker != null)
- {
- revisionLocker.acquireAtomicRequestLock(key);
- }
- }
-
- private void releaseAtomicRequestLock(Object key)
- {
- if (revisionLocker != null)
- {
- revisionLocker.releaseAtomicRequestLock(key);
- }
- }
-
- private InternalCDORevision getCachedRevisionByVersion(CDOID id, CDOBranchVersion branchVersion)
- {
- return (InternalCDORevision)cache.getRevisionByVersion(id, branchVersion);
- }
-
- private InternalCDORevision getCachedRevision(CDOID id, CDOBranchPoint branchPoint)
- {
- return (InternalCDORevision)cache.getRevision(id, branchPoint);
- }
-
- private InternalCDORevision getCachedRevisionRecursively(CDOID id, CDOBranchPoint branchPoint)
- {
- CDOBranch branch = branchPoint.getBranch();
- if (!branch.isMainBranch())
- {
- CDOBranchPoint base = branch.getBase();
- InternalCDORevision revision = getCachedRevision(id, base);
- if (revision != null)
- {
- return revision;
- }
-
- // Recurse
- return getCachedRevisionRecursively(id, base);
- }
-
- // Reached main branch
- 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 + * Simon McDuff - bug 201266 + * Simon McDuff - bug 230832 + */ +package org.eclipse.emf.cdo.internal.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.id.CDOID; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.CDORevisionCache; +import org.eclipse.emf.cdo.common.revision.CDORevisionFactory; +import org.eclipse.emf.cdo.common.revision.CDORevisionUtil; +import org.eclipse.emf.cdo.internal.common.bundle.OM; +import org.eclipse.emf.cdo.spi.common.branch.CDOBranchUtil; +import org.eclipse.emf.cdo.spi.common.revision.DetachedCDORevision; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionManager; +import org.eclipse.emf.cdo.spi.common.revision.PointerCDORevision; +import org.eclipse.emf.cdo.spi.common.revision.RevisionInfo; +import org.eclipse.emf.cdo.spi.common.revision.SyntheticCDORevision; + +import org.eclipse.net4j.util.ReflectUtil.ExcludeFromDump; +import org.eclipse.net4j.util.lifecycle.Lifecycle; +import org.eclipse.net4j.util.lifecycle.LifecycleUtil; +import org.eclipse.net4j.util.om.trace.ContextTracer; + +import org.eclipse.emf.ecore.EClass; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class CDORevisionManagerImpl extends Lifecycle implements InternalCDORevisionManager +{ + private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG_REVISION, CDORevisionManagerImpl.class); + + private boolean supportingAudits; + + private boolean supportingBranches; + + private RevisionLoader revisionLoader; + + private RevisionLocker revisionLocker; + + private CDORevisionFactory factory; + + private InternalCDORevisionCache cache; + + @ExcludeFromDump + private transient Object loadAndAddLock = new Object() + { + @Override + public String toString() + { + return "LoadAndAddLock"; //$NON-NLS-1$ + } + }; + + @ExcludeFromDump + private transient Object reviseLock = new Object() + { + @Override + public String toString() + { + return "ReviseLock"; //$NON-NLS-1$ + } + }; + + public CDORevisionManagerImpl() + { + } + + public boolean isSupportingAudits() + { + return supportingAudits; + } + + public void setSupportingAudits(boolean on) + { + checkInactive(); + supportingAudits = on; + } + + public boolean isSupportingBranches() + { + return supportingBranches; + } + + public void setSupportingBranches(boolean on) + { + checkInactive(); + supportingBranches = on; + } + + public RevisionLoader getRevisionLoader() + { + return revisionLoader; + } + + public void setRevisionLoader(RevisionLoader revisionLoader) + { + checkInactive(); + this.revisionLoader = revisionLoader; + } + + public RevisionLocker getRevisionLocker() + { + return revisionLocker; + } + + public void setRevisionLocker(RevisionLocker revisionLocker) + { + checkInactive(); + this.revisionLocker = revisionLocker; + } + + public CDORevisionFactory getFactory() + { + return factory; + } + + public void setFactory(CDORevisionFactory factory) + { + checkInactive(); + this.factory = factory; + } + + public InternalCDORevisionCache getCache() + { + return cache; + } + + public void setCache(CDORevisionCache cache) + { + checkInactive(); + this.cache = (InternalCDORevisionCache)cache; + } + + public EClass getObjectType(CDOID id, CDOBranchManager branchManagerForLoadOnDemand) + { + EClass type = cache.getObjectType(id); + if (type == null && branchManagerForLoadOnDemand != null) + { + CDOBranch mainBranch = branchManagerForLoadOnDemand.getMainBranch(); + CDORevision revision = getRevisionByVersion(id, mainBranch.getVersion(CDOBranchVersion.FIRST_VERSION), 0, true); + if (revision != null) + { + type = revision.getEClass(); + } + } + + return type; + } + + public EClass getObjectType(CDOID id) + { + return getObjectType(id, null); + } + + public boolean containsRevision(CDOID id, CDOBranchPoint branchPoint) + { + if (supportingBranches) + { + return getRevision(id, branchPoint, CDORevision.UNCHUNKED, CDORevision.DEPTH_NONE, false, null) != null; + } + + return getCachedRevision(id, branchPoint) != null; + } + + public boolean containsRevisionByVersion(CDOID id, CDOBranchVersion branchVersion) + { + return cache.getRevisionByVersion(id, branchVersion) != null; + } + + public void reviseLatest(CDOID id, CDOBranch branch) + { + acquireAtomicRequestLock(reviseLock); + + try + { + InternalCDORevision revision = (InternalCDORevision)cache.getRevision(id, branch.getHead()); + if (revision != null) + { + cache.removeRevision(id, branch.getVersion(revision.getVersion())); + } + } + finally + { + releaseAtomicRequestLock(reviseLock); + } + } + + public void reviseVersion(CDOID id, CDOBranchVersion branchVersion, long timeStamp) + { + acquireAtomicRequestLock(reviseLock); + + try + { + InternalCDORevision revision = getCachedRevisionByVersion(id, branchVersion); + if (revision != null) + { + if (timeStamp == CDORevision.UNSPECIFIED_DATE) + { + cache.removeRevision(id, branchVersion); + } + else + { + revision.setRevised(timeStamp - 1); + } + } + } + finally + { + releaseAtomicRequestLock(reviseLock); + } + } + + public InternalCDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int referenceChunk, + boolean loadOnDemand) + { + checkArg(branchVersion.getVersion() >= CDOBranchVersion.FIRST_VERSION, + "Invalid version: " + branchVersion.getVersion()); + acquireAtomicRequestLock(loadAndAddLock); + + try + { + InternalCDORevision revision = getCachedRevisionByVersion(id, branchVersion); + if (revision == null) + { + if (loadOnDemand) + { + if (TRACER.isEnabled()) + { + TRACER.format("Loading revision {0} from {1}", id, branchVersion); //$NON-NLS-1$ + } + + revision = revisionLoader.loadRevisionByVersion(id, branchVersion, referenceChunk); + addRevision(revision); + } + } + + return revision; + } + finally + { + releaseAtomicRequestLock(loadAndAddLock); + } + } + + public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth, + boolean loadOnDemand) + { + return getRevision(id, branchPoint, referenceChunk, prefetchDepth, loadOnDemand, null); + } + + public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth, + boolean loadOnDemand, SyntheticCDORevision[] synthetics) + { + List<CDOID> ids = Collections.singletonList(id); + CDORevision result = getRevisions(ids, branchPoint, referenceChunk, prefetchDepth, loadOnDemand, synthetics).get(0); + return (InternalCDORevision)result; + } + + public List<CDORevision> getRevisions(List<CDOID> ids, CDOBranchPoint branchPoint, int referenceChunk, + int prefetchDepth, boolean loadOnDemand) + { + return getRevisions(ids, branchPoint, referenceChunk, prefetchDepth, loadOnDemand, null); + } + + public List<CDORevision> getRevisions(List<CDOID> ids, CDOBranchPoint branchPoint, int referenceChunk, + int prefetchDepth, boolean loadOnDemand, SyntheticCDORevision[] synthetics) + { + RevisionInfo[] infos = new RevisionInfo[ids.size()]; + List<RevisionInfo> infosToLoad = createRevisionInfos(ids, branchPoint, prefetchDepth, loadOnDemand, infos); + if (infosToLoad != null) + { + loadRevisions(infosToLoad, branchPoint, referenceChunk, prefetchDepth); + } + + return getResultsAndSynthetics(infos, synthetics); + } + + private List<RevisionInfo> createRevisionInfos(List<CDOID> ids, CDOBranchPoint branchPoint, int prefetchDepth, + boolean loadOnDemand, RevisionInfo[] infos) + { + List<RevisionInfo> infosToLoad = null; + Iterator<CDOID> idIterator = ids.iterator(); + for (int i = 0; i < infos.length; i++) + { + CDOID id = idIterator.next(); + RevisionInfo info = createRevisionInfo(id, branchPoint); + infos[i] = info; + + if (loadOnDemand && (prefetchDepth != CDORevision.DEPTH_NONE || info.isLoadNeeded())) + { + if (infosToLoad == null) + { + infosToLoad = new ArrayList<RevisionInfo>(1); + } + + infosToLoad.add(info); + } + } + + return infosToLoad; + } + + private RevisionInfo createRevisionInfo(CDOID id, CDOBranchPoint branchPoint) + { + InternalCDORevision revision = getCachedRevision(id, branchPoint); + if (revision != null) + { + return createRevisionInfoAvailable(revision, branchPoint); + } + + if (supportingBranches) + { + revision = getCachedRevisionRecursively(id, branchPoint); + if (revision != null) + { + return createRevisionInfoAvailable(revision, branchPoint); + } + } + + return createRevisionInfoMissing(id, branchPoint); + } + + private RevisionInfo.Available createRevisionInfoAvailable(InternalCDORevision revision, + CDOBranchPoint requestedBranchPoint) + { + if (revision instanceof PointerCDORevision) + { + PointerCDORevision pointer = (PointerCDORevision)revision; + CDOBranchVersion target = pointer.getTarget(); + InternalCDORevision targetRevision = target == null ? null : getCachedRevisionByVersion(pointer.getID(), target); + if (targetRevision != null) + { + target = targetRevision; + } + + return new RevisionInfo.Available.Pointer(pointer.getID(), requestedBranchPoint, pointer, target); + } + + if (revision instanceof DetachedCDORevision) + { + DetachedCDORevision detached = (DetachedCDORevision)revision; + return new RevisionInfo.Available.Detached(detached.getID(), requestedBranchPoint, detached); + } + + return new RevisionInfo.Available.Normal(revision.getID(), requestedBranchPoint, revision); + } + + private RevisionInfo.Missing createRevisionInfoMissing(CDOID id, CDOBranchPoint requestedBranchPoint) + { + return new RevisionInfo.Missing(id, requestedBranchPoint); + } + + protected List<InternalCDORevision> loadRevisions(List<RevisionInfo> infosToLoad, CDOBranchPoint branchPoint, + int referenceChunk, int prefetchDepth) + { + acquireAtomicRequestLock(loadAndAddLock); + + try + { + List<InternalCDORevision> additionalRevisions = // + revisionLoader.loadRevisions(infosToLoad, branchPoint, referenceChunk, prefetchDepth); + + if (additionalRevisions != null) + { + for (InternalCDORevision revision : additionalRevisions) + { + addRevision(revision); + } + } + + return additionalRevisions; + } + finally + { + releaseAtomicRequestLock(loadAndAddLock); + } + } + + private List<CDORevision> getResultsAndSynthetics(RevisionInfo[] infos, SyntheticCDORevision[] synthetics) + { + List<CDORevision> results = new ArrayList<CDORevision>(infos.length); + for (int i = 0; i < infos.length; i++) + { + RevisionInfo info = infos[i]; + info.processResult(this, results, synthetics, i); + } + + return results; + } + + public void addRevision(CDORevision revision) + { + if (revision != null) + { + acquireAtomicRequestLock(loadAndAddLock); + + try + { + if (revision instanceof PointerCDORevision) + { + PointerCDORevision pointer = (PointerCDORevision)revision; + CDOBranchVersion target = pointer.getTarget(); + if (target instanceof InternalCDORevision) + { + revision = new PointerCDORevision(pointer.getEClass(), pointer.getID(), pointer.getBranch(), + pointer.getRevised(), CDOBranchUtil.copyBranchVersion(target)); + } + } + + int oldVersion = revision.getVersion() - 1; + if (oldVersion >= CDORevision.UNSPECIFIED_VERSION) + { + CDOBranchVersion old = revision.getBranch().getVersion(oldVersion); + InternalCDORevision oldRevision = getCachedRevisionByVersion(revision.getID(), old); + if (!revision.isHistorical()) + { + if (oldRevision != null) + { + oldRevision.setRevised(revision.getTimeStamp() - 1); + } + else + { + // Remove last revision from cache, which is not revised + InternalCDORevision cachedLatestRevision = getCachedRevision(revision.getID(), revision); + if (cachedLatestRevision != null && !cachedLatestRevision.isHistorical()) + { + // Found revision is stale. + // We cannot revise it now because of lack information, thus remove it from the cache + cache.removeRevision(cachedLatestRevision.getID(), cachedLatestRevision); + } + } + } + } + + cache.addRevision(revision); + } + finally + { + releaseAtomicRequestLock(loadAndAddLock); + } + } + } + + @Override + protected void doBeforeActivate() throws Exception + { + super.doBeforeActivate(); + if (factory == null) + { + factory = CDORevisionFactory.DEFAULT; + } + + if (cache == null) + { + cache = (InternalCDORevisionCache)CDORevisionUtil.createRevisionCache(supportingAudits, supportingBranches); + } + } + + @Override + protected void doActivate() throws Exception + { + super.doActivate(); + LifecycleUtil.activate(cache); + } + + @Override + protected void doDeactivate() throws Exception + { + LifecycleUtil.deactivate(cache); + super.doDeactivate(); + } + + private void acquireAtomicRequestLock(Object key) + { + if (revisionLocker != null) + { + revisionLocker.acquireAtomicRequestLock(key); + } + } + + private void releaseAtomicRequestLock(Object key) + { + if (revisionLocker != null) + { + revisionLocker.releaseAtomicRequestLock(key); + } + } + + private InternalCDORevision getCachedRevisionByVersion(CDOID id, CDOBranchVersion branchVersion) + { + return (InternalCDORevision)cache.getRevisionByVersion(id, branchVersion); + } + + private InternalCDORevision getCachedRevision(CDOID id, CDOBranchPoint branchPoint) + { + return (InternalCDORevision)cache.getRevision(id, branchPoint); + } + + private InternalCDORevision getCachedRevisionRecursively(CDOID id, CDOBranchPoint branchPoint) + { + CDOBranch branch = branchPoint.getBranch(); + if (!branch.isMainBranch()) + { + CDOBranchPoint base = branch.getBase(); + InternalCDORevision revision = getCachedRevision(id, base); + if (revision != null) + { + return revision; + } + + // Recurse + return getCachedRevisionRecursively(id, base); + } + + // Reached main branch + return null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/EvictionEventImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/EvictionEventImpl.java index 6decf1eada..a823d4e04e 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/EvictionEventImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/EvictionEventImpl.java @@ -1,67 +1,67 @@ -/*
- * 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.internal.common.revision;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevisionCache;
-import org.eclipse.emf.cdo.common.revision.CDORevisionCache.EvictionEvent;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.net4j.util.event.Event;
-
-/**
- * @author Eike Stepper
- */
-public class EvictionEventImpl extends Event implements EvictionEvent
-{
- private static final long serialVersionUID = 1L;
-
- private CDORevisionKey key;
-
- public EvictionEventImpl(CDORevisionCache cache, CDORevisionKey key)
- {
- super(cache);
- this.key = key;
- }
-
- @Override
- public CDORevisionCache getSource()
- {
- return (CDORevisionCache)super.getSource();
- }
-
- public CDOID getID()
- {
- return key.getID();
- }
-
- public CDOBranch getBranch()
- {
- return key.getBranch();
- }
-
- public int getVersion()
- {
- return key.getVersion();
- }
-
- public InternalCDORevision getRevision()
- {
- if (key instanceof InternalCDORevision)
- {
- return (InternalCDORevision)key;
- }
-
- 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 + */ +package org.eclipse.emf.cdo.internal.common.revision; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.revision.CDORevisionCache; +import org.eclipse.emf.cdo.common.revision.CDORevisionCache.EvictionEvent; +import org.eclipse.emf.cdo.common.revision.CDORevisionKey; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; + +import org.eclipse.net4j.util.event.Event; + +/** + * @author Eike Stepper + */ +public class EvictionEventImpl extends Event implements EvictionEvent +{ + private static final long serialVersionUID = 1L; + + private CDORevisionKey key; + + public EvictionEventImpl(CDORevisionCache cache, CDORevisionKey key) + { + super(cache); + this.key = key; + } + + @Override + public CDORevisionCache getSource() + { + return (CDORevisionCache)super.getSource(); + } + + public CDOID getID() + { + return key.getID(); + } + + public CDOBranch getBranch() + { + return key.getBranch(); + } + + public int getVersion() + { + return key.getVersion(); + } + + public InternalCDORevision getRevision() + { + if (key instanceof InternalCDORevision) + { + return (InternalCDORevision)key; + } + + return null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/NOOPRevisionCache.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/NOOPRevisionCache.java index 60d392215b..79fbb3a366 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/NOOPRevisionCache.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/NOOPRevisionCache.java @@ -1,101 +1,101 @@ -/*
- * 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.internal.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.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache;
-
-import org.eclipse.net4j.util.lifecycle.Lifecycle;
-
-import org.eclipse.emf.ecore.EClass;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- */
-public class NOOPRevisionCache extends Lifecycle implements InternalCDORevisionCache
-{
- public static final NOOPRevisionCache INSTANCE = new NOOPRevisionCache();
-
- private static final List<CDORevision> EMPTY = Collections.emptyList();
-
- public NOOPRevisionCache()
- {
- }
-
- public InternalCDORevisionCache instantiate(CDORevision revision)
- {
- return this;
- }
-
- public boolean isSupportingBranches()
- {
- return true;
- }
-
- public EClass getObjectType(CDOID id)
- {
- return null;
- }
-
- public List<CDORevision> getCurrentRevisions()
- {
- return EMPTY;
- }
-
- public InternalCDORevision getRevision(CDOID id)
- {
- return null;
- }
-
- public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint)
- {
- return null;
- }
-
- public InternalCDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion)
- {
- return null;
- }
-
- public void addRevision(CDORevision revision)
- {
- // Do nothing
- }
-
- public InternalCDORevision removeRevision(CDOID id, CDOBranchVersion branchVersion)
- {
- return null;
- }
-
- public void clear()
- {
- // Do nothing
- }
-
- public Map<CDOBranch, List<CDORevision>> getAllRevisions()
- {
- return Collections.emptyMap();
- }
-
- public List<CDORevision> getRevisions(CDOBranchPoint branchPoint)
- {
- return Collections.emptyList();
- }
-}
+/* + * 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.internal.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.id.CDOID; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionCache; + +import org.eclipse.net4j.util.lifecycle.Lifecycle; + +import org.eclipse.emf.ecore.EClass; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + * @author Eike Stepper + */ +public class NOOPRevisionCache extends Lifecycle implements InternalCDORevisionCache +{ + public static final NOOPRevisionCache INSTANCE = new NOOPRevisionCache(); + + private static final List<CDORevision> EMPTY = Collections.emptyList(); + + public NOOPRevisionCache() + { + } + + public InternalCDORevisionCache instantiate(CDORevision revision) + { + return this; + } + + public boolean isSupportingBranches() + { + return true; + } + + public EClass getObjectType(CDOID id) + { + return null; + } + + public List<CDORevision> getCurrentRevisions() + { + return EMPTY; + } + + public InternalCDORevision getRevision(CDOID id) + { + return null; + } + + public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint) + { + return null; + } + + public InternalCDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion) + { + return null; + } + + public void addRevision(CDORevision revision) + { + // Do nothing + } + + public InternalCDORevision removeRevision(CDOID id, CDOBranchVersion branchVersion) + { + return null; + } + + public void clear() + { + // Do nothing + } + + public Map<CDOBranch, List<CDORevision>> getAllRevisions() + { + return Collections.emptyMap(); + } + + public List<CDORevision> getRevisions(CDOBranchPoint branchPoint) + { + return Collections.emptyList(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOAddFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOAddFeatureDeltaImpl.java index aa46c162ed..93c83aa937 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOAddFeatureDeltaImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOAddFeatureDeltaImpl.java @@ -1,79 +1,79 @@ -/*
- * 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.internal.common.revision.delta;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.ListIndexAffecting;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.ListTargetAdding;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.io.IOException;
-
-/**
- * @author Simon McDuff
- */
-public class CDOAddFeatureDeltaImpl extends CDOSingleValueFeatureDeltaImpl implements CDOAddFeatureDelta,
- ListIndexAffecting, ListTargetAdding
-{
- public CDOAddFeatureDeltaImpl(EStructuralFeature feature, int index, Object value)
- {
- super(feature, index, value);
- }
-
- public CDOAddFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
- {
- super(in, eClass);
- }
-
- public Type getType()
- {
- return Type.ADD;
- }
-
- public void apply(CDORevision revision)
- {
- ((InternalCDORevision)revision).getList(getFeature()).add(getIndex(), getValue());
- }
-
- public void accept(CDOFeatureDeltaVisitor visitor)
- {
- visitor.visit(this);
- }
-
- public CDOAddFeatureDelta copy()
- {
- return new CDOAddFeatureDeltaImpl(getFeature(), getIndex(), getValue());
- }
-
- public void affectIndices(ListTargetAdding[] source, int[] indices)
- {
- int index = getIndex();
- if (index == NO_INDEX)
- {
- return;
- }
-
- for (int i = 1; i <= indices[0]; i++)
- {
- if (indices[i] >= index)
- {
- ++indices[i];
- }
- }
- }
-}
+/* + * 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.internal.common.revision.delta; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.ListIndexAffecting; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.ListTargetAdding; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; + +import java.io.IOException; + +/** + * @author Simon McDuff + */ +public class CDOAddFeatureDeltaImpl extends CDOSingleValueFeatureDeltaImpl implements CDOAddFeatureDelta, + ListIndexAffecting, ListTargetAdding +{ + public CDOAddFeatureDeltaImpl(EStructuralFeature feature, int index, Object value) + { + super(feature, index, value); + } + + public CDOAddFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException + { + super(in, eClass); + } + + public Type getType() + { + return Type.ADD; + } + + public void apply(CDORevision revision) + { + ((InternalCDORevision)revision).getList(getFeature()).add(getIndex(), getValue()); + } + + public void accept(CDOFeatureDeltaVisitor visitor) + { + visitor.visit(this); + } + + public CDOAddFeatureDelta copy() + { + return new CDOAddFeatureDeltaImpl(getFeature(), getIndex(), getValue()); + } + + public void affectIndices(ListTargetAdding[] source, int[] indices) + { + int index = getIndex(); + if (index == NO_INDEX) + { + return; + } + + for (int i = 1; i <= indices[0]; i++) + { + if (indices[i] >= index) + { + ++indices[i]; + } + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOClearFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOClearFeatureDeltaImpl.java index 6affdc1a20..f969746445 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOClearFeatureDeltaImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOClearFeatureDeltaImpl.java @@ -1,73 +1,73 @@ -/*
- * 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.internal.common.revision.delta;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.delta.CDOClearFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
-import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.io.IOException;
-
-/**
- * @author Simon McDuff
- */
-public class CDOClearFeatureDeltaImpl extends CDOFeatureDeltaImpl implements CDOClearFeatureDelta
-{
- public CDOClearFeatureDeltaImpl(EStructuralFeature feature)
- {
- super(feature);
- }
-
- public CDOClearFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
- {
- super(in, eClass);
- }
-
- public Type getType()
- {
- return Type.CLEAR;
- }
-
- public CDOFeatureDelta copy()
- {
- return new CDOClearFeatureDeltaImpl(getFeature());
- }
-
- public void apply(CDORevision revision)
- {
- ((InternalCDORevision)revision).clear(getFeature());
- }
-
- public void accept(CDOFeatureDeltaVisitor visitor)
- {
- visitor.visit(this);
- }
-
- @Override
- public boolean adjustReferences(CDOReferenceAdjuster referenceAdjuster)
- {
- return false;
- }
-
- @Override
- protected String toStringAdditional()
- {
- 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: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.internal.common.revision.delta; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.delta.CDOClearFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor; +import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; + +import java.io.IOException; + +/** + * @author Simon McDuff + */ +public class CDOClearFeatureDeltaImpl extends CDOFeatureDeltaImpl implements CDOClearFeatureDelta +{ + public CDOClearFeatureDeltaImpl(EStructuralFeature feature) + { + super(feature); + } + + public CDOClearFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException + { + super(in, eClass); + } + + public Type getType() + { + return Type.CLEAR; + } + + public CDOFeatureDelta copy() + { + return new CDOClearFeatureDeltaImpl(getFeature()); + } + + public void apply(CDORevision revision) + { + ((InternalCDORevision)revision).clear(getFeature()); + } + + public void accept(CDOFeatureDeltaVisitor visitor) + { + visitor.visit(this); + } + + @Override + public boolean adjustReferences(CDOReferenceAdjuster referenceAdjuster) + { + return false; + } + + @Override + protected String toStringAdditional() + { + return null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOContainerFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOContainerFeatureDeltaImpl.java index 33eb961254..27097627e6 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOContainerFeatureDeltaImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOContainerFeatureDeltaImpl.java @@ -1,173 +1,173 @@ -/*
- * 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 204890
- * Simon McDuff - bug 213402
- */
-package org.eclipse.emf.cdo.internal.common.revision.delta;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.delta.CDOContainerFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
-import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.net4j.util.ObjectUtil;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.impl.EReferenceImpl;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-
-/**
- * @author Simon McDuff
- */
-public class CDOContainerFeatureDeltaImpl extends CDOFeatureDeltaImpl implements CDOContainerFeatureDelta
-{
- private CDOID newResourceID;
-
- private Object newContainerID;
-
- private int newContainerFeatureID;
-
- public CDOContainerFeatureDeltaImpl(CDOID newResourceID, Object newContainerID, int newContainerFeatureID)
- {
- super(CONTAINER_FEATURE);
- this.newResourceID = newResourceID;
- this.newContainerID = newContainerID;
- this.newContainerFeatureID = newContainerFeatureID;
- }
-
- public CDOContainerFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
- {
- super(CONTAINER_FEATURE);
- newContainerFeatureID = in.readInt();
- newContainerID = in.readCDOID();
- newResourceID = in.readCDOID();
- }
-
- public Type getType()
- {
- return Type.CONTAINER;
- }
-
- public CDOFeatureDelta copy()
- {
- return new CDOContainerFeatureDeltaImpl(newResourceID, newContainerID, newContainerFeatureID);
- }
-
- public CDOID getResourceID()
- {
- return newResourceID;
- }
-
- public Object getContainerID()
- {
- return newContainerID;
- }
-
- public int getContainerFeatureID()
- {
- return newContainerFeatureID;
- }
-
- public void apply(CDORevision revision)
- {
- ((InternalCDORevision)revision).setResourceID(newResourceID);
- ((InternalCDORevision)revision).setContainerID(newContainerID);
- ((InternalCDORevision)revision).setContainingFeatureID(newContainerFeatureID);
- }
-
- @Override
- public boolean adjustReferences(CDOReferenceAdjuster referenceAdjuster)
- {
- boolean changed = false;
-
- CDOID id1 = (CDOID)referenceAdjuster.adjustReference(newResourceID, CONTAINER_FEATURE, NO_INDEX);
- if (id1 != newResourceID)
- {
- newResourceID = id1;
- changed = true;
- }
-
- Object id2 = referenceAdjuster.adjustReference(newContainerID, CONTAINER_FEATURE, NO_INDEX);
- if (id2 != newContainerID)
- {
- newContainerID = id2;
- changed = true;
- }
-
- return changed;
- }
-
- @Override
- public void write(CDODataOutput out, EClass eClass) throws IOException
- {
- out.writeInt(getType().ordinal());
- out.writeInt(newContainerFeatureID);
- out.writeCDOID(out.getIDProvider().provideCDOID(newContainerID));
- out.writeCDOID(newResourceID);
- }
-
- public void accept(CDOFeatureDeltaVisitor visitor)
- {
- visitor.visit(this);
- }
-
- @Override
- public boolean isStructurallyEqual(Object obj)
- {
- if (!super.isStructurallyEqual(obj))
- {
- return false;
- }
-
- CDOContainerFeatureDelta that = (CDOContainerFeatureDelta)obj;
- return ObjectUtil.equals(newResourceID, that.getResourceID())
- && ObjectUtil.equals(newContainerID, that.getContainerID())
- && newContainerFeatureID == that.getContainerFeatureID();
- }
-
- @Override
- protected String toStringAdditional()
- {
- return MessageFormat.format("resource={0}, container={1}, feature={2}", newResourceID, newContainerID,
- newContainerFeatureID);
- }
-
- /**
- * @author Simon McDuff
- */
- public static final class ContainerFeature extends EReferenceImpl
- {
- public static final String NAME = "eContainer";
-
- public ContainerFeature()
- {
- }
-
- @Override
- public String getName()
- {
- return null;
- }
-
- @Override
- public String toString()
- {
- return 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: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + * Simon McDuff - bug 204890 + * Simon McDuff - bug 213402 + */ +package org.eclipse.emf.cdo.internal.common.revision.delta; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.delta.CDOContainerFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor; +import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; + +import org.eclipse.net4j.util.ObjectUtil; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.impl.EReferenceImpl; + +import java.io.IOException; +import java.text.MessageFormat; + +/** + * @author Simon McDuff + */ +public class CDOContainerFeatureDeltaImpl extends CDOFeatureDeltaImpl implements CDOContainerFeatureDelta +{ + private CDOID newResourceID; + + private Object newContainerID; + + private int newContainerFeatureID; + + public CDOContainerFeatureDeltaImpl(CDOID newResourceID, Object newContainerID, int newContainerFeatureID) + { + super(CONTAINER_FEATURE); + this.newResourceID = newResourceID; + this.newContainerID = newContainerID; + this.newContainerFeatureID = newContainerFeatureID; + } + + public CDOContainerFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException + { + super(CONTAINER_FEATURE); + newContainerFeatureID = in.readInt(); + newContainerID = in.readCDOID(); + newResourceID = in.readCDOID(); + } + + public Type getType() + { + return Type.CONTAINER; + } + + public CDOFeatureDelta copy() + { + return new CDOContainerFeatureDeltaImpl(newResourceID, newContainerID, newContainerFeatureID); + } + + public CDOID getResourceID() + { + return newResourceID; + } + + public Object getContainerID() + { + return newContainerID; + } + + public int getContainerFeatureID() + { + return newContainerFeatureID; + } + + public void apply(CDORevision revision) + { + ((InternalCDORevision)revision).setResourceID(newResourceID); + ((InternalCDORevision)revision).setContainerID(newContainerID); + ((InternalCDORevision)revision).setContainingFeatureID(newContainerFeatureID); + } + + @Override + public boolean adjustReferences(CDOReferenceAdjuster referenceAdjuster) + { + boolean changed = false; + + CDOID id1 = (CDOID)referenceAdjuster.adjustReference(newResourceID, CONTAINER_FEATURE, NO_INDEX); + if (id1 != newResourceID) + { + newResourceID = id1; + changed = true; + } + + Object id2 = referenceAdjuster.adjustReference(newContainerID, CONTAINER_FEATURE, NO_INDEX); + if (id2 != newContainerID) + { + newContainerID = id2; + changed = true; + } + + return changed; + } + + @Override + public void write(CDODataOutput out, EClass eClass) throws IOException + { + out.writeInt(getType().ordinal()); + out.writeInt(newContainerFeatureID); + out.writeCDOID(out.getIDProvider().provideCDOID(newContainerID)); + out.writeCDOID(newResourceID); + } + + public void accept(CDOFeatureDeltaVisitor visitor) + { + visitor.visit(this); + } + + @Override + public boolean isStructurallyEqual(Object obj) + { + if (!super.isStructurallyEqual(obj)) + { + return false; + } + + CDOContainerFeatureDelta that = (CDOContainerFeatureDelta)obj; + return ObjectUtil.equals(newResourceID, that.getResourceID()) + && ObjectUtil.equals(newContainerID, that.getContainerID()) + && newContainerFeatureID == that.getContainerFeatureID(); + } + + @Override + protected String toStringAdditional() + { + return MessageFormat.format("resource={0}, container={1}, feature={2}", newResourceID, newContainerID, + newContainerFeatureID); + } + + /** + * @author Simon McDuff + */ + public static final class ContainerFeature extends EReferenceImpl + { + public static final String NAME = "eContainer"; + + public ContainerFeature() + { + } + + @Override + public String getName() + { + return null; + } + + @Override + public String toString() + { + return NAME; + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDODetachedRevisionDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDODetachedRevisionDeltaImpl.java index 3a9ec9263f..d51261b058 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDODetachedRevisionDeltaImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDODetachedRevisionDeltaImpl.java @@ -1,89 +1,89 @@ -/*
- * 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.internal.common.revision.delta;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevisable;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public class CDODetachedRevisionDeltaImpl implements CDORevisionDelta
-{
- public CDODetachedRevisionDeltaImpl()
- {
- }
-
- public CDOID getID()
- {
- throw new UnsupportedOperationException();
- }
-
- public CDOBranch getBranch()
- {
- throw new UnsupportedOperationException();
- }
-
- public int getVersion()
- {
- throw new UnsupportedOperationException();
- }
-
- public EClass getEClass()
- {
- throw new UnsupportedOperationException();
- }
-
- public CDORevisable getTarget()
- {
- throw new UnsupportedOperationException();
- }
-
- public boolean isEmpty()
- {
- throw new UnsupportedOperationException();
- }
-
- public CDORevisionDelta copy()
- {
- return this;
- }
-
- public CDOFeatureDelta getFeatureDelta(EStructuralFeature feature)
- {
- throw new UnsupportedOperationException();
- }
-
- public List<CDOFeatureDelta> getFeatureDeltas()
- {
- throw new UnsupportedOperationException();
- }
-
- public void apply(CDORevision revision)
- {
- throw new UnsupportedOperationException();
- }
-
- public void accept(CDOFeatureDeltaVisitor visitor)
- {
- throw new UnsupportedOperationException();
- }
-}
+/* + * 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.internal.common.revision.delta; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.revision.CDORevisable; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor; +import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; + +import java.util.List; + +/** + * @author Eike Stepper + */ +public class CDODetachedRevisionDeltaImpl implements CDORevisionDelta +{ + public CDODetachedRevisionDeltaImpl() + { + } + + public CDOID getID() + { + throw new UnsupportedOperationException(); + } + + public CDOBranch getBranch() + { + throw new UnsupportedOperationException(); + } + + public int getVersion() + { + throw new UnsupportedOperationException(); + } + + public EClass getEClass() + { + throw new UnsupportedOperationException(); + } + + public CDORevisable getTarget() + { + throw new UnsupportedOperationException(); + } + + public boolean isEmpty() + { + throw new UnsupportedOperationException(); + } + + public CDORevisionDelta copy() + { + return this; + } + + public CDOFeatureDelta getFeatureDelta(EStructuralFeature feature) + { + throw new UnsupportedOperationException(); + } + + public List<CDOFeatureDelta> getFeatureDeltas() + { + throw new UnsupportedOperationException(); + } + + public void apply(CDORevision revision) + { + throw new UnsupportedOperationException(); + } + + public void accept(CDOFeatureDeltaVisitor visitor) + { + throw new UnsupportedOperationException(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOFeatureDeltaImpl.java index 647e781afe..d697e28d5b 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOFeatureDeltaImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOFeatureDeltaImpl.java @@ -1,90 +1,90 @@ -/*
- * 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.internal.common.revision.delta;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta;
-
-import org.eclipse.net4j.util.CheckUtil;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-
-/**
- * @author Simon McDuff
- */
-public abstract class CDOFeatureDeltaImpl implements InternalCDOFeatureDelta
-{
- private EStructuralFeature feature;
-
- protected CDOFeatureDeltaImpl(EStructuralFeature feature)
- {
- CheckUtil.checkArg(feature, "feature");
- this.feature = feature;
- }
-
- public CDOFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
- {
- int featureID = in.readInt();
- feature = eClass.getEStructuralFeature(featureID);
- CheckUtil.checkState(feature, "feature");
- }
-
- public void write(CDODataOutput out, EClass eClass) throws IOException
- {
- out.writeInt(getType().ordinal());
- out.writeInt(eClass.getFeatureID(feature));
- }
-
- public EStructuralFeature getFeature()
- {
- return feature;
- }
-
- public boolean isStructurallyEqual(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj instanceof CDOFeatureDelta)
- {
- CDOFeatureDelta that = (CDOFeatureDelta)obj;
- return feature.equals(that.getFeature()) && getType().equals(that.getType());
- }
-
- return false;
- }
-
- @Override
- public String toString()
- {
- String additional = toStringAdditional();
- if (additional == null)
- {
- return MessageFormat.format("CDOFeatureDelta[{0}, {1}]", feature.getName(), getType());
- }
-
- return MessageFormat.format("CDOFeatureDelta[{0}, {1}, {2}]", feature.getName(), getType(), additional);
- }
-
- public abstract boolean adjustReferences(CDOReferenceAdjuster referenceAdjuster);
-
- protected abstract String toStringAdditional();
-}
+/* + * 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.internal.common.revision.delta; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta; +import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta; + +import org.eclipse.net4j.util.CheckUtil; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; + +import java.io.IOException; +import java.text.MessageFormat; + +/** + * @author Simon McDuff + */ +public abstract class CDOFeatureDeltaImpl implements InternalCDOFeatureDelta +{ + private EStructuralFeature feature; + + protected CDOFeatureDeltaImpl(EStructuralFeature feature) + { + CheckUtil.checkArg(feature, "feature"); + this.feature = feature; + } + + public CDOFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException + { + int featureID = in.readInt(); + feature = eClass.getEStructuralFeature(featureID); + CheckUtil.checkState(feature, "feature"); + } + + public void write(CDODataOutput out, EClass eClass) throws IOException + { + out.writeInt(getType().ordinal()); + out.writeInt(eClass.getFeatureID(feature)); + } + + public EStructuralFeature getFeature() + { + return feature; + } + + public boolean isStructurallyEqual(Object obj) + { + if (obj == this) + { + return true; + } + + if (obj instanceof CDOFeatureDelta) + { + CDOFeatureDelta that = (CDOFeatureDelta)obj; + return feature.equals(that.getFeature()) && getType().equals(that.getType()); + } + + return false; + } + + @Override + public String toString() + { + String additional = toStringAdditional(); + if (additional == null) + { + return MessageFormat.format("CDOFeatureDelta[{0}, {1}]", feature.getName(), getType()); + } + + return MessageFormat.format("CDOFeatureDelta[{0}, {1}, {2}]", feature.getName(), getType(), additional); + } + + public abstract boolean adjustReferences(CDOReferenceAdjuster referenceAdjuster); + + protected abstract String toStringAdditional(); +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOListFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOListFeatureDeltaImpl.java index 0bba475f15..538e56d422 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOListFeatureDeltaImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOListFeatureDeltaImpl.java @@ -1,464 +1,464 @@ -/*
- * 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
- * Cyril Jaquier - Bug 310574 (with the help of Pascal Lehmann)
- */
-package org.eclipse.emf.cdo.internal.common.revision.delta;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
-import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
-import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
-
-import org.eclipse.net4j.util.ObjectUtil;
-import org.eclipse.net4j.util.collection.Pair;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.util.FeatureMapUtil;
-
-import java.io.IOException;
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-
-/**
- * @author Simon McDuff
- */
-public class CDOListFeatureDeltaImpl extends CDOFeatureDeltaImpl implements CDOListFeatureDelta
-{
- private List<CDOFeatureDelta> featureDeltas = new ArrayList<CDOFeatureDelta>();
-
- private transient int[] cachedIndices;
-
- private transient ListTargetAdding[] cachedSources;
-
- private transient List<CDOFeatureDelta> unprocessedFeatureDeltas;
-
- public CDOListFeatureDeltaImpl(EStructuralFeature feature)
- {
- super(feature);
- }
-
- public CDOListFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
- {
- super(in, eClass);
- int size = in.readInt();
- for (int i = 0; i < size; i++)
- {
- featureDeltas.add(in.readCDOFeatureDelta(eClass));
- }
- }
-
- public CDOListFeatureDelta copy()
- {
- CDOListFeatureDeltaImpl result = new CDOListFeatureDeltaImpl(getFeature());
-
- Map<CDOFeatureDelta, CDOFeatureDelta> map = null;
- if (cachedSources != null || unprocessedFeatureDeltas != null)
- {
- map = new HashMap<CDOFeatureDelta, CDOFeatureDelta>();
- }
-
- for (CDOFeatureDelta delta : featureDeltas)
- {
- CDOFeatureDelta newDelta = delta.copy();
- result.featureDeltas.add(newDelta);
- if (map != null)
- {
- map.put(delta, newDelta);
- }
- }
-
- if (cachedIndices != null)
- {
- result.cachedIndices = copyOf(cachedIndices, cachedIndices.length);
- }
-
- if (cachedSources != null)
- {
- int length = cachedSources.length;
- result.cachedSources = new ListTargetAdding[length];
- for (int i = 0; i < length; i++)
- {
- ListTargetAdding oldElement = cachedSources[i];
- CDOFeatureDelta newElement = map.get(oldElement);
- if (newElement instanceof ListTargetAdding)
- {
- result.cachedSources[i] = (ListTargetAdding)newElement;
- }
- }
- }
-
- if (unprocessedFeatureDeltas != null)
- {
- int size = unprocessedFeatureDeltas.size();
- result.unprocessedFeatureDeltas = new ArrayList<CDOFeatureDelta>(size);
- for (CDOFeatureDelta oldDelta : unprocessedFeatureDeltas)
- {
- CDOFeatureDelta newDelta = map.get(oldDelta);
- if (newDelta != null)
- {
- result.unprocessedFeatureDeltas.add(newDelta);
- }
- }
- }
-
- return result;
- }
-
- @Override
- public void write(CDODataOutput out, EClass eClass) throws IOException
- {
- super.write(out, eClass);
- out.writeInt(featureDeltas.size());
- for (CDOFeatureDelta featureDelta : featureDeltas)
- {
- out.writeCDOFeatureDelta(eClass, featureDelta);
- }
- }
-
- public Type getType()
- {
- return Type.LIST;
- }
-
- public List<CDOFeatureDelta> getListChanges()
- {
- return featureDeltas;
- }
-
- /**
- * Returns the number of indices as the first element of the array.
- *
- * @return never <code>null</code>.
- */
- public Pair<ListTargetAdding[], int[]> reconstructAddedIndices()
- {
- reconstructAddedIndicesWithNoCopy();
- return new Pair<ListTargetAdding[], int[]>(copyOf(cachedSources, cachedSources.length, cachedSources.getClass()),
- copyOf(cachedIndices, cachedIndices.length));
- }
-
- private void reconstructAddedIndicesWithNoCopy()
- {
- // Note that cachedIndices and cachedSources are always either both null or
- // both non-null, and in the latter case, are always of the same length.
- // Furthermore, there can only be unprocessedFeatureDeltas if cachesIndices
- // and cachedSources are non-null.
-
- if (cachedIndices == null || unprocessedFeatureDeltas != null)
- {
- if (cachedIndices == null)
- {
- int initialCapacity = featureDeltas.size() + 1;
- cachedIndices = new int[initialCapacity];
- cachedSources = new ListTargetAdding[initialCapacity];
- }
- else
- // i.e. unprocessedFeatureDeltas != null
- {
- int requiredCapacity = 1 + cachedIndices[0] + unprocessedFeatureDeltas.size();
- if (cachedIndices.length < requiredCapacity)
- {
- int newCapacity = Math.max(requiredCapacity, cachedIndices.length * 2);
-
- int[] newIndices = new int[newCapacity];
- System.arraycopy(cachedIndices, 0, newIndices, 0, cachedIndices.length);
- cachedIndices = newIndices;
-
- ListTargetAdding[] newSources = new ListTargetAdding[newCapacity];
- System.arraycopy(cachedSources, 0, newSources, 0, cachedSources.length);
- cachedSources = newSources;
- }
- }
-
- List<CDOFeatureDelta> featureDeltasToBeProcessed = unprocessedFeatureDeltas == null ? featureDeltas
- : unprocessedFeatureDeltas;
- for (CDOFeatureDelta featureDelta : featureDeltasToBeProcessed)
- {
- if (featureDelta instanceof ListIndexAffecting)
- {
- ListIndexAffecting affecting = (ListIndexAffecting)featureDelta;
- affecting.affectIndices(cachedSources, cachedIndices);
- }
-
- if (featureDelta instanceof ListTargetAdding)
- {
- cachedIndices[++cachedIndices[0]] = ((ListTargetAdding)featureDelta).getIndex();
- cachedSources[cachedIndices[0]] = (ListTargetAdding)featureDelta;
- }
- }
-
- unprocessedFeatureDeltas = null;
- }
- }
-
- private boolean cleanupWithNewDelta(CDOFeatureDelta featureDelta)
- {
- EStructuralFeature feature = getFeature();
- if ((feature instanceof EReference || FeatureMapUtil.isFeatureMap(feature))
- && featureDelta instanceof CDORemoveFeatureDelta)
- {
- int indexToRemove = ((CDORemoveFeatureDelta)featureDelta).getIndex();
- reconstructAddedIndicesWithNoCopy();
-
- for (int i = 1; i <= cachedIndices[0]; i++)
- {
- int index = cachedIndices[i];
- if (indexToRemove == index)
- {
- // The previous implementation set the value of the feature delta to CDOID.NULL. Databinding and probably
- // others don't really like it. We now remove the ADD (or SET which seems to appear in CDOListFeatureDelta
- // during opposite adjustment!? Why???) and patch the other feature deltas.
- // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=310574
-
- ListTargetAdding delta = cachedSources[i];
-
- // We use a "floating" index which is the index (in the list) of the item to remove at the time when the
- // object was still in the list. This index evolves with the feature deltas.
- int floatingIndex = delta.getIndex();
-
- // First updates cachedSources and cachedIndices using CDORemoveFeatureDelta.
- ListIndexAffecting affecting = (ListIndexAffecting)featureDelta;
- affecting.affectIndices(cachedSources, cachedIndices);
-
- // Then adjusts the remaining feature deltas.
- boolean skip = true;
- ListIterator<CDOFeatureDelta> iterator = featureDeltas.listIterator();
-
- while (iterator.hasNext())
- {
- CDOFeatureDelta fd = iterator.next();
-
- // We only need to process feature deltas that come after the ADD (or SET) to be removed.
- if (skip)
- {
- if (fd == delta)
- {
- // Found the ADD (or SET) feature delta that we need to remove. So remove it from the list and start
- // processing the next feature deltas.
- skip = false;
- iterator.remove();
-
- // SET
- if (fd instanceof CDOSetFeatureDelta)
- {
- // If the removed delta is SET we add the REMOVE to the feature deltas. We do not need to adjust the
- // other feature deltas because SET do not modify the list.
- return true;
- }
- }
-
- continue;
- }
-
- // ADD
- if (fd instanceof CDOAddFeatureDelta)
- {
- // Increases the floating index if the ADD came in front of the item.
- if (((CDOAddFeatureDelta)fd).getIndex() <= floatingIndex)
- {
- ++floatingIndex;
- }
-
- // Adjusts the feature delta too.
- ((WithIndex)fd).adjustAfterRemoval(floatingIndex);
- }
-
- // REMOVE
- else if (fd instanceof CDORemoveFeatureDelta)
- {
- int idx = floatingIndex;
- // Decreases the floating index if the REMOVE came in front of the item.
- if (((CDORemoveFeatureDelta)fd).getIndex() <= floatingIndex)
- {
- --floatingIndex;
- }
-
- // Adjusts the feature delta too.
- ((WithIndex)fd).adjustAfterRemoval(idx);
- }
-
- // MOVE
- else if (fd instanceof CDOMoveFeatureDelta)
- {
- // Remembers the positions before we patch them.
- int from = ((CDOMoveFeatureDelta)fd).getOldPosition();
- int to = ((CDOMoveFeatureDelta)fd).getNewPosition();
-
- if (floatingIndex == from)
- {
- // We are moving the "to be deleted" item. So we update our floating index and remove the MOVE. It has
- // no effect on the list.
- floatingIndex = to;
- iterator.remove();
- }
- else
- {
- // In the other cases, we need to patch the positions.
-
- // If the old position is greater or equal to the current position of the item to be removed (remember,
- // that's our floating index), decrease the position.
- int patchedFrom = floatingIndex <= from ? from - 1 : from;
-
- // The new position requires more care. We need to know the direction of the move (left-to-right or
- // right-to-left).
- int patchedTo;
- if (from > to)
- {
- // left-to-right. Only decreases the position if it is strictly greater than the current item
- // position.
- patchedTo = floatingIndex < to ? to - 1 : to;
- }
- else
- {
- // right-to-left. Decreases the position if it is greater or equal than the current item position.
- patchedTo = floatingIndex <= to ? to - 1 : to;
- }
-
- // We can now update our floating index. We use the original positions because the floating index
- // represents the item "to be deleted" before it was actually removed.
- if (from < floatingIndex && floatingIndex <= to)
- {
- --floatingIndex;
- }
- else if (to <= floatingIndex && floatingIndex < from)
- {
- ++floatingIndex;
- }
-
- // And finally adjust the feature delta.
- if (patchedFrom == patchedTo)
- {
- // Source and destination are the same so just remove the feature delta.
- iterator.remove();
- }
- else
- {
- ((CDOMoveFeatureDeltaImpl)fd).setOldPosition(patchedFrom);
- ((CDOMoveFeatureDeltaImpl)fd).setNewPosition(patchedTo);
- }
- }
- }
-
- // SET
- else if (fd instanceof CDOSetFeatureDelta)
- {
- // Adjusts the feature delta too.
- ((WithIndex)fd).adjustAfterRemoval(floatingIndex);
- }
- }
-
- // If the removed delta was ADD so we do not add the REMOVE to the feature deltas.
- return false;
- }
- }
- }
-
- if (cachedIndices != null)
- {
- if (unprocessedFeatureDeltas == null)
- {
- unprocessedFeatureDeltas = new ArrayList<CDOFeatureDelta>();
- }
-
- unprocessedFeatureDeltas.add(featureDelta);
- }
-
- return true;
- }
-
- public void add(CDOFeatureDelta featureDelta)
- {
- // Only adds the feature delta to the list if required.
- if (cleanupWithNewDelta(featureDelta))
- {
- featureDeltas.add(featureDelta);
- }
- }
-
- public void apply(CDORevision revision)
- {
- for (CDOFeatureDelta featureDelta : featureDeltas)
- {
- ((CDOFeatureDeltaImpl)featureDelta).apply(revision);
- }
- }
-
- @Override
- public boolean adjustReferences(CDOReferenceAdjuster adjuster)
- {
- boolean changed = false;
- for (CDOFeatureDelta featureDelta : featureDeltas)
- {
- changed |= ((CDOFeatureDeltaImpl)featureDelta).adjustReferences(adjuster);
- }
-
- return changed;
- }
-
- public void accept(CDOFeatureDeltaVisitor visitor)
- {
- visitor.visit(this);
- }
-
- @Override
- public boolean isStructurallyEqual(Object obj)
- {
- if (!super.isStructurallyEqual(obj))
- {
- return false;
- }
-
- CDOListFeatureDelta that = (CDOListFeatureDelta)obj;
- return ObjectUtil.equals(featureDeltas, that.getListChanges());
- }
-
- @Override
- protected String toStringAdditional()
- {
- return "list=" + featureDeltas; //$NON-NLS-1$
- }
-
- /**
- * Copied from JAVA 1.6 {@link Arrays Arrays.copyOf}.
- */
- private static <T, U> T[] copyOf(U[] original, int newLength, Class<? extends T[]> newType)
- {
- @SuppressWarnings("unchecked")
- T[] copy = (Object)newType == (Object)Object[].class ? (T[])new Object[newLength] : (T[])Array.newInstance(
- newType.getComponentType(), newLength);
- System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
- return copy;
- }
-
- /**
- * Copied from JAVA 1.6 {@link Arrays Arrays.copyOf}.
- */
- private static int[] copyOf(int[] original, int newLength)
- {
- int[] copy = new int[newLength];
- System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength));
- return 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: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + * Cyril Jaquier - Bug 310574 (with the help of Pascal Lehmann) + */ +package org.eclipse.emf.cdo.internal.common.revision.delta; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor; +import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta; +import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster; + +import org.eclipse.net4j.util.ObjectUtil; +import org.eclipse.net4j.util.collection.Pair; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.util.FeatureMapUtil; + +import java.io.IOException; +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; + +/** + * @author Simon McDuff + */ +public class CDOListFeatureDeltaImpl extends CDOFeatureDeltaImpl implements CDOListFeatureDelta +{ + private List<CDOFeatureDelta> featureDeltas = new ArrayList<CDOFeatureDelta>(); + + private transient int[] cachedIndices; + + private transient ListTargetAdding[] cachedSources; + + private transient List<CDOFeatureDelta> unprocessedFeatureDeltas; + + public CDOListFeatureDeltaImpl(EStructuralFeature feature) + { + super(feature); + } + + public CDOListFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException + { + super(in, eClass); + int size = in.readInt(); + for (int i = 0; i < size; i++) + { + featureDeltas.add(in.readCDOFeatureDelta(eClass)); + } + } + + public CDOListFeatureDelta copy() + { + CDOListFeatureDeltaImpl result = new CDOListFeatureDeltaImpl(getFeature()); + + Map<CDOFeatureDelta, CDOFeatureDelta> map = null; + if (cachedSources != null || unprocessedFeatureDeltas != null) + { + map = new HashMap<CDOFeatureDelta, CDOFeatureDelta>(); + } + + for (CDOFeatureDelta delta : featureDeltas) + { + CDOFeatureDelta newDelta = delta.copy(); + result.featureDeltas.add(newDelta); + if (map != null) + { + map.put(delta, newDelta); + } + } + + if (cachedIndices != null) + { + result.cachedIndices = copyOf(cachedIndices, cachedIndices.length); + } + + if (cachedSources != null) + { + int length = cachedSources.length; + result.cachedSources = new ListTargetAdding[length]; + for (int i = 0; i < length; i++) + { + ListTargetAdding oldElement = cachedSources[i]; + CDOFeatureDelta newElement = map.get(oldElement); + if (newElement instanceof ListTargetAdding) + { + result.cachedSources[i] = (ListTargetAdding)newElement; + } + } + } + + if (unprocessedFeatureDeltas != null) + { + int size = unprocessedFeatureDeltas.size(); + result.unprocessedFeatureDeltas = new ArrayList<CDOFeatureDelta>(size); + for (CDOFeatureDelta oldDelta : unprocessedFeatureDeltas) + { + CDOFeatureDelta newDelta = map.get(oldDelta); + if (newDelta != null) + { + result.unprocessedFeatureDeltas.add(newDelta); + } + } + } + + return result; + } + + @Override + public void write(CDODataOutput out, EClass eClass) throws IOException + { + super.write(out, eClass); + out.writeInt(featureDeltas.size()); + for (CDOFeatureDelta featureDelta : featureDeltas) + { + out.writeCDOFeatureDelta(eClass, featureDelta); + } + } + + public Type getType() + { + return Type.LIST; + } + + public List<CDOFeatureDelta> getListChanges() + { + return featureDeltas; + } + + /** + * Returns the number of indices as the first element of the array. + * + * @return never <code>null</code>. + */ + public Pair<ListTargetAdding[], int[]> reconstructAddedIndices() + { + reconstructAddedIndicesWithNoCopy(); + return new Pair<ListTargetAdding[], int[]>(copyOf(cachedSources, cachedSources.length, cachedSources.getClass()), + copyOf(cachedIndices, cachedIndices.length)); + } + + private void reconstructAddedIndicesWithNoCopy() + { + // Note that cachedIndices and cachedSources are always either both null or + // both non-null, and in the latter case, are always of the same length. + // Furthermore, there can only be unprocessedFeatureDeltas if cachesIndices + // and cachedSources are non-null. + + if (cachedIndices == null || unprocessedFeatureDeltas != null) + { + if (cachedIndices == null) + { + int initialCapacity = featureDeltas.size() + 1; + cachedIndices = new int[initialCapacity]; + cachedSources = new ListTargetAdding[initialCapacity]; + } + else + // i.e. unprocessedFeatureDeltas != null + { + int requiredCapacity = 1 + cachedIndices[0] + unprocessedFeatureDeltas.size(); + if (cachedIndices.length < requiredCapacity) + { + int newCapacity = Math.max(requiredCapacity, cachedIndices.length * 2); + + int[] newIndices = new int[newCapacity]; + System.arraycopy(cachedIndices, 0, newIndices, 0, cachedIndices.length); + cachedIndices = newIndices; + + ListTargetAdding[] newSources = new ListTargetAdding[newCapacity]; + System.arraycopy(cachedSources, 0, newSources, 0, cachedSources.length); + cachedSources = newSources; + } + } + + List<CDOFeatureDelta> featureDeltasToBeProcessed = unprocessedFeatureDeltas == null ? featureDeltas + : unprocessedFeatureDeltas; + for (CDOFeatureDelta featureDelta : featureDeltasToBeProcessed) + { + if (featureDelta instanceof ListIndexAffecting) + { + ListIndexAffecting affecting = (ListIndexAffecting)featureDelta; + affecting.affectIndices(cachedSources, cachedIndices); + } + + if (featureDelta instanceof ListTargetAdding) + { + cachedIndices[++cachedIndices[0]] = ((ListTargetAdding)featureDelta).getIndex(); + cachedSources[cachedIndices[0]] = (ListTargetAdding)featureDelta; + } + } + + unprocessedFeatureDeltas = null; + } + } + + private boolean cleanupWithNewDelta(CDOFeatureDelta featureDelta) + { + EStructuralFeature feature = getFeature(); + if ((feature instanceof EReference || FeatureMapUtil.isFeatureMap(feature)) + && featureDelta instanceof CDORemoveFeatureDelta) + { + int indexToRemove = ((CDORemoveFeatureDelta)featureDelta).getIndex(); + reconstructAddedIndicesWithNoCopy(); + + for (int i = 1; i <= cachedIndices[0]; i++) + { + int index = cachedIndices[i]; + if (indexToRemove == index) + { + // The previous implementation set the value of the feature delta to CDOID.NULL. Databinding and probably + // others don't really like it. We now remove the ADD (or SET which seems to appear in CDOListFeatureDelta + // during opposite adjustment!? Why???) and patch the other feature deltas. + // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=310574 + + ListTargetAdding delta = cachedSources[i]; + + // We use a "floating" index which is the index (in the list) of the item to remove at the time when the + // object was still in the list. This index evolves with the feature deltas. + int floatingIndex = delta.getIndex(); + + // First updates cachedSources and cachedIndices using CDORemoveFeatureDelta. + ListIndexAffecting affecting = (ListIndexAffecting)featureDelta; + affecting.affectIndices(cachedSources, cachedIndices); + + // Then adjusts the remaining feature deltas. + boolean skip = true; + ListIterator<CDOFeatureDelta> iterator = featureDeltas.listIterator(); + + while (iterator.hasNext()) + { + CDOFeatureDelta fd = iterator.next(); + + // We only need to process feature deltas that come after the ADD (or SET) to be removed. + if (skip) + { + if (fd == delta) + { + // Found the ADD (or SET) feature delta that we need to remove. So remove it from the list and start + // processing the next feature deltas. + skip = false; + iterator.remove(); + + // SET + if (fd instanceof CDOSetFeatureDelta) + { + // If the removed delta is SET we add the REMOVE to the feature deltas. We do not need to adjust the + // other feature deltas because SET do not modify the list. + return true; + } + } + + continue; + } + + // ADD + if (fd instanceof CDOAddFeatureDelta) + { + // Increases the floating index if the ADD came in front of the item. + if (((CDOAddFeatureDelta)fd).getIndex() <= floatingIndex) + { + ++floatingIndex; + } + + // Adjusts the feature delta too. + ((WithIndex)fd).adjustAfterRemoval(floatingIndex); + } + + // REMOVE + else if (fd instanceof CDORemoveFeatureDelta) + { + int idx = floatingIndex; + // Decreases the floating index if the REMOVE came in front of the item. + if (((CDORemoveFeatureDelta)fd).getIndex() <= floatingIndex) + { + --floatingIndex; + } + + // Adjusts the feature delta too. + ((WithIndex)fd).adjustAfterRemoval(idx); + } + + // MOVE + else if (fd instanceof CDOMoveFeatureDelta) + { + // Remembers the positions before we patch them. + int from = ((CDOMoveFeatureDelta)fd).getOldPosition(); + int to = ((CDOMoveFeatureDelta)fd).getNewPosition(); + + if (floatingIndex == from) + { + // We are moving the "to be deleted" item. So we update our floating index and remove the MOVE. It has + // no effect on the list. + floatingIndex = to; + iterator.remove(); + } + else + { + // In the other cases, we need to patch the positions. + + // If the old position is greater or equal to the current position of the item to be removed (remember, + // that's our floating index), decrease the position. + int patchedFrom = floatingIndex <= from ? from - 1 : from; + + // The new position requires more care. We need to know the direction of the move (left-to-right or + // right-to-left). + int patchedTo; + if (from > to) + { + // left-to-right. Only decreases the position if it is strictly greater than the current item + // position. + patchedTo = floatingIndex < to ? to - 1 : to; + } + else + { + // right-to-left. Decreases the position if it is greater or equal than the current item position. + patchedTo = floatingIndex <= to ? to - 1 : to; + } + + // We can now update our floating index. We use the original positions because the floating index + // represents the item "to be deleted" before it was actually removed. + if (from < floatingIndex && floatingIndex <= to) + { + --floatingIndex; + } + else if (to <= floatingIndex && floatingIndex < from) + { + ++floatingIndex; + } + + // And finally adjust the feature delta. + if (patchedFrom == patchedTo) + { + // Source and destination are the same so just remove the feature delta. + iterator.remove(); + } + else + { + ((CDOMoveFeatureDeltaImpl)fd).setOldPosition(patchedFrom); + ((CDOMoveFeatureDeltaImpl)fd).setNewPosition(patchedTo); + } + } + } + + // SET + else if (fd instanceof CDOSetFeatureDelta) + { + // Adjusts the feature delta too. + ((WithIndex)fd).adjustAfterRemoval(floatingIndex); + } + } + + // If the removed delta was ADD so we do not add the REMOVE to the feature deltas. + return false; + } + } + } + + if (cachedIndices != null) + { + if (unprocessedFeatureDeltas == null) + { + unprocessedFeatureDeltas = new ArrayList<CDOFeatureDelta>(); + } + + unprocessedFeatureDeltas.add(featureDelta); + } + + return true; + } + + public void add(CDOFeatureDelta featureDelta) + { + // Only adds the feature delta to the list if required. + if (cleanupWithNewDelta(featureDelta)) + { + featureDeltas.add(featureDelta); + } + } + + public void apply(CDORevision revision) + { + for (CDOFeatureDelta featureDelta : featureDeltas) + { + ((CDOFeatureDeltaImpl)featureDelta).apply(revision); + } + } + + @Override + public boolean adjustReferences(CDOReferenceAdjuster adjuster) + { + boolean changed = false; + for (CDOFeatureDelta featureDelta : featureDeltas) + { + changed |= ((CDOFeatureDeltaImpl)featureDelta).adjustReferences(adjuster); + } + + return changed; + } + + public void accept(CDOFeatureDeltaVisitor visitor) + { + visitor.visit(this); + } + + @Override + public boolean isStructurallyEqual(Object obj) + { + if (!super.isStructurallyEqual(obj)) + { + return false; + } + + CDOListFeatureDelta that = (CDOListFeatureDelta)obj; + return ObjectUtil.equals(featureDeltas, that.getListChanges()); + } + + @Override + protected String toStringAdditional() + { + return "list=" + featureDeltas; //$NON-NLS-1$ + } + + /** + * Copied from JAVA 1.6 {@link Arrays Arrays.copyOf}. + */ + private static <T, U> T[] copyOf(U[] original, int newLength, Class<? extends T[]> newType) + { + @SuppressWarnings("unchecked") + T[] copy = (Object)newType == (Object)Object[].class ? (T[])new Object[newLength] : (T[])Array.newInstance( + newType.getComponentType(), newLength); + System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength)); + return copy; + } + + /** + * Copied from JAVA 1.6 {@link Arrays Arrays.copyOf}. + */ + private static int[] copyOf(int[] original, int newLength) + { + int[] copy = new int[newLength]; + System.arraycopy(original, 0, copy, 0, Math.min(original.length, newLength)); + return copy; + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOMoveFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOMoveFeatureDeltaImpl.java index e8c352afc6..efce733db2 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOMoveFeatureDeltaImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOMoveFeatureDeltaImpl.java @@ -1,207 +1,207 @@ -/*
- * 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.internal.common.revision.delta;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
-import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta;
-import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.ListIndexAffecting;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.WithIndex;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-
-/**
- * @author Simon McDuff
- */
-public class CDOMoveFeatureDeltaImpl extends CDOFeatureDeltaImpl implements CDOMoveFeatureDelta, ListIndexAffecting,
- WithIndex
-{
- private int oldPosition;
-
- private int newPosition;
-
- private Object value;
-
- public CDOMoveFeatureDeltaImpl(EStructuralFeature feature, int newPosition, int oldPosition)
- {
- super(feature);
- this.newPosition = newPosition;
- this.oldPosition = oldPosition;
- value = UNKNOWN_VALUE;
- }
-
- public CDOMoveFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
- {
- super(in, eClass);
- newPosition = in.readInt();
- oldPosition = in.readInt();
- value = UNKNOWN_VALUE;
- }
-
- @Override
- public void write(CDODataOutput out, EClass eClass) throws IOException
- {
- super.write(out, eClass);
- out.writeInt(newPosition);
- out.writeInt(oldPosition);
- }
-
- public int getNewPosition()
- {
- return newPosition;
- }
-
- public int getOldPosition()
- {
- return oldPosition;
- }
-
- public Type getType()
- {
- return Type.MOVE;
- }
-
- public Object getValue()
- {
- return value;
- }
-
- public void setValue(Object value)
- {
- this.value = value;
- }
-
- public void setOldPosition(int oldPosition)
- {
- this.oldPosition = oldPosition;
- }
-
- public void setNewPosition(int newPosition)
- {
- this.newPosition = newPosition;
- }
-
- public CDOFeatureDelta copy()
- {
- CDOFeatureDelta copy = new CDOMoveFeatureDeltaImpl(getFeature(), newPosition, oldPosition);
- ((CDOMoveFeatureDeltaImpl)copy).setValue(getValue());
- return copy;
- }
-
- public void apply(CDORevision revision)
- {
- ((InternalCDORevision)revision).getList(getFeature()).move(newPosition, oldPosition);
- }
-
- public void affectIndices(ListTargetAdding[] source, int[] indices)
- {
- if (oldPosition < newPosition)
- {
- for (int i = 1; i <= indices[0]; i++)
- {
- if (oldPosition < indices[i] && indices[i] <= newPosition)
- {
- --indices[i];
- }
- else if (indices[i] == oldPosition)
- {
- indices[i] = newPosition;
- }
- }
- }
- else if (newPosition < oldPosition)
- {
- for (int i = 1; i <= indices[0]; i++)
- {
- if (newPosition <= indices[i] && indices[i] < oldPosition)
- {
- ++indices[i];
- }
- else if (indices[i] == oldPosition)
- {
- indices[i] = newPosition;
- }
- }
- }
- }
-
- public void accept(CDOFeatureDeltaVisitor visitor)
- {
- visitor.visit(this);
- }
-
- public void adjustAfterAddition(int index)
- {
- if (index <= oldPosition)
- {
- ++oldPosition;
- }
-
- if (index <= newPosition)
- {
- ++newPosition;
- }
- }
-
- public void adjustAfterRemoval(int index)
- {
- if (index < oldPosition && oldPosition > 0)
- {
- --oldPosition;
- }
-
- // Index fix for moves from left to right.
- if (oldPosition < newPosition)
- {
- --index;
- }
-
- if (index < newPosition && newPosition > 0)
- {
- --newPosition;
- }
- }
-
- @Override
- public boolean adjustReferences(CDOReferenceAdjuster adjuster)
- {
- return false;
- }
-
- @Override
- public boolean isStructurallyEqual(Object obj)
- {
- if (!super.isStructurallyEqual(obj))
- {
- return false;
- }
-
- CDOMoveFeatureDelta that = (CDOMoveFeatureDelta)obj;
- return oldPosition == that.getOldPosition() && newPosition == that.getNewPosition();
- }
-
- @Override
- protected String toStringAdditional()
- {
- return MessageFormat.format("from={0}, to={1}, value={2}", oldPosition, newPosition, 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: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.internal.common.revision.delta; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor; +import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta; +import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.ListIndexAffecting; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.WithIndex; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; + +import java.io.IOException; +import java.text.MessageFormat; + +/** + * @author Simon McDuff + */ +public class CDOMoveFeatureDeltaImpl extends CDOFeatureDeltaImpl implements CDOMoveFeatureDelta, ListIndexAffecting, + WithIndex +{ + private int oldPosition; + + private int newPosition; + + private Object value; + + public CDOMoveFeatureDeltaImpl(EStructuralFeature feature, int newPosition, int oldPosition) + { + super(feature); + this.newPosition = newPosition; + this.oldPosition = oldPosition; + value = UNKNOWN_VALUE; + } + + public CDOMoveFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException + { + super(in, eClass); + newPosition = in.readInt(); + oldPosition = in.readInt(); + value = UNKNOWN_VALUE; + } + + @Override + public void write(CDODataOutput out, EClass eClass) throws IOException + { + super.write(out, eClass); + out.writeInt(newPosition); + out.writeInt(oldPosition); + } + + public int getNewPosition() + { + return newPosition; + } + + public int getOldPosition() + { + return oldPosition; + } + + public Type getType() + { + return Type.MOVE; + } + + public Object getValue() + { + return value; + } + + public void setValue(Object value) + { + this.value = value; + } + + public void setOldPosition(int oldPosition) + { + this.oldPosition = oldPosition; + } + + public void setNewPosition(int newPosition) + { + this.newPosition = newPosition; + } + + public CDOFeatureDelta copy() + { + CDOFeatureDelta copy = new CDOMoveFeatureDeltaImpl(getFeature(), newPosition, oldPosition); + ((CDOMoveFeatureDeltaImpl)copy).setValue(getValue()); + return copy; + } + + public void apply(CDORevision revision) + { + ((InternalCDORevision)revision).getList(getFeature()).move(newPosition, oldPosition); + } + + public void affectIndices(ListTargetAdding[] source, int[] indices) + { + if (oldPosition < newPosition) + { + for (int i = 1; i <= indices[0]; i++) + { + if (oldPosition < indices[i] && indices[i] <= newPosition) + { + --indices[i]; + } + else if (indices[i] == oldPosition) + { + indices[i] = newPosition; + } + } + } + else if (newPosition < oldPosition) + { + for (int i = 1; i <= indices[0]; i++) + { + if (newPosition <= indices[i] && indices[i] < oldPosition) + { + ++indices[i]; + } + else if (indices[i] == oldPosition) + { + indices[i] = newPosition; + } + } + } + } + + public void accept(CDOFeatureDeltaVisitor visitor) + { + visitor.visit(this); + } + + public void adjustAfterAddition(int index) + { + if (index <= oldPosition) + { + ++oldPosition; + } + + if (index <= newPosition) + { + ++newPosition; + } + } + + public void adjustAfterRemoval(int index) + { + if (index < oldPosition && oldPosition > 0) + { + --oldPosition; + } + + // Index fix for moves from left to right. + if (oldPosition < newPosition) + { + --index; + } + + if (index < newPosition && newPosition > 0) + { + --newPosition; + } + } + + @Override + public boolean adjustReferences(CDOReferenceAdjuster adjuster) + { + return false; + } + + @Override + public boolean isStructurallyEqual(Object obj) + { + if (!super.isStructurallyEqual(obj)) + { + return false; + } + + CDOMoveFeatureDelta that = (CDOMoveFeatureDelta)obj; + return oldPosition == that.getOldPosition() && newPosition == that.getNewPosition(); + } + + @Override + protected String toStringAdditional() + { + return MessageFormat.format("from={0}, to={1}, value={2}", oldPosition, newPosition, value); + } + +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORemoveFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORemoveFeatureDeltaImpl.java index 4141ffc4c6..2c39a794cc 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORemoveFeatureDeltaImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDORemoveFeatureDeltaImpl.java @@ -1,99 +1,99 @@ -/*
- * 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.internal.common.revision.delta;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
-import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.ListIndexAffecting;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.io.IOException;
-
-/**
- * @author Simon McDuff
- */
-public class CDORemoveFeatureDeltaImpl extends CDOSingleValueFeatureDeltaImpl implements CDORemoveFeatureDelta,
- ListIndexAffecting
-{
- public CDORemoveFeatureDeltaImpl(EStructuralFeature feature, int index)
- {
- super(feature, index, UNKNOWN_VALUE);
- }
-
- public CDORemoveFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
- {
- super(in, eClass);
- }
-
- @Override
- protected void writeValue(CDODataOutput out, EClass eClass) throws IOException
- {
- // Do nothing
- }
-
- @Override
- protected Object readValue(CDODataInput in, EClass eClass) throws IOException
- {
- return UNKNOWN_VALUE;
- }
-
- public Type getType()
- {
- return Type.REMOVE;
- }
-
- public CDOFeatureDelta copy()
- {
- CDORemoveFeatureDeltaImpl delta = new CDORemoveFeatureDeltaImpl(getFeature(), getIndex());
- delta.setValue(getValue());
- return delta;
- }
-
- public void apply(CDORevision revision)
- {
- ((InternalCDORevision)revision).getList(getFeature()).remove(getIndex());
- }
-
- public void accept(CDOFeatureDeltaVisitor visitor)
- {
- visitor.visit(this);
- }
-
- public void affectIndices(ListTargetAdding sources[], int[] indices)
- {
- int index = getIndex();
- for (int i = 1; i <= indices[0]; i++)
- {
- if (indices[i] > index)
- {
- --indices[i];
- }
- else if (indices[i] == index)
- {
- int rest = indices[0]-- - i;
- if (rest > 0)
- {
- System.arraycopy(indices, i + 1, indices, i, rest);
- System.arraycopy(sources, i + 1, sources, i, rest);
- --i;
- }
- }
- }
- }
-}
+/* + * 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.internal.common.revision.delta; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor; +import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.ListIndexAffecting; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; + +import java.io.IOException; + +/** + * @author Simon McDuff + */ +public class CDORemoveFeatureDeltaImpl extends CDOSingleValueFeatureDeltaImpl implements CDORemoveFeatureDelta, + ListIndexAffecting +{ + public CDORemoveFeatureDeltaImpl(EStructuralFeature feature, int index) + { + super(feature, index, UNKNOWN_VALUE); + } + + public CDORemoveFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException + { + super(in, eClass); + } + + @Override + protected void writeValue(CDODataOutput out, EClass eClass) throws IOException + { + // Do nothing + } + + @Override + protected Object readValue(CDODataInput in, EClass eClass) throws IOException + { + return UNKNOWN_VALUE; + } + + public Type getType() + { + return Type.REMOVE; + } + + public CDOFeatureDelta copy() + { + CDORemoveFeatureDeltaImpl delta = new CDORemoveFeatureDeltaImpl(getFeature(), getIndex()); + delta.setValue(getValue()); + return delta; + } + + public void apply(CDORevision revision) + { + ((InternalCDORevision)revision).getList(getFeature()).remove(getIndex()); + } + + public void accept(CDOFeatureDeltaVisitor visitor) + { + visitor.visit(this); + } + + public void affectIndices(ListTargetAdding sources[], int[] indices) + { + int index = getIndex(); + for (int i = 1; i <= indices[0]; i++) + { + if (indices[i] > index) + { + --indices[i]; + } + else if (indices[i] == index) + { + int rest = indices[0]-- - i; + if (rest > 0) + { + System.arraycopy(indices, i + 1, indices, i, rest); + System.arraycopy(sources, i + 1, sources, i, rest); + --i; + } + } + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOSetFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOSetFeatureDeltaImpl.java index 859e7c72b7..542d3fd2ce 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOSetFeatureDeltaImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOSetFeatureDeltaImpl.java @@ -1,97 +1,97 @@ -/*
- * 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.internal.common.revision.delta;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
-import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.ListTargetAdding;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-
-/**
- * @author Simon McDuff
- */
-public class CDOSetFeatureDeltaImpl extends CDOSingleValueFeatureDeltaImpl implements CDOSetFeatureDelta,
- ListTargetAdding
-{
- private Object oldValue = CDOSetFeatureDelta.UNSPECIFIED;
-
- public CDOSetFeatureDeltaImpl(EStructuralFeature feature, int index, Object value)
- {
- super(feature, index, value);
- }
-
- public CDOSetFeatureDeltaImpl(EStructuralFeature feature, int index, Object value, Object oldValue)
- {
- super(feature, index, value);
- this.oldValue = oldValue;
- }
-
- public CDOSetFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
- {
- super(in, eClass);
- }
-
- public Type getType()
- {
- return Type.SET;
- }
-
- public CDOFeatureDelta copy()
- {
- return new CDOSetFeatureDeltaImpl(getFeature(), getIndex(), getValue(), getOldValue());
- }
-
- public void apply(CDORevision revision)
- {
- ((InternalCDORevision)revision).set(getFeature(), getIndex(), getValue());
- }
-
- public void accept(CDOFeatureDeltaVisitor visitor)
- {
- visitor.visit(this);
- }
-
- public Object getOldValue()
- {
- return oldValue;
- }
-
- public void setOldValue(Object oldValue)
- {
- this.oldValue = oldValue;
- }
-
- @Override
- protected String toStringAdditional()
- {
- String oldValueForMessage;
- if (oldValue != CDOSetFeatureDelta.UNSPECIFIED)
- {
- oldValueForMessage = oldValue == null ? "null" : oldValue.toString();
- }
- else
- {
- oldValueForMessage = "UNSPECIFIED"; //$NON-NLS-1$
- }
-
- return super.toStringAdditional() + MessageFormat.format(", oldValue={0}", oldValueForMessage); //$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: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.internal.common.revision.delta; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor; +import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.ListTargetAdding; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; + +import java.io.IOException; +import java.text.MessageFormat; + +/** + * @author Simon McDuff + */ +public class CDOSetFeatureDeltaImpl extends CDOSingleValueFeatureDeltaImpl implements CDOSetFeatureDelta, + ListTargetAdding +{ + private Object oldValue = CDOSetFeatureDelta.UNSPECIFIED; + + public CDOSetFeatureDeltaImpl(EStructuralFeature feature, int index, Object value) + { + super(feature, index, value); + } + + public CDOSetFeatureDeltaImpl(EStructuralFeature feature, int index, Object value, Object oldValue) + { + super(feature, index, value); + this.oldValue = oldValue; + } + + public CDOSetFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException + { + super(in, eClass); + } + + public Type getType() + { + return Type.SET; + } + + public CDOFeatureDelta copy() + { + return new CDOSetFeatureDeltaImpl(getFeature(), getIndex(), getValue(), getOldValue()); + } + + public void apply(CDORevision revision) + { + ((InternalCDORevision)revision).set(getFeature(), getIndex(), getValue()); + } + + public void accept(CDOFeatureDeltaVisitor visitor) + { + visitor.visit(this); + } + + public Object getOldValue() + { + return oldValue; + } + + public void setOldValue(Object oldValue) + { + this.oldValue = oldValue; + } + + @Override + protected String toStringAdditional() + { + String oldValueForMessage; + if (oldValue != CDOSetFeatureDelta.UNSPECIFIED) + { + oldValueForMessage = oldValue == null ? "null" : oldValue.toString(); + } + else + { + oldValueForMessage = "UNSPECIFIED"; //$NON-NLS-1$ + } + + return super.toStringAdditional() + MessageFormat.format(", oldValue={0}", oldValueForMessage); //$NON-NLS-1$ + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOSingleValueFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOSingleValueFeatureDeltaImpl.java index 4977e1da15..029f532c33 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOSingleValueFeatureDeltaImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOSingleValueFeatureDeltaImpl.java @@ -1,185 +1,185 @@ -/*
- * 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.internal.common.revision.delta;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
-import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.WithIndex;
-
-import org.eclipse.net4j.util.ObjectUtil;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.util.FeatureMap;
-import org.eclipse.emf.ecore.util.FeatureMap.Entry;
-import org.eclipse.emf.ecore.util.FeatureMapUtil;
-
-import java.io.IOException;
-import java.text.MessageFormat;
-
-/**
- * @author Simon McDuff
- */
-public abstract class CDOSingleValueFeatureDeltaImpl extends CDOFeatureDeltaImpl implements WithIndex
-{
- private int index;
-
- private Object value;
-
- public CDOSingleValueFeatureDeltaImpl(EStructuralFeature feature, int index, Object value)
- {
- super(feature);
- this.index = index;
- this.value = value;
- }
-
- public CDOSingleValueFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
- {
- super(in, eClass);
- index = in.readInt();
- value = readValue(in, eClass);
- }
-
- @Override
- public void write(CDODataOutput out, EClass eClass) throws IOException
- {
- super.write(out, eClass);
- out.writeInt(index);
- writeValue(out, eClass);
- }
-
- protected void writeValue(CDODataOutput out, EClass eClass) throws IOException
- {
- Object valueToWrite = value;
- if (valueToWrite == UNKNOWN_VALUE)
- {
- throw new IOException("Value is unknown");
- }
-
- EStructuralFeature feature = getFeature();
- if (FeatureMapUtil.isFeatureMap(feature))
- {
- FeatureMap.Entry entry = (Entry)valueToWrite;
- feature = entry.getEStructuralFeature();
- valueToWrite = entry.getValue();
-
- int featureID = eClass.getFeatureID(feature);
- out.writeInt(featureID);
- }
-
- if (valueToWrite != null && feature instanceof EReference)
- {
- valueToWrite = out.getIDProvider().provideCDOID(value);
- }
-
- out.writeCDOFeatureValue(feature, valueToWrite);
- }
-
- protected Object readValue(CDODataInput in, EClass eClass) throws IOException
- {
- EStructuralFeature feature = getFeature();
- if (FeatureMapUtil.isFeatureMap(feature))
- {
- int featureID = in.readInt();
- feature = eClass.getEStructuralFeature(featureID);
- Object innerValue = in.readCDOFeatureValue(feature);
- return CDORevisionUtil.createFeatureMapEntry(feature, innerValue);
- }
-
- return in.readCDOFeatureValue(feature);
- }
-
- public int getIndex()
- {
- return index;
- }
-
- public void setIndex(int index)
- {
- this.index = index;
- }
-
- public Object getValue()
- {
- return value;
- }
-
- public void setValue(Object value)
- {
- this.value = value;
- }
-
- public void clear()
- {
- setValue(CDOID.NULL);
- }
-
- public void adjustAfterAddition(int index)
- {
- if (index <= this.index)
- {
- ++this.index;
- }
- }
-
- public void adjustAfterRemoval(int index)
- {
- if (index < this.index && this.index > 0)
- {
- --this.index;
- }
- }
-
- @Override
- public boolean adjustReferences(CDOReferenceAdjuster referenceAdjuster)
- {
- if (value != UNKNOWN_VALUE)
- {
- Object adjustedValue = referenceAdjuster.adjustReference(value, getFeature(), NO_INDEX);
- if (adjustedValue != value)
- {
- value = adjustedValue;
- return true;
- }
- }
-
- return false;
- }
-
- @Override
- public boolean isStructurallyEqual(Object obj)
- {
- if (!super.isStructurallyEqual(obj))
- {
- return false;
- }
-
- CDOSingleValueFeatureDeltaImpl that = (CDOSingleValueFeatureDeltaImpl)obj;
- return index == that.getIndex() && ObjectUtil.equals(value, that.getValue());
- }
-
- @Override
- protected String toStringAdditional()
- {
- if (index == Notification.NO_INDEX)
- {
- return MessageFormat.format("value={0}", value); //$NON-NLS-1$
- }
-
- return MessageFormat.format("value={0}, index={1}", value, index); //$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: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.internal.common.revision.delta; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.revision.CDORevisionUtil; +import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDOFeatureDelta.WithIndex; + +import org.eclipse.net4j.util.ObjectUtil; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.util.FeatureMap; +import org.eclipse.emf.ecore.util.FeatureMap.Entry; +import org.eclipse.emf.ecore.util.FeatureMapUtil; + +import java.io.IOException; +import java.text.MessageFormat; + +/** + * @author Simon McDuff + */ +public abstract class CDOSingleValueFeatureDeltaImpl extends CDOFeatureDeltaImpl implements WithIndex +{ + private int index; + + private Object value; + + public CDOSingleValueFeatureDeltaImpl(EStructuralFeature feature, int index, Object value) + { + super(feature); + this.index = index; + this.value = value; + } + + public CDOSingleValueFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException + { + super(in, eClass); + index = in.readInt(); + value = readValue(in, eClass); + } + + @Override + public void write(CDODataOutput out, EClass eClass) throws IOException + { + super.write(out, eClass); + out.writeInt(index); + writeValue(out, eClass); + } + + protected void writeValue(CDODataOutput out, EClass eClass) throws IOException + { + Object valueToWrite = value; + if (valueToWrite == UNKNOWN_VALUE) + { + throw new IOException("Value is unknown"); + } + + EStructuralFeature feature = getFeature(); + if (FeatureMapUtil.isFeatureMap(feature)) + { + FeatureMap.Entry entry = (Entry)valueToWrite; + feature = entry.getEStructuralFeature(); + valueToWrite = entry.getValue(); + + int featureID = eClass.getFeatureID(feature); + out.writeInt(featureID); + } + + if (valueToWrite != null && feature instanceof EReference) + { + valueToWrite = out.getIDProvider().provideCDOID(value); + } + + out.writeCDOFeatureValue(feature, valueToWrite); + } + + protected Object readValue(CDODataInput in, EClass eClass) throws IOException + { + EStructuralFeature feature = getFeature(); + if (FeatureMapUtil.isFeatureMap(feature)) + { + int featureID = in.readInt(); + feature = eClass.getEStructuralFeature(featureID); + Object innerValue = in.readCDOFeatureValue(feature); + return CDORevisionUtil.createFeatureMapEntry(feature, innerValue); + } + + return in.readCDOFeatureValue(feature); + } + + public int getIndex() + { + return index; + } + + public void setIndex(int index) + { + this.index = index; + } + + public Object getValue() + { + return value; + } + + public void setValue(Object value) + { + this.value = value; + } + + public void clear() + { + setValue(CDOID.NULL); + } + + public void adjustAfterAddition(int index) + { + if (index <= this.index) + { + ++this.index; + } + } + + public void adjustAfterRemoval(int index) + { + if (index < this.index && this.index > 0) + { + --this.index; + } + } + + @Override + public boolean adjustReferences(CDOReferenceAdjuster referenceAdjuster) + { + if (value != UNKNOWN_VALUE) + { + Object adjustedValue = referenceAdjuster.adjustReference(value, getFeature(), NO_INDEX); + if (adjustedValue != value) + { + value = adjustedValue; + return true; + } + } + + return false; + } + + @Override + public boolean isStructurallyEqual(Object obj) + { + if (!super.isStructurallyEqual(obj)) + { + return false; + } + + CDOSingleValueFeatureDeltaImpl that = (CDOSingleValueFeatureDeltaImpl)obj; + return index == that.getIndex() && ObjectUtil.equals(value, that.getValue()); + } + + @Override + protected String toStringAdditional() + { + if (index == Notification.NO_INDEX) + { + return MessageFormat.format("value={0}", value); //$NON-NLS-1$ + } + + return MessageFormat.format("value={0}, index={1}", value, index); //$NON-NLS-1$ + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOUnsetFeatureDeltaImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOUnsetFeatureDeltaImpl.java index 5c52f2a197..68975bb91e 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOUnsetFeatureDeltaImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/internal/common/revision/delta/CDOUnsetFeatureDeltaImpl.java @@ -1,73 +1,73 @@ -/*
- * 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.internal.common.revision.delta;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
-import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta;
-import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.io.IOException;
-
-/**
- * @author Simon McDuff
- */
-public class CDOUnsetFeatureDeltaImpl extends CDOFeatureDeltaImpl implements CDOUnsetFeatureDelta
-{
- public CDOUnsetFeatureDeltaImpl(EStructuralFeature feature)
- {
- super(feature);
- }
-
- public CDOUnsetFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException
- {
- super(in, eClass);
- }
-
- public Type getType()
- {
- return Type.UNSET;
- }
-
- public CDOFeatureDelta copy()
- {
- return new CDOUnsetFeatureDeltaImpl(getFeature());
- }
-
- public void apply(CDORevision revision)
- {
- ((InternalCDORevision)revision).unset(getFeature());
- }
-
- public void accept(CDOFeatureDeltaVisitor visitor)
- {
- visitor.visit(this);
- }
-
- @Override
- public boolean adjustReferences(CDOReferenceAdjuster adjuster)
- {
- return false;
- }
-
- @Override
- protected String toStringAdditional()
- {
- 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: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.internal.common.revision.delta; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor; +import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta; +import org.eclipse.emf.cdo.spi.common.revision.CDOReferenceAdjuster; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EStructuralFeature; + +import java.io.IOException; + +/** + * @author Simon McDuff + */ +public class CDOUnsetFeatureDeltaImpl extends CDOFeatureDeltaImpl implements CDOUnsetFeatureDelta +{ + public CDOUnsetFeatureDeltaImpl(EStructuralFeature feature) + { + super(feature); + } + + public CDOUnsetFeatureDeltaImpl(CDODataInput in, EClass eClass) throws IOException + { + super(in, eClass); + } + + public Type getType() + { + return Type.UNSET; + } + + public CDOFeatureDelta copy() + { + return new CDOUnsetFeatureDeltaImpl(getFeature()); + } + + public void apply(CDORevision revision) + { + ((InternalCDORevision)revision).unset(getFeature()); + } + + public void accept(CDOFeatureDeltaVisitor visitor) + { + visitor.visit(this); + } + + @Override + public boolean adjustReferences(CDOReferenceAdjuster adjuster) + { + return false; + } + + @Override + protected String toStringAdditional() + { + return null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/AbstractQueryResult.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/AbstractQueryResult.java index 0716feabf7..b445291abc 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/AbstractQueryResult.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/AbstractQueryResult.java @@ -1,104 +1,104 @@ -/*
- * 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.spi.common;
-
-import org.eclipse.emf.cdo.common.CDOCommonView;
-import org.eclipse.emf.cdo.common.util.BlockingCloseableIterator;
-import org.eclipse.emf.cdo.common.util.CDOQueryInfo;
-import org.eclipse.emf.cdo.common.util.CDOQueryQueue;
-
-/**
- * @author Simon McDuff
- * @since 2.0
- */
-public class AbstractQueryResult<T> implements BlockingCloseableIterator<T>
-{
- private int queryID;
-
- private CDOCommonView view;
-
- private CDOQueryInfo queryInfo;
-
- private CDOQueryQueue<Object> linkQueue = new CDOQueryQueue<Object>();
-
- private BlockingCloseableIterator<Object> queueItr = linkQueue.iterator();
-
- /**
- * @since 3.0
- */
- public AbstractQueryResult(CDOCommonView view, CDOQueryInfo queryInfo, int queryID)
- {
- this.queryID = queryID;
- this.view = view;
- this.queryInfo = queryInfo;
- }
-
- /**
- * @since 3.0
- */
- public CDOQueryInfo getQueryInfo()
- {
- return queryInfo;
- }
-
- public CDOQueryQueue<Object> getQueue()
- {
- return linkQueue;
- }
-
- public CDOCommonView getView()
- {
- return view;
- }
-
- public int getQueryID()
- {
- return queryID;
- }
-
- public void setQueryID(int queryID)
- {
- this.queryID = queryID;
- }
-
- @SuppressWarnings("unchecked")
- public T peek()
- {
- return (T)queueItr.peek();
- }
-
- public boolean hasNext()
- {
- return queueItr.hasNext();
- }
-
- @SuppressWarnings("unchecked")
- public T next()
- {
- return (T)queueItr.next();
- }
-
- public void remove()
- {
- throw new UnsupportedOperationException();
- }
-
- public void close()
- {
- queueItr.close();
- }
-
- public boolean isClosed()
- {
- return queueItr.isClosed();
- }
-}
+/* + * 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.spi.common; + +import org.eclipse.emf.cdo.common.CDOCommonView; +import org.eclipse.emf.cdo.common.util.BlockingCloseableIterator; +import org.eclipse.emf.cdo.common.util.CDOQueryInfo; +import org.eclipse.emf.cdo.common.util.CDOQueryQueue; + +/** + * @author Simon McDuff + * @since 2.0 + */ +public class AbstractQueryResult<T> implements BlockingCloseableIterator<T> +{ + private int queryID; + + private CDOCommonView view; + + private CDOQueryInfo queryInfo; + + private CDOQueryQueue<Object> linkQueue = new CDOQueryQueue<Object>(); + + private BlockingCloseableIterator<Object> queueItr = linkQueue.iterator(); + + /** + * @since 3.0 + */ + public AbstractQueryResult(CDOCommonView view, CDOQueryInfo queryInfo, int queryID) + { + this.queryID = queryID; + this.view = view; + this.queryInfo = queryInfo; + } + + /** + * @since 3.0 + */ + public CDOQueryInfo getQueryInfo() + { + return queryInfo; + } + + public CDOQueryQueue<Object> getQueue() + { + return linkQueue; + } + + public CDOCommonView getView() + { + return view; + } + + public int getQueryID() + { + return queryID; + } + + public void setQueryID(int queryID) + { + this.queryID = queryID; + } + + @SuppressWarnings("unchecked") + public T peek() + { + return (T)queueItr.peek(); + } + + public boolean hasNext() + { + return queueItr.hasNext(); + } + + @SuppressWarnings("unchecked") + public T next() + { + return (T)queueItr.next(); + } + + public void remove() + { + throw new UnsupportedOperationException(); + } + + public void close() + { + queueItr.close(); + } + + public boolean isClosed() + { + return queueItr.isClosed(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDOAuthenticationResult.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDOAuthenticationResult.java index 4a513e7906..02fb08a08b 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDOAuthenticationResult.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDOAuthenticationResult.java @@ -1,60 +1,60 @@ -/*
- * 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.spi.common;
-
-import org.eclipse.net4j.util.io.ExtendedDataInput;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
-
-import java.io.IOException;
-import java.io.Serializable;
-
-/**
- * The result of an authentication operation. Carries a userID and a crypted token.
- *
- * @author Eike Stepper
- * @since 4.0
- */
-public final class CDOAuthenticationResult implements Serializable
-{
- private static final long serialVersionUID = 1L;
-
- private String userID;
-
- private byte[] cryptedToken;
-
- public CDOAuthenticationResult(String userID, byte[] cryptedToken)
- {
- this.userID = userID;
- this.cryptedToken = cryptedToken;
- }
-
- public CDOAuthenticationResult(ExtendedDataInput in) throws IOException
- {
- userID = in.readString();
- cryptedToken = in.readByteArray();
- }
-
- public void write(ExtendedDataOutput out) throws IOException
- {
- out.writeString(userID);
- out.writeByteArray(cryptedToken);
- }
-
- public String getUserID()
- {
- return userID;
- }
-
- public byte[] getCryptedToken()
- {
- return cryptedToken;
- }
-}
+/* + * 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.spi.common; + +import org.eclipse.net4j.util.io.ExtendedDataInput; +import org.eclipse.net4j.util.io.ExtendedDataOutput; + +import java.io.IOException; +import java.io.Serializable; + +/** + * The result of an authentication operation. Carries a userID and a crypted token. + * + * @author Eike Stepper + * @since 4.0 + */ +public final class CDOAuthenticationResult implements Serializable +{ + private static final long serialVersionUID = 1L; + + private String userID; + + private byte[] cryptedToken; + + public CDOAuthenticationResult(String userID, byte[] cryptedToken) + { + this.userID = userID; + this.cryptedToken = cryptedToken; + } + + public CDOAuthenticationResult(ExtendedDataInput in) throws IOException + { + userID = in.readString(); + cryptedToken = in.readByteArray(); + } + + public void write(ExtendedDataOutput out) throws IOException + { + out.writeString(userID); + out.writeByteArray(cryptedToken); + } + + public String getUserID() + { + return userID; + } + + public byte[] getCryptedToken() + { + return cryptedToken; + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDOLobStoreImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDOLobStoreImpl.java index 0fffa37750..3f525b10c4 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDOLobStoreImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDOLobStoreImpl.java @@ -1,197 +1,197 @@ -/*
- * 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.spi.common;
-
-import org.eclipse.emf.cdo.common.lob.CDOLobInfo;
-import org.eclipse.emf.cdo.common.lob.CDOLobStore;
-
-import org.eclipse.net4j.util.HexUtil;
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.io.DigestWriter;
-import org.eclipse.net4j.util.io.ExpectedFileInputStream;
-import org.eclipse.net4j.util.io.ExpectedFileReader;
-import org.eclipse.net4j.util.io.IORuntimeException;
-import org.eclipse.net4j.util.io.IOUtil;
-import org.eclipse.net4j.util.om.OMPlatform;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.security.DigestOutputStream;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-/**
- * @author Eike Stepper
- * @since 4.0
- */
-public class CDOLobStoreImpl implements CDOLobStore
-{
- public static final CDOLobStoreImpl INSTANCE = new CDOLobStoreImpl();
-
- private File folder;
-
- private int tempID;
-
- public CDOLobStoreImpl(File folder)
- {
- this.folder = folder;
- if (folder.exists())
- {
- checkDirectory();
- }
- }
-
- public CDOLobStoreImpl()
- {
- this(getDefaultFolder());
- }
-
- public File getFolder()
- {
- if (!folder.exists())
- {
- folder.mkdirs();
- }
-
- checkDirectory();
- return folder;
- }
-
- public File getBinaryFile(byte[] id)
- {
- return new File(getFolder(), HexUtil.bytesToHex(id) + ".blob");
- }
-
- public InputStream getBinary(CDOLobInfo info) throws IOException
- {
- File file = getBinaryFile(info.getID());
- long expectedSize = info.getSize();
- return new ExpectedFileInputStream(file, expectedSize);
- }
-
- public CDOLobInfo putBinary(InputStream contents) throws IOException
- {
- File tempFile = getTempFile();
- MessageDigest digest = createDigest();
- digest.update("BINARY".getBytes());
-
- FileOutputStream fos = null;
- long size;
-
- try
- {
- fos = new FileOutputStream(tempFile);
- DigestOutputStream dos = new DigestOutputStream(fos, digest);
- size = IOUtil.copyBinary(contents, dos);
- }
- finally
- {
- IOUtil.close(fos);
- }
-
- byte[] id = digest.digest();
- makePermanent(tempFile, getBinaryFile(id));
- return new CDOLobInfo(id, size);
- }
-
- public File getCharacterFile(byte[] id)
- {
- return new File(getFolder(), HexUtil.bytesToHex(id) + ".clob");
- }
-
- public Reader getCharacter(CDOLobInfo info) throws IOException
- {
- File file = getCharacterFile(info.getID());
- long expectedSize = info.getSize();
- return new ExpectedFileReader(file, expectedSize);
-
- }
-
- public CDOLobInfo putCharacter(Reader contents) throws IOException
- {
- File tempFile = getTempFile();
- MessageDigest digest = createDigest();
- digest.update("CHARACTER".getBytes());
-
- FileWriter fw = null;
- long size;
-
- try
- {
- fw = new FileWriter(tempFile);
- DigestWriter dw = new DigestWriter(fw, digest);
- size = IOUtil.copyCharacter(contents, dw);
- }
- finally
- {
- IOUtil.close(fw);
- }
-
- byte[] id = digest.digest();
- makePermanent(tempFile, getCharacterFile(id));
- return new CDOLobInfo(id, size);
- }
-
- protected MessageDigest createDigest()
- {
- try
- {
- return MessageDigest.getInstance("SHA-1");
- }
- catch (NoSuchAlgorithmException ex)
- {
- throw WrappedException.wrap(ex);
- }
- }
-
- protected synchronized File getTempFile()
- {
- for (;;)
- {
- ++tempID;
- File file = new File(getFolder(), "contents" + tempID + ".tmp");
- if (!file.exists())
- {
- return file;
- }
- }
- }
-
- private void makePermanent(File tempFile, File file)
- {
- if (file.exists())
- {
- tempFile.delete();
- }
- else
- {
- tempFile.renameTo(file);
- }
- }
-
- private void checkDirectory()
- {
- if (!folder.isDirectory())
- {
- throw new IORuntimeException("Not a folder: " + folder.getAbsolutePath());
- }
- }
-
- private static File getDefaultFolder()
- {
- String path = OMPlatform.INSTANCE.getProperty("java.io.tmpdir");
- return new File(new File(path), "cdo_lobs");
- }
-}
+/* + * 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.spi.common; + +import org.eclipse.emf.cdo.common.lob.CDOLobInfo; +import org.eclipse.emf.cdo.common.lob.CDOLobStore; + +import org.eclipse.net4j.util.HexUtil; +import org.eclipse.net4j.util.WrappedException; +import org.eclipse.net4j.util.io.DigestWriter; +import org.eclipse.net4j.util.io.ExpectedFileInputStream; +import org.eclipse.net4j.util.io.ExpectedFileReader; +import org.eclipse.net4j.util.io.IORuntimeException; +import org.eclipse.net4j.util.io.IOUtil; +import org.eclipse.net4j.util.om.OMPlatform; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.security.DigestOutputStream; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +/** + * @author Eike Stepper + * @since 4.0 + */ +public class CDOLobStoreImpl implements CDOLobStore +{ + public static final CDOLobStoreImpl INSTANCE = new CDOLobStoreImpl(); + + private File folder; + + private int tempID; + + public CDOLobStoreImpl(File folder) + { + this.folder = folder; + if (folder.exists()) + { + checkDirectory(); + } + } + + public CDOLobStoreImpl() + { + this(getDefaultFolder()); + } + + public File getFolder() + { + if (!folder.exists()) + { + folder.mkdirs(); + } + + checkDirectory(); + return folder; + } + + public File getBinaryFile(byte[] id) + { + return new File(getFolder(), HexUtil.bytesToHex(id) + ".blob"); + } + + public InputStream getBinary(CDOLobInfo info) throws IOException + { + File file = getBinaryFile(info.getID()); + long expectedSize = info.getSize(); + return new ExpectedFileInputStream(file, expectedSize); + } + + public CDOLobInfo putBinary(InputStream contents) throws IOException + { + File tempFile = getTempFile(); + MessageDigest digest = createDigest(); + digest.update("BINARY".getBytes()); + + FileOutputStream fos = null; + long size; + + try + { + fos = new FileOutputStream(tempFile); + DigestOutputStream dos = new DigestOutputStream(fos, digest); + size = IOUtil.copyBinary(contents, dos); + } + finally + { + IOUtil.close(fos); + } + + byte[] id = digest.digest(); + makePermanent(tempFile, getBinaryFile(id)); + return new CDOLobInfo(id, size); + } + + public File getCharacterFile(byte[] id) + { + return new File(getFolder(), HexUtil.bytesToHex(id) + ".clob"); + } + + public Reader getCharacter(CDOLobInfo info) throws IOException + { + File file = getCharacterFile(info.getID()); + long expectedSize = info.getSize(); + return new ExpectedFileReader(file, expectedSize); + + } + + public CDOLobInfo putCharacter(Reader contents) throws IOException + { + File tempFile = getTempFile(); + MessageDigest digest = createDigest(); + digest.update("CHARACTER".getBytes()); + + FileWriter fw = null; + long size; + + try + { + fw = new FileWriter(tempFile); + DigestWriter dw = new DigestWriter(fw, digest); + size = IOUtil.copyCharacter(contents, dw); + } + finally + { + IOUtil.close(fw); + } + + byte[] id = digest.digest(); + makePermanent(tempFile, getCharacterFile(id)); + return new CDOLobInfo(id, size); + } + + protected MessageDigest createDigest() + { + try + { + return MessageDigest.getInstance("SHA-1"); + } + catch (NoSuchAlgorithmException ex) + { + throw WrappedException.wrap(ex); + } + } + + protected synchronized File getTempFile() + { + for (;;) + { + ++tempID; + File file = new File(getFolder(), "contents" + tempID + ".tmp"); + if (!file.exists()) + { + return file; + } + } + } + + private void makePermanent(File tempFile, File file) + { + if (file.exists()) + { + tempFile.delete(); + } + else + { + tempFile.renameTo(file); + } + } + + private void checkDirectory() + { + if (!folder.isDirectory()) + { + throw new IORuntimeException("Not a folder: " + folder.getAbsolutePath()); + } + } + + private static File getDefaultFolder() + { + String path = OMPlatform.INSTANCE.getProperty("java.io.tmpdir"); + return new File(new File(path), "cdo_lobs"); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDORawReplicationContext.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDORawReplicationContext.java index f5d5151253..108a8963f3 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDORawReplicationContext.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDORawReplicationContext.java @@ -1,29 +1,29 @@ -/*
- * 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.spi.common;
-
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-
-import org.eclipse.net4j.util.om.monitor.OMMonitor;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- * @since 3.0
- */
-public interface CDORawReplicationContext extends CDOReplicationInfo
-{
- /**
- * @since 4.0
- */
- public void replicateRaw(CDODataInput in, OMMonitor monitor) 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.spi.common; + +import org.eclipse.emf.cdo.common.protocol.CDODataInput; + +import org.eclipse.net4j.util.om.monitor.OMMonitor; + +import java.io.IOException; + +/** + * @author Eike Stepper + * @since 3.0 + */ +public interface CDORawReplicationContext extends CDOReplicationInfo +{ + /** + * @since 4.0 + */ + public void replicateRaw(CDODataInput in, OMMonitor monitor) throws IOException; +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDOReplicationContext.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDOReplicationContext.java index 68f9b8550e..f726abe317 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDOReplicationContext.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDOReplicationContext.java @@ -1,25 +1,25 @@ -/*
- * 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.spi.common;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchHandler;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
-import org.eclipse.emf.cdo.common.lock.IDurableLockingManager;
-
-/**
- * @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 CDOReplicationContext extends CDOReplicationInfo, CDOBranchHandler, CDOCommitInfoHandler,
- IDurableLockingManager.LockArea.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.spi.common; + +import org.eclipse.emf.cdo.common.branch.CDOBranchHandler; +import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler; +import org.eclipse.emf.cdo.common.lock.IDurableLockingManager; + +/** + * @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 CDOReplicationContext extends CDOReplicationInfo, CDOBranchHandler, CDOCommitInfoHandler, + IDurableLockingManager.LockArea.Handler +{ +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDOReplicationInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDOReplicationInfo.java index d3126aeaa9..fbecebd869 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDOReplicationInfo.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/CDOReplicationInfo.java @@ -1,29 +1,29 @@ -/*
- * 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
- * Caspar De Groot - maintenance
- */
-package org.eclipse.emf.cdo.spi.common;
-
-/**
- * @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 CDOReplicationInfo
-{
- public int getLastReplicatedBranchID();
-
- public long getLastReplicatedCommitTime();
-
- /**
- * @since 4.1
- */
- public String[] getLockAreaIDs();
-}
+/* + * 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 + * Caspar De Groot - maintenance + */ +package org.eclipse.emf.cdo.spi.common; + +/** + * @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 CDOReplicationInfo +{ + public int getLastReplicatedBranchID(); + + public long getLastReplicatedCommitTime(); + + /** + * @since 4.1 + */ + public String[] getLockAreaIDs(); +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/branch/CDOBranchUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/branch/CDOBranchUtil.java index dfc206b380..dcd1cec1f9 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/branch/CDOBranchUtil.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/branch/CDOBranchUtil.java @@ -1,124 +1,124 @@ -/*
- * 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.spi.common.branch;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPointRange;
-import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
-import org.eclipse.emf.cdo.internal.common.branch.CDOBranchManagerImpl;
-import org.eclipse.emf.cdo.internal.common.branch.CDOBranchPointRangeImpl;
-
-import org.eclipse.net4j.util.ObjectUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- * @since 3.0
- */
-public final class CDOBranchUtil
-{
- private CDOBranchUtil()
- {
- }
-
- public static InternalCDOBranchManager createBranchManager()
- {
- return new CDOBranchManagerImpl();
- }
-
- public static CDOBranchPointRange createRange(CDOBranchPoint startPoint, CDOBranchPoint endPoint)
- {
- return new CDOBranchPointRangeImpl(startPoint, endPoint);
- }
-
- public static CDOBranchPoint copyBranchPoint(CDOBranchPoint source)
- {
- return source.getBranch().getPoint(source.getTimeStamp());
- }
-
- public static CDOBranchVersion copyBranchVersion(CDOBranchVersion source)
- {
- return source.getBranch().getVersion(source.getVersion());
- }
-
- public static boolean isContainedBy(CDOBranchPoint contained, CDOBranchPoint container)
- {
- CDOBranch containerBranch = container.getBranch();
- if (ObjectUtil.equals(containerBranch, contained.getBranch()))
- {
- return CDOCommonUtil.compareTimeStamps(contained.getTimeStamp(), container.getTimeStamp()) <= 0;
- }
-
- if (containerBranch == null)
- {
- return false;
- }
-
- return isContainedBy(contained, containerBranch.getBase());
- }
-
- public static CDOBranchPoint getAncestor(CDOBranchPoint point1, CDOBranchPoint point2)
- {
- if (point1.getBranch() == null)
- {
- // Must be the main branch base
- return point1;
- }
-
- if (point2.getBranch() == null)
- {
- // Must be the main branch base
- return point2;
- }
-
- CDOBranchPoint[] path1 = getPath(point1);
- CDOBranchPoint[] path2 = getPath(point2);
- for (CDOBranchPoint pathPoint1 : path1)
- {
- for (CDOBranchPoint pathPoint2 : path2)
- {
- if (ObjectUtil.equals(pathPoint1.getBranch(), pathPoint2.getBranch()))
- {
- if (CDOCommonUtil.compareTimeStamps(pathPoint1.getTimeStamp(), pathPoint2.getTimeStamp()) < 0)
- {
- return pathPoint1;
- }
-
- return pathPoint2;
- }
- }
- }
-
- // Can not happen because any two branches meet on the main branch
- return null;
- }
-
- public static CDOBranchPoint[] getPath(CDOBranchPoint point)
- {
- List<CDOBranchPoint> result = new ArrayList<CDOBranchPoint>();
- getPath(point, result);
- return result.toArray(new CDOBranchPoint[result.size()]);
- }
-
- private static void getPath(CDOBranchPoint point, List<CDOBranchPoint> result)
- {
- CDOBranch branch = point.getBranch();
- if (branch != null)
- {
- result.add(point);
- getPath(branch.getBase(), result);
- }
- }
-}
+/* + * 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.spi.common.branch; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.branch.CDOBranchPointRange; +import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; +import org.eclipse.emf.cdo.common.util.CDOCommonUtil; +import org.eclipse.emf.cdo.internal.common.branch.CDOBranchManagerImpl; +import org.eclipse.emf.cdo.internal.common.branch.CDOBranchPointRangeImpl; + +import org.eclipse.net4j.util.ObjectUtil; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author Eike Stepper + * @since 3.0 + */ +public final class CDOBranchUtil +{ + private CDOBranchUtil() + { + } + + public static InternalCDOBranchManager createBranchManager() + { + return new CDOBranchManagerImpl(); + } + + public static CDOBranchPointRange createRange(CDOBranchPoint startPoint, CDOBranchPoint endPoint) + { + return new CDOBranchPointRangeImpl(startPoint, endPoint); + } + + public static CDOBranchPoint copyBranchPoint(CDOBranchPoint source) + { + return source.getBranch().getPoint(source.getTimeStamp()); + } + + public static CDOBranchVersion copyBranchVersion(CDOBranchVersion source) + { + return source.getBranch().getVersion(source.getVersion()); + } + + public static boolean isContainedBy(CDOBranchPoint contained, CDOBranchPoint container) + { + CDOBranch containerBranch = container.getBranch(); + if (ObjectUtil.equals(containerBranch, contained.getBranch())) + { + return CDOCommonUtil.compareTimeStamps(contained.getTimeStamp(), container.getTimeStamp()) <= 0; + } + + if (containerBranch == null) + { + return false; + } + + return isContainedBy(contained, containerBranch.getBase()); + } + + public static CDOBranchPoint getAncestor(CDOBranchPoint point1, CDOBranchPoint point2) + { + if (point1.getBranch() == null) + { + // Must be the main branch base + return point1; + } + + if (point2.getBranch() == null) + { + // Must be the main branch base + return point2; + } + + CDOBranchPoint[] path1 = getPath(point1); + CDOBranchPoint[] path2 = getPath(point2); + for (CDOBranchPoint pathPoint1 : path1) + { + for (CDOBranchPoint pathPoint2 : path2) + { + if (ObjectUtil.equals(pathPoint1.getBranch(), pathPoint2.getBranch())) + { + if (CDOCommonUtil.compareTimeStamps(pathPoint1.getTimeStamp(), pathPoint2.getTimeStamp()) < 0) + { + return pathPoint1; + } + + return pathPoint2; + } + } + } + + // Can not happen because any two branches meet on the main branch + return null; + } + + public static CDOBranchPoint[] getPath(CDOBranchPoint point) + { + List<CDOBranchPoint> result = new ArrayList<CDOBranchPoint>(); + getPath(point, result); + return result.toArray(new CDOBranchPoint[result.size()]); + } + + private static void getPath(CDOBranchPoint point, List<CDOBranchPoint> result) + { + CDOBranch branch = point.getBranch(); + if (branch != null) + { + result.add(point); + getPath(branch.getBase(), result); + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/branch/InternalCDOBranch.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/branch/InternalCDOBranch.java index 522addc62c..066e9d3cd7 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/branch/InternalCDOBranch.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/branch/InternalCDOBranch.java @@ -1,46 +1,46 @@ -/*
- * 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.spi.common.branch;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo;
-
-/**
- * @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 InternalCDOBranch extends CDOBranch
-{
- public boolean isProxy();
-
- public InternalCDOBranchManager getBranchManager();
-
- public InternalCDOBranch[] getBranches();
-
- /**
- * @since 4.0
- */
- public InternalCDOBranch[] getBranches(boolean loadOnDemand);
-
- public InternalCDOBranch getBranch(String path);
-
- public InternalCDOBranch createBranch(String name, long timeStamp);
-
- public InternalCDOBranch createBranch(String name);
-
- public BranchInfo getBranchInfo();
-
- public void setBranchInfo(String name, InternalCDOBranch baseBranch, long baseTimeStamp);
-
- public void addChild(InternalCDOBranch 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.spi.common.branch; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo; + +/** + * @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 InternalCDOBranch extends CDOBranch +{ + public boolean isProxy(); + + public InternalCDOBranchManager getBranchManager(); + + public InternalCDOBranch[] getBranches(); + + /** + * @since 4.0 + */ + public InternalCDOBranch[] getBranches(boolean loadOnDemand); + + public InternalCDOBranch getBranch(String path); + + public InternalCDOBranch createBranch(String name, long timeStamp); + + public InternalCDOBranch createBranch(String name); + + public BranchInfo getBranchInfo(); + + public void setBranchInfo(String name, InternalCDOBranch baseBranch, long baseTimeStamp); + + public void addChild(InternalCDOBranch branch); +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/branch/InternalCDOBranchManager.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/branch/InternalCDOBranchManager.java index 04242a6648..667d3869f5 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/branch/InternalCDOBranchManager.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/branch/InternalCDOBranchManager.java @@ -1,190 +1,190 @@ -/*
- * 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.spi.common.branch;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchHandler;
-import org.eclipse.emf.cdo.common.branch.CDOBranchManager;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.common.util.CDOTimeProvider;
-import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo;
-
-import org.eclipse.net4j.util.collection.Pair;
-import org.eclipse.net4j.util.lifecycle.ILifecycle;
-
-import java.io.IOException;
-
-/**
- * @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 InternalCDOBranchManager extends CDOBranchManager, ILifecycle
-{
- public BranchLoader getBranchLoader();
-
- public void setBranchLoader(BranchLoader branchLoader);
-
- public CDOTimeProvider getTimeProvider();
-
- public void setTimeProvider(CDOTimeProvider timeProvider);
-
- /**
- * @since 4.0
- */
- public void initMainBranch(boolean local, long timestamp);
-
- public InternalCDOBranch getMainBranch();
-
- public InternalCDOBranch getBranch(int branchID);
-
- public InternalCDOBranch getBranch(int id, String name, InternalCDOBranch baseBranch, long baseTimeStamp);
-
- public InternalCDOBranch getBranch(int id, BranchInfo branchInfo);
-
- public InternalCDOBranch getBranch(String path);
-
- public InternalCDOBranch createBranch(int id, String name, InternalCDOBranch baseBranch, long baseTimeStamp);
-
- public void handleBranchCreated(InternalCDOBranch branch);
-
- /**
- * @author Eike Stepper
- * @since 3.0
- */
- public interface BranchLoader
- {
- /**
- * Passed as the branchID in {@link #createBranch(int, BranchInfo)} causes a new non-local branch to be created.
- */
- public static final int NEW_BRANCH = Integer.MAX_VALUE;
-
- /**
- * Passed as the branchID in {@link #createBranch(int, BranchInfo)} causes a new local branch to be created.
- */
- public static final int NEW_LOCAL_BRANCH = Integer.MIN_VALUE;
-
- /**
- * Creates a new branch with the given id and branch info. If the id is equal to {@link #NEW_BRANCH} the implementor
- * of this method will determine a new positive unique branch id. If the id is equal to {@link #NEW_LOCAL_BRANCH}
- * the implementor of this method will determine a new negative unique branch id, so that the new branch becomes a
- * local branch. In either case the used branch id is returned to the caller.
- *
- * @since 4.0
- */
- public Pair<Integer, Long> createBranch(int branchID, BranchInfo branchInfo);
-
- public BranchInfo loadBranch(int branchID);
-
- public SubBranchInfo[] loadSubBranches(int branchID);
-
- public int loadBranches(int startID, int endID, CDOBranchHandler branchHandler);
-
- /**
- * @author Eike Stepper
- * @since 3.0
- */
- public static final class BranchInfo
- {
- private String name;
-
- private int baseBranchID;
-
- private long baseTimeStamp;
-
- public BranchInfo(String name, int baseBranchID, long baseTimeStamp)
- {
- this.name = name;
- this.baseBranchID = baseBranchID;
- this.baseTimeStamp = baseTimeStamp;
- }
-
- public BranchInfo(CDODataInput in) throws IOException
- {
- name = in.readString();
- baseBranchID = in.readInt();
- baseTimeStamp = in.readLong();
- }
-
- public void write(CDODataOutput out) throws IOException
- {
- out.writeString(name);
- out.writeInt(baseBranchID);
- out.writeLong(baseTimeStamp);
- }
-
- public String getName()
- {
- return name;
- }
-
- public int getBaseBranchID()
- {
- return baseBranchID;
- }
-
- public long getBaseTimeStamp()
- {
- return baseTimeStamp;
- }
- }
-
- /**
- * @author Eike Stepper
- * @since 3.0
- */
- public static final class SubBranchInfo
- {
- private int id;
-
- private String name;
-
- private long baseTimeStamp;
-
- public SubBranchInfo(int id, String name, long baseTimeStamp)
- {
- this.id = id;
- this.name = name;
- this.baseTimeStamp = baseTimeStamp;
- }
-
- public SubBranchInfo(CDODataInput in) throws IOException
- {
- id = in.readInt();
- name = in.readString();
- baseTimeStamp = in.readLong();
- }
-
- public void write(CDODataOutput out) throws IOException
- {
- out.writeInt(id);
- out.writeString(name);
- out.writeLong(baseTimeStamp);
- }
-
- public int getID()
- {
- return id;
- }
-
- public String getName()
- {
- return name;
- }
-
- public long getBaseTimeStamp()
- {
- return baseTimeStamp;
- }
- }
- }
-}
+/* + * 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.spi.common.branch; + +import org.eclipse.emf.cdo.common.branch.CDOBranchHandler; +import org.eclipse.emf.cdo.common.branch.CDOBranchManager; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.common.util.CDOTimeProvider; +import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager.BranchLoader.BranchInfo; + +import org.eclipse.net4j.util.collection.Pair; +import org.eclipse.net4j.util.lifecycle.ILifecycle; + +import java.io.IOException; + +/** + * @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 InternalCDOBranchManager extends CDOBranchManager, ILifecycle +{ + public BranchLoader getBranchLoader(); + + public void setBranchLoader(BranchLoader branchLoader); + + public CDOTimeProvider getTimeProvider(); + + public void setTimeProvider(CDOTimeProvider timeProvider); + + /** + * @since 4.0 + */ + public void initMainBranch(boolean local, long timestamp); + + public InternalCDOBranch getMainBranch(); + + public InternalCDOBranch getBranch(int branchID); + + public InternalCDOBranch getBranch(int id, String name, InternalCDOBranch baseBranch, long baseTimeStamp); + + public InternalCDOBranch getBranch(int id, BranchInfo branchInfo); + + public InternalCDOBranch getBranch(String path); + + public InternalCDOBranch createBranch(int id, String name, InternalCDOBranch baseBranch, long baseTimeStamp); + + public void handleBranchCreated(InternalCDOBranch branch); + + /** + * @author Eike Stepper + * @since 3.0 + */ + public interface BranchLoader + { + /** + * Passed as the branchID in {@link #createBranch(int, BranchInfo)} causes a new non-local branch to be created. + */ + public static final int NEW_BRANCH = Integer.MAX_VALUE; + + /** + * Passed as the branchID in {@link #createBranch(int, BranchInfo)} causes a new local branch to be created. + */ + public static final int NEW_LOCAL_BRANCH = Integer.MIN_VALUE; + + /** + * Creates a new branch with the given id and branch info. If the id is equal to {@link #NEW_BRANCH} the implementor + * of this method will determine a new positive unique branch id. If the id is equal to {@link #NEW_LOCAL_BRANCH} + * the implementor of this method will determine a new negative unique branch id, so that the new branch becomes a + * local branch. In either case the used branch id is returned to the caller. + * + * @since 4.0 + */ + public Pair<Integer, Long> createBranch(int branchID, BranchInfo branchInfo); + + public BranchInfo loadBranch(int branchID); + + public SubBranchInfo[] loadSubBranches(int branchID); + + public int loadBranches(int startID, int endID, CDOBranchHandler branchHandler); + + /** + * @author Eike Stepper + * @since 3.0 + */ + public static final class BranchInfo + { + private String name; + + private int baseBranchID; + + private long baseTimeStamp; + + public BranchInfo(String name, int baseBranchID, long baseTimeStamp) + { + this.name = name; + this.baseBranchID = baseBranchID; + this.baseTimeStamp = baseTimeStamp; + } + + public BranchInfo(CDODataInput in) throws IOException + { + name = in.readString(); + baseBranchID = in.readInt(); + baseTimeStamp = in.readLong(); + } + + public void write(CDODataOutput out) throws IOException + { + out.writeString(name); + out.writeInt(baseBranchID); + out.writeLong(baseTimeStamp); + } + + public String getName() + { + return name; + } + + public int getBaseBranchID() + { + return baseBranchID; + } + + public long getBaseTimeStamp() + { + return baseTimeStamp; + } + } + + /** + * @author Eike Stepper + * @since 3.0 + */ + public static final class SubBranchInfo + { + private int id; + + private String name; + + private long baseTimeStamp; + + public SubBranchInfo(int id, String name, long baseTimeStamp) + { + this.id = id; + this.name = name; + this.baseTimeStamp = baseTimeStamp; + } + + public SubBranchInfo(CDODataInput in) throws IOException + { + id = in.readInt(); + name = in.readString(); + baseTimeStamp = in.readLong(); + } + + public void write(CDODataOutput out) throws IOException + { + out.writeInt(id); + out.writeString(name); + out.writeLong(baseTimeStamp); + } + + public int getID() + { + return id; + } + + public String getName() + { + return name; + } + + public long getBaseTimeStamp() + { + return baseTimeStamp; + } + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/branch/package-info.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/branch/package-info.java index 471bebd78c..90a7b475e1 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/branch/package-info.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/branch/package-info.java @@ -1,15 +1,15 @@ -/*
- * 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
- */
-
-/**
- * Common service provider interfaces and useful base implementations for dealing with branches.
- */
-package org.eclipse.emf.cdo.spi.common.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 + */ + +/** + * Common service provider interfaces and useful base implementations for dealing with branches. + */ +package org.eclipse.emf.cdo.spi.common.branch; diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOChangeKindCache.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOChangeKindCache.java index 52d49f3c05..c0270669d9 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOChangeKindCache.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOChangeKindCache.java @@ -1,65 +1,65 @@ -/*
- * 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.spi.common.commit;
-
-import org.eclipse.emf.cdo.common.commit.CDOChangeKind;
-import org.eclipse.emf.cdo.common.commit.CDOChangeKindProvider;
-import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-
-import java.util.HashMap;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- * @since 4.0
- */
-public class CDOChangeKindCache extends HashMap<CDOID, CDOChangeKind> implements CDOChangeKindProvider
-{
- private static final long serialVersionUID = 1L;
-
- public CDOChangeKindCache(CDOChangeSetData changeSetData)
- {
- List<CDOIDAndVersion> newObjects = changeSetData.getNewObjects();
- if (newObjects != null)
- {
- for (CDOIDAndVersion key : newObjects)
- {
- put(key.getID(), CDOChangeKind.NEW);
- }
- }
-
- List<CDORevisionKey> changedObjects = changeSetData.getChangedObjects();
- if (changedObjects != null)
- {
- for (CDOIDAndVersion key : changedObjects)
- {
- put(key.getID(), CDOChangeKind.CHANGED);
- }
- }
-
- List<CDOIDAndVersion> detachedObjects = changeSetData.getDetachedObjects();
- if (detachedObjects != null)
- {
- for (CDOIDAndVersion key : detachedObjects)
- {
- put(key.getID(), CDOChangeKind.DETACHED);
- }
- }
- }
-
- public CDOChangeKind getChangeKind(CDOID id)
- {
- return get(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.spi.common.commit; + +import org.eclipse.emf.cdo.common.commit.CDOChangeKind; +import org.eclipse.emf.cdo.common.commit.CDOChangeKindProvider; +import org.eclipse.emf.cdo.common.commit.CDOChangeSetData; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion; +import org.eclipse.emf.cdo.common.revision.CDORevisionKey; + +import java.util.HashMap; +import java.util.List; + +/** + * @author Eike Stepper + * @since 4.0 + */ +public class CDOChangeKindCache extends HashMap<CDOID, CDOChangeKind> implements CDOChangeKindProvider +{ + private static final long serialVersionUID = 1L; + + public CDOChangeKindCache(CDOChangeSetData changeSetData) + { + List<CDOIDAndVersion> newObjects = changeSetData.getNewObjects(); + if (newObjects != null) + { + for (CDOIDAndVersion key : newObjects) + { + put(key.getID(), CDOChangeKind.NEW); + } + } + + List<CDORevisionKey> changedObjects = changeSetData.getChangedObjects(); + if (changedObjects != null) + { + for (CDOIDAndVersion key : changedObjects) + { + put(key.getID(), CDOChangeKind.CHANGED); + } + } + + List<CDOIDAndVersion> detachedObjects = changeSetData.getDetachedObjects(); + if (detachedObjects != null) + { + for (CDOIDAndVersion key : detachedObjects) + { + put(key.getID(), CDOChangeKind.DETACHED); + } + } + } + + public CDOChangeKind getChangeKind(CDOID id) + { + return get(id); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOChangeSetDataRevisionProvider.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOChangeSetDataRevisionProvider.java index 6c20d5d2f5..769e323140 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOChangeSetDataRevisionProvider.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOChangeSetDataRevisionProvider.java @@ -1,160 +1,160 @@ -/*
- * 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.spi.common.commit;
-
-import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.common.commit.CDOChangeSetDataProvider;
-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.CDORevisionProvider;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDeltaProvider;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- * @since 4.0
- */
-public class CDOChangeSetDataRevisionProvider implements CDORevisionProvider, CDOChangeSetDataProvider
-{
- private static final CDOIDAndVersion DETACHED = new CDOIDAndVersion()
- {
- public CDOID getID()
- {
- return CDOID.NULL;
- }
-
- public int getVersion()
- {
- return Integer.MIN_VALUE;
- }
-
- @Override
- public String toString()
- {
- return "DETACHED";
- }
- };
-
- private CDORevisionProvider delegate;
-
- private CDOChangeSetData changeSetData;
-
- private CDORevisionProvider revisionCallback;
-
- private CDORevisionDeltaProvider revisionDeltaCallback;
-
- private Map<CDOID, CDOIDAndVersion> cachedRevisions;
-
- public CDOChangeSetDataRevisionProvider(CDORevisionProvider delegate, CDOChangeSetData changeSetData,
- CDORevisionProvider revisionCallback, CDORevisionDeltaProvider revisionDeltaCallback)
- {
- this.delegate = delegate;
- this.changeSetData = changeSetData;
- this.revisionCallback = revisionCallback;
- this.revisionDeltaCallback = revisionDeltaCallback;
- }
-
- public CDOChangeSetDataRevisionProvider(CDORevisionProvider delegate, CDOChangeSetData changeSetData)
- {
- this(delegate, changeSetData, null, null);
- }
-
- public CDOChangeSetData getChangeSetData()
- {
- return changeSetData;
- }
-
- public synchronized CDORevision getRevision(CDOID id)
- {
- if (cachedRevisions == null)
- {
- cachedRevisions = cacheRevisions();
- }
-
- CDOIDAndVersion key = cachedRevisions.get(id);
- if (key == DETACHED)
- {
- return null;
- }
-
- if (key instanceof CDORevision) // New object (eager)
- {
- return (CDORevision)key;
- }
-
- if (key instanceof CDORevisionDelta) // Changed object (eager)
- {
- CDORevisionDelta revisionDelta = (CDORevisionDelta)key;
- return applyDelta(revisionDelta);
- }
-
- if (key instanceof CDORevisionKey) // Changed object (lazy)
- {
- CDORevisionDelta revisionDelta = revisionDeltaCallback.getRevisionDelta(id);
- return applyDelta(revisionDelta);
- }
-
- if (key != null) // New object (lazy)
- {
- CDORevision revision = revisionCallback.getRevision(id);
- cachedRevisions.put(id, revision);
- return revision;
- }
-
- return delegate.getRevision(id);
- }
-
- private Map<CDOID, CDOIDAndVersion> cacheRevisions()
- {
- Map<CDOID, CDOIDAndVersion> cache = new HashMap<CDOID, CDOIDAndVersion>();
-
- for (CDOIDAndVersion key : changeSetData.getNewObjects())
- {
- if (revisionCallback == null && !(key instanceof CDORevision))
- {
- throw new IllegalStateException("No callback installed to lazily obtain revision " + key);
- }
-
- cache.put(key.getID(), key);
- }
-
- for (CDORevisionKey key : changeSetData.getChangedObjects())
- {
- if (revisionDeltaCallback == null && !(key instanceof CDORevisionDelta))
- {
- throw new IllegalStateException("No callback installed to lazily obtain revision delta " + key);
- }
-
- cache.put(key.getID(), key);
- }
-
- for (CDOIDAndVersion key : changeSetData.getDetachedObjects())
- {
- cache.put(key.getID(), DETACHED);
- }
-
- return cache;
- }
-
- private CDORevision applyDelta(CDORevisionDelta revisionDelta)
- {
- CDOID id = revisionDelta.getID();
- CDORevision changedObject = delegate.getRevision(id).copy();
- revisionDelta.apply(changedObject);
- cachedRevisions.put(id, changedObject);
- return changedObject;
- }
-}
+/* + * 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.spi.common.commit; + +import org.eclipse.emf.cdo.common.commit.CDOChangeSetData; +import org.eclipse.emf.cdo.common.commit.CDOChangeSetDataProvider; +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.CDORevisionProvider; +import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDeltaProvider; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author Eike Stepper + * @since 4.0 + */ +public class CDOChangeSetDataRevisionProvider implements CDORevisionProvider, CDOChangeSetDataProvider +{ + private static final CDOIDAndVersion DETACHED = new CDOIDAndVersion() + { + public CDOID getID() + { + return CDOID.NULL; + } + + public int getVersion() + { + return Integer.MIN_VALUE; + } + + @Override + public String toString() + { + return "DETACHED"; + } + }; + + private CDORevisionProvider delegate; + + private CDOChangeSetData changeSetData; + + private CDORevisionProvider revisionCallback; + + private CDORevisionDeltaProvider revisionDeltaCallback; + + private Map<CDOID, CDOIDAndVersion> cachedRevisions; + + public CDOChangeSetDataRevisionProvider(CDORevisionProvider delegate, CDOChangeSetData changeSetData, + CDORevisionProvider revisionCallback, CDORevisionDeltaProvider revisionDeltaCallback) + { + this.delegate = delegate; + this.changeSetData = changeSetData; + this.revisionCallback = revisionCallback; + this.revisionDeltaCallback = revisionDeltaCallback; + } + + public CDOChangeSetDataRevisionProvider(CDORevisionProvider delegate, CDOChangeSetData changeSetData) + { + this(delegate, changeSetData, null, null); + } + + public CDOChangeSetData getChangeSetData() + { + return changeSetData; + } + + public synchronized CDORevision getRevision(CDOID id) + { + if (cachedRevisions == null) + { + cachedRevisions = cacheRevisions(); + } + + CDOIDAndVersion key = cachedRevisions.get(id); + if (key == DETACHED) + { + return null; + } + + if (key instanceof CDORevision) // New object (eager) + { + return (CDORevision)key; + } + + if (key instanceof CDORevisionDelta) // Changed object (eager) + { + CDORevisionDelta revisionDelta = (CDORevisionDelta)key; + return applyDelta(revisionDelta); + } + + if (key instanceof CDORevisionKey) // Changed object (lazy) + { + CDORevisionDelta revisionDelta = revisionDeltaCallback.getRevisionDelta(id); + return applyDelta(revisionDelta); + } + + if (key != null) // New object (lazy) + { + CDORevision revision = revisionCallback.getRevision(id); + cachedRevisions.put(id, revision); + return revision; + } + + return delegate.getRevision(id); + } + + private Map<CDOID, CDOIDAndVersion> cacheRevisions() + { + Map<CDOID, CDOIDAndVersion> cache = new HashMap<CDOID, CDOIDAndVersion>(); + + for (CDOIDAndVersion key : changeSetData.getNewObjects()) + { + if (revisionCallback == null && !(key instanceof CDORevision)) + { + throw new IllegalStateException("No callback installed to lazily obtain revision " + key); + } + + cache.put(key.getID(), key); + } + + for (CDORevisionKey key : changeSetData.getChangedObjects()) + { + if (revisionDeltaCallback == null && !(key instanceof CDORevisionDelta)) + { + throw new IllegalStateException("No callback installed to lazily obtain revision delta " + key); + } + + cache.put(key.getID(), key); + } + + for (CDOIDAndVersion key : changeSetData.getDetachedObjects()) + { + cache.put(key.getID(), DETACHED); + } + + return cache; + } + + private CDORevision applyDelta(CDORevisionDelta revisionDelta) + { + CDOID id = revisionDelta.getID(); + CDORevision changedObject = delegate.getRevision(id).copy(); + revisionDelta.apply(changedObject); + cachedRevisions.put(id, changedObject); + return changedObject; + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOChangeSetSegment.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOChangeSetSegment.java index c35dac97a6..1ce8678d3a 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOChangeSetSegment.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOChangeSetSegment.java @@ -1,87 +1,87 @@ -/*
- * 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.spi.common.commit;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.internal.common.branch.CDOBranchPointImpl;
-
-import org.eclipse.net4j.util.ObjectUtil;
-
-import java.text.MessageFormat;
-import java.util.LinkedList;
-
-/**
- * @author Eike Stepper
- * @since 3.0
- * @noextend This interface is not intended to be extended by clients.
- */
-public class CDOChangeSetSegment implements CDOBranchPoint
-{
- private CDOBranchPoint branchPoint;
-
- private long endTime;
-
- public CDOChangeSetSegment(CDOBranch branch, long timeStamp, long endTime)
- {
- branchPoint = new CDOBranchPointImpl(branch, timeStamp);
- this.endTime = endTime;
- }
-
- public CDOBranch getBranch()
- {
- return branchPoint.getBranch();
- }
-
- public long getTimeStamp()
- {
- return branchPoint.getTimeStamp();
- }
-
- public long getEndTime()
- {
- return endTime;
- }
-
- public CDOBranchPoint getEndPoint()
- {
- return getBranch().getPoint(endTime);
- }
-
- public boolean isOpenEnded()
- {
- return endTime == CDOBranchPoint.UNSPECIFIED_DATE;
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("Segment[{0}, {1}, {2}]", getBranch(), getTimeStamp(), endTime); //$NON-NLS-1$
- }
-
- public static CDOChangeSetSegment[] createFrom(CDOBranchPoint startPoint, CDOBranchPoint endPoint)
- {
- LinkedList<CDOChangeSetSegment> result = new LinkedList<CDOChangeSetSegment>();
- CDOBranch startBranch = startPoint.getBranch();
- CDOBranch endBranch = endPoint.getBranch();
-
- while (!ObjectUtil.equals(startBranch, endBranch))
- {
- CDOBranchPoint base = endBranch.getBase();
- result.addFirst(new CDOChangeSetSegment(endBranch, base.getTimeStamp(), endPoint.getTimeStamp()));
- endPoint = base;
- endBranch = base.getBranch();
- }
-
- result.addFirst(new CDOChangeSetSegment(startBranch, startPoint.getTimeStamp(), endPoint.getTimeStamp()));
- return result.toArray(new CDOChangeSetSegment[result.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.spi.common.commit; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.internal.common.branch.CDOBranchPointImpl; + +import org.eclipse.net4j.util.ObjectUtil; + +import java.text.MessageFormat; +import java.util.LinkedList; + +/** + * @author Eike Stepper + * @since 3.0 + * @noextend This interface is not intended to be extended by clients. + */ +public class CDOChangeSetSegment implements CDOBranchPoint +{ + private CDOBranchPoint branchPoint; + + private long endTime; + + public CDOChangeSetSegment(CDOBranch branch, long timeStamp, long endTime) + { + branchPoint = new CDOBranchPointImpl(branch, timeStamp); + this.endTime = endTime; + } + + public CDOBranch getBranch() + { + return branchPoint.getBranch(); + } + + public long getTimeStamp() + { + return branchPoint.getTimeStamp(); + } + + public long getEndTime() + { + return endTime; + } + + public CDOBranchPoint getEndPoint() + { + return getBranch().getPoint(endTime); + } + + public boolean isOpenEnded() + { + return endTime == CDOBranchPoint.UNSPECIFIED_DATE; + } + + @Override + public String toString() + { + return MessageFormat.format("Segment[{0}, {1}, {2}]", getBranch(), getTimeStamp(), endTime); //$NON-NLS-1$ + } + + public static CDOChangeSetSegment[] createFrom(CDOBranchPoint startPoint, CDOBranchPoint endPoint) + { + LinkedList<CDOChangeSetSegment> result = new LinkedList<CDOChangeSetSegment>(); + CDOBranch startBranch = startPoint.getBranch(); + CDOBranch endBranch = endPoint.getBranch(); + + while (!ObjectUtil.equals(startBranch, endBranch)) + { + CDOBranchPoint base = endBranch.getBase(); + result.addFirst(new CDOChangeSetSegment(endBranch, base.getTimeStamp(), endPoint.getTimeStamp())); + endPoint = base; + endBranch = base.getBranch(); + } + + result.addFirst(new CDOChangeSetSegment(startBranch, startPoint.getTimeStamp(), endPoint.getTimeStamp())); + return result.toArray(new CDOChangeSetSegment[result.size()]); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOCommitInfoUtil.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOCommitInfoUtil.java index 76378f2d4a..5233c7f009 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOCommitInfoUtil.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDOCommitInfoUtil.java @@ -1,102 +1,102 @@ -/*
- * 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.spi.common.commit;
-
-import org.eclipse.emf.cdo.common.commit.CDOChangeSetData;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion;
-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.CDOListFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.internal.common.commit.CDOCommitInfoManagerImpl;
-import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.io.PrintStream;
-import java.text.MessageFormat;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- * @since 3.0
- */
-public final class CDOCommitInfoUtil
-{
- private CDOCommitInfoUtil()
- {
- }
-
- public static InternalCDOCommitInfoManager createCommitInfoManager()
- {
- return new CDOCommitInfoManagerImpl();
- }
-
- /**
- * @since 4.0
- */
- public static void dump(PrintStream out, CDOChangeSetData changeSetData)
- {
- for (CDOIDAndVersion key : changeSetData.getNewObjects())
- {
- out.println(" + " + key);
- if (key instanceof InternalCDORevision)
- {
- InternalCDORevision revision = (InternalCDORevision)key;
- for (EStructuralFeature feature : revision.getClassInfo().getAllPersistentFeatures())
- {
- Object value = revision.getValue(feature);
- dumpFeature(out, feature, value);
- }
- }
- }
-
- for (CDORevisionKey key : changeSetData.getChangedObjects())
- {
- CDORevisionDelta delta = (CDORevisionDelta)key;
-
- String name = delta.getEClass().getName();
- CDOID id = delta.getID();
- int branch = delta.getBranch().getID();
- int version = delta.getVersion();
-
- out.println(MessageFormat.format(" * {0}@{1}:{2}v{3}", name, id, branch, version));
- dumpFeatureDeltas(out, delta.getFeatureDeltas());
- }
-
- for (CDOIDAndVersion key : changeSetData.getDetachedObjects())
- {
- out.println(" - " + key);
- }
- }
-
- private static void dumpFeatureDeltas(PrintStream out, List<CDOFeatureDelta> featureDeltas)
- {
- for (CDOFeatureDelta featureDelta : featureDeltas)
- {
- if (featureDelta instanceof CDOListFeatureDelta)
- {
- CDOListFeatureDelta list = (CDOListFeatureDelta)featureDelta;
- dumpFeatureDeltas(out, list.getListChanges());
- }
- else
- {
- dumpFeature(out, featureDelta.getFeature(), featureDelta);
- }
- }
- }
-
- private static void dumpFeature(PrintStream out, EStructuralFeature feature, Object value)
- {
- out.println(" " + feature.getName() + " = " + 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 + */ +package org.eclipse.emf.cdo.spi.common.commit; + +import org.eclipse.emf.cdo.common.commit.CDOChangeSetData; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.revision.CDOIDAndVersion; +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.CDOListFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; +import org.eclipse.emf.cdo.internal.common.commit.CDOCommitInfoManagerImpl; +import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision; + +import org.eclipse.emf.ecore.EStructuralFeature; + +import java.io.PrintStream; +import java.text.MessageFormat; +import java.util.List; + +/** + * @author Eike Stepper + * @since 3.0 + */ +public final class CDOCommitInfoUtil +{ + private CDOCommitInfoUtil() + { + } + + public static InternalCDOCommitInfoManager createCommitInfoManager() + { + return new CDOCommitInfoManagerImpl(); + } + + /** + * @since 4.0 + */ + public static void dump(PrintStream out, CDOChangeSetData changeSetData) + { + for (CDOIDAndVersion key : changeSetData.getNewObjects()) + { + out.println(" + " + key); + if (key instanceof InternalCDORevision) + { + InternalCDORevision revision = (InternalCDORevision)key; + for (EStructuralFeature feature : revision.getClassInfo().getAllPersistentFeatures()) + { + Object value = revision.getValue(feature); + dumpFeature(out, feature, value); + } + } + } + + for (CDORevisionKey key : changeSetData.getChangedObjects()) + { + CDORevisionDelta delta = (CDORevisionDelta)key; + + String name = delta.getEClass().getName(); + CDOID id = delta.getID(); + int branch = delta.getBranch().getID(); + int version = delta.getVersion(); + + out.println(MessageFormat.format(" * {0}@{1}:{2}v{3}", name, id, branch, version)); + dumpFeatureDeltas(out, delta.getFeatureDeltas()); + } + + for (CDOIDAndVersion key : changeSetData.getDetachedObjects()) + { + out.println(" - " + key); + } + } + + private static void dumpFeatureDeltas(PrintStream out, List<CDOFeatureDelta> featureDeltas) + { + for (CDOFeatureDelta featureDelta : featureDeltas) + { + if (featureDelta instanceof CDOListFeatureDelta) + { + CDOListFeatureDelta list = (CDOListFeatureDelta)featureDelta; + dumpFeatureDeltas(out, list.getListChanges()); + } + else + { + dumpFeature(out, featureDelta.getFeature(), featureDelta); + } + } + } + + private static void dumpFeature(PrintStream out, EStructuralFeature feature, Object value) + { + out.println(" " + feature.getName() + " = " + value); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDORevisionAvailabilityInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDORevisionAvailabilityInfo.java index d98c8d359b..f66332029d 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDORevisionAvailabilityInfo.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/CDORevisionAvailabilityInfo.java @@ -1,73 +1,73 @@ -/*
- * 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.spi.common.commit;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionKey;
-import org.eclipse.emf.cdo.common.revision.CDORevisionProvider;
-
-import java.text.MessageFormat;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- * @since 3.0
- */
-public final class CDORevisionAvailabilityInfo implements CDORevisionProvider
-{
- private CDOBranchPoint branchPoint;
-
- private Map<CDOID, CDORevisionKey> availableRevisions = new HashMap<CDOID, CDORevisionKey>();
-
- public CDORevisionAvailabilityInfo(CDOBranchPoint branchPoint)
- {
- this.branchPoint = branchPoint;
- }
-
- public CDOBranchPoint getBranchPoint()
- {
- return branchPoint;
- }
-
- public Map<CDOID, CDORevisionKey> getAvailableRevisions()
- {
- return availableRevisions;
- }
-
- public void addRevision(CDORevisionKey key)
- {
- availableRevisions.put(key.getID(), key);
- }
-
- public void removeRevision(CDOID id)
- {
- availableRevisions.remove(id);
- }
-
- public boolean containsRevision(CDOID id)
- {
- return availableRevisions.containsKey(id);
- }
-
- public CDORevision getRevision(CDOID id)
- {
- return (CDORevision)availableRevisions.get(id);
- }
-
- @Override
- public String toString()
- {
- return MessageFormat.format("CDORevisionAvailabilityInfo[{0} -> {1} ]", branchPoint, availableRevisions.values());
- }
-}
+/* + * 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.spi.common.commit; + +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.CDORevisionKey; +import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; + +import java.text.MessageFormat; +import java.util.HashMap; +import java.util.Map; + +/** + * @author Eike Stepper + * @since 3.0 + */ +public final class CDORevisionAvailabilityInfo implements CDORevisionProvider +{ + private CDOBranchPoint branchPoint; + + private Map<CDOID, CDORevisionKey> availableRevisions = new HashMap<CDOID, CDORevisionKey>(); + + public CDORevisionAvailabilityInfo(CDOBranchPoint branchPoint) + { + this.branchPoint = branchPoint; + } + + public CDOBranchPoint getBranchPoint() + { + return branchPoint; + } + + public Map<CDOID, CDORevisionKey> getAvailableRevisions() + { + return availableRevisions; + } + + public void addRevision(CDORevisionKey key) + { + availableRevisions.put(key.getID(), key); + } + + public void removeRevision(CDOID id) + { + availableRevisions.remove(id); + } + + public boolean containsRevision(CDOID id) + { + return availableRevisions.containsKey(id); + } + + public CDORevision getRevision(CDOID id) + { + return (CDORevision)availableRevisions.get(id); + } + + @Override + public String toString() + { + return MessageFormat.format("CDORevisionAvailabilityInfo[{0} -> {1} ]", branchPoint, availableRevisions.values()); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/InternalCDOCommitInfoManager.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/InternalCDOCommitInfoManager.java index a1039d380f..671696f301 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/InternalCDOCommitInfoManager.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/InternalCDOCommitInfoManager.java @@ -1,48 +1,48 @@ -/*
- * 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.spi.common.commit;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.commit.CDOCommitData;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler;
-import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager;
-
-import org.eclipse.net4j.util.lifecycle.ILifecycle;
-
-/**
- * @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 InternalCDOCommitInfoManager extends CDOCommitInfoManager, ILifecycle
-{
- public CommitInfoLoader getCommitInfoLoader();
-
- public void setCommitInfoLoader(CommitInfoLoader commitInfoLoader);
-
- /**
- * @since 4.0
- */
- public CDOCommitInfo createCommitInfo(CDOBranch branch, long timeStamp, long previousTimeStamp, String userID,
- String comment, CDOCommitData commitData);
-
- /**
- * @author Eike Stepper
- */
- public interface CommitInfoLoader
- {
- public void loadCommitInfos(CDOBranch branch, long startTime, long endTime, CDOCommitInfoHandler handler);
-
- public CDOCommitData loadCommitData(long timeStamp);
- }
-}
+/* + * 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.spi.common.commit; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.commit.CDOCommitData; +import org.eclipse.emf.cdo.common.commit.CDOCommitInfo; +import org.eclipse.emf.cdo.common.commit.CDOCommitInfoHandler; +import org.eclipse.emf.cdo.common.commit.CDOCommitInfoManager; + +import org.eclipse.net4j.util.lifecycle.ILifecycle; + +/** + * @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 InternalCDOCommitInfoManager extends CDOCommitInfoManager, ILifecycle +{ + public CommitInfoLoader getCommitInfoLoader(); + + public void setCommitInfoLoader(CommitInfoLoader commitInfoLoader); + + /** + * @since 4.0 + */ + public CDOCommitInfo createCommitInfo(CDOBranch branch, long timeStamp, long previousTimeStamp, String userID, + String comment, CDOCommitData commitData); + + /** + * @author Eike Stepper + */ + public interface CommitInfoLoader + { + public void loadCommitInfos(CDOBranch branch, long startTime, long endTime, CDOCommitInfoHandler handler); + + public CDOCommitData loadCommitData(long timeStamp); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/package-info.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/package-info.java index 9b8e34f2ed..821116b903 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/package-info.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/commit/package-info.java @@ -1,15 +1,15 @@ -/*
- * 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
- */
-
-/**
- * Common service provider interfaces and useful base implementations for dealing with commits and change sets.
- */
-package org.eclipse.emf.cdo.spi.common.commit;
+/* + * 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 + */ + +/** + * Common service provider interfaces and useful base implementations for dealing with commits and change sets. + */ +package org.eclipse.emf.cdo.spi.common.commit; diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOID.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOID.java index a45f7cf7c3..fb381790da 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOID.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOID.java @@ -1,68 +1,68 @@ -/*
- * 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.spi.common.id;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-
-import org.eclipse.net4j.util.io.ExtendedDataInput;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- * @since 2.0
- * @noextend This interface is not intended to be extended by clients.
- */
-public abstract class AbstractCDOID implements CDOID
-{
- private static final long serialVersionUID = 1L;
-
- public AbstractCDOID()
- {
- }
-
- @Override
- public String toString()
- {
- return toURIFragment();
- }
-
- public final int compareTo(CDOID o)
- {
- try
- {
- return doCompareTo(o);
- }
- catch (ClassCastException ex)
- {
- return getType().compareTo(o.getType());
- }
- }
-
- protected abstract int doCompareTo(CDOID o) throws ClassCastException;
-
- /**
- * <b>Note:</b> {@link CDOID#toURIFragment()} and {@link AbstractCDOID#read(String)} need to match.
- */
- public abstract void read(String fragmentPart);
-
- /**
- * TODO: Change the parameter to CDODataInput to prevent casting in IDs with classifier.
- */
- public abstract void read(ExtendedDataInput in) throws IOException;
-
- /**
- * TODO: Change the parameter to CDODataInput to prevent casting in IDs with classifier.
- */
- public abstract void write(ExtendedDataOutput out) 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 - bug 213402 + */ +package org.eclipse.emf.cdo.spi.common.id; + +import org.eclipse.emf.cdo.common.id.CDOID; + +import org.eclipse.net4j.util.io.ExtendedDataInput; +import org.eclipse.net4j.util.io.ExtendedDataOutput; + +import java.io.IOException; + +/** + * @author Eike Stepper + * @since 2.0 + * @noextend This interface is not intended to be extended by clients. + */ +public abstract class AbstractCDOID implements CDOID +{ + private static final long serialVersionUID = 1L; + + public AbstractCDOID() + { + } + + @Override + public String toString() + { + return toURIFragment(); + } + + public final int compareTo(CDOID o) + { + try + { + return doCompareTo(o); + } + catch (ClassCastException ex) + { + return getType().compareTo(o.getType()); + } + } + + protected abstract int doCompareTo(CDOID o) throws ClassCastException; + + /** + * <b>Note:</b> {@link CDOID#toURIFragment()} and {@link AbstractCDOID#read(String)} need to match. + */ + public abstract void read(String fragmentPart); + + /** + * TODO: Change the parameter to CDODataInput to prevent casting in IDs with classifier. + */ + public abstract void read(ExtendedDataInput in) throws IOException; + + /** + * TODO: Change the parameter to CDODataInput to prevent casting in IDs with classifier. + */ + public abstract void write(ExtendedDataOutput out) throws IOException; +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDByteArray.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDByteArray.java index 51e2fb92c7..b469323e34 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDByteArray.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDByteArray.java @@ -1,95 +1,95 @@ -/*
- * 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.spi.common.id;
-
-import org.eclipse.emf.cdo.common.id.CDOIDUtil;
-
-import org.eclipse.net4j.util.CheckUtil;
-import org.eclipse.net4j.util.io.ExtendedDataInput;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-/**
- * @author Eike Stepper
- * @since 4.1
- * @noextend This interface is not intended to be extended by clients.
- */
-public abstract class AbstractCDOIDByteArray extends AbstractCDOID
-{
- public static final String NULL_VALUE = null;
-
- private static final long serialVersionUID = 1L;
-
- private byte[] value;
-
- public AbstractCDOIDByteArray()
- {
- }
-
- public AbstractCDOIDByteArray(byte[] value)
- {
- CheckUtil.checkArg(value != null && value.length == 16, "Illegal UUID value");
- this.value = value;
- }
-
- public byte[] getByteArrayValue()
- {
- return value;
- }
-
- public String toURIFragment()
- {
- return CDOIDUtil.encodeUUID(value);
- }
-
- @Override
- public void read(String fragmentPart)
- {
- value = CDOIDUtil.decodeUUID(fragmentPart);
- }
-
- @Override
- public void read(ExtendedDataInput in) throws IOException
- {
- value = in.readByteArray();
- }
-
- @Override
- public void write(ExtendedDataOutput out) throws IOException
- {
- out.writeByteArray(value);
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj != null && obj.getClass() == getClass())
- {
- AbstractCDOIDByteArray that = (AbstractCDOIDByteArray)obj;
- return Arrays.equals(value, that.value);
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- return getClass().hashCode() ^ Arrays.hashCode(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 + */ +package org.eclipse.emf.cdo.spi.common.id; + +import org.eclipse.emf.cdo.common.id.CDOIDUtil; + +import org.eclipse.net4j.util.CheckUtil; +import org.eclipse.net4j.util.io.ExtendedDataInput; +import org.eclipse.net4j.util.io.ExtendedDataOutput; + +import java.io.IOException; +import java.util.Arrays; + +/** + * @author Eike Stepper + * @since 4.1 + * @noextend This interface is not intended to be extended by clients. + */ +public abstract class AbstractCDOIDByteArray extends AbstractCDOID +{ + public static final String NULL_VALUE = null; + + private static final long serialVersionUID = 1L; + + private byte[] value; + + public AbstractCDOIDByteArray() + { + } + + public AbstractCDOIDByteArray(byte[] value) + { + CheckUtil.checkArg(value != null && value.length == 16, "Illegal UUID value"); + this.value = value; + } + + public byte[] getByteArrayValue() + { + return value; + } + + public String toURIFragment() + { + return CDOIDUtil.encodeUUID(value); + } + + @Override + public void read(String fragmentPart) + { + value = CDOIDUtil.decodeUUID(fragmentPart); + } + + @Override + public void read(ExtendedDataInput in) throws IOException + { + value = in.readByteArray(); + } + + @Override + public void write(ExtendedDataOutput out) throws IOException + { + out.writeByteArray(value); + } + + @Override + public boolean equals(Object obj) + { + if (obj == this) + { + return true; + } + + if (obj != null && obj.getClass() == getClass()) + { + AbstractCDOIDByteArray that = (AbstractCDOIDByteArray)obj; + return Arrays.equals(value, that.value); + } + + return false; + } + + @Override + public int hashCode() + { + return getClass().hashCode() ^ Arrays.hashCode(value); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDInteger.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDInteger.java index 790243fd78..6c8275ae5e 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDInteger.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDInteger.java @@ -1,109 +1,109 @@ -/*
- * 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
- */
-package org.eclipse.emf.cdo.spi.common.id;
-
-import org.eclipse.net4j.util.io.ExtendedDataInput;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- * @since 2.0
- * @noextend This interface is not intended to be extended by clients.
- */
-public abstract class AbstractCDOIDInteger extends AbstractCDOID
-{
- private static final long serialVersionUID = 1L;
-
- private int value;
-
- public AbstractCDOIDInteger()
- {
- }
-
- public AbstractCDOIDInteger(int value)
- {
- if (value == 0)
- {
- throw new IllegalArgumentException("value == 0"); //$NON-NLS-1$
- }
-
- this.value = value;
- }
-
- public int getIntValue()
- {
- return value;
- }
-
- public String toURIFragment()
- {
- return String.valueOf(value);
- }
-
- @Override
- public void read(String fragmentPart)
- {
- value = Integer.valueOf(fragmentPart);
- }
-
- @Override
- public void read(ExtendedDataInput in) throws IOException
- {
- value = in.readInt();
- }
-
- @Override
- public void write(ExtendedDataOutput out) throws IOException
- {
- out.writeInt(value);
- }
-
- public int compareTo(AbstractCDOIDInteger that)
- {
- if (value < that.value)
- {
- return -1;
- }
-
- if (value > that.value)
- {
- return 1;
- }
-
- return 0;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj != null && obj.getClass() == getClass())
- {
- AbstractCDOIDInteger that = (AbstractCDOIDInteger)obj;
- return value == that.value;
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- return getClass().hashCode() ^ 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 + * Simon McDuff - bug 226778 + */ +package org.eclipse.emf.cdo.spi.common.id; + +import org.eclipse.net4j.util.io.ExtendedDataInput; +import org.eclipse.net4j.util.io.ExtendedDataOutput; + +import java.io.IOException; + +/** + * @author Eike Stepper + * @since 2.0 + * @noextend This interface is not intended to be extended by clients. + */ +public abstract class AbstractCDOIDInteger extends AbstractCDOID +{ + private static final long serialVersionUID = 1L; + + private int value; + + public AbstractCDOIDInteger() + { + } + + public AbstractCDOIDInteger(int value) + { + if (value == 0) + { + throw new IllegalArgumentException("value == 0"); //$NON-NLS-1$ + } + + this.value = value; + } + + public int getIntValue() + { + return value; + } + + public String toURIFragment() + { + return String.valueOf(value); + } + + @Override + public void read(String fragmentPart) + { + value = Integer.valueOf(fragmentPart); + } + + @Override + public void read(ExtendedDataInput in) throws IOException + { + value = in.readInt(); + } + + @Override + public void write(ExtendedDataOutput out) throws IOException + { + out.writeInt(value); + } + + public int compareTo(AbstractCDOIDInteger that) + { + if (value < that.value) + { + return -1; + } + + if (value > that.value) + { + return 1; + } + + return 0; + } + + @Override + public boolean equals(Object obj) + { + if (obj == this) + { + return true; + } + + if (obj != null && obj.getClass() == getClass()) + { + AbstractCDOIDInteger that = (AbstractCDOIDInteger)obj; + return value == that.value; + } + + return false; + } + + @Override + public int hashCode() + { + return getClass().hashCode() ^ value; + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDLong.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDLong.java index 60c0bbccaf..e7ad42d52c 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDLong.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDLong.java @@ -1,103 +1,103 @@ -/*
- * 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
- */
-package org.eclipse.emf.cdo.spi.common.id;
-
-import org.eclipse.net4j.util.ObjectUtil;
-import org.eclipse.net4j.util.io.ExtendedDataInput;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
-
-import java.io.IOException;
-
-/**
- * @author Eike Stepper
- * @since 2.0
- * @noextend This interface is not intended to be extended by clients.
- */
-public abstract class AbstractCDOIDLong extends AbstractCDOID
-{
- public static final long NULL_VALUE = 0L;
-
- private static final long serialVersionUID = 1L;
-
- private long value;
-
- public AbstractCDOIDLong()
- {
- }
-
- public AbstractCDOIDLong(long value)
- {
- if (value == NULL_VALUE)
- {
- throw new IllegalArgumentException("value == NULL_VALUE"); //$NON-NLS-1$
- }
-
- this.value = value;
- }
-
- public long getLongValue()
- {
- return value;
- }
-
- public String toURIFragment()
- {
- return String.valueOf(value);
- }
-
- @Override
- public void read(String fragmentPart)
- {
- value = Long.valueOf(fragmentPart);
- }
-
- @Override
- public void read(ExtendedDataInput in) throws IOException
- {
- value = in.readLong();
- }
-
- @Override
- public void write(ExtendedDataOutput out) throws IOException
- {
- out.writeLong(value);
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj != null && obj.getClass() == getClass())
- {
- AbstractCDOIDLong that = (AbstractCDOIDLong)obj;
- return value == that.value;
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- return getClass().hashCode() ^ ObjectUtil.hashCode(value);
- }
-
- @Override
- public String toString()
- {
- return String.valueOf(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 + * Simon McDuff - bug 226778 + */ +package org.eclipse.emf.cdo.spi.common.id; + +import org.eclipse.net4j.util.ObjectUtil; +import org.eclipse.net4j.util.io.ExtendedDataInput; +import org.eclipse.net4j.util.io.ExtendedDataOutput; + +import java.io.IOException; + +/** + * @author Eike Stepper + * @since 2.0 + * @noextend This interface is not intended to be extended by clients. + */ +public abstract class AbstractCDOIDLong extends AbstractCDOID +{ + public static final long NULL_VALUE = 0L; + + private static final long serialVersionUID = 1L; + + private long value; + + public AbstractCDOIDLong() + { + } + + public AbstractCDOIDLong(long value) + { + if (value == NULL_VALUE) + { + throw new IllegalArgumentException("value == NULL_VALUE"); //$NON-NLS-1$ + } + + this.value = value; + } + + public long getLongValue() + { + return value; + } + + public String toURIFragment() + { + return String.valueOf(value); + } + + @Override + public void read(String fragmentPart) + { + value = Long.valueOf(fragmentPart); + } + + @Override + public void read(ExtendedDataInput in) throws IOException + { + value = in.readLong(); + } + + @Override + public void write(ExtendedDataOutput out) throws IOException + { + out.writeLong(value); + } + + @Override + public boolean equals(Object obj) + { + if (obj == this) + { + return true; + } + + if (obj != null && obj.getClass() == getClass()) + { + AbstractCDOIDLong that = (AbstractCDOIDLong)obj; + return value == that.value; + } + + return false; + } + + @Override + public int hashCode() + { + return getClass().hashCode() ^ ObjectUtil.hashCode(value); + } + + @Override + public String toString() + { + return String.valueOf(value); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDString.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDString.java index b9ded5ab2e..e863c8b20f 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDString.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/AbstractCDOIDString.java @@ -1,101 +1,101 @@ -/*
- * 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:
- * Martin Taal - initial API and implementation
- * Eike Stepper - maintenance
- */
-package org.eclipse.emf.cdo.spi.common.id;
-
-import org.eclipse.net4j.util.ObjectUtil;
-import org.eclipse.net4j.util.io.ExtendedDataInput;
-import org.eclipse.net4j.util.io.ExtendedDataOutput;
-
-import java.io.IOException;
-
-/**
- * @author Martin Taal
- * @since 3.0
- * @noextend This interface is not intended to be extended by clients.
- */
-public abstract class AbstractCDOIDString extends AbstractCDOID
-{
- /**
- * @since 4.0
- */
- public static final String NULL_VALUE = null;
-
- private static final long serialVersionUID = 1L;
-
- private String value;
-
- public AbstractCDOIDString()
- {
- }
-
- public AbstractCDOIDString(String value)
- {
- this.value = value;
- }
-
- public String getStringValue()
- {
- return value;
- }
-
- public String toURIFragment()
- {
- return value;
- }
-
- @Override
- public void read(String fragmentPart)
- {
- value = fragmentPart;
- }
-
- @Override
- public void read(ExtendedDataInput in) throws IOException
- {
- value = in.readString();
- }
-
- @Override
- public void write(ExtendedDataOutput out) throws IOException
- {
- out.writeString(value);
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj != null && obj.getClass() == getClass())
- {
- AbstractCDOIDString that = (AbstractCDOIDString)obj;
- return value.equals(that.value);
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- return getClass().hashCode() ^ ObjectUtil.hashCode(value);
- }
-
- @Override
- public String toString()
- {
- return 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: + * Martin Taal - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.spi.common.id; + +import org.eclipse.net4j.util.ObjectUtil; +import org.eclipse.net4j.util.io.ExtendedDataInput; +import org.eclipse.net4j.util.io.ExtendedDataOutput; + +import java.io.IOException; + +/** + * @author Martin Taal + * @since 3.0 + * @noextend This interface is not intended to be extended by clients. + */ +public abstract class AbstractCDOIDString extends AbstractCDOID +{ + /** + * @since 4.0 + */ + public static final String NULL_VALUE = null; + + private static final long serialVersionUID = 1L; + + private String value; + + public AbstractCDOIDString() + { + } + + public AbstractCDOIDString(String value) + { + this.value = value; + } + + public String getStringValue() + { + return value; + } + + public String toURIFragment() + { + return value; + } + + @Override + public void read(String fragmentPart) + { + value = fragmentPart; + } + + @Override + public void read(ExtendedDataInput in) throws IOException + { + value = in.readString(); + } + + @Override + public void write(ExtendedDataOutput out) throws IOException + { + out.writeString(value); + } + + @Override + public boolean equals(Object obj) + { + if (obj == this) + { + return true; + } + + if (obj != null && obj.getClass() == getClass()) + { + AbstractCDOIDString that = (AbstractCDOIDString)obj; + return value.equals(that.value); + } + + return false; + } + + @Override + public int hashCode() + { + return getClass().hashCode() ^ ObjectUtil.hashCode(value); + } + + @Override + public String toString() + { + return value; + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/InternalCDOIDObject.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/InternalCDOIDObject.java index 47071b8b6d..d8dec20471 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/InternalCDOIDObject.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/InternalCDOIDObject.java @@ -1,24 +1,24 @@ -/*
- * 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.spi.common.id;
-
-import org.eclipse.emf.cdo.common.id.CDOIDObject;
-
-/**
- * @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 InternalCDOIDObject extends CDOIDObject
-{
- public ObjectType getSubType();
-}
+/* + * 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.spi.common.id; + +import org.eclipse.emf.cdo.common.id.CDOIDObject; + +/** + * @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 InternalCDOIDObject extends CDOIDObject +{ + public ObjectType getSubType(); +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/package-info.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/package-info.java index 548c925814..e43cebe508 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/package-info.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/id/package-info.java @@ -1,15 +1,15 @@ -/*
- * 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
- */
-
-/**
- * Common service provider interfaces and useful base implementations for dealing with object and revision IDs.
- */
-package org.eclipse.emf.cdo.spi.common.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 + */ + +/** + * Common service provider interfaces and useful base implementations for dealing with object and revision IDs. + */ +package org.eclipse.emf.cdo.spi.common.id; diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/lock/InternalCDOLockState.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/lock/InternalCDOLockState.java index 841f520093..c4f4c2f363 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/lock/InternalCDOLockState.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/lock/InternalCDOLockState.java @@ -1,31 +1,31 @@ -/*
- * 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.spi.common.lock;
-
-import org.eclipse.emf.cdo.common.lock.CDOLockOwner;
-import org.eclipse.emf.cdo.common.lock.CDOLockState;
-
-/**
- * @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 InternalCDOLockState extends CDOLockState
-{
- public void addReadLockOwner(CDOLockOwner lockOwner);
-
- public boolean removeReadLockOwner(CDOLockOwner lockOwner);
-
- public void setWriteLockOwner(CDOLockOwner lockOwner);
-
- public void setWriteOptionOwner(CDOLockOwner lockOwner);
-}
+/* + * 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.spi.common.lock; + +import org.eclipse.emf.cdo.common.lock.CDOLockOwner; +import org.eclipse.emf.cdo.common.lock.CDOLockState; + +/** + * @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 InternalCDOLockState extends CDOLockState +{ + public void addReadLockOwner(CDOLockOwner lockOwner); + + public boolean removeReadLockOwner(CDOLockOwner lockOwner); + + public void setWriteLockOwner(CDOLockOwner lockOwner); + + public void setWriteOptionOwner(CDOLockOwner lockOwner); +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/lock/package-info.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/lock/package-info.java index c4dbb6f6ea..cdb2748735 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/lock/package-info.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/lock/package-info.java @@ -1,15 +1,15 @@ -/*
- * 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
- */
-
-/**
- * Common service provider interfaces and useful base implementations for dealing with object locks.
- */
-package org.eclipse.emf.cdo.spi.common.lock;
+/* + * 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 + */ + +/** + * Common service provider interfaces and useful base implementations for dealing with object locks. + */ +package org.eclipse.emf.cdo.spi.common.lock; diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/DelegatingCDOPackageRegistry.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/DelegatingCDOPackageRegistry.java index e1552684bc..7c9bd827c4 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/DelegatingCDOPackageRegistry.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/DelegatingCDOPackageRegistry.java @@ -1,174 +1,174 @@ -/*
- * 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.spi.common.model;
-
-import org.eclipse.net4j.util.lifecycle.Lifecycle;
-
-import org.eclipse.emf.ecore.EFactory;
-import org.eclipse.emf.ecore.EPackage;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author Eike Stepper
- * @since 4.0
- */
-@Deprecated
-public abstract class DelegatingCDOPackageRegistry extends Lifecycle implements InternalCDOPackageRegistry
-{
- public DelegatingCDOPackageRegistry()
- {
- }
-
- protected abstract InternalCDOPackageRegistry getDelegate();
-
- public Object basicPut(String nsURI, Object value)
- {
- return getDelegate().basicPut(nsURI, value);
- }
-
- public void clear()
- {
- getDelegate().clear();
- }
-
- public boolean containsKey(Object key)
- {
- return getDelegate().containsKey(key);
- }
-
- public boolean containsValue(Object value)
- {
- return getDelegate().containsValue(value);
- }
-
- public Set<java.util.Map.Entry<String, Object>> entrySet()
- {
- return getDelegate().entrySet();
- }
-
- public Object get(Object key)
- {
- return getDelegate().get(key);
- }
-
- public EFactory getEFactory(String nsURI)
- {
- return getDelegate().getEFactory(nsURI);
- }
-
- public EPackage getEPackage(String nsURI)
- {
- return getDelegate().getEPackage(nsURI);
- }
-
- public EPackage[] getEPackages()
- {
- return getDelegate().getEPackages();
- }
-
- public InternalCDOPackageInfo getPackageInfo(EPackage ePackage)
- {
- return getDelegate().getPackageInfo(ePackage);
- }
-
- public InternalCDOPackageInfo[] getPackageInfos()
- {
- return getDelegate().getPackageInfos();
- }
-
- public PackageLoader getPackageLoader()
- {
- return getDelegate().getPackageLoader();
- }
-
- public PackageProcessor getPackageProcessor()
- {
- return getDelegate().getPackageProcessor();
- }
-
- public InternalCDOPackageUnit getPackageUnit(EPackage ePackage)
- {
- return getDelegate().getPackageUnit(ePackage);
- }
-
- public InternalCDOPackageUnit[] getPackageUnits()
- {
- return getDelegate().getPackageUnits();
- }
-
- public boolean isEmpty()
- {
- return getDelegate().isEmpty();
- }
-
- public boolean isReplacingDescriptors()
- {
- return getDelegate().isReplacingDescriptors();
- }
-
- public Set<String> keySet()
- {
- return getDelegate().keySet();
- }
-
- public Object put(String key, Object value)
- {
- return getDelegate().put(key, value);
- }
-
- public void putAll(Map<? extends String, ? extends Object> t)
- {
- getDelegate().putAll(t);
- }
-
- public Object putEPackage(EPackage ePackage)
- {
- return getDelegate().putEPackage(ePackage);
- }
-
- public void putPackageUnit(InternalCDOPackageUnit packageUnit)
- {
- getDelegate().putPackageUnit(packageUnit);
- }
-
- public Object remove(Object key)
- {
- return getDelegate().remove(key);
- }
-
- public void setPackageLoader(PackageLoader packageLoader)
- {
- getDelegate().setPackageLoader(packageLoader);
- }
-
- public void setPackageProcessor(PackageProcessor packageProcessor)
- {
- getDelegate().setPackageProcessor(packageProcessor);
- }
-
- public void setReplacingDescriptors(boolean replacingDescriptors)
- {
- getDelegate().setReplacingDescriptors(replacingDescriptors);
- }
-
- public int size()
- {
- return getDelegate().size();
- }
-
- public Collection<Object> values()
- {
- return getDelegate().values();
- }
-}
+/* + * 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.spi.common.model; + +import org.eclipse.net4j.util.lifecycle.Lifecycle; + +import org.eclipse.emf.ecore.EFactory; +import org.eclipse.emf.ecore.EPackage; + +import java.util.Collection; +import java.util.Map; +import java.util.Set; + +/** + * @author Eike Stepper + * @since 4.0 + */ +@Deprecated +public abstract class DelegatingCDOPackageRegistry extends Lifecycle implements InternalCDOPackageRegistry +{ + public DelegatingCDOPackageRegistry() + { + } + + protected abstract InternalCDOPackageRegistry getDelegate(); + + public Object basicPut(String nsURI, Object value) + { + return getDelegate().basicPut(nsURI, value); + } + + public void clear() + { + getDelegate().clear(); + } + + public boolean containsKey(Object key) + { + return getDelegate().containsKey(key); + } + + public boolean containsValue(Object value) + { + return getDelegate().containsValue(value); + } + + public Set<java.util.Map.Entry<String, Object>> entrySet() + { + return getDelegate().entrySet(); + } + + public Object get(Object key) + { + return getDelegate().get(key); + } + + public EFactory getEFactory(String nsURI) + { + return getDelegate().getEFactory(nsURI); + } + + public EPackage getEPackage(String nsURI) + { + return getDelegate().getEPackage(nsURI); + } + + public EPackage[] getEPackages() + { + return getDelegate().getEPackages(); + } + + public InternalCDOPackageInfo getPackageInfo(EPackage ePackage) + { + return getDelegate().getPackageInfo(ePackage); + } + + public InternalCDOPackageInfo[] getPackageInfos() + { + return getDelegate().getPackageInfos(); + } + + public PackageLoader getPackageLoader() + { + return getDelegate().getPackageLoader(); + } + + public PackageProcessor getPackageProcessor() + { + return getDelegate().getPackageProcessor(); + } + + public InternalCDOPackageUnit getPackageUnit(EPackage ePackage) + { + return getDelegate().getPackageUnit(ePackage); + } + + public InternalCDOPackageUnit[] getPackageUnits() + { + return getDelegate().getPackageUnits(); + } + + public boolean isEmpty() + { + return getDelegate().isEmpty(); + } + + public boolean isReplacingDescriptors() + { + return getDelegate().isReplacingDescriptors(); + } + + public Set<String> keySet() + { + return getDelegate().keySet(); + } + + public Object put(String key, Object value) + { + return getDelegate().put(key, value); + } + + public void putAll(Map<? extends String, ? extends Object> t) + { + getDelegate().putAll(t); + } + + public Object putEPackage(EPackage ePackage) + { + return getDelegate().putEPackage(ePackage); + } + + public void putPackageUnit(InternalCDOPackageUnit packageUnit) + { + getDelegate().putPackageUnit(packageUnit); + } + + public Object remove(Object key) + { + return getDelegate().remove(key); + } + + public void setPackageLoader(PackageLoader packageLoader) + { + getDelegate().setPackageLoader(packageLoader); + } + + public void setPackageProcessor(PackageProcessor packageProcessor) + { + getDelegate().setPackageProcessor(packageProcessor); + } + + public void setReplacingDescriptors(boolean replacingDescriptors) + { + getDelegate().setReplacingDescriptors(replacingDescriptors); + } + + public int size() + { + return getDelegate().size(); + } + + public Collection<Object> values() + { + return getDelegate().values(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOPackageInfo.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOPackageInfo.java index 20a56a7435..b69af6a1f0 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOPackageInfo.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOPackageInfo.java @@ -1,46 +1,46 @@ -/*
- * 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.spi.common.model;
-
-import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-
-import org.eclipse.emf.common.notify.Adapter;
-
-import java.io.IOException;
-
-/**
- * @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 InternalCDOPackageInfo extends CDOPackageInfo, Adapter.Internal
-{
- public InternalCDOPackageUnit getPackageUnit();
-
- public void setPackageUnit(InternalCDOPackageUnit packageUnit);
-
- public void setPackageURI(String packageURI);
-
- public void setParentURI(String parentURI);
-
- /**
- * @since 3.0
- */
- public void write(CDODataOutput out) throws IOException;
-
- /**
- * @since 3.0
- */
- public void read(CDODataInput in) 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.spi.common.model; + +import org.eclipse.emf.cdo.common.model.CDOPackageInfo; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; + +import org.eclipse.emf.common.notify.Adapter; + +import java.io.IOException; + +/** + * @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 InternalCDOPackageInfo extends CDOPackageInfo, Adapter.Internal +{ + public InternalCDOPackageUnit getPackageUnit(); + + public void setPackageUnit(InternalCDOPackageUnit packageUnit); + + public void setPackageURI(String packageURI); + + public void setParentURI(String parentURI); + + /** + * @since 3.0 + */ + public void write(CDODataOutput out) throws IOException; + + /** + * @since 3.0 + */ + public void read(CDODataInput in) throws IOException; +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOPackageRegistry.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOPackageRegistry.java index 82a441eece..2e7b161b39 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOPackageRegistry.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOPackageRegistry.java @@ -1,105 +1,105 @@ -/*
- * 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.spi.common.model;
-
-import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit.State;
-
-import org.eclipse.net4j.util.lifecycle.ILifecycle;
-
-import org.eclipse.emf.ecore.EPackage;
-
-import java.util.Set;
-
-/**
- * @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 InternalCDOPackageRegistry extends CDOPackageRegistry, ILifecycle
-{
- public void setReplacingDescriptors(boolean replacingDescriptors);
-
- public PackageProcessor getPackageProcessor();
-
- public void setPackageProcessor(PackageProcessor packageProcessor);
-
- public PackageLoader getPackageLoader();
-
- public void setPackageLoader(PackageLoader packageLoader);
-
- public Object basicPut(String nsURI, Object value);
-
- public void putPackageUnit(InternalCDOPackageUnit packageUnit);
-
- /**
- * @since 4.0
- */
- public void putPackageUnits(InternalCDOPackageUnit[] packageUnits, State state);
-
- /**
- * @since 4.0
- */
- public InternalCDOPackageUnit createPackageUnit();
-
- /**
- * @since 3.0
- */
- public InternalCDOPackageUnit getPackageUnit(String id);
-
- public InternalCDOPackageUnit getPackageUnit(EPackage ePackage);
-
- public InternalCDOPackageUnit[] getPackageUnits();
-
- /**
- * @since 4.0
- */
- public InternalCDOPackageUnit[] getPackageUnits(boolean withSystemPackages);
-
- /**
- * @since 3.0
- */
- public InternalCDOPackageUnit[] getPackageUnits(long startTime, long endTime);
-
- public InternalCDOPackageInfo getPackageInfo(EPackage ePackage);
-
- public InternalCDOPackageInfo[] getPackageInfos();
-
- public EPackage[] getEPackages();
-
- /**
- * @since 3.0
- */
- public Set<String> getAllKeys();
-
- /**
- * @since 3.0
- */
- public Object getWithDelegation(String nsURI, boolean resolve);
-
- /**
- * @author Eike Stepper
- */
- public interface PackageProcessor
- {
- public Object processPackage(Object value);
- }
-
- /**
- * @author Eike Stepper
- */
- public interface PackageLoader
- {
- public EPackage[] loadPackages(CDOPackageUnit packageUnit);
- }
-}
+/* + * 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.spi.common.model; + +import org.eclipse.emf.cdo.common.model.CDOPackageRegistry; +import org.eclipse.emf.cdo.common.model.CDOPackageUnit; +import org.eclipse.emf.cdo.common.model.CDOPackageUnit.State; + +import org.eclipse.net4j.util.lifecycle.ILifecycle; + +import org.eclipse.emf.ecore.EPackage; + +import java.util.Set; + +/** + * @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 InternalCDOPackageRegistry extends CDOPackageRegistry, ILifecycle +{ + public void setReplacingDescriptors(boolean replacingDescriptors); + + public PackageProcessor getPackageProcessor(); + + public void setPackageProcessor(PackageProcessor packageProcessor); + + public PackageLoader getPackageLoader(); + + public void setPackageLoader(PackageLoader packageLoader); + + public Object basicPut(String nsURI, Object value); + + public void putPackageUnit(InternalCDOPackageUnit packageUnit); + + /** + * @since 4.0 + */ + public void putPackageUnits(InternalCDOPackageUnit[] packageUnits, State state); + + /** + * @since 4.0 + */ + public InternalCDOPackageUnit createPackageUnit(); + + /** + * @since 3.0 + */ + public InternalCDOPackageUnit getPackageUnit(String id); + + public InternalCDOPackageUnit getPackageUnit(EPackage ePackage); + + public InternalCDOPackageUnit[] getPackageUnits(); + + /** + * @since 4.0 + */ + public InternalCDOPackageUnit[] getPackageUnits(boolean withSystemPackages); + + /** + * @since 3.0 + */ + public InternalCDOPackageUnit[] getPackageUnits(long startTime, long endTime); + + public InternalCDOPackageInfo getPackageInfo(EPackage ePackage); + + public InternalCDOPackageInfo[] getPackageInfos(); + + public EPackage[] getEPackages(); + + /** + * @since 3.0 + */ + public Set<String> getAllKeys(); + + /** + * @since 3.0 + */ + public Object getWithDelegation(String nsURI, boolean resolve); + + /** + * @author Eike Stepper + */ + public interface PackageProcessor + { + public Object processPackage(Object value); + } + + /** + * @author Eike Stepper + */ + public interface PackageLoader + { + public EPackage[] loadPackages(CDOPackageUnit packageUnit); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOPackageUnit.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOPackageUnit.java index 1232fc6a5a..46b32a859f 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOPackageUnit.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/InternalCDOPackageUnit.java @@ -1,72 +1,72 @@ -/*
- * 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.spi.common.model;
-
-import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
-import org.eclipse.emf.cdo.common.protocol.CDODataInput;
-import org.eclipse.emf.cdo.common.protocol.CDODataOutput;
-import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry.PackageLoader;
-
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-
-import java.io.IOException;
-
-/**
- * @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 InternalCDOPackageUnit extends CDOPackageUnit
-{
- public InternalCDOPackageRegistry getPackageRegistry();
-
- public void setPackageRegistry(InternalCDOPackageRegistry packageRegistry);
-
- public void setState(State state);
-
- public void setOriginalType(Type originalType);
-
- public void setTimeStamp(long timeStamp);
-
- public InternalCDOPackageInfo getTopLevelPackageInfo();
-
- public InternalCDOPackageInfo getPackageInfo(String packageURI);
-
- public InternalCDOPackageInfo[] getPackageInfos();
-
- public void setPackageInfos(InternalCDOPackageInfo[] packageInfos);
-
- /**
- * @since 4.0
- */
- public void load(boolean resolve);
-
- /**
- * @since 4.0
- */
- public void load(PackageLoader packageLoader, boolean resolve);
-
- /**
- * @since 3.0
- */
- public void write(CDODataOutput out, boolean withPackages) throws IOException;
-
- /**
- * @since 3.0
- */
- public void read(CDODataInput in, ResourceSet resourceSet) throws IOException;
-
- public void init(EPackage ePackage);
-
- public void dispose();
-}
+/* + * 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.spi.common.model; + +import org.eclipse.emf.cdo.common.model.CDOPackageUnit; +import org.eclipse.emf.cdo.common.protocol.CDODataInput; +import org.eclipse.emf.cdo.common.protocol.CDODataOutput; +import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageRegistry.PackageLoader; + +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.resource.ResourceSet; + +import java.io.IOException; + +/** + * @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 InternalCDOPackageUnit extends CDOPackageUnit +{ + public InternalCDOPackageRegistry getPackageRegistry(); + + public void setPackageRegistry(InternalCDOPackageRegistry packageRegistry); + + public void setState(State state); + + public void setOriginalType(Type originalType); + + public void setTimeStamp(long timeStamp); + + public InternalCDOPackageInfo getTopLevelPackageInfo(); + + public InternalCDOPackageInfo getPackageInfo(String packageURI); + + public InternalCDOPackageInfo[] getPackageInfos(); + + public void setPackageInfos(InternalCDOPackageInfo[] packageInfos); + + /** + * @since 4.0 + */ + public void load(boolean resolve); + + /** + * @since 4.0 + */ + public void load(PackageLoader packageLoader, boolean resolve); + + /** + * @since 3.0 + */ + public void write(CDODataOutput out, boolean withPackages) throws IOException; + + /** + * @since 3.0 + */ + public void read(CDODataInput in, ResourceSet resourceSet) throws IOException; + + public void init(EPackage ePackage); + + public void dispose(); +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/package-info.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/package-info.java index 6508609913..3d23e9f19a 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/package-info.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/model/package-info.java @@ -1,15 +1,15 @@ -/*
- * 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
- */
-
-/**
- * Common service provider interfaces and useful base implementations for dealing with models and types
- */
-package org.eclipse.emf.cdo.spi.common.model;
+/* + * 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 + */ + +/** + * Common service provider interfaces and useful base implementations for dealing with models and types + */ +package org.eclipse.emf.cdo.spi.common.model; diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/package-info.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/package-info.java index 8494f69797..f2a2f3419f 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/package-info.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/package-info.java @@ -1,15 +1,15 @@ -/*
- * 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
- */
-
-/**
- * Common service provider interfaces and useful base implementations.
- */
-package org.eclipse.emf.cdo.spi.common;
+/* + * 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 + */ + +/** + * Common service provider interfaces and useful base implementations. + */ +package org.eclipse.emf.cdo.spi.common; diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDOFeatureDeltaVisitorImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDOFeatureDeltaVisitorImpl.java index e1e6f96338..0c4ee62d4b 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDOFeatureDeltaVisitorImpl.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDOFeatureDeltaVisitorImpl.java @@ -1,98 +1,98 @@ -/*
- * 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.spi.common.revision;
-
-import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOClearFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOContainerFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor;
-import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta;
-
-/**
- * @author Simon McDuff
- * @since 3.0
- */
-public class CDOFeatureDeltaVisitorImpl implements CDOFeatureDeltaVisitor
-{
- public CDOFeatureDeltaVisitorImpl()
- {
- }
-
- public void visit(CDOAddFeatureDelta delta)
- {
- }
-
- public void visit(CDOClearFeatureDelta delta)
- {
- }
-
- public void visit(CDOContainerFeatureDelta delta)
- {
- }
-
- public void visit(CDOListFeatureDelta deltas)
- {
- for (CDOFeatureDelta delta : deltas.getListChanges())
- {
- try
- {
- delta.accept(this);
- }
- catch (StopVisitException ex)
- {
- return;
- }
- }
- }
-
- public void visit(CDOMoveFeatureDelta delta)
- {
- }
-
- public void visit(CDORemoveFeatureDelta delta)
- {
- }
-
- public void visit(CDOSetFeatureDelta delta)
- {
- }
-
- public void visit(CDOUnsetFeatureDelta delta)
- {
- }
-
- /**
- * @since 4.0
- */
- protected void stopVisit()
- {
- throw new StopVisitException();
- }
-
- /**
- * @author Eike Stepper
- * @since 4.0
- */
- private static final class StopVisitException extends RuntimeException
- {
- private static final long serialVersionUID = 1L;
-
- public StopVisitException()
- {
- }
- }
-}
+/* + * 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.spi.common.revision; + +import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOClearFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOContainerFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDeltaVisitor; +import org.eclipse.emf.cdo.common.revision.delta.CDOListFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta; + +/** + * @author Simon McDuff + * @since 3.0 + */ +public class CDOFeatureDeltaVisitorImpl implements CDOFeatureDeltaVisitor +{ + public CDOFeatureDeltaVisitorImpl() + { + } + + public void visit(CDOAddFeatureDelta delta) + { + } + + public void visit(CDOClearFeatureDelta delta) + { + } + + public void visit(CDOContainerFeatureDelta delta) + { + } + + public void visit(CDOListFeatureDelta deltas) + { + for (CDOFeatureDelta delta : deltas.getListChanges()) + { + try + { + delta.accept(this); + } + catch (StopVisitException ex) + { + return; + } + } + } + + public void visit(CDOMoveFeatureDelta delta) + { + } + + public void visit(CDORemoveFeatureDelta delta) + { + } + + public void visit(CDOSetFeatureDelta delta) + { + } + + public void visit(CDOUnsetFeatureDelta delta) + { + } + + /** + * @since 4.0 + */ + protected void stopVisit() + { + throw new StopVisitException(); + } + + /** + * @author Eike Stepper + * @since 4.0 + */ + private static final class StopVisitException extends RuntimeException + { + private static final long serialVersionUID = 1L; + + public StopVisitException() + { + } + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDOFeatureMapEntry.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDOFeatureMapEntry.java index e09c0ff74d..4677aec477 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDOFeatureMapEntry.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDOFeatureMapEntry.java @@ -1,25 +1,25 @@ -/*
- * 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:
- * Martin Taal - derived from CDOFeatureMapEntryImpl
- */
-package org.eclipse.emf.cdo.spi.common.revision;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.util.FeatureMap;
-
-/**
- * @since 3.0
- * @author Martin Taal
- */
-public interface CDOFeatureMapEntry extends FeatureMap.Entry
-{
- void setEStructuralFeature(EStructuralFeature feature);
-
- void setValue(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: + * Martin Taal - derived from CDOFeatureMapEntryImpl + */ +package org.eclipse.emf.cdo.spi.common.revision; + +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.ecore.util.FeatureMap; + +/** + * @since 3.0 + * @author Martin Taal + */ +public interface CDOFeatureMapEntry extends FeatureMap.Entry +{ + void setEStructuralFeature(EStructuralFeature feature); + + void setValue(Object value); +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDOIDMapper.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDOIDMapper.java index 3f18ffa4af..4a5ca49d02 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDOIDMapper.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDOIDMapper.java @@ -1,63 +1,63 @@ -/*
- * 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
- */
-package org.eclipse.emf.cdo.spi.common.revision;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.util.Map;
-
-/**
- * @author Simon McDuff
- * @since 2.0
- */
-public class CDOIDMapper implements CDOReferenceAdjuster
-{
- private Map<CDOID, CDOID> idMappings;
-
- private boolean allowUnmappedTempIDs;
-
- public CDOIDMapper(Map<CDOID, CDOID> idMappings)
- {
- this.idMappings = idMappings;
- }
-
- public Map<CDOID, CDOID> getIDMappings()
- {
- return idMappings;
- }
-
- /**
- * @since 3.0
- */
- public boolean isAllowUnmappedTempIDs()
- {
- return allowUnmappedTempIDs;
- }
-
- /**
- * @since 3.0
- */
- public void setAllowUnmappedTempIDs(boolean allowUnmappedTempIDs)
- {
- this.allowUnmappedTempIDs = allowUnmappedTempIDs;
- }
-
- /**
- * @since 4.0
- */
- public Object adjustReference(Object value, EStructuralFeature feature, int index)
- {
- return CDORevisionUtil.remapID(value, idMappings, allowUnmappedTempIDs);
- }
-}
+/* + * 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 + */ +package org.eclipse.emf.cdo.spi.common.revision; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.revision.CDORevisionUtil; + +import org.eclipse.emf.ecore.EStructuralFeature; + +import java.util.Map; + +/** + * @author Simon McDuff + * @since 2.0 + */ +public class CDOIDMapper implements CDOReferenceAdjuster +{ + private Map<CDOID, CDOID> idMappings; + + private boolean allowUnmappedTempIDs; + + public CDOIDMapper(Map<CDOID, CDOID> idMappings) + { + this.idMappings = idMappings; + } + + public Map<CDOID, CDOID> getIDMappings() + { + return idMappings; + } + + /** + * @since 3.0 + */ + public boolean isAllowUnmappedTempIDs() + { + return allowUnmappedTempIDs; + } + + /** + * @since 3.0 + */ + public void setAllowUnmappedTempIDs(boolean allowUnmappedTempIDs) + { + this.allowUnmappedTempIDs = allowUnmappedTempIDs; + } + + /** + * @since 4.0 + */ + public Object adjustReference(Object value, EStructuralFeature feature, int index) + { + return CDORevisionUtil.remapID(value, idMappings, allowUnmappedTempIDs); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDOReferenceAdjustable.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDOReferenceAdjustable.java index a206671ff3..edb26661d9 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDOReferenceAdjustable.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDOReferenceAdjustable.java @@ -1,21 +1,21 @@ -/*
- * 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.spi.common.revision;
-
-/**
- * @author Simon McDuff
- * @since 4.0
- */
-public interface CDOReferenceAdjustable
-{
- public boolean adjustReferences(CDOReferenceAdjuster referenceAdjuster);
-}
+/* + * 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.spi.common.revision; + +/** + * @author Simon McDuff + * @since 4.0 + */ +public interface CDOReferenceAdjustable +{ + public boolean adjustReferences(CDOReferenceAdjuster referenceAdjuster); +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDOReferenceAdjuster.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDOReferenceAdjuster.java index 3b9673d107..7d840eb460 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDOReferenceAdjuster.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDOReferenceAdjuster.java @@ -1,34 +1,34 @@ -/*
- * 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.spi.common.revision;
-
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.id.CDOIDTemp;
-import org.eclipse.emf.cdo.common.revision.CDOList;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-/**
- * @author Simon McDuff
- * @since 4.0
- */
-public interface CDOReferenceAdjuster
-{
- /**
- * Adjusts the internal structure of an object (e.g: {@link CDORevision}). This is mainly used after committing a
- * transaction. {@link CDORevision} must replace {@link CDOIDTemp} for non-temporary {@link CDOID} with a mapped ID.
- * Only the internal structure knows how to do these modifications. This is important to consider using different
- * implementation of {@link CDOList}.
- */
- public Object adjustReference(Object id, EStructuralFeature feature, int index);
-}
+/* + * 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.spi.common.revision; + +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.id.CDOIDTemp; +import org.eclipse.emf.cdo.common.revision.CDOList; +import org.eclipse.emf.cdo.common.revision.CDORevision; + +import org.eclipse.emf.ecore.EStructuralFeature; + +/** + * @author Simon McDuff + * @since 4.0 + */ +public interface CDOReferenceAdjuster +{ + /** + * Adjusts the internal structure of an object (e.g: {@link CDORevision}). This is mainly used after committing a + * transaction. {@link CDORevision} must replace {@link CDOIDTemp} for non-temporary {@link CDOID} with a mapped ID. + * Only the internal structure knows how to do these modifications. This is important to consider using different + * implementation of {@link CDOList}. + */ + public Object adjustReference(Object id, EStructuralFeature feature, int index); +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDORevisionMerger.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDORevisionMerger.java index 5d2934404f..4a0c11baa2 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDORevisionMerger.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/CDORevisionMerger.java @@ -1,86 +1,86 @@ -/*
- * 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.spi.common.revision;
-
-import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOClearFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOContainerFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta;
-
-/**
- * @author Simon McDuff
- * @since 2.0
- */
-public class CDORevisionMerger extends CDOFeatureDeltaVisitorImpl
-{
- private InternalCDORevision revision;
-
- public CDORevisionMerger()
- {
- }
-
- public synchronized void merge(InternalCDORevision revision, CDORevisionDelta delta)
- {
- this.revision = revision;
- delta.accept(this);
- revision = null;
- }
-
- @Override
- public void visit(CDOMoveFeatureDelta delta)
- {
- revision.move(delta.getFeature(), delta.getNewPosition(), delta.getOldPosition());
- }
-
- @Override
- public void visit(CDOAddFeatureDelta delta)
- {
- revision.add(delta.getFeature(), delta.getIndex(), delta.getValue());
- }
-
- @Override
- public void visit(CDORemoveFeatureDelta delta)
- {
- revision.remove(delta.getFeature(), delta.getIndex());
- }
-
- @Override
- public void visit(CDOSetFeatureDelta delta)
- {
- revision.set(delta.getFeature(), delta.getIndex(), delta.getValue());
- }
-
- @Override
- public void visit(CDOUnsetFeatureDelta delta)
- {
- revision.unset(delta.getFeature());
- }
-
- @Override
- public void visit(CDOClearFeatureDelta delta)
- {
- revision.clear(delta.getFeature());
- }
-
- @Override
- public void visit(CDOContainerFeatureDelta delta)
- {
- revision.setResourceID(delta.getResourceID());
- revision.setContainerID(delta.getContainerID());
- revision.setContainingFeatureID(delta.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.spi.common.revision; + +import org.eclipse.emf.cdo.common.revision.delta.CDOAddFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOClearFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOContainerFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOMoveFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDORemoveFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOSetFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDOUnsetFeatureDelta; + +/** + * @author Simon McDuff + * @since 2.0 + */ +public class CDORevisionMerger extends CDOFeatureDeltaVisitorImpl +{ + private InternalCDORevision revision; + + public CDORevisionMerger() + { + } + + public synchronized void merge(InternalCDORevision revision, CDORevisionDelta delta) + { + this.revision = revision; + delta.accept(this); + revision = null; + } + + @Override + public void visit(CDOMoveFeatureDelta delta) + { + revision.move(delta.getFeature(), delta.getNewPosition(), delta.getOldPosition()); + } + + @Override + public void visit(CDOAddFeatureDelta delta) + { + revision.add(delta.getFeature(), delta.getIndex(), delta.getValue()); + } + + @Override + public void visit(CDORemoveFeatureDelta delta) + { + revision.remove(delta.getFeature(), delta.getIndex()); + } + + @Override + public void visit(CDOSetFeatureDelta delta) + { + revision.set(delta.getFeature(), delta.getIndex(), delta.getValue()); + } + + @Override + public void visit(CDOUnsetFeatureDelta delta) + { + revision.unset(delta.getFeature()); + } + + @Override + public void visit(CDOClearFeatureDelta delta) + { + revision.clear(delta.getFeature()); + } + + @Override + public void visit(CDOContainerFeatureDelta delta) + { + revision.setResourceID(delta.getResourceID()); + revision.setContainerID(delta.getContainerID()); + revision.setContainingFeatureID(delta.getContainerFeatureID()); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevisionManager.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevisionManager.java index 6e36ce3ecd..186d4f0d04 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevisionManager.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DelegatingCDORevisionManager.java @@ -1,193 +1,193 @@ -/*
- * 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.spi.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.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionCache;
-import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
-
-import org.eclipse.net4j.util.lifecycle.Lifecycle;
-
-import org.eclipse.emf.ecore.EClass;
-
-import java.util.List;
-
-/**
- * @author Eike Stepper
- * @since 3.0
- */
-public abstract class DelegatingCDORevisionManager extends Lifecycle implements InternalCDORevisionManager
-{
- public DelegatingCDORevisionManager()
- {
- }
-
- public InternalCDORevisionCache getCache()
- {
- return getDelegate().getCache();
- }
-
- /**
- * @since 4.0
- */
- public void setCache(CDORevisionCache cache)
- {
- getDelegate().setCache(cache);
- }
-
- public void setFactory(CDORevisionFactory factory)
- {
- getDelegate().setFactory(factory);
- }
-
- public CDORevisionFactory getFactory()
- {
- return getDelegate().getFactory();
- }
-
- public RevisionLoader getRevisionLoader()
- {
- return getDelegate().getRevisionLoader();
- }
-
- public void setRevisionLoader(RevisionLoader revisionLoader)
- {
- getDelegate().setRevisionLoader(revisionLoader);
- }
-
- public RevisionLocker getRevisionLocker()
- {
- return getDelegate().getRevisionLocker();
- }
-
- public void setRevisionLocker(RevisionLocker revisionLocker)
- {
- getDelegate().setRevisionLocker(revisionLocker);
- }
-
- /**
- * @since 4.0
- */
- public boolean isSupportingAudits()
- {
- return getDelegate().isSupportingAudits();
- }
-
- /**
- * @since 4.0
- */
- public void setSupportingAudits(boolean on)
- {
- getDelegate().setSupportingAudits(on);
- }
-
- public boolean isSupportingBranches()
- {
- return getDelegate().isSupportingBranches();
- }
-
- public void setSupportingBranches(boolean on)
- {
- getDelegate().setSupportingBranches(on);
- }
-
- /**
- * @since 4.0
- */
- public void addRevision(CDORevision revision)
- {
- getDelegate().addRevision(revision);
- }
-
- public boolean containsRevision(CDOID id, CDOBranchPoint branchPoint)
- {
- return getDelegate().containsRevision(id, branchPoint);
- }
-
- public boolean containsRevisionByVersion(CDOID id, CDOBranchVersion branchVersion)
- {
- return getDelegate().containsRevisionByVersion(id, branchVersion);
- }
-
- public EClass getObjectType(CDOID id)
- {
- return getDelegate().getObjectType(id);
- }
-
- public InternalCDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int referenceChunk,
- boolean loadOnDemand)
- {
- return getDelegate().getRevisionByVersion(id, branchVersion, referenceChunk, loadOnDemand);
- }
-
- public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth,
- boolean loadOnDemand)
- {
- return getDelegate().getRevision(id, branchPoint, referenceChunk, prefetchDepth, loadOnDemand);
- }
-
- public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth,
- boolean loadOnDemand, SyntheticCDORevision[] synthetics)
- {
- return getDelegate().getRevision(id, branchPoint, referenceChunk, prefetchDepth, loadOnDemand, synthetics);
- }
-
- public List<CDORevision> getRevisions(List<CDOID> ids, CDOBranchPoint branchPoint, int referenceChunk,
- int prefetchDepth, boolean loadOnDemand)
- {
- return getDelegate().getRevisions(ids, branchPoint, referenceChunk, prefetchDepth, loadOnDemand);
- }
-
- public List<CDORevision> getRevisions(List<CDOID> ids, CDOBranchPoint branchPoint, int referenceChunk,
- int prefetchDepth, boolean loadOnDemand, SyntheticCDORevision[] synthetics)
- {
- return getDelegate().getRevisions(ids, branchPoint, referenceChunk, prefetchDepth, loadOnDemand, synthetics);
- }
-
- public void reviseLatest(CDOID id, CDOBranch branch)
- {
- getDelegate().reviseLatest(id, branch);
- }
-
- public void reviseVersion(CDOID id, CDOBranchVersion branchVersion, long timeStamp)
- {
- getDelegate().reviseVersion(id, branchVersion, timeStamp);
- }
-
- @Override
- protected void doActivate() throws Exception
- {
- if (isDelegatingLifecycle())
- {
- getDelegate().activate();
- }
- }
-
- @Override
- protected void doDeactivate() throws Exception
- {
- if (isDelegatingLifecycle())
- {
- getDelegate().deactivate();
- }
- }
-
- protected boolean isDelegatingLifecycle()
- {
- return true;
- }
-
- protected abstract InternalCDORevisionManager 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.spi.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.id.CDOID; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.CDORevisionCache; +import org.eclipse.emf.cdo.common.revision.CDORevisionFactory; + +import org.eclipse.net4j.util.lifecycle.Lifecycle; + +import org.eclipse.emf.ecore.EClass; + +import java.util.List; + +/** + * @author Eike Stepper + * @since 3.0 + */ +public abstract class DelegatingCDORevisionManager extends Lifecycle implements InternalCDORevisionManager +{ + public DelegatingCDORevisionManager() + { + } + + public InternalCDORevisionCache getCache() + { + return getDelegate().getCache(); + } + + /** + * @since 4.0 + */ + public void setCache(CDORevisionCache cache) + { + getDelegate().setCache(cache); + } + + public void setFactory(CDORevisionFactory factory) + { + getDelegate().setFactory(factory); + } + + public CDORevisionFactory getFactory() + { + return getDelegate().getFactory(); + } + + public RevisionLoader getRevisionLoader() + { + return getDelegate().getRevisionLoader(); + } + + public void setRevisionLoader(RevisionLoader revisionLoader) + { + getDelegate().setRevisionLoader(revisionLoader); + } + + public RevisionLocker getRevisionLocker() + { + return getDelegate().getRevisionLocker(); + } + + public void setRevisionLocker(RevisionLocker revisionLocker) + { + getDelegate().setRevisionLocker(revisionLocker); + } + + /** + * @since 4.0 + */ + public boolean isSupportingAudits() + { + return getDelegate().isSupportingAudits(); + } + + /** + * @since 4.0 + */ + public void setSupportingAudits(boolean on) + { + getDelegate().setSupportingAudits(on); + } + + public boolean isSupportingBranches() + { + return getDelegate().isSupportingBranches(); + } + + public void setSupportingBranches(boolean on) + { + getDelegate().setSupportingBranches(on); + } + + /** + * @since 4.0 + */ + public void addRevision(CDORevision revision) + { + getDelegate().addRevision(revision); + } + + public boolean containsRevision(CDOID id, CDOBranchPoint branchPoint) + { + return getDelegate().containsRevision(id, branchPoint); + } + + public boolean containsRevisionByVersion(CDOID id, CDOBranchVersion branchVersion) + { + return getDelegate().containsRevisionByVersion(id, branchVersion); + } + + public EClass getObjectType(CDOID id) + { + return getDelegate().getObjectType(id); + } + + public InternalCDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int referenceChunk, + boolean loadOnDemand) + { + return getDelegate().getRevisionByVersion(id, branchVersion, referenceChunk, loadOnDemand); + } + + public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth, + boolean loadOnDemand) + { + return getDelegate().getRevision(id, branchPoint, referenceChunk, prefetchDepth, loadOnDemand); + } + + public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth, + boolean loadOnDemand, SyntheticCDORevision[] synthetics) + { + return getDelegate().getRevision(id, branchPoint, referenceChunk, prefetchDepth, loadOnDemand, synthetics); + } + + public List<CDORevision> getRevisions(List<CDOID> ids, CDOBranchPoint branchPoint, int referenceChunk, + int prefetchDepth, boolean loadOnDemand) + { + return getDelegate().getRevisions(ids, branchPoint, referenceChunk, prefetchDepth, loadOnDemand); + } + + public List<CDORevision> getRevisions(List<CDOID> ids, CDOBranchPoint branchPoint, int referenceChunk, + int prefetchDepth, boolean loadOnDemand, SyntheticCDORevision[] synthetics) + { + return getDelegate().getRevisions(ids, branchPoint, referenceChunk, prefetchDepth, loadOnDemand, synthetics); + } + + public void reviseLatest(CDOID id, CDOBranch branch) + { + getDelegate().reviseLatest(id, branch); + } + + public void reviseVersion(CDOID id, CDOBranchVersion branchVersion, long timeStamp) + { + getDelegate().reviseVersion(id, branchVersion, timeStamp); + } + + @Override + protected void doActivate() throws Exception + { + if (isDelegatingLifecycle()) + { + getDelegate().activate(); + } + } + + @Override + protected void doDeactivate() throws Exception + { + if (isDelegatingLifecycle()) + { + getDelegate().deactivate(); + } + } + + protected boolean isDelegatingLifecycle() + { + return true; + } + + protected abstract InternalCDORevisionManager getDelegate(); +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DetachedCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DetachedCDORevision.java index b940ae58a8..885df9b98d 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DetachedCDORevision.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/DetachedCDORevision.java @@ -1,69 +1,69 @@ -/*
- * 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.spi.common.revision;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.id.CDOID;
-
-import org.eclipse.emf.ecore.EClass;
-
-/**
- * @author Eike Stepper
- * @since 3.0
- */
-public class DetachedCDORevision extends SyntheticCDORevision
-{
- private int version;
-
- private long timeStamp;
-
- private long revised;
-
- public DetachedCDORevision(EClass eClass, CDOID id, CDOBranch branch, int version, long timeStamp)
- {
- this(eClass, id, branch, version, timeStamp, UNSPECIFIED_DATE);
- }
-
- /**
- * @since 4.0
- */
- public DetachedCDORevision(EClass eClass, CDOID id, CDOBranch branch, int version, long timeStamp, long revised)
- {
- super(eClass, id, branch);
- this.version = version;
- this.timeStamp = timeStamp;
- this.revised = revised;
- }
-
- @Override
- public final int getVersion()
- {
- return version;
- }
-
- @Override
- public long getTimeStamp()
- {
- return timeStamp;
- }
-
- @Override
- public long getRevised()
- {
- return revised;
- }
-
- @Override
- public void setRevised(long revised)
- {
- this.revised = revised;
- }
-}
+/* + * 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.spi.common.revision; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.id.CDOID; + +import org.eclipse.emf.ecore.EClass; + +/** + * @author Eike Stepper + * @since 3.0 + */ +public class DetachedCDORevision extends SyntheticCDORevision +{ + private int version; + + private long timeStamp; + + private long revised; + + public DetachedCDORevision(EClass eClass, CDOID id, CDOBranch branch, int version, long timeStamp) + { + this(eClass, id, branch, version, timeStamp, UNSPECIFIED_DATE); + } + + /** + * @since 4.0 + */ + public DetachedCDORevision(EClass eClass, CDOID id, CDOBranch branch, int version, long timeStamp, long revised) + { + super(eClass, id, branch); + this.version = version; + this.timeStamp = timeStamp; + this.revised = revised; + } + + @Override + public final int getVersion() + { + return version; + } + + @Override + public long getTimeStamp() + { + return timeStamp; + } + + @Override + public long getRevised() + { + return revised; + } + + @Override + public void setRevised(long revised) + { + this.revised = revised; + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDOFeatureDelta.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDOFeatureDelta.java index 81cc54549b..0565f45bad 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDOFeatureDelta.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDOFeatureDelta.java @@ -1,57 +1,57 @@ -/*
- * 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.spi.common.revision;
-
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-
-/**
- * @author Simon McDuff
- * @since 3.0
- */
-public interface InternalCDOFeatureDelta extends CDOFeatureDelta
-{
- /**
- * @author Eike Stepper
- */
- public interface WithIndex
- {
- public void adjustAfterAddition(int index);
-
- public void adjustAfterRemoval(int index);
- }
-
- /**
- * @author Eike Stepper
- */
- public interface ListIndexAffecting
- {
- /**
- * Expects the number of indices in the first element of the indices array.
- */
- public void affectIndices(ListTargetAdding source[], int[] indices);
- }
-
- /**
- * @author Eike Stepper
- */
- public interface ListTargetAdding
- {
- /**
- * @since 4.0
- */
- public Object getValue();
-
- public int getIndex();
-
- public void clear();
- }
-}
+/* + * 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.spi.common.revision; + +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta; + +/** + * @author Simon McDuff + * @since 3.0 + */ +public interface InternalCDOFeatureDelta extends CDOFeatureDelta +{ + /** + * @author Eike Stepper + */ + public interface WithIndex + { + public void adjustAfterAddition(int index); + + public void adjustAfterRemoval(int index); + } + + /** + * @author Eike Stepper + */ + public interface ListIndexAffecting + { + /** + * Expects the number of indices in the first element of the indices array. + */ + public void affectIndices(ListTargetAdding source[], int[] indices); + } + + /** + * @author Eike Stepper + */ + public interface ListTargetAdding + { + /** + * @since 4.0 + */ + public Object getValue(); + + public int getIndex(); + + public void clear(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDOList.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDOList.java index 9960d1fbe1..031717e62f 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDOList.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDOList.java @@ -1,49 +1,49 @@ -/*
- * 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.spi.common.revision;
-
-import org.eclipse.emf.cdo.common.revision.CDOList;
-import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
-
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-/**
- * @author Simon McDuff
- * @since 2.0
- */
-public interface InternalCDOList extends CDOList
-{
- public static final Object UNINITIALIZED = CDORevisionUtil.UNINITIALIZED;
-
- /**
- * Adjusts references according to the passed adjuster and resynchronizes indexes.
- *
- * @since 4.0
- */
- public boolean adjustReferences(CDOReferenceAdjuster adjuster, EStructuralFeature feature);
-
- /**
- * Clones the list.
- */
- public InternalCDOList clone(EClassifier classifier);
-
- /**
- * @since 4.0
- */
- public void freeze();
-
- /**
- * @since 4.0
- */
- public void setWithoutFrozenCheck(int i, 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: + * Simon McDuff - initial API and implementation + * Eike Stepper - maintenance + */ +package org.eclipse.emf.cdo.spi.common.revision; + +import org.eclipse.emf.cdo.common.revision.CDOList; +import org.eclipse.emf.cdo.common.revision.CDORevisionUtil; + +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EStructuralFeature; + +/** + * @author Simon McDuff + * @since 2.0 + */ +public interface InternalCDOList extends CDOList +{ + public static final Object UNINITIALIZED = CDORevisionUtil.UNINITIALIZED; + + /** + * Adjusts references according to the passed adjuster and resynchronizes indexes. + * + * @since 4.0 + */ + public boolean adjustReferences(CDOReferenceAdjuster adjuster, EStructuralFeature feature); + + /** + * Clones the list. + */ + public InternalCDOList clone(EClassifier classifier); + + /** + * @since 4.0 + */ + public void freeze(); + + /** + * @since 4.0 + */ + public void setWithoutFrozenCheck(int i, Object value); +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevisionCache.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevisionCache.java index e753650b93..7297d86c8b 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevisionCache.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevisionCache.java @@ -1,37 +1,37 @@ -/*
- * 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.spi.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.common.revision.CDOAllRevisionsProvider;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionCache;
-
-import org.eclipse.net4j.util.lifecycle.ILifecycle;
-
-import java.util.List;
-
-/**
- * @author Eike Stepper
- * @since 3.0
- */
-public interface InternalCDORevisionCache extends CDORevisionCache, CDOAllRevisionsProvider, ILifecycle
-{
- public InternalCDORevisionCache instantiate(CDORevision revision);
-
- public CDORevision removeRevision(CDOID id, CDOBranchVersion branchVersion);
-
- public void clear();
-
- public List<CDORevision> getRevisions(CDOBranchPoint branchPoint);
-}
+/* + * 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.spi.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.common.revision.CDOAllRevisionsProvider; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.CDORevisionCache; + +import org.eclipse.net4j.util.lifecycle.ILifecycle; + +import java.util.List; + +/** + * @author Eike Stepper + * @since 3.0 + */ +public interface InternalCDORevisionCache extends CDORevisionCache, CDOAllRevisionsProvider, ILifecycle +{ + public InternalCDORevisionCache instantiate(CDORevision revision); + + public CDORevision removeRevision(CDOID id, CDOBranchVersion branchVersion); + + public void clear(); + + public List<CDORevision> getRevisions(CDOBranchPoint branchPoint); +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevisionDelta.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevisionDelta.java index ca4cdb0268..27abcbec7d 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevisionDelta.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevisionDelta.java @@ -1,51 +1,51 @@ -/*
- * 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.spi.common.revision;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.revision.CDORevisable;
-import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta;
-import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta;
-
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-import java.util.Map;
-
-/**
- * @author Eike Stepper
- * @noimplement This interface is not intended to be implemented by clients.
- * @noextend This interface is not intended to be extended by clients.
- * @since 2.0
- */
-public interface InternalCDORevisionDelta extends CDORevisionDelta, CDOReferenceAdjustable
-{
- /**
- * @since 3.0
- */
- public Map<EStructuralFeature, CDOFeatureDelta> getFeatureDeltaMap();
-
- public void addFeatureDelta(CDOFeatureDelta delta);
-
- /**
- * @since 3.0
- */
- public void setBranch(CDOBranch branch);
-
- /**
- * @since 3.0
- */
- public void setVersion(int version);
-
- /**
- * @since 4.0
- */
- public void setTarget(CDORevisable target);
-}
+/* + * 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.spi.common.revision; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.revision.CDORevisable; +import org.eclipse.emf.cdo.common.revision.delta.CDOFeatureDelta; +import org.eclipse.emf.cdo.common.revision.delta.CDORevisionDelta; + +import org.eclipse.emf.ecore.EStructuralFeature; + +import java.util.Map; + +/** + * @author Eike Stepper + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. + * @since 2.0 + */ +public interface InternalCDORevisionDelta extends CDORevisionDelta, CDOReferenceAdjustable +{ + /** + * @since 3.0 + */ + public Map<EStructuralFeature, CDOFeatureDelta> getFeatureDeltaMap(); + + public void addFeatureDelta(CDOFeatureDelta delta); + + /** + * @since 3.0 + */ + public void setBranch(CDOBranch branch); + + /** + * @since 3.0 + */ + public void setVersion(int version); + + /** + * @since 4.0 + */ + public void setTarget(CDORevisable target); +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevisionManager.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevisionManager.java index 98d9dcf73f..79b85aab76 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevisionManager.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/InternalCDORevisionManager.java @@ -1,107 +1,107 @@ -/*
- * 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.spi.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.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionCache;
-import org.eclipse.emf.cdo.common.revision.CDORevisionCacheAdder;
-import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
-import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
-
-import org.eclipse.net4j.util.lifecycle.ILifecycle;
-
-import java.util.List;
-
-/**
- * @author Eike Stepper
- * @since 3.0
- */
-public interface InternalCDORevisionManager extends CDORevisionManager, CDORevisionCacheAdder, ILifecycle
-{
- /**
- * @since 4.0
- */
- public boolean isSupportingAudits();
-
- /**
- * @since 4.0
- */
- public void setSupportingAudits(boolean on);
-
- public boolean isSupportingBranches();
-
- public void setSupportingBranches(boolean on);
-
- public RevisionLoader getRevisionLoader();
-
- public void setRevisionLoader(RevisionLoader revisionLoader);
-
- public RevisionLocker getRevisionLocker();
-
- public void setRevisionLocker(RevisionLocker revisionLocker);
-
- public CDORevisionFactory getFactory();
-
- public void setFactory(CDORevisionFactory factory);
-
- public InternalCDORevisionCache getCache();
-
- /**
- * @since 4.0
- */
- public void setCache(CDORevisionCache cache);
-
- /**
- * Called on client via postCommit when there is no version of detached objects available.
- */
- public void reviseLatest(CDOID id, CDOBranch branch);
-
- public void reviseVersion(CDOID id, CDOBranchVersion branchVersion, long timeStamp);
-
- public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth,
- boolean loadOnDemand, SyntheticCDORevision[] synthetics);
-
- public List<CDORevision> getRevisions(List<CDOID> ids, CDOBranchPoint branchPoint, int referenceChunk,
- int prefetchDepth, boolean loadOnDemand, SyntheticCDORevision[] synthetics);
-
- public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth,
- boolean loadOnDemand);
-
- public InternalCDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int referenceChunk,
- boolean loadOnDemand);
-
- /**
- * @author Eike Stepper
- * @since 3.0
- */
- public interface RevisionLoader
- {
- public List<InternalCDORevision> loadRevisions(List<RevisionInfo> infos, CDOBranchPoint branchPoint,
- int referenceChunk, int prefetchDepth);
-
- public InternalCDORevision loadRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int referenceChunk);
- }
-
- /**
- * @author Eike Stepper
- * @since 3.0
- */
- public interface RevisionLocker
- {
- public void acquireAtomicRequestLock(Object key);
-
- public void releaseAtomicRequestLock(Object key);
- }
-}
+/* + * 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.spi.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.id.CDOID; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.CDORevisionCache; +import org.eclipse.emf.cdo.common.revision.CDORevisionCacheAdder; +import org.eclipse.emf.cdo.common.revision.CDORevisionFactory; +import org.eclipse.emf.cdo.common.revision.CDORevisionManager; + +import org.eclipse.net4j.util.lifecycle.ILifecycle; + +import java.util.List; + +/** + * @author Eike Stepper + * @since 3.0 + */ +public interface InternalCDORevisionManager extends CDORevisionManager, CDORevisionCacheAdder, ILifecycle +{ + /** + * @since 4.0 + */ + public boolean isSupportingAudits(); + + /** + * @since 4.0 + */ + public void setSupportingAudits(boolean on); + + public boolean isSupportingBranches(); + + public void setSupportingBranches(boolean on); + + public RevisionLoader getRevisionLoader(); + + public void setRevisionLoader(RevisionLoader revisionLoader); + + public RevisionLocker getRevisionLocker(); + + public void setRevisionLocker(RevisionLocker revisionLocker); + + public CDORevisionFactory getFactory(); + + public void setFactory(CDORevisionFactory factory); + + public InternalCDORevisionCache getCache(); + + /** + * @since 4.0 + */ + public void setCache(CDORevisionCache cache); + + /** + * Called on client via postCommit when there is no version of detached objects available. + */ + public void reviseLatest(CDOID id, CDOBranch branch); + + public void reviseVersion(CDOID id, CDOBranchVersion branchVersion, long timeStamp); + + public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth, + boolean loadOnDemand, SyntheticCDORevision[] synthetics); + + public List<CDORevision> getRevisions(List<CDOID> ids, CDOBranchPoint branchPoint, int referenceChunk, + int prefetchDepth, boolean loadOnDemand, SyntheticCDORevision[] synthetics); + + public InternalCDORevision getRevision(CDOID id, CDOBranchPoint branchPoint, int referenceChunk, int prefetchDepth, + boolean loadOnDemand); + + public InternalCDORevision getRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int referenceChunk, + boolean loadOnDemand); + + /** + * @author Eike Stepper + * @since 3.0 + */ + public interface RevisionLoader + { + public List<InternalCDORevision> loadRevisions(List<RevisionInfo> infos, CDOBranchPoint branchPoint, + int referenceChunk, int prefetchDepth); + + public InternalCDORevision loadRevisionByVersion(CDOID id, CDOBranchVersion branchVersion, int referenceChunk); + } + + /** + * @author Eike Stepper + * @since 3.0 + */ + public interface RevisionLocker + { + public void acquireAtomicRequestLock(Object key); + + public void releaseAtomicRequestLock(Object key); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/ManagedRevisionProvider.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/ManagedRevisionProvider.java index 6fd1f59d71..1686321010 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/ManagedRevisionProvider.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/ManagedRevisionProvider.java @@ -1,49 +1,49 @@ -/*
- * 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.spi.common.revision;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevision;
-import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
-import org.eclipse.emf.cdo.common.revision.CDORevisionProvider;
-
-/**
- * @author Eike Stepper
- * @since 4.0
- */
-public class ManagedRevisionProvider implements CDORevisionProvider
-{
- private CDORevisionManager revisionManager;
-
- private CDOBranchPoint branchPoint;
-
- public ManagedRevisionProvider(CDORevisionManager revisionManager, CDOBranchPoint branchPoint)
- {
- this.branchPoint = branchPoint;
- this.revisionManager = revisionManager;
- }
-
- public CDORevisionManager getRevisionManager()
- {
- return revisionManager;
- }
-
- public CDOBranchPoint getBranchPoint()
- {
- return branchPoint;
- }
-
- public CDORevision getRevision(CDOID id)
- {
- return revisionManager.getRevision(id, branchPoint, CDORevision.UNCHUNKED, CDORevision.DEPTH_NONE, 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.spi.common.revision; + +import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.common.revision.CDORevisionManager; +import org.eclipse.emf.cdo.common.revision.CDORevisionProvider; + +/** + * @author Eike Stepper + * @since 4.0 + */ +public class ManagedRevisionProvider implements CDORevisionProvider +{ + private CDORevisionManager revisionManager; + + private CDOBranchPoint branchPoint; + + public ManagedRevisionProvider(CDORevisionManager revisionManager, CDOBranchPoint branchPoint) + { + this.branchPoint = branchPoint; + this.revisionManager = revisionManager; + } + + public CDORevisionManager getRevisionManager() + { + return revisionManager; + } + + public CDOBranchPoint getBranchPoint() + { + return branchPoint; + } + + public CDORevision getRevision(CDOID id) + { + return revisionManager.getRevision(id, branchPoint, CDORevision.UNCHUNKED, CDORevision.DEPTH_NONE, true); + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/PointerCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/PointerCDORevision.java index 1cab3a0ecb..68a7164d63 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/PointerCDORevision.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/PointerCDORevision.java @@ -1,69 +1,69 @@ -/*
- * 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.spi.common.revision;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-import org.eclipse.emf.cdo.common.id.CDOID;
-
-import org.eclipse.emf.ecore.EClass;
-
-/**
- * A {@link SyntheticCDORevision synthetic} revision that represents the initial period of an object in a
- * {@link CDOBranch branch} when the object is still associated with a revision from one of the baseline branches. It
- * always has {@link #getVersion() version} {@link CDOBranchVersion#UNSPECIFIED_VERSION zero} and can only appear in
- * branches below the {@link CDOBranch#isMainBranch() main} branch.
- *
- * @author Eike Stepper
- * @since 3.0
- */
-public class PointerCDORevision extends SyntheticCDORevision
-{
- private long revised = UNSPECIFIED_DATE;
-
- private CDOBranchVersion target;
-
- public PointerCDORevision(EClass eClass, CDOID id, CDOBranch branch, long revised, CDOBranchVersion target)
- {
- super(eClass, id, branch);
- this.revised = revised;
- this.target = target;
- }
-
- @Override
- public final int getVersion()
- {
- return UNSPECIFIED_VERSION;
- }
-
- @Override
- public long getTimeStamp()
- {
- return getBranch().getBase().getTimeStamp();
- }
-
- @Override
- public long getRevised()
- {
- return revised;
- }
-
- @Override
- public void setRevised(long revised)
- {
- this.revised = revised;
- }
-
- public CDOBranchVersion getTarget()
- {
- return target;
- }
-}
+/* + * 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.spi.common.revision; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; +import org.eclipse.emf.cdo.common.id.CDOID; + +import org.eclipse.emf.ecore.EClass; + +/** + * A {@link SyntheticCDORevision synthetic} revision that represents the initial period of an object in a + * {@link CDOBranch branch} when the object is still associated with a revision from one of the baseline branches. It + * always has {@link #getVersion() version} {@link CDOBranchVersion#UNSPECIFIED_VERSION zero} and can only appear in + * branches below the {@link CDOBranch#isMainBranch() main} branch. + * + * @author Eike Stepper + * @since 3.0 + */ +public class PointerCDORevision extends SyntheticCDORevision +{ + private long revised = UNSPECIFIED_DATE; + + private CDOBranchVersion target; + + public PointerCDORevision(EClass eClass, CDOID id, CDOBranch branch, long revised, CDOBranchVersion target) + { + super(eClass, id, branch); + this.revised = revised; + this.target = target; + } + + @Override + public final int getVersion() + { + return UNSPECIFIED_VERSION; + } + + @Override + public long getTimeStamp() + { + return getBranch().getBase().getTimeStamp(); + } + + @Override + public long getRevised() + { + return revised; + } + + @Override + public void setRevised(long revised) + { + this.revised = revised; + } + + public CDOBranchVersion getTarget() + { + return target; + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/SyntheticCDORevision.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/SyntheticCDORevision.java index 3fe2ae2dd2..2687010565 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/SyntheticCDORevision.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/SyntheticCDORevision.java @@ -1,70 +1,70 @@ -/*
- * 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.spi.common.revision;
-
-import org.eclipse.emf.cdo.common.branch.CDOBranch;
-import org.eclipse.emf.cdo.common.branch.CDOBranchVersion;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.common.revision.CDORevisionCache;
-import org.eclipse.emf.cdo.common.revision.CDORevisionManager;
-
-import org.eclipse.emf.ecore.EClass;
-
-/**
- * A synthetic revision that represents the initial period of an object in a {@link CDOBranch branch} when the object is
- * still associated with a revision from one of the baseline branches. It always has {@link #getVersion() version}
- * {@link CDOBranchVersion#UNSPECIFIED_VERSION zero} and can only appear in branches below the
- * {@link CDOBranch#isMainBranch() main} branch.
- * <p>
- * Synthetic revisions are used for two slightly different purposes:
- * <ol>
- * <li>For {@link CDORevisionCache cache} optimization.
- * <li>As a persistent "detach marker" indicating that the first modification of an object in a branch is its deletion.
- * </ol>
- * <p>
- * Instances of this marker revision are not supposed to be exposed outside of a revision {@link CDORevisionManager
- * manager}. They are mainly used in the communication between a revision manager and its associated revision
- * {@link InternalCDORevisionManager.RevisionLoader loader}.
- *
- * @author Eike Stepper
- * @since 3.0
- */
-public abstract class SyntheticCDORevision extends StubCDORevision
-{
- private CDOID id;
-
- private CDOBranch branch;
-
- public SyntheticCDORevision(EClass eClass, CDOID id, CDOBranch branch)
- {
- super(eClass);
- this.id = id;
- this.branch = branch;
- }
-
- @Override
- public CDOID getID()
- {
- return id;
- }
-
- @Override
- public CDOBranch getBranch()
- {
- return branch;
- }
-
- @Override
- public void freeze()
- {
- // Do nothing
- }
-}
+/* + * 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.spi.common.revision; + +import org.eclipse.emf.cdo.common.branch.CDOBranch; +import org.eclipse.emf.cdo.common.branch.CDOBranchVersion; +import org.eclipse.emf.cdo.common.id.CDOID; +import org.eclipse.emf.cdo.common.revision.CDORevisionCache; +import org.eclipse.emf.cdo.common.revision.CDORevisionManager; + +import org.eclipse.emf.ecore.EClass; + +/** + * A synthetic revision that represents the initial period of an object in a {@link CDOBranch branch} when the object is + * still associated with a revision from one of the baseline branches. It always has {@link #getVersion() version} + * {@link CDOBranchVersion#UNSPECIFIED_VERSION zero} and can only appear in branches below the + * {@link CDOBranch#isMainBranch() main} branch. + * <p> + * Synthetic revisions are used for two slightly different purposes: + * <ol> + * <li>For {@link CDORevisionCache cache} optimization. + * <li>As a persistent "detach marker" indicating that the first modification of an object in a branch is its deletion. + * </ol> + * <p> + * Instances of this marker revision are not supposed to be exposed outside of a revision {@link CDORevisionManager + * manager}. They are mainly used in the communication between a revision manager and its associated revision + * {@link InternalCDORevisionManager.RevisionLoader loader}. + * + * @author Eike Stepper + * @since 3.0 + */ +public abstract class SyntheticCDORevision extends StubCDORevision +{ + private CDOID id; + + private CDOBranch branch; + + public SyntheticCDORevision(EClass eClass, CDOID id, CDOBranch branch) + { + super(eClass); + this.id = id; + this.branch = branch; + } + + @Override + public CDOID getID() + { + return id; + } + + @Override + public CDOBranch getBranch() + { + return branch; + } + + @Override + public void freeze() + { + // Do nothing + } +} diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/package-info.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/package-info.java index 5488739d64..e588086f1d 100644 --- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/package-info.java +++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/revision/package-info.java @@ -1,15 +1,15 @@ -/*
- * 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
- */
-
-/**
- * Common service provider interfaces and useful base implementations for dealing with revisions and deltas.
- */
-package org.eclipse.emf.cdo.spi.common.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 + */ + +/** + * Common service provider interfaces and useful base implementations for dealing with revisions and deltas. + */ +package org.eclipse.emf.cdo.spi.common.revision; |