1 11 package org.eclipse.team.internal.ccvs.core.client; 12 13 import org.eclipse.core.runtime.IProgressMonitor; 14 import org.eclipse.team.internal.ccvs.core.CVSException; 15 16 public class MTHandler extends ResponseHandler { 17 18 private String nextLine; 19 private boolean isLineAvailable; 20 21 24 ResponseHandler getInstance() { 25 return new MTHandler(); 26 } 27 28 31 public String getResponseID() { 32 return "MT"; } 34 35 38 public void handle(Session session, String argument, IProgressMonitor monitor) 39 throws CVSException { 40 41 if (isLineAvailable()) { 43 startNextLine(); 44 } 45 46 if (argument.charAt(0) == '+') { 47 startNextLine(); 49 } else if (argument.charAt(0) == '-') { 50 if (nextLine != null) { 52 isLineAvailable = true; 53 } 54 } else { 55 String tag; 57 String text; 58 int spaceIndex = argument.indexOf(' '); 59 if (spaceIndex == -1) { 60 tag = argument; 61 text = null; 62 } else { 63 tag = argument.substring(0, spaceIndex); 64 text = argument.substring(spaceIndex + 1); 65 } 66 67 if (tag.equals("newline")) { isLineAvailable = true; 70 } else if (text != null) { 71 if (isLineAvailable()) { 73 startNextLine(); 74 } 75 if (nextLine == null) { 77 nextLine = text; 78 } else { 79 nextLine = nextLine + text; 81 } 82 } 83 } 84 } 85 86 90 public boolean isLineAvailable() { 91 return isLineAvailable; 92 } 93 94 97 public String getLine() { 98 return nextLine; 99 } 100 101 private void startNextLine() { 102 isLineAvailable = false; 103 nextLine = null; 104 } 105 } 106 | Popular Tags |