Coverage Report - org.seasar.eclipse.common.util.StatusUtil
 
Classes in this File Line Coverage Branch Coverage Complexity
StatusUtil
0%
0/10
0%
0/6
1.167
 
 1  
 /*
 2  
  * Copyright 2004-2008 the Seasar Foundation and the Others.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 15  
  */
 16  
 package org.seasar.eclipse.common.util;
 17  
 
 18  
 import org.eclipse.core.runtime.IStatus;
 19  
 import org.eclipse.core.runtime.Plugin;
 20  
 import org.eclipse.core.runtime.Status;
 21  
 
 22  0
 public class StatusUtil {
 23  
 
 24  
     public static IStatus create(Plugin plugin, int severity, int code,
 25  
             String message, Throwable throwable) {
 26  0
         return new Status(severity, plugin.getBundle().getSymbolicName(), code,
 27  
                 message, throwable);
 28  
     }
 29  
 
 30  
     public static IStatus createError(Plugin plugin, int code,
 31  
             Throwable throwable) {
 32  0
         String message = throwable.getMessage();
 33  0
         if (message == null) {
 34  0
             message = throwable.getClass().getName();
 35  
         }
 36  0
         return create(plugin, IStatus.ERROR, code, message, throwable);
 37  
     }
 38  
 
 39  
     public static IStatus createError(Plugin plugin, int code, String message,
 40  
             Throwable throwable) {
 41  0
         return create(plugin, IStatus.ERROR, code, message, throwable);
 42  
     }
 43  
 
 44  
     public static IStatus createWarning(Plugin plugin, int code,
 45  
             String message, Throwable throwable) {
 46  0
         return create(plugin, IStatus.WARNING, code, message, throwable);
 47  
     }
 48  
 
 49  
     public static IStatus createInfo(Plugin plugin, int code, String message,
 50  
             Throwable throwable) {
 51  0
         return create(plugin, IStatus.INFO, code, message, throwable);
 52  
     }
 53  
 
 54  
     public static boolean isError(IStatus status) {
 55  0
         return status.getSeverity() == IStatus.ERROR
 56  
                 || status.getSeverity() == IStatus.WARNING;
 57  
     }
 58  
 
 59  
 }