<commit_before>/**
 * Copyright (c) 2009 - 2011 AppWork UG(haftungsbeschränkt) <<EMAIL>>
 * 
 * This file is part of org.appwork.storage
 * 
 * This software is licensed under the Artistic License 2.0,
 * see the LICENSE file or http://www.opensource.org/licenses/artistic-license-2.0.php
 * for details
 */
package org.appwork.storage;

import java.util.ArrayList;
import java.util.List;

import org.appwork.storage.simplejson.JSonFactory;
import org.appwork.storage.simplejson.JSonNode;
import org.appwork.storage.simplejson.ParserException;
import org.appwork.storage.simplejson.mapper.JSonMapper;
import org.appwork.storage.simplejson.mapper.MapperException;

/**
 * @author thomas
 * 
 */
public class SimpleMapper implements JSONMapper {
    private final JSonMapper mapper;

    public SimpleMapper() {
        mapper = new JSonMapper() {
            /*
             * (non-Javadoc)
             * 
             * @see
             * org.appwork.storage.simplejson.mapper.JSonMapper#create(java.
             * lang.Object)
             */
            @Override
            public JSonNode create(final Object obj) throws MapperException {
                for (final JsonSerializerEntry se : serializer) {
                    if (se.clazz.isAssignableFrom(obj.getClass())) { return new JSonNode() {
                     
                        @Override
                        public String toString() {                     
                            return se.serializer.toJSonString(obj);
                        }
                    }; }
                }
                return super.create(obj);
            }
        };
    }

    public JSonMapper getMapper() {
        return mapper;
    }

    class JsonSerializerEntry {
        /**<commit_msg>build>full<commit_after>/**
 * Copyright (c) 2009 - 2011 AppWork UG(haftungsbeschränkt) <<EMAIL>>
 * 
 * This file is part of org.appwork.storage
 * 
 * This software is licensed under the Artistic License 2.0,
 * see the LICENSE file or http://www.opensource.org/licenses/artistic-license-2.0.php
 * for details
 */
package org.appwork.storage;

import java.util.ArrayList;
import java.util.List;

import org.appwork.storage.simplejson.JSonFactory;
import org.appwork.storage.simplejson.JSonNode;
import org.appwork.storage.simplejson.ParserException;
import org.appwork.storage.simplejson.mapper.JSonMapper;
import org.appwork.storage.simplejson.mapper.MapperException;

/**
 * @author thomas
 * 
 */
public class SimpleMapper implements JSONMapper {
    private final JSonMapper mapper;

    public SimpleMapper() {
        mapper = new JSonMapper() {
            /*
             * (non-Javadoc)
             * 
             * @see
             * org.appwork.storage.simplejson.mapper.JSonMapper#create(java.
             * lang.Object)
             */
            @Override
            public JSonNode create(final Object obj) throws MapperException {
                for (final JsonSerializerEntry se : serializer) {
                    if (obj!=null&&se.clazz.isAssignableFrom(obj.getClass())) { return new JSonNode() {
                     
                        @Override
                        public String toString() {                     
                            return se.serializer.toJSonString(obj);
                        }
                    }; }
                }
                return super.create(obj);
            }
        };
    }

    public JSonMapper getMapper() {
        return mapper;
    }

    class JsonSerializerEntry {
        /**
{'fraction_non_alphanumeric': 0.09576271186440678, 'fraction_numerical': 0.006779661016949152, 'mean_word_length': 1.7772549019607844, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4927224', 'n_tokens_mistral': 993, 'n_tokens_neox': 940, 'n_words': 200}