1 11 package org.eclipse.jdt.internal.corext.refactoring; 12 13 import org.eclipse.core.runtime.Assert; 14 15 import org.eclipse.jdt.core.IType; 16 import org.eclipse.jdt.core.dom.ITypeBinding; 17 18 19 public class ExceptionInfo { 20 private final IType fType; 21 private final ITypeBinding fTypeBinding; 22 private int fKind; 23 24 public static final int OLD= 0; 25 public static final int ADDED= 1; 26 public static final int DELETED= 2; 27 28 public ExceptionInfo(IType type, int kind, ITypeBinding binding) { 29 Assert.isNotNull(type); 30 fType= type; 31 fKind= kind; 32 fTypeBinding= binding; 33 } 34 35 public static ExceptionInfo createInfoForOldException(IType type, ITypeBinding binding){ 36 return new ExceptionInfo(type, OLD, binding); 37 } 38 public static ExceptionInfo createInfoForAddedException(IType type){ 39 return new ExceptionInfo(type, ADDED, null); 40 } 41 42 public void markAsDeleted(){ 43 Assert.isTrue(! isAdded()); fKind= DELETED; 45 } 46 47 public void markAsOld(){ 48 Assert.isTrue(isDeleted()); 49 fKind= OLD; 50 } 51 52 public boolean isAdded(){ 53 return fKind == ADDED; 54 } 55 56 public boolean isDeleted(){ 57 return fKind == DELETED; 58 } 59 60 public boolean isOld(){ 61 return fKind == OLD; 62 } 63 64 public IType getType() { 65 return fType; 66 } 67 68 public int getKind() { 69 return fKind; 70 } 71 72 75 public ITypeBinding getTypeBinding() { 76 return fTypeBinding; 77 } 78 79 public String toString() { 80 StringBuffer result= new StringBuffer (); 81 switch (fKind) { 82 case OLD : result.append("OLD: "); break; case ADDED : result.append("ADDED: "); break; case DELETED : result.append("DELETED: "); break; } 86 if (fType == null) 87 result.append("null"); else 89 result.append(fType.toString()); 90 return result.toString(); 91 } 92 } 93 | Popular Tags |