1 11 package org.eclipse.core.internal.resources; 12 13 import org.eclipse.core.resources.IResourceStatus; 14 import org.eclipse.core.resources.ResourcesPlugin; 15 import org.eclipse.core.runtime.*; 16 17 20 public class ResourceStatus extends Status implements IResourceStatus { 21 IPath path; 22 23 public ResourceStatus(int type, int code, IPath path, String message, Throwable exception) { 24 super(type, ResourcesPlugin.PI_RESOURCES, code, message, exception); 25 this.path = path; 26 } 27 28 public ResourceStatus(int code, String message) { 29 this(getSeverity(code), code, null, message, null); 30 } 31 32 public ResourceStatus(int code, IPath path, String message) { 33 this(getSeverity(code), code, path, message, null); 34 } 35 36 public ResourceStatus(int code, IPath path, String message, Throwable exception) { 37 this(getSeverity(code), code, path, message, exception); 38 } 39 40 43 public IPath getPath() { 44 return path; 45 } 46 47 protected static int getSeverity(int code) { 48 return code == 0 ? 0 : 1 << (code % 100 / 33); 49 } 50 51 private String getTypeName() { 53 switch (getSeverity()) { 54 case IStatus.OK : 55 return "OK"; case IStatus.ERROR : 57 return "ERROR"; case IStatus.INFO : 59 return "INFO"; case IStatus.WARNING : 61 return "WARNING"; default : 63 return String.valueOf(getSeverity()); 64 } 65 } 66 67 public String toString() { 69 StringBuffer sb = new StringBuffer (); 70 sb.append("[type: "); sb.append(getTypeName()); 72 sb.append("], [path: "); sb.append(getPath()); 74 sb.append("], [message: "); sb.append(getMessage()); 76 sb.append("], [plugin: "); sb.append(getPlugin()); 78 sb.append("], [exception: "); sb.append(getException()); 80 sb.append("]\n"); return sb.toString(); 82 } 83 } 84 | Popular Tags |