1 11 package org.eclipse.jdt.internal.debug.eval; 12 13 14 import java.util.ArrayList ; 15 import java.util.Iterator ; 16 import java.util.List ; 17 18 import org.eclipse.debug.core.DebugException; 19 import org.eclipse.jdt.core.dom.Message; 20 import org.eclipse.jdt.debug.core.IJavaThread; 21 import org.eclipse.jdt.debug.core.IJavaValue; 22 import org.eclipse.jdt.debug.eval.IEvaluationEngine; 23 import org.eclipse.jdt.debug.eval.IEvaluationResult; 24 25 30 public class EvaluationResult implements IEvaluationResult { 31 32 35 private IJavaValue fValue; 36 37 41 private IJavaThread fThread; 42 43 46 private IEvaluationEngine fEngine; 47 48 51 private String fSnippet; 52 53 57 private DebugException fException; 58 59 62 private List fErrors; 63 64 68 public EvaluationResult(IEvaluationEngine engine, String snippet, IJavaThread thread) { 69 setEvaluationEngine(engine); 70 setThread(thread); 71 setSnippet(snippet); 72 fErrors= new ArrayList (); 73 } 74 75 78 public IJavaValue getValue() { 79 return fValue; 80 } 81 82 89 public void setValue(IJavaValue value) { 90 fValue = value; 91 } 92 93 96 public boolean hasErrors() { 97 return getErrors().length > 0 || getException() != null; 98 } 99 100 104 public Message[] getErrors() { 105 Message[] messages= new Message[fErrors.size()]; 106 int i= 0; 107 for (Iterator iter= fErrors.iterator(); iter.hasNext();) { 108 messages[i++]= new Message((String ) iter.next(), -1); 109 } 110 return messages; 111 } 112 113 116 public String [] getErrorMessages() { 117 return (String [])fErrors.toArray(new String [fErrors.size()]); 118 } 119 120 123 public String getSnippet() { 124 return fSnippet; 125 } 126 127 132 private void setSnippet(String snippet) { 133 fSnippet = snippet; 134 } 135 136 139 public DebugException getException() { 140 return fException; 141 } 142 143 149 public void setException(DebugException e) { 150 fException = e; 151 } 152 153 156 public IJavaThread getThread() { 157 return fThread; 158 } 159 160 167 private void setThread(IJavaThread thread) { 168 fThread= thread; 169 } 170 171 174 public IEvaluationEngine getEvaluationEngine() { 175 return fEngine; 176 } 177 178 183 private void setEvaluationEngine(IEvaluationEngine engine) { 184 fEngine = engine; 185 } 186 187 190 public void addError(String message) { 191 fErrors.add(message); 192 } 193 } 194 195 | Popular Tags |