1 11 package org.eclipse.jdt.internal.core; 12 13 import org.eclipse.jdt.core.IJavaElementDelta; 14 15 18 public class SimpleDelta { 19 20 23 protected int kind = 0; 24 25 28 protected int changeFlags = 0; 29 30 33 public void added() { 34 this.kind = IJavaElementDelta.ADDED; 35 } 36 37 40 public void changed(int flags) { 41 this.kind = IJavaElementDelta.CHANGED; 42 this.changeFlags |= flags; 43 } 44 45 48 public int getFlags() { 49 return this.changeFlags; 50 } 51 52 55 public int getKind() { 56 return this.kind; 57 } 58 59 62 public void modifiers() { 63 changed(IJavaElementDelta.F_MODIFIERS); 64 } 65 66 69 public void removed() { 70 this.kind = IJavaElementDelta.REMOVED; 71 this.changeFlags = 0; 72 } 73 74 77 public void superTypes() { 78 changed(IJavaElementDelta.F_SUPER_TYPES); 79 } 80 81 protected void toDebugString(StringBuffer buffer) { 82 buffer.append("["); switch (getKind()) { 84 case IJavaElementDelta.ADDED : 85 buffer.append('+'); 86 break; 87 case IJavaElementDelta.REMOVED : 88 buffer.append('-'); 89 break; 90 case IJavaElementDelta.CHANGED : 91 buffer.append('*'); 92 break; 93 default : 94 buffer.append('?'); 95 break; 96 } 97 buffer.append("]: {"); toDebugString(buffer, getFlags()); 99 buffer.append("}"); } 101 102 protected boolean toDebugString(StringBuffer buffer, int flags) { 103 boolean prev = false; 104 if ((flags & IJavaElementDelta.F_MODIFIERS) != 0) { 105 if (prev) 106 buffer.append(" | "); buffer.append("MODIFIERS CHANGED"); prev = true; 109 } 110 if ((flags & IJavaElementDelta.F_SUPER_TYPES) != 0) { 111 if (prev) 112 buffer.append(" | "); buffer.append("SUPER TYPES CHANGED"); prev = true; 115 } 116 return prev; 117 } 118 119 public String toString() { 120 StringBuffer buffer = new StringBuffer (); 121 toDebugString(buffer); 122 return buffer.toString(); 123 } 124 } 125 | Popular Tags |