KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > resources > ResourceStatus


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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 /**
18  *
19  */

20 public class ResourceStatus extends Status implements IResourceStatus {
21     IPath path;
22
23     public ResourceStatus(int type, int code, IPath path, String JavaDoc message, Throwable JavaDoc exception) {
24         super(type, ResourcesPlugin.PI_RESOURCES, code, message, exception);
25         this.path = path;
26     }
27
28     public ResourceStatus(int code, String JavaDoc message) {
29         this(getSeverity(code), code, null, message, null);
30     }
31
32     public ResourceStatus(int code, IPath path, String JavaDoc message) {
33         this(getSeverity(code), code, path, message, null);
34     }
35
36     public ResourceStatus(int code, IPath path, String JavaDoc message, Throwable JavaDoc exception) {
37         this(getSeverity(code), code, path, message, exception);
38     }
39
40     /**
41      * @see IResourceStatus#getPath()
42      */

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     // for debug only
52
private String JavaDoc getTypeName() {
53         switch (getSeverity()) {
54             case IStatus.OK :
55                 return "OK"; //$NON-NLS-1$
56
case IStatus.ERROR :
57                 return "ERROR"; //$NON-NLS-1$
58
case IStatus.INFO :
59                 return "INFO"; //$NON-NLS-1$
60
case IStatus.WARNING :
61                 return "WARNING"; //$NON-NLS-1$
62
default :
63                 return String.valueOf(getSeverity());
64         }
65     }
66
67     // for debug only
68
public String JavaDoc toString() {
69         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
70         sb.append("[type: "); //$NON-NLS-1$
71
sb.append(getTypeName());
72         sb.append("], [path: "); //$NON-NLS-1$
73
sb.append(getPath());
74         sb.append("], [message: "); //$NON-NLS-1$
75
sb.append(getMessage());
76         sb.append("], [plugin: "); //$NON-NLS-1$
77
sb.append(getPlugin());
78         sb.append("], [exception: "); //$NON-NLS-1$
79
sb.append(getException());
80         sb.append("]\n"); //$NON-NLS-1$
81
return sb.toString();
82     }
83 }
84
Popular Tags