CharsetMXBeanImpl.java

package com.ziesemer.utils.jmx.mBeans;

import java.nio.charset.Charset;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

/**
 * @author Mark A. Ziesemer
 * 	<a href="http://www.ziesemer.com.">&lt;www.ziesemer.com&gt;</a>
 */
public class CharsetMXBeanImpl implements CharsetMXBean{
	
	public SortedMap<String, CharsetWrapper> getAvailableCharsets(){
		final TreeMap<String, CharsetWrapper> m = new TreeMap<String, CharsetWrapper>();
		for(final Map.Entry<String, Charset> e : Charset.availableCharsets().entrySet()){
			m.put(e.getKey(), new CharsetWrapper(e.getValue()));
		}
		return m;
	}
	
	public CharsetWrapper getDefaultCharset(){
		return new CharsetWrapper(Charset.defaultCharset());
	}
		
	public CharsetWrapper forName(final String charsetName){
		return new CharsetWrapper(Charset.forName(charsetName));
	}
	
	public boolean isSupported(final String charsetName){
		return Charset.isSupported(charsetName);
	}
	
}