1 11 package org.eclipse.jdt.internal.core.dom.rewrite; 12 13 14 15 18 public class NodeRewriteEvent extends RewriteEvent { 19 20 private Object originalValue; 21 private Object newValue; 22 23 public NodeRewriteEvent(Object originalValue, Object newValue) { 24 this.originalValue= originalValue; 25 this.newValue= newValue; 26 } 27 28 31 public Object getNewValue() { 32 return this.newValue; 33 } 34 35 38 public Object getOriginalValue() { 39 return this.originalValue; 40 } 41 42 45 public int getChangeKind() { 46 if (this.originalValue == this.newValue) { 47 return UNCHANGED; 48 } 49 if (this.originalValue == null) { 50 return INSERTED; 51 } 52 if (this.newValue == null) { 53 return REMOVED; 54 } 55 if (this.originalValue.equals(this.newValue)) { 56 return UNCHANGED; 57 } 58 return REPLACED; 59 } 60 61 62 65 public boolean isListRewrite() { 66 return false; 67 } 68 69 73 public void setNewValue(Object newValue) { 74 this.newValue= newValue; 75 } 76 77 80 public RewriteEvent[] getChildren() { 81 return null; 82 } 83 84 87 public String toString() { 88 StringBuffer buf= new StringBuffer (); 89 switch (getChangeKind()) { 90 case INSERTED: 91 buf.append(" [inserted: "); buf.append(getNewValue()); 93 buf.append(']'); 94 break; 95 case REPLACED: 96 buf.append(" [replaced: "); buf.append(getOriginalValue()); 98 buf.append(" -> "); buf.append(getNewValue()); 100 buf.append(']'); 101 break; 102 case REMOVED: 103 buf.append(" [removed: "); buf.append(getOriginalValue()); 105 buf.append(']'); 106 break; 107 default: 108 buf.append(" [unchanged]"); } 110 return buf.toString(); 111 } 112 113 114 } 115 | Popular Tags |