1 19 package org.netbeans.modules.java.source.save; 20 21 29 class Difference { 30 public static final int NONE = -1; 31 32 35 private int delStart = NONE; 36 37 40 private int delEnd = NONE; 41 42 45 private int addStart = NONE; 46 47 50 private int addEnd = NONE; 51 52 56 public Difference(int delStart, int delEnd, int addStart, int addEnd) { 57 this.delStart = delStart; 58 this.delEnd = delEnd; 59 this.addStart = addStart; 60 this.addEnd = addEnd; 61 } 62 63 67 public int getDeletedStart() { 68 return delStart; 69 } 70 71 75 public int getDeletedEnd() { 76 return delEnd; 77 } 78 79 83 public int getAddedStart() { 84 return addStart; 85 } 86 87 91 public int getAddedEnd() { 92 return addEnd; 93 } 94 95 99 public void setDeleted(int line) { 100 delStart = Math.min(line, delStart); 101 delEnd = Math.max(line, delEnd); 102 } 103 104 108 public void setAdded(int line) { 109 addStart = Math.min(line, addStart); 110 addEnd = Math.max(line, addEnd); 111 } 112 113 117 public boolean equals(Object obj) { 118 if (obj instanceof Difference) { 119 Difference other = (Difference)obj; 120 121 return (delStart == other.delStart && 122 delEnd == other.delEnd && 123 addStart == other.addStart && 124 addEnd == other.addEnd); 125 } else { 126 return false; 127 } 128 } 129 130 133 public String toString() { 134 StringBuffer buf = new StringBuffer (); 135 buf.append("del: [" + delStart + ", " + delEnd + "]"); 136 buf.append(" "); 137 buf.append("add: [" + addStart + ", " + addEnd + "]"); 138 return buf.toString(); 139 } 140 141 } 142 | Popular Tags |