1 11 12 package org.eclipse.jdt.internal.junit.util; 13 14 import org.eclipse.core.runtime.Assert; 15 import org.eclipse.core.runtime.IStatus; 16 import org.eclipse.jdt.internal.junit.ui.JUnitPlugin; 17 18 22 public class JUnitStatus implements IStatus { 23 private String fStatusMessage; 24 private int fSeverity; 25 26 29 public JUnitStatus() { 30 this(OK, null); 31 } 32 33 39 public JUnitStatus(int severity, String message) { 40 fStatusMessage= message; 41 fSeverity= severity; 42 } 43 44 public static IStatus createError(String message) { 45 return new JUnitStatus(IStatus.ERROR, message); 46 } 47 48 public static IStatus createWarning(String message) { 49 return new JUnitStatus(IStatus.WARNING, message); 50 } 51 52 public static IStatus createInfo(String message) { 53 return new JUnitStatus(IStatus.INFO, message); 54 } 55 56 59 public boolean isOK() { 60 return fSeverity == IStatus.OK; 61 } 62 63 66 public boolean isWarning() { 67 return fSeverity == IStatus.WARNING; 68 } 69 70 73 public boolean isInfo() { 74 return fSeverity == IStatus.INFO; 75 } 76 77 80 public boolean isError() { 81 return fSeverity == IStatus.ERROR; 82 } 83 84 87 public String getMessage() { 88 return fStatusMessage; 89 } 90 91 95 public void setError(String errorMessage) { 96 Assert.isNotNull(errorMessage); 97 fStatusMessage= errorMessage; 98 fSeverity= IStatus.ERROR; 99 } 100 101 105 public void setWarning(String warningMessage) { 106 Assert.isNotNull(warningMessage); 107 fStatusMessage= warningMessage; 108 fSeverity= IStatus.WARNING; 109 } 110 111 115 public void setInfo(String infoMessage) { 116 Assert.isNotNull(infoMessage); 117 fStatusMessage= infoMessage; 118 fSeverity= IStatus.INFO; 119 } 120 121 124 public void setOK() { 125 fStatusMessage= null; 126 fSeverity= IStatus.OK; 127 } 128 129 132 public boolean matches(int severityMask) { 133 return (fSeverity & severityMask) != 0; 134 } 135 136 140 public boolean isMultiStatus() { 141 return false; 142 } 143 144 147 public int getSeverity() { 148 return fSeverity; 149 } 150 151 154 public String getPlugin() { 155 return JUnitPlugin.PLUGIN_ID; 156 } 157 158 162 public Throwable getException() { 163 return null; 164 } 165 166 170 public int getCode() { 171 return fSeverity; 172 } 173 174 178 public IStatus[] getChildren() { 179 return new IStatus[0]; 180 } 181 182 } 183 | Popular Tags |