1 11 package org.eclipse.core.internal.dtree; 12 13 16 public final class NodeComparison { 17 20 private Object oldData; 21 22 25 private Object newData; 26 27 30 private int comparison; 31 32 35 private int userInt; 36 37 40 public final static int K_ADDED = 1; 41 public final static int K_REMOVED = 2; 42 public final static int K_CHANGED = 4; 43 44 NodeComparison(Object oldData, Object newData, int realComparison, int userComparison) { 45 this.oldData = oldData; 46 this.newData = newData; 47 this.comparison = realComparison; 48 this.userInt = userComparison; 49 } 50 51 54 NodeComparison asReverseComparison(IComparator comparator) { 55 56 Object tempData = oldData; 57 oldData = newData; 58 newData = tempData; 59 60 61 userInt = comparator.compare(oldData, newData); 62 63 if (comparison == K_ADDED) { 64 comparison = K_REMOVED; 65 } else { 66 if (comparison == K_REMOVED) { 67 comparison = K_ADDED; 68 } 69 } 70 return this; 71 } 72 73 78 public int getComparison() { 79 return comparison; 80 } 81 82 85 public Object getNewData() { 86 return newData; 87 } 88 89 92 public Object getOldData() { 93 return oldData; 94 } 95 96 99 public int getUserComparison() { 100 return userInt; 101 } 102 103 106 boolean isUnchanged() { 107 return userInt == 0; 108 } 109 110 113 public String toString() { 114 StringBuffer buf = new StringBuffer ("NodeComparison("); switch (comparison) { 116 case K_ADDED : 117 buf.append("Added, "); break; 119 case K_REMOVED : 120 buf.append("Removed, "); break; 122 case K_CHANGED : 123 buf.append("Changed, "); break; 125 case 0 : 126 buf.append("No change, "); break; 128 default : 129 buf.append("Corrupt(" + comparison + "), "); } 131 buf.append(userInt); 132 buf.append(")"); return buf.toString(); 134 } 135 } 136 | Popular Tags |