Coverage Report - javax.faces.internal.ConvertUtil
 
Classes in this File Line Coverage Branch Coverage Complexity
ConvertUtil
56%
9/16
70%
7/10
1.222
 
 1  
 /*
 2  
  * Copyright 2004-2011 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 javax.faces.internal;
 17  
 
 18  
 import javax.faces.application.FacesMessage;
 19  
 import javax.faces.component.UIComponent;
 20  
 import javax.faces.context.FacesContext;
 21  
 import javax.faces.convert.Converter;
 22  
 import javax.faces.convert.ConverterException;
 23  
 
 24  
 /**
 25  
  * @author shot
 26  
  *
 27  
  * This class might be changed without notice. Please do not use it
 28  
  * excluding the JSF specification part.
 29  
  */
 30  0
 public class ConvertUtil {
 31  
 
 32  
     public static ConverterException wrappedByConverterException() {
 33  0
         return new ConverterException();
 34  
     }
 35  
 
 36  
     public static ConverterException wrappedByConverterException(String message) {
 37  0
         return new ConverterException(message);
 38  
     }
 39  
 
 40  
     public static ConverterException wrappedByConverterException(Throwable t) {
 41  0
         return wrappedByConverterException(null, t);
 42  
     }
 43  
 
 44  
     public static ConverterException wrappedByConverterException(
 45  
             String message, Throwable t) {
 46  0
         return new ConverterException(message, t);
 47  
     }
 48  
 
 49  
     /**
 50  
      * @deprecated
 51  
      */
 52  
     public static ConverterException wrappedByConverterException(
 53  
             Converter converter, FacesContext context, Object[] args) {
 54  0
         return wrappedByConverterException(converter, context, args, null);
 55  
     }
 56  
 
 57  
     /**
 58  
      * @deprecated
 59  
      */
 60  
     public static ConverterException wrappedByConverterException(
 61  
             Converter converter, FacesContext context, Object[] args,
 62  
             Throwable t) {
 63  2
         FacesMessage facesMessage = null;
 64  4
         for (Class c = converter.getClass(); c != null && c != Object.class; c = c
 65  
                 .getSuperclass()) {
 66  3
             String conversionMessage = createConversionMessage(c);
 67  3
             facesMessage = FacesMessageUtil.getMessage(context,
 68  
                     conversionMessage, args);
 69  3
             if (facesMessage.getSummary() != null
 70  
                     || facesMessage.getDetail() != null) {
 71  0
                 break;
 72  
             }
 73  
         }
 74  2
         return new ConverterException(facesMessage, t);
 75  
     }
 76  
 
 77  
     public static String createConversionMessage(Class c) {
 78  3
         return c.getName() + ".CONVERSION";
 79  
     }
 80  
 
 81  
     public static String createConversionMessage(Converter converter) {
 82  1
         return converter.getClass().getName() + ".CONVERSION";
 83  
     }
 84  
 
 85  
     public static Object[] createExceptionMessageArgs(UIComponent component,
 86  
             Object value) {
 87  39
         return new Object[] { UIComponentUtil.getLabel(component), value };
 88  
     }
 89  
 }