1 19 20 package org.netbeans.lib.cvsclient.command.remove; 21 22 import java.io.*; 23 24 import org.netbeans.lib.cvsclient.command.*; 25 import org.netbeans.lib.cvsclient.event.*; 26 27 33 public class RemoveBuilder implements Builder { 34 private static final String UNKNOWN = ": nothing known about"; private static final String WARNING = ": warning: "; private static final String SCHEDULING = ": scheduling `"; private static final String USE_COMMIT = ": use 'cvs commit' "; private static final String DIRECTORY = ": Removing "; private static final String STILL_IN_WORKING = ": file `"; private static final String REMOVE_FIRST = "first"; private static final String UNKNOWN_FILE = "?"; 43 46 private RemoveInformation removeInformation; 47 48 52 private String fileDirectory; 53 54 57 private final EventManager eventManager; 58 59 private final RemoveCommand removeCommand; 60 61 public RemoveBuilder(EventManager eventManager, RemoveCommand removeCommand) { 62 this.eventManager = eventManager; 63 this.removeCommand = removeCommand; 64 } 65 66 public void outputDone() { 67 if (removeInformation != null) { 68 eventManager.fireCVSEvent(new FileInfoEvent(this, removeInformation)); 69 removeInformation = null; 70 } 71 } 72 73 public void parseLine(String line, boolean isErrorMessage) { 74 if (line.indexOf(SCHEDULING) >= 0) { 75 int endingIndex = line.indexOf('\''); 76 String fn = line.substring(line.indexOf(SCHEDULING) + SCHEDULING.length(), endingIndex).trim(); 77 addFile(fn); 78 removeInformation.setRemoved(true); 79 outputDone(); 80 } 81 if (line.startsWith(UNKNOWN_FILE)) { 82 addFile(line.substring(UNKNOWN_FILE.length())); 83 removeInformation.setRemoved(false); 84 outputDone(); 85 } 86 if (line.indexOf(STILL_IN_WORKING) >= 0) { 87 int endingIndex = line.indexOf('\''); 88 String fn = line.substring(line.indexOf(STILL_IN_WORKING) + STILL_IN_WORKING.length(), endingIndex).trim(); 89 addFile(fn); 90 removeInformation.setRemoved(false); 91 outputDone(); 92 } 93 } 95 96 protected File createFile(String fileName) { 97 StringBuffer path = new StringBuffer (); 98 path.append(removeCommand.getLocalDirectory()); 99 path.append(File.separator); 100 if (fileDirectory == null) { 101 File locFile = removeCommand.getFileEndingWith(fileName); 104 if (locFile == null) { 105 path.append(fileName); 106 } 107 else { 108 path = new StringBuffer (locFile.getAbsolutePath()); 109 } 110 } 111 else { 112 path.append(fileName); 115 } 116 String toReturn = path.toString(); 117 toReturn = toReturn.replace('/', File.separatorChar); 118 return new File(path.toString()); 119 } 120 121 protected void addFile(String name) { 122 removeInformation = new RemoveInformation(); 123 removeInformation.setFile(createFile(name)); 124 } 125 126 public void parseEnhancedMessage(String key, Object value) { 127 } 128 } 129 | Popular Tags |