1 19 20 package org.netbeans.api.diff; 21 22 import java.io.Serializable ; 23 24 29 public class Difference extends Object implements Serializable { 30 31 32 public static final int DELETE = 0; 33 34 35 public static final int ADD = 1; 36 37 38 public static final int CHANGE = 2; 39 40 private int type = 0; 41 private int firstStart = 0; 42 private int firstEnd = 0; 43 private int secondStart = 0; 44 private int secondEnd = 0; 45 private Difference.Part[] firstLineDiffs; 46 private Difference.Part[] secondLineDiffs; 47 48 49 private String firstText; 50 51 private String secondText; 52 53 private static final long serialVersionUID = 7638201981188907148L; 54 55 64 public Difference(int type, int firstStart, int firstEnd, int secondStart, int secondEnd) { 65 this(type, firstStart, firstEnd, secondStart, secondEnd, null, null, null, null); 66 } 67 68 79 public Difference(int type, int firstStart, int firstEnd, int secondStart, int secondEnd, 80 String firstText, String secondText) { 81 this(type, firstStart, firstEnd, secondStart, secondEnd, firstText, secondText, null, null); 82 } 83 84 101 public Difference(int type, int firstStart, int firstEnd, int secondStart, int secondEnd, 102 String firstText, String secondText, Difference.Part[] firstLineDiffs, Difference.Part[] secondLineDiffs) { 103 if (type > 2 || type < 0) { 104 throw new IllegalArgumentException ("Bad Difference type = "+type); 105 } 106 this.type = type; 107 this.firstStart = firstStart; 108 this.firstEnd = firstEnd; 109 this.secondStart = secondStart; 110 this.secondEnd = secondEnd; 111 this.firstText = firstText; 112 this.secondText = secondText; 113 this.firstLineDiffs = firstLineDiffs; 114 this.secondLineDiffs = secondLineDiffs; 115 } 116 117 122 public int getType() { 123 return this.type; 124 } 125 126 132 public int getFirstStart() { 133 return this.firstStart; 134 } 135 136 141 public int getFirstEnd() { 142 return this.firstEnd; 143 } 144 145 148 public int getSecondStart() { 149 return this.secondStart; 150 } 151 152 157 public int getSecondEnd() { 158 return this.secondEnd; 159 } 160 161 166 public Difference.Part[] getFirstLineDiffs() { 167 return firstLineDiffs; 168 } 169 170 175 public Difference.Part[] getSecondLineDiffs() { 176 return secondLineDiffs; 177 } 178 179 182 public String getFirstText() { 183 return firstText; 184 } 185 186 189 public String getSecondText() { 190 return secondText; 191 } 192 193 public String toString() { 194 return "Difference("+((type == ADD) ? "ADD" : (type == DELETE) ? "DELETE" : "CHANGE")+", "+ 195 firstStart+", "+firstEnd+", "+secondStart+", "+secondEnd+")"; 196 } 197 198 201 public static final class Part extends Object implements Serializable { 202 203 private int type; 204 private int line; 205 private int pos1; 206 private int pos2; 207 private String text; 208 209 private static final long serialVersionUID = 7638201981188907149L; 210 211 219 public Part(int type, int line, int pos1, int pos2) { 220 if (type > 2 || type < 0) { 221 throw new IllegalArgumentException ("Bad Difference type = "+type); 222 } 223 this.type = type; 224 this.line = line; 225 this.pos1 = pos1; 226 this.pos2 = pos2; 227 } 228 229 233 public int getType() { 234 return this.type; 235 } 236 237 240 public int getLine() { 241 return this.line; 242 } 243 244 247 public int getStartPosition() { 248 return this.pos1; 249 } 250 251 254 public int getEndPosition() { 255 return this.pos2; 256 } 257 258 272 273 } 274 275 } 276 | Popular Tags |