1 22 package org.netbeans.lib.cvsclient.event; 23 24 29 public class MessageEvent extends CVSEvent { 30 33 private String message; 34 35 38 private boolean error; 39 40 41 private boolean tagged; 42 43 private final byte[] raw; 44 45 46 public MessageEvent(Object source, String message, byte[] raw, boolean isError) { 47 super(source); 48 setMessage(message); 49 setError(isError); 50 setTagged(false); 51 this.raw = raw; 52 } 53 54 61 public MessageEvent(Object source, String message, boolean isError) { 62 this(source, message, null, isError); 63 } 64 65 69 public MessageEvent(Object source) { 70 this(source, null, false); 71 } 72 73 77 public String getMessage() { 78 return message; 79 } 80 81 82 public byte[] getRawData() { 83 return raw; 84 } 85 86 90 public void setMessage(String message) { 91 this.message = message; 92 } 93 94 98 public boolean isError() { 99 return error; 100 } 101 102 106 public void setError(boolean error) { 107 this.error = error; 108 } 109 110 115 protected void fireEvent(CVSListener listener) { 116 listener.messageSent(this); 117 } 118 119 122 public boolean isTagged() { 123 return tagged; 124 } 125 126 129 public void setTagged(boolean tagged) { 130 this.tagged = tagged; 131 } 132 133 137 public static String parseTaggedMessage(StringBuffer taggedLineBufferNotNull, String taggedMessage) { 138 String line = taggedMessage; 139 140 if (line.charAt(0) == '+' || line.charAt(0) == '-') { 141 return null; 142 } 143 144 String result = null; 145 if (line.equals("newline")) { result = taggedLineBufferNotNull.toString(); 147 taggedLineBufferNotNull.setLength(0); 148 } 149 int index = line.indexOf(' '); 150 if (index > 0) { 151 taggedLineBufferNotNull.append(line.substring(index + 1)); 152 } 153 return result; 154 } 155 } | Popular Tags |