View Javadoc
1   package org.csveed.bean.conversion;
2   
3   import java.nio.charset.Charset;
4   
5   public class CharsetConverter extends AbstractConverter<Charset> {
6   
7       public CharsetConverter() {
8           super(Charset.class);
9       }
10  
11      @Override
12      public Charset fromString(String text) throws Exception {
13          if (text != null && !text.isEmpty()) {
14              return Charset.forName(text);
15          }
16          return null;
17      }
18  
19      @Override
20      public String toString(Charset value) throws Exception {
21          return value != null ? value.name() : "";
22      }
23  
24  }