1 11 package org.eclipse.jdt.internal.debug.core.model; 12 13 14 import com.ibm.icu.text.MessageFormat; 15 16 import org.eclipse.debug.core.DebugException; 17 18 import com.sun.jdi.ObjectReference; 19 import com.sun.jdi.ReferenceType; 20 import com.sun.jdi.Type; 21 import com.sun.jdi.Value; 22 23 24 27 28 public class JDIThisVariable extends JDIVariable { 29 32 private ObjectReference fObject; 33 34 37 public JDIThisVariable(JDIDebugTarget target, ObjectReference object) { 38 super(target); 39 fObject= object; 40 } 41 42 45 protected Value retrieveValue() { 46 return fObject; 47 } 48 49 52 public String getName() { 53 return "this"; } 55 56 59 public String getSignature() throws DebugException { 60 try { 61 return retrieveValue().type().signature(); 62 } catch (RuntimeException e) { 63 targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIThisVariableexception_retrieving_type_signature, new String [] {e.toString()}), e); 64 return null; 67 } 68 } 69 70 73 public String getGenericSignature() throws DebugException { 74 return getSignature(); 75 } 76 77 80 public String getReferenceTypeName() throws DebugException { 81 try { 82 return getValue().getReferenceTypeName(); 83 } catch (RuntimeException e) { 84 targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIThisVariableexception_retrieving_reference_type_name, new String [] {e.toString()}), e); 85 return null; 88 } 89 } 90 91 94 protected Type getUnderlyingType() throws DebugException { 95 try { 96 return retrieveValue().type(); 97 } catch (RuntimeException e) { 98 targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIThisVariable_exception_while_retrieving_type_this, new String []{e.toString()}), e); 99 } 100 return null; 103 } 104 105 108 public boolean isPrivate() throws DebugException { 109 try { 110 return ((ReferenceType)getUnderlyingType()).isPrivate(); 111 } catch (RuntimeException e) { 112 targetRequestFailed(JDIDebugModelMessages.JDIThisVariable_Exception_occurred_while_retrieving_modifiers__1, e); 113 } 114 return false; 117 } 118 119 122 public boolean isProtected() throws DebugException { 123 try { 124 return ((ReferenceType)getUnderlyingType()).isProtected(); 125 } catch (RuntimeException e) { 126 targetRequestFailed(JDIDebugModelMessages.JDIThisVariable_Exception_occurred_while_retrieving_modifiers__1, e); 127 } 128 return false; 131 } 132 133 136 public boolean isPublic() throws DebugException { 137 try { 138 return ((ReferenceType)getUnderlyingType()).isPublic(); 139 } catch (RuntimeException e) { 140 targetRequestFailed(JDIDebugModelMessages.JDIThisVariable_Exception_occurred_while_retrieving_modifiers__1, e); 141 } 142 return false; 145 } 146 147 150 public boolean equals(Object o) { 151 if (o instanceof JDIThisVariable) { 152 return ((JDIThisVariable)o).fObject.equals(fObject); 153 } 154 return false; 155 } 156 157 160 public int hashCode() { 161 return fObject.hashCode(); 162 } 163 164 } 165 | Popular Tags |