1 19 20 package org.netbeans.lib.cvsclient.command.export; 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 ExportBuilder implements Builder { 31 32 private static final String FILE_INFOS = "MUARC?"; 34 private final EventManager eventManager; 35 private final String localPath; 36 37 private DefaultFileInfoContainer fileInfoContainer; 38 39 public ExportBuilder(EventManager eventManager, ExportCommand exportCommand) { 40 this.eventManager = eventManager; 41 42 this.localPath = exportCommand.getLocalDirectory(); 43 } 44 45 public void outputDone() { 46 if (fileInfoContainer == null) { 47 return; 48 } 49 50 FileInfoEvent event = new FileInfoEvent(this, fileInfoContainer); 51 eventManager.fireCVSEvent(event); 52 53 fileInfoContainer = null; 54 } 55 56 public void parseLine(String line, boolean isErrorMessage) { 57 if (line.length() > 2 && line.charAt(1) == ' ') { 58 String firstChar = line.substring(0, 1); 59 if (FILE_INFOS.indexOf(firstChar) >= 0) { 60 String filename = line.substring(2).trim(); 61 processFile(firstChar, filename); 62 } 63 else { 64 error(line); 65 } 66 } 67 } 68 69 public void parseEnhancedMessage(String key, Object value) { 70 } 71 72 private void error(String line) { 73 System.err.println("Don't know anything about: " + line); 74 } 75 76 private void processFile(String type, String filename) { 77 outputDone(); 78 79 File file = new File(localPath, filename); 80 81 fileInfoContainer = new DefaultFileInfoContainer(); 82 fileInfoContainer.setType(type); 83 fileInfoContainer.setFile(file); 84 85 outputDone(); 86 } 87 } 88 | Popular Tags |