Skip to main content
summaryrefslogtreecommitdiffstats
blob: 5e322a63dfb0ea5abb9da6bbc3014835d24b8e8b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/**
 * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Eike Stepper - initial API and implementation
 */
package org.eclipse.emf.cdo.common.branch;

import org.eclipse.emf.cdo.common.CDOCommonRepository;
import org.eclipse.emf.cdo.common.CDOCommonRepository.State;
import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
import org.eclipse.emf.cdo.common.util.CDOTimeProvider;

import org.eclipse.net4j.util.container.IContainer;

/**
 * Represents a <i>stream of changes</i> that is isolated from other streams of changes.
 * <p>
 * A branch starts at a fixed {@link #getBase() base} point and ends at a floating {@link #getHead() head} point.
 * Between these two points there can be a number of other {@link CDOBranchPoint branch points}:
 * <ul>
 * <li> {@link CDOCommitInfo Commit infos} are points in a branch that represent commit operations.
 * <li> {@link CDOBranchTag Branch tags} are named points in a branch.
 * <li> {@link #getBase() Base points } of sub branches of a branch.
 * </ul>
 * 
 * @author Eike Stepper
 * @since 3.0
 * @noextend This interface is not intended to be extended by clients.
 * @noimplement This interface is not intended to be implemented by clients.
 * @apiviz.landmark
 * @apiviz.has {@link CDOBranchPoint} oneway - - base
 * @apiviz.composedOf {@link CDOBranch} - - subBranches
 */
public interface CDOBranch extends IContainer<CDOBranch>, Comparable<CDOBranch>
{
  /**
   * The fixed ID of the {@link CDOBranchManager#getMainBranch() main branch}.
   */
  public static final int MAIN_BRANCH_ID = 0;

  /**
   * The fixed name of the {@link CDOBranchManager#getMainBranch() main branch}.
   */
  public static final String MAIN_BRANCH_NAME = "MAIN"; //$NON-NLS-1$

  /**
   * The string used to separate the segments of branch paths.
   * 
   * @see #getPathName()
   * @see #getBranch(String)
   * @see CDOBranchManager#getBranch(String)
   */
  public static final String PATH_SEPARATOR = "/"; //$NON-NLS-1$

  /**
   * Returns <code>true</code> if this branch is the {@link CDOBranchManager#getMainBranch() main branch},
   * <code>false</code> otherwise.
   */
  public boolean isMainBranch();

  /**
   * Returns <code>true</code> if this branch is a local branch, <code>false</code> otherwise.
   * <p>
   * Local branches are created on the fly when committing to a
   * {@link org.eclipse.emf.cdo.common.CDOCommonRepository.Type#CLONE clone} repository while it is in
   * {@link State#OFFLINE offline} state and they do not participate in repository replication. They can not be created
   * manually and they have negative {@link #getID() IDs}.
   */
  public boolean isLocal();

  /**
   * Returns the ID of this branch.
   * <p>
   * The {@link CDOBranchManager#getMainBranch() main branch} has the fixed ID 0 (zero), {@link #isLocal() Local
   * branches} have negative IDs and normal branches have positive IDs.
   */
  public int getID();

  /**
   * Returns the name of this branch as specified when it was created with {@link #createBranch(String, long)
   * createBranch()} or {@link #MAIN_BRANCH_NAME} if this branch is the {@link CDOBranchManager#getMainBranch() main
   * branch}.
   */
  public String getName();

  /**
   * Returns the fully qualified path name of this branch, a concatenation of the names of all branches from the
   * {@link CDOBranchManager#getMainBranch() main branch} to this branch, separated by {@link #PATH_SEPARATOR slashes}
   * ("/" characters). Example: "MAIN/team1/smith".
   */
  public String getPathName();

  /**
   * Returns an array of the {@link #getBase() base} branch points starting from the base of the
   * {@link CDOBranchManager#getMainBranch() main branch} down to and including the base of this branch.
   */
  public CDOBranchPoint[] getBasePath();

  /**
   * Returns the immutable base branch point of this branch, the point in the parent branch that marks the creation of
   * this branch.
   * <p>
   * The base of the {@link CDOBranchManager#getMainBranch() main branch} marks the creation of the
   * {@link CDOCommonRepository repository}.
   * 
   * @see CDOBranch#getHead()
   * @see #getPoint(long)
   */
  public CDOBranchPoint getBase();

  /**
   * Returns the floating <i>end point</i> of this branch, a pair of this branch and the fixed special time stamp <i>
   * {@link CDOBranchPoint#UNSPECIFIED_DATE unspecified}</i>.
   * 
   * @see CDOBranch#getBase()
   * @see #getPoint(long)
   */
  public CDOBranchPoint getHead();

  /**
   * Returns the branch point in this branch with the given time stamp.
   * <p>
   * This factory method never returns <code>null</code>.
   * 
   * @see CDOBranch#getBase()
   * @see CDOBranch#getHead()
   * @see #getVersion(int)
   */
  public CDOBranchPoint getPoint(long timeStamp);

  /**
   * Returns the branch version in this branch with the given version number.
   * <p>
   * This factory method never returns <code>null</code>.
   * 
   * @see #getPoint(long)
   */
  public CDOBranchVersion getVersion(int version);

  /**
   * Returns the branch manager that manages this branch, never <code>null</code>.
   */
  public CDOBranchManager getBranchManager();

  /**
   * Returns an array of the sub branches of this branch, never <code>null</code>.
   */
  public CDOBranch[] getBranches();

  /**
   * Returns the sub branch of this branch with the given relative path, or <code>null</code> if no sub branch with this
   * path exists in this branch.
   * <p>
   * The path name is the concatenation of the names of all branches from a direct sub branch of this branch, separated
   * by {@link #PATH_SEPARATOR slashes} ("/" characters). Example: "team1/smith".
   */
  public CDOBranch getBranch(String path);

  /**
   * Creates a sub branch of this branch with the given name, {@link #getBase() based} at the {@link CDOBranchPoint
   * branch point} in this branch with the given time stamp.
   * <p>
   * 
   * @param name
   *          The name of the sub branch to be created. It must not contain the {@link #PATH_SEPARATOR path separator}
   *          character (slash).
   * @param timeStamp
   *          The time stamp in this branch that the sub branch to be created is supposed to be {@link #getBase() based
   *          at}. It must not be before the base time stamp of this branch and it must be different from the fixed
   *          special time stamp <i> {@link CDOBranchPoint#UNSPECIFIED_DATE unspecified}</i>
   * @see #createBranch(String)
   */
  public CDOBranch createBranch(String name, long timeStamp);

  /**
   * Creates a sub branch of this branch with the given name, {@link #getBase() based} at the {@link CDOTimeProvider
   * current time}.
   */
  public CDOBranch createBranch(String name);
}

Back to the top