KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > internal > runtime > Policy


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.runtime;
12
13 import java.util.Date JavaDoc;
14 import org.eclipse.core.runtime.*;
15
16 public class Policy {
17
18     public static IProgressMonitor monitorFor(IProgressMonitor monitor) {
19         if (monitor == null)
20             return new NullProgressMonitor();
21         return monitor;
22     }
23
24     public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks) {
25         if (monitor == null)
26             return new NullProgressMonitor();
27         if (monitor instanceof NullProgressMonitor)
28             return monitor;
29         return new SubProgressMonitor(monitor, ticks);
30     }
31
32     public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks, int style) {
33         if (monitor == null)
34             return new NullProgressMonitor();
35         if (monitor instanceof NullProgressMonitor)
36             return monitor;
37         return new SubProgressMonitor(monitor, ticks, style);
38     }
39
40     /**
41      * Print a debug message to the console.
42      * Pre-pend the message with the current date and the name of the current thread.
43      */

44     public static void debug(String JavaDoc message) {
45         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
46         buffer.append(new Date JavaDoc(System.currentTimeMillis()));
47         buffer.append(" - ["); //$NON-NLS-1$
48
buffer.append(Thread.currentThread().getName());
49         buffer.append("] "); //$NON-NLS-1$
50
buffer.append(message);
51         System.out.println(buffer.toString());
52     }
53 }
54
Popular Tags