Coverage Report - org.mule.util.CharSetUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
CharSetUtils
0%
0/9
0%
0/2
6
 
 1  
 /*
 2  
  * $Id: CharSetUtils.java 20320 2010-11-24 15:03:31Z dfeist $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.util;
 12  
 
 13  
 import java.io.ByteArrayOutputStream;
 14  
 import java.io.OutputStreamWriter;
 15  
 import java.lang.reflect.Method;
 16  
 import java.nio.charset.Charset;
 17  
 
 18  0
 public class CharSetUtils extends org.apache.commons.lang.CharSetUtils
 19  
 {
 20  
     public static String defaultCharsetName()
 21  
     {
 22  
         try
 23  
         {
 24  0
             if (SystemUtils.IS_JAVA_1_4)
 25  
             {
 26  0
                 return new OutputStreamWriter(new ByteArrayOutputStream()).getEncoding();
 27  
             }
 28  
             else
 29  
             {
 30  0
                 Class target = Charset.class;
 31  0
                 Method defaultCharset = target.getMethod("defaultCharset", ArrayUtils.EMPTY_CLASS_ARRAY);
 32  0
                 Charset cs = (Charset) defaultCharset.invoke(target, (Object[]) null);
 33  0
                 return cs.name();
 34  
             }
 35  
         }
 36  0
         catch (Exception ex)
 37  
         {
 38  0
             throw new Error(ex);
 39  
         }
 40  
     }
 41  
 }
 42  
 
 43