diff options
Diffstat (limited to 'plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/remote/CDORemoteSessionImpl.java')
-rw-r--r-- | plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/remote/CDORemoteSessionImpl.java | 234 |
1 files changed, 117 insertions, 117 deletions
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/remote/CDORemoteSessionImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/remote/CDORemoteSessionImpl.java index 6e4071835c..8843decce7 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/remote/CDORemoteSessionImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/remote/CDORemoteSessionImpl.java @@ -1,117 +1,117 @@ -/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.internal.cdo.session.remote;
-
-import org.eclipse.emf.cdo.session.remote.CDORemoteSession;
-import org.eclipse.emf.cdo.session.remote.CDORemoteSessionMessage;
-
-import org.eclipse.emf.spi.cdo.InternalCDORemoteSession;
-import org.eclipse.emf.spi.cdo.InternalCDORemoteSessionManager;
-
-import java.text.MessageFormat;
-
-/**
- * @author Eike Stepper
- */
-public class CDORemoteSessionImpl implements InternalCDORemoteSession
-{
- private InternalCDORemoteSessionManager manager;
-
- private int sessionID;
-
- private String userID;
-
- private boolean subscribed;
-
- public CDORemoteSessionImpl(InternalCDORemoteSessionManager manager, int sessionID, String userID)
- {
- this.manager = manager;
- this.sessionID = sessionID;
- this.userID = userID;
- }
-
- public InternalCDORemoteSessionManager getManager()
- {
- return manager;
- }
-
- public int getSessionID()
- {
- return sessionID;
- }
-
- public String getUserID()
- {
- return userID;
- }
-
- public boolean isSubscribed()
- {
- return subscribed;
- }
-
- public void setSubscribed(boolean subscribed)
- {
- this.subscribed = subscribed;
- }
-
- public boolean sendMessage(CDORemoteSessionMessage message)
- {
- if (!isSubscribed())
- {
- return false;
- }
-
- return manager.sendMessage(message, this).size() == 1;
- }
-
- public int compareTo(CDORemoteSession obj)
- {
- int result = userID.compareTo(obj.getUserID());
- if (result == 0)
- {
- result = Integer.valueOf(sessionID).compareTo(obj.getSessionID());
- }
-
- return result;
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (obj == this)
- {
- return true;
- }
-
- if (obj instanceof CDORemoteSession)
- {
- CDORemoteSession that = (CDORemoteSession)obj;
- return manager == that.getManager() && sessionID == that.getSessionID();
- }
-
- return false;
- }
-
- @Override
- public int hashCode()
- {
- return manager.hashCode() ^ sessionID;
- }
-
- @Override
- public String toString()
- {
- String repo = manager.getLocalSession().getRepositoryInfo().getName();
- String user = userID == null ? repo : userID + "@" + repo;
- return MessageFormat.format("{0} ({1})", user, sessionID); //$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.internal.cdo.session.remote; + +import org.eclipse.emf.cdo.session.remote.CDORemoteSession; +import org.eclipse.emf.cdo.session.remote.CDORemoteSessionMessage; + +import org.eclipse.emf.spi.cdo.InternalCDORemoteSession; +import org.eclipse.emf.spi.cdo.InternalCDORemoteSessionManager; + +import java.text.MessageFormat; + +/** + * @author Eike Stepper + */ +public class CDORemoteSessionImpl implements InternalCDORemoteSession +{ + private InternalCDORemoteSessionManager manager; + + private int sessionID; + + private String userID; + + private boolean subscribed; + + public CDORemoteSessionImpl(InternalCDORemoteSessionManager manager, int sessionID, String userID) + { + this.manager = manager; + this.sessionID = sessionID; + this.userID = userID; + } + + public InternalCDORemoteSessionManager getManager() + { + return manager; + } + + public int getSessionID() + { + return sessionID; + } + + public String getUserID() + { + return userID; + } + + public boolean isSubscribed() + { + return subscribed; + } + + public void setSubscribed(boolean subscribed) + { + this.subscribed = subscribed; + } + + public boolean sendMessage(CDORemoteSessionMessage message) + { + if (!isSubscribed()) + { + return false; + } + + return manager.sendMessage(message, this).size() == 1; + } + + public int compareTo(CDORemoteSession obj) + { + int result = userID.compareTo(obj.getUserID()); + if (result == 0) + { + result = Integer.valueOf(sessionID).compareTo(obj.getSessionID()); + } + + return result; + } + + @Override + public boolean equals(Object obj) + { + if (obj == this) + { + return true; + } + + if (obj instanceof CDORemoteSession) + { + CDORemoteSession that = (CDORemoteSession)obj; + return manager == that.getManager() && sessionID == that.getSessionID(); + } + + return false; + } + + @Override + public int hashCode() + { + return manager.hashCode() ^ sessionID; + } + + @Override + public String toString() + { + String repo = manager.getLocalSession().getRepositoryInfo().getName(); + String user = userID == null ? repo : userID + "@" + repo; + return MessageFormat.format("{0} ({1})", user, sessionID); //$NON-NLS-1$ + } +} |