1 22 23 package org.aspectj.debugger.request; 24 25 import org.aspectj.debugger.base.*; 26 27 import com.sun.jdi.*; 28 import java.util.*; 29 30 38 39 public abstract class ClassAndFieldNeedingRequestAction extends RequestAction { 40 41 protected String className; 42 protected String fieldName; 43 44 public ClassAndFieldNeedingRequestAction(Debugger debugger, String className, String fieldName) { 45 super(debugger); 46 this.className = className; 47 this.fieldName = fieldName; 48 } 49 50 protected Field getField() throws NoVMException, DebuggerException { 51 try { 52 return getReferenceType().fieldByName(fieldName); 53 } catch (ClassNotPreparedException cnpe) { 54 throw new DebuggerException(cnpe); 55 } 56 } 57 58 protected ReferenceType getReferenceType() throws NoVMException, DebuggerException { 59 List refTypes = vm().classesByName(className); 60 if (refTypes.size() == 0) { 61 throw new InvalidClassException(className); 62 } else if (refTypes.size() > 1) { 63 throw new AmbiguousClassException(className, refTypes); 64 } 65 return (ReferenceType) refTypes.get(0); 66 } 67 68 public String getClassName() { 69 return className; 70 } 71 72 public String getFieldName() { 73 return fieldName; 74 } 75 76 public boolean equals(Object other) { 77 if (other == null || !(other instanceof ClassAndFieldNeedingRequestAction)) { 78 return super.equals(other); 79 } 80 ClassAndFieldNeedingRequestAction ra = (ClassAndFieldNeedingRequestAction) other; 81 return (getClassName().equals(ra.getClassName()) 82 && getFieldName().equals(ra.getFieldName())); 83 } 84 85 public String toString() { 86 return getClassName() + "." + getFieldName(); 87 } 88 } 89 | Popular Tags |