package org.eclipse.core.internal.resources;
import org.eclipse.core.resources.IResourceStatus;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.*;
public class ResourceStatus extends Status implements IResourceStatus {
IPath path;
public ResourceStatus(int type, int code, IPath path, String message, Throwable exception) {
super(type, ResourcesPlugin.PI_RESOURCES, code, message, exception);
this.path = path;
}
public ResourceStatus(int code, String message) {
this(getSeverity(code), code, null, message, null);
}
public ResourceStatus(int code, IPath path, String message) {
this(getSeverity(code), code, path, message, null);
}
public ResourceStatus(int code, IPath path, String message, Throwable exception) {
this(getSeverity(code), code, path, message, exception);
}
@Override
public IPath getPath() {
return path;
}
protected static int getSeverity(int code) {
return code == 0 ? 0 : 1 << (code % 100 / 33);
}
private String getTypeName() {
switch (getSeverity()) {
case IStatus.OK :
return "OK";
case IStatus.ERROR :
return "ERROR";
case IStatus.INFO :
return "INFO";
case IStatus.WARNING :
return "WARNING";
default :
return String.valueOf(getSeverity());
}
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("[type: ");
sb.append(getTypeName());
sb.append("], [path: ");
sb.append(getPath());
sb.append("], [message: ");
sb.append(getMessage());
sb.append("], [plugin: ");
sb.append(getPlugin());
sb.append("], [exception: ");
sb.append(getException());
sb.append("]\n");
return sb.toString();
}
}