<commit_before>package com.thoughtworks.xstream.converters.extended;

import com.thoughtworks.xstream.converters.ConversionException;
import com.thoughtworks.xstream.converters.basic.AbstractBasicConverter;

/**
 * Converts a java.lang.Class to XML.
 * 
 * @author <NAME>&oslash;y
 * @author <NAME>
 * @author <NAME>
 */
public class JavaClassConverter extends AbstractBasicConverter {

    private ClassLoader classLoader;

    public JavaClassConverter() {
        this(Thread.currentThread().getContextClassLoader());
    }

    public JavaClassConverter(ClassLoader classLoader) {
        this.classLoader = classLoader;
    }

    public boolean canConvert(Class clazz) {
        return Class.class.equals(clazz); // :)
    }

    protected String toString(Object obj) {
        return ((Class) obj).getName();
    }

    protected Object fromString(String str) {
        try {
            return
                    str.equals("byte") ? byte.class :
                    str.equals("int") ? int.class :
                    str.equals("long") ? long.class :
                    str.equals("float") ? float.class :
                    str.equals("boolean") ? boolean.class :<commit_msg>XSTR-89: JavaClassConverter can now serialize void<commit_after>package com.thoughtworks.xstream.converters.extended;

import com.thoughtworks.xstream.converters.ConversionException;
import com.thoughtworks.xstream.converters.basic.AbstractBasicConverter;

/**
 * Converts a java.lang.Class to XML.
 * 
 * @author <NAME>&oslash;y
 * @author <NAME>
 * @author <NAME>
 */
public class JavaClassConverter extends AbstractBasicConverter {

    private ClassLoader classLoader;

    public JavaClassConverter() {
        this(Thread.currentThread().getContextClassLoader());
    }

    public JavaClassConverter(ClassLoader classLoader) {
        this.classLoader = classLoader;
    }

    public boolean canConvert(Class clazz) {
        return Class.class.equals(clazz); // :)
    }

    protected String toString(Object obj) {
        return ((Class) obj).getName();
    }

    protected Object fromString(String str) {
        try {
            return
                    str.equals("void") ? void.class :
                    str.equals("byte") ? byte.class :
                    str.equals("int") ? int.class :
                    str.equals("long") ? long.class :
                    str.equals("float") ? float.class :
                    str.equals("boolean") ? boolean.class :
{'fraction_non_alphanumeric': 0.11259619279060348, 'fraction_numerical': 0.0008100445524503848, 'mean_word_length': 2.5135135135135136, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7664354', 'n_tokens_mistral': 684, 'n_tokens_neox': 651, 'n_words': 131}