KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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.jsch.internal.core;
12
13 import org.eclipse.core.runtime.*;
14
15 public class Policy{
16
17   public static void checkCanceled(IProgressMonitor monitor){
18     if(monitor.isCanceled())
19       throw new OperationCanceledException();
20   }
21
22   public static IProgressMonitor monitorFor(IProgressMonitor monitor){
23     if(monitor==null)
24       return new NullProgressMonitor();
25     return monitor;
26   }
27
28   public static IProgressMonitor subMonitorFor(IProgressMonitor monitor,
29       int ticks){
30     if(monitor==null)
31       return new NullProgressMonitor();
32     if(monitor instanceof NullProgressMonitor)
33       return monitor;
34     return new SubProgressMonitor(monitor, ticks);
35   }
36   
37 }
38
Popular Tags