<commit_before>/*******************************************************************************
 * Copyright (c) 2014 Whizzo Software, LLC.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package com.whizzosoftware.hobson.api.plugin;

import com.whizzosoftware.hobson.api.hub.HubContext;
import com.whizzosoftware.hobson.api.image.ImageInputStream;
import com.whizzosoftware.hobson.api.property.PropertyContainer;

import java.io.File;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class MockPluginManager implements PluginManager {
    private final Map<String,PropertyContainer> configMap = new HashMap<>();

    @Override
    public File getDataFile(PluginContext ctx, String filename) {
        return null;
    }

    @Override
    public HobsonPlugin getLocalPlugin(PluginContext ctx) {
        return null;
    }

    @Override
    public Collection<PluginDescriptor> getLocalPluginDescriptors(HubContext ctx) {
        return null;
    }

    @Override
    public Collection<PluginDescriptor> getRemotePluginDescriptors(HubContext ctx) {
        return null;
    }

    @Override
    public PluginDescriptor getRemotePluginDescriptor(PluginContext ctx, String version) {
        return null;
    }

    @Override
    public ImageInputStream getLocalPluginIcon(PluginContext ctx) {
        return null;
    }

    @Override
    public PropertyContainer getLocalPluginConfiguration(PluginContext ctx) {
        return configMap.get(ctx.getPluginId());
    }

    @Override
    public Object getLocalPluginConfigurationProperty(PluginContext ctx, String name) {
        Object value = null;
        PropertyContainer c = getLocalPluginConfiguration(ctx);
        if (c != null) {
            value = c.getPropertyValue(name);
        }
        return value;
    }

    @Override
    public void installRemotePlugin(PluginContext ctx, String pluginVersion) {

    }

    @Override
    public void setLocalPluginConfiguration(PluginContext ctx, PropertyContainer config) {
        configMap.put(ctx.getPluginId(), config);
    }

    @Override
    public void setLocalPluginConfigurationProperty(PluginContext ctx, String name, Object value) {
        PropertyContainer config = configMap.get(ctx.getPluginId());
        if (config == null) {
            config = new PropertyContainer();
            configMap.put(ctx.getPluginId(), config);
        }
        config.setPropertyValue(name, value);
    }

    @Override
    public void reloadLocalPlugin(PluginContext ctx) {

    }
}
<commit_msg>Added convenience method for plugins to access their data directory.<commit_after>/*******************************************************************************
 * Copyright (c) 2014 Whizzo Software, LLC.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package com.whizzosoftware.hobson.api.plugin;

import com.whizzosoftware.hobson.api.hub.HubContext;
import com.whizzosoftware.hobson.api.image.ImageInputStream;
import com.whizzosoftware.hobson.api.property.PropertyContainer;

import java.io.File;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class MockPluginManager implements PluginManager {
    private final Map<String,PropertyContainer> configMap = new HashMap<>();

    @Override
    public File getDataDirectory(PluginContext ctx) {
        return null;
    }

    @Override
    public File getDataFile(PluginContext ctx, String filename) {
        return null;
    }

    @Override
    public HobsonPlugin getLocalPlugin(PluginContext ctx) {
        return null;
    }

    @Override
    public Collection<PluginDescriptor> getLocalPluginDescriptors(HubContext ctx) {
        return null;
    }

    @Override
    public Collection<PluginDescriptor> getRemotePluginDescriptors(HubContext ctx) {
        return null;
    }

    @Override
    public PluginDescriptor getRemotePluginDescriptor(PluginContext ctx, String version) {
        return null;
    }

    @Override
    public ImageInputStream getLocalPluginIcon(PluginContext ctx) {
        return null;
    }

    @Override
    public PropertyContainer getLocalPluginConfiguration(PluginContext ctx) {
        return configMap.get(ctx.getPluginId());
    }

    @Override
    public Object getLocalPluginConfigurationProperty(PluginContext ctx, String name) {
        Object value = null;
        PropertyContainer c = getLocalPluginConfiguration(ctx);
        if (c != null) {
            value = c.getPropertyValue(name);
        }
        return value;
    }

    @Override
    public void installRemotePlugin(PluginContext ctx, String pluginVersion) {

    }

    @Override
    public void setLocalPluginConfiguration(PluginContext ctx, PropertyContainer config) {
        configMap.put(ctx.getPluginId(), config);
    }

    @Override
    public void setLocalPluginConfigurationProperty(PluginContext ctx, String name, Object value) {
        PropertyContainer config = configMap.get(ctx.getPluginId());
        if (config == null) {
            config = new PropertyContainer();
            configMap.put(ctx.getPluginId(), config);
        }
        config.setPropertyValue(name, value);
    }

    @Override
    public void reloadLocalPlugin(PluginContext ctx) {

    }
}

{'fraction_non_alphanumeric': 0.12942802833938138, 'fraction_numerical': 0.002764817694833247, 'mean_word_length': 3.539607843137255, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '1090839', 'n_tokens_mistral': 1484, 'n_tokens_neox': 1420, 'n_words': 376}