1 19 20 package org.netbeans.lib.cvsclient.command.importcmd; 21 22 import java.io.*; 23 24 import org.netbeans.lib.cvsclient.command.*; 25 import org.netbeans.lib.cvsclient.event.*; 26 27 30 public class ImportBuilder 31 implements Builder { 32 33 private static final String NO_CONFLICTS = "No conflicts created by this import"; private static final String FILE_INFOS = "NUCIL?"; 36 private final EventManager eventManager; 37 private final String localPath; 38 private final String module; 39 40 private DefaultFileInfoContainer fileInfoContainer; 41 42 public ImportBuilder(EventManager eventManager, ImportCommand importCommand) { 43 this.eventManager = eventManager; 44 45 this.localPath = importCommand.getLocalDirectory(); 46 this.module = importCommand.getModule(); 47 } 48 49 public void outputDone() { 50 if (fileInfoContainer == null) { 51 return; 52 } 53 54 FileInfoEvent event = new FileInfoEvent(this, fileInfoContainer); 55 eventManager.fireCVSEvent(event); 56 57 fileInfoContainer = null; 58 } 59 60 public void parseLine(String line, boolean isErrorMessage) { 61 if (line.length() > 2 && line.charAt(1) == ' ') { 62 String firstChar = line.substring(0, 1); 63 if (FILE_INFOS.indexOf(firstChar) >= 0) { 64 String filename = line.substring(2).trim(); 65 processFile(firstChar, filename); 66 } 67 else { 68 error(line); 69 } 70 } 71 else if (line.startsWith(NO_CONFLICTS)) { 72 outputDone(); 73 } 74 } 75 76 public void parseEnhancedMessage(String key, Object value) { 77 } 78 79 private void error(String line) { 80 System.err.println("Don't know anything about: " + line); 81 } 82 83 private void processFile(String type, String filename) { 84 outputDone(); 85 86 filename = filename.substring(module.length()); 87 File file = new File(localPath, filename); 88 89 fileInfoContainer = new DefaultFileInfoContainer(); 90 fileInfoContainer.setType(type); 91 fileInfoContainer.setFile(file); 92 93 outputDone(); 94 } 95 } 96 | Popular Tags |