1 11 package org.eclipse.team.internal.ccvs.core.syncinfo; 12 13 import org.eclipse.core.runtime.IStatus; 14 import org.eclipse.osgi.util.NLS; 15 import org.eclipse.team.internal.ccvs.core.*; 16 import org.eclipse.team.internal.ccvs.core.util.Util; 17 18 21 public class BaserevInfo { 22 private static final String BASEREV_PREFIX = "B"; 24 private String name; 25 private String revision; 26 27 public BaserevInfo(String entryLine) throws CVSException { 28 setEntryLine(entryLine); 29 } 30 31 public BaserevInfo(String name, String revision) { 32 this.name = name; 33 this.revision = revision; 34 } 35 39 public String getEntryLine() { 40 StringBuffer result = new StringBuffer (); 41 result.append(BASEREV_PREFIX); 42 result.append(name); 43 result.append(ResourceSyncInfo.SEPARATOR); 44 result.append(revision); 45 result.append(ResourceSyncInfo.SEPARATOR); 46 return result.toString(); 47 } 48 private void setEntryLine(String entryLine) throws CVSException { 49 if(entryLine.startsWith(BASEREV_PREFIX)) { 50 entryLine = entryLine.substring(1); 51 } 52 String [] strings = Util.parseIntoSubstrings(entryLine, ResourceSyncInfo.SEPARATOR); 53 if(strings.length != 2 && strings.length != 3) { 56 IStatus status = new CVSStatus(IStatus.ERROR,NLS.bind(CVSMessages.BaseRevInfo_malformedEntryLine, new String [] { entryLine })); 57 throw new CVSException(status); 58 } 59 60 name = strings[0]; 61 62 if(name.length()==0) { 63 IStatus status = new CVSStatus(IStatus.ERROR,NLS.bind(CVSMessages.BaseRevInfo_malformedEntryLine, new String [] { entryLine })); 64 throw new CVSException(status); 65 } 66 67 revision = strings[1]; 68 69 if(revision.length()==0) { 70 IStatus status = new CVSStatus(IStatus.ERROR,NLS.bind(CVSMessages.BaseRevInfo_malformedEntryLine, new String [] { entryLine })); 71 throw new CVSException(status); 72 } 73 } 74 78 public String getName() { 79 return name; 80 } 81 82 86 public String getRevision() { 87 return revision; 88 } 89 90 } 91 | Popular Tags |