blob: 169ffd22517ede5250bdec3ac8f26dc989fa73d8 (
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
|
/*******************************************************************************
* Copyright (c) 2000, 2007 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.team.internal.ccvs.core.syncinfo;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.internal.ccvs.core.*;
import org.eclipse.team.internal.ccvs.core.util.Util;
/**
* This class represents the information in the CVS/Baserev file
*/
public class BaserevInfo {
private static final String BASEREV_PREFIX = "B"; //$NON-NLS-1$
private String name;
private String revision;
public BaserevInfo(String entryLine) throws CVSException {
setEntryLine(entryLine);
}
public BaserevInfo(String name, String revision) {
this.name = name;
this.revision = revision;
}
/**
* Return the entry line as it appears in the CVS/Baserev file
* @return String
*/
public String getEntryLine() {
StringBuilder result = new StringBuilder();
result.append(BASEREV_PREFIX);
result.append(name);
result.append(ResourceSyncInfo.SEPARATOR);
result.append(revision);
result.append(ResourceSyncInfo.SEPARATOR);
return result.toString();
}
private void setEntryLine(String entryLine) throws CVSException {
if(entryLine.startsWith(BASEREV_PREFIX)) {
entryLine = entryLine.substring(1);
}
String[] strings = Util.parseIntoSubstrings(entryLine, ResourceSyncInfo.SEPARATOR);
// Accept either a length of 2 or 3. If the length is 3, we ignore the last
// string as per the CVS spec.
if(strings.length != 2 && strings.length != 3) {
IStatus status = new CVSStatus(IStatus.ERROR,NLS.bind(CVSMessages.BaseRevInfo_malformedEntryLine, new String[] { entryLine }));
throw new CVSException(status);
}
name = strings[0];
if(name.length()==0) {
IStatus status = new CVSStatus(IStatus.ERROR,NLS.bind(CVSMessages.BaseRevInfo_malformedEntryLine, new String[] { entryLine }));
throw new CVSException(status);
}
revision = strings[1];
if(revision.length()==0) {
IStatus status = new CVSStatus(IStatus.ERROR,NLS.bind(CVSMessages.BaseRevInfo_malformedEntryLine, new String[] { entryLine }));
throw new CVSException(status);
}
}
/**
* Returns the name.
* @return String
*/
public String getName() {
return name;
}
/**
* Returns the revision.
* @return String
*/
public String getRevision() {
return revision;
}
}
|